package org.opendaylight.openflowplugin.impl.services.multilayer;
-import com.google.common.base.Function;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.base.MoreObjects;
-import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
-import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import org.opendaylight.openflowplugin.api.OFConstants;
import org.opendaylight.openflowplugin.api.openflow.md.core.TranslatorKey;
import org.opendaylight.openflowplugin.impl.services.AbstractAggregateFlowMultipartService;
import org.opendaylight.openflowplugin.impl.services.util.RequestInputUtils;
-import org.opendaylight.openflowplugin.impl.services.util.ServiceException;
import org.opendaylight.openflowplugin.impl.util.FlowCreatorUtil;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.aggregate._case.MultipartRequestAggregateBuilder;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+import org.opendaylight.yangtools.yang.common.Uint32;
+import org.opendaylight.yangtools.yang.common.Uint8;
public class MultiLayerAggregateFlowMultipartService extends AbstractAggregateFlowMultipartService<MultipartReply> {
super(requestContextStack, deviceContext);
this.convertorExecutor = convertorExecutor;
this.translatorLibrary = translatorLibrary;
- this.data = new VersionConvertorData(getVersion());
+ data = new VersionConvertorData(getVersion());
}
@Override
protected OfHeader buildRequest(final Xid xid,
- final GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput input) throws
- ServiceException {
+ final GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput input) {
final MultipartRequestAggregateCaseBuilder multipartRequestAggregateCaseBuilder
= new MultipartRequestAggregateCaseBuilder();
final MultipartRequestAggregateBuilder mprAggregateRequestBuilder = new MultipartRequestAggregateBuilder();
- final short tableId = MoreObjects.firstNonNull(input.getTableId(), OFConstants.OFPTT_ALL);
+ final Uint8 tableId = MoreObjects.firstNonNull(input.getTableId(), OFConstants.OFPTT_ALL);
mprAggregateRequestBuilder.setTableId(tableId);
long outputPortValue = MoreObjects.firstNonNull(input.getOutPort(), OFConstants.OFPP_ANY).longValue();
- mprAggregateRequestBuilder.setOutPort(outputPortValue);
+ mprAggregateRequestBuilder.setOutPort(Uint32.valueOf(outputPortValue));
- final short version = getVersion();
- if (version == OFConstants.OFP_VERSION_1_3) {
+ final Uint8 version = getVersion();
+ if (OFConstants.OFP_VERSION_1_3.equals(version)) {
if (input.getCookie() == null) {
mprAggregateRequestBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
mprAggregateRequestBuilder.setCookieMask(
MoreObjects.firstNonNull(input.getCookieMask().getValue(), OFConstants.DEFAULT_COOKIE_MASK));
}
- long outGroup = MoreObjects.firstNonNull(input.getOutGroup(), OFConstants.OFPG_ANY);
+ Uint32 outGroup = MoreObjects.firstNonNull(input.getOutGroup(), OFConstants.OFPG_ANY);
mprAggregateRequestBuilder.setOutGroup(outGroup);
} else {
mprAggregateRequestBuilder.setOutGroup(OFConstants.OFPG_ANY);
public ListenableFuture<RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>> handleAndReply(
final GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput input) {
return Futures.transform(handleServiceCall(input),
- (Function<RpcResult<List<MultipartReply>>,
- RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>>)
result -> {
- if (Preconditions.checkNotNull(result).isSuccessful()) {
+ if (requireNonNull(result).isSuccessful()) {
final MessageTranslator<MultipartReply, AggregatedFlowStatistics>
messageTranslator = translatorLibrary.lookupTranslator(
- new TranslatorKey(getVersion(),
+ new TranslatorKey(getVersion(),
MultipartReplyAggregateCase.class.getName()));
return RpcResultBuilder.success(
multipartReply,
getDeviceInfo(),
null))
- .collect(Collectors
- .toList())))
+ .collect(Collectors.toList()))
+ .build())
.build();
}