Bump odlparent to 3.1.2
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / entityownership / DistributedEntityOwnershipService.java
index 48c68e7a6bbef170aef9c940b1f186127640f440..1cb744670e7e5eb6e1c2e32f70e816b38f39bd2a 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.controller.cluster.datastore.entityownership;
 import static org.opendaylight.controller.cluster.datastore.entityownership.EntityOwnersModel.CANDIDATE_NODE_ID;
 import static org.opendaylight.controller.cluster.datastore.entityownership.EntityOwnersModel.ENTITY_OWNER_NODE_ID;
 import static org.opendaylight.controller.cluster.datastore.entityownership.EntityOwnersModel.entityPath;
+
 import akka.actor.ActorRef;
 import akka.dispatch.OnComplete;
 import akka.pattern.Patterns;
@@ -73,7 +74,7 @@ public class DistributedEntityOwnershipService implements DOMEntityOwnershipServ
     private volatile ActorRef localEntityOwnershipShard;
     private volatile DataTree localEntityOwnershipShardDataTree;
 
-    private DistributedEntityOwnershipService(final ActorContext context) {
+    DistributedEntityOwnershipService(final ActorContext context) {
         this.context = Preconditions.checkNotNull(context);
     }
 
@@ -109,10 +110,10 @@ public class DistributedEntityOwnershipService implements DOMEntityOwnershipServ
         future.onComplete(new OnComplete<Object>() {
             @Override
             public void onComplete(final Throwable failure, final Object response) {
-                if(failure != null) {
+                if (failure != null) {
                     LOG.debug("Error sending message {} to {}", message, shardActor, failure);
                 } else {
-                    LOG.debug("{} message to {} succeeded", message, shardActor, failure);
+                    LOG.debug("{} message to {} succeeded", message, shardActor);
                 }
             }
         }, context.getClientDispatcher());
@@ -120,12 +121,12 @@ public class DistributedEntityOwnershipService implements DOMEntityOwnershipServ
 
     @VisibleForTesting
     void executeLocalEntityOwnershipShardOperation(final Object message) {
-        if(localEntityOwnershipShard == null) {
+        if (localEntityOwnershipShard == null) {
             Future<ActorRef> future = context.findLocalShardAsync(ENTITY_OWNERSHIP_SHARD_NAME);
             future.onComplete(new OnComplete<ActorRef>() {
                 @Override
                 public void onComplete(final Throwable failure, final ActorRef shardActor) {
-                    if(failure != null) {
+                    if (failure != null) {
                         LOG.error("Failed to find local {} shard", ENTITY_OWNERSHIP_SHARD_NAME, failure);
                     } else {
                         localEntityOwnershipShard = shardActor;
@@ -144,7 +145,7 @@ public class DistributedEntityOwnershipService implements DOMEntityOwnershipServ
             throws CandidateAlreadyRegisteredException {
         Preconditions.checkNotNull(entity, "entity cannot be null");
 
-        if(registeredEntities.putIfAbsent(entity, entity) != null) {
+        if (registeredEntities.putIfAbsent(entity, entity) != null) {
             throw new CandidateAlreadyRegisteredException(entity);
         }
 
@@ -186,7 +187,7 @@ public class DistributedEntityOwnershipService implements DOMEntityOwnershipServ
             return Optional.absent();
         }
 
-        Optional<NormalizedNode<?, ?>> entityNode = dataTree.takeSnapshot().readNode(
+        java.util.Optional<NormalizedNode<?, ?>> entityNode = dataTree.takeSnapshot().readNode(
                 entityPath(forEntity.getType(), forEntity.getIdentifier()));
         if (!entityNode.isPresent()) {
             return Optional.absent();
@@ -194,14 +195,17 @@ public class DistributedEntityOwnershipService implements DOMEntityOwnershipServ
 
         // Check if there are any candidates, if there are none we do not really have ownership state
         final MapEntryNode entity = (MapEntryNode) entityNode.get();
-        final Optional<DataContainerChild<? extends PathArgument, ?>> optionalCandidates = entity.getChild(CANDIDATE_NODE_ID);
-        final boolean hasCandidates = optionalCandidates.isPresent() && ((MapNode) optionalCandidates.get()).getValue().size() > 0;
-        if(!hasCandidates){
+        final java.util.Optional<DataContainerChild<? extends PathArgument, ?>> optionalCandidates =
+                entity.getChild(CANDIDATE_NODE_ID);
+        final boolean hasCandidates = optionalCandidates.isPresent()
+                && ((MapNode) optionalCandidates.get()).getValue().size() > 0;
+        if (!hasCandidates) {
             return Optional.absent();
         }
 
         MemberName localMemberName = context.getCurrentMemberName();
-        Optional<DataContainerChild<? extends PathArgument, ?>> ownerLeaf = entity.getChild(ENTITY_OWNER_NODE_ID);
+        java.util.Optional<DataContainerChild<? extends PathArgument, ?>> ownerLeaf = entity.getChild(
+            ENTITY_OWNER_NODE_ID);
         String owner = ownerLeaf.isPresent() ? ownerLeaf.get().getValue().toString() : null;
         boolean hasOwner = !Strings.isNullOrEmpty(owner);
         boolean isOwner = hasOwner && localMemberName.getName().equals(owner);
@@ -215,10 +219,11 @@ public class DistributedEntityOwnershipService implements DOMEntityOwnershipServ
     }
 
     @VisibleForTesting
+    @SuppressWarnings("checkstyle:IllegalCatch")
     DataTree getLocalEntityOwnershipShardDataTree() {
         if (localEntityOwnershipShardDataTree == null) {
             try {
-                if(localEntityOwnershipShard == null) {
+                if (localEntityOwnershipShard == null) {
                     localEntityOwnershipShard = Await.result(context.findLocalShardAsync(
                             ENTITY_OWNERSHIP_SHARD_NAME), Duration.Inf());
                 }