use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput in project openflowplugin by opendaylight.
the class SingleLayerAggregateFlowMultipartServiceTest method handleAndReply.
@Test
public void handleAndReply() throws Exception {
mockSuccessfulFuture(Collections.singletonList(new MultipartReplyBuilder().setMultipartReplyBody(new MultipartReplyFlowAggregateStatsBuilder().setByteCount(new Counter64(BYTE_COUNT)).build()).build()));
final GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput input = new GetAggregateFlowStatisticsFromFlowTableForGivenMatchInputBuilder().setTableId(TABLE_ID).build();
final Future<RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>> rpcResultFuture = service.handleAndReply(input);
final RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput> sendAggregateFlowMpRequestOutputRpcResult = rpcResultFuture.get();
assertEquals(BYTE_COUNT, sendAggregateFlowMpRequestOutputRpcResult.getResult().getAggregatedFlowStatistics().get(0).getByteCount().getValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput in project openflowplugin by opendaylight.
the class SingleLayerAggregateFlowMultipartServiceTest method buildRequest.
@Test
public void buildRequest() throws Exception {
final GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput input = new GetAggregateFlowStatisticsFromFlowTableForGivenMatchInputBuilder().setTableId(TABLE_ID).build();
final OfHeader ofHeader = service.buildRequest(DUMMY_XID, input);
assertEquals(MultipartRequest.class, ofHeader.getImplementedInterface());
final MultipartRequestFlowAggregateStats result = MultipartRequestFlowAggregateStats.class.cast(MultipartRequest.class.cast(ofHeader).getMultipartRequestBody());
assertEquals(TABLE_ID, result.getTableId().shortValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput in project openflowplugin by opendaylight.
the class MultiLayerAggregateFlowMultipartService method buildRequest.
@Override
protected OfHeader buildRequest(final Xid xid, final GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput input) throws ServiceException {
final MultipartRequestAggregateCaseBuilder multipartRequestAggregateCaseBuilder = new MultipartRequestAggregateCaseBuilder();
final MultipartRequestAggregateBuilder mprAggregateRequestBuilder = new MultipartRequestAggregateBuilder();
final short tableId = MoreObjects.firstNonNull(input.getTableId(), OFConstants.OFPTT_ALL);
mprAggregateRequestBuilder.setTableId(tableId);
long outputPortValue = MoreObjects.firstNonNull(input.getOutPort(), OFConstants.OFPP_ANY).longValue();
mprAggregateRequestBuilder.setOutPort(outputPortValue);
final short version = getVersion();
if (version == OFConstants.OFP_VERSION_1_3) {
if (input.getCookie() == null) {
mprAggregateRequestBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
} else {
mprAggregateRequestBuilder.setCookie(MoreObjects.firstNonNull(input.getCookie().getValue(), OFConstants.DEFAULT_COOKIE));
}
if (input.getCookieMask() == null) {
mprAggregateRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
} else {
mprAggregateRequestBuilder.setCookieMask(MoreObjects.firstNonNull(input.getCookieMask().getValue(), OFConstants.DEFAULT_COOKIE_MASK));
}
long outGroup = MoreObjects.firstNonNull(input.getOutGroup(), OFConstants.OFPG_ANY);
mprAggregateRequestBuilder.setOutGroup(outGroup);
} else {
mprAggregateRequestBuilder.setOutGroup(OFConstants.OFPG_ANY);
mprAggregateRequestBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
mprAggregateRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
}
// convert and inject match
final Optional<Object> conversionMatch = convertorExecutor.convert(input.getMatch(), data);
MatchInjector.inject(conversionMatch, mprAggregateRequestBuilder, data.getVersion());
FlowCreatorUtil.setWildcardedFlowMatch(version, mprAggregateRequestBuilder);
// Set request body to main multipart request
multipartRequestAggregateCaseBuilder.setMultipartRequestAggregate(mprAggregateRequestBuilder.build());
final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(MultipartType.OFPMPAGGREGATE, xid.getValue(), version);
mprInput.setMultipartRequestBody(multipartRequestAggregateCaseBuilder.build());
return mprInput.build();
}
Aggregations