X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fclustering%2Ftest%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fclustering%2Ftest%2Finternal%2FSimpleClient.java;h=52cc56e377e0529c3c39ca4ecf8cd278614cc904;hb=20a6da0545abbfddde09a9ba423489f3032b40c9;hp=b6ab95db33fff81260879bb97065b2fafbf840bd;hpb=f6fdaa2c3a3542264c4fa0e92e9ca14ed6f26b66;p=controller.git diff --git a/opendaylight/clustering/test/src/main/java/org/opendaylight/controller/clustering/test/internal/SimpleClient.java b/opendaylight/clustering/test/src/main/java/org/opendaylight/controller/clustering/test/internal/SimpleClient.java index b6ab95db33..52cc56e377 100644 --- a/opendaylight/clustering/test/src/main/java/org/opendaylight/controller/clustering/test/internal/SimpleClient.java +++ b/opendaylight/clustering/test/src/main/java/org/opendaylight/controller/clustering/test/internal/SimpleClient.java @@ -9,6 +9,7 @@ package org.opendaylight.controller.clustering.test.internal; +import java.net.InetAddress; import java.util.ArrayList; import java.util.EnumSet; import java.util.List; @@ -151,7 +152,7 @@ public class SimpleClient implements CommandProvider { .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)); } } @@ -268,12 +269,30 @@ public class SimpleClient implements CommandProvider { 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; @@ -325,7 +344,13 @@ public class SimpleClient implements CommandProvider { 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!"); @@ -372,7 +397,7 @@ public class SimpleClient implements CommandProvider { public void _dumper(CommandInterpreter ci) { ConcurrentMap c; - String containerName = ci.nextArgument(); + String containerName = ci.nextArgument().toLowerCase(); if (containerName == null) { ci.println("containerName not supplied"); return; @@ -382,6 +407,7 @@ public class SimpleClient implements CommandProvider { ci.println("Cache not supplied"); return; } + int count = 0; c = (ConcurrentMap) this.icluster.getCache(containerName, cacheName); if (c != null) { for (Map.Entry e : c.entrySet()) { @@ -394,7 +420,9 @@ public class SimpleClient implements CommandProvider { 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!"); @@ -438,29 +466,6 @@ public class SimpleClient implements CommandProvider { } } - @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) { @@ -490,6 +495,7 @@ public class SimpleClient implements CommandProvider { } class DoListenRoleChanged implements IListenRoleChange { + @Override public void newActiveAvailable() { logger.debug("New Active is available"); } @@ -636,16 +642,12 @@ public class SimpleClient implements CommandProvider { 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(); } }