use of org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode in project controller by opendaylight.
the class CommitTransactionPayloadTest method testOrderedLeafSetNodeCandidate.
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testOrderedLeafSetNodeCandidate() throws Exception {
YangInstanceIdentifier.NodeWithValue entryPathArg = new YangInstanceIdentifier.NodeWithValue(LEAF_SET, "one");
YangInstanceIdentifier leafSetPath = YangInstanceIdentifier.builder(TestModel.TEST_PATH).node(LEAF_SET).build();
LeafSetEntryNode leafSetEntryNode = Builders.leafSetEntryBuilder().withNodeIdentifier(entryPathArg).withValue("one").build();
NormalizedNode<?, ?> leafSetNode = Builders.orderedLeafSetBuilder().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(LEAF_SET)).withChild(leafSetEntryNode).build();
candidate = DataTreeCandidates.fromNormalizedNode(leafSetPath, leafSetNode);
CommitTransactionPayload payload = CommitTransactionPayload.create(nextTransactionId(), candidate);
assertCandidateEquals(candidate, payload.getCandidate().getValue());
}
use of org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode in project controller by opendaylight.
the class CommitTransactionPayloadTest method testLeafSetNodeCandidate.
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testLeafSetNodeCandidate() throws Exception {
YangInstanceIdentifier.NodeWithValue entryPathArg = new YangInstanceIdentifier.NodeWithValue(LEAF_SET, "one");
YangInstanceIdentifier leafSetPath = YangInstanceIdentifier.builder(TestModel.TEST_PATH).node(LEAF_SET).build();
LeafSetEntryNode leafSetEntryNode = Builders.leafSetEntryBuilder().withNodeIdentifier(entryPathArg).withValue("one").build();
NormalizedNode<?, ?> leafSetNode = Builders.leafSetBuilder().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(LEAF_SET)).withChild(leafSetEntryNode).build();
candidate = DataTreeCandidates.fromNormalizedNode(leafSetPath, leafSetNode);
CommitTransactionPayload payload = CommitTransactionPayload.create(nextTransactionId(), candidate);
assertCandidateEquals(candidate, payload.getCandidate().getValue());
}
use of org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode in project controller by opendaylight.
the class PrefixedShardConfigWriter method doWrite.
private DOMStoreThreePhaseCommitCohort doWrite(final YangInstanceIdentifier path, final Collection<MemberName> replicas) {
final ListNodeBuilder<Object, LeafSetEntryNode<Object>> replicaListBuilder = ImmutableLeafSetNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(ClusterUtils.SHARD_REPLICA_QNAME));
replicas.forEach(name -> replicaListBuilder.withChild(ImmutableLeafSetEntryNodeBuilder.create().withNodeIdentifier(new NodeWithValue<>(ClusterUtils.SHARD_REPLICA_QNAME, name.getName())).withValue(name.getName()).build()));
final MapEntryNode newEntry = ImmutableMapEntryNodeBuilder.create().withNodeIdentifier(new NodeIdentifierWithPredicates(ClusterUtils.SHARD_LIST_QNAME, ClusterUtils.SHARD_PREFIX_QNAME, path)).withChild(ImmutableLeafNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(ClusterUtils.SHARD_PREFIX_QNAME)).withValue(path).build()).withChild(ImmutableContainerNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(ClusterUtils.SHARD_REPLICAS_QNAME)).withChild(replicaListBuilder.build()).build()).build();
final ClientTransaction tx = history.createTransaction();
final DOMDataTreeWriteCursor cursor = tx.openCursor();
ClusterUtils.SHARD_LIST_PATH.getPathArguments().forEach(cursor::enter);
cursor.write(newEntry.getIdentifier(), newEntry);
cursor.close();
return tx.ready();
}
Aggregations