X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fconnectionmanager%2Fimplementation%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconnectionmanager%2Fscheme%2FAbstractScheme.java;h=78f274c717585993d13a3deeb86812a32ad4ad5a;hb=5ae6e41ad804baa665181d1e15c37bf6d8259bfb;hp=6b20909a877ce81de268c585c5e309be9fe7e2cf;hpb=abe7cd0f3412d447cf054e618ce1c7c7fa096745;p=controller.git diff --git a/opendaylight/connectionmanager/implementation/src/main/java/org/opendaylight/controller/connectionmanager/scheme/AbstractScheme.java b/opendaylight/connectionmanager/implementation/src/main/java/org/opendaylight/controller/connectionmanager/scheme/AbstractScheme.java index 6b20909a87..78f274c717 100644 --- a/opendaylight/connectionmanager/implementation/src/main/java/org/opendaylight/controller/connectionmanager/scheme/AbstractScheme.java +++ b/opendaylight/connectionmanager/implementation/src/main/java/org/opendaylight/controller/connectionmanager/scheme/AbstractScheme.java @@ -10,12 +10,11 @@ import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; -import javax.transaction.SystemException; - import org.opendaylight.controller.clustering.services.CacheConfigException; import org.opendaylight.controller.clustering.services.CacheExistException; import org.opendaylight.controller.clustering.services.IClusterGlobalServices; import org.opendaylight.controller.clustering.services.IClusterServices; +import org.opendaylight.controller.connectionmanager.ConnectionLocality; import org.opendaylight.controller.connectionmanager.ConnectionMgmtScheme; import org.opendaylight.controller.sal.core.Node; import org.opendaylight.controller.sal.utils.Status; @@ -75,6 +74,7 @@ public abstract class AbstractScheme { @SuppressWarnings("deprecation") public void handleClusterViewChanged() { + log.debug("Handling Cluster View changed notification"); List controllers = clusterServices.getClusteredControllers(); ConcurrentMap > controllerNodesMap = getControllerToNodesMap(); List toRemove = new ArrayList(); @@ -103,8 +103,8 @@ public abstract class AbstractScheme { clusterServices.tcommit(); } } catch (Exception e) { - log.error("Exception in replacing nodeConnections ", e); - retry = false; + log.debug("Exception in replacing nodeConnections ", e); + retry = true; try { clusterServices.trollback(); } catch (Exception e1) {} @@ -115,10 +115,8 @@ public abstract class AbstractScheme { } if (retry) { try { - Thread.sleep(100); - } catch (InterruptedException e) { - e.printStackTrace(); - } + Thread.sleep(1000); + } catch (InterruptedException e) {} handleClusterViewChanged(); } } @@ -129,7 +127,6 @@ public abstract class AbstractScheme { return controllerNodesMap.get(controller); } - @SuppressWarnings("deprecation") public Set getNodes() { return getNodes(clusterServices.getMyAddress()); } @@ -143,7 +140,6 @@ public abstract class AbstractScheme { return nodeConnections; } - @SuppressWarnings("deprecation") public boolean isLocal(Node node) { if (nodeConnections == null) return false; InetAddress myController = clusterServices.getMyAddress(); @@ -151,7 +147,15 @@ public abstract class AbstractScheme { return (controllers != null && controllers.contains(myController)); } - @SuppressWarnings("deprecation") + public ConnectionLocality getLocalityStatus(Node node) { + if (nodeConnections == null) return ConnectionLocality.NOT_CONNECTED; + Set controllers = nodeConnections.get(node); + if (controllers == null || controllers.size() == 0) return ConnectionLocality.NOT_CONNECTED; + InetAddress myController = clusterServices.getMyAddress(); + return controllers.contains(myController) ? ConnectionLocality.LOCAL: + ConnectionLocality.NOT_LOCAL; + } + public Status removeNode (Node node) { return removeNodeFromController(node, clusterServices.getMyAddress()); } @@ -238,13 +242,12 @@ public abstract class AbstractScheme { * with this controller to take hold of a Node. */ if (isConnectionAllowed(node)) { - if (!nodeConnections.replace(node, oldControllers, newControllers)) { + if (oldControllers == null || !nodeConnections.replace(node, oldControllers, newControllers)) { clusterServices.trollback(); try { Thread.sleep(100); } catch ( InterruptedException e) {} - log.debug("Replace failed... old={} with new={} for {} to {}", oldControllers.toString(), newControllers.toString(), - controller.getHostAddress(), node.toString()); + log.debug("Retrying ... {} with {}", controller.getHostAddress(), node.toString()); return putNodeToController(node, controller); } else { log.debug("Replace successful old={} with new={} for {} to {}", oldControllers.toString(), newControllers.toString(), @@ -315,7 +318,7 @@ public abstract class AbstractScheme { } catch (CacheConfigException cce) { log.error("\nCache configuration invalid - check cache mode"); } catch (Exception e) { - e.printStackTrace(); + log.error("An error occured",e); } } }