private void publishNotification(final DOMNotification notification, TopicId topicId) { final ContainerNode topicNotification = Builders.containerBuilder().withNodeIdentifier(TOPIC_NOTIFICATION_ARG) .withChild(ImmutableNodes.leafNode(TOPIC_ID_ARG, topicId)) .withChild(ImmutableNodes.leafNode(EVENT_SOURCE_ARG, mount.getNodeId())).withChild(encapsulate(notification)) .build(); try { domPublish.putNotification(new TopicDOMNotification(topicNotification)); } catch (final InterruptedException e) { throw Throwables.propagate(e); } }
private void createRouterEntry() { Preconditions.checkState(isDatastoreWritable()); final DOMDataWriteTransaction wTx = this.domTxChain.newWriteOnlyTransaction(); wTx.put(LogicalDatastoreType.OPERATIONAL, this.routerYangIId, Builders.mapEntryBuilder() .withNodeIdentifier(new NodeIdentifierWithPredicates(Router.QNAME, ROUTER_ID_QNAME, this.routerIp)) .withChild(ImmutableNodes.leafNode(ROUTER_ID_QNAME, routerIp)) .withChild(ImmutableNodes.leafNode(ROUTER_STATUS_QNAME, DOWN)) .withChild(ImmutableNodes.mapNodeBuilder(Peer.QNAME).build()).build()); wTx.submit(); }
/** * Creates a container node for CreateSubscription RPC output. * * @param sid * @return containerNode for Create Subscription Output */ private ContainerNode createCSOutPut(String sid) { final ContainerNode cn = Builders.containerBuilder().withNodeIdentifier(I_PUSH_CS_OUTPUT) .withChild(ImmutableNodes.leafNode(I_PUSH_SUB_ID, sid)).build(); return cn; }
public static DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> mapEntryBuilder( final QName nodeName, final QName keyName, final Object keyValue) { return ImmutableMapEntryNodeBuilder.create() .withNodeIdentifier(new NodeIdentifierWithPredicates(nodeName, keyName, keyValue)) .withChild(leafNode(keyName, keyValue)); }
public static DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> mapEntryBuilder( final QName nodeName, final QName keyName, final Object keyValue) { return ImmutableMapEntryNodeBuilder.create() .withNodeIdentifier(new NodeIdentifierWithPredicates(nodeName, keyName, keyValue)) .withChild(leafNode(keyName, keyValue)); }
private DOMNotification createNotification(EventSourceStatusNotification notification) { final ContainerNode cn = Builders.containerBuilder().withNodeIdentifier(EVENT_SOURCE_STATUS_ARG) .withChild(encapsulate(notification)).build(); DOMNotification dn = new DOMNotification() { @Override public SchemaPath getType() { return EVENT_SOURCE_STATUS_PATH; } @Override public ContainerNode getBody() { return cn; } }; return dn; }
private void onInitiate(final InitiationMessage initiation) { Preconditions.checkState(isDatastoreWritable()); final DOMDataWriteTransaction wTx = this.domTxChain.newWriteOnlyTransaction(); wTx.merge(LogicalDatastoreType.OPERATIONAL, this.routerYangIId, Builders.mapEntryBuilder() .withNodeIdentifier(new NodeIdentifierWithPredicates(Router.QNAME, ROUTER_ID_QNAME, this.routerIp)) .withChild(ImmutableNodes.leafNode(ROUTER_NAME_QNAME, initiation.getTlvs().getNameTlv().getName())) .withChild(ImmutableNodes.leafNode(ROUTER_DESCRIPTION_QNAME, initiation.getTlvs().getDescriptionTlv().getDescription())) .withChild(ImmutableNodes.leafNode(ROUTER_INFO_QNAME, getStringInfo(initiation.getTlvs().getStringInformation()))) .withChild(ImmutableNodes.leafNode(ROUTER_STATUS_QNAME, UP)).build()); wTx.submit(); }
public static NormalizedNode<?, ?> getUnLockContent(final QName datastore) { return Builders.containerBuilder().withNodeIdentifier(toId(NETCONF_UNLOCK_QNAME)) .withChild(getTargetNode(datastore)).build(); }
public static ContainerNode getLockContent(final QName datastore) { return Builders.containerBuilder().withNodeIdentifier(toId(NETCONF_LOCK_QNAME)) .withChild(getTargetNode(datastore)).build(); }
public static NormalizedNode<?, ?> getValidateContent(final QName source) { return Builders.containerBuilder().withNodeIdentifier(toId(NETCONF_VALIDATE_QNAME)) .withChild(getSourceNode(source)).build(); }
/** * Creates the Delete Subscription RPC's input container node for the * device. * * @param inputData * @param error * @return */ private ContainerNode createDeviceDSRpcInput(DeleteSubscriptionRpcInput inputData, String error) { final ContainerNode dscn = Builders.containerBuilder().withNodeIdentifier(I_RPC_DS_INPUT) .withChild(ImmutableNodes.leafNode(I_PUSH_SUB_ID, inputData.getSubscription_id())).build(); return dscn; }
private ContainerNode createMirrors(final Mirror mirror, final Timestamp timestamp) { final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> builder = Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(Mirrors.QNAME)); builder.withChild(ImmutableNodes.leafNode(PEER_MIRROR_INFORMATION_QNAME, toDom(MirrorInformationCode.forValue( mirror.getTlvs().getMirrorInformationTlv().getCode().getIntValue())))); builder.withChild(ImmutableNodes.leafNode(PEER_MIRROR_TIMESTAMP_QNAME, timestamp.getValue())); return builder.build(); }
private ContainerNode createStats(final Stat stat, final Timestamp timestamp) { final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> builder = Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(Stats.QNAME)); builder.withChild(ImmutableNodes.leafNode(PEER_STATS_TIMESTAMP_QNAME, timestamp.getValue())); final Tlvs tlvs = stat.getTlvs(); if (tlvs != null) { statsForTlvs(tlvs, builder); } return builder.build(); }
private void processMapEntries(final NormalizedNode<?, ?> node, final Integer depth, CollectionNodeBuilder<MapEntryNode, ? extends MapNode> newOrderedMapNodeBuilder) { if (depth > 1) { for (MapEntryNode oldMapEntryNode : ((MapNode) node).getValue()) { DataContainerNodeAttrBuilder<NodeIdentifierWithPredicates, MapEntryNode> newMapEntryNodeBuilder = Builders .mapEntryBuilder().withNodeIdentifier(oldMapEntryNode.getIdentifier()); for (DataContainerChild<? extends PathArgument, ?> mapEntryNodeValue : oldMapEntryNode.getValue()) { newMapEntryNodeBuilder.withChild(pruneDataAtDepth(mapEntryNodeValue, depth - 1)); } newOrderedMapNodeBuilder.withChild(newMapEntryNodeBuilder.build()); } } }
@Setup(Level.Trial) public void setup() throws DataValidationFailedException { datastore = new InMemoryDataTreeFactory().create(DataTreeConfiguration.DEFAULT_CONFIGURATION, BenchmarkModel.createTestContext()); final DataTreeModification modification = begin(); modification.write(BenchmarkModel.TEST_PATH, ImmutableContainerNodeBuilder.create() .withNodeIdentifier(BenchmarkModel.TEST).withChild(EMPTY_OUTER_LIST).build()); commit(modification); }
public static DataContainerChild<?, ?> getTargetNode(final QName datastore) { return Builders.containerBuilder().withNodeIdentifier(toId(NETCONF_TARGET_QNAME)) .withChild( Builders.choiceBuilder().withNodeIdentifier(toId(ConfigTarget.QNAME)).withChild( Builders.leafBuilder().withNodeIdentifier(toId(datastore)).build()).build() ).build(); }
public static DataContainerChild<?, ?> getSourceNode(final QName datastore) { return Builders.containerBuilder().withNodeIdentifier(toId(NETCONF_SOURCE_QNAME)) .withChild( Builders.choiceBuilder().withNodeIdentifier(toId(ConfigSource.QNAME)).withChild( Builders.leafBuilder().withNodeIdentifier(toId(datastore)).build()).build() ).build(); }
@Test public void testAnyXMLNodeNotPrunedWhenHasParent() throws IOException { NormalizedNodePruner pruner = prunerFullSchema(TestModel.TEST_PATH); AnyXmlNode child = Builders.anyXmlBuilder().withNodeIdentifier( new NodeIdentifier(TestModel.ANY_XML_QNAME)).withValue(mock(DOMSource.class)).build(); NormalizedNode<?, ?> input = Builders.containerBuilder().withNodeIdentifier( new NodeIdentifier(TestModel.TEST_QNAME)).withChild(child).build(); NormalizedNodeWriter.forStreamWriter(pruner).write(input); NormalizedNode<?, ?> actual = pruner.normalizedNode(); assertEquals("normalizedNode", input, actual); }
private static NormalizedNode<?, ?> createTestContainer() { byte[] bytes1 = {1, 2, 3}; LeafSetEntryNode<Object> entry1 = ImmutableLeafSetEntryNodeBuilder.create().withNodeIdentifier( new NodeWithValue<>(TestModel.BINARY_LEAF_LIST_QNAME, bytes1)).withValue(bytes1).build(); byte[] bytes2 = {}; LeafSetEntryNode<Object> entry2 = ImmutableLeafSetEntryNodeBuilder.create().withNodeIdentifier( new NodeWithValue<>(TestModel.BINARY_LEAF_LIST_QNAME, bytes2)).withValue(bytes2).build(); return TestModel.createBaseTestContainerBuilder() .withChild(ImmutableLeafSetNodeBuilder.create().withNodeIdentifier( new NodeIdentifier(TestModel.BINARY_LEAF_LIST_QNAME)) .withChild(entry1).withChild(entry2).build()) .withChild(ImmutableNodes.leafNode(TestModel.SOME_BINARY_DATA_QNAME, new byte[]{1, 2, 3, 4})) .build(); } }