Search in sources :

Example 1 with GetMeterStatisticsOutput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsOutput 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);
}
Also used : MultipartReplyMeter(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.MultipartReplyMeter) MultipartReplyMeterCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterCase) MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply) MeterId(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId) MeterStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.multipart.reply.meter.MeterStats) GetMeterStatisticsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetMeterStatisticsOutput) MeterStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.multipart.reply.meter.MeterStatsBuilder)

Example 2 with GetMeterStatisticsOutput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsOutput in project openflowplugin by opendaylight.

the class OpendaylightMeterStatisticsServiceImplTest method testGetMeterStatistics.

@Test
public void testGetMeterStatistics() throws Exception {
    GetMeterStatisticsInputBuilder input = new GetMeterStatisticsInputBuilder().setNode(createNodeRef("unitProt:123")).setMeterId(new MeterId(21L));
    rpcResult = buildMeterStatisticsReply();
    final Future<RpcResult<GetMeterStatisticsOutput>> resultFuture = meterStatisticsService.getMeterStatistics(input.build());
    Assert.assertTrue(resultFuture.isDone());
    final RpcResult<GetMeterStatisticsOutput> rpcResult = resultFuture.get();
    Assert.assertTrue(rpcResult.isSuccessful());
    Assert.assertEquals(MultipartType.OFPMPMETER, requestInput.getValue().getType());
}
Also used : GetMeterStatisticsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsOutput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) GetMeterStatisticsInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsInputBuilder) MeterId(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId) Test(org.junit.Test)

Example 3 with GetMeterStatisticsOutput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsOutput in project openflowplugin by opendaylight.

the class OpendaylightDirectStatisticsServiceImplTest method testGetMeterStatisticsFail.

@Test
public void testGetMeterStatisticsFail() throws Exception {
    RpcResult<GetMeterStatisticsOutput> result = emptyService.getMeterStatistics(getMeterStatisticsInput).get();
    assertFalse(result.isSuccessful());
    for (RpcError error : result.getErrors()) {
        assertTrue(error.getMessage().contains(AbstractMeterDirectStatisticsService.class.getSimpleName()));
    }
    verify(meterDirectStatisticsService, times(0)).handleAndReply(getMeterStatisticsInput);
}
Also used : GetMeterStatisticsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetMeterStatisticsOutput) RpcError(org.opendaylight.yangtools.yang.common.RpcError) Test(org.junit.Test)

Example 4 with GetMeterStatisticsOutput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsOutput in project openflowplugin by opendaylight.

the class MeterDirectStatisticsService method buildReply.

@Override
protected GetMeterStatisticsOutput buildReply(List<MultipartReply> input, boolean success) {
    final List<MeterStats> meterStats = new ArrayList<>();
    if (success) {
        for (final MultipartReply mpReply : input) {
            final MultipartReplyMeterCase caseBody = (MultipartReplyMeterCase) mpReply.getMultipartReplyBody();
            final MultipartReplyMeter replyBody = caseBody.getMultipartReplyMeter();
            final Optional<List<MeterStats>> meterStatsList = getConvertorExecutor().convert(replyBody.getMeterStats(), data);
            meterStatsList.ifPresent(meterStats::addAll);
        }
    }
    return new GetMeterStatisticsOutputBuilder().setMeterStats(meterStats).build();
}
Also used : MeterStats(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStats) MultipartReplyMeter(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.MultipartReplyMeter) MultipartReplyMeterCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterCase) MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) GetMeterStatisticsOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetMeterStatisticsOutputBuilder)

Example 5 with GetMeterStatisticsOutput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsOutput in project openflowplugin by opendaylight.

the class MeterDirectStatisticsServiceTest method testBuildReply.

@Override
public void testBuildReply() throws Exception {
    final MeterStats meterStat = new MeterStatsBuilder().setMeterId(new MeterId(METER_NO)).setByteInCount(new Counter64(BigInteger.ONE)).setPacketInCount(new Counter64(BigInteger.ONE)).setDuration(new DurationBuilder().setSecond(new Counter32(1L)).setNanosecond(new Counter32(1L)).build()).setFlowCount(new Counter32(0L)).setMeterBandStats(new MeterBandStatsBuilder().build()).build();
    final MultipartReply reply = new MultipartReplyBuilder().setMultipartReplyBody(new MultipartReplyMeterStatsBuilder().setMeterStats(Collections.singletonList(meterStat)).build()).build();
    final List<MultipartReply> input = Collections.singletonList(reply);
    final GetMeterStatisticsOutput output = service.buildReply(input, true);
    assertTrue(output.getMeterStats().size() > 0);
    final MeterStats stats = output.getMeterStats().get(0);
    assertEquals(stats.getMeterId().getValue(), METER_NO);
}
Also used : Counter32(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32) Counter64(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64) MultipartRequestMeterStats(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.request.multipart.request.body.MultipartRequestMeterStats) MeterStats(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStats) MultipartReplyMeterStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyMeterStatsBuilder) GetMeterStatisticsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetMeterStatisticsOutput) MeterBandStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.MeterBandStatsBuilder) MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartReply) MultipartReplyMeterStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyMeterStatsBuilder) MeterStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStatsBuilder) MultipartReplyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartReplyBuilder) MeterId(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId) DurationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.DurationBuilder)

Aggregations

GetMeterStatisticsOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetMeterStatisticsOutput)5 MeterId (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId)5 MeterStats (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStats)3 Test (org.junit.Test)2 MultipartRequestMeterStats (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.request.multipart.request.body.MultipartRequestMeterStats)2 MultipartReply (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply)2 MultipartReplyMeterCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterCase)2 MultipartReplyMeter (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.MultipartReplyMeter)2 MeterStats (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.multipart.reply.meter.MeterStats)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Counter32 (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32)1 Counter64 (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64)1 GetMeterStatisticsOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetMeterStatisticsOutputBuilder)1 GetMeterStatisticsInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsInputBuilder)1 GetMeterStatisticsOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsOutput)1 MultipartReplyMeterStatsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyMeterStatsBuilder)1 DurationBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.DurationBuilder)1 MeterBandStatsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.MeterBandStatsBuilder)1 MeterStatsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStatsBuilder)1