package org.opendaylight.controller.clustering.test.internal;
+import java.net.InetAddress;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
.getILoggerFactory();
if (lc != null) {
for (ch.qos.logback.classic.Logger l : lc.getLoggerList()) {
- if (loggerName == null || l.getName().startsWith(loggerName)) {
+ if ((loggerName == null) || l.getName().startsWith(loggerName)) {
ci.println(retrieveLogLevel(l));
}
}
ci.println(cacheName + " is no longer being monitored for updates");
}
+ public void _myController(CommandInterpreter ci) {
+ if (this.icluster == null) {
+ ci.println("\nNo Clustering services available");
+ return;
+ }
+ ci.println("This Controller : " +icluster.getMyAddress().getHostAddress());
+ }
+
+ public void _getClusterNodes(CommandInterpreter ci) {
+ if (this.icluster == null) {
+ ci.println("\nNo Clustering services available");
+ return;
+ }
+ for (InetAddress address : icluster.getClusteredControllers()) {
+ ci.println("\t"+address.getHostAddress());
+ }
+ }
+
public void _listcaches(CommandInterpreter ci) {
if (this.icluster == null) {
ci.println("\nNo Clustering services available");
return;
}
- String containerName = ci.nextArgument();
+ String containerName = ci.nextArgument().toLowerCase();
if (containerName == null) {
ci.println("containerName not supplied");
return;
containerName, cacheName);
if (c != null) {
ci.println("\nAdd mapping " + key + " = " + sValue);
- c.put(key, new StringContainer(sValue));
+ try {
+ c.put(key, new StringContainer(sValue));
+ } catch (Exception e) {
+ ci.println("Exception raised:" + e);
+ ci.println("\tStacktrace:");
+ e.printStackTrace();
+ }
} else {
ci.println("Cache " + cacheName + " on container " + containerName
+ " not existant!");
public void _dumper(CommandInterpreter ci) {
ConcurrentMap<Object, Object> c;
- String containerName = ci.nextArgument();
+ String containerName = ci.nextArgument().toLowerCase();
if (containerName == null) {
ci.println("containerName not supplied");
return;
ci.println("Cache not supplied");
return;
}
+ int count = 0;
c = (ConcurrentMap<Object, Object>) this.icluster.getCache(containerName, cacheName);
if (c != null) {
for (Map.Entry<Object, Object> e : c.entrySet()) {
ci.println("Element " + entry.getKey() + "(hashCode="
+ entry.getKey().hashCode() + ") has value = (" + res
+ ")");
+ count++;
}
+ ci.println("Dumped " + count + " records");
} else {
ci.println("Cache " + cacheName + " on container " + containerName
+ " not existant!");
}
}
- @SuppressWarnings("deprecation") //TODO: remove call to deprecated amIStandby
- public void _getRole(CommandInterpreter ci) {
- if (this.icluster == null) {
- ci.println("\nNo Clustering services available");
- return;
- }
- String role = "Active";
- if (this.icluster.amIStandby()) {
- role = "Standby";
- }
- ci.println("My role is: " + role);
- }
-
- @SuppressWarnings("deprecation") //TODO: remove call to deprecated getActiveAddres
- public void _getActive(CommandInterpreter ci) {
- if (this.icluster == null) {
- ci.println("\nNo Clustering services available");
- return;
- }
- ci.println("Current active address is "
- + this.icluster.getActiveAddress());
- }
-
@SuppressWarnings("deprecation") //TODO: remove use of deprecated listenRoleChange
public void _listenActive(CommandInterpreter ci) {
if (this.icluster == null) {
}
class DoListenRoleChanged implements IListenRoleChange {
+ @Override
public void newActiveAvailable() {
logger.debug("New Active is available");
}
help.append("\tunlistenActive - UNListen to Active updates\n");
help.append("\tdestroy - Destroy a cache\n");
help.append("\tcreate - Create a cache\n");
- help.append("\tgetRole - Tell if active or standby\n");
- help.append("\tgetActive - Report the IP address of Active\n");
- help
- .append("\tputComplex - Fill a more complex data structure\n");
- help
- .append("\tupdateComplex - Update the value of a more complex data structure\n");
- help
- .append("\tgetLogLevel - Get the loglevel for the logger specified\n");
- help
- .append("\tsetLogLevel - Set the loglevel for the logger specified\n");
+ help.append("\tmyController - Print this controller's Cluster identifier\n");
+ help.append("\tgetClusterNodes - Print all the controllers that make this cluster\n");
+ help.append("\tputComplex - Fill a more complex data structure\n");
+ help.append("\tupdateComplex - Update the value of a more complex data structure\n");
+ help.append("\tgetLogLevel - Get the loglevel for the logger specified\n");
+ help.append("\tsetLogLevel - Set the loglevel for the logger specified\n");
return help.toString();
}
}