--- /dev/null
+package org.opendaylight.controller.connectionmanager;
+
+public enum ConnectionLocality {
+ /**
+ * This controller is the (or one of the) master for a given node
+ */
+ LOCAL("This controller is the (or one of the) master for a given node"),
+
+ /**
+ * This controller is not the master for a given node
+ */
+ NOT_LOCAL("This controller is not the master for a given node"),
+
+ /**
+ * The given node is not connected to any of the controllers in the cluster
+ */
+ NOT_CONNECTED("The given node is not connected to any of the controllers in the cluster");
+
+ private ConnectionLocality(String description) {
+ this.description = description;
+ }
+
+ private String description;
+
+ public String toString() {
+ return description;
+ }
+}
public Set<Node> getLocalNodes();
/**
+ * @deprecated Use getLocalityStatus(Node node) instead.
+ *
* Method to test if a node is local to a controller.
*
- * @return true if node is local to this controller. false otherwise.
+ * @param node The node for which the locality is being tested
+ * @return true if node is local to this controller.<br>
+ * false if either node is not connected to this controller or
+ * not connected to any other controllers in the cluster.
*/
public boolean isLocal(Node node);
+ /**
+ * getLocalityStatus provides the tri-state connectivity status as opposed to the
+ * binary status returned by isLocal.
+ * ConnectionLocality enum that is returned by this method also includes the case of
+ * a Node not connected to any of the controllers in the cluster.
+ * @param node The node for which the locality is being verified
+ * @return ConnectionLocality
+ */
+ public ConnectionLocality getLocalityStatus(Node node);
+
/**
* Disconnect a Node from the controller.
*
import org.opendaylight.controller.clustering.services.ICacheUpdateAware;
import org.opendaylight.controller.clustering.services.IClusterGlobalServices;
import org.opendaylight.controller.clustering.services.ICoordinatorChangeAware;
+import org.opendaylight.controller.connectionmanager.ConnectionLocality;
import org.opendaylight.controller.connectionmanager.ConnectionMgmtScheme;
import org.opendaylight.controller.connectionmanager.IConnectionManager;
import org.opendaylight.controller.connectionmanager.scheme.AbstractScheme;
return scheme.isLocal(node);
}
+ @Override
+ public ConnectionLocality getLocalityStatus(Node node) {
+ AbstractScheme scheme = schemes.get(activeScheme);
+ if (scheme == null) return ConnectionLocality.NOT_CONNECTED;
+ return scheme.getLocalityStatus(node);
+ }
+
@Override
public void updateNode(Node node, UpdateType type, Set<Property> props) {
logger.debug("updateNode: {} type {} props {}", node, type, props);
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;
return (controllers != null && controllers.contains(myController));
}
+ public ConnectionLocality getLocalityStatus(Node node) {
+ if (nodeConnections == null) return ConnectionLocality.NOT_CONNECTED;
+ Set<InetAddress> 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());
}
import org.opendaylight.controller.clustering.services.IClusterContainerServices;
import org.opendaylight.controller.clustering.services.IClusterServices;
import org.opendaylight.controller.configuration.IConfigurationContainerAware;
+import org.opendaylight.controller.connectionmanager.ConnectionLocality;
import org.opendaylight.controller.connectionmanager.IConnectionManager;
import org.opendaylight.controller.forwardingrulesmanager.FlowConfig;
import org.opendaylight.controller.forwardingrulesmanager.FlowEntry;
}
Node n = e.getNode();
- if (!connectionManager.isLocal(n)) {
+ if (connectionManager.getLocalityStatus(n) == ConnectionLocality.NOT_LOCAL) {
Callable<Future<Status>> worker = new DistributeOrderCallable(e, u, t);
if (worker != null) {
Future<Future<Status>> workerRes = this.executor.submit(worker);
}
}
- logsync.trace("LOCAL Node {} so processing Entry:{} UpdateType:{}", n, e, t);
+ logsync.trace("Node {} could be local. so processing Entry:{} UpdateType:{}", n, e, t);
return null;
}
return;
}
Node n = fei.getNode();
- if (connectionManager.isLocal(n)) {
+ if (connectionManager.getLocalityStatus(n) == ConnectionLocality.LOCAL) {
logsync.trace("workOrder for fe {} processed locally", fe);
// I'm the controller in charge for the request, queue it for
// processing