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%2FEntityOwnershipShard.java;h=74cc6717dcb44b330d38e211a899690a39b0e316;hp=30fafbbb10f4e78b1a09f0a5c6ec2559a4d88bf3;hb=207129172cb981630f955170cb67efceba02df85;hpb=488ec1e9d3552ec60c5dd6acb757d6f6c194a672;ds=sidebyside 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 30fafbbb10..74cc6717dc 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 @@ -7,7 +7,6 @@ */ package org.opendaylight.controller.cluster.datastore.entityownership; -import static org.opendaylight.controller.cluster.datastore.entityownership.EntityOwnersModel.CANDIDATE_NAME_NODE_ID; import static org.opendaylight.controller.cluster.datastore.entityownership.EntityOwnersModel.CANDIDATE_NODE_ID; import static org.opendaylight.controller.cluster.datastore.entityownership.EntityOwnersModel.ENTITY_ID_NODE_ID; import static org.opendaylight.controller.cluster.datastore.entityownership.EntityOwnersModel.ENTITY_ID_QNAME; @@ -269,7 +268,7 @@ class EntityOwnershipShard extends Shard { LOG.debug("{}: oldLeaderMemberName: {}", persistenceId(), oldLeaderMemberName); if(downPeerMemberNames.contains(oldLeaderMemberName)) { - selectNewOwnerForEntitiesOwnedBy(oldLeaderMemberName); + removeCandidateFromEntities(oldLeaderMemberName); } } else { // The leader changed - notify the coordinator to check if pending modifications need to be sent. @@ -359,32 +358,6 @@ class EntityOwnershipShard extends Shard { commitCoordinator.onStateChanged(this, isLeader()); } - private void selectNewOwnerForEntitiesOwnedBy(String owner) { - final BatchedModifications modifications = commitCoordinator.newBatchedModifications(); - searchForEntitiesOwnedBy(owner, new EntityWalker() { - @Override - public void onEntity(MapEntryNode entityTypeNode, MapEntryNode entityNode) { - - YangInstanceIdentifier entityPath = YangInstanceIdentifier.builder(ENTITY_TYPES_PATH). - node(entityTypeNode.getIdentifier()).node(ENTITY_NODE_ID).node(entityNode.getIdentifier()). - node(ENTITY_OWNER_NODE_ID).build(); - - String entityType = EntityOwnersModel.entityTypeFromEntityPath(entityPath); - - Object newOwner = newOwner(getCandidateNames(entityNode), - entityOwnershipStatistics.byEntityType(entityType), - getEntityOwnerElectionStrategy(entityPath)); - - LOG.debug("{}: Found entity {}, writing new owner {}", persistenceId(), entityPath, newOwner); - - modifications.addModification(new WriteModification(entityPath, - ImmutableNodes.leafNode(ENTITY_OWNER_NODE_ID, newOwner))); - } - }); - - commitCoordinator.commitModifications(modifications, this); - } - private void removeCandidateFromEntities(final String owner) { final BatchedModifications modifications = commitCoordinator.newBatchedModifications(); searchForEntities(new EntityWalker() { @@ -451,16 +424,6 @@ class EntityOwnershipShard extends Shard { } } - private static Collection getCandidateNames(MapEntryNode entity) { - Collection candidates = ((MapNode) entity.getChild(CANDIDATE_NODE_ID).get()).getValue(); - Collection candidateNames = new ArrayList<>(candidates.size()); - for(MapEntryNode candidate: candidates) { - candidateNames.add(candidate.getChild(CANDIDATE_NAME_NODE_ID).get().getValue().toString()); - } - - return candidateNames; - } - private void writeNewOwner(YangInstanceIdentifier entityPath, String newOwner) { LOG.debug("{}: Writing new owner {} for entity {}", persistenceId(), newOwner, entityPath);