@Test public void testMultipleProducerCursorCreation() throws Exception { final DOMDataTreeProducer rootProducer = dataTreeService.createProducer(Collections.singletonList(ROOT_ID)); DOMDataTreeCursorAwareTransaction rootTx = rootProducer.createTransaction(false); DOMDataTreeWriteCursor rootTxCursor = rootTx.createCursor(INNER_CONTAINER_ID); assertNotNull(rootTxCursor); rootTxCursor.close(); try { rootProducer.createProducer(Collections.singletonList(INNER_CONTAINER_ID)); fail("Should've failed there is still a tx open"); } catch (final IllegalStateException e) { assertTrue(e.getMessage().contains("open")); } assertTrue(rootTx.cancel()); final DOMDataTreeProducer innerContainerProducer = rootProducer.createProducer( Collections.singletonList(INNER_CONTAINER_ID)); rootTx = rootProducer.createTransaction(false); try { rootTx.createCursor(INNER_CONTAINER_ID); fail("Subtree should not be available to this producer"); } catch (final IllegalArgumentException e) { assertTrue(e.getMessage().contains("delegated to child producer")); } rootTxCursor = rootTx.createCursor(TEST_ID); assertNotNull(rootTxCursor); try { rootTxCursor.enter(INNER_CONTAINER_ID.getRootIdentifier().getLastPathArgument()); fail("Cursor should not have this subtree available"); } catch (final IllegalArgumentException e) { assertTrue(e.getMessage().contains("not available to this cursor")); } try { rootTxCursor.write(TestModel.INNER_CONTAINER_PATH.getLastPathArgument(), ImmutableContainerNodeBuilder.create() .withNodeIdentifier(new NodeIdentifier(TestModel.INNER_CONTAINER)) .build()); fail("Cursor should not have this subtree available"); } catch (final IllegalArgumentException e) { assertTrue(e.getMessage().contains("not available to this cursor")); } final DOMDataTreeCursorAwareTransaction innerShardTx = innerContainerProducer.createTransaction(false); final DOMDataTreeWriteCursor innerShardCursor = innerShardTx.createCursor(INNER_CONTAINER_ID); assertNotNull(innerShardCursor); }
@GuardedBy("this") private DOMDataTreeProducer createProducer(final Collection<DOMDataTreeIdentifier> subtrees, final Map<DOMDataTreeIdentifier, DOMDataTreeShard> shardMap) { final DOMDataTreeProducer ret = ShardedDOMDataTreeProducer.create(this, subtrees, shardMap); for (final DOMDataTreeIdentifier subtree : subtrees) { producers.store(subtree, ret); producerMap.put(subtree, ret); } return ret; }
ShardedDOMDataTree implements DOMDataTreeService, DOMDataTreeShardingService { @GuardedBy("this") private DOMDataTreeProducer createProducer(final Collection<DOMDataTreeIdentifier> subtrees, final Map<DOMDataTreeIdentifier, DOMDataTreeShard> shardMap) { final DOMDataTreeProducer ret = ShardedDOMDataTreeProducer.create(this, subtrees, shardMap); for (final DOMDataTreeIdentifier subtree : subtrees) { producers.store(subtree, ret); producerMap.put(subtree, ret); } return ret; } }
ShardedDOMDataTree implements DOMDataTreeService, DOMDataTreeShardingService { @GuardedBy("this") private DOMDataTreeProducer createProducer(final Collection<DOMDataTreeIdentifier> subtrees, final Map<DOMDataTreeIdentifier, DOMDataTreeShard> shardMap) { final DOMDataTreeProducer ret = ShardedDOMDataTreeProducer.create(this, subtrees, shardMap); for (final DOMDataTreeIdentifier subtree : subtrees) { producers.store(subtree, ret); producerMap.put(subtree, ret); } return ret; }  }
ShardedDOMDataTree implements DOMDataTreeService, DOMDataTreeShardingService { @GuardedBy("this") private DOMDataTreeProducer createProducer(final Collection<DOMDataTreeIdentifier> subtrees, final Map<DOMDataTreeIdentifier, DOMDataTreeShard> shardMap) { final DOMDataTreeProducer ret = ShardedDOMDataTreeProducer.create(this, subtrees, shardMap); for (final DOMDataTreeIdentifier subtree : subtrees) { producers.store(subtree, ret); producerMap.put(subtree, ret); } return ret; }  @Override DOMDataTreeShardRegistration<T> registerDataTreeShard(
            final DOMDataTreeIdentifier prefix, final T shard, final DOMDataTreeProducer producer); @Override ClassToInstanceMap<DOMDataTreeServiceExtension> getExtensions(); @Override synchronized DOMDataTreeProducer createProducer(final Collection<DOMDataTreeIdentifier> subtrees); @SuppressWarnings({ "checkstyle:IllegalCatch", "checkstyle:hiddenField" }) @Override synchronized ListenerRegistration<T> registerListener(final T listener,
            final Collection<DOMDataTreeIdentifier> subtrees, final boolean allowRxMerges,
            final Collection<DOMDataTreeProducer> producers); }
ShardedDOMDataTree implements DOMDataTreeService, DOMDataTreeShardingService { @GuardedBy("this") private DOMDataTreeProducer createProducer(final Collection<DOMDataTreeIdentifier> subtrees, final Map<DOMDataTreeIdentifier, DOMDataTreeShard> shardMap) { final DOMDataTreeProducer ret = ShardedDOMDataTreeProducer.create(this, subtrees, shardMap); for (final DOMDataTreeIdentifier subtree : subtrees) { producers.store(subtree, ret); producerMap.put(subtree, ret); } return ret; }  @Override DOMDataTreeShardRegistration<T> registerDataTreeShard(
            final DOMDataTreeIdentifier prefix, final T shard, final DOMDataTreeProducer producer); @Override ClassToInstanceMap<DOMDataTreeServiceExtension> getExtensions(); @Override synchronized DOMDataTreeProducer createProducer(final Collection<DOMDataTreeIdentifier> subtrees); @SuppressWarnings({ "checkstyle:IllegalCatch", "checkstyle:hiddenField" }) @Override synchronized ListenerRegistration<T> registerListener(final T listener,
            final Collection<DOMDataTreeIdentifier> subtrees, final boolean allowRxMerges,
            final Collection<DOMDataTreeProducer> producers);  }