Skip to content

Commit 6d0bb6d

Browse files
committed
Revert "bug 13379: throw exception, if master cannot connect to slave"
This reverts commit 01768176fcd4b0dfe72baf16039e073d18344578.
1 parent 38ada9c commit 6d0bb6d

1 file changed

Lines changed: 35 additions & 19 deletions

File tree

‎core/src/com/cloud/hypervisor/xen/resource/XenServerConnectionPool.java‎

Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -531,12 +531,13 @@ public Connection connect(String hostUuid, String poolUuid, String ipAddress,
531531
s_logger.debug(msg);
532532
throw new CloudRuntimeException(msg);
533533
}
534+
Host host = null;
534535
synchronized (poolUuid.intern()) {
535536
// Let's see if it is an existing connection.
536537
mConn = getConnect(poolUuid);
537538
if (mConn != null){
538539
try{
539-
Host.getByUuid(mConn, hostUuid);
540+
host = Host.getByUuid(mConn, hostUuid);
540541
} catch (Types.SessionInvalid e) {
541542
s_logger.debug("Session thgrough ip " + mConn.getIp() + " is invalid for pool(" + poolUuid + ") due to " + e.toString());
542543
try {
@@ -635,6 +636,39 @@ public Connection connect(String hostUuid, String poolUuid, String ipAddress,
635636
}
636637
}
637638
}
639+
640+
if ( mConn != null ) {
641+
if (s_managePool) {
642+
try {
643+
Map<String, String> args = new HashMap<String, String>();
644+
host.callPlugin(mConn, "vmops", "pingxenserver", args);
645+
} catch (Types.CannotContactHost e ) {
646+
if (s_logger.isDebugEnabled()) {
647+
String msg = "Catch Exception: " + e.getClass().getName() + " Can't connect host " + ipAddress + " due to " + e.toString();
648+
s_logger.debug(msg);
649+
}
650+
PoolEmergencyResetMaster(ipAddress, mConn.getIp(), mConn.getUsername(), mConn.getPassword());
651+
} catch (Types.HostOffline e ) {
652+
if (s_logger.isDebugEnabled()) {
653+
String msg = "Catch Exception: " + e.getClass().getName() + " Host is offline " + ipAddress + " due to " + e.toString();
654+
s_logger.debug(msg);
655+
}
656+
PoolEmergencyResetMaster(ipAddress, mConn.getIp(), mConn.getUsername(), mConn.getPassword());
657+
} catch (Types.HostNotLive e ) {
658+
String msg = "Catch Exception: " + e.getClass().getName() + " Host Not Live " + ipAddress + " due to " + e.toString();
659+
if (s_logger.isDebugEnabled()) {
660+
s_logger.debug(msg);
661+
}
662+
PoolEmergencyResetMaster(ipAddress, mConn.getIp(), mConn.getUsername(), mConn.getPassword());
663+
} catch (Exception e) {
664+
String msg = "Master can not talk to Slave " + hostUuid + " IP " + ipAddress;
665+
if (s_logger.isDebugEnabled()) {
666+
s_logger.debug(msg);
667+
}
668+
throw new CloudRuntimeException(msg);
669+
}
670+
}
671+
}
638672
return mConn;
639673
}
640674

@@ -879,24 +913,6 @@ protected Map dispatch(String method_call, Object[] method_params) throws XmlRp
879913
}
880914
loginWithPassword(this, _username, _password, APIVersion.latest().toString());
881915
method_params[0] = getSessionReference();
882-
} catch (Types.CannotContactHost e ) {
883-
if (s_logger.isDebugEnabled()) {
884-
String msg = "Cannot Contact Host for method: " + method_call + " due to " + e.toString();
885-
s_logger.debug(msg);
886-
}
887-
throw e;
888-
} catch (Types.HostOffline e ) {
889-
if (s_logger.isDebugEnabled()) {
890-
String msg = "Host Offline for method: " + method_call + " due to " + e.toString();
891-
s_logger.debug(msg);
892-
}
893-
throw e;
894-
} catch (Types.HostNotLive e ) {
895-
if (s_logger.isDebugEnabled()) {
896-
String msg = "Host is Not alive for method: " + method_call + " due to " + e.toString();
897-
s_logger.debug(msg);
898-
}
899-
throw e;
900916
} catch (XmlRpcClientException e) {
901917
s_logger.debug("XmlRpcClientException for method: " + method_call + " due to " + e.getMessage());
902918
removeConnect(_poolUuid);

0 commit comments

Comments
 (0)