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%2Fsharding%2FDistributedShardChangePublisher.java;h=db8e1edebde2e6a2d3f1b72253e6d5a1f27e263e;hb=refs%2Fchanges%2F61%2F95161%2F6;hp=504ac101986ef2f1660a5943d901c20c40574d0f;hpb=127042ea7e148d9dc0282acc3780b4754ca69e12;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/DistributedShardChangePublisher.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/DistributedShardChangePublisher.java index 504ac10198..db8e1edebd 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/DistributedShardChangePublisher.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/DistributedShardChangePublisher.java @@ -17,12 +17,11 @@ import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; -import java.util.Optional; import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Collectors; -import javax.annotation.concurrent.GuardedBy; +import org.checkerframework.checker.lock.qual.GuardedBy; import org.opendaylight.controller.cluster.databroker.actors.dds.DataStoreClient; -import org.opendaylight.controller.cluster.datastore.AbstractDataStore; +import org.opendaylight.controller.cluster.datastore.DistributedDataStoreInterface; import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener; import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier; import org.opendaylight.mdsal.dom.spi.AbstractDOMDataTreeChangeListenerRegistration; @@ -33,27 +32,27 @@ import org.opendaylight.mdsal.dom.spi.store.DOMStoreTreeChangePublisher; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree; import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate; import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode; +import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNodes; import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidates; import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeConfiguration; import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification; import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException; -import org.opendaylight.yangtools.yang.data.api.schema.tree.ModificationType; import org.opendaylight.yangtools.yang.data.impl.schema.tree.InMemoryDataTreeFactory; import org.opendaylight.yangtools.yang.data.impl.schema.tree.SchemaValidationFailedException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +@Deprecated(forRemoval = true) public class DistributedShardChangePublisher extends AbstractRegistrationTree> implements DOMStoreTreeChangePublisher { private static final Logger LOG = LoggerFactory.getLogger(DistributedShardChangePublisher.class); - private final AbstractDataStore distributedDataStore; + private final DistributedDataStoreInterface distributedDataStore; private final YangInstanceIdentifier shardPath; private final Map childShards; @@ -62,7 +61,7 @@ public class DistributedShardChangePublisher private final DataTree dataTree; public DistributedShardChangePublisher(final DataStoreClient client, - final AbstractDataStore distributedDataStore, + final DistributedDataStoreInterface distributedDataStore, final DOMDataTreeIdentifier prefix, final Map childShards) { this.distributedDataStore = distributedDataStore; @@ -89,7 +88,7 @@ public class DistributedShardChangePublisher .build()); // XXX: can we guarantee that the root is present in the schemacontext? - this.dataTree.setSchemaContext(distributedDataStore.getActorUtils().getSchemaContext()); + this.dataTree.setEffectiveModelContext(distributedDataStore.getActorUtils().getSchemaContext()); this.shardPath = prefix.getRootIdentifier(); this.childShards = childShards; } @@ -158,7 +157,7 @@ public class DistributedShardChangePublisher @SuppressWarnings("unchecked") final AbstractDOMDataTreeChangeListenerRegistration registration = - new AbstractDOMDataTreeChangeListenerRegistration((L) listener) { + new AbstractDOMDataTreeChangeListenerRegistration<>((L) listener) { @Override protected void removeRegistration() { listener.close(); @@ -218,11 +217,12 @@ public class DistributedShardChangePublisher DataTreeCandidateNode modifiedChild = candidate.getRootNode(); for (final PathArgument pathArgument : listenerPath.getPathArguments()) { - modifiedChild = modifiedChild.getModifiedChild(pathArgument); + modifiedChild = modifiedChild.getModifiedChild(pathArgument).orElse(null); } + if (modifiedChild == null) { - modifiedChild = new EmptyDataTreeCandidateNode(dataTree.getRootPath().getLastPathArgument()); + modifiedChild = DataTreeCandidateNodes.empty(dataTree.getRootPath().getLastPathArgument()); } return DataTreeCandidates.newDataTreeCandidate(dataTree.getRootPath(), modifiedChild); @@ -317,44 +317,4 @@ public class DistributedShardChangePublisher registrations.clear(); } } - - private static final class EmptyDataTreeCandidateNode implements DataTreeCandidateNode { - - private final PathArgument identifier; - - EmptyDataTreeCandidateNode(final PathArgument identifier) { - this.identifier = requireNonNull(identifier, "Identifier should not be null"); - } - - @Override - public PathArgument getIdentifier() { - return identifier; - } - - @Override - public Collection getChildNodes() { - return Collections.emptySet(); - } - - @Override - @SuppressWarnings("checkstyle:hiddenField") - public DataTreeCandidateNode getModifiedChild(final PathArgument identifier) { - return null; - } - - @Override - public ModificationType getModificationType() { - return ModificationType.UNMODIFIED; - } - - @Override - public Optional> getDataAfter() { - return Optional.empty(); - } - - @Override - public Optional> getDataBefore() { - return Optional.empty(); - } - } }