use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId in project openflowplugin by opendaylight.
the class MeterConfigStatsResponseConvertorTest method createMeterConfigList.
private List<MeterConfig> createMeterConfigList() {
List<MeterConfig> meterConfigs = new ArrayList<>();
MeterConfigBuilder meterConfigBuilder = new MeterConfigBuilder();
for (int i = 0; i < PRESET_COUNT; i++) {
meterConfigBuilder.setMeterId(new MeterId((long) i));
List<Bands> bandses = new ArrayList<>();
BandsBuilder bandsBuilder = new BandsBuilder();
bandsBuilder.setMeterBand(new MeterBandDropCaseBuilder().setMeterBandDrop(new MeterBandDropBuilder().build()).build());
bandses.add(bandsBuilder.build());
bandsBuilder = new BandsBuilder();
bandsBuilder.setMeterBand(new MeterBandDscpRemarkCaseBuilder().setMeterBandDscpRemark(new MeterBandDscpRemarkBuilder().build()).build());
bandses.add(bandsBuilder.build());
bandsBuilder = new BandsBuilder();
bandsBuilder.setMeterBand(new MockMeterBandBuilder());
bandses.add(bandsBuilder.build());
bandsBuilder = new BandsBuilder();
bandsBuilder.setMeterBand(new MeterBandExperimenterCaseBuilder().setMeterBandExperimenter(new MeterBandExperimenterBuilder().build()).build());
bandses.add(bandsBuilder.build());
meterConfigBuilder.setBands(bandses);
meterConfigBuilder.setFlags(new MeterFlags(true, false, true, false));
meterConfigs.add(meterConfigBuilder.build());
}
return meterConfigs;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId in project openflowplugin by opendaylight.
the class MeterStatsResponseConvertorTest method testToSALMeterStatsList.
@Test
public /**
* Test of basic mapping functionality of {@link MeterStatsResponseConvertor#convert(java.util.List)}
*/
void testToSALMeterStatsList() {
final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();
Optional<List<MeterStats>> meterStatsListOptional = convertorManager.convert(createMeterStatsLit(), new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
List<MeterStats> meterStatsList = meterStatsListOptional.orElse(Collections.emptyList());
assertEquals(PRESET_COUNT, meterStatsList.size());
int cnt = 0;
for (MeterStats meterStats : meterStatsList) {
assertEquals(new MeterStatsKey(new org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId((long) cnt)).getMeterId(), meterStats.getKey().getMeterId());
assertEquals(BigInteger.valueOf(cnt), meterStats.getByteInCount().getValue());
assertEquals(new Long(1000 * cnt), meterStats.getDuration().getNanosecond().getValue());
assertEquals(new Long(10 * cnt), meterStats.getDuration().getSecond().getValue());
assertEquals(new Long(cnt), meterStats.getFlowCount().getValue());
assertEquals(BigInteger.valueOf(cnt), meterStats.getByteInCount().getValue());
assertEquals(PRESET_COUNT, meterStats.getMeterBandStats().getBandStat().size());
int bandStatCount = 0;
for (BandStat bandStat : meterStats.getMeterBandStats().getBandStat()) {
assertEquals(BigInteger.valueOf(bandStatCount), bandStat.getByteBandCount().getValue());
assertEquals(BigInteger.valueOf(bandStatCount), bandStat.getPacketBandCount().getValue());
bandStatCount++;
}
assertEquals(new MeterStatsKey(new org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId((long) cnt)).getMeterId(), meterStats.getMeterId());
assertEquals(BigInteger.valueOf(cnt), meterStats.getPacketInCount().getValue());
cnt++;
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId in project openflowplugin by opendaylight.
the class StatisticsGatheringUtilsTest method testGatherStatistics_meter.
@Test
public void testGatherStatistics_meter() throws Exception {
final MultipartType type = MultipartType.OFPMPMETER;
final long meterIdValue = 19L;
final MeterBandStatsBuilder meterBandStatsBld = new MeterBandStatsBuilder().setByteBandCount(BigInteger.valueOf(91L)).setPacketBandCount(BigInteger.valueOf(92L));
final MeterStatsBuilder meterStatsBld = new MeterStatsBuilder().setMeterId(new MeterId(meterIdValue)).setByteInCount(BigInteger.valueOf(111L)).setDurationSec(112L).setDurationNsec(113L).setFlowCount(114L).setPacketInCount(BigInteger.valueOf(115L)).setMeterBandStats(Lists.newArrayList(meterBandStatsBld.build()));
final MultipartReplyMeterBuilder mpReplyMeterBld = new MultipartReplyMeterBuilder();
mpReplyMeterBld.setMeterStats(Lists.newArrayList(meterStatsBld.build()));
final MultipartReplyMeterCaseBuilder mpReplyMeterCaseBld = new MultipartReplyMeterCaseBuilder();
mpReplyMeterCaseBld.setMultipartReplyMeter(mpReplyMeterBld.build());
final MultipartReply meterStatsUpdated = assembleMPReplyMessage(type, mpReplyMeterCaseBld.build());
final List<MultipartReply> statsData = Collections.singletonList(meterStatsUpdated);
fireAndCheck(type, statsData);
final InstanceIdentifier<MeterStatistics> meterPath = dummyNodePath.augmentation(FlowCapableNode.class).child(Meter.class, new MeterKey(new org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId(meterIdValue))).augmentation(NodeMeterStatistics.class).child(MeterStatistics.class);
verify(deviceContext).writeToTransaction(Matchers.eq(LogicalDatastoreType.OPERATIONAL), Matchers.eq(meterPath), Matchers.any(MeterStatistics.class));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId in project openflowplugin by opendaylight.
the class MeterListenerTest method removeMeterTest.
@Test
public void removeMeterTest() throws Exception {
addFlowCapableNode(NODE_KEY);
MeterKey meterKey = new MeterKey(new MeterId((long) 2000));
InstanceIdentifier<Meter> meterII = InstanceIdentifier.create(Nodes.class).child(Node.class, NODE_KEY).augmentation(FlowCapableNode.class).child(Meter.class, meterKey);
Meter meter = new MeterBuilder().setKey(meterKey).setMeterName("meter_one").build();
WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.CONFIGURATION, meterII, meter);
assertCommit(writeTx.submit());
SalMeterServiceMock salMeterService = (SalMeterServiceMock) forwardingRulesManager.getSalMeterService();
List<AddMeterInput> addMeterCalls = salMeterService.getAddMeterCalls();
assertEquals(1, addMeterCalls.size());
assertEquals("DOM-0", addMeterCalls.get(0).getTransactionUri().getValue());
writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.delete(LogicalDatastoreType.CONFIGURATION, meterII);
assertCommit(writeTx.submit());
salMeterService = (SalMeterServiceMock) forwardingRulesManager.getSalMeterService();
List<RemoveMeterInput> removeMeterCalls = salMeterService.getRemoveMeterCalls();
assertEquals(1, removeMeterCalls.size());
assertEquals("DOM-1", removeMeterCalls.get(0).getTransactionUri().getValue());
assertEquals(meterII, removeMeterCalls.get(0).getMeterRef().getValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId in project openflowplugin by opendaylight.
the class MeterListenerTest method staleMeterCreationTest.
@Test
public void staleMeterCreationTest() throws Exception {
addFlowCapableNode(NODE_KEY);
StaleMeterKey meterKey = new StaleMeterKey(new MeterId((long) 2000));
InstanceIdentifier<StaleMeter> meterII = InstanceIdentifier.create(Nodes.class).child(Node.class, NODE_KEY).augmentation(FlowCapableNode.class).child(StaleMeter.class, meterKey);
StaleMeter meter = new StaleMeterBuilder().setKey(meterKey).setMeterName("stale_meter_one").build();
WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.CONFIGURATION, meterII, meter);
assertCommit(writeTx.submit());
}
Aggregations