use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier in project controller by opendaylight.
the class InMemoryDataStoreTest method testMerge.
@Test
public void testMerge() throws Exception {
DOMStoreWriteTransaction writeTx = domStore.newWriteOnlyTransaction();
assertNotNull(writeTx);
ContainerNode containerNode = ImmutableContainerNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME)).addChild(ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME).addChild(ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1)).build()).build();
writeTx.merge(TestModel.TEST_PATH, containerNode);
assertThreePhaseCommit(writeTx.ready());
Optional<NormalizedNode<?, ?>> afterCommitRead = domStore.newReadOnlyTransaction().read(TestModel.TEST_PATH).get();
assertEquals("After commit read: isPresent", true, afterCommitRead.isPresent());
assertEquals("After commit read: data", containerNode, afterCommitRead.get());
// Merge a new list entry node
writeTx = domStore.newWriteOnlyTransaction();
assertNotNull(writeTx);
containerNode = ImmutableContainerNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME)).addChild(ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME).addChild(ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1)).addChild(ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 2)).build()).build();
writeTx.merge(TestModel.TEST_PATH, containerNode);
assertThreePhaseCommit(writeTx.ready());
afterCommitRead = domStore.newReadOnlyTransaction().read(TestModel.TEST_PATH).get();
assertEquals("After commit read: isPresent", true, afterCommitRead.isPresent());
assertEquals("After commit read: data", containerNode, afterCommitRead.get());
}
use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier in project bgpcep by opendaylight.
the class BmpMonitorImplTest method setUp.
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
doAnswer(invocationOnMock -> {
BmpMonitorImplTest.this.singletonService = (ClusterSingletonService) invocationOnMock.getArguments()[0];
this.singletonService.instantiateServiceInstance();
return BmpMonitorImplTest.this.singletonServiceRegistration;
}).when(this.clusterSSProv).registerClusterSingletonService(any(ClusterSingletonService.class));
doAnswer(invocationOnMock -> BmpMonitorImplTest.this.singletonService.closeServiceInstance()).when(this.singletonServiceRegistration).close();
doAnswer(invocationOnMock -> {
this.singletonService2 = (ClusterSingletonService) invocationOnMock.getArguments()[0];
this.singletonService2.instantiateServiceInstance();
return BmpMonitorImplTest.this.singletonServiceRegistration2;
}).when(this.clusterSSProv2).registerClusterSingletonService(any(ClusterSingletonService.class));
doAnswer(invocationOnMock -> BmpMonitorImplTest.this.singletonService2.closeServiceInstance()).when(this.singletonServiceRegistration2).close();
this.mappingService = new BindingToNormalizedNodeCodec(GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy(), new BindingNormalizedNodeCodecRegistry(StreamWriterGenerator.create(JavassistUtils.forClassPool(ClassPool.getDefault()))));
final ModuleInfoBackedContext moduleInfoBackedContext = ModuleInfoBackedContext.create();
moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(InitiationMessage.class));
moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(CParameters1.class));
moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(BgpParameters.class));
moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(MultiprotocolCapability.class));
moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(DestinationIpv4Case.class));
moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(AdvertizedRoutes.class));
moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(SentOpen.class));
moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(ReceivedOpen.class));
this.mappingService.onGlobalContextUpdated(moduleInfoBackedContext.tryToCreateSchemaContext().get());
this.ribActivator = new RIBActivator();
this.ribExtension = new SimpleRIBExtensionProviderContext();
this.ribActivator.startRIBExtensionProvider(this.ribExtension);
this.bgpActivator = new BGPActivator();
final BGPExtensionProviderContext context = new SimpleBGPExtensionProviderContext();
this.bgpActivator.start(context);
final SimpleBmpExtensionProviderContext ctx = new SimpleBmpExtensionProviderContext();
this.bmpActivator = new BmpActivator(context);
this.bmpActivator.start(ctx);
this.msgRegistry = ctx.getBmpMessageRegistry();
this.dispatcher = new BmpDispatcherImpl(new NioEventLoopGroup(), new NioEventLoopGroup(), ctx.getBmpMessageRegistry(), new DefaultBmpSessionFactory());
final InetSocketAddress inetAddress = new InetSocketAddress(InetAddresses.forString(MONITOR_LOCAL_ADDRESS), MONITOR_LOCAL_PORT);
final DOMDataWriteTransaction wTx = getDomBroker().newWriteOnlyTransaction();
final ContainerNode parentNode = Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(BmpMonitor.QNAME)).addChild(ImmutableNodes.mapNodeBuilder(Monitor.QNAME).build()).build();
wTx.merge(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.of(BmpMonitor.QNAME), parentNode);
wTx.submit();
final BmpDeployerDependencies bmpDependecies = new BmpDeployerDependencies(getDataBroker(), getDomBroker(), this.ribExtension, this.mappingService.getCodecFactory(), getSchemaContext(), this.clusterSSProv);
this.bmpApp = new BmpMonitoringStationImpl(bmpDependecies, this.dispatcher, MONITOR_ID, inetAddress, null);
readDataOperational(getDataBroker(), BMP_II, monitor -> {
assertEquals(1, monitor.getMonitor().size());
final Monitor bmpMonitor = monitor.getMonitor().get(0);
assertEquals(MONITOR_ID, bmpMonitor.getMonitorId());
assertEquals(0, bmpMonitor.getRouter().size());
assertEquals(MONITOR_ID, bmpMonitor.getMonitorId());
assertEquals(0, bmpMonitor.getRouter().size());
return monitor;
});
}
use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier in project bgpcep by opendaylight.
the class BmpRouterPeerImpl method createMirrors.
private static 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();
}
use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier in project bgpcep by opendaylight.
the class BmpRouterPeerImpl method createStats.
private static 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();
}
use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier in project bgpcep by opendaylight.
the class TableContext method createTable.
void createTable(final DOMDataWriteTransaction tx) {
final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> tb = ImmutableNodes.mapEntryBuilder();
tb.withNodeIdentifier((NodeIdentifierWithPredicates) this.tableId.getLastPathArgument());
tb.withChild(EMPTY_TABLE_ATTRIBUTES);
// tableId is keyed, but that fact is not directly visible from YangInstanceIdentifier, see BUG-2796
final NodeIdentifierWithPredicates tableKey = (NodeIdentifierWithPredicates) this.tableId.getLastPathArgument();
for (final Map.Entry<QName, Object> e : tableKey.getKeyValues().entrySet()) {
tb.withChild(ImmutableNodes.leafNode(e.getKey(), e.getValue()));
}
final ChoiceNode routes = this.tableSupport.emptyRoutes();
Verify.verifyNotNull(routes, "Null empty routes in %s", this.tableSupport);
tx.put(LogicalDatastoreType.OPERATIONAL, this.tableId, tb.withChild(ImmutableChoiceNodeBuilder.create(routes).withNodeIdentifier(new NodeIdentifier(TablesUtil.BMP_ROUTES_QNAME)).build()).build());
}
Aggregations