Search in sources :

Example 1 with PcepTopologyNodeStatsAugBuilder

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());
}
Also used : WriteTransaction(org.opendaylight.mdsal.binding.api.WriteTransaction) PcepSessionState(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.PcepSessionState) TransactionChain(org.opendaylight.mdsal.binding.api.TransactionChain) ExecutionException(java.util.concurrent.ExecutionException) PcepTopologyNodeStatsAugBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.stats.rev181109.PcepTopologyNodeStatsAugBuilder) PcepTopologyNodeStatsAug(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.stats.rev181109.PcepTopologyNodeStatsAug) PcepSessionStateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.grouping.PcepSessionStateBuilder) KeyedInstanceIdentifier(org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier) CommitInfo(org.opendaylight.mdsal.common.api.CommitInfo)

Example 2 with PcepTopologyNodeStatsAugBuilder

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();
}
Also used : WriteTransaction(org.opendaylight.mdsal.binding.api.WriteTransaction) PcepTopologyNodeStatsAugBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.stats.rev181109.PcepTopologyNodeStatsAugBuilder) TopologyKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) NetworkTopology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) NodeBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder) NodeKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey) TopologyId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId)

Example 3 with PcepTopologyNodeStatsAugBuilder

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();
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) PcepTopologyNodeStatsAugBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.stats.rev171113.PcepTopologyNodeStatsAugBuilder) PcepTopologyNodeStatsAug(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.stats.rev171113.PcepTopologyNodeStatsAug) PcepSessionState(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.PcepSessionState) PcepSessionStateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.grouping.PcepSessionStateBuilder) KeyedInstanceIdentifier(org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

WriteTransaction (org.opendaylight.mdsal.binding.api.WriteTransaction)2 PcepSessionState (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.PcepSessionState)2 PcepSessionStateBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.grouping.PcepSessionStateBuilder)2 PcepTopologyNodeStatsAugBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.stats.rev181109.PcepTopologyNodeStatsAugBuilder)2 KeyedInstanceIdentifier (org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ExecutionException (java.util.concurrent.ExecutionException)1 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)1 TransactionChain (org.opendaylight.mdsal.binding.api.TransactionChain)1 CommitInfo (org.opendaylight.mdsal.common.api.CommitInfo)1 PcepTopologyNodeStatsAug (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.stats.rev171113.PcepTopologyNodeStatsAug)1 PcepTopologyNodeStatsAugBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.stats.rev171113.PcepTopologyNodeStatsAugBuilder)1 PcepTopologyNodeStatsAug (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.stats.rev181109.PcepTopologyNodeStatsAug)1 NetworkTopology (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology)1 NodeId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)1 TopologyId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId)1 TopologyKey (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey)1 Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)1 NodeBuilder (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder)1