Merge "Fix clustering versions"
[controller.git] / opendaylight / clustering / services_implementation / src / main / java / org / opendaylight / controller / clustering / services_implementation / internal / ClusterManagerCommon.java
index 61681bc90add8d596a69658720cd170a65c9cd32..06e5bc5b611c0480de04ff4bff814095804048bf 100644 (file)
@@ -19,13 +19,15 @@ import java.util.Properties;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.TimeUnit;
+
 import javax.transaction.HeuristicMixedException;
 import javax.transaction.HeuristicRollbackException;
 import javax.transaction.NotSupportedException;
 import javax.transaction.RollbackException;
 import javax.transaction.SystemException;
 import javax.transaction.Transaction;
-import javax.transaction.TransactionManager;
+
 import org.apache.felix.dm.Component;
 import org.opendaylight.controller.clustering.services.CacheConfigException;
 import org.opendaylight.controller.clustering.services.CacheExistException;
@@ -56,6 +58,7 @@ public abstract class ClusterManagerCommon implements IClusterServicesCommon {
      * export the interface ICoordinatorChangeAware
      */
     class ListenCoordinatorChange implements IListenRoleChange {
+        @Override
         public void newActiveAvailable() {
             if (coordinatorChangeAware != null) {
                 // Make sure to look the set while walking it
@@ -91,13 +94,9 @@ public abstract class ClusterManagerCommon implements IClusterServicesCommon {
                 logger.trace("cachenames provided below:");
                 for (String cache : caches) {
                     if (this.cacheUpdateAware.get(cache) != null) {
-                        logger.error("cachename:{} on container:{} has " +
-                                     "already a listener", cache,
-                                     this.containerName);
+                        logger.error("cachename:{} on container:{} has already a listener", cache, this.containerName);
                     } else {
-                        GetUpdatesContainer<?, ?> up =
-                            new GetUpdatesContainer(s, this.containerName,
-                                                    cache);
+                        GetUpdatesContainer<?, ?> up = new GetUpdatesContainer(s, this.containerName, cache);
                         if (up != null) {
                             try {
                                 this.clusterService.addListener(this.containerName,
@@ -107,6 +106,7 @@ public abstract class ClusterManagerCommon implements IClusterServicesCommon {
                                              "been registered", cache,
                                              this.containerName);
                             } catch (CacheListenerAddException exc) {
+                                logger.debug("Cache {} didn't exist when {} tried to register to its updates", cache, s);
                                 // Do nothing, the important is that
                                 // we don't register the listener in
                                 // the shadow, and we are not doing
@@ -256,6 +256,15 @@ public abstract class ClusterManagerCommon implements IClusterServicesCommon {
         }
     }
 
+    @Override
+    public void tbegin(long timeout, TimeUnit unit) throws NotSupportedException, SystemException {
+        if (this.clusterService != null) {
+            this.clusterService.tbegin(timeout, unit);
+        } else {
+            throw new IllegalStateException();
+        }
+    }
+
     @Override
     public void tcommit() throws RollbackException, HeuristicMixedException,
             HeuristicRollbackException, java.lang.SecurityException,