Migrate DatastoreContextIntrospectorFactory to OSGi DS
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / CompositeDataTreeCohort.java
index 0ef49b6244c33a8a86fb7adec36106117c1f6175..bca00ebc4a6bdbb88cd928ffe609bdb6ae1acd5f 100644 (file)
@@ -5,9 +5,11 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.controller.cluster.datastore;
 
+import static com.google.common.base.Preconditions.checkState;
+import static java.util.Objects.requireNonNull;
+
 import akka.actor.ActorRef;
 import akka.actor.Status;
 import akka.actor.Status.Failure;
@@ -17,7 +19,6 @@ import akka.dispatch.OnComplete;
 import akka.dispatch.Recover;
 import akka.pattern.Patterns;
 import akka.util.Timeout;
-import com.google.common.base.Preconditions;
 import com.google.common.collect.Lists;
 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.util.AbstractMap.SimpleImmutableEntry;
@@ -31,7 +32,7 @@ import java.util.Optional;
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.CompletionStage;
 import java.util.concurrent.Executor;
-import javax.annotation.Nonnull;
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
 import org.opendaylight.controller.cluster.datastore.DataTreeCohortActor.CanCommit;
 import org.opendaylight.controller.cluster.datastore.DataTreeCohortActor.Success;
@@ -104,17 +105,16 @@ class CompositeDataTreeCohort {
     private final Executor callbackExecutor;
     private final Timeout timeout;
 
-    @Nonnull
-    private List<Success> successfulFromPrevious = Collections.emptyList();
+    private @NonNull List<Success> successfulFromPrevious = Collections.emptyList();
     private State state = State.IDLE;
 
     CompositeDataTreeCohort(final DataTreeCohortActorRegistry registry, final TransactionIdentifier transactionID,
         final SchemaContext schema, final Executor callbackExecutor, final Timeout timeout) {
-        this.registry = Preconditions.checkNotNull(registry);
-        this.txId = Preconditions.checkNotNull(transactionID);
-        this.schema = Preconditions.checkNotNull(schema);
-        this.callbackExecutor = Preconditions.checkNotNull(callbackExecutor);
-        this.timeout = Preconditions.checkNotNull(timeout);
+        this.registry = requireNonNull(registry);
+        this.txId = requireNonNull(transactionID);
+        this.schema = requireNonNull(schema);
+        this.callbackExecutor = requireNonNull(callbackExecutor);
+        this.timeout = requireNonNull(timeout);
     }
 
     void reset() {
@@ -222,8 +222,7 @@ class CompositeDataTreeCohort {
         return ret;
     }
 
-    @Nonnull
-    private CompletionStage<Void> processResponses(final List<Entry<ActorRef, Future<Object>>> futures,
+    private @NonNull CompletionStage<Void> processResponses(final List<Entry<ActorRef, Future<Object>>> futures,
             final State currentState, final State afterState) {
         LOG.debug("{}: processResponses - currentState: {}, afterState: {}", txId, currentState, afterState);
         final CompletableFuture<Void> returnFuture = new CompletableFuture<>();
@@ -232,7 +231,7 @@ class CompositeDataTreeCohort {
 
         aggregateFuture.onComplete(new OnComplete<Iterable<Object>>() {
             @Override
-            public void onComplete(Throwable failure, Iterable<Object> results) {
+            public void onComplete(final Throwable failure, final Iterable<Object> results) {
                 callbackExecutor.execute(
                     () -> processResponses(failure, results, currentState, afterState, returnFuture));
             }
@@ -243,9 +242,10 @@ class CompositeDataTreeCohort {
 
     // FB issues violation for passing null to CompletableFuture#complete but it is valid and necessary when the
     // generic type is Void.
-    @SuppressFBWarnings("NP_NONNULL_PARAM_VIOLATION")
-    private void processResponses(Throwable failure, Iterable<Object> results, State currentState, State afterState,
-            CompletableFuture<Void> resultFuture) {
+    @SuppressFBWarnings(value = { "NP_NONNULL_PARAM_VIOLATION", "UPM_UNCALLED_PRIVATE_METHOD" },
+            justification = "https://github.com/spotbugs/spotbugs/issues/811")
+    private void processResponses(final Throwable failure, final Iterable<Object> results,
+            final State currentState, final State afterState, final CompletableFuture<Void> resultFuture) {
         if (failure != null) {
             successfulFromPrevious = Collections.emptyList();
             resultFuture.completeExceptionally(failure);
@@ -260,7 +260,7 @@ class CompositeDataTreeCohort {
             } else if (result instanceof Status.Failure) {
                 failed.add((Failure) result);
             } else {
-                LOG.warn("{}: unrecognized response {}, ignoring it", result);
+                LOG.warn("{}: unrecognized response {}, ignoring it", txId, result);
             }
         }
 
@@ -284,7 +284,7 @@ class CompositeDataTreeCohort {
     }
 
     void changeStateFrom(final State expected, final State followup) {
-        Preconditions.checkState(state == expected);
+        checkState(state == expected);
         state = followup;
     }
 }