use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterKey in project openflowplugin by opendaylight.
the class MeterListenerTest method updateMeterTest.
@Test
public void updateMeterTest() 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").setBarrier(false).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());
meter = new MeterBuilder().setKey(meterKey).setMeterName("meter_two").setBarrier(true).build();
writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.CONFIGURATION, meterII, meter);
assertCommit(writeTx.submit());
salMeterService = (SalMeterServiceMock) forwardingRulesManager.getSalMeterService();
List<UpdateMeterInput> updateMeterCalls = salMeterService.getUpdateMeterCalls();
assertEquals(1, updateMeterCalls.size());
assertEquals("DOM-1", updateMeterCalls.get(0).getTransactionUri().getValue());
assertEquals(meterII, updateMeterCalls.get(0).getMeterRef().getValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterKey in project openflowplugin by opendaylight.
the class MeterListenerTest method addTwoMetersTest.
@Test
public void addTwoMetersTest() 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());
meterKey = new MeterKey(new MeterId((long) 2001));
meterII = InstanceIdentifier.create(Nodes.class).child(Node.class, NODE_KEY).augmentation(FlowCapableNode.class).child(Meter.class, meterKey);
meter = new MeterBuilder().setKey(meterKey).setMeterName("meter_two").setBarrier(true).build();
writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.CONFIGURATION, meterII, meter);
assertCommit(writeTx.submit());
salMeterService = (SalMeterServiceMock) forwardingRulesManager.getSalMeterService();
addMeterCalls = salMeterService.getAddMeterCalls();
assertEquals(2, addMeterCalls.size());
assertEquals("DOM-1", addMeterCalls.get(1).getTransactionUri().getValue());
assertEquals(meterII, addMeterCalls.get(1).getMeterRef().getValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterKey in project openflowplugin by opendaylight.
the class StatisticsGatheringUtilsTest method testGatherStatistics_meterConfig.
@Test
public void testGatherStatistics_meterConfig() throws Exception {
final MultipartType type = MultipartType.OFPMPMETERCONFIG;
final Long meterIdValue = 55L;
final MeterConfigBuilder meterConfigBld = new MeterConfigBuilder().setMeterId(new MeterId(meterIdValue)).setFlags(new MeterFlags(false, true, false, true)).setBands(Collections.<Bands>emptyList());
final MultipartReplyMeterConfigBuilder mpReplyMeterConfigBld = new MultipartReplyMeterConfigBuilder();
mpReplyMeterConfigBld.setMeterConfig(Lists.newArrayList(meterConfigBld.build()));
final MultipartReplyMeterConfigCaseBuilder mpReplyMeterConfigCaseBld = new MultipartReplyMeterConfigCaseBuilder();
mpReplyMeterConfigCaseBld.setMultipartReplyMeterConfig(mpReplyMeterConfigBld.build());
final MultipartReply meterConfigUpdated = assembleMPReplyMessage(type, mpReplyMeterConfigCaseBld.build());
final List<MultipartReply> statsData = Collections.singletonList(meterConfigUpdated);
fireAndCheck(type, statsData);
final org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId meterId = new org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId(meterIdValue);
final KeyedInstanceIdentifier<Meter, MeterKey> meterPath = dummyNodePath.augmentation(FlowCapableNode.class).child(Meter.class, new MeterKey(meterId));
verify(deviceContext, Mockito.never()).addDeleteToTxChain(Matchers.eq(LogicalDatastoreType.OPERATIONAL), Matchers.<InstanceIdentifier<?>>any());
verify(deviceMeterRegistry).store(meterId);
verify(deviceContext).writeToTransaction(Matchers.eq(LogicalDatastoreType.OPERATIONAL), Matchers.eq(meterPath), Matchers.any(Meter.class));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterKey in project openflowplugin by opendaylight.
the class OpenflowpluginMeterTestCommandProvider method _removeMeters.
public void _removeMeters(final CommandInterpreter ci) {
String nref = ci.nextArgument();
if (nref == null) {
ci.println("test node added");
createTestNode();
} else {
ci.println("User node added" + nref);
createUserNode(nref);
}
Integer count = Integer.parseInt(ci.nextArgument());
ReadWriteTransaction modification = dataBroker.newReadWriteTransaction();
switch(count) {
case 1:
createTestMeters("1", "remove");
InstanceIdentifier<Meter> path1 = InstanceIdentifier.create(Nodes.class).child(Node.class, testNode.getKey()).augmentation(FlowCapableNode.class).child(Meter.class, new MeterKey(testMeter1.getMeterId()));
modification.delete(LogicalDatastoreType.CONFIGURATION, path1);
createTestMeters("2", "remove");
InstanceIdentifier<Meter> path2 = InstanceIdentifier.create(Nodes.class).child(Node.class, testNode.getKey()).augmentation(FlowCapableNode.class).child(Meter.class, new MeterKey(testMeter2.getMeterId()));
modification.delete(LogicalDatastoreType.CONFIGURATION, path2);
break;
case 2:
createTestMeters("3", "remove");
InstanceIdentifier<Meter> path3 = InstanceIdentifier.create(Nodes.class).child(Node.class, testNode.getKey()).augmentation(FlowCapableNode.class).child(Meter.class, new MeterKey(testMeter1.getMeterId()));
modification.delete(LogicalDatastoreType.CONFIGURATION, path3);
createTestMeters("4", "remove");
InstanceIdentifier<Meter> path4 = InstanceIdentifier.create(Nodes.class).child(Node.class, testNode.getKey()).augmentation(FlowCapableNode.class).child(Meter.class, new MeterKey(testMeter2.getMeterId()));
modification.delete(LogicalDatastoreType.CONFIGURATION, path4);
break;
case 3:
createTestMeters("5", "remove");
InstanceIdentifier<Meter> path5 = InstanceIdentifier.create(Nodes.class).child(Node.class, testNode.getKey()).augmentation(FlowCapableNode.class).child(Meter.class, new MeterKey(testMeter1.getMeterId()));
modification.delete(LogicalDatastoreType.CONFIGURATION, path5);
createTestMeters("6", "remove");
InstanceIdentifier<Meter> path6 = InstanceIdentifier.create(Nodes.class).child(Node.class, testNode.getKey()).augmentation(FlowCapableNode.class).child(Meter.class, new MeterKey(testMeter2.getMeterId()));
modification.delete(LogicalDatastoreType.CONFIGURATION, path6);
break;
case 4:
createTestMeters("7", "remove");
InstanceIdentifier<Meter> path7 = InstanceIdentifier.create(Nodes.class).child(Node.class, testNode.getKey()).augmentation(FlowCapableNode.class).child(Meter.class, new MeterKey(testMeter1.getMeterId()));
modification.delete(LogicalDatastoreType.CONFIGURATION, path7);
createTestMeters("8", "remove");
InstanceIdentifier<Meter> path8 = InstanceIdentifier.create(Nodes.class).child(Node.class, testNode.getKey()).augmentation(FlowCapableNode.class).child(Meter.class, new MeterKey(testMeter2.getMeterId()));
modification.delete(LogicalDatastoreType.CONFIGURATION, path8);
break;
default:
break;
}
CheckedFuture<Void, TransactionCommitFailedException> commitFuture = modification.submit();
Futures.addCallback(commitFuture, new FutureCallback<Void>() {
@Override
public void onSuccess(Void notUsed) {
ci.println("Status of Group Data Loaded Transaction: success.");
}
@Override
public void onFailure(Throwable throwable) {
ci.println(String.format("Status of Group Data Loaded Transaction : failure. Reason : %s", throwable));
}
}, MoreExecutors.directExecutor());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterKey in project openflowplugin by opendaylight.
the class OpenflowpluginMeterTestCommandProvider method createTestMeter.
private MeterBuilder createTestMeter() {
// Sample data , committing to DataStore
long id = 12;
MeterKey key = new MeterKey(new MeterId(id));
MeterBuilder meter = new MeterBuilder();
meter.setContainerName("abcd");
meter.setKey(key);
meter.setMeterId(new MeterId(9L));
meter.setMeterName(originalMeterName);
meter.setFlags(new MeterFlags(true, false, false, false));
MeterBandHeaderBuilder bandHeader = new MeterBandHeaderBuilder();
bandHeader.setBandRate((long) 234);
bandHeader.setBandBurstSize((long) 444);
DscpRemarkBuilder dscpRemark = new DscpRemarkBuilder();
dscpRemark.setDscpRemarkBurstSize((long) 5);
dscpRemark.setPrecLevel((short) 1);
dscpRemark.setDscpRemarkRate((long) 12);
bandHeader.setBandType(dscpRemark.build());
MeterBandTypesBuilder bandTypes = new MeterBandTypesBuilder();
MeterBandType bandType = new MeterBandType(false, true, false);
bandTypes.setFlags(bandType);
bandHeader.setMeterBandTypes(bandTypes.build());
bandHeader.setBandId(new BandId(0L));
List<MeterBandHeader> bandHdr = new ArrayList<>();
bandHdr.add(bandHeader.build());
MeterBandHeadersBuilder bandHeaders = new MeterBandHeadersBuilder();
bandHeaders.setMeterBandHeader(bandHdr);
meter.setMeterBandHeaders(bandHeaders.build());
testMeter = meter.build();
return meter;
}
Aggregations