private void statMeterCommit(final List<MeterStats> meterStats, final InstanceIdentifier<Node> nodeIdent, final ReadWriteTransaction tx) { Preconditions.checkNotNull(meterStats); Preconditions.checkNotNull(nodeIdent); Preconditions.checkNotNull(tx); final InstanceIdentifier<FlowCapableNode> fNodeIdent = nodeIdent.augmentation(FlowCapableNode.class); for (final MeterStats mStat : meterStats) { final MeterStatistics stats = new MeterStatisticsBuilder(mStat).build(); final InstanceIdentifier<Meter> meterIdent = fNodeIdent.child(Meter.class, new MeterKey(mStat.getMeterId())); final InstanceIdentifier<NodeMeterStatistics> nodeMeterStatIdent = meterIdent .augmentation(NodeMeterStatistics.class); final InstanceIdentifier<MeterStatistics> msIdent = nodeMeterStatIdent.child(MeterStatistics.class); /* Meter Statistics commit */ Optional<Meter> meter = Optional.absent(); try { meter = tx.read(LogicalDatastoreType.OPERATIONAL, meterIdent).checkedGet(); } catch (final ReadFailedException e) { LOG.debug("Read Operational/DS for FlowCapableNode fail! {}", fNodeIdent, e); } if (meter.isPresent()) { tx.merge(LogicalDatastoreType.OPERATIONAL, nodeMeterStatIdent, new NodeMeterStatisticsBuilder().build(), true); tx.put(LogicalDatastoreType.OPERATIONAL, msIdent, stats); } } }
private void statMeterCommit(final List<MeterStats> meterStats, final InstanceIdentifier<Node> nodeIdent, final ReadWriteTransaction tx) { Preconditions.checkNotNull(meterStats); Preconditions.checkNotNull(nodeIdent); Preconditions.checkNotNull(tx); final InstanceIdentifier<FlowCapableNode> fNodeIdent = nodeIdent.augmentation(FlowCapableNode.class); for (final MeterStats mStat : meterStats) { final MeterStatistics stats = new MeterStatisticsBuilder(mStat).build(); final InstanceIdentifier<Meter> meterIdent = fNodeIdent.child(Meter.class, new MeterKey(mStat.getMeterId())); final InstanceIdentifier<NodeMeterStatistics> nodeMeterStatIdent = meterIdent .augmentation(NodeMeterStatistics.class); final InstanceIdentifier<MeterStatistics> msIdent = nodeMeterStatIdent.child(MeterStatistics.class); /* Meter Statistics commit */ Optional<Meter> meter = Optional.absent(); try { meter = tx.read(LogicalDatastoreType.OPERATIONAL, meterIdent).checkedGet(); } catch (final ReadFailedException e) { LOG.debug("Read Operational/DS for FlowCapableNode fail! {}", fNodeIdent, e); } if (meter.isPresent()) { tx.merge(LogicalDatastoreType.OPERATIONAL, nodeMeterStatIdent, new NodeMeterStatisticsBuilder().build(), true); tx.put(LogicalDatastoreType.OPERATIONAL, msIdent, stats); } } }