Skip to content

Commit

Permalink
HA-vcenter plugin failed to reconnect
Browse files Browse the repository at this point in the history
Closes-Bug: #1550603

Change-Id: Ia37dd0c8009b7b33013f5f1e5d0a952d21d3966f
  • Loading branch information
Andra Cismaru committed Mar 3, 2016
1 parent 6b4b611 commit 5d8883a
Show file tree
Hide file tree
Showing 6 changed files with 124 additions and 202 deletions.
24 changes: 12 additions & 12 deletions src/net/juniper/contrail/sandesh/VCenterPluginResp.java
Expand Up @@ -7,14 +7,14 @@
import net.juniper.contrail.vcenter.VRouterNotifier;
import net.juniper.contrail.vcenter.VncDB;

public class VCenterPluginResp {
public class VCenterPluginResp {
private VCenterPlugin vCenterPluginInfo;

public VCenterPluginResp(VCenterPluginReq req) {
vCenterPluginInfo = new VCenterPlugin();

vCenterPluginInfo.setMaster(VCenterMonitor.isZookeeperLeader());

if (VCenterMonitor.isZookeeperLeader()) {
populateVRouterStats();
populateApiServerInfo();
Expand All @@ -29,8 +29,8 @@ private void populatePluginState() {
&& (vCenterPluginInfo.getVCenterServerInfo().getConnected() == true)
&& (( vCenterPluginInfo.getVRouterStats().getDown() == 0)));
}
private void populateVRouterStats() {

private void populateVRouterStats() {
int up = 0;
int down = 0;

Expand All @@ -52,7 +52,7 @@ private void populateVRouterStats() {
vCenterPluginInfo.getVRouterStats().setUp(up);
vCenterPluginInfo.getVRouterStats().setDown(down);
}

private void populateApiServerInfo() {
ApiServerInfo apiServerInfo = vCenterPluginInfo.getApiServerInfo();
VncDB vncDB = VCenterNotify.getVncDB();
Expand All @@ -62,15 +62,15 @@ private void populateApiServerInfo() {
apiServerInfo.setConnected(vncDB.isServerAlive());
}
}

private void populateVCenterServerInfo() {
VCenterServerInfo vCenterServerInfo = vCenterPluginInfo.getVCenterServerInfo();

if (VCenterNotify.getVcenterDB() != null) {
vCenterServerInfo.setUrl(VCenterNotify.getVcenterDB().getVcenterUrl() );

vCenterServerInfo.setConnected(
VCenterNotify.getVcenterDB().isConnected());
VCenterNotify.getVCenterConnected());
}
}

Expand All @@ -81,6 +81,6 @@ public void writeObject(StringBuilder s) {
}
s.append("<vCenterPluginIntrospect type=\"sandesh\">");
vCenterPluginInfo.writeObject(s);
s.append("</vCenterPluginIntrospect>");
s.append("</vCenterPluginIntrospect>");
}
}
16 changes: 10 additions & 6 deletions src/net/juniper/contrail/vcenter/VCenterDB.java
Expand Up @@ -10,6 +10,7 @@
import java.net.URL;
import java.util.HashMap;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.Hashtable;
import java.util.Map;
Expand Down Expand Up @@ -63,6 +64,7 @@ public class VCenterDB {
Logger.getLogger(VCenterDB.class);
private static final String esxiToVRouterIpMapFile = "/etc/contrail/ESXiToVRouterIp.map";
static final int VCENTER_READ_TIMEOUT = 30000; //30 sec
static final int VCENTER_WAIT_FOR_UPDATES_TIMEOUT = 120; // 120 seconds
protected final String contrailDvSwitchName;
public final String contrailDataCenterName;
private final String vcenterUrl;
Expand Down Expand Up @@ -261,8 +263,6 @@ public void setReadTimeout(int milliSecs) {
serviceInstance.getServerConnection()
.getVimService()
.getWsc().setReadTimeout(milliSecs);
s_logger.info("ServiceInstance read timeout set to " +
serviceInstance.getServerConnection().getVimService().getWsc().getReadTimeout());
}

public boolean isConnected() {
Expand Down Expand Up @@ -987,10 +987,14 @@ public void readVirtualMachineInterfaces(VirtualMachineInfo vmInfo)
}

public boolean isAlive() {
Folder folder = serviceInstance.getRootFolder();
if (folder == null) {
String msg = "Failed aliveness check for vCenter " + vcenterUrl;
s_logger.error(msg);
try {
Calendar currTime = serviceInstance.currentTime();
if (currTime == null) {
String msg = "Failed aliveness check for vCenter " + vcenterUrl;
s_logger.error(msg);
return false;
}
} catch (Exception e) {
return false;
}
return true;
Expand Down
6 changes: 2 additions & 4 deletions src/net/juniper/contrail/vcenter/VCenterMonitor.java
Expand Up @@ -176,16 +176,14 @@ public static void main(String[] args) throws Exception {
_apiServerAddress, _apiServerPort, _username, _password,
_tenant,
_authtype, _authurl, mode);
VCenterMonitorTask _monitorTask = new VCenterMonitorTask(_eventMonitor,
_vcenterURL, _vcenterUsername, _vcenterPassword,
_vcenterDcName, _vcenterDvsName, _vcenterIpFabricPg);

s_logger.info("Starting the notify task.. ");
_eventMonitor.start();
s_logger.info("Notify task started.");

// Launch the periodic VCenterMonitorTask
s_logger.info("Starting periodic monitor task.. ");
VRouterMonitorTask _monitorTask = new VRouterMonitorTask();
s_logger.info("Starting vrouter periodic monitor task.. ");
scheduledTaskExecutor.scheduleWithFixedDelay(_monitorTask, 0, 8, //8 second periodic
TimeUnit.SECONDS);
s_logger.info("Periodic monitor task started.");
Expand Down
88 changes: 0 additions & 88 deletions src/net/juniper/contrail/vcenter/VCenterMonitorTask.java

This file was deleted.

0 comments on commit 5d8883a

Please sign in to comment.