@Test public void testWritesIntoDefaultShard() throws Exception { initEmptyDatastores(); final DOMDataTreeIdentifier configRoot = new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.empty()); final DOMDataTreeProducer producer = leaderShardFactory.createProducer(Collections.singleton(configRoot)); final DOMDataTreeCursorAwareTransaction tx = producer.createTransaction(true); final DOMDataTreeWriteCursor cursor = tx.createCursor(new DOMDataTreeIdentifier( LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.empty())); Assert.assertNotNull(cursor); final ContainerNode test = ImmutableContainerNodeBuilder.create() .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME)).build(); cursor.write(test.getIdentifier(), test); cursor.close(); tx.commit().get(); }
@Override public DOMDataTreeProducer createProducer(final Collection<DOMDataTreeIdentifier> subtrees) { LOG.debug("{} - Creating producer for {}", memberName, subtrees); final DOMDataTreeProducer producer = shardedDOMDataTree.createProducer(subtrees); final Object response = distributedConfigDatastore.getActorUtils() .executeOperation(shardedDataTreeActor, new ProducerCreated(subtrees)); if (response == null) { LOG.debug("{} - Received success from remote nodes, creating producer:{}", memberName, subtrees); return new ProxyProducer(producer, subtrees, shardedDataTreeActor, distributedConfigDatastore.getActorUtils(), shards); } closeProducer(producer); if (response instanceof Throwable) { Throwables.throwIfUnchecked((Throwable) response); throw new RuntimeException((Throwable) response); } throw new RuntimeException("Unexpected response to create producer received." + response); }
DistributedShardedDOMDataTree implements DOMDataTreeService, DOMDataTreeShardingService,
        DistributedShardFactory { @Override public DOMDataTreeProducer createProducer(final Collection<DOMDataTreeIdentifier> subtrees) { LOG.debug("{} - Creating producer for {}", memberName, subtrees); final DOMDataTreeProducer producer = shardedDOMDataTree.createProducer(subtrees); final Object response = distributedConfigDatastore.getActorUtils() .executeOperation(shardedDataTreeActor, new ProducerCreated(subtrees)); if (response == null) { LOG.debug("{} - Received success from remote nodes, creating producer:{}", memberName, subtrees); return new ProxyProducer(producer, subtrees, shardedDataTreeActor, distributedConfigDatastore.getActorUtils(), shards); } closeProducer(producer); if (response instanceof Throwable) { Throwables.throwIfUnchecked((Throwable) response); throw new RuntimeException((Throwable) response); } throw new RuntimeException("Unexpected response to create producer received." + response); } }
DistributedShardedDOMDataTree implements DOMDataTreeService, DOMDataTreeShardingService,
        DistributedShardFactory { @Override public DOMDataTreeProducer createProducer(final Collection<DOMDataTreeIdentifier> subtrees) { LOG.debug("{} - Creating producer for {}", memberName, subtrees); final DOMDataTreeProducer producer = shardedDOMDataTree.createProducer(subtrees); final Object response = distributedConfigDatastore.getActorUtils() .executeOperation(shardedDataTreeActor, new ProducerCreated(subtrees)); if (response == null) { LOG.debug("{} - Received success from remote nodes, creating producer:{}", memberName, subtrees); return new ProxyProducer(producer, subtrees, shardedDataTreeActor, distributedConfigDatastore.getActorUtils(), shards); } closeProducer(producer); if (response instanceof Throwable) { Throwables.throwIfUnchecked((Throwable) response); throw new RuntimeException((Throwable) response); } throw new RuntimeException("Unexpected response to create producer received." + response); } DistributedShardedDOMDataTree(final ActorSystemProvider actorSystemProvider,
                                         final DistributedDataStoreInterface distributedOperDatastore,
                                         final DistributedDataStoreInterface distributedConfigDatastore); }
DistributedShardedDOMDataTree implements DOMDataTreeService, DOMDataTreeShardingService,
        DistributedShardFactory { @Override public DOMDataTreeProducer createProducer(final Collection<DOMDataTreeIdentifier> subtrees) { LOG.debug("{} - Creating producer for {}", memberName, subtrees); final DOMDataTreeProducer producer = shardedDOMDataTree.createProducer(subtrees); final Object response = distributedConfigDatastore.getActorUtils() .executeOperation(shardedDataTreeActor, new ProducerCreated(subtrees)); if (response == null) { LOG.debug("{} - Received success from remote nodes, creating producer:{}", memberName, subtrees); return new ProxyProducer(producer, subtrees, shardedDataTreeActor, distributedConfigDatastore.getActorUtils(), shards); } closeProducer(producer); if (response instanceof Throwable) { Throwables.throwIfUnchecked((Throwable) response); throw new RuntimeException((Throwable) response); } throw new RuntimeException("Unexpected response to create producer received." + response); } DistributedShardedDOMDataTree(final ActorSystemProvider actorSystemProvider,
                                         final DistributedDataStoreInterface distributedOperDatastore,
                                         final DistributedDataStoreInterface distributedConfigDatastore); void init(); @Override ListenerRegistration<T> registerListener(
            final T listener, final Collection<DOMDataTreeIdentifier> subtrees,
            final boolean allowRxMerges, final Collection<DOMDataTreeProducer> producers); @Override ClassToInstanceMap<DOMDataTreeServiceExtension> getExtensions(); @Override DOMDataTreeProducer createProducer(final Collection<DOMDataTreeIdentifier> subtrees); @Override CompletionStage<DistributedShardRegistration> createDistributedShard(
            final DOMDataTreeIdentifier prefix, final Collection<MemberName> replicaMembers); @Override ListenerRegistration<T> registerDataTreeShard(
            final DOMDataTreeIdentifier prefix, final T shard, final DOMDataTreeProducer producer); }
DistributedShardedDOMDataTree implements DOMDataTreeService, DOMDataTreeShardingService,
        DistributedShardFactory { @Override public DOMDataTreeProducer createProducer(final Collection<DOMDataTreeIdentifier> subtrees) { LOG.debug("{} - Creating producer for {}", memberName, subtrees); final DOMDataTreeProducer producer = shardedDOMDataTree.createProducer(subtrees); final Object response = distributedConfigDatastore.getActorUtils() .executeOperation(shardedDataTreeActor, new ProducerCreated(subtrees)); if (response == null) { LOG.debug("{} - Received success from remote nodes, creating producer:{}", memberName, subtrees); return new ProxyProducer(producer, subtrees, shardedDataTreeActor, distributedConfigDatastore.getActorUtils(), shards); } closeProducer(producer); if (response instanceof Throwable) { Throwables.throwIfUnchecked((Throwable) response); throw new RuntimeException((Throwable) response); } throw new RuntimeException("Unexpected response to create producer received." + response); } DistributedShardedDOMDataTree(final ActorSystemProvider actorSystemProvider,
                                         final DistributedDataStoreInterface distributedOperDatastore,
                                         final DistributedDataStoreInterface distributedConfigDatastore); void init(); @Override ListenerRegistration<T> registerListener(
            final T listener, final Collection<DOMDataTreeIdentifier> subtrees,
            final boolean allowRxMerges, final Collection<DOMDataTreeProducer> producers); @Override ClassToInstanceMap<DOMDataTreeServiceExtension> getExtensions(); @Override DOMDataTreeProducer createProducer(final Collection<DOMDataTreeIdentifier> subtrees); @Override CompletionStage<DistributedShardRegistration> createDistributedShard(
            final DOMDataTreeIdentifier prefix, final Collection<MemberName> replicaMembers); @Override ListenerRegistration<T> registerDataTreeShard(
            final DOMDataTreeIdentifier prefix, final T shard, final DOMDataTreeProducer producer);  }