Search in sources :

Example 6 with DataTreeModification

use of org.opendaylight.yangtools.yang.data.tree.api.DataTreeModification in project yangtools by opendaylight.

the class InMemoryDataTreeBenchmark method write10KSingleNodeWithTenInnerItemsInOneCommitBenchmark.

@Benchmark
@Warmup(iterations = WARMUP_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
@Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
public void write10KSingleNodeWithTenInnerItemsInOneCommitBenchmark() throws DataValidationFailedException {
    final DataTreeModification modification = begin();
    for (int outerListKey = 0; outerListKey < OUTER_LIST_10K; ++outerListKey) {
        modification.write(OUTER_LIST_PATHS[outerListKey], OUTER_LIST_TEN_ITEM_INNER_LIST[outerListKey]);
    }
    commit(modification);
}
Also used : CursorAwareDataTreeModification(org.opendaylight.yangtools.yang.data.tree.api.CursorAwareDataTreeModification) DataTreeModification(org.opendaylight.yangtools.yang.data.tree.api.DataTreeModification) Measurement(org.openjdk.jmh.annotations.Measurement) Warmup(org.openjdk.jmh.annotations.Warmup) Benchmark(org.openjdk.jmh.annotations.Benchmark)

Example 7 with DataTreeModification

use of org.opendaylight.yangtools.yang.data.tree.api.DataTreeModification in project yangtools by opendaylight.

the class Bug3674Test method testDeleteOfNonExistingNode.

@Test
public void testDeleteOfNonExistingNode() throws DataValidationFailedException {
    final DataTreeModification mod = tree.takeSnapshot().newModification();
    mod.delete(TestModel.OUTER_LIST_PATH);
    mod.ready();
    final DataTreeCandidate candidate = tree.prepare(mod);
    final DataTreeCandidateNode root = candidate.getRootNode();
    assertEquals(ModificationType.UNMODIFIED, root.getModificationType());
}
Also used : DataTreeModification(org.opendaylight.yangtools.yang.data.tree.api.DataTreeModification) DataTreeCandidate(org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidate) DataTreeCandidateNode(org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode) Test(org.junit.Test)

Example 8 with DataTreeModification

use of org.opendaylight.yangtools.yang.data.tree.api.DataTreeModification in project yangtools by opendaylight.

the class Bug3674Test method setUp.

@Before
public void setUp() throws DataValidationFailedException {
    tree = new InMemoryDataTreeFactory().create(DataTreeConfiguration.DEFAULT_OPERATIONAL, SCHEMA_CONTEXT);
    // Create the top-level container
    final DataTreeModification mod = tree.takeSnapshot().newModification();
    mod.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
    mod.ready();
    tree.commit(tree.prepare(mod));
}
Also used : DataTreeModification(org.opendaylight.yangtools.yang.data.tree.api.DataTreeModification) InMemoryDataTreeFactory(org.opendaylight.yangtools.yang.data.tree.impl.di.InMemoryDataTreeFactory) Before(org.junit.Before)

Example 9 with DataTreeModification

use of org.opendaylight.yangtools.yang.data.tree.api.DataTreeModification in project yangtools by opendaylight.

the class Bug4454Test method minMaxListDeleteTest.

@Test
public void minMaxListDeleteTest() throws DataValidationFailedException {
    final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
    NodeIdentifierWithPredicates mapEntryPath2 = NodeIdentifierWithPredicates.of(MIN_MAX_LIST_QNAME, MIN_MAX_KEY_LEAF_QNAME, "foo");
    final YangInstanceIdentifier minMaxLeafFoo = MASTER_CONTAINER_PATH.node(MIN_MAX_LIST_QNAME).node(mapEntryPath2);
    mapEntryPath2 = NodeIdentifierWithPredicates.of(MIN_MAX_LIST_QNAME, MIN_MAX_KEY_LEAF_QNAME, "bar");
    final YangInstanceIdentifier minMaxLeafBar = MASTER_CONTAINER_PATH.node(MIN_MAX_LIST_QNAME).node(mapEntryPath2);
    mapEntryPath2 = NodeIdentifierWithPredicates.of(MIN_MAX_LIST_QNAME, MIN_MAX_KEY_LEAF_QNAME, "baz");
    final YangInstanceIdentifier minMaxLeafBaz = MASTER_CONTAINER_PATH.node(MIN_MAX_LIST_QNAME).node(mapEntryPath2);
    modificationTree.write(MIN_MAX_LIST_PATH, mapNodeFooWithNodes);
    modificationTree.merge(MIN_MAX_LIST_PATH, mapNodeBar);
    modificationTree.merge(MIN_MAX_LIST_PATH, mapNodeBaz);
    modificationTree.delete(minMaxLeafFoo);
    modificationTree.delete(minMaxLeafBar);
    modificationTree.delete(minMaxLeafBaz);
    modificationTree.ready();
    inMemoryDataTree.validate(modificationTree);
    final DataTreeCandidate prepare = inMemoryDataTree.prepare(modificationTree);
    inMemoryDataTree.commit(prepare);
    // Empty list should have disappeared, along with the container, as we are not enforcing root
    final NormalizedNode data = inMemoryDataTree.takeSnapshot().readNode(YangInstanceIdentifier.empty()).get();
    assertTrue(data instanceof ContainerNode);
    assertEquals(0, ((ContainerNode) data).size());
}
Also used : DataTreeModification(org.opendaylight.yangtools.yang.data.tree.api.DataTreeModification) DataTreeCandidate(org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidate) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) NodeIdentifierWithPredicates(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates) NormalizedNode(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) Test(org.junit.Test)

Example 10 with DataTreeModification

use of org.opendaylight.yangtools.yang.data.tree.api.DataTreeModification in project yangtools by opendaylight.

the class Bug4454Test method minMaxLeafListPass.

@Test
public void minMaxLeafListPass() throws DataValidationFailedException {
    final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
    final NodeWithValue<?> barPath = new NodeWithValue<>(MIN_MAX_LIST_QNAME, "bar");
    final NodeWithValue<?> gooPath = new NodeWithValue<>(MIN_MAX_LIST_QNAME, "goo");
    final LeafSetEntryNode<Object> barLeafSetEntry = ImmutableLeafSetEntryNodeBuilder.create().withNodeIdentifier(barPath).withValue("bar").build();
    final LeafSetEntryNode<Object> gooLeafSetEntry = ImmutableLeafSetEntryNodeBuilder.create().withNodeIdentifier(gooPath).withValue("goo").build();
    final LeafSetNode<Object> fooLeafSetNode = ImmutableLeafSetNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(MIN_MAX_LEAF_LIST_QNAME)).withChildValue("foo").build();
    modificationTree.write(MIN_MAX_LEAF_LIST_PATH, fooLeafSetNode);
    modificationTree.write(MIN_MAX_LEAF_LIST_PATH.node(barPath), barLeafSetEntry);
    modificationTree.ready();
    inMemoryDataTree.validate(modificationTree);
    final DataTreeCandidate prepare1 = inMemoryDataTree.prepare(modificationTree);
    inMemoryDataTree.commit(prepare1);
    DataTreeSnapshot test1 = inMemoryDataTree.takeSnapshot();
    DataTreeModification tempMod1 = test1.newModification();
    tempMod1.write(MIN_MAX_LEAF_LIST_PATH.node(gooPath), gooLeafSetEntry);
    tempMod1.write(MIN_MAX_LEAF_LIST_PATH.node(barPath), barLeafSetEntry);
    tempMod1.ready();
    inMemoryDataTree.validate(tempMod1);
    final DataTreeCandidate prepare2 = inMemoryDataTree.prepare(tempMod1);
    inMemoryDataTree.commit(prepare2);
    final DataTreeSnapshot snapshotAfterCommit = inMemoryDataTree.takeSnapshot();
    final Optional<NormalizedNode> masterContainer = snapshotAfterCommit.readNode(MASTER_CONTAINER_PATH);
    assertTrue(masterContainer.isPresent());
    final Optional<NormalizedNodeContainer<?>> leafList = ((DistinctNodeContainer) masterContainer.get()).findChildByArg(new NodeIdentifier(MIN_MAX_LEAF_LIST_QNAME));
    assertTrue(leafList.isPresent());
    assertEquals(3, leafList.get().size());
}
Also used : DataTreeModification(org.opendaylight.yangtools.yang.data.tree.api.DataTreeModification) DistinctNodeContainer(org.opendaylight.yangtools.yang.data.api.schema.DistinctNodeContainer) DataTreeCandidate(org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidate) NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) NormalizedNodeContainer(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodeContainer) NodeWithValue(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue) DataTreeSnapshot(org.opendaylight.yangtools.yang.data.tree.api.DataTreeSnapshot) NormalizedNode(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode) Test(org.junit.Test)

Aggregations

DataTreeModification (org.opendaylight.yangtools.yang.data.tree.api.DataTreeModification)162 Test (org.junit.Test)112 DataTreeCandidate (org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidate)102 NodeIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier)44 DataTree (org.opendaylight.yangtools.yang.data.tree.api.DataTree)43 DataTreeSnapshot (org.opendaylight.yangtools.yang.data.tree.api.DataTreeSnapshot)36 ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)32 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)31 NormalizedNode (org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)23 InMemoryDataTreeFactory (org.opendaylight.yangtools.yang.data.tree.impl.di.InMemoryDataTreeFactory)17 MapEntryNode (org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode)12 CursorAwareDataTreeModification (org.opendaylight.yangtools.yang.data.tree.api.CursorAwareDataTreeModification)11 ConflictingModificationAppliedException (org.opendaylight.yangtools.yang.data.tree.api.ConflictingModificationAppliedException)10 SystemMapNode (org.opendaylight.yangtools.yang.data.api.schema.SystemMapNode)9 DataTreeCandidateNode (org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode)9 NodeIdentifierWithPredicates (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates)7 Benchmark (org.openjdk.jmh.annotations.Benchmark)6 Measurement (org.openjdk.jmh.annotations.Measurement)6 Warmup (org.openjdk.jmh.annotations.Warmup)6 ChoiceNode (org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode)5