use of org.opendaylight.controller.md.sal.binding.api.WriteTransaction in project bgpcep by opendaylight.
the class PcepStateUtilsTest method createDefaultProtocol.
private void createDefaultProtocol() throws ExecutionException, InterruptedException {
final WriteTransaction wt = getDataBroker().newWriteOnlyTransaction();
final Node node = new NodeBuilder().setNodeId(new NodeId(NODE_ID)).addAugmentation(PcepTopologyNodeStatsAug.class, new PcepTopologyNodeStatsAugBuilder().setPcepSessionState(createPcepSessionState()).build()).build();
final InstanceIdentifier<Node> topology = InstanceIdentifier.builder(NetworkTopology.class).child(Topology.class, new TopologyKey(new TopologyId(PCEP_TOPOLOGY))).child(Node.class, new NodeKey(new NodeId(NODE_ID))).build();
wt.put(LogicalDatastoreType.OPERATIONAL, topology, node, true);
wt.submit().get();
}
use of org.opendaylight.controller.md.sal.binding.api.WriteTransaction in project bgpcep by opendaylight.
the class TopologyStatsProviderImpl method unbind.
@Override
public synchronized void unbind(final KeyedInstanceIdentifier<Node, NodeKey> nodeId) {
this.statsMap.remove(nodeId);
final WriteTransaction wTx = this.transactionChain.newWriteOnlyTransaction();
wTx.delete(LogicalDatastoreType.OPERATIONAL, nodeId);
try {
wTx.submit().get();
} catch (final InterruptedException | ExecutionException e) {
LOG.warn("Failed to remove Pcep Node stats {}.", nodeId.getKey().getNodeId());
}
}
use of org.opendaylight.controller.md.sal.binding.api.WriteTransaction 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.controller.md.sal.binding.api.WriteTransaction in project bgpcep by opendaylight.
the class TopologyNodeState method released.
synchronized void released(final boolean persist) {
// We might want to persist topology node for later re-use.
if (!persist) {
final WriteTransaction trans = this.chain.newWriteOnlyTransaction();
trans.delete(LogicalDatastoreType.OPERATIONAL, this.nodeId);
Futures.addCallback(trans.submit(), new FutureCallback<Void>() {
@Override
public void onSuccess(final Void result) {
LOG.trace("Internal state for node {} cleaned up successfully", TopologyNodeState.this.nodeId);
}
@Override
public void onFailure(final Throwable throwable) {
LOG.error("Failed to cleanup internal state for session {}", TopologyNodeState.this.nodeId, throwable);
}
}, MoreExecutors.directExecutor());
}
this.lastReleased = System.nanoTime();
}
use of org.opendaylight.controller.md.sal.binding.api.WriteTransaction in project bgpcep by opendaylight.
the class AppPeerBenchmark method close.
@Override
public void close() {
this.rpcRegistration.close();
final WriteTransaction dTx = this.txChain.newWriteOnlyTransaction();
dTx.delete(LogicalDatastoreType.CONFIGURATION, this.appIID);
try {
dTx.submit().checkedGet();
} catch (final TransactionCommitFailedException e) {
LOG.warn("Failed to clean-up BGP Application RIB.", e);
}
this.txChain.close();
LOG.info("BGP Application Peer Benchmark Application closed.");
}
Aggregations