use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyBuilder in project bgpcep by opendaylight.
the class ServerSessionManager method instantiateServiceInstance.
/**
* Create Base Topology.
*/
synchronized void instantiateServiceInstance() {
final TopologyKey key = InstanceIdentifier.keyOf(this.topology);
final TopologyId topologyId = key.getTopologyId();
final WriteTransaction tx = this.dependenciesProvider.getDataBroker().newWriteOnlyTransaction();
tx.put(LogicalDatastoreType.OPERATIONAL, this.topology, new TopologyBuilder().setKey(key).setTopologyId(topologyId).setTopologyTypes(new TopologyTypesBuilder().addAugmentation(TopologyTypes1.class, new TopologyTypes1Builder().setTopologyPcep(new TopologyPcepBuilder().build()).build()).build()).setNode(new ArrayList<>()).build(), true);
try {
tx.submit().get();
LOG.info("PCEP Topology {} created successfully.", topologyId.getValue());
ServerSessionManager.this.isClosed.set(false);
} catch (final ExecutionException | InterruptedException throwable) {
LOG.error("Failed to create PCEP Topology {}.", topologyId.getValue(), throwable);
ServerSessionManager.this.isClosed.set(true);
}
}
use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyBuilder in project bgpcep by opendaylight.
the class AbstractBgpTopologyProvider method createInstance.
private TopologyReferenceSingletonService createInstance(final Topology topology) {
final RibReference ribReference = new DefaultRibReference(InstanceIdentifier.create(BgpRib.class).child(Rib.class, new RibKey(topology.getAugmentation(Topology1.class).getRibId())));
final AbstractTopologyBuilder<?> topologyBuilder = createTopologyBuilder(this.dataBroker, ribReference, topology.getTopologyId());
return new TopologyReferenceSingletonServiceImpl(topologyBuilder, this.deployer, topology);
}
use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyBuilder in project bgpcep by opendaylight.
the class BgpTopologyDeployerImpl method registerService.
@Override
@SuppressWarnings("checkstyle:IllegalCatch")
public AbstractRegistration registerService(final TopologyReferenceSingletonService topologyProviderService) {
final Dictionary<String, String> properties = new Hashtable<>();
properties.put("topology-id", topologyProviderService.getInstanceIdentifier().firstKeyOf(Topology.class).getTopologyId().getValue());
final ServiceRegistration<?> registerService = this.context.registerService(new String[] { TopologyReference.class.getName() }, topologyProviderService, properties);
final ClusterSingletonServiceRegistration registerClusterSingletonService = registerSingletonService(topologyProviderService);
return new AbstractRegistration() {
@Override
protected void removeRegistration() {
try {
registerClusterSingletonService.close();
} catch (final Exception e) {
LOG.warn("Failed to close ClusterSingletonServiceRegistration {} for TopologyBuilder {}", registerClusterSingletonService, topologyProviderService.getInstanceIdentifier(), e);
} finally {
registerService.unregister();
}
}
};
}
use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyBuilder in project bgpcep by opendaylight.
the class CheckUtilTest method storeTopo.
private void storeTopo(final LogicalDatastoreType dsType) throws ExecutionException, InterruptedException {
final WriteTransaction wt = getDataBroker().newWriteOnlyTransaction();
wt.put(dsType, this.topologyIIdKeyed, new TopologyBuilder().setTopologyId(TOPOLOGY_ID).build(), true);
wt.submit().get();
}
use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyBuilder in project openflowplugin by opendaylight.
the class TerminationPointChangeListenerImplTest method testOnNodeConnectorRemoved.
@SuppressWarnings("rawtypes")
@Test
public void testOnNodeConnectorRemoved() {
NodeKey topoNodeKey = new NodeKey(new NodeId("node1"));
TerminationPointKey terminationPointKey = new TerminationPointKey(new TpId("tp1"));
final InstanceIdentifier<Node> topoNodeII = topologyIID.child(Node.class, topoNodeKey);
Node topoNode = new NodeBuilder().setKey(topoNodeKey).build();
org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey nodeKey = newInvNodeKey(topoNodeKey.getNodeId().getValue());
org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey ncKey = newInvNodeConnKey(terminationPointKey.getTpId().getValue());
final InstanceIdentifier<?> invNodeConnID = newNodeConnID(nodeKey, ncKey);
List<Link> linkList = Arrays.asList(newLink("link1", newSourceTp("tp1"), newDestTp("dest")), newLink("link2", newSourceTp("source"), newDestTp("tp1")), newLink("link3", newSourceTp("source2"), newDestTp("dest2")));
final Topology topology = new TopologyBuilder().setLink(linkList).build();
final InstanceIdentifier[] expDeletedIIDs = { topologyIID.child(Link.class, linkList.get(0).getKey()), topologyIID.child(Link.class, linkList.get(1).getKey()), topologyIID.child(Node.class, new NodeKey(new NodeId("node1"))).child(TerminationPoint.class, new TerminationPointKey(new TpId("tp1"))) };
final SettableFuture<Optional<Topology>> readFuture = SettableFuture.create();
readFuture.set(Optional.of(topology));
ReadWriteTransaction mockTx1 = mock(ReadWriteTransaction.class);
doReturn(Futures.makeChecked(readFuture, ReadFailedException.MAPPER)).when(mockTx1).read(LogicalDatastoreType.OPERATIONAL, topologyIID);
SettableFuture<Optional<Node>> readFutureNode = SettableFuture.create();
readFutureNode.set(Optional.of(topoNode));
doReturn(Futures.makeChecked(readFutureNode, ReadFailedException.MAPPER)).when(mockTx1).read(LogicalDatastoreType.OPERATIONAL, topoNodeII);
final CountDownLatch submitLatch1 = setupStubbedSubmit(mockTx1);
int expDeleteCalls = expDeletedIIDs.length;
CountDownLatch deleteLatch = new CountDownLatch(expDeleteCalls);
ArgumentCaptor<InstanceIdentifier> deletedLinkIDs = ArgumentCaptor.forClass(InstanceIdentifier.class);
setupStubbedDeletes(mockTx1, deletedLinkIDs, deleteLatch);
doReturn(mockTx1).when(mockTxChain).newReadWriteTransaction();
DataTreeModification dataTreeModification = setupDataTreeChange(DELETE, invNodeConnID);
terminationPointListener.onDataTreeChanged(Collections.singleton(dataTreeModification));
waitForSubmit(submitLatch1);
setReadFutureAsync(topology, readFuture);
waitForDeletes(expDeleteCalls, deleteLatch);
assertDeletedIDs(expDeletedIIDs, deletedLinkIDs);
verifyMockTx(mockTx1);
}
Aggregations