Search in sources :

Example 1 with GetFlowStatisticsInput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetFlowStatisticsInput in project openflowplugin by opendaylight.

the class OpendaylightDirectStatisticsServiceImplTest method testGetFlowStatisticsFail.

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

Example 2 with GetFlowStatisticsInput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetFlowStatisticsInput in project netvirt by opendaylight.

the class TestOdlDirectStatisticsService method getFlowStatistics.

@Override
public Future<RpcResult<GetFlowStatisticsOutput>> getFlowStatistics(GetFlowStatisticsInput input) {
    LOG.info("getFlowStatistics rpc input = {}", input);
    List<FlowAndStatisticsMapList> flowStatsList = new ArrayList<>();
    FlowAndStatisticsMapList portIngressFlowStats1 = buildFlowStats(NwConstants.EGRESS_ACL_FILTER_CUM_DISPATCHER_TABLE, AclConstants.ACL_PORT_SPECIFIC_DROP_PRIORITY, 1, 5, 5);
    FlowAndStatisticsMapList portIngressFlowStats2 = buildFlowStats(NwConstants.EGRESS_ACL_FILTER_CUM_DISPATCHER_TABLE, AclConstants.CT_STATE_TRACKED_INVALID_PRIORITY, 1, 10, 10);
    FlowAndStatisticsMapList portEgressFlowStats1 = buildFlowStats(NwConstants.INGRESS_ACL_FILTER_CUM_DISPATCHER_TABLE, AclConstants.ACL_PORT_SPECIFIC_DROP_PRIORITY, 1, 15, 15);
    FlowAndStatisticsMapList portEgressFlowStats2 = buildFlowStats(NwConstants.INGRESS_ACL_FILTER_CUM_DISPATCHER_TABLE, AclConstants.CT_STATE_TRACKED_INVALID_PRIORITY, 1, 20, 20);
    if (input.getTableId() == null || input.getTableId() == NwConstants.EGRESS_ACL_FILTER_CUM_DISPATCHER_TABLE) {
        flowStatsList.add(portIngressFlowStats1);
        flowStatsList.add(portIngressFlowStats2);
    }
    if (input.getTableId() == null || input.getTableId() == NwConstants.INGRESS_ACL_FILTER_CUM_DISPATCHER_TABLE) {
        flowStatsList.add(portEgressFlowStats1);
        flowStatsList.add(portEgressFlowStats2);
    }
    GetFlowStatisticsOutput output = new GetFlowStatisticsOutputBuilder().setFlowAndStatisticsMapList(flowStatsList).build();
    RpcResultBuilder<GetFlowStatisticsOutput> rpcResultBuilder = RpcResultBuilder.success();
    rpcResultBuilder.withResult(output);
    return Futures.immediateFuture(rpcResultBuilder.build());
}
Also used : ArrayList(java.util.ArrayList) FlowAndStatisticsMapList(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList) GetFlowStatisticsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetFlowStatisticsOutput) GetFlowStatisticsOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetFlowStatisticsOutputBuilder)

Example 3 with GetFlowStatisticsInput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetFlowStatisticsInput in project openflowplugin by opendaylight.

the class FlowDirectStatisticsServiceTest method testBuildRequestBody.

@Override
public void testBuildRequestBody() throws Exception {
    final GetFlowStatisticsInput input = mock(GetFlowStatisticsInput.class);
    when(input.getNode()).thenReturn(createNodeRef(NODE_ID));
    when(input.getTableId()).thenReturn(TABLE_NO);
    final MultipartRequestFlowStats body = (MultipartRequestFlowStats) ((MultipartRequest) service.buildRequest(new Xid(42L), input)).getMultipartRequestBody();
    assertEquals(TABLE_NO, body.getTableId());
}
Also used : Xid(org.opendaylight.openflowplugin.api.openflow.device.Xid) MultipartRequestFlowStats(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.multipart.request.multipart.request.body.MultipartRequestFlowStats) GetFlowStatisticsInput(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetFlowStatisticsInput)

Example 4 with GetFlowStatisticsInput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetFlowStatisticsInput in project openflowplugin by opendaylight.

the class FlowDirectStatisticsServiceTest method testBuildRequestBody.

@Override
public void testBuildRequestBody() throws Exception {
    final GetFlowStatisticsInput input = mock(GetFlowStatisticsInput.class);
    when(input.getNode()).thenReturn(createNodeRef(NODE_ID));
    when(input.getTableId()).thenReturn(TABLE_NO);
    final MultipartRequestFlowCase body = (MultipartRequestFlowCase) ((MultipartRequestInput) service.buildRequest(new Xid(42L), input)).getMultipartRequestBody();
    final MultipartRequestFlow flow = body.getMultipartRequestFlow();
    assertEquals(TABLE_NO, flow.getTableId());
}
Also used : MultipartRequestFlowCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlowCase) Xid(org.opendaylight.openflowplugin.api.openflow.device.Xid) MultipartRequestFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.flow._case.MultipartRequestFlow) GetFlowStatisticsInput(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetFlowStatisticsInput)

Example 5 with GetFlowStatisticsInput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetFlowStatisticsInput in project openflowplugin by opendaylight.

the class FlowDirectStatisticsService method buildRequest.

@Override
protected OfHeader buildRequest(final Xid xid, final GetFlowStatisticsInput input) {
    final MultipartRequestFlowBuilder mprFlowRequestBuilder = new MultipartRequestFlowBuilder();
    if (input.getTableId() != null) {
        mprFlowRequestBuilder.setTableId(input.getTableId());
    } else {
        mprFlowRequestBuilder.setTableId(OFConstants.OFPTT_ALL);
    }
    if (input.getOutPort() != null) {
        mprFlowRequestBuilder.setOutPort(input.getOutPort().longValue());
    } else {
        mprFlowRequestBuilder.setOutPort(OFConstants.OFPP_ANY);
    }
    if (input.getOutGroup() != null) {
        mprFlowRequestBuilder.setOutGroup(input.getOutGroup());
    } else {
        mprFlowRequestBuilder.setOutGroup(OFConstants.OFPG_ANY);
    }
    if (input.getCookie() != null) {
        mprFlowRequestBuilder.setCookie(input.getCookie().getValue());
    } else {
        mprFlowRequestBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
    }
    if (input.getCookieMask() != null) {
        mprFlowRequestBuilder.setCookieMask(input.getCookieMask().getValue());
    } else {
        mprFlowRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
    }
    // convert and inject match
    final Optional<Object> conversionMatch = getConvertorExecutor().convert(input.getMatch(), data);
    MatchInjector.inject(conversionMatch, mprFlowRequestBuilder, data.getVersion());
    return RequestInputUtils.createMultipartHeader(getMultipartType(), xid.getValue(), getVersion()).setMultipartRequestBody(new MultipartRequestFlowCaseBuilder().setMultipartRequestFlow(mprFlowRequestBuilder.build()).build()).build();
}
Also used : MultipartRequestFlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.flow._case.MultipartRequestFlowBuilder) MultipartRequestFlowCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlowCaseBuilder)

Aggregations

Xid (org.opendaylight.openflowplugin.api.openflow.device.Xid)2 GetFlowStatisticsInput (org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetFlowStatisticsInput)2 GetFlowStatisticsOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetFlowStatisticsOutput)2 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 GetFlowStatisticsOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetFlowStatisticsOutputBuilder)1 FlowAndStatisticsMapList (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList)1 MultipartRequestFlowStats (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.multipart.request.multipart.request.body.MultipartRequestFlowStats)1 MultipartRequestFlowCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlowCase)1 MultipartRequestFlowCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlowCaseBuilder)1 MultipartRequestFlow (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.flow._case.MultipartRequestFlow)1 MultipartRequestFlowBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.flow._case.MultipartRequestFlowBuilder)1 RpcError (org.opendaylight.yangtools.yang.common.RpcError)1