Search in sources :

Example 16 with MeterId

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;
}
Also used : MeterConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.MeterConfigBuilder) MeterBandDscpRemarkCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDscpRemarkCaseBuilder) ArrayList(java.util.ArrayList) MeterBandDropBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.drop._case.MeterBandDropBuilder) MeterBandExperimenterCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCaseBuilder) MeterConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.MeterConfig) MeterId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId) MeterBandDscpRemarkBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.dscp.remark._case.MeterBandDscpRemarkBuilder) Bands(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.meter.config.Bands) MeterBandExperimenterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.experimenter._case.MeterBandExperimenterBuilder) MeterBandDropCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDropCaseBuilder) MeterFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags) BandsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.meter.config.BandsBuilder)

Example 17 with MeterId

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++;
    }
}
Also used : MeterStatsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStatsKey) BandStat(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.meter.band.stats.BandStat) VersionConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData) MeterStats(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStats) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test)

Example 18 with MeterId

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));
}
Also used : MultipartType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType) MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply) NodeMeterStatistics(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.NodeMeterStatistics) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) MeterId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId) MeterKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterKey) MeterBandStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.multipart.reply.meter.meter.stats.MeterBandStatsBuilder) NodeMeterStatistics(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.NodeMeterStatistics) MeterStatistics(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.nodes.node.meter.MeterStatistics) MeterStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.multipart.reply.meter.MeterStatsBuilder) MultipartReplyMeterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.MultipartReplyMeterBuilder) MultipartReplyMeterCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterCaseBuilder) Test(org.junit.Test)

Example 19 with MeterId

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());
}
Also used : MeterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterBuilder) StaleMeterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.StaleMeterBuilder) WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) Meter(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter) StaleMeter(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.StaleMeter) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes) MeterId(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId) MeterKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterKey) StaleMeterKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.StaleMeterKey) SalMeterServiceMock(test.mock.util.SalMeterServiceMock) AddMeterInput(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterInput) RemoveMeterInput(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterInput) FRMTest(test.mock.util.FRMTest) Test(org.junit.Test)

Example 20 with MeterId

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());
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) StaleMeter(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.StaleMeter) StaleMeterKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.StaleMeterKey) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes) MeterId(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId) StaleMeterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.StaleMeterBuilder) FRMTest(test.mock.util.FRMTest) Test(org.junit.Test)

Aggregations

MeterId (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId)32 Test (org.junit.Test)26 ArrayList (java.util.ArrayList)24 MeterId (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId)23 ByteBuf (io.netty.buffer.ByteBuf)11 AddMeterInput (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterInput)10 MeterFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags)9 MeterBandType (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterBandType)8 DscpRemarkBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.DscpRemarkBuilder)8 MeterBandHeadersBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.MeterBandHeadersBuilder)8 MeterBandHeader (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeader)8 MeterBandHeaderBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeaderBuilder)8 MeterBandTypesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.meter.band.header.MeterBandTypesBuilder)8 MeterModInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInputBuilder)8 MeterBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterBuilder)7 MeterKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterKey)7 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)6 Meter (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter)6 MeterCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.MeterCaseBuilder)6 MeterBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.meter._case.MeterBuilder)6