Search in sources :

Example 1 with AggregatedFlowStatisticsBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.get.aggregate.flow.statistics.from.flow.table._for.given.match.output.AggregatedFlowStatisticsBuilder in project openflowplugin by opendaylight.

the class OpendaylightFlowStatisticsServiceImpl2Test method testGetAggregateFlowStatisticsFromFlowTableForGivenMatch.

@Test
public void testGetAggregateFlowStatisticsFromFlowTableForGivenMatch() throws Exception {
    Mockito.doAnswer(answerVoidToCallback).when(outboundQueueProvider).commitEntry(Matchers.eq(42L), requestInput.capture(), Matchers.any(FutureCallback.class));
    Mockito.doAnswer((Answer<Void>) invocation -> {
        final MultipartReplyMessageBuilder messageBuilder = new MultipartReplyMessageBuilder().setVersion(OFConstants.OFP_VERSION_1_3);
        rqContextMp.setResult(RpcResultBuilder.success(Collections.<MultipartReply>singletonList(messageBuilder.build())).build());
        return null;
    }).when(multiMsgCollector).endCollecting(Matchers.any(EventIdentifier.class));
    Mockito.when(translator.translate(Matchers.any(MultipartReply.class), Matchers.same(deviceInfo), Matchers.isNull())).thenReturn(new AggregatedFlowStatisticsBuilder().build());
    GetAggregateFlowStatisticsFromFlowTableForGivenMatchInputBuilder input = new GetAggregateFlowStatisticsFromFlowTableForGivenMatchInputBuilder().setNode(createNodeRef("unitProt:123")).setPriority(5).setTableId((short) 1);
    final Future<RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>> resultFuture = flowStatisticsService.getAggregateFlowStatisticsFromFlowTableForGivenMatch(input.build());
    Assert.assertTrue(resultFuture.isDone());
    final RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput> rpcResult = resultFuture.get();
    Assert.assertTrue(rpcResult.isSuccessful());
    Assert.assertEquals(1, rpcResult.getResult().getAggregatedFlowStatistics().size());
    Assert.assertEquals(MultipartType.OFPMPAGGREGATE, requestInput.getValue().getType());
}
Also used : GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) Matchers(org.mockito.Matchers) Mock(org.mockito.Mock) Captor(org.mockito.Captor) Answer(org.mockito.stubbing.Answer) Future(java.util.concurrent.Future) ArgumentCaptor(org.mockito.ArgumentCaptor) MessageTranslator(org.opendaylight.openflowplugin.api.openflow.device.MessageTranslator) ConvertorManagerFactory(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory) MultipartRequestInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput) AbstractRequestContext(org.opendaylight.openflowplugin.impl.rpc.AbstractRequestContext) Test(org.junit.Test) MultipartReplyMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder) FutureCallback(com.google.common.util.concurrent.FutureCallback) OFConstants(org.opendaylight.openflowplugin.api.OFConstants) Mockito(org.mockito.Mockito) List(java.util.List) ConvertorManager(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager) GetAggregateFlowStatisticsFromFlowTableForGivenMatchInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchInputBuilder) EventIdentifier(org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.EventIdentifier) MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply) RpcResultBuilder(org.opendaylight.yangtools.yang.common.RpcResultBuilder) MultipartType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType) TranslatorKey(org.opendaylight.openflowplugin.api.openflow.md.core.TranslatorKey) Assert(org.junit.Assert) Collections(java.util.Collections) AggregatedFlowStatistics(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.get.aggregate.flow.statistics.from.flow.table._for.given.match.output.AggregatedFlowStatistics) AggregatedFlowStatisticsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.get.aggregate.flow.statistics.from.flow.table._for.given.match.output.AggregatedFlowStatisticsBuilder) GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput) EventIdentifier(org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.EventIdentifier) MultipartReplyMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder) MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply) GetAggregateFlowStatisticsFromFlowTableForGivenMatchInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchInputBuilder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) AggregatedFlowStatisticsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.get.aggregate.flow.statistics.from.flow.table._for.given.match.output.AggregatedFlowStatisticsBuilder) FutureCallback(com.google.common.util.concurrent.FutureCallback) Test(org.junit.Test)

Example 2 with AggregatedFlowStatisticsBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.get.aggregate.flow.statistics.from.flow.table._for.given.match.output.AggregatedFlowStatisticsBuilder in project openflowplugin by opendaylight.

the class OpendaylightFlowStatisticsServiceDelegateImplTest method testGetAggregateFlowStatisticsFromFlowTableForAllFlows.

@Test
public void testGetAggregateFlowStatisticsFromFlowTableForAllFlows() throws Exception {
    GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder input = new GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder().setNode(createNodeRef("unitProt:123")).setTableId(new TableId((short) 1));
    Mockito.when(translator.translate(Matchers.any(MultipartReply.class), Matchers.eq(deviceInfo), Matchers.any())).thenReturn(new AggregatedFlowStatisticsBuilder().setByteCount(new Counter64(BigInteger.valueOf(50L))).setPacketCount(new Counter64(BigInteger.valueOf(51L))).setFlowCount(new Counter32(52L)).build());
    rpcResult = RpcResultBuilder.<Object>success(Collections.singletonList(new MultipartReplyMessageBuilder().setType(MultipartType.OFPMPAGGREGATE).setVersion(OFConstants.OFP_VERSION_1_3).setFlags(new MultipartRequestFlags(false)).setMultipartReplyBody(new MultipartReplyAggregateCaseBuilder().setMultipartReplyAggregate(new MultipartReplyAggregateBuilder().setByteCount(BigInteger.valueOf(50L)).setPacketCount(BigInteger.valueOf(51L)).setFlowCount(52L).build()).build()).build())).build();
    final Future<RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>> resultFuture = flowStatisticsServiceDelegate.getAggregateFlowStatisticsFromFlowTableForAllFlows(input.build());
    Assert.assertTrue(resultFuture.isDone());
    final RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput> rpcResultCompatible = resultFuture.get();
    Assert.assertTrue(rpcResultCompatible.isSuccessful());
    Assert.assertEquals(MultipartType.OFPMPAGGREGATE, requestInput.getValue().getType());
    Mockito.verify(notificationPublishService, Mockito.timeout(NOTIFICATION_WAIT_TIMEOUT_MS)).offerNotification(Matchers.any(Notification.class));
}
Also used : TableId(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId) MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) MultipartRequestFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags) AggregatedFlowStatisticsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.get.aggregate.flow.statistics.from.flow.table._for.given.match.output.AggregatedFlowStatisticsBuilder) Notification(org.opendaylight.yangtools.yang.binding.Notification) Counter32(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32) MultipartReplyAggregateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.aggregate._case.MultipartReplyAggregateBuilder) Counter64(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64) GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder) MultipartReplyMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder) GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput) MultipartReplyAggregateCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCaseBuilder) AbstractSingleStatsServiceTest(org.opendaylight.openflowplugin.impl.statistics.services.AbstractSingleStatsServiceTest) Test(org.junit.Test)

Example 3 with AggregatedFlowStatisticsBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.get.aggregate.flow.statistics.from.flow.table._for.given.match.output.AggregatedFlowStatisticsBuilder in project openflowplugin by opendaylight.

the class AggregatedFlowStatisticsTranslator method translate.

@Override
public AggregatedFlowStatistics translate(final MultipartReply input, final DeviceInfo deviceInfo, final Object connectionDistinguisher) {
    AggregatedFlowStatisticsBuilder aggregatedFlowStatisticsBuilder = new AggregatedFlowStatisticsBuilder();
    MultipartReplyAggregateCase caseBody = (MultipartReplyAggregateCase) input.getMultipartReplyBody();
    MultipartReplyAggregate replyBody = caseBody.getMultipartReplyAggregate();
    aggregatedFlowStatisticsBuilder.setByteCount(new Counter64(replyBody.getByteCount()));
    aggregatedFlowStatisticsBuilder.setFlowCount(new Counter32(replyBody.getFlowCount()));
    aggregatedFlowStatisticsBuilder.setPacketCount(new Counter64(replyBody.getPacketCount()));
    return aggregatedFlowStatisticsBuilder.build();
}
Also used : Counter32(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32) MultipartReplyAggregateCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCase) Counter64(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64) MultipartReplyAggregate(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.aggregate._case.MultipartReplyAggregate) AggregatedFlowStatisticsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.get.aggregate.flow.statistics.from.flow.table._for.given.match.output.AggregatedFlowStatisticsBuilder)

Example 4 with AggregatedFlowStatisticsBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.get.aggregate.flow.statistics.from.flow.table._for.given.match.output.AggregatedFlowStatisticsBuilder in project openflowplugin by opendaylight.

the class AbstractCompatibleStatServiceTest method testHandleAndNotify.

@Test
public void testHandleAndNotify() throws Exception {
    GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput input = new GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder().setNode(createNodeRef("unitProt:123")).setTableId(new TableId((short) 1)).build();
    rpcResult = RpcResultBuilder.<Object>success(Collections.singletonList(new MultipartReplyMessageBuilder().setVersion(OFConstants.OFP_VERSION_1_3).setMultipartReplyBody(new MultipartReplyAggregateCaseBuilder().setMultipartReplyAggregate(new MultipartReplyAggregateBuilder().setByteCount(BigInteger.valueOf(11L)).setFlowCount(12L).setPacketCount(BigInteger.valueOf(13L)).build()).build()).build())).build();
    AggregatedFlowStatistics aggregatedStats = new AggregatedFlowStatisticsBuilder().setByteCount(new Counter64(BigInteger.valueOf(11L))).setFlowCount(new Counter32(12L)).setPacketCount(new Counter64(BigInteger.valueOf(13L))).build();
    Mockito.when(translator.translate(Matchers.any(MultipartReply.class), Matchers.eq(deviceInfo), Matchers.any())).thenReturn(aggregatedStats);
    ListenableFuture<RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>> resultFuture = service.handleAndNotify(input, notificationPublishService);
    Assert.assertTrue(resultFuture.isDone());
    final RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput> result = resultFuture.get();
    Assert.assertTrue(result.isSuccessful());
    Assert.assertEquals(MultipartType.OFPMPAGGREGATE, requestInput.getValue().getType());
    Mockito.verify(notificationPublishService, Mockito.timeout(500)).offerNotification(Matchers.any(AggregateFlowStatisticsUpdate.class));
}
Also used : TableId(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId) MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput) AggregatedFlowStatistics(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.get.aggregate.flow.statistics.from.flow.table._for.given.match.output.AggregatedFlowStatistics) AggregatedFlowStatisticsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.get.aggregate.flow.statistics.from.flow.table._for.given.match.output.AggregatedFlowStatisticsBuilder) MultipartReplyAggregateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.aggregate._case.MultipartReplyAggregateBuilder) 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) GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder) MultipartReplyMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder) AggregateFlowStatisticsUpdate(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.AggregateFlowStatisticsUpdate) GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput) MultipartReplyAggregateCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCaseBuilder) Test(org.junit.Test) AbstractStatsServiceTest(org.opendaylight.openflowplugin.impl.statistics.services.AbstractStatsServiceTest)

Aggregations

AggregatedFlowStatisticsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.get.aggregate.flow.statistics.from.flow.table._for.given.match.output.AggregatedFlowStatisticsBuilder)4 Test (org.junit.Test)3 Counter32 (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32)3 Counter64 (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64)3 MultipartReply (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply)3 MultipartReplyMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder)3 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)3 GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder)2 GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput)2 AggregatedFlowStatistics (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.get.aggregate.flow.statistics.from.flow.table._for.given.match.output.AggregatedFlowStatistics)2 MultipartReplyAggregateCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCaseBuilder)2 MultipartReplyAggregateBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.aggregate._case.MultipartReplyAggregateBuilder)2 TableId (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId)2 FutureCallback (com.google.common.util.concurrent.FutureCallback)1 Collections (java.util.Collections)1 List (java.util.List)1 Future (java.util.concurrent.Future)1 Assert (org.junit.Assert)1 ArgumentCaptor (org.mockito.ArgumentCaptor)1 Captor (org.mockito.Captor)1