package org.opendaylight.openflowplugin.api.openflow.device;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-
/**
* Request context handles all requests on device. Number of requests is limited by request quota. When this quota is
* exceeded all rpc's will end up with exception.
- * <p>
+ * <p/>
* Created by Martin Bobak <mbobak@cisco.com> on 25.2.2015.
*/
public interface RequestContext<T> extends RequestFutureContext<T>, AutoCloseable {
/**
* Returns xid generated for this request.
+ *
* @return
*/
Xid getXid();
/**
* Sets xid generated for this request.
+ *
* @return
*/
void setXid(Xid xid);
/**
* Returns request timeout value.
+ *
* @return
*/
long getWaitTimeout();
/**
* Sets request timeout value.
+ *
* @return
*/
void setWaitTimeout(long waitTimeout);
package org.opendaylight.openflowplugin.impl.statistics;
+import com.google.common.util.concurrent.FutureCallback;
+import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.SettableFuture;
import java.util.ArrayList;
import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.OpendaylightQueueStatisticsService;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
+import org.opendaylight.openflowplugin.impl.statistics.services.dedicated.FlowStatisticsService;
+import org.opendaylight.openflowplugin.impl.statistics.services.dedicated.FlowTableStatisticsService;
+import org.opendaylight.openflowplugin.impl.statistics.services.dedicated.GroupStatisticsService;
+import org.opendaylight.openflowplugin.impl.statistics.services.dedicated.MeterStatisticsService;
+import org.opendaylight.openflowplugin.impl.statistics.services.dedicated.PortStatisticsService;
+import org.opendaylight.openflowplugin.impl.statistics.services.dedicated.QueueStatisticsService;
import org.opendaylight.yangtools.yang.common.RpcResult;
+import java.util.Arrays;
/**
* Created by Martin Bobak <mbobak@cisco.com> on 1.4.2015.
private final List<RequestContext> requestContexts = new ArrayList();
private final DeviceContext deviceContext;
- private final RequestContext requestContext;
- private final OpendaylightFlowStatisticsService flowStatisticsService;
- private final OpendaylightFlowTableStatisticsService flowTableStatisticsService;
- private final OpendaylightGroupStatisticsService groupStatisticsService;
- private final OpendaylightMeterStatisticsService meterStatisticsService;
- private final OpendaylightPortStatisticsService portStatisticsService;
- private final OpendaylightQueueStatisticsService queueStatisticsService;
+ private final FlowStatisticsService flowStatisticsService;
+ private final FlowTableStatisticsService flowTableStatisticsService;
+ private final GroupStatisticsService groupStatisticsService;
+ private final MeterStatisticsService meterStatisticsService;
+ private final PortStatisticsService portStatisticsService;
+ private final QueueStatisticsService queueStatisticsService;
- /**
- * FIXME : Why we need RequestContext
- * @param deviceContext
- * @param requestContext
- */
- public StatisticsContextImpl(final DeviceContext deviceContext, final RequestContext requestContext) {
+ public StatisticsContextImpl(DeviceContext deviceContext) {
this.deviceContext = deviceContext;
- this.requestContext = requestContext;
- flowStatisticsService = new OpendaylightFlowStatisticsServiceImpl(this, deviceContext);
- flowTableStatisticsService = new OpendaylightFlowTableStatisticsServiceImpl(this, deviceContext);
- groupStatisticsService = new OpendaylightGroupStatisticsServiceImpl(this, deviceContext);
- meterStatisticsService = new OpendaylightMeterStatisticsServiceImpl(this, deviceContext);
- portStatisticsService = new OpendaylightPortStatisticsServiceImpl(this, deviceContext);
- queueStatisticsService = new OpendaylightQueueStatisticsServiceImpl(this, deviceContext);
+ flowStatisticsService = new FlowStatisticsService(this, deviceContext);
+ flowTableStatisticsService = new FlowTableStatisticsService(this, deviceContext);
+ groupStatisticsService = new GroupStatisticsService(this, deviceContext);
+ meterStatisticsService = new MeterStatisticsService(this, deviceContext);
+ portStatisticsService = new PortStatisticsService(this, deviceContext);
+ queueStatisticsService = new QueueStatisticsService(this, deviceContext);
}
final GetAllFlowsStatisticsFromAllFlowTablesInputBuilder builder =
new GetAllFlowsStatisticsFromAllFlowTablesInputBuilder();
builder.setNode(nodeRef);
- final Future<RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput>> flowStatisticsResult = flowStatisticsService.getAllFlowsStatisticsFromAllFlowTables(builder.build());
//TODO : process data from result
}
@Override
public ListenableFuture<Void> gatherDynamicData() {
- final ListenableFuture<Boolean> flowStatistics = StatisticsGatheringUtils.gatherFlowStatistics(flowStatisticsService, deviceContext);
- final ListenableFuture<Boolean> tableStatistics = StatisticsGatheringUtils.gatherTableStatistics(flowTableStatisticsService, deviceContext);
- final ListenableFuture<Boolean> groupStatistics = StatisticsGatheringUtils.gatherGroupStatistics(groupStatisticsService, deviceContext);
- final ListenableFuture<Boolean> meterStatistics = StatisticsGatheringUtils.gatherMeterStatistics(meterStatisticsService, deviceContext);
- final ListenableFuture<Boolean> portStatistics = StatisticsGatheringUtils.gatherPortStatistics(portStatisticsService, deviceContext);
- final ListenableFuture<Boolean> queueStatistics = StatisticsGatheringUtils.gatherQueueStatistics(queueStatisticsService, deviceContext);
- return null;
+ ListenableFuture<Boolean> flowStatistics = StatisticsGatheringUtils.gatherFlowStatistics(flowStatisticsService, deviceContext);
+ ListenableFuture<Boolean> tableStatistics = StatisticsGatheringUtils.gatherTableStatistics(flowTableStatisticsService, deviceContext);
+ ListenableFuture<Boolean> groupStatistics = StatisticsGatheringUtils.gatherGroupStatistics(groupStatisticsService, deviceContext);
+ ListenableFuture<Boolean> meterStatistics = StatisticsGatheringUtils.gatherMeterStatistics(meterStatisticsService, deviceContext);
+ ListenableFuture<Boolean> portStatistics = StatisticsGatheringUtils.gatherPortStatistics(portStatisticsService, deviceContext);
+ ListenableFuture<Boolean> queueStatistics = StatisticsGatheringUtils.gatherQueueStatistics(queueStatisticsService, deviceContext);
+
+ ListenableFuture<List<Boolean>> allFutures = Futures.allAsList(Arrays.asList(flowStatistics, tableStatistics, groupStatistics, meterStatistics, portStatistics, queueStatistics));
+ final SettableFuture<Void> resultingFuture = SettableFuture.create();
+ Futures.addCallback(allFutures, new FutureCallback<List<Boolean>>() {
+ @Override
+ public void onSuccess(final List<Boolean> booleans) {
+ resultingFuture.set(null);
+ }
+
+ @Override
+ public void onFailure(final Throwable throwable) {
+ resultingFuture.setException(throwable);
+ }
+ });
+ return resultingFuture;
}
@Override
import com.google.common.util.concurrent.JdkFutureAdapters;
import com.google.common.util.concurrent.ListenableFuture;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.OpendaylightFlowStatisticsService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.OpendaylightFlowTableStatisticsService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.OpendaylightGroupStatisticsService;
+import org.opendaylight.openflowplugin.impl.statistics.services.dedicated.FlowStatisticsService;
+import org.opendaylight.openflowplugin.impl.statistics.services.dedicated.FlowTableStatisticsService;
+import org.opendaylight.openflowplugin.impl.statistics.services.dedicated.GroupStatisticsService;
+import org.opendaylight.openflowplugin.impl.statistics.services.dedicated.MeterStatisticsService;
+import org.opendaylight.openflowplugin.impl.statistics.services.dedicated.PortStatisticsService;
+import org.opendaylight.openflowplugin.impl.statistics.services.dedicated.QueueStatisticsService;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.FlowStatsResponseConvertor;
+import org.opendaylight.openflowplugin.openflow.md.core.translator.MultipartReplyTranslator;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterStatisticsInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterStatisticsOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.OpendaylightMeterStatisticsService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllNodeConnectorsStatisticsInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllNodeConnectorsStatisticsOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.OpendaylightPortStatisticsService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromAllPortsInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromAllPortsOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.OpendaylightQueueStatisticsService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
import org.opendaylight.yangtools.yang.common.RpcResult;
*/
public final class StatisticsGatheringUtils {
+ private static final FlowStatsResponseConvertor FLOW_STATS_RESPONSE_CONVERTOR = new FlowStatsResponseConvertor();
+ private static final MultipartReplyTranslator MULTIPART_REPLY_TRANSLATOR = new MultipartReplyTranslator();
+
+
private StatisticsGatheringUtils() {
throw new IllegalStateException("This class should not be instantiated.");
}
private static NodeRef createNodeRef(DeviceContext deviceContext) {
- final KeyedInstanceIdentifier<Node, NodeKey> nodeInstanceIdentifier = InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(deviceContext.getPrimaryConnectionContext().getNodeId()));
+ final KeyedInstanceIdentifier<Node, NodeKey> nodeInstanceIdentifier = getInstanceIdentifier(deviceContext);
return new NodeRef(nodeInstanceIdentifier);
}
- public static ListenableFuture<Boolean> gatherQueueStatistics(OpendaylightQueueStatisticsService queueStatisticsService, DeviceContext deviceContext) {
-
- final GetAllQueuesStatisticsFromAllPortsInputBuilder builder =
- new GetAllQueuesStatisticsFromAllPortsInputBuilder();
+ private static KeyedInstanceIdentifier<Node, NodeKey> getInstanceIdentifier(final DeviceContext deviceContext) {
+ return InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(deviceContext.getPrimaryConnectionContext().getNodeId()));
+ }
- builder.setNode(createNodeRef(deviceContext));
+ public static ListenableFuture<Boolean> gatherQueueStatistics(QueueStatisticsService queueStatisticsService, final DeviceContext deviceContext) {
- ListenableFuture<RpcResult<GetAllQueuesStatisticsFromAllPortsOutput>> statisticsDataInFuture =
- JdkFutureAdapters.
- listenInPoolThread(queueStatisticsService.
- getAllQueuesStatisticsFromAllPorts(builder.build()));
+ ListenableFuture<RpcResult<List<MultipartReply>>> statisticsDataInFuture =
+ JdkFutureAdapters.listenInPoolThread(queueStatisticsService.getAllQueuesStatisticsFromAllPorts());
- return Futures.transform(statisticsDataInFuture, new Function<RpcResult<GetAllQueuesStatisticsFromAllPortsOutput>, Boolean>() {
- @Nullable
- @Override
- public Boolean apply(final RpcResult<GetAllQueuesStatisticsFromAllPortsOutput> rpcResult) {
- if (rpcResult.isSuccessful()) {
- //TODO : implement data read and put them into transaction chain
- return Boolean.TRUE;
- }
- return Boolean.FALSE;
- }
- });
+ return transformAndStoreStatisticsData(statisticsDataInFuture, deviceContext);
}
- public static ListenableFuture<Boolean> gatherPortStatistics(OpendaylightPortStatisticsService portStatisticsService, DeviceContext deviceContext) {
-
- final GetAllNodeConnectorsStatisticsInputBuilder builder =
- new GetAllNodeConnectorsStatisticsInputBuilder();
+ public static ListenableFuture<Boolean> gatherPortStatistics(PortStatisticsService portStatisticsService, final DeviceContext deviceContext) {
- builder.setNode(createNodeRef(deviceContext));
+ ListenableFuture<RpcResult<List<MultipartReply>>> statisticsDataInFuture =
+ JdkFutureAdapters.listenInPoolThread(portStatisticsService.getAllNodeConnectorsStatistics());
- ListenableFuture<RpcResult<GetAllNodeConnectorsStatisticsOutput>> statisticsDataInFuture =
- JdkFutureAdapters.
- listenInPoolThread(portStatisticsService.
- getAllNodeConnectorsStatistics(builder.build()));
-
- return Futures.transform(statisticsDataInFuture, new Function<RpcResult<GetAllNodeConnectorsStatisticsOutput>, Boolean>() {
- @Nullable
- @Override
- public Boolean apply(final RpcResult<GetAllNodeConnectorsStatisticsOutput> rpcResult) {
- if (rpcResult.isSuccessful()) {
- //TODO : implement data read and put them into transaction chain
- return Boolean.TRUE;
- }
- return Boolean.FALSE;
- }
- });
+ return transformAndStoreStatisticsData(statisticsDataInFuture, deviceContext);
}
- public static ListenableFuture<Boolean> gatherMeterStatistics(OpendaylightMeterStatisticsService meterStatisticsService, DeviceContext deviceContext) {
-
- final GetAllMeterStatisticsInputBuilder builder =
- new GetAllMeterStatisticsInputBuilder();
+ public static ListenableFuture<Boolean> gatherMeterStatistics(MeterStatisticsService meterStatisticsService, final DeviceContext deviceContext) {
- builder.setNode(createNodeRef(deviceContext));
- ListenableFuture<RpcResult<GetAllMeterStatisticsOutput>> statisticsDataInFuture =
+ ListenableFuture<RpcResult<List<MultipartReply>>> statisticsDataInFuture =
JdkFutureAdapters.
listenInPoolThread(meterStatisticsService.
- getAllMeterStatistics(builder.build()));
+ getAllMeterStatistics());
- return Futures.transform(statisticsDataInFuture, new Function<RpcResult<GetAllMeterStatisticsOutput>, Boolean>() {
- @Nullable
- @Override
- public Boolean apply(final RpcResult<GetAllMeterStatisticsOutput> rpcResult) {
- if (rpcResult.isSuccessful()) {
- //TODO : implement data read and put them into transaction chain
- return Boolean.TRUE;
- }
- return Boolean.FALSE;
- }
- });
+ return transformAndStoreStatisticsData(statisticsDataInFuture, deviceContext);
}
- public static ListenableFuture<Boolean> gatherGroupStatistics(OpendaylightGroupStatisticsService groupStatisticsService, DeviceContext deviceContext) {
- final GetAllGroupStatisticsInputBuilder builder =
- new GetAllGroupStatisticsInputBuilder();
- builder.setNode(createNodeRef(deviceContext));
- ListenableFuture<RpcResult<GetAllGroupStatisticsOutput>> allFlowTablesDataInFuture =
+ public static ListenableFuture<Boolean> gatherGroupStatistics(GroupStatisticsService groupStatisticsService, final DeviceContext deviceContext) {
+ ListenableFuture<RpcResult<List<MultipartReply>>> statisticsDataInFuture =
JdkFutureAdapters.
listenInPoolThread(groupStatisticsService.
- getAllGroupStatistics(builder.build()));
+ getAllGroupStatistics());
- return Futures.transform(allFlowTablesDataInFuture, new Function<RpcResult<GetAllGroupStatisticsOutput>, Boolean>() {
- @Nullable
- @Override
- public Boolean apply(final RpcResult<GetAllGroupStatisticsOutput> rpcResult) {
- if (rpcResult.isSuccessful()) {
- //TODO : implement data read and put them into transaction chain
- return Boolean.TRUE;
- }
- return Boolean.FALSE;
- }
- });
+ return transformAndStoreStatisticsData(statisticsDataInFuture, deviceContext);
}
- public static ListenableFuture<Boolean> gatherFlowStatistics(OpendaylightFlowStatisticsService flowStatisticsService, DeviceContext deviceContext) {
- final GetAllFlowsStatisticsFromAllFlowTablesInputBuilder builder =
- new GetAllFlowsStatisticsFromAllFlowTablesInputBuilder();
- builder.setNode(createNodeRef(deviceContext));
- ListenableFuture<RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput>> allFlowTablesDataInFuture =
+ public static ListenableFuture<Boolean> gatherFlowStatistics(FlowStatisticsService flowStatisticsService, final DeviceContext deviceContext) {
+ ListenableFuture<RpcResult<List<MultipartReply>>> statisticsDataInFuture =
JdkFutureAdapters.
listenInPoolThread(flowStatisticsService.
- getAllFlowsStatisticsFromAllFlowTables(builder.build()));
- return Futures.transform(allFlowTablesDataInFuture, new Function<RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput>, Boolean>() {
- @Nullable
- @Override
- public Boolean apply(final RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput> rpcResult) {
- if (rpcResult.isSuccessful()) {
- List<FlowAndStatisticsMapList> flowAndStatsList = rpcResult.getResult().getFlowAndStatisticsMapList();
- //TODO : implement data read and put them into transaction chain
- for (FlowAndStatisticsMapList flowAndStatisticsMap : flowAndStatsList) {
- }
- return Boolean.TRUE;
- }
- return Boolean.FALSE;
- }
- });
+ getAllFlowsStatisticsFromAllFlowTables());
+ return transformAndStoreStatisticsData(statisticsDataInFuture, deviceContext);
+
+ }
+
+ public static ListenableFuture<Boolean> gatherTableStatistics(FlowTableStatisticsService flowTableStatisticsService, final DeviceContext deviceContext) {
+
+ ListenableFuture<RpcResult<List<MultipartReply>>> statisticsDataInFuture =
+ JdkFutureAdapters.listenInPoolThread(
+ flowTableStatisticsService.getFlowTablesStatistics());
+
+ return transformAndStoreStatisticsData(statisticsDataInFuture, deviceContext);
}
- public static ListenableFuture<Boolean> gatherTableStatistics(OpendaylightFlowTableStatisticsService flowTableStatisticsService, DeviceContext deviceContext) {
- GetFlowTablesStatisticsInputBuilder getFlowTablesStatisticsInputBuilder = new GetFlowTablesStatisticsInputBuilder();
- getFlowTablesStatisticsInputBuilder.setNode(createNodeRef(deviceContext));
- ListenableFuture<RpcResult<GetFlowTablesStatisticsOutput>> flowTableStaticsDataInFuture = JdkFutureAdapters.listenInPoolThread(flowTableStatisticsService.getFlowTablesStatistics(getFlowTablesStatisticsInputBuilder.build()));
- return Futures.transform(flowTableStaticsDataInFuture, new Function<RpcResult<GetFlowTablesStatisticsOutput>, Boolean>() {
+ private static ListenableFuture<Boolean> transformAndStoreStatisticsData(final ListenableFuture<RpcResult<List<MultipartReply>>> statisticsDataInFuture, final DeviceContext deviceContext) {
+ return Futures.transform(statisticsDataInFuture, new Function<RpcResult<List<MultipartReply>>, Boolean>() {
@Nullable
@Override
- public Boolean apply(
- final RpcResult<GetFlowTablesStatisticsOutput> rpcResult) {
+ public Boolean apply(final RpcResult<List<MultipartReply>> rpcResult) {
if (rpcResult.isSuccessful()) {
//TODO : implement data read and put them into transaction chain
return Boolean.TRUE;
@Override
public void deviceConnected(final DeviceContext deviceContext) {
- final StatisticsContext statisticsContext = new StatisticsContextImpl(deviceContext, null);
+ final StatisticsContext statisticsContext = new StatisticsContextImpl(deviceContext);
final ListenableFuture<Void> weHaveDynamicData = statisticsContext.gatherDynamicData();
Futures.addCallback(weHaveDynamicData, new FutureCallback<Void>() {
@Override
--- /dev/null
+/*
+ * 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.dedicated;
+
+import com.google.common.base.Function;
+import com.google.common.util.concurrent.JdkFutureAdapters;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.openflowplugin.api.openflow.device.Xid;
+import org.opendaylight.openflowplugin.impl.services.CommonService;
+import org.opendaylight.openflowplugin.impl.services.DataCrate;
+import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
+import org.opendaylight.openflowplugin.openflow.md.util.FlowCreatorUtil;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlowCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.flow._case.MultipartRequestFlowBuilder;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import java.util.List;
+import java.util.concurrent.Future;
+
+/**
+ * Created by Martin Bobak <mbobak@cisco.com> on 2.4.2015.
+ */
+public class FlowStatisticsService extends CommonService {
+ public FlowStatisticsService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+ super(requestContextStack, deviceContext);
+ }
+
+ public Future<RpcResult<List<MultipartReply>>> getAllFlowsStatisticsFromAllFlowTables() {
+ return handleServiceCall(
+ PRIMARY_CONNECTION, new Function<DataCrate<List<MultipartReply>>, Future<RpcResult<Void>>>() {
+ @Override
+ public Future<RpcResult<Void>> apply(final DataCrate<List<MultipartReply>> data) {
+
+ final MultipartRequestFlowCaseBuilder multipartRequestFlowCaseBuilder = new MultipartRequestFlowCaseBuilder();
+ final MultipartRequestFlowBuilder mprFlowRequestBuilder = new MultipartRequestFlowBuilder();
+ mprFlowRequestBuilder.setTableId(OFConstants.OFPTT_ALL);
+ mprFlowRequestBuilder.setOutPort(OFConstants.OFPP_ANY);
+ mprFlowRequestBuilder.setOutGroup(OFConstants.OFPG_ANY);
+ mprFlowRequestBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
+ mprFlowRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
+ FlowCreatorUtil.setWildcardedFlowMatch(version, mprFlowRequestBuilder);
+
+ final Xid xid = deviceContext.getNextXid();
+ data.getRequestContext().setXid(xid);
+ final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
+ MultipartType.OFPMPFLOW, xid.getValue(), version);
+
+ multipartRequestFlowCaseBuilder.setMultipartRequestFlow(mprFlowRequestBuilder.build());
+ mprInput.setMultipartRequestBody(multipartRequestFlowCaseBuilder.build());
+ final Future<RpcResult<Void>> resultFromOFLib = deviceContext.getPrimaryConnectionContext()
+ .getConnectionAdapter().multipartRequest(mprInput.build());
+ return JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
+ }
+ }
+
+ );
+ }
+
+}
--- /dev/null
+/*
+ * 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.dedicated;
+
+import com.google.common.base.Function;
+import com.google.common.util.concurrent.JdkFutureAdapters;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.openflowplugin.api.openflow.device.Xid;
+import org.opendaylight.openflowplugin.impl.services.CommonService;
+import org.opendaylight.openflowplugin.impl.services.DataCrate;
+import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table._case.MultipartRequestTableBuilder;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import java.util.List;
+import java.util.concurrent.Future;
+
+/**
+ * Created by Martin Bobak <mbobak@cisco.com> on 2.4.2015.
+ */
+public class FlowTableStatisticsService extends CommonService {
+ public FlowTableStatisticsService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+ super(requestContextStack, deviceContext);
+ }
+
+ public Future<RpcResult<List<MultipartReply>>> getFlowTablesStatistics() {
+ return handleServiceCall(
+ PRIMARY_CONNECTION, new Function<DataCrate<List<MultipartReply>>, Future<RpcResult<Void>>>() {
+ @Override
+ public Future<RpcResult<Void>> apply(final DataCrate<List<MultipartReply>> data) {
+
+ // Create multipart request body for fetch all the group stats
+ final MultipartRequestTableCaseBuilder multipartRequestTableCaseBuilder = new MultipartRequestTableCaseBuilder();
+ final MultipartRequestTableBuilder multipartRequestTableBuilder = new MultipartRequestTableBuilder();
+ multipartRequestTableBuilder.setEmpty(true);
+ multipartRequestTableCaseBuilder.setMultipartRequestTable(multipartRequestTableBuilder.build());
+
+ // Set request body to main multipart request
+ final Xid xid = deviceContext.getNextXid();
+ data.getRequestContext().setXid(xid);
+ final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
+ MultipartType.OFPMPFLOW, xid.getValue(), version);
+
+ mprInput.setMultipartRequestBody(multipartRequestTableCaseBuilder.build());
+ final Future<RpcResult<Void>> resultFromOFLib = deviceContext.getPrimaryConnectionContext()
+ .getConnectionAdapter().multipartRequest(mprInput.build());
+
+ return JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
+ }
+ });
+ }
+
+}
--- /dev/null
+/*
+ * 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.dedicated;
+
+import com.google.common.base.Function;
+import com.google.common.util.concurrent.JdkFutureAdapters;
+import org.opendaylight.openflowjava.protocol.api.util.BinContent;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.openflowplugin.api.openflow.device.Xid;
+import org.opendaylight.openflowplugin.impl.services.CommonService;
+import org.opendaylight.openflowplugin.impl.services.DataCrate;
+import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.group._case.MultipartRequestGroupBuilder;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import java.util.List;
+import java.util.concurrent.Future;
+
+/**
+ * Created by Martin Bobak <mbobak@cisco.com> on 2.4.2015.
+ */
+public class GroupStatisticsService extends CommonService {
+ public GroupStatisticsService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+ super(requestContextStack, deviceContext);
+ }
+
+ public Future<RpcResult<List<MultipartReply>>> getAllGroupStatistics() {
+ return handleServiceCall(
+ PRIMARY_CONNECTION, new Function<DataCrate<List<MultipartReply>>, Future<RpcResult<Void>>>() {
+ @Override
+ public Future<RpcResult<Void>> apply(final DataCrate<List<MultipartReply>> data) {
+ final MultipartRequestGroupCaseBuilder caseBuilder = new MultipartRequestGroupCaseBuilder();
+ final MultipartRequestGroupBuilder mprGroupBuild = new MultipartRequestGroupBuilder();
+ mprGroupBuild.setGroupId(new GroupId(
+ BinContent
+ .intToUnsignedLong(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Group.OFPGALL
+ .getIntValue())));
+ caseBuilder.setMultipartRequestGroup(mprGroupBuild.build());
+
+ // Create multipart request header
+ final Xid xid = deviceContext.getNextXid();
+ data.getRequestContext().setXid(xid);
+ final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
+ MultipartType.OFPMPGROUP, xid.getValue(), version);
+
+ // Set request body to main multipart request
+ mprInput.setMultipartRequestBody(caseBuilder.build());
+
+ // Send the request, no cookies associated, use any connection
+
+ final Future<RpcResult<Void>> resultFromOFLib = deviceContext.getPrimaryConnectionContext()
+ .getConnectionAdapter().multipartRequest(mprInput.build());
+ return JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
+
+ }
+ });
+ }
+}
--- /dev/null
+/*
+ * 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.dedicated;
+
+import com.google.common.base.Function;
+import com.google.common.util.concurrent.JdkFutureAdapters;
+import org.opendaylight.openflowjava.protocol.api.util.BinContent;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.openflowplugin.api.openflow.device.Xid;
+import org.opendaylight.openflowplugin.impl.services.CommonService;
+import org.opendaylight.openflowplugin.impl.services.DataCrate;
+import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.meter._case.MultipartRequestMeterBuilder;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import java.util.List;
+import java.util.concurrent.Future;
+
+/**
+ * Created by Martin Bobak <mbobak@cisco.com> on 2.4.2015.
+ */
+public class MeterStatisticsService extends CommonService {
+
+ public MeterStatisticsService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+ super(requestContextStack, deviceContext);
+ }
+
+ public Future<RpcResult<List<MultipartReply>>> getAllMeterStatistics() {
+ return handleServiceCall(
+ PRIMARY_CONNECTION, new Function<DataCrate<List<MultipartReply>>, Future<RpcResult<Void>>>() {
+ @Override
+ public Future<RpcResult<Void>> apply(final DataCrate<List<MultipartReply>> data) {
+
+ MultipartRequestMeterCaseBuilder caseBuilder =
+ new MultipartRequestMeterCaseBuilder();
+ MultipartRequestMeterBuilder mprMeterBuild =
+ new MultipartRequestMeterBuilder();
+ mprMeterBuild.setMeterId(new MeterId(BinContent.intToUnsignedLong(
+ org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common
+ .types.rev130731.Meter.OFPMALL.getIntValue())));
+ caseBuilder.setMultipartRequestMeter(mprMeterBuild.build());
+
+ final Xid xid = deviceContext.getNextXid();
+
+ MultipartRequestInputBuilder mprInput = RequestInputUtils
+ .createMultipartHeader(MultipartType.OFPMPMETER, xid.getValue(), version);
+ mprInput.setMultipartRequestBody(caseBuilder.build());
+ Future<RpcResult<Void>> resultFromOFLib = deviceContext.getPrimaryConnectionContext()
+ .getConnectionAdapter().multipartRequest(mprInput.build());
+
+ return JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
+ }
+ }
+ );
+
+ }
+
+}
--- /dev/null
+/*
+ * 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.dedicated;
+
+import com.google.common.base.Function;
+import com.google.common.util.concurrent.JdkFutureAdapters;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.openflowplugin.api.openflow.device.Xid;
+import org.opendaylight.openflowplugin.impl.services.CommonService;
+import org.opendaylight.openflowplugin.impl.services.DataCrate;
+import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortStatsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.port.stats._case.MultipartRequestPortStatsBuilder;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import java.util.List;
+import java.util.concurrent.Future;
+
+/**
+ * Created by Martin Bobak <mbobak@cisco.com> on 2.4.2015.
+ */
+public class PortStatisticsService extends CommonService {
+ public PortStatisticsService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+ super(requestContextStack, deviceContext);
+ }
+
+ public Future<RpcResult<List<MultipartReply>>> getAllNodeConnectorsStatistics() {
+ return handleServiceCall(
+ PRIMARY_CONNECTION, new Function<DataCrate<List<MultipartReply>>, Future<RpcResult<Void>>>() {
+ @Override
+ public Future<RpcResult<Void>> apply(final DataCrate<List<MultipartReply>> data) {
+
+ MultipartRequestPortStatsCaseBuilder caseBuilder =
+ new MultipartRequestPortStatsCaseBuilder();
+ MultipartRequestPortStatsBuilder mprPortStatsBuilder =
+ new MultipartRequestPortStatsBuilder();
+ // Select all ports
+ mprPortStatsBuilder.setPortNo(OFConstants.OFPP_ANY);
+ caseBuilder.setMultipartRequestPortStats(mprPortStatsBuilder.build());
+
+ final Xid xid = deviceContext.getNextXid();
+ data.getRequestContext().setXid(xid);
+ MultipartRequestInputBuilder mprInput = RequestInputUtils
+ .createMultipartHeader(MultipartType.OFPMPPORTSTATS, xid.getValue(), version);
+ mprInput.setMultipartRequestBody(caseBuilder.build());
+ Future<RpcResult<Void>> resultFromOFLib = deviceContext
+ .getPrimaryConnectionContext().getConnectionAdapter().multipartRequest(mprInput.build());
+ return JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
+ }
+ }
+
+ );
+ }
+
+}
--- /dev/null
+/*
+ * 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.dedicated;
+
+import com.google.common.base.Function;
+import com.google.common.util.concurrent.JdkFutureAdapters;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.openflowplugin.api.openflow.device.Xid;
+import org.opendaylight.openflowplugin.impl.services.CommonService;
+import org.opendaylight.openflowplugin.impl.services.DataCrate;
+import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestQueueCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.queue._case.MultipartRequestQueueBuilder;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import java.util.List;
+import java.util.concurrent.Future;
+
+/**
+ * Created by Martin Bobak <mbobak@cisco.com> on 2.4.2015.
+ */
+public class QueueStatisticsService extends CommonService {
+
+ public QueueStatisticsService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+ super(requestContextStack, deviceContext);
+ }
+
+ public Future<RpcResult<List<MultipartReply>>> getAllQueuesStatisticsFromAllPorts() {
+ return handleServiceCall(
+ PRIMARY_CONNECTION, new Function<DataCrate<List<MultipartReply>>, Future<RpcResult<Void>>>() {
+
+ @Override
+ public Future<RpcResult<Void>> apply(final DataCrate<List<MultipartReply>> data) {
+
+ MultipartRequestQueueCaseBuilder caseBuilder = new MultipartRequestQueueCaseBuilder();
+ MultipartRequestQueueBuilder mprQueueBuilder = new MultipartRequestQueueBuilder();
+ // Select all ports
+ mprQueueBuilder.setPortNo(OFConstants.OFPP_ANY);
+ // Select all the ports
+ mprQueueBuilder.setQueueId(OFConstants.OFPQ_ANY);
+ caseBuilder.setMultipartRequestQueue(mprQueueBuilder.build());
+
+ // Set request body to main multipart request
+ final Xid xid = deviceContext.getNextXid();
+ data.getRequestContext().setXid(xid);
+ MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
+ MultipartType.OFPMPQUEUE, xid.getValue(), version);
+ mprInput.setMultipartRequestBody(caseBuilder.build());
+ Future<RpcResult<Void>> resultFromOFLib = deviceContext.getPrimaryConnectionContext()
+ .getConnectionAdapter().multipartRequest(mprInput.build());
+ return JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
+ }
+ });
+ }
+
+}
private static GroupStatsResponseConvertor groupStatsConvertor = new GroupStatsResponseConvertor();
private static MeterStatsResponseConvertor meterStatsConvertor = new MeterStatsResponseConvertor();
+
@Override
public List<DataObject> translate(SwitchConnectionDistinguisher cookie, SessionContext sc, OfHeader msg) {