import java.util.List;
import java.util.concurrent.Future;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
import org.opendaylight.openflowplugin.api.openflow.device.MessageTranslator;
import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
import org.opendaylight.openflowplugin.api.openflow.device.TranslatorLibrary;
import org.opendaylight.openflowplugin.api.openflow.md.core.TranslatorKey;
+import org.opendaylight.openflowplugin.api.openflow.statistics.compatibility.Delegator;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCase;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* @author joe
*/
-public class OpendaylightFlowStatisticsServiceImpl implements OpendaylightFlowStatisticsService {
- private static final Logger LOG = LoggerFactory.getLogger(OpendaylightFlowStatisticsServiceImpl.class);
+public class OpendaylightFlowStatisticsServiceImpl implements OpendaylightFlowStatisticsService, Delegator<OpendaylightFlowStatisticsService> {
private final Function<RpcResult<List<MultipartReply>>, RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>> matchingConvertor =
new Function<RpcResult<List<MultipartReply>>, RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>>() {
@Override
public RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput> apply(final RpcResult<List<MultipartReply>> input) {
- final DeviceContext deviceContext = matchingFlowsInTable.getDeviceContext();
- TranslatorLibrary translatorLibrary = deviceContext.oook();
- RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput> rpcResult;
+ final DeviceInfo deviceInfo = matchingFlowsInTable.getDeviceInfo();
+ final RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput> rpcResult;
if (input.isSuccessful()) {
MultipartReply reply = input.getResult().get(0);
final TranslatorKey translatorKey = new TranslatorKey(reply.getVersion(), MultipartReplyAggregateCase.class.getName());
List<AggregatedFlowStatistics> aggregStats = new ArrayList<AggregatedFlowStatistics>();
for (MultipartReply multipartReply : input.getResult()) {
- aggregStats.add(messageTranslator.translate(multipartReply, deviceContext, null));
+ aggregStats.add(messageTranslator.translate(multipartReply, deviceInfo, null));
}
GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder getAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder =
}
};
- private final AggregateFlowsInTableService aggregateFlowsInTable;
private final MatchingFlowsInTableService matchingFlowsInTable;
- private final AllFlowsInAllTablesService allFlowsInAllTables;
- private final AllFlowsInTableService allFlowsInTable;
- private final FlowsInTableService flowsInTable;
-
- public OpendaylightFlowStatisticsServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
- aggregateFlowsInTable = new AggregateFlowsInTableService(requestContextStack, deviceContext);
- allFlowsInAllTables = new AllFlowsInAllTablesService(requestContextStack, deviceContext);
- allFlowsInTable = new AllFlowsInTableService(requestContextStack, deviceContext);
- flowsInTable = new FlowsInTableService(requestContextStack, deviceContext);
- matchingFlowsInTable = new MatchingFlowsInTableService(requestContextStack, deviceContext);
+ private final TranslatorLibrary translatorLibrary;
+ private OpendaylightFlowStatisticsService delegate;
+
+ public static OpendaylightFlowStatisticsServiceImpl createWithOook(final RequestContextStack requestContextStack,
+ final DeviceContext deviceContext, final ConvertorExecutor convertorExecutor) {
+ return new OpendaylightFlowStatisticsServiceImpl(requestContextStack, deviceContext, deviceContext.oook(), convertorExecutor);
+ }
+
+ public OpendaylightFlowStatisticsServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext,
+ final TranslatorLibrary translatorLibrary, final ConvertorExecutor convertorExecutor) {
+ matchingFlowsInTable = new MatchingFlowsInTableService(requestContextStack, deviceContext, convertorExecutor);
+ this.translatorLibrary = translatorLibrary;
+ }
+
+ @Override
+ public void setDelegate(OpendaylightFlowStatisticsService delegate) {
+ this.delegate = delegate;
}
+ /**
+ * @deprecated provided for Be-release as backward compatibility relic
+ */
@Override
+ @Deprecated
public Future<RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>> getAggregateFlowStatisticsFromFlowTableForAllFlows(
final GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput input) {
- return aggregateFlowsInTable.handleServiceCall(input);
+ if (delegate != null) {
+ return delegate.getAggregateFlowStatisticsFromFlowTableForAllFlows(input);
+ } else {
+ throw new IllegalAccessError("no delegate available - service is currently out of order");
+ }
}
@Override
return Futures.transform(matchingFlowsInTable.handleServiceCall(input), matchingConvertor);
}
+ /**
+ * @deprecated provided for Be-release as backward compatibility relic
+ */
@Override
+ @Deprecated
public Future<RpcResult<GetAllFlowStatisticsFromFlowTableOutput>> getAllFlowStatisticsFromFlowTable(
final GetAllFlowStatisticsFromFlowTableInput input) {
- return allFlowsInTable.handleServiceCall(input);
+ if (delegate != null) {
+ return delegate.getAllFlowStatisticsFromFlowTable(input);
+ } else {
+ throw new IllegalAccessError("no delegate available - service is currently out of order");
+ }
}
+ /**
+ * @deprecated provided for Be-release as backward compatibility relic
+ */
@Override
+ @Deprecated
public Future<RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput>> getAllFlowsStatisticsFromAllFlowTables(
final GetAllFlowsStatisticsFromAllFlowTablesInput input) {
- return allFlowsInAllTables.handleServiceCall(input);
+ if (delegate != null) {
+ return delegate.getAllFlowsStatisticsFromAllFlowTables(input);
+ } else {
+ throw new IllegalAccessError("no delegate available - service is currently out of order");
+ }
}
+ /**
+ * @deprecated provided for Be-release as backward compatibility relic
+ */
@Override
+ @Deprecated
public Future<RpcResult<GetFlowStatisticsFromFlowTableOutput>> getFlowStatisticsFromFlowTable(
final GetFlowStatisticsFromFlowTableInput input) {
- return flowsInTable.handleServiceCall(input);
+ if (delegate != null) {
+ return delegate.getFlowStatisticsFromFlowTable(input);
+ } else {
+ throw new IllegalAccessError("no delegate available - service is currently out of order");
+ }
}
}