X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-dom-broker%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fmd%2Fsal%2Fdom%2Fbroker%2Fimpl%2FShardedDOMDataTree.java;h=cd9f7bd37991bb03ba7861a73371bde03badc4c8;hb=b712eb01354ddb5878008e2a2e8f03fb19b92555;hp=11eae5d8334ef2e91d0be9baa0c5e25f79e8fc14;hpb=5c008222efa5c0af49cf8a52881a6299b1e249dc;p=controller.git 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..cd9f7bd379 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 @@ -45,11 +45,7 @@ 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 t = shardingTables.computeIfAbsent(prefix.getDatastoreType(), k -> new ShardingTableEntry()); t.store(prefix.getRootIdentifier(), reg); } @@ -95,12 +91,12 @@ 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 +113,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 +123,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 +147,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); @@ -166,7 +162,7 @@ public final class ShardedDOMDataTree implements DOMDataTreeService, DOMDataTree Preconditions.checkNotNull(parent); final Map shardMap = new HashMap<>(); - for (DOMDataTreeIdentifier s : subtrees) { + for (final DOMDataTreeIdentifier s : subtrees) { shardMap.put(s, lookupShard(s).getRegistration().getInstance()); } @@ -175,7 +171,7 @@ 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; + // FIXME Implement this. + throw new UnsupportedOperationException("Not implemented yet."); } }