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=11eae5d8334ef2e91d0be9baa0c5e25f79e8fc14;hb=0b161730fd648bfa4c953e84b2d6a66972bc4da2;hpb=3927509ec3ecfa32a51b725d2b7155d425f5b877 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 11eae5d833..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 {}", 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); @@ -117,7 +123,7 @@ public final class ShardedDOMDataTree implements DOMDataTreeService, DOMDataTree @GuardedBy("this") private DOMDataTreeProducer findProducer(final DOMDataTreeIdentifier subtree) { - for (Entry e : idToProducer.entrySet()) { + for (final Entry e : idToProducer.entrySet()) { if (e.getKey().contains(subtree)) { return e.getValue(); } @@ -127,10 +133,10 @@ public final class ShardedDOMDataTree implements DOMDataTreeService, DOMDataTree } synchronized void destroyProducer(final ShardedDOMDataTreeProducer producer) { - for (DOMDataTreeIdentifier s : producer.getSubtrees()) { - DOMDataTreeProducer r = idToProducer.remove(s); + 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); } } } @@ -151,7 +157,7 @@ public final class ShardedDOMDataTree implements DOMDataTreeService, DOMDataTree Preconditions.checkArgument(!subtrees.isEmpty(), "Subtrees may not be empty"); final Map shardMap = new HashMap<>(); - for (DOMDataTreeIdentifier s : subtrees) { + for (final DOMDataTreeIdentifier s : subtrees) { // Attempting to create a disconnected producer -- all subtrees have to be unclaimed final DOMDataTreeProducer producer = findProducer(s); Preconditions.checkArgument(producer == null, "Subtree %s is attached to producer %s", s, producer); @@ -162,11 +168,12 @@ 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<>(); - for (DOMDataTreeIdentifier s : subtrees) { + for (final DOMDataTreeIdentifier s : subtrees) { shardMap.put(s, lookupShard(s).getRegistration().getInstance()); } @@ -174,8 +181,12 @@ public final class ShardedDOMDataTree implements DOMDataTreeService, DOMDataTree } @Override - public synchronized ListenerRegistration registerListener(final T listener, final Collection subtrees, final boolean allowRxMerges, final Collection producers) { - // TODO Auto-generated method stub - return null; + 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."); } }