use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter in project openflowplugin by opendaylight.
the class MultipartReplyMeterConfigDeserializer method deserialize.
@Override
public MultipartReplyBody deserialize(ByteBuf message) {
final MultipartReplyMeterConfigBuilder builder = new MultipartReplyMeterConfigBuilder();
final List<MeterConfigStats> items = new ArrayList<>();
while (message.readableBytes() > 0) {
final int itemLength = message.readUnsignedShort();
final MeterConfigStatsBuilder itemBuilder = new MeterConfigStatsBuilder().setFlags(readMeterFlags(message)).setMeterId(new MeterId(message.readUnsignedInt()));
final List<MeterBandHeader> subItems = new ArrayList<>();
int actualLength = METER_CONFIG_LENGTH;
while (actualLength < itemLength) {
final int itemStartIndex = message.readerIndex();
final int itemBandType = message.readUnsignedShort();
final MeterBandHeaderBuilder subItemBuilder = new MeterBandHeaderBuilder();
actualLength += message.readUnsignedShort();
switch(itemBandType) {
case OFPMBTDROP:
subItemBuilder.setMeterBandTypes(new MeterBandTypesBuilder().setFlags(new MeterBandType(true, false, false)).build()).setBandType(new DropBuilder().setDropRate(message.readUnsignedInt()).setDropBurstSize(message.readUnsignedInt()).build());
message.skipBytes(PADDING_IN_METER_BAND_DROP_HEADER);
break;
case OFPMBTDSCP:
subItemBuilder.setMeterBandTypes(new MeterBandTypesBuilder().setFlags(new MeterBandType(false, true, false)).build()).setBandType(new DscpRemarkBuilder().setDscpRemarkRate(message.readUnsignedInt()).setDscpRemarkBurstSize(message.readUnsignedInt()).setPrecLevel(message.readUnsignedByte()).build());
message.skipBytes(PADDING_IN_METER_BAND_DSCP_HEADER);
break;
case OFPMBTEXPERIMENTER:
// TODO: Finish meter band experimenter deserialization
final long expId = message.getUnsignedInt(message.readerIndex() + 2 * EncodeConstants.SIZE_OF_INT_IN_BYTES);
message.readerIndex(itemStartIndex);
final OFDeserializer<Experimenter> deserializer = registry.getDeserializer(new ExperimenterIdDeserializerKey(EncodeConstants.OF13_VERSION_ID, expId, Experimenter.class));
subItemBuilder.setMeterBandTypes(new MeterBandTypesBuilder().setFlags(new MeterBandType(false, false, true)).build()).setBandType(deserializer.deserialize(message));
break;
default:
}
subItems.add(subItemBuilder.build());
}
items.add(itemBuilder.setKey(new MeterConfigStatsKey(itemBuilder.getMeterId())).setMeterBandHeaders(new MeterBandHeadersBuilder().setMeterBandHeader(subItems).build()).build());
}
return builder.setMeterConfigStats(items).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter in project openflowplugin by opendaylight.
the class MeterMessageDeserializer method deserialize.
@Override
public MeterMessage deserialize(ByteBuf message) {
final MeterMessageBuilder builder = new MeterMessageBuilder().setVersion((short) EncodeConstants.OF13_VERSION_ID).setXid(message.readUnsignedInt()).setCommand(MeterModCommand.forValue(message.readUnsignedShort())).setFlags(readMeterFlags(message)).setMeterId(new MeterId(message.readUnsignedInt()));
final List<MeterBandHeader> bands = new ArrayList<>();
while (message.readableBytes() > 0) {
final MeterBandHeaderBuilder bandBuilder = new MeterBandHeaderBuilder();
final int bandStartIndex = message.readerIndex();
final int bandType = message.readUnsignedShort();
switch(bandType) {
case OFPMBTDROP:
{
bandBuilder.setMeterBandTypes(new MeterBandTypesBuilder().setFlags(new MeterBandType(true, false, false)).build()).setBandType(new DropBuilder().setDropRate(message.readUnsignedInt()).setDropBurstSize(message.readUnsignedInt()).build());
message.skipBytes(PADDING_IN_METER_BAND_DROP_HEADER);
break;
}
case OFPMBTDSCP:
{
bandBuilder.setMeterBandTypes(new MeterBandTypesBuilder().setFlags(new MeterBandType(false, true, false)).build()).setBandType(new DscpRemarkBuilder().setDscpRemarkRate(message.readUnsignedInt()).setDscpRemarkBurstSize(message.readUnsignedInt()).setPrecLevel(message.readUnsignedByte()).build());
message.skipBytes(PADDING_IN_METER_BAND_DSCP_HEADER);
break;
}
case OFPMBTEXPERIMENTER:
{
// TODO: Finish meter band experimenter deserialization
long expId = message.getUnsignedInt(message.readerIndex() + 2 * EncodeConstants.SIZE_OF_INT_IN_BYTES);
message.readerIndex(bandStartIndex);
OFDeserializer<Experimenter> deserializer = registry.getDeserializer(new ExperimenterIdDeserializerKey(EncodeConstants.OF13_VERSION_ID, expId, Experimenter.class));
bandBuilder.setMeterBandTypes(new MeterBandTypesBuilder().setFlags(new MeterBandType(false, false, true)).build()).setBandType(deserializer.deserialize(message));
break;
}
default:
}
bands.add(bandBuilder.build());
}
return builder.setMeterBandHeaders(new MeterBandHeadersBuilder().setMeterBandHeader(bands).build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter in project openflowplugin by opendaylight.
the class MeterDirectStatisticsServiceTest method testBuildReply.
@Override
public void testBuildReply() throws Exception {
final MultipartReply reply = mock(MultipartReply.class);
final MultipartReplyMeterCase MeterCase = mock(MultipartReplyMeterCase.class);
final MultipartReplyMeter meter = mock(MultipartReplyMeter.class);
final MeterStats meterStat = new MeterStatsBuilder().setMeterId(new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId(METER_NO)).setByteInCount(BigInteger.ONE).setPacketInCount(BigInteger.ONE).setDurationSec(1L).setDurationNsec(1L).setFlowCount(0L).setMeterBandStats(Collections.emptyList()).build();
final List<MeterStats> meterStats = Collections.singletonList(meterStat);
final List<MultipartReply> input = Collections.singletonList(reply);
when(meter.getMeterStats()).thenReturn(meterStats);
when(MeterCase.getMultipartReplyMeter()).thenReturn(meter);
when(reply.getMultipartReplyBody()).thenReturn(MeterCase);
final GetMeterStatisticsOutput output = service.buildReply(input, true);
assertTrue(output.getMeterStats().size() > 0);
final org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStats stats = output.getMeterStats().get(0);
assertEquals(stats.getMeterId().getValue(), METER_NO);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter in project openflowplugin by opendaylight.
the class OpenflowpluginMeterTestCommandProvider method _removeMeter.
public void _removeMeter(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);
}
createTestMeter();
ReadWriteTransaction modification = dataBroker.newReadWriteTransaction();
InstanceIdentifier<Meter> path1 = InstanceIdentifier.create(Nodes.class).child(Node.class, testNode.getKey()).augmentation(FlowCapableNode.class).child(Meter.class, new MeterKey(testMeter.getMeterId()));
modification.delete(LogicalDatastoreType.CONFIGURATION, path1);
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.Meter in project openflowplugin by opendaylight.
the class OpenflowpluginMeterTestCommandProvider method createTestMeters.
private MeterBuilder createTestMeters(String s1, String s2) {
// Sample data , committing to DataStore
long id = Integer.parseInt(s1);
MeterKey key = new MeterKey(new MeterId(id));
MeterBuilder meter = new MeterBuilder();
meter.setContainerName("abcd");
meter.setKey(key);
meter.setMeterId(new MeterId(9L));
MeterBandHeaderBuilder bandHeader = new MeterBandHeaderBuilder();
if (s2.equalsIgnoreCase("modify")) {
meter.setMeterName(updatedMeterName);
bandHeader.setBandRate((long) 234);
} else {
meter.setMeterName(originalMeterName);
bandHeader.setBandRate((long) 123);
}
meter.setFlags(new MeterFlags(true, false, false, false));
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());
if (Integer.parseInt(s1) == 1) {
testMeter1 = meter.build();
} else if (Integer.parseInt(s1) == 2) {
testMeter2 = meter.build();
} else if (Integer.parseInt(s1) == 3) {
testMeter1 = meter.build();
} else if (Integer.parseInt(s1) == 4) {
testMeter2 = meter.build();
} else if (Integer.parseInt(s1) == 5) {
testMeter1 = meter.build();
} else if (Integer.parseInt(s1) == 6) {
testMeter2 = meter.build();
} else if (Integer.parseInt(s1) == 7) {
testMeter1 = meter.build();
} else if (Integer.parseInt(s1) == 8) {
testMeter2 = meter.build();
}
return meter;
}
Aggregations