Code Review
/
controller.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Add some log messages in case controller failed to add connected node.
[controller.git]
/
opendaylight
/
connectionmanager
/
implementation
/
src
/
main
/
java
/
org
/
opendaylight
/
controller
/
connectionmanager
/
scheme
/
AbstractScheme.java
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 78f274c717585993d13a3deeb86812a32ad4ad5a..718a3ff166e1a7ae72cae6175da0aaef12542e4c 100644
(file)
--- 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
@@
-2,6
+2,7
@@
package org.opendaylight.controller.connectionmanager.scheme;
import java.net.InetAddress;
import java.util.ArrayList;
import java.net.InetAddress;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.Iterator;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.Iterator;
@@
-14,8
+15,8
@@
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.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.connectionmanager.ConnectionMgmtScheme;
+import org.opendaylight.controller.sal.connection.ConnectionLocality;
import org.opendaylight.controller.sal.core.Node;
import org.opendaylight.controller.sal.utils.Status;
import org.opendaylight.controller.sal.utils.StatusCode;
import org.opendaylight.controller.sal.core.Node;
import org.opendaylight.controller.sal.utils.Status;
import org.opendaylight.controller.sal.utils.StatusCode;
@@
-35,15
+36,18
@@
public abstract class AbstractScheme {
*/
protected ConcurrentMap <Node, Set<InetAddress>> nodeConnections;
protected abstract boolean isConnectionAllowedInternal(Node node);
*/
protected ConcurrentMap <Node, Set<InetAddress>> nodeConnections;
protected abstract boolean isConnectionAllowedInternal(Node node);
- private String name;
+ private final String name;
+ private final String nodeConnectionsCacheName;
protected AbstractScheme(IClusterGlobalServices clusterServices, ConnectionMgmtScheme type) {
this.clusterServices = clusterServices;
protected AbstractScheme(IClusterGlobalServices clusterServices, ConnectionMgmtScheme type) {
this.clusterServices = clusterServices;
-
if (type != null) name = type.name(
);
-
else name = "UNKNOWN
";
+
name = (type != null ? type.name() : "UNKNOWN"
);
+
nodeConnectionsCacheName = "connectionmanager."+name+".nodeconnections
";
if (clusterServices != null) {
allocateCaches();
retrieveCaches();
if (clusterServices != null) {
allocateCaches();
retrieveCaches();
+ } else {
+ log.error("Couldn't retrieve caches for scheme %s. Clustering service unavailable", name);
}
}
}
}
@@
-72,7
+76,6
@@
public abstract class AbstractScheme {
return isConnectionAllowedInternal(node);
}
return isConnectionAllowedInternal(node);
}
- @SuppressWarnings("deprecation")
public void handleClusterViewChanged() {
log.debug("Handling Cluster View changed notification");
List<InetAddress> controllers = clusterServices.getClusteredControllers();
public void handleClusterViewChanged() {
log.debug("Handling Cluster View changed notification");
List<InetAddress> controllers = clusterServices.getClusteredControllers();
@@
-122,7
+125,6
@@
public abstract class AbstractScheme {
}
public Set<Node> getNodes(InetAddress controller) {
}
public Set<Node> getNodes(InetAddress controller) {
- if (nodeConnections == null) return null;
ConcurrentMap <InetAddress, Set<Node>> controllerNodesMap = getControllerToNodesMap();
return controllerNodesMap.get(controller);
}
ConcurrentMap <InetAddress, Set<Node>> controllerNodesMap = getControllerToNodesMap();
return controllerNodesMap.get(controller);
}
@@
-133,7
+135,7
@@
public abstract class AbstractScheme {
public Set<InetAddress> getControllers(Node node) {
if (nodeConnections != null) return nodeConnections.get(node);
public Set<InetAddress> getControllers(Node node) {
if (nodeConnections != null) return nodeConnections.get(node);
- return
null
;
+ return
Collections.emptySet()
;
}
public ConcurrentMap<Node, Set<InetAddress>> getNodeConnections() {
}
public ConcurrentMap<Node, Set<InetAddress>> getNodeConnections() {
@@
-162,7
+164,7
@@
public abstract class AbstractScheme {
protected Status removeNodeFromController (Node node, InetAddress controller) {
if (node == null || controller == null) {
protected Status removeNodeFromController (Node node, InetAddress controller) {
if (node == null || controller == null) {
- return new Status(StatusCode.BADREQUEST);
+ return new Status(StatusCode.BADREQUEST
, "Invalid Node or Controller Address Specified."
);
}
if (clusterServices == null || nodeConnections == null) {
}
if (clusterServices == null || nodeConnections == null) {
@@
-189,7
+191,7
@@
public abstract class AbstractScheme {
}
clusterServices.tcommit();
} catch (Exception e) {
}
clusterServices.tcommit();
} catch (Exception e) {
- log.error("Excepion in removing Controller from a Node", e);
+ log.error("Excep
t
ion in removing Controller from a Node", e);
try {
clusterServices.trollback();
} catch (Exception e1) {
try {
clusterServices.trollback();
} catch (Exception e1) {
@@
-210,7
+212,7
@@
public abstract class AbstractScheme {
*/
private Status putNodeToController (Node node, InetAddress controller) {
if (clusterServices == null || nodeConnections == null) {
*/
private Status putNodeToController (Node node, InetAddress controller) {
if (clusterServices == null || nodeConnections == null) {
- return new Status(StatusCode.
SUCCESS
);
+ return new Status(StatusCode.
INTERNALERROR, "Cluster service unavailable, or node connections info missing."
);
}
log.debug("Trying to Put {} to {}", controller.getHostAddress(), node.toString());
}
log.debug("Trying to Put {} to {}", controller.getHostAddress(), node.toString());
@@
-275,9
+277,16
@@
public abstract class AbstractScheme {
public Status addNode (Node node, InetAddress controller) {
if (node == null || controller == null) {
public Status addNode (Node node, InetAddress controller) {
if (node == null || controller == null) {
+ if (node == null) {
+ log.warn("addNode: node is null");
+ } else if (controller == null) {
+ log.error("Failed to add node {}. The controller address retrieved from clusterServices is null.", node);
+ }
return new Status(StatusCode.BADREQUEST);
}
return new Status(StatusCode.BADREQUEST);
}
- if (isLocal(node)) return new Status(StatusCode.SUCCESS);
+ if (isLocal(node)) {
+ return new Status(StatusCode.SUCCESS);
+ }
if (isConnectionAllowed(node)) {
return putNodeToController(node, controller);
} else {
if (isConnectionAllowed(node)) {
return putNodeToController(node, controller);
} else {
@@
-285,36
+294,34
@@
public abstract class AbstractScheme {
}
}
}
}
- @SuppressWarnings("deprecation")
public Status addNode (Node node) {
return addNode(node, clusterServices.getMyAddress());
}
public Status addNode (Node node) {
return addNode(node, clusterServices.getMyAddress());
}
- @SuppressWarnings({ "unchecked"
, "deprecation"
})
+ @SuppressWarnings({ "unchecked" })
private void retrieveCaches() {
if (this.clusterServices == null) {
private void retrieveCaches() {
if (this.clusterServices == null) {
- log.error("
un-initialized clusterServices, can't retrieve cache"
);
+ log.error("
Un-initialized Cluster Services, can't retrieve caches for scheme: {}", name
);
return;
}
return;
}
- nodeConnections = (ConcurrentMap<Node, Set<InetAddress>>) clusterServices.getCache(
"connectionmanager."+name+".nodeconnections"
);
+ nodeConnections = (ConcurrentMap<Node, Set<InetAddress>>) clusterServices.getCache(
nodeConnectionsCacheName
);
if (nodeConnections == null) {
if (nodeConnections == null) {
- log.error("\nFailed to get cache
s"
);
+ log.error("\nFailed to get cache
: {}", nodeConnectionsCacheName
);
}
}
}
}
- @SuppressWarnings("deprecation")
private void allocateCaches() {
if (this.clusterServices == null) {
private void allocateCaches() {
if (this.clusterServices == null) {
- log.error("
u
n-initialized clusterServices, can't create cache");
+ log.error("
U
n-initialized clusterServices, can't create cache");
return;
}
try {
return;
}
try {
- clusterServices.createCache(
"connectionmanager."+name+".nodeconnections"
, EnumSet.of(IClusterServices.cacheMode.TRANSACTIONAL));
+ clusterServices.createCache(
nodeConnectionsCacheName
, EnumSet.of(IClusterServices.cacheMode.TRANSACTIONAL));
} catch (CacheExistException cee) {
} catch (CacheExistException cee) {
- log.
error("\nCache already exists - destroy and recreate if needed"
);
+ log.
debug("\nCache already exists: {}", nodeConnectionsCacheName
);
} catch (CacheConfigException cce) {
log.error("\nCache configuration invalid - check cache mode");
} catch (Exception e) {
} catch (CacheConfigException cce) {
log.error("\nCache configuration invalid - check cache mode");
} catch (Exception e) {