X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2Fentityownership%2FDistributedEntityOwnershipService.java;h=944d14a3d91b1c9441f6569689d1e43bb1f2e415;hp=48c68e7a6bbef170aef9c940b1f186127640f440;hb=2d60632f7cf63712e8357a3cf3fc40d83366e5e6;hpb=6b31b94c7c06711efd69f7fd456167026f34dc2e 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..944d14a3d9 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); } @@ -194,9 +195,11 @@ 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 Optional> optionalCandidates = + entity.getChild(CANDIDATE_NODE_ID); + final boolean hasCandidates = optionalCandidates.isPresent() + && ((MapNode) optionalCandidates.get()).getValue().size() > 0; + if (!hasCandidates) { return Optional.absent(); } @@ -215,10 +218,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()); }