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%2FDistributedShardedDOMDataTree.java;h=64c3f14dfb5dde59806c31dd3f92e92af745ebc7;hb=3dc48592696e6a4535c0e125c1e23dbc62bc9091;hp=0348e7a2af12fc45e86f19af0c5bcf600348feac;hpb=048d61c7408875c1483d912c5837ae36fd689304;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/DistributedShardedDOMDataTree.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/DistributedShardedDOMDataTree.java index 0348e7a2af..64c3f14dfb 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/DistributedShardedDOMDataTree.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/DistributedShardedDOMDataTree.java @@ -31,9 +31,9 @@ import com.google.common.util.concurrent.MoreExecutors; import com.google.common.util.concurrent.SettableFuture; import com.google.common.util.concurrent.Uninterruptibles; import java.util.AbstractMap.SimpleEntry; -import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.Comparator; import java.util.EnumMap; import java.util.HashMap; import java.util.List; @@ -238,17 +238,8 @@ public class DistributedShardedDOMDataTree implements DOMDataTreeService, DOMDat //create shard registration for DEFAULT_SHARD - try { - initDefaultShard(LogicalDatastoreType.CONFIGURATION); - } catch (final InterruptedException | ExecutionException e) { - throw new IllegalStateException("Unable to create default shard frontend for config shard", e); - } - - try { - initDefaultShard(LogicalDatastoreType.OPERATIONAL); - } catch (final InterruptedException | ExecutionException e) { - throw new IllegalStateException("Unable to create default shard frontend for operational shard", e); - } + initDefaultShard(LogicalDatastoreType.CONFIGURATION); + initDefaultShard(LogicalDatastoreType.OPERATIONAL); } private ListenableFuture> handleConfigShardLookup() { @@ -267,7 +258,7 @@ public class DistributedShardedDOMDataTree implements DOMDataTreeService, DOMDat ask.onComplete(new OnComplete() { @Override - public void onComplete(final Throwable throwable, final Object result) throws Throwable { + public void onComplete(final Throwable throwable, final Object result) { if (throwable != null) { future.setException(throwable); } else { @@ -288,12 +279,6 @@ public class DistributedShardedDOMDataTree implements DOMDataTreeService, DOMDat return shardedDOMDataTree.registerListener(listener, subtrees, allowRxMerges, producers); } - @Override - @Deprecated - public Map, DOMDataTreeServiceExtension> getSupportedExtensions() { - return ImmutableClassToInstanceMap.of(); - } - @Override public ClassToInstanceMap getExtensions() { return ImmutableClassToInstanceMap.of(); @@ -378,19 +363,11 @@ public class DistributedShardedDOMDataTree implements DOMDataTreeService, DOMDat void resolveShardAdditions(final Set additions) { LOG.debug("{}: Resolving additions : {}", memberName, additions); - final ArrayList list = new ArrayList<>(additions); // we need to register the shards from top to bottom, so we need to atleast make sure the ordering reflects that - Collections.sort(list, (o1, o2) -> { - if (o1.getRootIdentifier().getPathArguments().size() < o2.getRootIdentifier().getPathArguments().size()) { - return -1; - } else if (o1.getRootIdentifier().getPathArguments().size() - == o2.getRootIdentifier().getPathArguments().size()) { - return 0; - } else { - return 1; - } - }); - list.forEach(this::createShardFrontend); + additions + .stream() + .sorted(Comparator.comparingInt(o -> o.getRootIdentifier().getPathArguments().size())) + .forEachOrdered(this::createShardFrontend); } void resolveShardRemovals(final Set removals) { @@ -516,8 +493,7 @@ public class DistributedShardedDOMDataTree implements DOMDataTreeService, DOMDat } @SuppressWarnings("checkstyle:IllegalCatch") - private void initDefaultShard(final LogicalDatastoreType logicalDatastoreType) - throws ExecutionException, InterruptedException { + private void initDefaultShard(final LogicalDatastoreType logicalDatastoreType) { final PrefixedShardConfigWriter writer = writerMap.get(logicalDatastoreType);