use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.stats.rev181109.PcepTopologyNodeStatsAugBuilder in project bgpcep by opendaylight.
the class TopologyStatsProviderImpl method updateStats.
@SuppressWarnings("checkstyle:IllegalCatch")
public synchronized void updateStats() {
final TransactionChain chain = accessChain();
if (chain == null) {
// Already closed, do not bother
return;
}
final WriteTransaction tx = chain.newWriteOnlyTransaction();
try {
for (Entry<KeyedInstanceIdentifier<Node, NodeKey>, PcepSessionState> entry : statsMap.entrySet()) {
if (!statsPendingDelete.contains(entry.getKey())) {
tx.put(LogicalDatastoreType.OPERATIONAL, entry.getKey().augmentation(PcepTopologyNodeStatsAug.class), new PcepTopologyNodeStatsAugBuilder().setPcepSessionState(new PcepSessionStateBuilder(entry.getValue()).build()).build());
}
}
} catch (Exception e) {
LOG.warn("Failed to prepare Tx for PCEP stats update", e);
tx.cancel();
return;
}
tx.commit().addCallback(new FutureCallback<CommitInfo>() {
@Override
public void onSuccess(final CommitInfo result) {
LOG.debug("Successfully committed Topology stats update");
}
@Override
public void onFailure(final Throwable ex) {
LOG.error("Failed to commit Topology stats update", ex);
}
}, MoreExecutors.directExecutor());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.stats.rev181109.PcepTopologyNodeStatsAugBuilder 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(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.mergeParentStructurePut(LogicalDatastoreType.OPERATIONAL, topology, node);
wt.commit().get();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.stats.rev181109.PcepTopologyNodeStatsAugBuilder in project bgpcep by opendaylight.
the class TopologyStatsProviderImpl method updatePcepStats.
private synchronized void updatePcepStats() {
final WriteTransaction tx = TopologyStatsProviderImpl.this.transactionChain.newWriteOnlyTransaction();
for (final Map.Entry<KeyedInstanceIdentifier<Node, NodeKey>, PcepSessionState> entry : this.statsMap.entrySet()) {
final PcepTopologyNodeStatsAug nodeStatsAug = new PcepTopologyNodeStatsAugBuilder().setPcepSessionState(new PcepSessionStateBuilder(entry.getValue()).build()).build();
final InstanceIdentifier<PcepTopologyNodeStatsAug> statId = entry.getKey().augmentation(PcepTopologyNodeStatsAug.class);
tx.put(LogicalDatastoreType.OPERATIONAL, statId, nodeStatsAug);
}
tx.submit();
}
Aggregations