/** * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ package org.opendaylight.openflowplugin.impl.statistics.services; import com.google.common.util.concurrent.ListenableFuture; import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext; import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack; import org.opendaylight.openflowplugin.api.openflow.device.TranslatorLibrary; import org.opendaylight.openflowplugin.api.openflow.statistics.compatibility.Delegator; import org.opendaylight.openflowplugin.impl.services.multilayer.MultiLayerAggregateFlowMultipartService; import org.opendaylight.openflowplugin.impl.services.singlelayer.SingleLayerAggregateFlowMultipartService; 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.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.OpendaylightFlowStatisticsService; import org.opendaylight.yangtools.yang.common.RpcResult; public class OpendaylightFlowStatisticsServiceImpl implements OpendaylightFlowStatisticsService, Delegator { private final SingleLayerAggregateFlowMultipartService singleLayerService; private final MultiLayerAggregateFlowMultipartService multiLayerService; 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) { singleLayerService = new SingleLayerAggregateFlowMultipartService(requestContextStack, deviceContext); multiLayerService = new MultiLayerAggregateFlowMultipartService(requestContextStack, deviceContext, convertorExecutor, translatorLibrary); } @Override public void setDelegate(OpendaylightFlowStatisticsService delegate) { this.delegate = delegate; } /** * Get aggregate statistics. * * @deprecated provided for Be-release as backward compatibility relic. */ @Override @Deprecated public ListenableFuture> getAggregateFlowStatisticsFromFlowTableForAllFlows( final GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput input) { if (delegate != null) { return delegate.getAggregateFlowStatisticsFromFlowTableForAllFlows(input); } else { throw new IllegalAccessError("no delegate available - service is currently out of order"); } } @Override public ListenableFuture> getAggregateFlowStatisticsFromFlowTableForGivenMatch( final GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput input) { return singleLayerService.canUseSingleLayerSerialization() ? singleLayerService.handleAndReply(input) : multiLayerService.handleAndReply(input); } /** * Get flow statistics. * * @deprecated provided for Be-release as backward compatibility relic. */ @Override @Deprecated public ListenableFuture> getAllFlowStatisticsFromFlowTable( final GetAllFlowStatisticsFromFlowTableInput input) { if (delegate != null) { return delegate.getAllFlowStatisticsFromFlowTable(input); } else { throw new IllegalAccessError("no delegate available - service is currently out of order"); } } /** * Get flow statistics. * * @deprecated provided for Be-release as backward compatibility relic. */ @Override @Deprecated public ListenableFuture> getAllFlowsStatisticsFromAllFlowTables(final GetAllFlowsStatisticsFromAllFlowTablesInput input) { if (delegate != null) { return delegate.getAllFlowsStatisticsFromAllFlowTables(input); } else { throw new IllegalAccessError("no delegate available - service is currently out of order"); } } /** * Get flow statistics. * * @deprecated provided for Be-release as backward compatibility relic. */ @Override @Deprecated public ListenableFuture> getFlowStatisticsFromFlowTable( final GetFlowStatisticsFromFlowTableInput input) { if (delegate != null) { return delegate.getFlowStatisticsFromFlowTable(input); } else { throw new IllegalAccessError("no delegate available - service is currently out of order"); } } }