X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-dom-broker%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fmd%2Fsal%2Fdom%2Fbroker%2Fimpl%2FShardedDOMDataTree.java;h=9e7596f5561821dc2078c1bd4b080640bf6edd79;hp=c882d5c522f85c4c7675eb33a556f42f0e5b32a0;hb=0b161730fd648bfa4c953e84b2d6a66972bc4da2;hpb=79d7cc9bdb75fa015c8cadc0bd02314d646f2d57 diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/ShardedDOMDataTree.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/ShardedDOMDataTree.java index c882d5c522..9e7596f556 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/ShardedDOMDataTree.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/ShardedDOMDataTree.java @@ -27,9 +27,16 @@ import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +/** + * Shared DOM data tree. + * + * @deprecated Use {@link org.opendaylight.mdsal.dom.broker.ShardedDOMDataTree} instead. + */ +@Deprecated public final class ShardedDOMDataTree implements DOMDataTreeService, DOMDataTreeShardingService { private static final Logger LOG = LoggerFactory.getLogger(ShardedDOMDataTree.class); - private final Map shardingTables = new EnumMap<>(LogicalDatastoreType.class); + private final Map shardingTables = new EnumMap<>( + LogicalDatastoreType.class); @GuardedBy("this") private final Map idToProducer = new TreeMap<>(); @@ -45,13 +52,10 @@ public final class ShardedDOMDataTree implements DOMDataTreeService, DOMDataTree @GuardedBy("this") private void storeShard(final DOMDataTreeIdentifier prefix, final ShardRegistration reg) { - ShardingTableEntry t = shardingTables.get(prefix.getDatastoreType()); - if (t == null) { - t = new ShardingTableEntry(); - shardingTables.put(prefix.getDatastoreType(), t); - } + ShardingTableEntry shardingTableEntry = shardingTables + .computeIfAbsent(prefix.getDatastoreType(), k -> new ShardingTableEntry()); - t.store(prefix.getRootIdentifier(), reg); + shardingTableEntry.store(prefix.getRootIdentifier(), reg); } void removeShard(final ShardRegistration reg) { @@ -82,7 +86,8 @@ public final class ShardedDOMDataTree implements DOMDataTreeService, DOMDataTree } @Override - public ListenerRegistration registerDataTreeShard(final DOMDataTreeIdentifier prefix, final T shard) throws DOMDataTreeShardingConflictException { + public ListenerRegistration registerDataTreeShard( + final DOMDataTreeIdentifier prefix, final T shard) throws DOMDataTreeShardingConflictException { final ShardRegistration reg; final ShardRegistration parentReg; @@ -95,12 +100,13 @@ public final class ShardedDOMDataTree implements DOMDataTreeService, DOMDataTree final ShardingTableEntry parent = lookupShard(prefix); parentReg = parent.getRegistration(); if (parentReg != null && prefix.equals(parentReg.getPrefix())) { - throw new DOMDataTreeShardingConflictException(String.format("Prefix %s is already occupied by shard %s", prefix, parentReg.getInstance())); + throw new DOMDataTreeShardingConflictException( + String.format("Prefix %s is already occupied by shard %s", prefix, parentReg.getInstance())); } // FIXME: wrap the shard in a proper adaptor based on implemented interface - reg = new ShardRegistration(this, prefix, shard); + reg = new ShardRegistration<>(this, prefix, shard); storeShard(prefix, reg); @@ -130,7 +136,7 @@ public final class ShardedDOMDataTree implements DOMDataTreeService, DOMDataTree for (final DOMDataTreeIdentifier s : producer.getSubtrees()) { final DOMDataTreeProducer r = idToProducer.remove(s); if (!producer.equals(r)) { - LOG.error("Removed producer %s on subtree %s while removing %s", r, s, producer); + LOG.error("Removed producer {} on subtree {} while removing {}", r, s, producer); } } } @@ -139,7 +145,7 @@ public final class ShardedDOMDataTree implements DOMDataTreeService, DOMDataTree private DOMDataTreeProducer createProducer(final Map shardMap) { // Record the producer's attachment points final DOMDataTreeProducer ret = ShardedDOMDataTreeProducer.create(this, shardMap); - for (final DOMDataTreeIdentifier s : shardMap.keySet()) { + for (DOMDataTreeIdentifier s : shardMap.keySet()) { idToProducer.put(s, ret); } @@ -162,7 +168,8 @@ public final class ShardedDOMDataTree implements DOMDataTreeService, DOMDataTree return createProducer(shardMap); } - synchronized DOMDataTreeProducer createProducer(final ShardedDOMDataTreeProducer parent, final Collection subtrees) { + synchronized DOMDataTreeProducer createProducer(final ShardedDOMDataTreeProducer parent, + final Collection subtrees) { Preconditions.checkNotNull(parent); final Map shardMap = new HashMap<>(); @@ -174,7 +181,11 @@ public final class ShardedDOMDataTree implements DOMDataTreeService, DOMDataTree } @Override - public synchronized ListenerRegistration registerListener(final T listener, final Collection subtrees, final boolean allowRxMerges, final Collection producers) { + public synchronized ListenerRegistration + registerListener(final T listener, + final Collection subtrees, + final boolean allowRxMerges, + final Collection producers) { // FIXME Implement this. throw new UnsupportedOperationException("Not implemented yet."); }