Simpleforwarding cache synch doesn't work
[controller.git] / opendaylight / clustering / services_implementation / src / main / java / org / opendaylight / controller / clustering / services_implementation / internal / ClusterManager.java
index 632f550ffe342d585cfaf1e27cba0dac344e7f6b..0b2610797fe507f210bf09af989fa4ee643c21ab 100644 (file)
@@ -62,7 +62,7 @@ public class ClusterManager implements IClusterServices {
             .getLogger(ClusterManager.class);
     private DefaultCacheManager cm;
     GossipRouter gossiper;
-    private HashSet roleChangeListeners;
+    private HashSet<IListenRoleChange> roleChangeListeners;
     private ViewChangedListener cacheManagerListener;
 
     private static String loopbackAddress = "127.0.0.1";
@@ -97,10 +97,10 @@ public class ClusterManager implements IClusterServices {
         if (supernodes.hasMoreTokens()) {
             // Populate the list of my addresses
             try {
-                Enumeration e = NetworkInterface.getNetworkInterfaces();
+                Enumeration<NetworkInterface> e = NetworkInterface.getNetworkInterfaces();
                 while (e.hasMoreElements()) {
                     NetworkInterface n = (NetworkInterface) e.nextElement();
-                    Enumeration ee = n.getInetAddresses();
+                    Enumeration<InetAddress> ee = n.getInetAddresses();
                     while (ee.hasMoreElements()) {
                         InetAddress i = (InetAddress) ee.nextElement();
                         myAddresses.add(i);
@@ -113,15 +113,15 @@ public class ClusterManager implements IClusterServices {
         }
         while (supernodes.hasMoreTokens()) {
             String curr_supernode = supernodes.nextToken();
-            logger.debug("Examining supernode " + curr_supernode);
+            logger.debug("Examining supernode {}", curr_supernode);
             StringTokenizer host_port = new StringTokenizer(curr_supernode,
                     "[]");
             String host;
             String port;
             Integer port_num = gossipRouterPortDefault;
             if (host_port.countTokens() > 2) {
-                logger.error("Error parsing supernode " + curr_supernode
-                        + " proceed to the next one");
+                logger.error("Error parsing supernode {} proceed to the next one",
+                        curr_supernode);
                 continue;
             }
             host = host_port.nextToken();
@@ -184,13 +184,13 @@ public class ClusterManager implements IClusterServices {
                     for (InetAddress myAddr : myAddresses) {
                         if (myAddr.isLoopbackAddress()
                                 || myAddr.isLinkLocalAddress()) {
-                            logger.debug("Skipping local address "
-                                    + myAddr.getHostAddress());
+                            logger.debug("Skipping local address {}",
+                                         myAddr.getHostAddress());
                             continue;
                         } else {
                             // First non-local address
                             myBind = myAddr.getHostAddress();
-                            logger.debug("First non-local address " + myBind);
+                            logger.debug("First non-local address {}", myBind);
                             break;
                         }
                     }
@@ -199,7 +199,7 @@ public class ClusterManager implements IClusterServices {
                         .getProperty("jgroups.tcp.address");
                 if (jgroupAddress == null) {
                     if (myBind != null) {
-                        logger.debug("Set bind address to be " + myBind);
+                        logger.debug("Set bind address to be {}", myBind);
                         System.setProperty("jgroups.tcp.address", myBind);
                     } else {
                         logger
@@ -207,8 +207,8 @@ public class ClusterManager implements IClusterServices {
                         System.setProperty("jgroups.tcp.address", "127.0.0.1");
                     }
                 } else {
-                    logger.debug("jgroup.tcp.address already set to be "
-                            jgroupAddress);
+                    logger.debug("jgroup.tcp.address already set to be {}",
+                            jgroupAddress);
                 }
             } catch (UnknownHostException uhe) {
                 logger
@@ -220,14 +220,14 @@ public class ClusterManager implements IClusterServices {
         // host list
         System.setProperty("jgroups.tcpgossip.initial_hosts",
                 sanitized_supernodes_list.toString());
-        logger.debug("jgroups.tcp.address set to "
-                System.getProperty("jgroups.tcp.address"));
-        logger.debug("jgroups.tcpgossip.initial_hosts set to "
-                System.getProperty("jgroups.tcpgossip.initial_hosts"));
+        logger.debug("jgroups.tcp.address set to {}",
+                System.getProperty("jgroups.tcp.address"));
+        logger.debug("jgroups.tcpgossip.initial_hosts set to {}",
+                System.getProperty("jgroups.tcpgossip.initial_hosts"));
         GossipRouter res = null;
         if (amIGossipRouter) {
-            logger.info("I'm a GossipRouter will listen on port "
-                    gossipRouterPort);
+            logger.info("I'm a GossipRouter will listen on port {}",
+                    gossipRouterPort);
             res = new GossipRouter(gossipRouterPort);
         }
         return res;
@@ -241,18 +241,14 @@ public class ClusterManager implements IClusterServices {
                 this.gossiper.start();
                 logger.info("Started GossipRouter");
             } catch (Exception e) {
-                logger.error("GossipRouter didn't start exception " + e
-                        + " met");
-                StringWriter sw = new StringWriter();
-                logger.error("Stack Trace that raised the exception");
-                e.printStackTrace(new PrintWriter(sw));
-                logger.error(sw.toString());
+                logger.error("GossipRouter didn't start. Exception Stack Trace",
+                             e);
             }
         }
         logger.info("Starting the ClusterManager");
         try {
             //FIXME keeps throwing FileNotFoundException
-            this.cm = new DefaultCacheManager("/config/infinispan-config.xml");
+            this.cm = new DefaultCacheManager("config/infinispan-config.xml");
             logger.debug("Allocated ClusterManager");
             if (this.cm != null) {
                 this.cm.start();
@@ -260,15 +256,13 @@ public class ClusterManager implements IClusterServices {
                 logger.debug("Started the ClusterManager");
             }
         } catch (Exception ioe) {
-            StringWriter sw = new StringWriter();
             logger.error("Cannot configure infinispan .. bailing out ");
             logger.error("Stack Trace that raised th exception");
-            ioe.printStackTrace(new PrintWriter(sw));
-            logger.error(sw.toString());
+            logger.error("",ioe);
             this.cm = null;
             this.stop();
         }
-        logger.debug("Cache Manager has value " + this.cm);
+        logger.debug("Cache Manager has value {}", this.cm);
     }
 
     public void stop() {
@@ -289,7 +283,7 @@ public class ClusterManager implements IClusterServices {
             String cacheName, Set<cacheMode> cMode) throws CacheExistException,
             CacheConfigException {
         EmbeddedCacheManager manager = this.cm;
-        Cache c;
+        Cache<Object,Object> c;
         String realCacheName = "{" + containerName + "}_{" + cacheName + "}";
         if (manager == null) {
             return null;
@@ -322,7 +316,7 @@ public class ClusterManager implements IClusterServices {
     @Override
     public ConcurrentMap<?, ?> getCache(String containerName, String cacheName) {
         EmbeddedCacheManager manager = this.cm;
-        Cache c;
+        Cache<Object,Object> c;
         String realCacheName = "{" + containerName + "}_{" + cacheName + "}";
         if (manager == null) {
             return null;
@@ -359,7 +353,7 @@ public class ClusterManager implements IClusterServices {
 
     @Override
     public Set<String> getCacheList(String containerName) {
-        Set<String> perContainerCaches = new HashSet();
+        Set<String> perContainerCaches = new HashSet<String>();
         EmbeddedCacheManager manager = this.cm;
         if (manager == null) {
             return null;
@@ -403,7 +397,7 @@ public class ClusterManager implements IClusterServices {
     public void addListener(String containerName, String cacheName,
             IGetUpdates<?, ?> u) throws CacheListenerAddException {
         EmbeddedCacheManager manager = this.cm;
-        Cache c;
+        Cache<Object,Object> c;
         String realCacheName = "{" + containerName + "}_{" + cacheName + "}";
         if (manager == null) {
             return;
@@ -422,7 +416,7 @@ public class ClusterManager implements IClusterServices {
     public Set<IGetUpdates<?, ?>> getListeners(String containerName,
             String cacheName) {
         EmbeddedCacheManager manager = this.cm;
-        Cache c;
+        Cache<Object,Object> c;
         String realCacheName = "{" + containerName + "}_{" + cacheName + "}";
         if (manager == null) {
             return null;
@@ -433,7 +427,7 @@ public class ClusterManager implements IClusterServices {
         }
         c = manager.getCache(realCacheName);
 
-        Set<IGetUpdates<?, ?>> res = new HashSet();
+        Set<IGetUpdates<?, ?>> res = new HashSet<IGetUpdates<?, ?>>();
         Set<Object> listeners = c.getListeners();
         for (Object listener : listeners) {
             if (listener instanceof CacheListenerContainer) {
@@ -449,7 +443,7 @@ public class ClusterManager implements IClusterServices {
     public void removeListener(String containerName, String cacheName,
             IGetUpdates<?, ?> u) {
         EmbeddedCacheManager manager = this.cm;
-        Cache c;
+        Cache<Object,Object> c;
         String realCacheName = "{" + containerName + "}_{" + cacheName + "}";
         if (manager == null) {
             return;
@@ -536,7 +530,7 @@ public class ClusterManager implements IClusterServices {
         EmbeddedCacheManager manager = this.cm;
         if (manager == null) {
             // In case we cannot fetch the information, lets assume we
-            // are standby, so to have less responsability.
+            // are standby, so to have less responsibility.
             return true;
         }
         return (!manager.isCoordinator());
@@ -546,7 +540,7 @@ public class ClusterManager implements IClusterServices {
         EmbeddedCacheManager manager = this.cm;
         if ((manager == null) || (a == null)) {
             // In case we cannot fetch the information, lets assume we
-            // are standby, so to have less responsability.
+            // are standby, so to have less responsibility.
             return null;
         }
         Transport t = manager.getTransport();
@@ -600,7 +594,7 @@ public class ClusterManager implements IClusterServices {
         EmbeddedCacheManager manager = this.cm;
         if (manager == null) {
             // In case we cannot fetch the information, lets assume we
-            // are standby, so to have less responsability.
+            // are standby, so to have less responsibility.
             return null;
         }
 
@@ -613,12 +607,12 @@ public class ClusterManager implements IClusterServices {
         EmbeddedCacheManager manager = this.cm;
         if (manager == null) {
             // In case we cannot fetch the information, lets assume we
-            // are standby, so to have less responsability.
+            // are standby, so to have less responsibility.
             throw new ListenRoleChangeAddException();
         }
 
         if (this.roleChangeListeners == null) {
-            this.roleChangeListeners = new HashSet();
+            this.roleChangeListeners = new HashSet<IListenRoleChange>();
             this.cacheManagerListener = new ViewChangedListener(
                     this.roleChangeListeners);
             manager.addListener(this.cacheManagerListener);
@@ -634,7 +628,7 @@ public class ClusterManager implements IClusterServices {
         EmbeddedCacheManager manager = this.cm;
         if (manager == null) {
             // In case we cannot fetch the information, lets assume we
-            // are standby, so to have less responsability.
+            // are standby, so to have less responsibility.
             return;
         }