Integrate MRI projects for Neon
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / FrontendReadWriteTransaction.java
index 50e913025d6b9a7ab818393a47c61d4a384f202a..e2ae16f097fb1bac74a74065fe252bb3d389d692 100644 (file)
@@ -7,11 +7,11 @@
  */
 package org.opendaylight.controller.cluster.datastore;
 
-import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.primitives.UnsignedLong;
 import com.google.common.util.concurrent.FutureCallback;
 import java.util.Collection;
+import java.util.Optional;
 import javax.annotation.Nullable;
 import javax.annotation.concurrent.NotThreadSafe;
 import org.opendaylight.controller.cluster.access.commands.AbortLocalTransactionRequest;
@@ -247,7 +247,7 @@ final class FrontendReadWriteTransaction extends FrontendTransaction {
             case READY:
                 throw new IllegalStateException("Attempted to preCommit in stage " + ready.stage);
             default:
-                throw new IllegalStateException("Unhandled commit stage " + ready.stage);
+                throwUnhandledCommitStage(ready);
         }
     }
 
@@ -306,7 +306,7 @@ final class FrontendReadWriteTransaction extends FrontendTransaction {
             case READY:
                 throw new IllegalStateException("Attempted to doCommit in stage " + ready.stage);
             default:
-                throw new IllegalStateException("Unhandled commit stage " + ready.stage);
+                throwUnhandledCommitStage(ready);
         }
     }
 
@@ -395,7 +395,7 @@ final class FrontendReadWriteTransaction extends FrontendTransaction {
             case PRE_COMMIT_PENDING:
                 throw new IllegalStateException("Attempted to canCommit in stage " + ready.stage);
             default:
-                throw new IllegalStateException("Unhandled commit stage " + ready.stage);
+                throwUnhandledCommitStage(ready);
         }
     }
 
@@ -442,7 +442,7 @@ final class FrontendReadWriteTransaction extends FrontendTransaction {
                 });
                 break;
             default:
-                throw new IllegalStateException("Unhandled commit stage " + ready.stage);
+                throwUnhandledCommitStage(ready);
         }
     }
 
@@ -513,7 +513,8 @@ final class FrontendReadWriteTransaction extends FrontendTransaction {
         if (optFailure.isPresent()) {
             state = new Ready(history().createFailedCohort(getIdentifier(), sealedModification, optFailure.get()));
         } else {
-            state = new Ready(history().createReadyCohort(getIdentifier(), sealedModification));
+            state = new Ready(history().createReadyCohort(getIdentifier(), sealedModification,
+                    java.util.Optional.empty()));
         }
 
         if (request.isCoordinated()) {
@@ -523,15 +524,13 @@ final class FrontendReadWriteTransaction extends FrontendTransaction {
         }
     }
 
-    private ExistsTransactionSuccess handleExistsTransaction(final ExistsTransactionRequest request)
-            throws RequestException {
+    private ExistsTransactionSuccess handleExistsTransaction(final ExistsTransactionRequest request) {
         final Optional<NormalizedNode<?, ?>> data = checkOpen().getSnapshot().readNode(request.getPath());
         return recordSuccess(request.getSequence(), new ExistsTransactionSuccess(getIdentifier(), request.getSequence(),
             data.isPresent()));
     }
 
-    private ReadTransactionSuccess handleReadTransaction(final ReadTransactionRequest request)
-            throws RequestException {
+    private ReadTransactionSuccess handleReadTransaction(final ReadTransactionRequest request) {
         final Optional<NormalizedNode<?, ?>> data = checkOpen().getSnapshot().readNode(request.getPath());
         return recordSuccess(request.getSequence(), new ReadTransactionSuccess(getIdentifier(), request.getSequence(),
             data));
@@ -558,7 +557,8 @@ final class FrontendReadWriteTransaction extends FrontendTransaction {
         }
     }
 
-    private @Nullable TransactionSuccess<?> handleModifyTransaction(final ModifyTransactionRequest request,
+    @Nullable
+    private TransactionSuccess<?> handleModifyTransaction(final ModifyTransactionRequest request,
             final RequestEnvelope envelope, final long now) throws RequestException {
         // We need to examine the persistence protocol first to see if this is an idempotent request. If there is no
         // protocol, there is nothing for us to do.
@@ -608,7 +608,7 @@ final class FrontendReadWriteTransaction extends FrontendTransaction {
         }
 
         applyModifications(modifications);
-        state = new Ready(checkOpen().ready());
+        state = new Ready(checkOpen().ready(java.util.Optional.empty()));
         LOG.debug("{}: transitioned {} to ready", persistenceId(), getIdentifier());
     }
 
@@ -636,4 +636,8 @@ final class FrontendReadWriteTransaction extends FrontendTransaction {
             state);
         return ((Sealed) state).sealedModification;
     }
+
+    private static void throwUnhandledCommitStage(final Ready ready) {
+        throw new IllegalStateException("Unhandled commit stage " + ready.stage);
+    }
 }