checkStyleViolationSeverity=error implemented for mdsal-dom-broker
[mdsal.git] / dom / mdsal-dom-broker / src / main / java / org / opendaylight / mdsal / dom / broker / CommitCoordinationTask.java
index 694b8411a81f082eb533d2e2598359d875a018b6..385697b9c2d6ad27ec6e24b5d188c95a9ebb8255 100644 (file)
@@ -8,10 +8,6 @@
 
 package org.opendaylight.mdsal.dom.broker;
 
-import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort;
-
-import org.opendaylight.mdsal.common.api.TransactionCommitFailedException;
-import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction;
 import com.google.common.base.Preconditions;
 import com.google.common.base.Throwables;
 import com.google.common.util.concurrent.Futures;
@@ -19,6 +15,9 @@ import com.google.common.util.concurrent.ListenableFuture;
 import java.util.Collection;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ExecutionException;
+import org.opendaylight.mdsal.common.api.TransactionCommitFailedException;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort;
 import org.opendaylight.yangtools.util.DurationStatisticsTracker;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -28,7 +27,7 @@ import org.slf4j.LoggerFactory;
  * support of cancellation.
  */
 final class CommitCoordinationTask implements Callable<Void> {
-    private static enum Phase {
+    private enum Phase {
         canCommit,
         preCommit,
         doCommit,
@@ -39,7 +38,7 @@ final class CommitCoordinationTask implements Callable<Void> {
     private final DurationStatisticsTracker commitStatTracker;
     private final DOMDataTreeWriteTransaction tx;
 
-    public CommitCoordinationTask(final DOMDataTreeWriteTransaction transaction,
+    CommitCoordinationTask(final DOMDataTreeWriteTransaction transaction,
             final Collection<DOMStoreThreePhaseCommitCohort> cohorts,
             final DurationStatisticsTracker commitStatTracker) {
         this.tx = Preconditions.checkNotNull(transaction, "transaction must not be null");
@@ -79,10 +78,10 @@ final class CommitCoordinationTask implements Callable<Void> {
     }
 
     /**
-     *
      * Invokes canCommit on underlying cohorts and blocks till
      * all results are returned.
      *
+     *<p>
      * Valid state transition is from SUBMITTED to CAN_COMMIT,
      * if currentPhase is not SUBMITTED throws IllegalStateException.
      *
@@ -104,11 +103,11 @@ final class CommitCoordinationTask implements Callable<Void> {
     }
 
     /**
-     *
      * Invokes canCommit on underlying cohorts and returns composite future
      * which will contains {@link Boolean#TRUE} only and only if
      * all cohorts returned true.
      *
+     *<p>
      * Valid state transition is from SUBMITTED to CAN_COMMIT,
      * if currentPhase is not SUBMITTED throws IllegalStateException.
      *
@@ -117,18 +116,18 @@ final class CommitCoordinationTask implements Callable<Void> {
      */
     private ListenableFuture<?>[] canCommitAll() {
         final ListenableFuture<?>[] ops = new ListenableFuture<?>[cohorts.size()];
-        int i = 0;
+        int index = 0;
         for (final DOMStoreThreePhaseCommitCohort cohort : cohorts) {
-            ops[i++] = cohort.canCommit();
+            ops[index++] = cohort.canCommit();
         }
         return ops;
     }
 
     /**
-     *
      * Invokes preCommit on underlying cohorts and blocks till
      * all results are returned.
      *
+     *<p>
      * Valid state transition is from CAN_COMMIT to PRE_COMMIT, if current
      * state is not CAN_COMMIT
      * throws IllegalStateException.
@@ -140,7 +139,7 @@ final class CommitCoordinationTask implements Callable<Void> {
     private void preCommitBlocking() throws TransactionCommitFailedException {
         final ListenableFuture<?>[] preCommitFutures = preCommitAll();
         try {
-            for(final ListenableFuture<?> future : preCommitFutures) {
+            for (final ListenableFuture<?> future : preCommitFutures) {
                 future.get();
             }
         } catch (InterruptedException | ExecutionException e) {
@@ -149,12 +148,11 @@ final class CommitCoordinationTask implements Callable<Void> {
     }
 
     /**
-     *
      * Invokes preCommit on underlying cohorts and returns future
      * which will complete once all preCommit on cohorts completed or
      * failed.
      *
-     *
+     *<p>
      * Valid state transition is from CAN_COMMIT to PRE_COMMIT, if current
      * state is not CAN_COMMIT
      * throws IllegalStateException.
@@ -164,18 +162,18 @@ final class CommitCoordinationTask implements Callable<Void> {
      */
     private ListenableFuture<?>[] preCommitAll() {
         final ListenableFuture<?>[] ops = new ListenableFuture<?>[cohorts.size()];
-        int i = 0;
+        int index = 0;
         for (final DOMStoreThreePhaseCommitCohort cohort : cohorts) {
-            ops[i++] = cohort.preCommit();
+            ops[index++] = cohort.preCommit();
         }
         return ops;
     }
 
     /**
-     *
      * Invokes commit on underlying cohorts and blocks till
      * all results are returned.
      *
+     *<p>
      * Valid state transition is from PRE_COMMIT to COMMIT, if not throws
      * IllegalStateException.
      *
@@ -186,7 +184,7 @@ final class CommitCoordinationTask implements Callable<Void> {
     private void commitBlocking() throws TransactionCommitFailedException {
         final ListenableFuture<?>[] commitFutures = commitAll();
         try {
-            for(final ListenableFuture<?> future : commitFutures) {
+            for (final ListenableFuture<?> future : commitFutures) {
                 future.get();
             }
         } catch (InterruptedException | ExecutionException e) {
@@ -195,11 +193,11 @@ final class CommitCoordinationTask implements Callable<Void> {
     }
 
     /**
-     *
      * Invokes commit on underlying cohorts and returns future which
      * completes
      * once all commits on cohorts are completed.
      *
+     *<p>
      * Valid state transition is from PRE_COMMIT to COMMIT, if not throws
      * IllegalStateException
      *
@@ -207,9 +205,9 @@ final class CommitCoordinationTask implements Callable<Void> {
      */
     private ListenableFuture<?>[] commitAll() {
         final ListenableFuture<?>[] ops = new ListenableFuture<?>[cohorts.size()];
-        int i = 0;
+        int index = 0;
         for (final DOMStoreThreePhaseCommitCohort cohort : cohorts) {
-            ops[i++] = cohort.commit();
+            ops[index++] = cohort.commit();
         }
         return ops;
     }
@@ -217,12 +215,14 @@ final class CommitCoordinationTask implements Callable<Void> {
     /**
      * Aborts transaction.
      *
+     *<p>
      * Invokes {@link DOMStoreThreePhaseCommitCohort#abort()} on all
      * cohorts, blocks
      * for all results. If any of the abort failed throws
      * IllegalStateException,
      * which will contains originalCause as suppressed Exception.
      *
+     *<p>
      * If aborts we're successful throws supplied exception
      *
      * @param originalCause
@@ -236,7 +236,8 @@ final class CommitCoordinationTask implements Callable<Void> {
      * @throws IllegalStateException
      *             if abort failed.
      */
-    private void abortBlocking(final TransactionCommitFailedException originalCause) throws TransactionCommitFailedException {
+    private void abortBlocking(final TransactionCommitFailedException originalCause)
+            throws TransactionCommitFailedException {
         Exception cause = originalCause;
         try {
             abortAsyncAll().get();
@@ -259,9 +260,9 @@ final class CommitCoordinationTask implements Callable<Void> {
     private ListenableFuture<Void> abortAsyncAll() {
 
         final ListenableFuture<?>[] ops = new ListenableFuture<?>[cohorts.size()];
-        int i = 0;
+        int index = 0;
         for (final DOMStoreThreePhaseCommitCohort cohort : cohorts) {
-            ops[i++] = cohort.abort();
+            ops[index++] = cohort.abort();
         }
 
         /*