use of org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification in project controller by opendaylight.
the class AbstractShardTest method writeToStore.
public static void writeToStore(final DataTree store, final YangInstanceIdentifier id, final NormalizedNode<?, ?> node) throws DataValidationFailedException {
final DataTreeModification transaction = store.takeSnapshot().newModification();
transaction.write(id, node);
transaction.ready();
store.validate(transaction);
final DataTreeCandidate candidate = store.prepare(transaction);
store.commit(candidate);
}
use of org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification in project controller by opendaylight.
the class AbstractShardTest method writeToStore.
public static void writeToStore(final ShardDataTree store, final YangInstanceIdentifier id, final NormalizedNode<?, ?> node) throws DataValidationFailedException {
BatchedModifications batched = newBatchedModifications(nextTransactionId(), id, node, true, true, 1);
DataTreeModification modification = store.getDataTree().takeSnapshot().newModification();
batched.apply(modification);
store.notifyListeners(commitTransaction(store.getDataTree(), modification));
}
use of org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification in project controller by opendaylight.
the class AbstractShardTest method mergeToStore.
public void mergeToStore(final ShardDataTree store, final YangInstanceIdentifier id, final NormalizedNode<?, ?> node) throws DataValidationFailedException {
final BatchedModifications batched = new BatchedModifications(nextTransactionId(), CURRENT_VERSION);
batched.addModification(new MergeModification(id, node));
batched.setReady(true);
batched.setDoCommitOnReady(true);
batched.setTotalMessagesSent(1);
DataTreeModification modification = store.getDataTree().takeSnapshot().newModification();
batched.apply(modification);
store.notifyListeners(commitTransaction(store.getDataTree(), modification));
}
use of org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification in project controller by opendaylight.
the class TransactionProxyTest method createDataTree.
private static DataTree createDataTree(final NormalizedNode<?, ?> readResponse) {
DataTree dataTree = mock(DataTree.class);
DataTreeSnapshot dataTreeSnapshot = mock(DataTreeSnapshot.class);
DataTreeModification dataTreeModification = mock(DataTreeModification.class);
doReturn(dataTreeSnapshot).when(dataTree).takeSnapshot();
doReturn(dataTreeModification).when(dataTreeSnapshot).newModification();
doReturn(java.util.Optional.of(readResponse)).when(dataTreeModification).readNode(any(YangInstanceIdentifier.class));
return dataTree;
}
use of org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification in project controller by opendaylight.
the class SnapshotBackedWriteTransaction method write.
@Override
@SuppressWarnings("checkstyle:IllegalCatch")
public void write(final YangInstanceIdentifier path, final NormalizedNode<?, ?> data) {
checkNotReady();
final DataTreeModification tree = mutableTree;
LOG.debug("Tx: {} Write: {}:{}", getIdentifier(), path, data);
try {
tree.write(path, data);
// FIXME: Add checked exception
} catch (RuntimeException e) {
LOG.error("Tx: {}, failed to write {}:{} in {}", getIdentifier(), path, data, tree, e);
// Rethrow original ones if they are subclasses of RuntimeException
// or Error
Throwables.propagateIfPossible(e);
// FIXME: Introduce proper checked exception
throw new IllegalArgumentException("Illegal input data.", e);
}
}
Aggregations