2 * Copyright (c) 2013-2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.openflowplugin.openflow.md.core.sal;
10 import com.google.common.util.concurrent.AsyncFunction;
11 import com.google.common.util.concurrent.FutureCallback;
12 import com.google.common.util.concurrent.Futures;
13 import com.google.common.util.concurrent.JdkFutureAdapters;
14 import com.google.common.util.concurrent.ListenableFuture;
15 import com.google.common.util.concurrent.SettableFuture;
16 import java.math.BigInteger;
17 import java.util.ArrayList;
18 import java.util.List;
19 import java.util.concurrent.Future;
20 import org.opendaylight.openflowjava.protocol.api.util.BinContent;
21 import org.opendaylight.openflowplugin.api.OFConstants;
22 import org.opendaylight.openflowplugin.api.openflow.md.core.SwitchConnectionDistinguisher;
23 import org.opendaylight.openflowplugin.api.openflow.md.core.sal.NotificationComposer;
24 import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
25 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.FlowConvertor;
26 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.GroupConvertor;
27 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.MeterConvertor;
28 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.PortConvertor;
29 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.TableFeaturesConvertor;
30 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchReactor;
31 import org.opendaylight.openflowplugin.openflow.md.util.FlowCreatorUtil;
32 import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowAdded;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowAddedBuilder;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowRemoved;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowRemovedBuilder;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowUpdated;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowUpdatedBuilder;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInput;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInputBuilder;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInput;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowOutput;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.OriginalFlow;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.UpdatedFlow;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutputBuilder;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableInput;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableOutput;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableOutputBuilder;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesInput;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesOutput;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesOutputBuilder;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableInput;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableOutput;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableOutputBuilder;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsInput;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsOutput;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsOutputBuilder;
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionId;
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.Port;
67 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow;
68 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInput;
69 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.GroupAdded;
70 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.GroupAddedBuilder;
71 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.GroupRemoved;
72 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.GroupRemovedBuilder;
73 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.GroupUpdated;
74 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.GroupUpdatedBuilder;
75 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInput;
76 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupInput;
77 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupOutput;
78 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsInput;
79 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsOutput;
80 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsOutputBuilder;
81 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupDescriptionInput;
82 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupDescriptionOutput;
83 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupDescriptionOutputBuilder;
84 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupFeaturesInput;
85 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupFeaturesOutput;
86 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupFeaturesOutputBuilder;
87 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupStatisticsInput;
88 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupStatisticsOutput;
89 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupStatisticsOutputBuilder;
90 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group;
91 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterInput;
92 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.MeterAdded;
93 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.MeterAddedBuilder;
94 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.MeterRemoved;
95 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.MeterRemovedBuilder;
96 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.MeterUpdated;
97 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.MeterUpdatedBuilder;
98 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterInput;
99 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterInput;
100 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterOutput;
101 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsInput;
102 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsOutput;
103 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsOutputBuilder;
104 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterStatisticsInput;
105 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterStatisticsOutput;
106 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterStatisticsOutputBuilder;
107 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterFeaturesInput;
108 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterFeaturesOutput;
109 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterFeaturesOutputBuilder;
110 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsInput;
111 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsOutput;
112 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsOutputBuilder;
113 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.Meter;
114 import org.opendaylight.yang.gen.v1.urn.opendaylight.module.config.rev141015.SetConfigInput;
115 import org.opendaylight.yang.gen.v1.urn.opendaylight.module.config.rev141015.SetConfigOutput;
116 import org.opendaylight.yang.gen.v1.urn.opendaylight.module.config.rev141015.SetConfigOutputBuilder;
117 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId;
118 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId;
119 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags;
120 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
121 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.SwitchConfigFlag;
122 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInputBuilder;
123 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInputBuilder;
124 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInputBuilder;
125 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
126 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput;
127 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInputBuilder;
128 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInputBuilder;
129 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestAggregateCaseBuilder;
130 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlowCaseBuilder;
131 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupCaseBuilder;
132 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupDescCaseBuilder;
133 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupFeaturesCaseBuilder;
134 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterCaseBuilder;
135 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterConfigCaseBuilder;
136 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterFeaturesCaseBuilder;
137 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortStatsCaseBuilder;
138 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestQueueCaseBuilder;
139 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableCaseBuilder;
140 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableFeaturesCaseBuilder;
141 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.aggregate._case.MultipartRequestAggregateBuilder;
142 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.flow._case.MultipartRequestFlowBuilder;
143 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.group._case.MultipartRequestGroupBuilder;
144 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.meter._case.MultipartRequestMeterBuilder;
145 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.meter.config._case.MultipartRequestMeterConfigBuilder;
146 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.port.stats._case.MultipartRequestPortStatsBuilder;
147 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.queue._case.MultipartRequestQueueBuilder;
148 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table._case.MultipartRequestTableBuilder;
149 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.MultipartRequestTableFeaturesBuilder;
150 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.multipart.request.table.features.TableFeatures;
151 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.UpdatePortInput;
152 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.UpdatePortOutput;
153 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllNodeConnectorsStatisticsInput;
154 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllNodeConnectorsStatisticsOutput;
155 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllNodeConnectorsStatisticsOutputBuilder;
156 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetNodeConnectorStatisticsInput;
157 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetNodeConnectorStatisticsOutput;
158 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetNodeConnectorStatisticsOutputBuilder;
159 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromAllPortsInput;
160 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromAllPortsOutput;
161 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromAllPortsOutputBuilder;
162 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromGivenPortInput;
163 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromGivenPortOutput;
164 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromGivenPortOutputBuilder;
165 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetQueueStatisticsFromGivenPortInput;
166 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetQueueStatisticsFromGivenPortOutput;
167 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetQueueStatisticsFromGivenPortOutputBuilder;
168 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableInput;
169 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableOutput;
170 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableOutputBuilder;
171 import org.opendaylight.yangtools.yang.common.RpcError.ErrorType;
172 import org.opendaylight.yangtools.yang.common.RpcResult;
173 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
174 import org.slf4j.Logger;
175 import org.slf4j.LoggerFactory;
180 public abstract class OFRpcTaskFactory {
181 protected static final Logger logger = LoggerFactory.getLogger(OFRpcTaskFactory.class);
187 * @return UpdateFlow task
189 public static OFRpcTask<AddFlowInput, RpcResult<UpdateFlowOutput>> createAddFlowTask(
190 OFRpcTaskContext taskContext, AddFlowInput input,
191 SwitchConnectionDistinguisher cookie) {
192 OFRpcTask<AddFlowInput, RpcResult<UpdateFlowOutput>> task =
193 new OFRpcTask<AddFlowInput, RpcResult<UpdateFlowOutput>>(taskContext, cookie, input) {
196 public ListenableFuture<RpcResult<UpdateFlowOutput>> call() {
197 ListenableFuture<RpcResult<UpdateFlowOutput>> result = SettableFuture.create();
199 // Convert the AddFlowInput to FlowModInput
200 List<FlowModInputBuilder> ofFlowModInputs = FlowConvertor.toFlowModInputs(getInput(),
201 getVersion(), getSession().getFeatures().getDatapathId());
203 logger.debug("Number of flows to push to switch: {}", ofFlowModInputs.size());
205 result = chainFlowMods(ofFlowModInputs, 0, getTaskContext(), getCookie());
208 result = OFRpcTaskUtil.chainFutureBarrier(this, result);
209 OFRpcTaskUtil.hookFutureNotification(this, result,
210 getRpcNotificationProviderService(),
211 createFlowAddedNotification(getInput()));
216 public Boolean isBarrier() {
217 return getInput().isBarrier();
224 * Recursive helper method for {@link OFRpcTaskFactory#createAddFlowTask()}
225 * and {@link OFRpcTaskFactory#createUpdateFlowTask()} to chain results
226 * of multiple flowmods.
227 * The next flowmod gets executed if the earlier one is successful.
228 * All the flowmods should have the same xid, in-order to cross-reference
231 protected static ListenableFuture<RpcResult<UpdateFlowOutput>> chainFlowMods(
232 final List<FlowModInputBuilder> ofFlowModInputs, final int index,
233 final OFRpcTaskContext taskContext, final SwitchConnectionDistinguisher cookie) {
235 Future<RpcResult<UpdateFlowOutput>> resultFromOFLib =
236 createResultForFlowMod(taskContext, ofFlowModInputs.get(index), cookie);
238 ListenableFuture<RpcResult<UpdateFlowOutput>> result = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
240 if (ofFlowModInputs.size() > index + 1) {
241 // there are more flowmods to chain
242 return Futures.transform(result,
243 new AsyncFunction<RpcResult<UpdateFlowOutput>, RpcResult<UpdateFlowOutput>>() {
245 public ListenableFuture<RpcResult<UpdateFlowOutput>> apply(RpcResult<UpdateFlowOutput> input) throws Exception {
246 if (input.isSuccessful()) {
247 return chainFlowMods(ofFlowModInputs, index + 1, taskContext, cookie);
249 logger.warn("Flowmod failed. Any chained flowmods are ignored. xid:{}",
250 ofFlowModInputs.get(index).getXid());
251 return Futures.immediateFuture(input);
261 private static Future<RpcResult<UpdateFlowOutput>> createResultForFlowMod(
262 OFRpcTaskContext taskContext, FlowModInputBuilder flowModInput,
263 SwitchConnectionDistinguisher cookie) {
264 flowModInput.setXid(taskContext.getSession().getNextXid());
265 return taskContext.getMessageService().flowMod(flowModInput.build(), cookie);
273 protected static NotificationComposer<FlowAdded> createFlowAddedNotification(
274 final AddFlowInput input) {
275 return new NotificationComposer<FlowAdded>() {
277 public FlowAdded compose(TransactionId tXid) {
278 FlowAddedBuilder newFlow = new FlowAddedBuilder((Flow) input);
279 newFlow.setTransactionId(tXid);
280 newFlow.setFlowRef(input.getFlowRef());
281 return newFlow.build();
290 * @return UpdateFlow task
292 public static OFRpcTask<UpdateFlowInput, RpcResult<UpdateFlowOutput>> createUpdateFlowTask(
293 final OFRpcTaskContext taskContext, UpdateFlowInput input,
294 SwitchConnectionDistinguisher cookie) {
296 OFRpcTask<UpdateFlowInput, RpcResult<UpdateFlowOutput>> task =
297 new OFRpcTask<UpdateFlowInput, RpcResult<UpdateFlowOutput>>(taskContext, cookie, input) {
300 public ListenableFuture<RpcResult<UpdateFlowOutput>> call() {
301 ListenableFuture<RpcResult<UpdateFlowOutput>> result = null;
303 UpdateFlowInput in = getInput();
304 UpdatedFlow updated = in.getUpdatedFlow();
305 OriginalFlow original = in.getOriginalFlow();
306 Short version = getVersion();
308 List<FlowModInputBuilder> allFlowMods = new ArrayList<>();
309 List<FlowModInputBuilder> ofFlowModInputs;
311 if (!FlowCreatorUtil.canModifyFlow(original, updated, version)) {
312 // We would need to remove original and add updated.
315 RemoveFlowInputBuilder removeflow = new RemoveFlowInputBuilder(original);
316 List<FlowModInputBuilder> ofFlowRemoveInput = FlowConvertor.toFlowModInputs(removeflow.build(),
317 version, getSession().getFeatures().getDatapathId());
318 // remove flow should be the first
319 allFlowMods.addAll(ofFlowRemoveInput);
320 AddFlowInputBuilder addFlowInputBuilder = new AddFlowInputBuilder(updated);
321 ofFlowModInputs = FlowConvertor.toFlowModInputs(addFlowInputBuilder.build(),
322 version, getSession().getFeatures().getDatapathId());
324 ofFlowModInputs = FlowConvertor.toFlowModInputs(updated,
325 version, getSession().getFeatures().getDatapathId());
328 allFlowMods.addAll(ofFlowModInputs);
329 logger.debug("Number of flows to push to switch: {}", allFlowMods.size());
330 result = chainFlowMods(allFlowMods, 0, getTaskContext(), getCookie());
332 result = OFRpcTaskUtil.chainFutureBarrier(this, result);
333 OFRpcTaskUtil.hookFutureNotification(this, result,
334 getRpcNotificationProviderService(),
335 createFlowUpdatedNotification(in));
340 public Boolean isBarrier() {
341 return getInput().getUpdatedFlow().isBarrier();
353 protected static NotificationComposer<FlowUpdated> createFlowUpdatedNotification(final UpdateFlowInput input) {
354 return new NotificationComposer<FlowUpdated>() {
356 public FlowUpdated compose(TransactionId tXid) {
357 FlowUpdatedBuilder updFlow = new FlowUpdatedBuilder(input.getUpdatedFlow());
358 updFlow.setTransactionId(tXid);
359 updFlow.setFlowRef(input.getFlowRef());
360 return updFlow.build();
369 * @return update group task
371 public static OFRpcTask<AddGroupInput, RpcResult<UpdateGroupOutput>> createAddGroupTask(
372 final OFRpcTaskContext taskContext, AddGroupInput input,
373 final SwitchConnectionDistinguisher cookie) {
374 OFRpcTask<AddGroupInput, RpcResult<UpdateGroupOutput>> task =
375 new OFRpcTask<AddGroupInput, RpcResult<UpdateGroupOutput>>(taskContext, cookie, input) {
378 public ListenableFuture<RpcResult<UpdateGroupOutput>> call() {
379 ListenableFuture<RpcResult<UpdateGroupOutput>> result = SettableFuture.create();
381 // Convert the AddGroupInput to GroupModInput
382 GroupModInputBuilder ofGroupModInput = GroupConvertor.toGroupModInput(getInput(),
383 getVersion(), getSession().getFeatures().getDatapathId());
384 final Long xId = getSession().getNextXid();
385 ofGroupModInput.setXid(xId);
387 Future<RpcResult<UpdateGroupOutput>> resultFromOFLib = getMessageService()
388 .groupMod(ofGroupModInput.build(), getCookie());
389 result = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
391 result = OFRpcTaskUtil.chainFutureBarrier(this, result);
392 OFRpcTaskUtil.hookFutureNotification(this, result,
393 getRpcNotificationProviderService(), createGroupAddedNotification(getInput()));
399 public Boolean isBarrier() {
400 return getInput().isBarrier();
412 protected static NotificationComposer<GroupAdded> createGroupAddedNotification(
413 final AddGroupInput input) {
414 return new NotificationComposer<GroupAdded>() {
416 public GroupAdded compose(TransactionId tXid) {
417 GroupAddedBuilder groupMod = new GroupAddedBuilder((Group) input);
418 groupMod.setTransactionId(tXid);
419 groupMod.setGroupRef(input.getGroupRef());
420 return groupMod.build();
429 * @return update meter task
431 public static OFRpcTask<AddMeterInput, RpcResult<UpdateMeterOutput>> createAddMeterTask(
432 OFRpcTaskContext taskContext, AddMeterInput input,
433 SwitchConnectionDistinguisher cookie) {
434 OFRpcTask<AddMeterInput, RpcResult<UpdateMeterOutput>> task =
435 new OFRpcTask<AddMeterInput, RpcResult<UpdateMeterOutput>>(taskContext, cookie, input) {
438 public ListenableFuture<RpcResult<UpdateMeterOutput>> call() {
439 ListenableFuture<RpcResult<UpdateMeterOutput>> result = SettableFuture.create();
441 // Convert the AddGroupInput to GroupModInput
442 MeterModInputBuilder ofMeterModInput = MeterConvertor.toMeterModInput(getInput(), getVersion());
443 final Long xId = getSession().getNextXid();
444 ofMeterModInput.setXid(xId);
446 Future<RpcResult<UpdateMeterOutput>> resultFromOFLib = getMessageService()
447 .meterMod(ofMeterModInput.build(), getCookie());
448 result = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
450 result = OFRpcTaskUtil.chainFutureBarrier(this, result);
451 OFRpcTaskUtil.hookFutureNotification(this, result,
452 getRpcNotificationProviderService(), createMeterAddedNotification(getInput()));
458 public Boolean isBarrier() {
459 return getInput().isBarrier();
471 protected static NotificationComposer<MeterAdded> createMeterAddedNotification(
472 final AddMeterInput input) {
473 return new NotificationComposer<MeterAdded>() {
475 public MeterAdded compose(TransactionId tXid) {
476 MeterAddedBuilder meterMod = new MeterAddedBuilder((Meter) input);
477 meterMod.setTransactionId(tXid);
478 meterMod.setMeterRef(input.getMeterRef());
479 return meterMod.build();
488 * @return UpdateFlow task
490 public static OFRpcTask<UpdateGroupInput, RpcResult<UpdateGroupOutput>> createUpdateGroupTask(
491 OFRpcTaskContext taskContext, UpdateGroupInput input,
492 SwitchConnectionDistinguisher cookie) {
493 OFRpcTask<UpdateGroupInput, RpcResult<UpdateGroupOutput>> task =
494 new OFRpcTask<UpdateGroupInput, RpcResult<UpdateGroupOutput>>(taskContext, cookie, input) {
497 public ListenableFuture<RpcResult<UpdateGroupOutput>> call() {
498 ListenableFuture<RpcResult<UpdateGroupOutput>> result = null;
500 // Convert the UpdateGroupInput to GroupModInput
501 GroupModInputBuilder ofGroupModInput = GroupConvertor.toGroupModInput(
502 getInput().getUpdatedGroup(), getVersion(),
503 getSession().getFeatures().getDatapathId());
504 final Long xId = getSession().getNextXid();
505 ofGroupModInput.setXid(xId);
507 Future<RpcResult<UpdateGroupOutput>> resultFromOFLib =
508 getMessageService().groupMod(ofGroupModInput.build(), getCookie());
509 result = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
511 result = OFRpcTaskUtil.chainFutureBarrier(this, result);
512 OFRpcTaskUtil.hookFutureNotification(this, result,
513 getRpcNotificationProviderService(), createGroupUpdatedNotification(getInput()));
525 protected static NotificationComposer<GroupUpdated> createGroupUpdatedNotification(
526 final UpdateGroupInput input) {
527 return new NotificationComposer<GroupUpdated>() {
529 public GroupUpdated compose(TransactionId tXid) {
530 GroupUpdatedBuilder groupMod = new GroupUpdatedBuilder(input.getUpdatedGroup());
531 groupMod.setTransactionId(tXid);
532 groupMod.setGroupRef(input.getGroupRef());
533 return groupMod.build();
542 * @return update meter task
544 public static OFRpcTask<UpdateMeterInput, RpcResult<UpdateMeterOutput>> createUpdateMeterTask(
545 OFRpcTaskContext taskContext, UpdateMeterInput input,
546 SwitchConnectionDistinguisher cookie) {
547 OFRpcTask<UpdateMeterInput, RpcResult<UpdateMeterOutput>> task =
548 new OFRpcTask<UpdateMeterInput, RpcResult<UpdateMeterOutput>>(taskContext, cookie, input) {
551 public ListenableFuture<RpcResult<UpdateMeterOutput>> call() {
552 ListenableFuture<RpcResult<UpdateMeterOutput>> result = null;
554 // Convert the UpdateMeterInput to MeterModInput
555 MeterModInputBuilder ofMeterModInput = MeterConvertor.toMeterModInput(
556 getInput().getUpdatedMeter(), getVersion());
557 final Long xId = getSession().getNextXid();
558 ofMeterModInput.setXid(xId);
560 Future<RpcResult<UpdateMeterOutput>> resultFromOFLib =
561 getMessageService().meterMod(ofMeterModInput.build(), getCookie());
562 result = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
564 result = OFRpcTaskUtil.chainFutureBarrier(this, result);
565 OFRpcTaskUtil.hookFutureNotification(this, result,
566 getRpcNotificationProviderService(), createMeterUpdatedNotification(getInput()));
577 protected static NotificationComposer<MeterUpdated> createMeterUpdatedNotification(
578 final UpdateMeterInput input) {
579 return new NotificationComposer<MeterUpdated>() {
581 public MeterUpdated compose(TransactionId tXid) {
582 MeterUpdatedBuilder meterMod = new MeterUpdatedBuilder(input.getUpdatedMeter());
583 meterMod.setTransactionId(tXid);
584 meterMod.setMeterRef(input.getMeterRef());
585 return meterMod.build();
597 public static OFRpcTask<RemoveFlowInput, RpcResult<UpdateFlowOutput>> createRemoveFlowTask(
598 OFRpcTaskContext taskContext, RemoveFlowInput input,
599 SwitchConnectionDistinguisher cookie) {
600 OFRpcTask<RemoveFlowInput, RpcResult<UpdateFlowOutput>> task =
601 new OFRpcTask<RemoveFlowInput, RpcResult<UpdateFlowOutput>>(taskContext, cookie, input) {
604 public ListenableFuture<RpcResult<UpdateFlowOutput>> call() {
605 ListenableFuture<RpcResult<UpdateFlowOutput>> result = SettableFuture.create();
607 // Convert the AddFlowInput to FlowModInput
608 FlowModInputBuilder ofFlowModInput = FlowConvertor.toFlowModInput(getInput(),
609 getVersion(), getSession().getFeatures().getDatapathId());
610 final Long xId = getSession().getNextXid();
611 ofFlowModInput.setXid(xId);
613 Future<RpcResult<UpdateFlowOutput>> resultFromOFLib =
614 getMessageService().flowMod(ofFlowModInput.build(), getCookie());
615 result = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
617 result = OFRpcTaskUtil.chainFutureBarrier(this, result);
618 OFRpcTaskUtil.hookFutureNotification(this, result,
619 getRpcNotificationProviderService(), createFlowRemovedNotification(getInput()));
632 protected static NotificationComposer<FlowRemoved> createFlowRemovedNotification(
633 final RemoveFlowInput input) {
634 return new NotificationComposer<FlowRemoved>() {
636 public FlowRemoved compose(TransactionId tXid) {
637 FlowRemovedBuilder removedFlow = new FlowRemovedBuilder((Flow) input);
638 removedFlow.setTransactionId(tXid);
639 removedFlow.setFlowRef(input.getFlowRef());
640 return removedFlow.build();
652 public static OFRpcTask<RemoveGroupInput, RpcResult<UpdateGroupOutput>> createRemoveGroupTask(
653 final OFRpcTaskContext taskContext, RemoveGroupInput input,
654 final SwitchConnectionDistinguisher cookie) {
655 OFRpcTask<RemoveGroupInput, RpcResult<UpdateGroupOutput>> task =
656 new OFRpcTask<RemoveGroupInput, RpcResult<UpdateGroupOutput>>(taskContext, cookie, input) {
659 public ListenableFuture<RpcResult<UpdateGroupOutput>> call() {
660 ListenableFuture<RpcResult<UpdateGroupOutput>> result = SettableFuture.create();
662 // Convert the AddGroupInput to GroupModInput
663 GroupModInputBuilder ofGroupModInput = GroupConvertor.toGroupModInput(getInput(),
664 getVersion(), getSession().getFeatures().getDatapathId());
665 final Long xId = getSession().getNextXid();
666 ofGroupModInput.setXid(xId);
668 Future<RpcResult<UpdateGroupOutput>> resultFromOFLib = getMessageService()
669 .groupMod(ofGroupModInput.build(), getCookie());
670 result = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
672 result = OFRpcTaskUtil.chainFutureBarrier(this, result);
673 OFRpcTaskUtil.hookFutureNotification(this, result,
674 getRpcNotificationProviderService(), createGroupRemovedNotification(getInput()));
687 protected static NotificationComposer<GroupRemoved> createGroupRemovedNotification(
688 final RemoveGroupInput input) {
689 return new NotificationComposer<GroupRemoved>() {
691 public GroupRemoved compose(TransactionId tXid) {
692 GroupRemovedBuilder removedGroup = new GroupRemovedBuilder((Group) input);
693 removedGroup.setTransactionId(tXid);
694 removedGroup.setGroupRef(input.getGroupRef());
695 return removedGroup.build();
706 public static OFRpcTask<RemoveMeterInput, RpcResult<UpdateMeterOutput>> createRemoveMeterTask(
707 OFRpcTaskContext taskContext, RemoveMeterInput input,
708 SwitchConnectionDistinguisher cookie) {
709 OFRpcTask<RemoveMeterInput, RpcResult<UpdateMeterOutput>> task =
710 new OFRpcTask<RemoveMeterInput, RpcResult<UpdateMeterOutput>>(taskContext, cookie, input) {
713 public ListenableFuture<RpcResult<UpdateMeterOutput>> call() {
714 ListenableFuture<RpcResult<UpdateMeterOutput>> result = SettableFuture.create();
716 // Convert the AddGroupInput to GroupModInput
717 MeterModInputBuilder ofMeterModInput = MeterConvertor.toMeterModInput(getInput(), getVersion());
718 final Long xId = getSession().getNextXid();
719 ofMeterModInput.setXid(xId);
721 Future<RpcResult<UpdateMeterOutput>> resultFromOFLib = getMessageService()
722 .meterMod(ofMeterModInput.build(), getCookie());
723 result = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
725 result = OFRpcTaskUtil.chainFutureBarrier(this, result);
726 OFRpcTaskUtil.hookFutureNotification(this, result,
727 getRpcNotificationProviderService(), createMeterRemovedNotification(getInput()));
741 protected static NotificationComposer<MeterRemoved> createMeterRemovedNotification(
742 final RemoveMeterInput input) {
743 return new NotificationComposer<MeterRemoved>() {
745 public MeterRemoved compose(TransactionId tXid) {
746 MeterRemovedBuilder meterRemoved = new MeterRemovedBuilder((Meter) input);
747 meterRemoved.setTransactionId(tXid);
748 meterRemoved.setMeterRef(input.getMeterRef());
749 return meterRemoved.build();
760 public static OFRpcTask<GetAllGroupStatisticsInput, RpcResult<GetAllGroupStatisticsOutput>> createGetAllGroupStatisticsTask(
761 final OFRpcTaskContext taskContext, GetAllGroupStatisticsInput input,
762 SwitchConnectionDistinguisher cookie) {
763 OFRpcTask<GetAllGroupStatisticsInput, RpcResult<GetAllGroupStatisticsOutput>> task =
764 new OFRpcTask<GetAllGroupStatisticsInput, RpcResult<GetAllGroupStatisticsOutput>>(taskContext, cookie, input) {
767 public ListenableFuture<RpcResult<GetAllGroupStatisticsOutput>> call() {
768 final SettableFuture<RpcResult<GetAllGroupStatisticsOutput>> result = SettableFuture.create();
770 if (taskContext.getSession().getPrimaryConductor().getVersion() == OFConstants.OFP_VERSION_1_0) {
771 RpcResult<GetAllGroupStatisticsOutput> rpcResult = RpcResultBuilder.success(
772 new GetAllGroupStatisticsOutputBuilder().build()).build();
774 return Futures.immediateFuture(rpcResult);
777 // Generate xid to associate it with the request
778 final Long xid = taskContext.getSession().getNextXid();
780 // Create multipart request body for fetch all the group stats
781 MultipartRequestGroupCaseBuilder caseBuilder = new MultipartRequestGroupCaseBuilder();
782 MultipartRequestGroupBuilder mprGroupBuild = new MultipartRequestGroupBuilder();
783 mprGroupBuild.setGroupId(new GroupId(BinContent.intToUnsignedLong(
784 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731
785 .Group.OFPGALL.getIntValue())));
786 caseBuilder.setMultipartRequestGroup(mprGroupBuild.build());
788 // Create multipart request header
789 MultipartRequestInputBuilder mprInput = createMultipartHeader(MultipartType.OFPMPGROUP,
792 // Set request body to main multipart request
793 mprInput.setMultipartRequestBody(caseBuilder.build());
795 // Send the request, no cookies associated, use any connection
797 Future<RpcResult<Void>> resultFromOFLib = getMessageService()
798 .multipartRequest(mprInput.build(), getCookie());
799 ListenableFuture<RpcResult<Void>> resultLib = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
801 Futures.addCallback(resultLib, new ResultCallback<GetAllGroupStatisticsOutput>(result) {
803 public GetAllGroupStatisticsOutput createResult() {
804 GetAllGroupStatisticsOutputBuilder groupStatBuilder = new GetAllGroupStatisticsOutputBuilder()
805 .setTransactionId(new TransactionId(BigInteger.valueOf(xid)));
806 return groupStatBuilder.build();
823 public static OFRpcTask<GetGroupDescriptionInput, RpcResult<GetGroupDescriptionOutput>> createGetGroupDescriptionTask(
824 final OFRpcTaskContext taskContext, GetGroupDescriptionInput input,
825 SwitchConnectionDistinguisher cookie) {
826 OFRpcTask<GetGroupDescriptionInput, RpcResult<GetGroupDescriptionOutput>> task =
827 new OFRpcTask<GetGroupDescriptionInput, RpcResult<GetGroupDescriptionOutput>>(taskContext, cookie, input) {
830 public ListenableFuture<RpcResult<GetGroupDescriptionOutput>> call()
832 final SettableFuture<RpcResult<GetGroupDescriptionOutput>> result = SettableFuture.create();
834 if (taskContext.getSession().getPrimaryConductor().getVersion() == OFConstants.OFP_VERSION_1_0) {
835 RpcResult<GetGroupDescriptionOutput> rpcResult = RpcResultBuilder.success(
836 new GetGroupDescriptionOutputBuilder().build()).build();
837 return Futures.immediateFuture(rpcResult);
839 final Long xid = taskContext.getSession().getNextXid();
841 MultipartRequestGroupDescCaseBuilder mprGroupDescCaseBuild =
842 new MultipartRequestGroupDescCaseBuilder();
843 MultipartRequestInputBuilder mprInput =
844 createMultipartHeader(MultipartType.OFPMPGROUPDESC, taskContext, xid);
845 mprInput.setMultipartRequestBody(mprGroupDescCaseBuild.build());
846 Future<RpcResult<Void>> resultFromOFLib = getMessageService()
847 .multipartRequest(mprInput.build(), getCookie());
848 ListenableFuture<RpcResult<Void>> resultLib = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
850 Futures.addCallback(resultLib, new ResultCallback<GetGroupDescriptionOutput>(result) {
852 public GetGroupDescriptionOutput createResult() {
853 GetGroupDescriptionOutputBuilder groupStatBuilder = new GetGroupDescriptionOutputBuilder()
854 .setTransactionId(new TransactionId(BigInteger.valueOf(xid)));
855 return groupStatBuilder.build();
871 public static OFRpcTask<GetGroupFeaturesInput, RpcResult<GetGroupFeaturesOutput>> createGetGroupFeaturesTask(
872 final OFRpcTaskContext taskContext, GetGroupFeaturesInput input,
873 SwitchConnectionDistinguisher cookie) {
874 OFRpcTask<GetGroupFeaturesInput, RpcResult<GetGroupFeaturesOutput>> task =
875 new OFRpcTask<GetGroupFeaturesInput, RpcResult<GetGroupFeaturesOutput>>(taskContext, cookie, input) {
878 public ListenableFuture<RpcResult<GetGroupFeaturesOutput>> call()
880 final SettableFuture<RpcResult<GetGroupFeaturesOutput>> result = SettableFuture.create();
882 if (taskContext.getSession().getPrimaryConductor().getVersion() == OFConstants.OFP_VERSION_1_0) {
883 RpcResult<GetGroupFeaturesOutput> rpcResult = RpcResultBuilder.success(
884 new GetGroupFeaturesOutputBuilder().build()).build();
885 return Futures.immediateFuture(rpcResult);
887 final Long xid = taskContext.getSession().getNextXid();
889 MultipartRequestGroupFeaturesCaseBuilder mprGroupFeaturesBuild =
890 new MultipartRequestGroupFeaturesCaseBuilder();
891 MultipartRequestInputBuilder mprInput =
892 createMultipartHeader(MultipartType.OFPMPGROUPFEATURES, taskContext, xid);
893 mprInput.setMultipartRequestBody(mprGroupFeaturesBuild.build());
894 Future<RpcResult<Void>> resultFromOFLib = getMessageService()
895 .multipartRequest(mprInput.build(), getCookie());
896 ListenableFuture<RpcResult<Void>> resultLib = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
898 Futures.addCallback(resultLib, new ResultCallback<GetGroupFeaturesOutput>(result) {
900 public GetGroupFeaturesOutput createResult() {
901 GetGroupFeaturesOutputBuilder groupFeatureBuilder = new GetGroupFeaturesOutputBuilder()
902 .setTransactionId(new TransactionId(BigInteger.valueOf(xid)));
903 return groupFeatureBuilder.build();
919 public static OFRpcTask<GetGroupStatisticsInput, RpcResult<GetGroupStatisticsOutput>> createGetGroupStatisticsTask(
920 final OFRpcTaskContext taskContext, final GetGroupStatisticsInput input,
921 SwitchConnectionDistinguisher cookie) {
922 OFRpcTask<GetGroupStatisticsInput, RpcResult<GetGroupStatisticsOutput>> task =
923 new OFRpcTask<GetGroupStatisticsInput, RpcResult<GetGroupStatisticsOutput>>(taskContext, cookie, input) {
926 public ListenableFuture<RpcResult<GetGroupStatisticsOutput>> call()
928 final SettableFuture<RpcResult<GetGroupStatisticsOutput>> result = SettableFuture.create();
930 if (taskContext.getSession().getPrimaryConductor().getVersion() == OFConstants.OFP_VERSION_1_0) {
931 RpcResult<GetGroupStatisticsOutput> rpcResult = RpcResultBuilder.success(
932 new GetGroupStatisticsOutputBuilder().build()).build();
933 return Futures.immediateFuture(rpcResult);
935 final Long xid = taskContext.getSession().getNextXid();
937 MultipartRequestGroupCaseBuilder caseBuilder = new MultipartRequestGroupCaseBuilder();
938 MultipartRequestGroupBuilder mprGroupBuild = new MultipartRequestGroupBuilder();
939 mprGroupBuild.setGroupId(new GroupId(input.getGroupId().getValue()));
940 caseBuilder.setMultipartRequestGroup(mprGroupBuild.build());
942 MultipartRequestInputBuilder mprInput =
943 createMultipartHeader(MultipartType.OFPMPGROUP, taskContext, xid);
944 mprInput.setMultipartRequestBody(caseBuilder.build());
945 Future<RpcResult<Void>> resultFromOFLib = getMessageService()
946 .multipartRequest(mprInput.build(), getCookie());
947 ListenableFuture<RpcResult<Void>> resultLib = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
949 Futures.addCallback(resultLib, new ResultCallback<GetGroupStatisticsOutput>(result) {
951 public GetGroupStatisticsOutput createResult() {
952 GetGroupStatisticsOutputBuilder groupStatisticsBuilder =
953 new GetGroupStatisticsOutputBuilder()
954 .setTransactionId(new TransactionId(BigInteger.valueOf(xid)));
955 return groupStatisticsBuilder.build();
971 public static OFRpcTask<GetAllMeterConfigStatisticsInput, RpcResult<GetAllMeterConfigStatisticsOutput>> createGetAllMeterConfigStatisticsTask(
972 final OFRpcTaskContext taskContext, final GetAllMeterConfigStatisticsInput input,
973 SwitchConnectionDistinguisher cookie) {
974 OFRpcTask<GetAllMeterConfigStatisticsInput, RpcResult<GetAllMeterConfigStatisticsOutput>> task =
975 new OFRpcTask<GetAllMeterConfigStatisticsInput, RpcResult<GetAllMeterConfigStatisticsOutput>>(taskContext, cookie, input) {
978 public ListenableFuture<RpcResult<GetAllMeterConfigStatisticsOutput>> call()
980 final SettableFuture<RpcResult<GetAllMeterConfigStatisticsOutput>> result = SettableFuture.create();
982 if (taskContext.getSession().getPrimaryConductor().getVersion() == OFConstants.OFP_VERSION_1_0) {
983 RpcResult<GetAllMeterConfigStatisticsOutput> rpcResult = RpcResultBuilder.success(
984 new GetAllMeterConfigStatisticsOutputBuilder().build()).build();
985 return Futures.immediateFuture(rpcResult);
987 final Long xid = taskContext.getSession().getNextXid();
989 MultipartRequestMeterConfigCaseBuilder caseBuilder =
990 new MultipartRequestMeterConfigCaseBuilder();
991 MultipartRequestMeterConfigBuilder mprMeterConfigBuild =
992 new MultipartRequestMeterConfigBuilder();
993 mprMeterConfigBuild.setMeterId(new MeterId(BinContent.intToUnsignedLong(
994 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common
995 .types.rev130731.Meter.OFPMALL.getIntValue())));
996 caseBuilder.setMultipartRequestMeterConfig(mprMeterConfigBuild.build());
998 MultipartRequestInputBuilder mprInput =
999 createMultipartHeader(MultipartType.OFPMPMETERCONFIG, taskContext, xid);
1000 mprInput.setMultipartRequestBody(caseBuilder.build());
1001 Future<RpcResult<Void>> resultFromOFLib = getMessageService()
1002 .multipartRequest(mprInput.build(), getCookie());
1003 ListenableFuture<RpcResult<Void>> resultLib = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
1005 Futures.addCallback(resultLib, new ResultCallback<GetAllMeterConfigStatisticsOutput>(result) {
1007 public GetAllMeterConfigStatisticsOutput createResult() {
1008 GetAllMeterConfigStatisticsOutputBuilder allMeterConfStatBuilder =
1009 new GetAllMeterConfigStatisticsOutputBuilder()
1010 .setTransactionId(new TransactionId(BigInteger.valueOf(xid)));
1011 return allMeterConfStatBuilder.build();
1022 * @param taskContext
1027 public static OFRpcTask<GetAllMeterStatisticsInput, RpcResult<GetAllMeterStatisticsOutput>> createGetAllMeterStatisticsTask(
1028 final OFRpcTaskContext taskContext, final GetAllMeterStatisticsInput input,
1029 SwitchConnectionDistinguisher cookie) {
1030 OFRpcTask<GetAllMeterStatisticsInput, RpcResult<GetAllMeterStatisticsOutput>> task =
1031 new OFRpcTask<GetAllMeterStatisticsInput, RpcResult<GetAllMeterStatisticsOutput>>(taskContext, cookie, input) {
1034 public ListenableFuture<RpcResult<GetAllMeterStatisticsOutput>> call()
1036 final SettableFuture<RpcResult<GetAllMeterStatisticsOutput>> result = SettableFuture.create();
1038 if (taskContext.getSession().getPrimaryConductor().getVersion() == OFConstants.OFP_VERSION_1_0) {
1039 RpcResult<GetAllMeterStatisticsOutput> rpcResult = RpcResultBuilder.success(
1040 new GetAllMeterStatisticsOutputBuilder().build()).build();
1041 return Futures.immediateFuture(rpcResult);
1043 final Long xid = taskContext.getSession().getNextXid();
1045 MultipartRequestMeterCaseBuilder caseBuilder =
1046 new MultipartRequestMeterCaseBuilder();
1047 MultipartRequestMeterBuilder mprMeterBuild =
1048 new MultipartRequestMeterBuilder();
1049 mprMeterBuild.setMeterId(new MeterId(BinContent.intToUnsignedLong(
1050 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common
1051 .types.rev130731.Meter.OFPMALL.getIntValue())));
1052 caseBuilder.setMultipartRequestMeter(mprMeterBuild.build());
1054 MultipartRequestInputBuilder mprInput =
1055 createMultipartHeader(MultipartType.OFPMPMETER, taskContext, xid);
1056 mprInput.setMultipartRequestBody(caseBuilder.build());
1057 Future<RpcResult<Void>> resultFromOFLib = getMessageService()
1058 .multipartRequest(mprInput.build(), getCookie());
1059 ListenableFuture<RpcResult<Void>> resultLib = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
1061 Futures.addCallback(resultLib, new ResultCallback<GetAllMeterStatisticsOutput>(result) {
1063 public GetAllMeterStatisticsOutput createResult() {
1064 GetAllMeterStatisticsOutputBuilder allMeterStatBuilder =
1065 new GetAllMeterStatisticsOutputBuilder()
1066 .setTransactionId(new TransactionId(BigInteger.valueOf(xid)));
1067 return allMeterStatBuilder.build();
1078 * @param taskContext
1083 public static OFRpcTask<GetMeterFeaturesInput, RpcResult<GetMeterFeaturesOutput>> createGetMeterFeaturesTask(
1084 final OFRpcTaskContext taskContext, final GetMeterFeaturesInput input,
1085 SwitchConnectionDistinguisher cookie) {
1086 OFRpcTask<GetMeterFeaturesInput, RpcResult<GetMeterFeaturesOutput>> task =
1087 new OFRpcTask<GetMeterFeaturesInput, RpcResult<GetMeterFeaturesOutput>>(taskContext, cookie, input) {
1090 public ListenableFuture<RpcResult<GetMeterFeaturesOutput>> call()
1092 final SettableFuture<RpcResult<GetMeterFeaturesOutput>> result = SettableFuture.create();
1094 if (taskContext.getSession().getPrimaryConductor().getVersion() == OFConstants.OFP_VERSION_1_0) {
1095 RpcResult<GetMeterFeaturesOutput> rpcResult = RpcResultBuilder.success(
1096 new GetMeterFeaturesOutputBuilder().build()).build();
1097 return Futures.immediateFuture(rpcResult);
1099 final Long xid = taskContext.getSession().getNextXid();
1101 MultipartRequestMeterFeaturesCaseBuilder mprMeterFeaturesBuild =
1102 new MultipartRequestMeterFeaturesCaseBuilder();
1104 MultipartRequestInputBuilder mprInput =
1105 createMultipartHeader(MultipartType.OFPMPMETERFEATURES, taskContext, xid);
1106 mprInput.setMultipartRequestBody(mprMeterFeaturesBuild.build());
1107 Future<RpcResult<Void>> resultFromOFLib = getMessageService()
1108 .multipartRequest(mprInput.build(), getCookie());
1109 ListenableFuture<RpcResult<Void>> resultLib = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
1111 Futures.addCallback(resultLib, new ResultCallback<GetMeterFeaturesOutput>(result) {
1113 public GetMeterFeaturesOutput createResult() {
1114 GetMeterFeaturesOutputBuilder meterFeaturesBuilder =
1115 new GetMeterFeaturesOutputBuilder()
1116 .setTransactionId(new TransactionId(BigInteger.valueOf(xid)));
1117 return meterFeaturesBuilder.build();
1128 * @param taskContext
1133 public static OFRpcTask<GetMeterStatisticsInput, RpcResult<GetMeterStatisticsOutput>> createGetMeterStatisticsTask(
1134 final OFRpcTaskContext taskContext, final GetMeterStatisticsInput input,
1135 SwitchConnectionDistinguisher cookie) {
1136 OFRpcTask<GetMeterStatisticsInput, RpcResult<GetMeterStatisticsOutput>> task =
1137 new OFRpcTask<GetMeterStatisticsInput, RpcResult<GetMeterStatisticsOutput>>(taskContext, cookie, input) {
1140 public ListenableFuture<RpcResult<GetMeterStatisticsOutput>> call()
1142 final SettableFuture<RpcResult<GetMeterStatisticsOutput>> result = SettableFuture.create();
1144 if (taskContext.getSession().getPrimaryConductor().getVersion() == OFConstants.OFP_VERSION_1_0) {
1145 RpcResult<GetMeterStatisticsOutput> rpcResult = RpcResultBuilder.success(
1146 new GetMeterStatisticsOutputBuilder().build()).build();
1147 return Futures.immediateFuture(rpcResult);
1149 final Long xid = taskContext.getSession().getNextXid();
1151 MultipartRequestMeterCaseBuilder caseBuilder =
1152 new MultipartRequestMeterCaseBuilder();
1153 MultipartRequestMeterBuilder mprMeterBuild =
1154 new MultipartRequestMeterBuilder();
1155 mprMeterBuild.setMeterId(new MeterId(input.getMeterId().getValue()));
1156 caseBuilder.setMultipartRequestMeter(mprMeterBuild.build());
1158 MultipartRequestInputBuilder mprInput =
1159 createMultipartHeader(MultipartType.OFPMPMETER, taskContext, xid);
1160 mprInput.setMultipartRequestBody(caseBuilder.build());
1161 Future<RpcResult<Void>> resultFromOFLib = getMessageService()
1162 .multipartRequest(mprInput.build(), getCookie());
1163 ListenableFuture<RpcResult<Void>> resultLib = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
1165 Futures.addCallback(resultLib, new ResultCallback<GetMeterStatisticsOutput>(result) {
1167 public GetMeterStatisticsOutput createResult() {
1168 GetMeterStatisticsOutputBuilder meterStatBuilder =
1169 new GetMeterStatisticsOutputBuilder()
1170 .setTransactionId(new TransactionId(BigInteger.valueOf(xid)));
1171 return meterStatBuilder.build();
1182 * @param taskContext
1187 public static OFRpcTask<GetAllNodeConnectorsStatisticsInput, RpcResult<GetAllNodeConnectorsStatisticsOutput>>
1188 createGetAllNodeConnectorsStatisticsTask(
1189 final OFRpcTaskContext taskContext, final GetAllNodeConnectorsStatisticsInput input,
1190 SwitchConnectionDistinguisher cookie) {
1191 OFRpcTask<GetAllNodeConnectorsStatisticsInput, RpcResult<GetAllNodeConnectorsStatisticsOutput>> task =
1192 new OFRpcTask<GetAllNodeConnectorsStatisticsInput, RpcResult<GetAllNodeConnectorsStatisticsOutput>>(taskContext, cookie, input) {
1195 public ListenableFuture<RpcResult<GetAllNodeConnectorsStatisticsOutput>> call()
1197 final SettableFuture<RpcResult<GetAllNodeConnectorsStatisticsOutput>> result = SettableFuture.create();
1199 final Long xid = taskContext.getSession().getNextXid();
1201 MultipartRequestPortStatsCaseBuilder caseBuilder =
1202 new MultipartRequestPortStatsCaseBuilder();
1203 MultipartRequestPortStatsBuilder mprPortStatsBuilder =
1204 new MultipartRequestPortStatsBuilder();
1206 mprPortStatsBuilder.setPortNo(OFConstants.OFPP_ANY);
1207 caseBuilder.setMultipartRequestPortStats(mprPortStatsBuilder.build());
1209 MultipartRequestInputBuilder mprInput =
1210 createMultipartHeader(MultipartType.OFPMPPORTSTATS, taskContext, xid);
1211 mprInput.setMultipartRequestBody(caseBuilder.build());
1212 Future<RpcResult<Void>> resultFromOFLib = getMessageService()
1213 .multipartRequest(mprInput.build(), getCookie());
1214 ListenableFuture<RpcResult<Void>> resultLib = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
1216 Futures.addCallback(resultLib, new ResultCallback<GetAllNodeConnectorsStatisticsOutput>(result) {
1218 public GetAllNodeConnectorsStatisticsOutput createResult() {
1219 GetAllNodeConnectorsStatisticsOutputBuilder allNodeConnectorStatBuilder =
1220 new GetAllNodeConnectorsStatisticsOutputBuilder()
1221 .setTransactionId(new TransactionId(BigInteger.valueOf(xid)));
1222 return allNodeConnectorStatBuilder.build();
1232 * @param taskContext
1237 public static OFRpcTask<GetNodeConnectorStatisticsInput, RpcResult<GetNodeConnectorStatisticsOutput>>
1238 createGetNodeConnectorStatisticsTask(
1239 final OFRpcTaskContext taskContext, final GetNodeConnectorStatisticsInput input,
1240 SwitchConnectionDistinguisher cookie) {
1241 OFRpcTask<GetNodeConnectorStatisticsInput, RpcResult<GetNodeConnectorStatisticsOutput>> task =
1242 new OFRpcTask<GetNodeConnectorStatisticsInput, RpcResult<GetNodeConnectorStatisticsOutput>>(taskContext, cookie, input) {
1245 public ListenableFuture<RpcResult<GetNodeConnectorStatisticsOutput>> call()
1247 final SettableFuture<RpcResult<GetNodeConnectorStatisticsOutput>> result = SettableFuture.create();
1249 final Long xid = taskContext.getSession().getNextXid();
1251 MultipartRequestPortStatsCaseBuilder caseBuilder =
1252 new MultipartRequestPortStatsCaseBuilder();
1253 MultipartRequestPortStatsBuilder mprPortStatsBuilder =
1254 new MultipartRequestPortStatsBuilder();
1255 // Set specific port
1257 .setPortNo(InventoryDataServiceUtil.portNumberfromNodeConnectorId(
1258 OpenflowVersion.get(taskContext.getSession().getFeatures().getVersion()),
1259 input.getNodeConnectorId()));
1260 caseBuilder.setMultipartRequestPortStats(mprPortStatsBuilder.build());
1262 MultipartRequestInputBuilder mprInput =
1263 createMultipartHeader(MultipartType.OFPMPPORTSTATS, taskContext, xid);
1264 mprInput.setMultipartRequestBody(caseBuilder.build());
1265 Future<RpcResult<Void>> resultFromOFLib = getMessageService()
1266 .multipartRequest(mprInput.build(), getCookie());
1267 ListenableFuture<RpcResult<Void>> resultLib = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
1269 Futures.addCallback(resultLib, new ResultCallback<GetNodeConnectorStatisticsOutput>(result) {
1271 public GetNodeConnectorStatisticsOutput createResult() {
1272 GetNodeConnectorStatisticsOutputBuilder allNodeConnectorStatBuilder =
1273 new GetNodeConnectorStatisticsOutputBuilder()
1274 .setTransactionId(new TransactionId(BigInteger.valueOf(xid)));
1275 return allNodeConnectorStatBuilder.build();
1285 * @param taskContext
1290 public static OFRpcTask<GetAllFlowStatisticsFromFlowTableInput, RpcResult<GetAllFlowStatisticsFromFlowTableOutput>>
1291 createGetAllFlowStatisticsFromFlowTableTask(
1292 final OFRpcTaskContext taskContext,
1293 final GetAllFlowStatisticsFromFlowTableInput input,
1294 SwitchConnectionDistinguisher cookie) {
1295 OFRpcTask<GetAllFlowStatisticsFromFlowTableInput, RpcResult<GetAllFlowStatisticsFromFlowTableOutput>> task =
1296 new OFRpcTask<GetAllFlowStatisticsFromFlowTableInput, RpcResult<GetAllFlowStatisticsFromFlowTableOutput>>(taskContext, cookie, input) {
1299 public ListenableFuture<RpcResult<GetAllFlowStatisticsFromFlowTableOutput>> call() throws Exception {
1300 final SettableFuture<RpcResult<GetAllFlowStatisticsFromFlowTableOutput>> result = SettableFuture.create();
1302 final Long xid = taskContext.getSession().getNextXid();
1304 MultipartRequestFlowBuilder mprFlowRequestBuilder = new MultipartRequestFlowBuilder();
1305 mprFlowRequestBuilder.setTableId(input.getTableId().getValue());
1306 mprFlowRequestBuilder.setOutPort(OFConstants.OFPP_ANY);
1307 mprFlowRequestBuilder.setOutGroup(OFConstants.OFPG_ANY);
1308 mprFlowRequestBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
1309 mprFlowRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
1310 FlowCreatorUtil.setWildcardedFlowMatch(taskContext.getSession()
1311 .getPrimaryConductor().getVersion(), mprFlowRequestBuilder);
1313 MultipartRequestFlowCaseBuilder multipartRequestFlowCaseBuilder = new MultipartRequestFlowCaseBuilder();
1314 multipartRequestFlowCaseBuilder.setMultipartRequestFlow(mprFlowRequestBuilder.build());
1316 MultipartRequestInputBuilder mprInput =
1317 createMultipartHeader(MultipartType.OFPMPFLOW, taskContext, xid);
1318 mprInput.setMultipartRequestBody(multipartRequestFlowCaseBuilder.build());
1319 Future<RpcResult<Void>> resultFromOFLib = getMessageService()
1320 .multipartRequest(mprInput.build(), getCookie());
1321 ListenableFuture<RpcResult<Void>> resultLib = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
1323 Futures.addCallback(resultLib, new ResultCallback<GetAllFlowStatisticsFromFlowTableOutput>(result) {
1325 public GetAllFlowStatisticsFromFlowTableOutput createResult() {
1326 GetAllFlowStatisticsFromFlowTableOutputBuilder allFlowStatsFromFlowTableBuilder =
1327 new GetAllFlowStatisticsFromFlowTableOutputBuilder()
1328 .setTransactionId(new TransactionId(BigInteger.valueOf(xid)));
1329 return allFlowStatsFromFlowTableBuilder.build();
1339 * @param taskContext
1344 public static OFRpcTask<GetAllFlowsStatisticsFromAllFlowTablesInput, RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput>>
1345 createGetAllFlowsStatisticsFromAllFlowTablesTask(
1346 final OFRpcTaskContext taskContext,
1347 final GetAllFlowsStatisticsFromAllFlowTablesInput input,
1348 SwitchConnectionDistinguisher cookie) {
1349 OFRpcTask<GetAllFlowsStatisticsFromAllFlowTablesInput,
1350 RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput>> task =
1351 new OFRpcTask<GetAllFlowsStatisticsFromAllFlowTablesInput,
1352 RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput>>(taskContext, cookie, input) {
1355 public ListenableFuture<RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput>> call() throws Exception {
1356 final SettableFuture<RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput>> result = SettableFuture.create();
1358 final Long xid = taskContext.getSession().getNextXid();
1360 // Create multipart request body for fetch all the group stats
1361 MultipartRequestFlowCaseBuilder multipartRequestFlowCaseBuilder =
1362 new MultipartRequestFlowCaseBuilder();
1363 MultipartRequestFlowBuilder mprFlowRequestBuilder =
1364 new MultipartRequestFlowBuilder();
1365 mprFlowRequestBuilder.setTableId(OFConstants.OFPTT_ALL);
1366 mprFlowRequestBuilder.setOutPort(OFConstants.OFPP_ANY);
1367 mprFlowRequestBuilder.setOutGroup(OFConstants.OFPG_ANY);
1368 mprFlowRequestBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
1369 mprFlowRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
1370 FlowCreatorUtil.setWildcardedFlowMatch(taskContext.getSession()
1371 .getPrimaryConductor().getVersion(), mprFlowRequestBuilder);
1373 MultipartRequestInputBuilder mprInput =
1374 createMultipartHeader(MultipartType.OFPMPFLOW, taskContext, xid);
1375 multipartRequestFlowCaseBuilder.setMultipartRequestFlow(mprFlowRequestBuilder.build());
1376 mprInput.setMultipartRequestBody(multipartRequestFlowCaseBuilder.build());
1377 Future<RpcResult<Void>> resultFromOFLib = getMessageService()
1378 .multipartRequest(mprInput.build(), getCookie());
1379 ListenableFuture<RpcResult<Void>> resultLib = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
1381 Futures.addCallback(resultLib, new ResultCallback<GetAllFlowsStatisticsFromAllFlowTablesOutput>(result) {
1383 public GetAllFlowsStatisticsFromAllFlowTablesOutput createResult() {
1384 GetAllFlowsStatisticsFromAllFlowTablesOutputBuilder allFlowStatsFromAllFlowTableBuilder =
1385 new GetAllFlowsStatisticsFromAllFlowTablesOutputBuilder()
1386 .setTransactionId(new TransactionId(BigInteger.valueOf(xid)));
1387 return allFlowStatsFromAllFlowTableBuilder.build();
1397 * @param taskContext
1402 public static OFRpcTask<GetFlowStatisticsFromFlowTableInput, RpcResult<GetFlowStatisticsFromFlowTableOutput>>
1403 createGetFlowStatisticsFromFlowTableTask(
1404 final OFRpcTaskContext taskContext,
1405 final GetFlowStatisticsFromFlowTableInput input, SwitchConnectionDistinguisher cookie) {
1406 OFRpcTask<GetFlowStatisticsFromFlowTableInput, RpcResult<GetFlowStatisticsFromFlowTableOutput>> task =
1407 new OFRpcTask<GetFlowStatisticsFromFlowTableInput, RpcResult<GetFlowStatisticsFromFlowTableOutput>>(taskContext, cookie, input) {
1410 public ListenableFuture<RpcResult<GetFlowStatisticsFromFlowTableOutput>> call() throws Exception {
1411 final SettableFuture<RpcResult<GetFlowStatisticsFromFlowTableOutput>> result = SettableFuture.create();
1413 final Long xid = taskContext.getSession().getNextXid();
1415 // Create multipart request body for fetch all the group stats
1416 MultipartRequestFlowCaseBuilder multipartRequestFlowCaseBuilder = new MultipartRequestFlowCaseBuilder();
1417 MultipartRequestFlowBuilder mprFlowRequestBuilder = new MultipartRequestFlowBuilder();
1418 mprFlowRequestBuilder.setTableId(input.getTableId());
1420 if (input.getOutPort() != null)
1421 mprFlowRequestBuilder.setOutPort(input.getOutPort().longValue());
1423 mprFlowRequestBuilder.setOutPort(OFConstants.OFPP_ANY);
1425 if (input.getOutGroup() != null)
1426 mprFlowRequestBuilder.setOutGroup(input.getOutGroup());
1428 mprFlowRequestBuilder.setOutGroup(OFConstants.OFPG_ANY);
1430 if (input.getCookie() != null)
1431 mprFlowRequestBuilder.setCookie(input.getCookie().getValue());
1433 mprFlowRequestBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
1435 if (input.getCookieMask() != null)
1436 mprFlowRequestBuilder.setCookieMask(input.getCookieMask().getValue());
1438 mprFlowRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
1440 // convert and inject match
1441 MatchReactor.getInstance().convert(input.getMatch(), taskContext.getSession()
1442 .getPrimaryConductor().getVersion(), mprFlowRequestBuilder,
1443 taskContext.getSession().getFeatures().getDatapathId());
1445 // Set request body to main multipart request
1446 multipartRequestFlowCaseBuilder.setMultipartRequestFlow(mprFlowRequestBuilder.build());
1447 MultipartRequestInputBuilder mprInput =
1448 createMultipartHeader(MultipartType.OFPMPFLOW, taskContext, xid);
1449 mprInput.setMultipartRequestBody(multipartRequestFlowCaseBuilder.build());
1450 Future<RpcResult<Void>> resultFromOFLib = getMessageService()
1451 .multipartRequest(mprInput.build(), getCookie());
1452 ListenableFuture<RpcResult<Void>> resultLib = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
1454 Futures.addCallback(resultLib, new ResultCallback<GetFlowStatisticsFromFlowTableOutput>(result) {
1456 public GetFlowStatisticsFromFlowTableOutput createResult() {
1457 GetFlowStatisticsFromFlowTableOutputBuilder flowStatsFromFlowTableBuilder =
1458 new GetFlowStatisticsFromFlowTableOutputBuilder()
1459 .setTransactionId(new TransactionId(BigInteger.valueOf(xid)));
1460 return flowStatsFromFlowTableBuilder.build();
1470 * @param taskContext
1475 public static OFRpcTask<GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput, RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>>
1476 createGetAggregateFlowStatisticsFromFlowTableForAllFlowsTask(
1477 final OFRpcTaskContext taskContext,
1478 final GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput input, SwitchConnectionDistinguisher cookie) {
1479 OFRpcTask<GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput, RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>> task =
1480 new OFRpcTask<GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput, RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>>(taskContext, cookie, input) {
1483 public ListenableFuture<RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>> call() throws Exception {
1484 final SettableFuture<RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>> result = SettableFuture.create();
1486 final Long xid = taskContext.getSession().getNextXid();
1488 // Create multipart request body for fetch all the group stats
1489 MultipartRequestAggregateCaseBuilder multipartRequestAggregateCaseBuilder = new MultipartRequestAggregateCaseBuilder();
1490 MultipartRequestAggregateBuilder mprAggregateRequestBuilder = new MultipartRequestAggregateBuilder();
1491 mprAggregateRequestBuilder.setTableId(input.getTableId().getValue());
1492 mprAggregateRequestBuilder.setOutPort(OFConstants.OFPP_ANY);
1493 mprAggregateRequestBuilder.setOutGroup(OFConstants.OFPG_ANY);
1494 mprAggregateRequestBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
1495 mprAggregateRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
1497 FlowCreatorUtil.setWildcardedFlowMatch(taskContext.getSession()
1498 .getPrimaryConductor().getVersion(), mprAggregateRequestBuilder);
1500 // Set request body to main multipart request
1501 multipartRequestAggregateCaseBuilder.setMultipartRequestAggregate(mprAggregateRequestBuilder.build());
1502 MultipartRequestInputBuilder mprInput =
1503 createMultipartHeader(MultipartType.OFPMPAGGREGATE, taskContext, xid);
1504 mprInput.setMultipartRequestBody(multipartRequestAggregateCaseBuilder.build());
1505 Future<RpcResult<Void>> resultFromOFLib = getMessageService()
1506 .multipartRequest(mprInput.build(), getCookie());
1507 ListenableFuture<RpcResult<Void>> resultLib = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
1509 Futures.addCallback(resultLib, new ResultCallback<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>(result) {
1511 public GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput createResult() {
1512 GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutputBuilder flowStatsFromFlowTableBuilder =
1513 new GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutputBuilder()
1514 .setTransactionId(new TransactionId(BigInteger.valueOf(xid)));
1515 return flowStatsFromFlowTableBuilder.build();
1525 * @param taskContext
1530 public static OFRpcTask<GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput, RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>>
1531 createGetAggregateFlowStatisticsFromFlowTableForGivenMatchTask(
1532 final OFRpcTaskContext taskContext,
1533 final GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput input, SwitchConnectionDistinguisher cookie) {
1534 OFRpcTask<GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput, RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>> task =
1535 new OFRpcTask<GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput, RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>>(taskContext, cookie, input) {
1538 public ListenableFuture<RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>> call() throws Exception {
1539 final SettableFuture<RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>> result = SettableFuture.create();
1541 final Long xid = taskContext.getSession().getNextXid();
1543 MultipartRequestAggregateCaseBuilder multipartRequestAggregateCaseBuilder = new MultipartRequestAggregateCaseBuilder();
1544 MultipartRequestAggregateBuilder mprAggregateRequestBuilder = new MultipartRequestAggregateBuilder();
1545 mprAggregateRequestBuilder.setTableId(input.getTableId());
1546 mprAggregateRequestBuilder.setOutPort(input.getOutPort().longValue());
1547 // TODO: repeating code
1548 if (taskContext.getSession().getPrimaryConductor().getVersion() ==
1549 OFConstants.OFP_VERSION_1_3) {
1550 mprAggregateRequestBuilder.setCookie(input.getCookie().getValue());
1551 mprAggregateRequestBuilder.setCookieMask(input.getCookieMask().getValue());
1552 mprAggregateRequestBuilder.setOutGroup(input.getOutGroup());
1554 mprAggregateRequestBuilder.setOutGroup(OFConstants.OFPG_ANY);
1555 mprAggregateRequestBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
1556 mprAggregateRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
1559 MatchReactor.getInstance().convert(input.getMatch(), taskContext.getSession()
1560 .getPrimaryConductor().getVersion(), mprAggregateRequestBuilder,
1561 taskContext.getSession().getFeatures().getDatapathId());
1563 FlowCreatorUtil.setWildcardedFlowMatch(taskContext.getSession()
1564 .getPrimaryConductor().getVersion(), mprAggregateRequestBuilder);
1566 // Set request body to main multipart request
1567 multipartRequestAggregateCaseBuilder.setMultipartRequestAggregate(mprAggregateRequestBuilder.build());
1568 MultipartRequestInputBuilder mprInput =
1569 createMultipartHeader(MultipartType.OFPMPAGGREGATE, taskContext, xid);
1570 mprInput.setMultipartRequestBody(multipartRequestAggregateCaseBuilder.build());
1571 Future<RpcResult<Void>> resultFromOFLib = getMessageService()
1572 .multipartRequest(mprInput.build(), getCookie());
1573 ListenableFuture<RpcResult<Void>> resultLib = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
1575 Futures.addCallback(resultLib, new ResultCallback<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>(result) {
1577 public GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput createResult() {
1578 GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder aggregFlowStatsFromFlowTableBuilder =
1579 new GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder()
1580 .setTransactionId(new TransactionId(BigInteger.valueOf(xid)));
1581 return aggregFlowStatsFromFlowTableBuilder.build();
1591 * @param taskContext
1596 public static OFRpcTask<GetFlowTablesStatisticsInput, RpcResult<GetFlowTablesStatisticsOutput>> createGetFlowTablesStatisticsTask(
1597 final OFRpcTaskContext taskContext, final GetFlowTablesStatisticsInput input, SwitchConnectionDistinguisher cookie) {
1598 OFRpcTask<GetFlowTablesStatisticsInput, RpcResult<GetFlowTablesStatisticsOutput>> task =
1599 new OFRpcTask<GetFlowTablesStatisticsInput, RpcResult<GetFlowTablesStatisticsOutput>>(taskContext, cookie, input) {
1602 public ListenableFuture<RpcResult<GetFlowTablesStatisticsOutput>> call() throws Exception {
1603 final SettableFuture<RpcResult<GetFlowTablesStatisticsOutput>> result = SettableFuture.create();
1605 final Long xid = taskContext.getSession().getNextXid();
1607 // Create multipart request body for fetch all the group stats
1608 MultipartRequestTableCaseBuilder multipartRequestTableCaseBuilder = new MultipartRequestTableCaseBuilder();
1609 MultipartRequestTableBuilder multipartRequestTableBuilder = new MultipartRequestTableBuilder();
1610 multipartRequestTableBuilder.setEmpty(true);
1611 multipartRequestTableCaseBuilder.setMultipartRequestTable(multipartRequestTableBuilder.build());
1613 // Set request body to main multipart request
1614 MultipartRequestInputBuilder mprInput =
1615 createMultipartHeader(MultipartType.OFPMPTABLE, taskContext, xid);
1616 mprInput.setMultipartRequestBody(multipartRequestTableCaseBuilder.build());
1617 Future<RpcResult<Void>> resultFromOFLib = getMessageService()
1618 .multipartRequest(mprInput.build(), getCookie());
1619 ListenableFuture<RpcResult<Void>> resultLib = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
1621 Futures.addCallback(resultLib, new ResultCallback<GetFlowTablesStatisticsOutput>(result) {
1623 public GetFlowTablesStatisticsOutput createResult() {
1624 GetFlowTablesStatisticsOutputBuilder flowTableStatsBuilder =
1625 new GetFlowTablesStatisticsOutputBuilder()
1626 .setTransactionId(new TransactionId(BigInteger.valueOf(xid)));
1627 return flowTableStatsBuilder.build();
1637 * @param taskContext
1642 public static OFRpcTask<GetAllQueuesStatisticsFromAllPortsInput, RpcResult<GetAllQueuesStatisticsFromAllPortsOutput>> createGetAllQueuesStatisticsFromAllPortsTask(
1643 final OFRpcTaskContext taskContext, final GetAllQueuesStatisticsFromAllPortsInput input, SwitchConnectionDistinguisher cookie) {
1644 OFRpcTask<GetAllQueuesStatisticsFromAllPortsInput, RpcResult<GetAllQueuesStatisticsFromAllPortsOutput>> task =
1645 new OFRpcTask<GetAllQueuesStatisticsFromAllPortsInput, RpcResult<GetAllQueuesStatisticsFromAllPortsOutput>>(taskContext, cookie, input) {
1648 public ListenableFuture<RpcResult<GetAllQueuesStatisticsFromAllPortsOutput>> call() throws Exception {
1649 final SettableFuture<RpcResult<GetAllQueuesStatisticsFromAllPortsOutput>> result = SettableFuture.create();
1651 final Long xid = taskContext.getSession().getNextXid();
1653 MultipartRequestQueueCaseBuilder caseBuilder = new MultipartRequestQueueCaseBuilder();
1654 MultipartRequestQueueBuilder mprQueueBuilder = new MultipartRequestQueueBuilder();
1656 mprQueueBuilder.setPortNo(OFConstants.OFPP_ANY);
1657 // Select all the ports
1658 mprQueueBuilder.setQueueId(OFConstants.OFPQ_ANY);
1659 caseBuilder.setMultipartRequestQueue(mprQueueBuilder.build());
1661 // Set request body to main multipart request
1662 MultipartRequestInputBuilder mprInput =
1663 createMultipartHeader(MultipartType.OFPMPQUEUE, taskContext, xid);
1664 mprInput.setMultipartRequestBody(caseBuilder.build());
1665 Future<RpcResult<Void>> resultFromOFLib = getMessageService()
1666 .multipartRequest(mprInput.build(), getCookie());
1667 ListenableFuture<RpcResult<Void>> resultLib = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
1669 Futures.addCallback(resultLib, new ResultCallback<GetAllQueuesStatisticsFromAllPortsOutput>(result) {
1671 public GetAllQueuesStatisticsFromAllPortsOutput createResult() {
1672 GetAllQueuesStatisticsFromAllPortsOutputBuilder allQueueStatsBuilder =
1673 new GetAllQueuesStatisticsFromAllPortsOutputBuilder()
1674 .setTransactionId(new TransactionId(BigInteger.valueOf(xid)));
1675 return allQueueStatsBuilder.build();
1685 * @param taskContext
1690 public static OFRpcTask<GetAllQueuesStatisticsFromGivenPortInput, RpcResult<GetAllQueuesStatisticsFromGivenPortOutput>> createGetAllQueuesStatisticsFromGivenPortTask(
1691 final OFRpcTaskContext taskContext, final GetAllQueuesStatisticsFromGivenPortInput input, SwitchConnectionDistinguisher cookie) {
1692 OFRpcTask<GetAllQueuesStatisticsFromGivenPortInput, RpcResult<GetAllQueuesStatisticsFromGivenPortOutput>> task =
1693 new OFRpcTask<GetAllQueuesStatisticsFromGivenPortInput, RpcResult<GetAllQueuesStatisticsFromGivenPortOutput>>(taskContext, cookie, input) {
1696 public ListenableFuture<RpcResult<GetAllQueuesStatisticsFromGivenPortOutput>> call() throws Exception {
1697 final SettableFuture<RpcResult<GetAllQueuesStatisticsFromGivenPortOutput>> result = SettableFuture.create();
1699 final Long xid = taskContext.getSession().getNextXid();
1701 MultipartRequestQueueCaseBuilder caseBuilder = new MultipartRequestQueueCaseBuilder();
1702 MultipartRequestQueueBuilder mprQueueBuilder = new MultipartRequestQueueBuilder();
1703 // Select all queues
1704 mprQueueBuilder.setQueueId(OFConstants.OFPQ_ANY);
1705 // Select specific port
1706 mprQueueBuilder.setPortNo(InventoryDataServiceUtil.portNumberfromNodeConnectorId(
1707 OpenflowVersion.get(taskContext.getSession().getFeatures().getVersion()),
1708 input.getNodeConnectorId()));
1709 caseBuilder.setMultipartRequestQueue(mprQueueBuilder.build());
1711 // Set request body to main multipart request
1712 MultipartRequestInputBuilder mprInput =
1713 createMultipartHeader(MultipartType.OFPMPQUEUE, taskContext, xid);
1714 mprInput.setMultipartRequestBody(caseBuilder.build());
1715 Future<RpcResult<Void>> resultFromOFLib = getMessageService()
1716 .multipartRequest(mprInput.build(), getCookie());
1717 ListenableFuture<RpcResult<Void>> resultLib = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
1719 Futures.addCallback(resultLib, new ResultCallback<GetAllQueuesStatisticsFromGivenPortOutput>(result) {
1721 public GetAllQueuesStatisticsFromGivenPortOutput createResult() {
1722 GetAllQueuesStatisticsFromGivenPortOutputBuilder allQueueStatsBuilder =
1723 new GetAllQueuesStatisticsFromGivenPortOutputBuilder()
1724 .setTransactionId(new TransactionId(BigInteger.valueOf(xid)));
1725 return allQueueStatsBuilder.build();
1735 * @param taskContext
1740 public static OFRpcTask<GetQueueStatisticsFromGivenPortInput, RpcResult<GetQueueStatisticsFromGivenPortOutput>> createGetQueueStatisticsFromGivenPortTask(
1741 final OFRpcTaskContext taskContext, final GetQueueStatisticsFromGivenPortInput input, SwitchConnectionDistinguisher cookie) {
1742 OFRpcTask<GetQueueStatisticsFromGivenPortInput, RpcResult<GetQueueStatisticsFromGivenPortOutput>> task =
1743 new OFRpcTask<GetQueueStatisticsFromGivenPortInput, RpcResult<GetQueueStatisticsFromGivenPortOutput>>(taskContext, cookie, input) {
1746 public ListenableFuture<RpcResult<GetQueueStatisticsFromGivenPortOutput>> call() throws Exception {
1747 final SettableFuture<RpcResult<GetQueueStatisticsFromGivenPortOutput>> result = SettableFuture.create();
1749 final Long xid = taskContext.getSession().getNextXid();
1751 MultipartRequestQueueCaseBuilder caseBuilder = new MultipartRequestQueueCaseBuilder();
1752 MultipartRequestQueueBuilder mprQueueBuilder = new MultipartRequestQueueBuilder();
1753 // Select specific queue
1754 mprQueueBuilder.setQueueId(input.getQueueId().getValue());
1755 // Select specific port
1756 mprQueueBuilder.setPortNo(InventoryDataServiceUtil.portNumberfromNodeConnectorId(
1757 OpenflowVersion.get(taskContext.getSession().getFeatures().getVersion()),
1758 input.getNodeConnectorId()));
1759 caseBuilder.setMultipartRequestQueue(mprQueueBuilder.build());
1761 // Set request body to main multipart request
1762 MultipartRequestInputBuilder mprInput =
1763 createMultipartHeader(MultipartType.OFPMPQUEUE, taskContext, xid);
1764 mprInput.setMultipartRequestBody(caseBuilder.build());
1765 Future<RpcResult<Void>> resultFromOFLib = getMessageService()
1766 .multipartRequest(mprInput.build(), getCookie());
1767 ListenableFuture<RpcResult<Void>> resultLib = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
1769 Futures.addCallback(resultLib, new ResultCallback<GetQueueStatisticsFromGivenPortOutput>(result) {
1771 public GetQueueStatisticsFromGivenPortOutput createResult() {
1772 GetQueueStatisticsFromGivenPortOutputBuilder queueStatsFromPortBuilder =
1773 new GetQueueStatisticsFromGivenPortOutputBuilder()
1774 .setTransactionId(new TransactionId(BigInteger.valueOf(xid)));
1775 return queueStatsFromPortBuilder.build();
1784 static MultipartRequestInputBuilder createMultipartHeader(MultipartType multipart,
1785 OFRpcTaskContext taskContext, Long xid) {
1786 MultipartRequestInputBuilder mprInput = new MultipartRequestInputBuilder();
1787 mprInput.setType(multipart);
1788 mprInput.setVersion(taskContext.getSession().getPrimaryConductor().getVersion());
1789 mprInput.setXid(xid);
1790 mprInput.setFlags(new MultipartRequestFlags(false));
1794 private static abstract class ResultCallback<T> implements FutureCallback<RpcResult<Void>> {
1796 private SettableFuture<RpcResult<T>> result;
1801 public ResultCallback(SettableFuture<RpcResult<T>> result) {
1802 this.result = result;
1805 public abstract T createResult();
1808 public void onSuccess(RpcResult<Void> resultArg) {
1809 result.set(RpcResultBuilder.success(createResult()).build());
1813 public void onFailure(Throwable t) {
1814 result.set(RpcResultBuilder.<T>failed().withWarning(
1816 OFConstants.ERROR_TAG_TIMEOUT,
1817 "something wrong happened",
1818 OFConstants.APPLICATION_TAG,
1824 * @param taskContext
1829 public static OFRpcTask<UpdatePortInput, RpcResult<UpdatePortOutput>> createUpdatePortTask(
1830 final OFRpcTaskContext taskContext, final UpdatePortInput input,
1831 final SwitchConnectionDistinguisher cookie) {
1832 OFRpcTask<UpdatePortInput, RpcResult<UpdatePortOutput>> task =
1833 new OFRpcTask<UpdatePortInput, RpcResult<UpdatePortOutput>>(taskContext, cookie, input) {
1836 public ListenableFuture<RpcResult<UpdatePortOutput>> call() {
1837 ListenableFuture<RpcResult<UpdatePortOutput>> result = SettableFuture.create();
1838 final Long xid = taskContext.getSession().getNextXid();
1839 Port inputPort = input.getUpdatedPort().getPort().getPort().get(0);
1841 PortModInput ofPortModInput = PortConvertor.toPortModInput(inputPort,
1842 taskContext.getSession().getPrimaryConductor().getVersion());
1844 PortModInputBuilder mdInput = new PortModInputBuilder(ofPortModInput);
1845 mdInput.setXid(xid);
1847 Future<RpcResult<UpdatePortOutput>> resultFromOFLib = getMessageService()
1848 .portMod(mdInput.build(), cookie);
1849 result = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
1860 * @param taskContext
1865 public static OFRpcTask<UpdateTableInput, RpcResult<UpdateTableOutput>> createUpdateTableTask(
1866 final OFRpcTaskContext taskContext, final UpdateTableInput input,
1867 final SwitchConnectionDistinguisher cookie) {
1868 OFRpcTask<UpdateTableInput, RpcResult<UpdateTableOutput>> task =
1869 new OFRpcTask<UpdateTableInput, RpcResult<UpdateTableOutput>>(taskContext, cookie, input) {
1872 public ListenableFuture<RpcResult<UpdateTableOutput>> call() {
1873 final SettableFuture<RpcResult<UpdateTableOutput>> result = SettableFuture.create();
1875 final Long xid = taskContext.getSession().getNextXid();
1877 MultipartRequestTableFeaturesCaseBuilder caseBuilder = new MultipartRequestTableFeaturesCaseBuilder();
1878 MultipartRequestTableFeaturesBuilder requestBuilder = new MultipartRequestTableFeaturesBuilder();
1879 List<TableFeatures> ofTableFeatureList = TableFeaturesConvertor
1880 .toTableFeaturesRequest(input.getUpdatedTable());
1881 requestBuilder.setTableFeatures(ofTableFeatureList);
1882 caseBuilder.setMultipartRequestTableFeatures(requestBuilder.build());
1884 // Set request body to main multipart request
1885 MultipartRequestInputBuilder mprInput =
1886 createMultipartHeader(MultipartType.OFPMPTABLEFEATURES, taskContext, xid);
1887 mprInput.setMultipartRequestBody(caseBuilder.build());
1889 Future<RpcResult<Void>> resultFromOFLib = getMessageService()
1890 .multipartRequest(mprInput.build(), getCookie());
1891 ListenableFuture<RpcResult<Void>> resultLib = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
1893 Futures.addCallback(resultLib, new ResultCallback<UpdateTableOutput>(result) {
1895 public UpdateTableOutput createResult() {
1896 UpdateTableOutputBuilder queueStatsFromPortBuilder =
1897 new UpdateTableOutputBuilder()
1898 .setTransactionId(new TransactionId(BigInteger.valueOf(xid)));
1899 return queueStatsFromPortBuilder.build();
1908 public static OFRpcTask<SetConfigInput, RpcResult<SetConfigOutput>> createSetNodeConfigTask(final OFRpcTaskContext taskContext,
1909 final SetConfigInput input,
1910 final SwitchConnectionDistinguisher cookie) {
1911 OFRpcTask<SetConfigInput, RpcResult<SetConfigOutput>> rpcTask = new OFRpcTask<SetConfigInput, RpcResult<SetConfigOutput>>(taskContext, cookie, input) {
1913 public ListenableFuture<RpcResult<SetConfigOutput>> call() throws Exception {
1915 final SettableFuture<RpcResult<SetConfigOutput>> result = SettableFuture.create();
1916 final Long xid = taskContext.getSession().getNextXid();
1918 SetConfigInputBuilder builder = new SetConfigInputBuilder();
1919 SwitchConfigFlag flag = SwitchConfigFlag.valueOf(input.getFlag());
1920 builder.setXid(xid);
1921 builder.setFlags(flag);
1922 builder.setMissSendLen(input.getMissSearchLength());
1923 builder.setVersion(getVersion());
1924 ListenableFuture<RpcResult<Void>> resultLib = JdkFutureAdapters.listenInPoolThread(taskContext.getSession().getPrimaryConductor().getConnectionAdapter().setConfig(builder.build()));
1925 Futures.addCallback(resultLib, new ResultCallback<SetConfigOutput>(result) {
1927 public SetConfigOutput createResult() {
1928 SetConfigOutputBuilder setConfigOutputBuilder = new SetConfigOutputBuilder();
1929 setConfigOutputBuilder.setTransactionId(new TransactionId(BigInteger.valueOf(xid)));
1930 return setConfigOutputBuilder.build();