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%2FEntityOwnershipShard.java;h=56b169c5562a30f2703f8321595961e332608a05;hb=refs%2Fchanges%2F24%2F62524%2F2;hp=e57874a3ad58d7c5559a174549e3ded2817d7001;hpb=5bbe45d0b189e706ed587e5e4a30c1205213c2f7;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/EntityOwnershipShard.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/EntityOwnershipShard.java index e57874a3ad..56b169c556 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/EntityOwnershipShard.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/EntityOwnershipShard.java @@ -38,6 +38,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; +import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.TimeUnit; @@ -60,6 +61,7 @@ import org.opendaylight.controller.cluster.datastore.messages.PeerUp; import org.opendaylight.controller.cluster.datastore.messages.SuccessReply; import org.opendaylight.controller.cluster.datastore.modification.DeleteModification; import org.opendaylight.controller.cluster.datastore.modification.MergeModification; +import org.opendaylight.controller.cluster.datastore.modification.Modification; import org.opendaylight.controller.cluster.datastore.modification.WriteModification; import org.opendaylight.controller.cluster.raft.RaftState; import org.opendaylight.mdsal.eos.dom.api.DOMEntity; @@ -169,8 +171,6 @@ class EntityOwnershipShard extends Shard { private void onRegisterCandidateLocal(final RegisterCandidateLocal registerCandidate) { LOG.debug("{}: onRegisterCandidateLocal: {}", persistenceId(), registerCandidate); - listenerSupport.setHasCandidateForEntity(registerCandidate.getEntity()); - NormalizedNode entityOwners = entityOwnersWithCandidate(registerCandidate.getEntity().getType(), registerCandidate.getEntity().getIdentifier(), localMemberName.getName()); commitCoordinator.commitModification(new MergeModification(ENTITY_OWNERS_PATH, entityOwners), this); @@ -182,8 +182,6 @@ class EntityOwnershipShard extends Shard { LOG.debug("{}: onUnregisterCandidateLocal: {}", persistenceId(), unregisterCandidate); DOMEntity entity = unregisterCandidate.getEntity(); - listenerSupport.unsetHasCandidateForEntity(entity); - YangInstanceIdentifier candidatePath = candidatePath(entity.getType(), entity.getIdentifier(), localMemberName.getName()); commitCoordinator.commitModification(new DeleteModification(candidatePath), this); @@ -473,7 +471,7 @@ class EntityOwnershipShard extends Shard { } private void selectNewOwnerForEntitiesOwnedBy(final Set ownedBy) { - final BatchedModifications modifications = commitCoordinator.newBatchedModifications(); + final List modifications = new ArrayList<>(); searchForEntitiesOwnedBy(ownedBy, (entityTypeNode, entityNode) -> { YangInstanceIdentifier entityPath = YangInstanceIdentifier.builder(ENTITY_TYPES_PATH) .node(entityTypeNode.getIdentifier()).node(ENTITY_NODE_ID).node(entityNode.getIdentifier()) @@ -484,8 +482,8 @@ class EntityOwnershipShard extends Shard { if (!newOwner.isEmpty()) { LOG.debug("{}: Found entity {}, writing new owner {}", persistenceId(), entityPath, newOwner); - modifications.addModification(new WriteModification(entityPath, - ImmutableNodes.leafNode(ENTITY_OWNER_NODE_ID, newOwner))); + modifications.add(new WriteModification(entityPath, + ImmutableNodes.leafNode(ENTITY_OWNER_NODE_ID, newOwner))); } else { LOG.debug("{}: Found entity {} but no other candidates - not clearing owner", persistenceId(), @@ -542,7 +540,7 @@ class EntityOwnershipShard extends Shard { } private void removeCandidateFromEntities(final MemberName member) { - final BatchedModifications modifications = commitCoordinator.newBatchedModifications(); + final List modifications = new ArrayList<>(); searchForEntities((entityTypeNode, entityNode) -> { if (hasCandidate(entityNode, member)) { YangInstanceIdentifier entityId = @@ -554,7 +552,7 @@ class EntityOwnershipShard extends Shard { LOG.info("{}: Found entity {}, removing candidate {}, path {}", persistenceId(), entityId, member, candidatePath); - modifications.addModification(new DeleteModification(candidatePath)); + modifications.add(new DeleteModification(candidatePath)); } });