Search in sources :

Example 1 with DataTreeModification

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

the class SnapshotBackedWriteTransaction method merge.

@SuppressWarnings("checkstyle:IllegalCatch")
@Override
public void merge(final YangInstanceIdentifier path, final NormalizedNode data) {
    checkNotReady();
    final DataTreeModification tree = mutableTree;
    LOG.debug("Tx: {} Merge: {}:{}", getIdentifier(), path, data);
    try {
        tree.merge(path, data);
    // FIXME: Add checked exception
    } catch (Exception e) {
        LOG.error("Tx: {}, failed to merge {}:{} in {}", getIdentifier(), path, data, tree, e);
        // Rethrow original ones if they are subclasses of RuntimeException or Error
        Throwables.throwIfUnchecked(e);
        // FIXME: Introduce proper checked exception
        throw new IllegalArgumentException("Illegal input data.", e);
    }
}
Also used : DataTreeModification(org.opendaylight.yangtools.yang.data.tree.api.DataTreeModification)

Example 2 with DataTreeModification

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

the class SnapshotBackedWriteTransaction method ready.

@SuppressWarnings("checkstyle:IllegalCatch")
@Override
public DOMStoreThreePhaseCommitCohort ready() {
    @SuppressWarnings("unchecked") final TransactionReadyPrototype<T> wasReady = READY_UPDATER.getAndSet(this, null);
    checkState(wasReady != null, "Transaction %s is no longer open", getIdentifier());
    LOG.debug("Store transaction: {} : Ready", getIdentifier());
    final DataTreeModification tree = mutableTree;
    TREE_UPDATER.lazySet(this, null);
    try {
        tree.ready();
        return wasReady.transactionReady(this, tree, null);
    } catch (RuntimeException e) {
        LOG.debug("Store transaction: {}: unexpected failure when readying", getIdentifier(), e);
        return wasReady.transactionReady(this, tree, e);
    }
}
Also used : DataTreeModification(org.opendaylight.yangtools.yang.data.tree.api.DataTreeModification)

Example 3 with DataTreeModification

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

the class InMemoryDataTreeBenchmark method write50KSingleNodeWithTwoInnerItemsInCommitPerWriteBenchmark.

@Benchmark
@Warmup(iterations = WARMUP_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
@Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
public void write50KSingleNodeWithTwoInnerItemsInCommitPerWriteBenchmark() throws DataValidationFailedException {
    for (int outerListKey = 0; outerListKey < OUTER_LIST_50K; ++outerListKey) {
        final DataTreeModification modification = begin();
        modification.write(OUTER_LIST_PATHS[outerListKey], OUTER_LIST_TWO_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 4 with DataTreeModification

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

the class InMemoryDataTreeBenchmark method write10KSingleNodeWithTenInnerItemsInCommitPerWriteBenchmark.

@Benchmark
@Warmup(iterations = WARMUP_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
@Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
public void write10KSingleNodeWithTenInnerItemsInCommitPerWriteBenchmark() throws DataValidationFailedException {
    for (int outerListKey = 0; outerListKey < OUTER_LIST_10K; ++outerListKey) {
        final DataTreeModification modification = begin();
        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 5 with DataTreeModification

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

the class InMemoryDataTreeBenchmark method write50KSingleNodeWithTwoInnerItemsInOneCommitBenchmark.

@Benchmark
@Warmup(iterations = WARMUP_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
@Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
public void write50KSingleNodeWithTwoInnerItemsInOneCommitBenchmark() throws DataValidationFailedException {
    final DataTreeModification modification = begin();
    for (int outerListKey = 0; outerListKey < OUTER_LIST_50K; ++outerListKey) {
        modification.write(OUTER_LIST_PATHS[outerListKey], OUTER_LIST_TWO_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)

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