Make ShardCoordinationTasks public 45/44645/2
authorTomas Cere <tcere@cisco.com>
Wed, 10 Aug 2016 08:57:29 +0000 (10:57 +0200)
committerRobert Varga <nite@hq.sk>
Thu, 25 Aug 2016 13:39:24 +0000 (13:39 +0000)
These will be reused in controller so make them public.

Change-Id: I89fb776768d8e975fd744fd1daefc2d0bb3eaa3f
Signed-off-by: Tomas Cere <tcere@cisco.com>
(cherry picked from commit 6a8c4d89d24cb6a819949b3782965f2cde1d20fe)

dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/ShardCanCommitCoordinationTask.java
dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/ShardCommitCoordinationTask.java
dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/ShardPreCommitCoordinationTask.java
dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/ShardSubmitCoordinationTask.java

index 766650a3301594310ddf4aa19a4707b0dba10b56..c8499ecd48cbee559628ed2c137b3c2641dfd32d 100644 (file)
@@ -8,6 +8,8 @@
 
 package org.opendaylight.mdsal.dom.store.inmemory;
 
+import com.google.common.annotations.Beta;
+import com.google.common.base.Preconditions;
 import com.google.common.util.concurrent.ListenableFuture;
 import java.util.Collection;
 import java.util.concurrent.Callable;
@@ -18,17 +20,21 @@ import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-class ShardCanCommitCoordinationTask implements Callable<Boolean> {
+/**
+ * Task that coordinates the CanCommit phase of the provided {@link DOMStoreThreePhaseCommitCohort}'s
+ */
+@Beta
+public class ShardCanCommitCoordinationTask implements Callable<Boolean> {
 
     private static final Logger LOG = LoggerFactory.getLogger(ShardCanCommitCoordinationTask.class);
 
     private final DOMDataTreeIdentifier rootShardPrefix;
     private final Collection<DOMStoreThreePhaseCommitCohort> cohorts;
 
-    ShardCanCommitCoordinationTask(final DOMDataTreeIdentifier rootShardPrefix,
+    public ShardCanCommitCoordinationTask(final DOMDataTreeIdentifier rootShardPrefix,
                                        final Collection<DOMStoreThreePhaseCommitCohort> cohorts) {
-        this.rootShardPrefix = rootShardPrefix;
-        this.cohorts = cohorts;
+        this.rootShardPrefix = Preconditions.checkNotNull(rootShardPrefix);
+        this.cohorts = Preconditions.checkNotNull(cohorts);
     }
 
     @Override
@@ -39,7 +45,7 @@ class ShardCanCommitCoordinationTask implements Callable<Boolean> {
             canCommitBlocking();
 
             return true;
-        } catch (TransactionCommitFailedException e) {
+        } catch (final TransactionCommitFailedException e) {
             LOG.warn("Shard: {} Submit Error during phase CanCommit, starting Abort", rootShardPrefix, e);
             //FIXME abort here
             throw e;
index 76318212192326103ea31e2a02279067d1e1ec52..4ff9d2f5cdaaffa708830499503cc31085fa9317 100644 (file)
@@ -8,6 +8,8 @@
 
 package org.opendaylight.mdsal.dom.store.inmemory;
 
+import com.google.common.annotations.Beta;
+import com.google.common.base.Preconditions;
 import com.google.common.util.concurrent.ListenableFuture;
 import java.util.Collection;
 import java.util.concurrent.Callable;
@@ -18,17 +20,21 @@ import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-class ShardCommitCoordinationTask implements Callable<Void> {
+/**
+ * Task that coordinates the Commit phase of the provided {@link DOMStoreThreePhaseCommitCohort}'s
+ */
+@Beta
+public class ShardCommitCoordinationTask implements Callable<Void> {
 
     private static final Logger LOG = LoggerFactory.getLogger(ShardCommitCoordinationTask.class);
 
     private final DOMDataTreeIdentifier rootShardPrefix;
     private final Collection<DOMStoreThreePhaseCommitCohort> cohorts;
 
-    ShardCommitCoordinationTask(final DOMDataTreeIdentifier rootShardPrefix,
+    public ShardCommitCoordinationTask(final DOMDataTreeIdentifier rootShardPrefix,
                                        final Collection<DOMStoreThreePhaseCommitCohort> cohorts) {
-        this.rootShardPrefix = rootShardPrefix;
-        this.cohorts = cohorts;
+        this.rootShardPrefix = Preconditions.checkNotNull(rootShardPrefix);
+        this.cohorts = Preconditions.checkNotNull(cohorts);
     }
 
     @Override
@@ -39,7 +45,7 @@ class ShardCommitCoordinationTask implements Callable<Void> {
             commitBlocking();
 
             return null;
-        } catch (TransactionCommitFailedException e) {
+        } catch (final TransactionCommitFailedException e) {
             LOG.warn("Shard: {} Submit Error during phase Commit, starting Abort", rootShardPrefix, e);
             //FIXME abort here
             throw e;
index 0024cb83f133ec324df23ca38b0711f48b51f06a..737be35c7431e189a39e3c9d97b663f405c74c9b 100644 (file)
@@ -9,6 +9,8 @@
 
 package org.opendaylight.mdsal.dom.store.inmemory;
 
+import com.google.common.annotations.Beta;
+import com.google.common.base.Preconditions;
 import com.google.common.util.concurrent.ListenableFuture;
 import java.util.Collection;
 import java.util.concurrent.Callable;
@@ -19,17 +21,21 @@ import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-class ShardPreCommitCoordinationTask implements Callable<Void>{
+/**
+ * Task that coordinates the PreCommit phase of the provided {@link DOMStoreThreePhaseCommitCohort}'s
+ */
+@Beta
+public class ShardPreCommitCoordinationTask implements Callable<Void>{
 
     private static final Logger LOG = LoggerFactory.getLogger(ShardPreCommitCoordinationTask.class);
 
     private final DOMDataTreeIdentifier rootShardPrefix;
     private final Collection<DOMStoreThreePhaseCommitCohort> cohorts;
 
-    ShardPreCommitCoordinationTask(final DOMDataTreeIdentifier rootShardPrefix,
+    public ShardPreCommitCoordinationTask(final DOMDataTreeIdentifier rootShardPrefix,
                                        final Collection<DOMStoreThreePhaseCommitCohort> cohorts) {
-        this.rootShardPrefix = rootShardPrefix;
-        this.cohorts = cohorts;
+        this.rootShardPrefix = Preconditions.checkNotNull(rootShardPrefix);
+        this.cohorts = Preconditions.checkNotNull(cohorts);
     }
 
     @Override
@@ -40,7 +46,7 @@ class ShardPreCommitCoordinationTask implements Callable<Void>{
             preCommitBlocking();
 
             return null;
-        } catch (TransactionCommitFailedException e) {
+        } catch (final TransactionCommitFailedException e) {
             LOG.warn("Shard: {} Submit Error during phase {}, starting Abort", rootShardPrefix, e);
             //FIXME abort here
             throw e;
index b46c9fcf0b0712e551a8ddb2e4bb403777a5a2d3..c7b0ee6adc01ae91c3222d6a25f708615f220242 100644 (file)
@@ -8,6 +8,8 @@
 
 package org.opendaylight.mdsal.dom.store.inmemory;
 
+import com.google.common.annotations.Beta;
+import com.google.common.base.Preconditions;
 import java.util.Collection;
 import java.util.concurrent.Callable;
 import org.opendaylight.mdsal.common.api.TransactionCommitFailedException;
@@ -16,7 +18,12 @@ import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-class ShardSubmitCoordinationTask implements Callable<Void> {
+/**
+ * Task that coordinates all phases of transaction submit from the provided {@link DOMStoreThreePhaseCommitCohort}'s.
+ * Each phase will only be started once all cohorts have finished the previous phase.
+ */
+@Beta
+public class ShardSubmitCoordinationTask implements Callable<Void> {
 
     private static final Logger LOG = LoggerFactory.getLogger(ShardSubmitCoordinationTask.class);
 
@@ -26,9 +33,9 @@ class ShardSubmitCoordinationTask implements Callable<Void> {
     private final ShardCommitCoordinationTask commitCoordinationTask;
 
 
-    ShardSubmitCoordinationTask(final DOMDataTreeIdentifier rootShardPrefix,
+    public ShardSubmitCoordinationTask(final DOMDataTreeIdentifier rootShardPrefix,
                                        final Collection<DOMStoreThreePhaseCommitCohort> cohorts) {
-        this.rootShardPrefix = rootShardPrefix;
+        this.rootShardPrefix = Preconditions.checkNotNull(rootShardPrefix);
 
         canCommitCoordinationTask = new ShardCanCommitCoordinationTask(rootShardPrefix, cohorts);
         preCommitCoordinationTask = new ShardPreCommitCoordinationTask(rootShardPrefix, cohorts);