X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2Fentityownership%2FDistributedEntityOwnershipService.java;h=1cb744670e7e5eb6e1c2e32f70e816b38f39bd2a;hb=634dfac8eead60f443bf75e749c70d1f2bb29198;hp=48c68e7a6bbef170aef9c940b1f186127640f440;hpb=6b31b94c7c06711efd69f7fd456167026f34dc2e;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/DistributedEntityOwnershipService.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/DistributedEntityOwnershipService.java index 48c68e7a6b..1cb744670e 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/DistributedEntityOwnershipService.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/DistributedEntityOwnershipService.java @@ -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() { @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 future = context.findLocalShardAsync(ENTITY_OWNERSHIP_SHARD_NAME); future.onComplete(new OnComplete() { @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> entityNode = dataTree.takeSnapshot().readNode( + java.util.Optional> 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> optionalCandidates = entity.getChild(CANDIDATE_NODE_ID); - final boolean hasCandidates = optionalCandidates.isPresent() && ((MapNode) optionalCandidates.get()).getValue().size() > 0; - if(!hasCandidates){ + final java.util.Optional> 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> ownerLeaf = entity.getChild(ENTITY_OWNER_NODE_ID); + java.util.Optional> 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()); }