Merge "Addding a new method to let the clients of clustering service specify a transa...
authorGiovanni Meo <gmeo@cisco.com>
Wed, 4 Dec 2013 08:26:45 +0000 (08:26 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Wed, 4 Dec 2013 08:26:45 +0000 (08:26 +0000)
17 files changed:
opendaylight/clustering/integrationtest/pom.xml
opendaylight/clustering/services/pom.xml
opendaylight/clustering/services/src/main/java/org/opendaylight/controller/clustering/services/IClusterServices.java
opendaylight/clustering/services/src/main/java/org/opendaylight/controller/clustering/services/IClusterServicesCommon.java
opendaylight/clustering/services_implementation/pom.xml
opendaylight/clustering/services_implementation/src/main/java/org/opendaylight/controller/clustering/services_implementation/internal/ClusterManager.java
opendaylight/clustering/services_implementation/src/main/java/org/opendaylight/controller/clustering/services_implementation/internal/ClusterManagerCommon.java
opendaylight/clustering/stub/pom.xml
opendaylight/clustering/stub/src/main/java/org/opendaylight/controller/clustering/stub/internal/ClusterManagerCommon.java
opendaylight/commons/opendaylight/pom.xml
opendaylight/configuration/integrationtest/pom.xml
opendaylight/distribution/opendaylight/pom.xml
opendaylight/forwardingrulesmanager/integrationtest/pom.xml
opendaylight/hosttracker/integrationtest/pom.xml
opendaylight/northbound/integrationtest/pom.xml
opendaylight/statisticsmanager/integrationtest/pom.xml
opendaylight/switchmanager/integrationtest/pom.xml

index ca1e37e3bee0eac8a55fda94e4385d58cbdfa4ec..43fa74fba8dd9a10b0d167fd0a05cf4f7fcfd0c5 100644 (file)
@@ -21,7 +21,7 @@
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>clustering.services</artifactId>
-      <version>0.4.1-SNAPSHOT</version>
+      <version>0.5.0-SNAPSHOT</version>
     </dependency>
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
index 7eede83638b0fd8eda5155c3d20a3773acbfc5c4..ebaffc29dfad0d6ceb4ac43a673a48c24db8adfe 100644 (file)
@@ -16,7 +16,7 @@
   </scm>
 
   <artifactId>clustering.services</artifactId>
-  <version>0.4.1-SNAPSHOT</version>
+  <version>0.5.0-SNAPSHOT</version>
   <packaging>bundle</packaging>
 
   <dependencies>
index 77e300e95aaa7475b276fa10eaa8f37bb9326d5b..b3427c7fcc13d77b43afd4666c788f21386cdbb6 100644 (file)
@@ -24,6 +24,7 @@ import java.util.List;
 import java.util.Properties;
 import java.util.Set;
 import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.TimeUnit;
 
 import javax.transaction.HeuristicMixedException;
 import javax.transaction.HeuristicRollbackException;
@@ -215,6 +216,16 @@ public interface IClusterServices {
      */
     void tbegin() throws NotSupportedException, SystemException;
 
+    /**
+     * tbegin with a timeout
+     * @see IClusterServices#tbegin
+     * @param timeout the transaction timeout
+     * @param unit TimeUnit for the timeout
+     * @throws NotSupportedException
+     * @throws SystemException
+     */
+    void tbegin(long timeout, TimeUnit unit) throws NotSupportedException, SystemException;
+
     /**
      * Commit a transaction covering all the data structures/HW updates.
      */
index 6850c64a0ed15774c3808773241659da7b75d7aa..7ea86c6db7d334fc0cd85ac940a76da1c96c7cc0 100644 (file)
@@ -26,6 +26,7 @@ import java.util.List;
 import java.util.Properties;
 import java.util.Set;
 import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.TimeUnit;
 
 import javax.transaction.HeuristicMixedException;
 import javax.transaction.HeuristicRollbackException;
@@ -118,6 +119,16 @@ public interface IClusterServicesCommon {
      */
     void tbegin() throws NotSupportedException, SystemException;
 
+    /**
+     * tbegin with a timeout
+     * @see IClusterServicesCommon#tbegin
+     * @param timeout the transaction timeout
+     * @param unit TimeUnit for the timeout
+     * @throws NotSupportedException
+     * @throws SystemException
+     */
+    void tbegin(long timeout, TimeUnit unit) throws NotSupportedException, SystemException;
+
     /**
      * Commit a transaction covering all the data structures/HW updates.
      */
index ab75eb8dd1414f777c41adb985ac475097c0cd2b..90df7511e4c8050aadfbe42a40bae6a8eea8f821 100644 (file)
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>clustering.services</artifactId>
-      <version>0.4.1-SNAPSHOT</version>
+      <version>0.5.0-SNAPSHOT</version>
     </dependency>
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
index a9e6948a408699762c9e0cd2e7396db0d05e1b16..fcf71a90ac5c3ae96940861df4296dd14dc8ef7e 100644 (file)
@@ -22,6 +22,7 @@ import java.util.Properties;
 import java.util.Set;
 import java.util.StringTokenizer;
 import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.TimeUnit;
 
 import javax.transaction.HeuristicMixedException;
 import javax.transaction.HeuristicRollbackException;
@@ -69,6 +70,9 @@ public class ClusterManager implements IClusterServices {
 
     private static String loopbackAddress = "127.0.0.1";
 
+    // defaultTransactionTimeout is 60 seconds
+    private static int DEFAULT_TRANSACTION_TIMEOUT = 60;
+
     /**
      * Start a JGroups GossipRouter if we are a supernode. The
      * GosispRouter is nothing more than a simple
@@ -525,6 +529,12 @@ public class ClusterManager implements IClusterServices {
 
     @Override
     public void tbegin() throws NotSupportedException, SystemException {
+        // call tbegin with the default timeout
+        tbegin(DEFAULT_TRANSACTION_TIMEOUT, TimeUnit.SECONDS);
+    }
+
+    @Override
+    public void tbegin(long timeout, TimeUnit unit) throws NotSupportedException, SystemException {
         EmbeddedCacheManager manager = this.cm;
         if (manager == null) {
             throw new IllegalStateException();
@@ -534,6 +544,15 @@ public class ClusterManager implements IClusterServices {
         if (tm == null) {
             throw new IllegalStateException();
         }
+        long timeoutSec = unit.toSeconds(timeout);
+        if((timeoutSec > Integer.MAX_VALUE) || (timeoutSec <= 0)) {
+            // fall back to the default timeout
+            tm.setTransactionTimeout(DEFAULT_TRANSACTION_TIMEOUT);
+        } else {
+            // cast is ok here
+            // as here we are sure that timeoutSec < = Integer.MAX_VALUE.
+            tm.setTransactionTimeout((int) timeoutSec);
+        }
         tm.begin();
     }
 
index 9ee00484ce573123778226c0a298b3203b3ba116..97d9ded6c86b864f06356ff026bd170cc6dbe4d5 100644 (file)
@@ -19,12 +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 org.apache.felix.dm.Component;
 import org.opendaylight.controller.clustering.services.CacheConfigException;
 import org.opendaylight.controller.clustering.services.CacheExistException;
@@ -255,6 +258,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,
index 607b48b3aa99d7d522e0ebae6276dbef8a80d00f..8fe1a99a0df59d2e8573b9f2964fb413480457a6 100644 (file)
@@ -48,7 +48,7 @@
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>clustering.services</artifactId>
-      <version>0.4.1-SNAPSHOT</version>
+      <version>0.5.0-SNAPSHOT</version>
     </dependency>
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
index b6cb742d4789bf9dcc9760e3aa9fd42490a8feef..fe73e240f995acf3ff2b00dead4e9771bdb98fd5 100644 (file)
@@ -9,14 +9,16 @@
 
 package org.opendaylight.controller.clustering.stub.internal;
 
-import java.util.ArrayList;
-import java.util.concurrent.ConcurrentHashMap;
-import java.net.UnknownHostException;
 import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.Dictionary;
 import java.util.List;
 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;
@@ -25,6 +27,7 @@ import javax.transaction.RollbackException;
 import javax.transaction.SystemException;
 import javax.transaction.Transaction;
 
+import org.apache.felix.dm.Component;
 import org.opendaylight.controller.clustering.services.CacheConfigException;
 import org.opendaylight.controller.clustering.services.CacheExistException;
 import org.opendaylight.controller.clustering.services.IClusterServices;
@@ -32,9 +35,6 @@ import org.opendaylight.controller.clustering.services.IClusterServicesCommon;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.Dictionary;
-import org.apache.felix.dm.Component;
-
 public abstract class ClusterManagerCommon implements IClusterServicesCommon {
     protected String containerName = "";
     protected static final Logger logger = LoggerFactory
@@ -120,6 +120,11 @@ public abstract class ClusterManagerCommon implements IClusterServicesCommon {
             java.lang.IllegalStateException, SystemException {
     }
 
+    @Override
+    public void tbegin(long timeout, TimeUnit unit) throws NotSupportedException, SystemException {
+
+    }
+
     @Override
     public void trollback() throws java.lang.IllegalStateException,
             java.lang.SecurityException, SystemException {
index a652845770eb64009bf8fc79fc63356ce99a3e95..f277b545bffcd33f90e308ee77c20c09f261bd52 100644 (file)
     <sonar.language>java</sonar.language>
     <forwardingrulesmanager.version>0.5.0-SNAPSHOT</forwardingrulesmanager.version>
     <statisticsmanager.version>0.5.0-SNAPSHOT</statisticsmanager.version>
+    <clustering.services.version>0.5.0-SNAPSHOT</clustering.services.version>
     <maven.compile.plugin.version>2.5.1</maven.compile.plugin.version>
     <java.version.source>1.7</java.version.source>
     <java.version.target>1.7</java.version.target>
index 894f94bc46b67d11e2858715d8602dec1a54755e..6bcee92544327290aeea3826f79d26edaad206cf 100644 (file)
@@ -40,7 +40,7 @@
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>clustering.services</artifactId>
-      <version>0.4.1-SNAPSHOT</version>
+      <version>0.5.0-SNAPSHOT</version>
     </dependency>
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
index 9ce668da85a63dd0145daac62a34574a4a8d4054..35ebbbe0dd2455394a06f5ff62e731b57012ac6d 100644 (file)
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>clustering.services</artifactId>
-      <version>${controller.version}</version>
+      <version>${clustering.services.version}</version>
     </dependency>
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
index 7904bd3a8f78f522a9a5dc93bd5b621ea3ab1488..95fbd5dafb66b2e376f595b9d8fa90552ab1c522 100644 (file)
@@ -61,7 +61,7 @@
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>clustering.services</artifactId>
-      <version>0.4.1-SNAPSHOT</version>
+      <version>0.5.0-SNAPSHOT</version>
     </dependency>
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
index 8f4163d68674d8a65cd0fb94689d42b6a6679189..2e80cac2ac540ca36a5ca8c4a6fbb80b07afbd3b 100644 (file)
@@ -58,7 +58,7 @@
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>clustering.services</artifactId>
-      <version>0.4.1-SNAPSHOT</version>
+      <version>0.5.0-SNAPSHOT</version>
     </dependency>
 
     <dependency>
index b4e0b34d091c570d3ceb90a0da52df23927ae4a7..4e1de914f7677e649f291a86d1dea69b368bddba 100644 (file)
@@ -74,7 +74,7 @@
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>clustering.services</artifactId>
-      <version>0.4.1-SNAPSHOT</version>
+      <version>0.5.0-SNAPSHOT</version>
     </dependency>
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
index 743c6784a51b607e57bd15b0d216593be274a6a0..a3ecf526c0748bfd274f39ff9161089d1ba3389b 100644 (file)
@@ -50,7 +50,7 @@
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>clustering.services</artifactId>
-      <version>0.4.1-SNAPSHOT</version>
+      <version>0.5.0-SNAPSHOT</version>
     </dependency>
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
index 5d8ce9b303067c68e79cc82fbf2a3293ac1e72ce..c06efb91b88f4b730fb86e7e256fe3e0fac7f688 100644 (file)
@@ -51,7 +51,7 @@
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>clustering.services</artifactId>
-      <version>0.4.1-SNAPSHOT</version>
+      <version>0.5.0-SNAPSHOT</version>
     </dependency>
     <dependency>
       <groupId>org.opendaylight.controller</groupId>