예제 #1
0
 @Override
 protected void cleanupSingleStat(DataModificationTransaction trans, MeterStats item) {
   InstanceIdentifier<NodeMeterStatistics> meterRef =
       getNodeIdentifierBuilder()
           .augmentation(FlowCapableNode.class)
           .child(Meter.class, new MeterKey(item.getMeterId()))
           .augmentation(NodeMeterStatistics.class)
           .build();
   trans.removeOperationalData(meterRef);
 }
예제 #2
0
  @Override
  public void onDataChanged(DataChangeEvent<InstanceIdentifier<?>, DataObject> change) {
    for (InstanceIdentifier<?> key : change.getCreatedConfigurationData().keySet()) {
      if (Meter.class.equals(key.getTargetType())) {
        request();
      }
    }

    final DataModificationTransaction trans = startTransaction();
    for (InstanceIdentifier<?> key : change.getRemovedConfigurationData()) {
      if (Meter.class.equals(key.getTargetType())) {
        @SuppressWarnings("unchecked")
        InstanceIdentifier<Meter> meter = (InstanceIdentifier<Meter>) key;

        InstanceIdentifier<?> nodeMeterStatisticsAugmentation =
            InstanceIdentifier.builder(meter).augmentation(NodeMeterStatistics.class).toInstance();
        trans.removeOperationalData(nodeMeterStatisticsAugmentation);
      }
    }
    trans.commit();
  }
예제 #3
0
  @Override
  protected MeterStats updateSingleStat(DataModificationTransaction trans, MeterStats item) {
    MeterBuilder meterBuilder = new MeterBuilder();
    MeterKey meterKey = new MeterKey(item.getMeterId());
    meterBuilder.setKey(meterKey);

    InstanceIdentifier<Meter> meterRef =
        getNodeIdentifierBuilder()
            .augmentation(FlowCapableNode.class)
            .child(Meter.class, meterKey)
            .build();

    NodeMeterStatisticsBuilder meterStatsBuilder = new NodeMeterStatisticsBuilder();
    meterStatsBuilder.setMeterStatistics(new MeterStatisticsBuilder(item).build());

    // Update augmented data
    meterBuilder.addAugmentation(NodeMeterStatistics.class, meterStatsBuilder.build());
    trans.putOperationalData(meterRef, meterBuilder.build());
    return item;
  }