- 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);
+ try {
+ 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.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());
+ } catch (final Exception e) {
+ LOG.warn("Failed to prepare Tx for PCEP stats update", e);
+ tx.cancel();