From fa0dd8a228e77759fe688b04bdb79fabd01943b0 Mon Sep 17 00:00:00 2001 From: Kelven Yang Date: Mon, 28 Mar 2011 15:12:47 -0700 Subject: [PATCH] Allow cluster management confliction detection to handle quick manageemnt server restarts --- .../com/cloud/cluster/ClusterManagerImpl.java | 18 +++++++++++++----- .../cloud/utils/exception/ExceptionUtil.java | 2 +- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/server/src/com/cloud/cluster/ClusterManagerImpl.java b/server/src/com/cloud/cluster/ClusterManagerImpl.java index 3cc9dd7849a..3c475b318af 100644 --- a/server/src/com/cloud/cluster/ClusterManagerImpl.java +++ b/server/src/com/cloud/cluster/ClusterManagerImpl.java @@ -934,14 +934,22 @@ public class ClusterManagerImpl implements ClusterManager { String peerIP = peer.getServiceIP().trim(); if(_clusterNodeIP.equals(peerIP)) { if("127.0.0.1".equals(_clusterNodeIP)) { - String msg = "Detected another management node with localhost IP is already running, please check your cluster configuration"; - s_logger.error(msg); - throw new ConfigurationException(msg); + if(pingManagementNode(peer.getMsid())) { + String msg = "Detected another management node with localhost IP is already running, please check your cluster configuration"; + s_logger.error(msg); + throw new ConfigurationException(msg); + } else { + String msg = "Detected another management node with localhost IP is considered as running in DB, however it is not pingable, we will continue cluster initialization with this management server node"; + s_logger.info(msg); + } } else { - if(!pingManagementNode(peer.getMsid())) { - String msg = "Detected that another management node with the same IP " + peer.getServiceIP() + " is already running"; + if(pingManagementNode(peer.getMsid())) { + String msg = "Detected that another management node with the same IP " + peer.getServiceIP() + " is already running, please check your cluster configuration"; s_logger.error(msg); throw new ConfigurationException(msg); + } else { + String msg = "Detected that another management node with the same IP " + peer.getServiceIP() + " is considered as running in DB, however it is not pingable, we will continue cluster initialization with this management server node"; + s_logger.info(msg); } } } diff --git a/utils/src/com/cloud/utils/exception/ExceptionUtil.java b/utils/src/com/cloud/utils/exception/ExceptionUtil.java index 5a0bfe5fa7b..9c494a249a7 100644 --- a/utils/src/com/cloud/utils/exception/ExceptionUtil.java +++ b/utils/src/com/cloud/utils/exception/ExceptionUtil.java @@ -23,11 +23,11 @@ import java.io.StringWriter; public class ExceptionUtil { public static String toString(Throwable th) { final StringWriter writer = new StringWriter(); + writer.append("Exception: " + th.getClass().getName() + "\n"); writer.append("Message: "); writer.append(th.getMessage()); writer.append("\n Stack: "); th.printStackTrace(new PrintWriter(writer)); return writer.toString(); } - }