use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.NodeIdentifier in project controller by opendaylight.
the class CrossBrokerMountPointTest method testMountPoint.
@Test
public void testMountPoint() throws ReadFailedException, TimeoutException {
final Integer attrIntValue = 500;
domMountPointService.createMountPoint(TLL_INSTANCE_ID_BI).addService(DOMDataBroker.class, new DOMDataBroker() {
@Override
public ListenerRegistration<DOMDataChangeListener> registerDataChangeListener(final LogicalDatastoreType store, final YangInstanceIdentifier path, final DOMDataChangeListener listener, final DataChangeScope triggeringScope) {
throw new UnsupportedOperationException();
}
@Override
public DOMDataWriteTransaction newWriteOnlyTransaction() {
throw new UnsupportedOperationException();
}
@Override
public DOMDataReadWriteTransaction newReadWriteTransaction() {
return new DOMDataReadWriteTransaction() {
@Override
public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
if (store == LogicalDatastoreType.OPERATIONAL && path.getLastPathArgument().equals(GROUP_STATISTICS_ID_BI.getLastPathArgument())) {
final ContainerNode data = Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(AUG_CONT)).withChild(ImmutableNodes.leafNode(QName.create(AUG_CONT, "attr-int"), attrIntValue)).build();
return Futures.immediateCheckedFuture(Optional.<NormalizedNode<?, ?>>of(data));
}
return Futures.immediateFailedCheckedFuture(new ReadFailedException(TLL_NAME, new Exception()));
}
@Override
public CheckedFuture<Boolean, ReadFailedException> exists(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
throw new UnsupportedOperationException();
}
@Override
public Object getIdentifier() {
return this;
}
@Override
public boolean cancel() {
return false;
}
@Override
public void delete(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
throw new UnsupportedOperationException();
}
@Override
public void merge(final LogicalDatastoreType store, final YangInstanceIdentifier path, final NormalizedNode<?, ?> data) {
throw new UnsupportedOperationException();
}
@Override
public void put(final LogicalDatastoreType store, final YangInstanceIdentifier path, final NormalizedNode<?, ?> data) {
throw new UnsupportedOperationException();
}
@Override
public CheckedFuture<Void, TransactionCommitFailedException> submit() {
throw new UnsupportedOperationException();
}
};
}
@Override
public DOMDataReadOnlyTransaction newReadOnlyTransaction() {
throw new UnsupportedOperationException();
}
@Override
public DOMTransactionChain createTransactionChain(final TransactionChainListener listener) {
throw new UnsupportedOperationException();
}
@Override
public Map<Class<? extends DOMDataBrokerExtension>, DOMDataBrokerExtension> getSupportedExtensions() {
return Collections.emptyMap();
}
}).register();
final Optional<MountPoint> bindingMountPoint = bindingMountPointService.getMountPoint(TLL_INSTANCE_ID_BA);
assertTrue(bindingMountPoint.isPresent());
final Optional<DataBroker> dataBroker = bindingMountPoint.get().getService(DataBroker.class);
assertTrue(dataBroker.isPresent());
final Optional<Cont> data = dataBroker.get().newReadWriteTransaction().read(LogicalDatastoreType.OPERATIONAL, AUG_CONT_ID_BA).checkedGet(5, TimeUnit.SECONDS);
assertTrue(data.isPresent());
assertEquals(attrIntValue, data.get().getAttrInt());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.NodeIdentifier in project bgpcep by opendaylight.
the class AbstractLabeledUnicastRIBSupport method extractLabel.
public static List<LabelStack> extractLabel(final DataContainerNode<? extends PathArgument> route, final NodeIdentifier labelStackNid, final NodeIdentifier labelValueNid) {
final List<LabelStack> labels = new ArrayList<>();
final Optional<DataContainerChild<? extends PathArgument, ?>> labelStacks = route.getChild(labelStackNid);
if (labelStacks.isPresent()) {
for (final UnkeyedListEntryNode label : ((UnkeyedListNode) labelStacks.get()).getValue()) {
final Optional<DataContainerChild<? extends PathArgument, ?>> labelStack = label.getChild(labelValueNid);
if (labelStack.isPresent()) {
final LabelStackBuilder labelStackbuilder = new LabelStackBuilder();
labelStackbuilder.setLabelValue(new MplsLabel((Long) labelStack.get().getValue()));
labels.add(labelStackbuilder.build());
}
}
}
return labels;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.NodeIdentifier in project genius by opendaylight.
the class ItmUtils method buildHwTunnelInterface.
public static Interface buildHwTunnelInterface(String tunnelIfName, String desc, boolean enabled, String topoId, String nodeId, Class<? extends TunnelTypeBase> tunType, IpAddress srcIp, IpAddress destIp, IpAddress gwIp, Boolean monitorEnabled, Class<? extends TunnelMonitoringTypeBase> monitorProtocol, Integer monitorInterval) {
InterfaceBuilder builder = new InterfaceBuilder().setKey(new InterfaceKey(tunnelIfName)).setName(tunnelIfName).setDescription(desc).setEnabled(enabled).setType(Tunnel.class);
List<NodeIdentifier> nodeIds = new ArrayList<>();
NodeIdentifier hwNode = new NodeIdentifierBuilder().setKey(new NodeIdentifierKey(topoId)).setTopologyId(topoId).setNodeId(nodeId).build();
nodeIds.add(hwNode);
ParentRefs parent = new ParentRefsBuilder().setNodeIdentifier(nodeIds).build();
builder.addAugmentation(ParentRefs.class, parent);
IfTunnel tunnel = new IfTunnelBuilder().setTunnelDestination(destIp).setTunnelGateway(gwIp).setTunnelSource(srcIp).setMonitorEnabled(monitorEnabled == null || monitorEnabled).setMonitorProtocol(monitorProtocol == null ? ITMConstants.DEFAULT_MONITOR_PROTOCOL : monitorProtocol).setMonitorInterval(DEFAULT_MONITORING_INTERVAL).setTunnelInterfaceType(tunType).setInternal(false).build();
builder.addAugmentation(IfTunnel.class, tunnel);
LOG.trace("iftunnel {} built from hwvtep {} ", tunnel, nodeId);
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.NodeIdentifier in project controller by opendaylight.
the class AkkaEntityOwnershipServiceTest method testEntityRetrievalWithYiid.
@Test
public void testEntityRetrievalWithYiid() throws Exception {
final YangInstanceIdentifier entityId = YangInstanceIdentifier.create(new NodeIdentifier(NetworkTopology.QNAME), new NodeIdentifier(Topology.QNAME), NodeIdentifierWithPredicates.of(Topology.QNAME, QName.create(Topology.QNAME, "topology-id"), "test"), new NodeIdentifier(Node.QNAME), NodeIdentifierWithPredicates.of(Node.QNAME, QName.create(Node.QNAME, "node-id"), "test://test-node"));
final DOMEntity entity = new DOMEntity(ENTITY_TYPE, entityId);
final DOMEntityOwnershipCandidateRegistration reg = service.registerCandidate(entity);
verifyEntityOwnershipCandidateRegistration(entity, reg);
verifyEntityCandidateRegistered(ENTITY_TYPE, entityId, "member-1");
RpcResult<GetEntityOutput> getEntityResult = service.getEntity(new GetEntityInputBuilder().setName(new EntityName(CODEC_CONTEXT.fromYangInstanceIdentifier(entityId))).setType(new EntityType(ENTITY_TYPE)).build()).get();
assertEquals(getEntityResult.getResult().getOwnerNode().getValue(), "member-1");
assertEquals(getEntityResult.getResult().getCandidateNodes().get(0).getValue(), "member-1");
// we should not be able to retrieve the entity when using string
final String entityPathEncoded = "/network-topology:network-topology/topology[topology-id='test']/node[node-id='test://test-node']";
getEntityResult = service.getEntity(new GetEntityInputBuilder().setName(new EntityName(entityPathEncoded)).setType(new EntityType(ENTITY_TYPE)).build()).get();
assertNull(getEntityResult.getResult().getOwnerNode());
assertTrue(getEntityResult.getResult().getCandidateNodes().isEmpty());
final GetEntitiesOutput getEntitiesResult = service.getEntities(new GetEntitiesInputBuilder().build()).get().getResult();
assertEquals(getEntitiesResult.getEntities().size(), 1);
assertTrue(getEntitiesResult.getEntities().get(new EntitiesKey(new EntityName(CODEC_CONTEXT.fromYangInstanceIdentifier(entityId)), new EntityType(ENTITY_TYPE))).getCandidateNodes().contains(new NodeName("member-1")));
assertTrue(getEntitiesResult.getEntities().get(new EntitiesKey(new EntityName(CODEC_CONTEXT.fromYangInstanceIdentifier(entityId)), new EntityType(ENTITY_TYPE))).getOwnerNode().getValue().equals("member-1"));
final GetEntityOwnerOutput getOwnerResult = service.getEntityOwner(new GetEntityOwnerInputBuilder().setName(new EntityName(CODEC_CONTEXT.fromYangInstanceIdentifier(entityId))).setType(new EntityType(ENTITY_TYPE)).build()).get().getResult();
assertEquals(getOwnerResult.getOwnerNode().getValue(), "member-1");
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.NodeIdentifier in project controller by opendaylight.
the class EntityRpcHandlerTest method testEntityRetrievalWithUnavailableSupervisor.
/*
* Tests entity rpcs handled both by the owner supervisor(service1) and with an idle supervisor(falling
* back to distributed-data in an inactive datacenter). This covers both the available cases, datacenters and case
* in which the node with active akka-singleton is shutdown and another one takes over.
*/
@Test
public void testEntityRetrievalWithUnavailableSupervisor() throws Exception {
final YangInstanceIdentifier entityId = YangInstanceIdentifier.create(new NodeIdentifier(NetworkTopology.QNAME), new NodeIdentifier(Topology.QNAME), NodeIdentifierWithPredicates.of(Topology.QNAME, QName.create(Topology.QNAME, "topology-id"), "test"), new NodeIdentifier(Node.QNAME), NodeIdentifierWithPredicates.of(Node.QNAME, QName.create(Node.QNAME, "node-id"), "test://test-node"));
final DOMEntity entity = new DOMEntity(ENTITY_TYPE, entityId);
final DOMEntityOwnershipCandidateRegistration reg = service1.registerCandidate(entity);
await().untilAsserted(() -> {
final RpcResult<GetEntityOutput> getEntityResult = service1.getEntity(new GetEntityInputBuilder().setName(new EntityName(CODEC_CONTEXT.fromYangInstanceIdentifier(entityId))).setType(new EntityType(ENTITY_TYPE)).build()).get();
assertEquals(getEntityResult.getResult().getOwnerNode().getValue(), "member-1");
assertEquals(getEntityResult.getResult().getCandidateNodes().get(0).getValue(), "member-1");
});
// keep this under ask timeout to make sure the singleton actor in the inactive datacenter responds with failure
// immediately, so that the rpc actor retries with distributed-data asap
await().atMost(Duration.ofSeconds(2)).untilAsserted(() -> {
final GetEntitiesOutput getEntitiesResult = service2.getEntities(new GetEntitiesInputBuilder().build()).get().getResult();
assertEquals(getEntitiesResult.getEntities().size(), 1);
assertTrue(getEntitiesResult.getEntities().get(new EntitiesKey(new EntityName(CODEC_CONTEXT.fromYangInstanceIdentifier(entityId)), new EntityType(ENTITY_TYPE))).getCandidateNodes().contains(new NodeName("member-1")));
assertTrue(getEntitiesResult.getEntities().get(new EntitiesKey(new EntityName(CODEC_CONTEXT.fromYangInstanceIdentifier(entityId)), new EntityType(ENTITY_TYPE))).getOwnerNode().getValue().equals("member-1"));
});
await().atMost(Duration.ofSeconds(2)).untilAsserted(() -> {
final GetEntityOutput getEntityResult = service2.getEntity(new GetEntityInputBuilder().setName(new EntityName(CODEC_CONTEXT.fromYangInstanceIdentifier(entityId))).setType(new EntityType(ENTITY_TYPE)).build()).get().getResult();
assertEquals(getEntityResult.getOwnerNode().getValue(), "member-1");
assertEquals(getEntityResult.getCandidateNodes().get(0).getValue(), "member-1");
});
await().atMost(Duration.ofSeconds(2)).untilAsserted(() -> {
final GetEntityOwnerOutput getOwnerResult = service2.getEntityOwner(new GetEntityOwnerInputBuilder().setName(new EntityName(CODEC_CONTEXT.fromYangInstanceIdentifier(entityId))).setType(new EntityType(ENTITY_TYPE)).build()).get().getResult();
assertEquals(getOwnerResult.getOwnerNode().getValue(), "member-1");
});
}
Aggregations