2 * Copyright (c) 2013 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.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutputBuilder;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableInput;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableOutput;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableOutputBuilder;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesInput;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesOutput;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesOutputBuilder;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableInput;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableOutput;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableOutputBuilder;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsInput;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsOutput;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsOutputBuilder;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionId;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.Port;
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow;
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInput;
67 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.GroupAdded;
68 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.GroupAddedBuilder;
69 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.GroupRemoved;
70 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.GroupRemovedBuilder;
71 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.GroupUpdated;
72 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.GroupUpdatedBuilder;
73 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInput;
74 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupInput;
75 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupOutput;
76 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsInput;
77 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsOutput;
78 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsOutputBuilder;
79 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupDescriptionInput;
80 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupDescriptionOutput;
81 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupDescriptionOutputBuilder;
82 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupFeaturesInput;
83 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupFeaturesOutput;
84 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupFeaturesOutputBuilder;
85 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupStatisticsInput;
86 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupStatisticsOutput;
87 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupStatisticsOutputBuilder;
88 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group;
89 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterInput;
90 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.MeterAdded;
91 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.MeterAddedBuilder;
92 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.MeterRemoved;
93 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.MeterRemovedBuilder;
94 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.MeterUpdated;
95 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.MeterUpdatedBuilder;
96 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterInput;
97 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterInput;
98 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterOutput;
99 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsInput;
100 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsOutput;
101 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsOutputBuilder;
102 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterStatisticsInput;
103 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterStatisticsOutput;
104 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterStatisticsOutputBuilder;
105 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterFeaturesInput;
106 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterFeaturesOutput;
107 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterFeaturesOutputBuilder;
108 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsInput;
109 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsOutput;
110 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsOutputBuilder;
111 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.Meter;
112 import org.opendaylight.yang.gen.v1.urn.opendaylight.module.config.rev141015.SetConfigInput;
113 import org.opendaylight.yang.gen.v1.urn.opendaylight.module.config.rev141015.SetConfigOutput;
114 import org.opendaylight.yang.gen.v1.urn.opendaylight.module.config.rev141015.SetConfigOutputBuilder;
115 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId;
116 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId;
117 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags;
118 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
119 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.SwitchConfigFlag;
120 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInputBuilder;
121 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInputBuilder;
122 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInputBuilder;
123 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
124 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput;
125 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInputBuilder;
126 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInputBuilder;
127 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestAggregateCaseBuilder;
128 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlowCaseBuilder;
129 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupCaseBuilder;
130 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupDescCaseBuilder;
131 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupFeaturesCaseBuilder;
132 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterCaseBuilder;
133 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterConfigCaseBuilder;
134 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterFeaturesCaseBuilder;
135 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortStatsCaseBuilder;
136 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestQueueCaseBuilder;
137 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableCaseBuilder;
138 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableFeaturesCaseBuilder;
139 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.aggregate._case.MultipartRequestAggregateBuilder;
140 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.flow._case.MultipartRequestFlowBuilder;
141 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.group._case.MultipartRequestGroupBuilder;
142 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.meter._case.MultipartRequestMeterBuilder;
143 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.meter.config._case.MultipartRequestMeterConfigBuilder;
144 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.port.stats._case.MultipartRequestPortStatsBuilder;
145 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.queue._case.MultipartRequestQueueBuilder;
146 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table._case.MultipartRequestTableBuilder;
147 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.MultipartRequestTableFeaturesBuilder;
148 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;
149 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.UpdatePortInput;
150 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.UpdatePortOutput;
151 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllNodeConnectorsStatisticsInput;
152 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllNodeConnectorsStatisticsOutput;
153 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllNodeConnectorsStatisticsOutputBuilder;
154 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetNodeConnectorStatisticsInput;
155 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetNodeConnectorStatisticsOutput;
156 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetNodeConnectorStatisticsOutputBuilder;
157 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromAllPortsInput;
158 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromAllPortsOutput;
159 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromAllPortsOutputBuilder;
160 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromGivenPortInput;
161 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromGivenPortOutput;
162 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromGivenPortOutputBuilder;
163 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetQueueStatisticsFromGivenPortInput;
164 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetQueueStatisticsFromGivenPortOutput;
165 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetQueueStatisticsFromGivenPortOutputBuilder;
166 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableInput;
167 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableOutput;
168 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableOutputBuilder;
169 import org.opendaylight.yangtools.yang.common.RpcError.ErrorType;
170 import org.opendaylight.yangtools.yang.common.RpcResult;
171 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
172 import org.slf4j.Logger;
173 import org.slf4j.LoggerFactory;
178 public abstract class OFRpcTaskFactory {
179 protected static final Logger logger = LoggerFactory.getLogger(OFRpcTaskFactory.class);
185 * @return UpdateFlow task
187 public static OFRpcTask<AddFlowInput, RpcResult<UpdateFlowOutput>> createAddFlowTask(
188 OFRpcTaskContext taskContext, AddFlowInput input,
189 SwitchConnectionDistinguisher cookie) {
190 OFRpcTask<AddFlowInput, RpcResult<UpdateFlowOutput>> task =
191 new OFRpcTask<AddFlowInput, RpcResult<UpdateFlowOutput>>(taskContext, cookie, input) {
194 public ListenableFuture<RpcResult<UpdateFlowOutput>> call() {
195 ListenableFuture<RpcResult<UpdateFlowOutput>> result = SettableFuture.create();
197 // Convert the AddFlowInput to FlowModInput
198 List<FlowModInputBuilder> ofFlowModInputs = FlowConvertor.toFlowModInputs(getInput(),
199 getVersion(), getSession().getFeatures().getDatapathId());
201 logger.debug("Number of flows to push to switch: {}", ofFlowModInputs.size());
203 result = chainFlowMods(ofFlowModInputs, 0, getTaskContext(), getCookie());
206 result = OFRpcTaskUtil.chainFutureBarrier(this, result);
207 OFRpcTaskUtil.hookFutureNotification(this, result,
208 getRpcNotificationProviderService(),
209 createFlowAddedNotification(getInput()));
214 public Boolean isBarrier() {
215 return getInput().isBarrier();
222 * Recursive helper method for {@link OFRpcTaskFactory#createAddFlowTask()}
223 * and {@link OFRpcTaskFactory#createUpdateFlowTask()} to chain results
224 * of multiple flowmods.
225 * The next flowmod gets executed if the earlier one is successful.
226 * All the flowmods should have the same xid, in-order to cross-reference
229 protected static ListenableFuture<RpcResult<UpdateFlowOutput>> chainFlowMods(
230 final List<FlowModInputBuilder> ofFlowModInputs, final int index,
231 final OFRpcTaskContext taskContext, final SwitchConnectionDistinguisher cookie) {
233 Future<RpcResult<UpdateFlowOutput>> resultFromOFLib =
234 createResultForFlowMod(taskContext, ofFlowModInputs.get(index), cookie);
236 ListenableFuture<RpcResult<UpdateFlowOutput>> result = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
238 if (ofFlowModInputs.size() > index + 1) {
239 // there are more flowmods to chain
240 return Futures.transform(result,
241 new AsyncFunction<RpcResult<UpdateFlowOutput>, RpcResult<UpdateFlowOutput>>() {
243 public ListenableFuture<RpcResult<UpdateFlowOutput>> apply(RpcResult<UpdateFlowOutput> input) throws Exception {
244 if (input.isSuccessful()) {
245 return chainFlowMods(ofFlowModInputs, index + 1, taskContext, cookie);
247 logger.warn("Flowmod failed. Any chained flowmods are ignored. xid:{}",
248 ofFlowModInputs.get(index).getXid());
249 return Futures.immediateFuture(input);
259 private static Future<RpcResult<UpdateFlowOutput>> createResultForFlowMod(
260 OFRpcTaskContext taskContext, FlowModInputBuilder flowModInput,
261 SwitchConnectionDistinguisher cookie) {
262 flowModInput.setXid(taskContext.getSession().getNextXid());
263 return taskContext.getMessageService().flowMod(flowModInput.build(), cookie);
271 protected static NotificationComposer<FlowAdded> createFlowAddedNotification(
272 final AddFlowInput input) {
273 return new NotificationComposer<FlowAdded>() {
275 public FlowAdded compose(TransactionId tXid) {
276 FlowAddedBuilder newFlow = new FlowAddedBuilder((Flow) input);
277 newFlow.setTransactionId(tXid);
278 newFlow.setFlowRef(input.getFlowRef());
279 return newFlow.build();
288 * @return UpdateFlow task
290 public static OFRpcTask<UpdateFlowInput, RpcResult<UpdateFlowOutput>> createUpdateFlowTask(
291 final OFRpcTaskContext taskContext, UpdateFlowInput input,
292 SwitchConnectionDistinguisher cookie) {
294 OFRpcTask<UpdateFlowInput, RpcResult<UpdateFlowOutput>> task =
295 new OFRpcTask<UpdateFlowInput, RpcResult<UpdateFlowOutput>>(taskContext, cookie, input) {
298 public ListenableFuture<RpcResult<UpdateFlowOutput>> call() {
299 ListenableFuture<RpcResult<UpdateFlowOutput>> result = null;
301 boolean updatedFlow = (getInput().getUpdatedFlow().getMatch().equals(getInput().getOriginalFlow().getMatch())) &&
302 (getInput().getUpdatedFlow().getPriority().equals(getInput().getOriginalFlow().getPriority()));
304 List<FlowModInputBuilder> allFlowMods = new ArrayList<>();
305 List<FlowModInputBuilder> ofFlowModInputs;
307 if (updatedFlow == false) {
308 // if neither match nor priority matches, then we would need to remove the flow and add it
310 RemoveFlowInputBuilder removeflow = new RemoveFlowInputBuilder(getInput().getOriginalFlow());
311 List<FlowModInputBuilder> ofFlowRemoveInput = FlowConvertor.toFlowModInputs(removeflow.build(),
312 getVersion(), getSession().getFeatures().getDatapathId());
313 // remove flow should be the first
314 allFlowMods.addAll(ofFlowRemoveInput);
315 AddFlowInputBuilder addFlowInputBuilder = new AddFlowInputBuilder(getInput().getUpdatedFlow());
316 ofFlowModInputs = FlowConvertor.toFlowModInputs(addFlowInputBuilder.build(),
317 getVersion(), getSession().getFeatures().getDatapathId());
319 ofFlowModInputs = FlowConvertor.toFlowModInputs(getInput().getUpdatedFlow(),
320 getVersion(), getSession().getFeatures().getDatapathId());
323 allFlowMods.addAll(ofFlowModInputs);
324 logger.debug("Number of flows to push to switch: {}", allFlowMods.size());
325 result = chainFlowMods(allFlowMods, 0, getTaskContext(), getCookie());
327 result = OFRpcTaskUtil.chainFutureBarrier(this, result);
328 OFRpcTaskUtil.hookFutureNotification(this, result,
329 getRpcNotificationProviderService(),
330 createFlowUpdatedNotification(getInput()));
335 public Boolean isBarrier() {
336 return getInput().getUpdatedFlow().isBarrier();
348 protected static NotificationComposer<FlowUpdated> createFlowUpdatedNotification(final UpdateFlowInput input) {
349 return new NotificationComposer<FlowUpdated>() {
351 public FlowUpdated compose(TransactionId tXid) {
352 FlowUpdatedBuilder updFlow = new FlowUpdatedBuilder(input.getUpdatedFlow());
353 updFlow.setTransactionId(tXid);
354 updFlow.setFlowRef(input.getFlowRef());
355 return updFlow.build();
364 * @return update group task
366 public static OFRpcTask<AddGroupInput, RpcResult<UpdateGroupOutput>> createAddGroupTask(
367 final OFRpcTaskContext taskContext, AddGroupInput input,
368 final SwitchConnectionDistinguisher cookie) {
369 OFRpcTask<AddGroupInput, RpcResult<UpdateGroupOutput>> task =
370 new OFRpcTask<AddGroupInput, RpcResult<UpdateGroupOutput>>(taskContext, cookie, input) {
373 public ListenableFuture<RpcResult<UpdateGroupOutput>> call() {
374 ListenableFuture<RpcResult<UpdateGroupOutput>> result = SettableFuture.create();
376 // Convert the AddGroupInput to GroupModInput
377 GroupModInputBuilder ofGroupModInput = GroupConvertor.toGroupModInput(getInput(),
378 getVersion(), getSession().getFeatures().getDatapathId());
379 final Long xId = getSession().getNextXid();
380 ofGroupModInput.setXid(xId);
382 Future<RpcResult<UpdateGroupOutput>> resultFromOFLib = getMessageService()
383 .groupMod(ofGroupModInput.build(), getCookie());
384 result = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
386 result = OFRpcTaskUtil.chainFutureBarrier(this, result);
387 OFRpcTaskUtil.hookFutureNotification(this, result,
388 getRpcNotificationProviderService(), createGroupAddedNotification(getInput()));
394 public Boolean isBarrier() {
395 return getInput().isBarrier();
407 protected static NotificationComposer<GroupAdded> createGroupAddedNotification(
408 final AddGroupInput input) {
409 return new NotificationComposer<GroupAdded>() {
411 public GroupAdded compose(TransactionId tXid) {
412 GroupAddedBuilder groupMod = new GroupAddedBuilder((Group) input);
413 groupMod.setTransactionId(tXid);
414 groupMod.setGroupRef(input.getGroupRef());
415 return groupMod.build();
424 * @return update meter task
426 public static OFRpcTask<AddMeterInput, RpcResult<UpdateMeterOutput>> createAddMeterTask(
427 OFRpcTaskContext taskContext, AddMeterInput input,
428 SwitchConnectionDistinguisher cookie) {
429 OFRpcTask<AddMeterInput, RpcResult<UpdateMeterOutput>> task =
430 new OFRpcTask<AddMeterInput, RpcResult<UpdateMeterOutput>>(taskContext, cookie, input) {
433 public ListenableFuture<RpcResult<UpdateMeterOutput>> call() {
434 ListenableFuture<RpcResult<UpdateMeterOutput>> result = SettableFuture.create();
436 // Convert the AddGroupInput to GroupModInput
437 MeterModInputBuilder ofMeterModInput = MeterConvertor.toMeterModInput(getInput(), getVersion());
438 final Long xId = getSession().getNextXid();
439 ofMeterModInput.setXid(xId);
441 Future<RpcResult<UpdateMeterOutput>> resultFromOFLib = getMessageService()
442 .meterMod(ofMeterModInput.build(), getCookie());
443 result = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
445 result = OFRpcTaskUtil.chainFutureBarrier(this, result);
446 OFRpcTaskUtil.hookFutureNotification(this, result,
447 getRpcNotificationProviderService(), createMeterAddedNotification(getInput()));
453 public Boolean isBarrier() {
454 return getInput().isBarrier();
466 protected static NotificationComposer<MeterAdded> createMeterAddedNotification(
467 final AddMeterInput input) {
468 return new NotificationComposer<MeterAdded>() {
470 public MeterAdded compose(TransactionId tXid) {
471 MeterAddedBuilder meterMod = new MeterAddedBuilder((Meter) input);
472 meterMod.setTransactionId(tXid);
473 meterMod.setMeterRef(input.getMeterRef());
474 return meterMod.build();
483 * @return UpdateFlow task
485 public static OFRpcTask<UpdateGroupInput, RpcResult<UpdateGroupOutput>> createUpdateGroupTask(
486 OFRpcTaskContext taskContext, UpdateGroupInput input,
487 SwitchConnectionDistinguisher cookie) {
488 OFRpcTask<UpdateGroupInput, RpcResult<UpdateGroupOutput>> task =
489 new OFRpcTask<UpdateGroupInput, RpcResult<UpdateGroupOutput>>(taskContext, cookie, input) {
492 public ListenableFuture<RpcResult<UpdateGroupOutput>> call() {
493 ListenableFuture<RpcResult<UpdateGroupOutput>> result = null;
495 // Convert the UpdateGroupInput to GroupModInput
496 GroupModInputBuilder ofGroupModInput = GroupConvertor.toGroupModInput(
497 getInput().getUpdatedGroup(), getVersion(),
498 getSession().getFeatures().getDatapathId());
499 final Long xId = getSession().getNextXid();
500 ofGroupModInput.setXid(xId);
502 Future<RpcResult<UpdateGroupOutput>> resultFromOFLib =
503 getMessageService().groupMod(ofGroupModInput.build(), getCookie());
504 result = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
506 result = OFRpcTaskUtil.chainFutureBarrier(this, result);
507 OFRpcTaskUtil.hookFutureNotification(this, result,
508 getRpcNotificationProviderService(), createGroupUpdatedNotification(getInput()));
520 protected static NotificationComposer<GroupUpdated> createGroupUpdatedNotification(
521 final UpdateGroupInput input) {
522 return new NotificationComposer<GroupUpdated>() {
524 public GroupUpdated compose(TransactionId tXid) {
525 GroupUpdatedBuilder groupMod = new GroupUpdatedBuilder(input.getUpdatedGroup());
526 groupMod.setTransactionId(tXid);
527 groupMod.setGroupRef(input.getGroupRef());
528 return groupMod.build();
537 * @return update meter task
539 public static OFRpcTask<UpdateMeterInput, RpcResult<UpdateMeterOutput>> createUpdateMeterTask(
540 OFRpcTaskContext taskContext, UpdateMeterInput input,
541 SwitchConnectionDistinguisher cookie) {
542 OFRpcTask<UpdateMeterInput, RpcResult<UpdateMeterOutput>> task =
543 new OFRpcTask<UpdateMeterInput, RpcResult<UpdateMeterOutput>>(taskContext, cookie, input) {
546 public ListenableFuture<RpcResult<UpdateMeterOutput>> call() {
547 ListenableFuture<RpcResult<UpdateMeterOutput>> result = null;
549 // Convert the UpdateMeterInput to MeterModInput
550 MeterModInputBuilder ofMeterModInput = MeterConvertor.toMeterModInput(
551 getInput().getUpdatedMeter(), getVersion());
552 final Long xId = getSession().getNextXid();
553 ofMeterModInput.setXid(xId);
555 Future<RpcResult<UpdateMeterOutput>> resultFromOFLib =
556 getMessageService().meterMod(ofMeterModInput.build(), getCookie());
557 result = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
559 result = OFRpcTaskUtil.chainFutureBarrier(this, result);
560 OFRpcTaskUtil.hookFutureNotification(this, result,
561 getRpcNotificationProviderService(), createMeterUpdatedNotification(getInput()));
572 protected static NotificationComposer<MeterUpdated> createMeterUpdatedNotification(
573 final UpdateMeterInput input) {
574 return new NotificationComposer<MeterUpdated>() {
576 public MeterUpdated compose(TransactionId tXid) {
577 MeterUpdatedBuilder meterMod = new MeterUpdatedBuilder(input.getUpdatedMeter());
578 meterMod.setTransactionId(tXid);
579 meterMod.setMeterRef(input.getMeterRef());
580 return meterMod.build();
592 public static OFRpcTask<RemoveFlowInput, RpcResult<UpdateFlowOutput>> createRemoveFlowTask(
593 OFRpcTaskContext taskContext, RemoveFlowInput input,
594 SwitchConnectionDistinguisher cookie) {
595 OFRpcTask<RemoveFlowInput, RpcResult<UpdateFlowOutput>> task =
596 new OFRpcTask<RemoveFlowInput, RpcResult<UpdateFlowOutput>>(taskContext, cookie, input) {
599 public ListenableFuture<RpcResult<UpdateFlowOutput>> call() {
600 ListenableFuture<RpcResult<UpdateFlowOutput>> result = SettableFuture.create();
602 // Convert the AddFlowInput to FlowModInput
603 FlowModInputBuilder ofFlowModInput = FlowConvertor.toFlowModInput(getInput(),
604 getVersion(), getSession().getFeatures().getDatapathId());
605 final Long xId = getSession().getNextXid();
606 ofFlowModInput.setXid(xId);
608 Future<RpcResult<UpdateFlowOutput>> resultFromOFLib =
609 getMessageService().flowMod(ofFlowModInput.build(), getCookie());
610 result = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
612 result = OFRpcTaskUtil.chainFutureBarrier(this, result);
613 OFRpcTaskUtil.hookFutureNotification(this, result,
614 getRpcNotificationProviderService(), createFlowRemovedNotification(getInput()));
627 protected static NotificationComposer<FlowRemoved> createFlowRemovedNotification(
628 final RemoveFlowInput input) {
629 return new NotificationComposer<FlowRemoved>() {
631 public FlowRemoved compose(TransactionId tXid) {
632 FlowRemovedBuilder removedFlow = new FlowRemovedBuilder((Flow) input);
633 removedFlow.setTransactionId(tXid);
634 removedFlow.setFlowRef(input.getFlowRef());
635 return removedFlow.build();
647 public static OFRpcTask<RemoveGroupInput, RpcResult<UpdateGroupOutput>> createRemoveGroupTask(
648 final OFRpcTaskContext taskContext, RemoveGroupInput input,
649 final SwitchConnectionDistinguisher cookie) {
650 OFRpcTask<RemoveGroupInput, RpcResult<UpdateGroupOutput>> task =
651 new OFRpcTask<RemoveGroupInput, RpcResult<UpdateGroupOutput>>(taskContext, cookie, input) {
654 public ListenableFuture<RpcResult<UpdateGroupOutput>> call() {
655 ListenableFuture<RpcResult<UpdateGroupOutput>> result = SettableFuture.create();
657 // Convert the AddGroupInput to GroupModInput
658 GroupModInputBuilder ofGroupModInput = GroupConvertor.toGroupModInput(getInput(),
659 getVersion(), getSession().getFeatures().getDatapathId());
660 final Long xId = getSession().getNextXid();
661 ofGroupModInput.setXid(xId);
663 Future<RpcResult<UpdateGroupOutput>> resultFromOFLib = getMessageService()
664 .groupMod(ofGroupModInput.build(), getCookie());
665 result = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
667 result = OFRpcTaskUtil.chainFutureBarrier(this, result);
668 OFRpcTaskUtil.hookFutureNotification(this, result,
669 getRpcNotificationProviderService(), createGroupRemovedNotification(getInput()));
682 protected static NotificationComposer<GroupRemoved> createGroupRemovedNotification(
683 final RemoveGroupInput input) {
684 return new NotificationComposer<GroupRemoved>() {
686 public GroupRemoved compose(TransactionId tXid) {
687 GroupRemovedBuilder removedGroup = new GroupRemovedBuilder((Group) input);
688 removedGroup.setTransactionId(tXid);
689 removedGroup.setGroupRef(input.getGroupRef());
690 return removedGroup.build();
701 public static OFRpcTask<RemoveMeterInput, RpcResult<UpdateMeterOutput>> createRemoveMeterTask(
702 OFRpcTaskContext taskContext, RemoveMeterInput input,
703 SwitchConnectionDistinguisher cookie) {
704 OFRpcTask<RemoveMeterInput, RpcResult<UpdateMeterOutput>> task =
705 new OFRpcTask<RemoveMeterInput, RpcResult<UpdateMeterOutput>>(taskContext, cookie, input) {
708 public ListenableFuture<RpcResult<UpdateMeterOutput>> call() {
709 ListenableFuture<RpcResult<UpdateMeterOutput>> result = SettableFuture.create();
711 // Convert the AddGroupInput to GroupModInput
712 MeterModInputBuilder ofMeterModInput = MeterConvertor.toMeterModInput(getInput(), getVersion());
713 final Long xId = getSession().getNextXid();
714 ofMeterModInput.setXid(xId);
716 Future<RpcResult<UpdateMeterOutput>> resultFromOFLib = getMessageService()
717 .meterMod(ofMeterModInput.build(), getCookie());
718 result = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
720 result = OFRpcTaskUtil.chainFutureBarrier(this, result);
721 OFRpcTaskUtil.hookFutureNotification(this, result,
722 getRpcNotificationProviderService(), createMeterRemovedNotification(getInput()));
736 protected static NotificationComposer<MeterRemoved> createMeterRemovedNotification(
737 final RemoveMeterInput input) {
738 return new NotificationComposer<MeterRemoved>() {
740 public MeterRemoved compose(TransactionId tXid) {
741 MeterRemovedBuilder meterRemoved = new MeterRemovedBuilder((Meter) input);
742 meterRemoved.setTransactionId(tXid);
743 meterRemoved.setMeterRef(input.getMeterRef());
744 return meterRemoved.build();
755 public static OFRpcTask<GetAllGroupStatisticsInput, RpcResult<GetAllGroupStatisticsOutput>> createGetAllGroupStatisticsTask(
756 final OFRpcTaskContext taskContext, GetAllGroupStatisticsInput input,
757 SwitchConnectionDistinguisher cookie) {
758 OFRpcTask<GetAllGroupStatisticsInput, RpcResult<GetAllGroupStatisticsOutput>> task =
759 new OFRpcTask<GetAllGroupStatisticsInput, RpcResult<GetAllGroupStatisticsOutput>>(taskContext, cookie, input) {
762 public ListenableFuture<RpcResult<GetAllGroupStatisticsOutput>> call() {
763 final SettableFuture<RpcResult<GetAllGroupStatisticsOutput>> result = SettableFuture.create();
765 if (taskContext.getSession().getPrimaryConductor().getVersion() == OFConstants.OFP_VERSION_1_0) {
766 RpcResult<GetAllGroupStatisticsOutput> rpcResult = RpcResultBuilder.success(
767 new GetAllGroupStatisticsOutputBuilder().build()).build();
769 return Futures.immediateFuture(rpcResult);
772 // Generate xid to associate it with the request
773 final Long xid = taskContext.getSession().getNextXid();
775 // Create multipart request body for fetch all the group stats
776 MultipartRequestGroupCaseBuilder caseBuilder = new MultipartRequestGroupCaseBuilder();
777 MultipartRequestGroupBuilder mprGroupBuild = new MultipartRequestGroupBuilder();
778 mprGroupBuild.setGroupId(new GroupId(BinContent.intToUnsignedLong(
779 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731
780 .Group.OFPGALL.getIntValue())));
781 caseBuilder.setMultipartRequestGroup(mprGroupBuild.build());
783 // Create multipart request header
784 MultipartRequestInputBuilder mprInput = createMultipartHeader(MultipartType.OFPMPGROUP,
787 // Set request body to main multipart request
788 mprInput.setMultipartRequestBody(caseBuilder.build());
790 // Send the request, no cookies associated, use any connection
792 Future<RpcResult<Void>> resultFromOFLib = getMessageService()
793 .multipartRequest(mprInput.build(), getCookie());
794 ListenableFuture<RpcResult<Void>> resultLib = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
796 Futures.addCallback(resultLib, new ResultCallback<GetAllGroupStatisticsOutput>(result) {
798 public GetAllGroupStatisticsOutput createResult() {
799 GetAllGroupStatisticsOutputBuilder groupStatBuilder = new GetAllGroupStatisticsOutputBuilder()
800 .setTransactionId(new TransactionId(BigInteger.valueOf(xid)));
801 return groupStatBuilder.build();
818 public static OFRpcTask<GetGroupDescriptionInput, RpcResult<GetGroupDescriptionOutput>> createGetGroupDescriptionTask(
819 final OFRpcTaskContext taskContext, GetGroupDescriptionInput input,
820 SwitchConnectionDistinguisher cookie) {
821 OFRpcTask<GetGroupDescriptionInput, RpcResult<GetGroupDescriptionOutput>> task =
822 new OFRpcTask<GetGroupDescriptionInput, RpcResult<GetGroupDescriptionOutput>>(taskContext, cookie, input) {
825 public ListenableFuture<RpcResult<GetGroupDescriptionOutput>> call()
827 final SettableFuture<RpcResult<GetGroupDescriptionOutput>> result = SettableFuture.create();
829 if (taskContext.getSession().getPrimaryConductor().getVersion() == OFConstants.OFP_VERSION_1_0) {
830 RpcResult<GetGroupDescriptionOutput> rpcResult = RpcResultBuilder.success(
831 new GetGroupDescriptionOutputBuilder().build()).build();
832 return Futures.immediateFuture(rpcResult);
834 final Long xid = taskContext.getSession().getNextXid();
836 MultipartRequestGroupDescCaseBuilder mprGroupDescCaseBuild =
837 new MultipartRequestGroupDescCaseBuilder();
838 MultipartRequestInputBuilder mprInput =
839 createMultipartHeader(MultipartType.OFPMPGROUPDESC, taskContext, xid);
840 mprInput.setMultipartRequestBody(mprGroupDescCaseBuild.build());
841 Future<RpcResult<Void>> resultFromOFLib = getMessageService()
842 .multipartRequest(mprInput.build(), getCookie());
843 ListenableFuture<RpcResult<Void>> resultLib = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
845 Futures.addCallback(resultLib, new ResultCallback<GetGroupDescriptionOutput>(result) {
847 public GetGroupDescriptionOutput createResult() {
848 GetGroupDescriptionOutputBuilder groupStatBuilder = new GetGroupDescriptionOutputBuilder()
849 .setTransactionId(new TransactionId(BigInteger.valueOf(xid)));
850 return groupStatBuilder.build();
866 public static OFRpcTask<GetGroupFeaturesInput, RpcResult<GetGroupFeaturesOutput>> createGetGroupFeaturesTask(
867 final OFRpcTaskContext taskContext, GetGroupFeaturesInput input,
868 SwitchConnectionDistinguisher cookie) {
869 OFRpcTask<GetGroupFeaturesInput, RpcResult<GetGroupFeaturesOutput>> task =
870 new OFRpcTask<GetGroupFeaturesInput, RpcResult<GetGroupFeaturesOutput>>(taskContext, cookie, input) {
873 public ListenableFuture<RpcResult<GetGroupFeaturesOutput>> call()
875 final SettableFuture<RpcResult<GetGroupFeaturesOutput>> result = SettableFuture.create();
877 if (taskContext.getSession().getPrimaryConductor().getVersion() == OFConstants.OFP_VERSION_1_0) {
878 RpcResult<GetGroupFeaturesOutput> rpcResult = RpcResultBuilder.success(
879 new GetGroupFeaturesOutputBuilder().build()).build();
880 return Futures.immediateFuture(rpcResult);
882 final Long xid = taskContext.getSession().getNextXid();
884 MultipartRequestGroupFeaturesCaseBuilder mprGroupFeaturesBuild =
885 new MultipartRequestGroupFeaturesCaseBuilder();
886 MultipartRequestInputBuilder mprInput =
887 createMultipartHeader(MultipartType.OFPMPGROUPFEATURES, taskContext, xid);
888 mprInput.setMultipartRequestBody(mprGroupFeaturesBuild.build());
889 Future<RpcResult<Void>> resultFromOFLib = getMessageService()
890 .multipartRequest(mprInput.build(), getCookie());
891 ListenableFuture<RpcResult<Void>> resultLib = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
893 Futures.addCallback(resultLib, new ResultCallback<GetGroupFeaturesOutput>(result) {
895 public GetGroupFeaturesOutput createResult() {
896 GetGroupFeaturesOutputBuilder groupFeatureBuilder = new GetGroupFeaturesOutputBuilder()
897 .setTransactionId(new TransactionId(BigInteger.valueOf(xid)));
898 return groupFeatureBuilder.build();
914 public static OFRpcTask<GetGroupStatisticsInput, RpcResult<GetGroupStatisticsOutput>> createGetGroupStatisticsTask(
915 final OFRpcTaskContext taskContext, final GetGroupStatisticsInput input,
916 SwitchConnectionDistinguisher cookie) {
917 OFRpcTask<GetGroupStatisticsInput, RpcResult<GetGroupStatisticsOutput>> task =
918 new OFRpcTask<GetGroupStatisticsInput, RpcResult<GetGroupStatisticsOutput>>(taskContext, cookie, input) {
921 public ListenableFuture<RpcResult<GetGroupStatisticsOutput>> call()
923 final SettableFuture<RpcResult<GetGroupStatisticsOutput>> result = SettableFuture.create();
925 if (taskContext.getSession().getPrimaryConductor().getVersion() == OFConstants.OFP_VERSION_1_0) {
926 RpcResult<GetGroupStatisticsOutput> rpcResult = RpcResultBuilder.success(
927 new GetGroupStatisticsOutputBuilder().build()).build();
928 return Futures.immediateFuture(rpcResult);
930 final Long xid = taskContext.getSession().getNextXid();
932 MultipartRequestGroupCaseBuilder caseBuilder = new MultipartRequestGroupCaseBuilder();
933 MultipartRequestGroupBuilder mprGroupBuild = new MultipartRequestGroupBuilder();
934 mprGroupBuild.setGroupId(new GroupId(input.getGroupId().getValue()));
935 caseBuilder.setMultipartRequestGroup(mprGroupBuild.build());
937 MultipartRequestInputBuilder mprInput =
938 createMultipartHeader(MultipartType.OFPMPGROUP, taskContext, xid);
939 mprInput.setMultipartRequestBody(caseBuilder.build());
940 Future<RpcResult<Void>> resultFromOFLib = getMessageService()
941 .multipartRequest(mprInput.build(), getCookie());
942 ListenableFuture<RpcResult<Void>> resultLib = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
944 Futures.addCallback(resultLib, new ResultCallback<GetGroupStatisticsOutput>(result) {
946 public GetGroupStatisticsOutput createResult() {
947 GetGroupStatisticsOutputBuilder groupStatisticsBuilder =
948 new GetGroupStatisticsOutputBuilder()
949 .setTransactionId(new TransactionId(BigInteger.valueOf(xid)));
950 return groupStatisticsBuilder.build();
966 public static OFRpcTask<GetAllMeterConfigStatisticsInput, RpcResult<GetAllMeterConfigStatisticsOutput>> createGetAllMeterConfigStatisticsTask(
967 final OFRpcTaskContext taskContext, final GetAllMeterConfigStatisticsInput input,
968 SwitchConnectionDistinguisher cookie) {
969 OFRpcTask<GetAllMeterConfigStatisticsInput, RpcResult<GetAllMeterConfigStatisticsOutput>> task =
970 new OFRpcTask<GetAllMeterConfigStatisticsInput, RpcResult<GetAllMeterConfigStatisticsOutput>>(taskContext, cookie, input) {
973 public ListenableFuture<RpcResult<GetAllMeterConfigStatisticsOutput>> call()
975 final SettableFuture<RpcResult<GetAllMeterConfigStatisticsOutput>> result = SettableFuture.create();
977 if (taskContext.getSession().getPrimaryConductor().getVersion() == OFConstants.OFP_VERSION_1_0) {
978 RpcResult<GetAllMeterConfigStatisticsOutput> rpcResult = RpcResultBuilder.success(
979 new GetAllMeterConfigStatisticsOutputBuilder().build()).build();
980 return Futures.immediateFuture(rpcResult);
982 final Long xid = taskContext.getSession().getNextXid();
984 MultipartRequestMeterConfigCaseBuilder caseBuilder =
985 new MultipartRequestMeterConfigCaseBuilder();
986 MultipartRequestMeterConfigBuilder mprMeterConfigBuild =
987 new MultipartRequestMeterConfigBuilder();
988 mprMeterConfigBuild.setMeterId(new MeterId(BinContent.intToUnsignedLong(
989 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common
990 .types.rev130731.Meter.OFPMALL.getIntValue())));
991 caseBuilder.setMultipartRequestMeterConfig(mprMeterConfigBuild.build());
993 MultipartRequestInputBuilder mprInput =
994 createMultipartHeader(MultipartType.OFPMPMETERCONFIG, taskContext, xid);
995 mprInput.setMultipartRequestBody(caseBuilder.build());
996 Future<RpcResult<Void>> resultFromOFLib = getMessageService()
997 .multipartRequest(mprInput.build(), getCookie());
998 ListenableFuture<RpcResult<Void>> resultLib = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
1000 Futures.addCallback(resultLib, new ResultCallback<GetAllMeterConfigStatisticsOutput>(result) {
1002 public GetAllMeterConfigStatisticsOutput createResult() {
1003 GetAllMeterConfigStatisticsOutputBuilder allMeterConfStatBuilder =
1004 new GetAllMeterConfigStatisticsOutputBuilder()
1005 .setTransactionId(new TransactionId(BigInteger.valueOf(xid)));
1006 return allMeterConfStatBuilder.build();
1017 * @param taskContext
1022 public static OFRpcTask<GetAllMeterStatisticsInput, RpcResult<GetAllMeterStatisticsOutput>> createGetAllMeterStatisticsTask(
1023 final OFRpcTaskContext taskContext, final GetAllMeterStatisticsInput input,
1024 SwitchConnectionDistinguisher cookie) {
1025 OFRpcTask<GetAllMeterStatisticsInput, RpcResult<GetAllMeterStatisticsOutput>> task =
1026 new OFRpcTask<GetAllMeterStatisticsInput, RpcResult<GetAllMeterStatisticsOutput>>(taskContext, cookie, input) {
1029 public ListenableFuture<RpcResult<GetAllMeterStatisticsOutput>> call()
1031 final SettableFuture<RpcResult<GetAllMeterStatisticsOutput>> result = SettableFuture.create();
1033 if (taskContext.getSession().getPrimaryConductor().getVersion() == OFConstants.OFP_VERSION_1_0) {
1034 RpcResult<GetAllMeterStatisticsOutput> rpcResult = RpcResultBuilder.success(
1035 new GetAllMeterStatisticsOutputBuilder().build()).build();
1036 return Futures.immediateFuture(rpcResult);
1038 final Long xid = taskContext.getSession().getNextXid();
1040 MultipartRequestMeterCaseBuilder caseBuilder =
1041 new MultipartRequestMeterCaseBuilder();
1042 MultipartRequestMeterBuilder mprMeterBuild =
1043 new MultipartRequestMeterBuilder();
1044 mprMeterBuild.setMeterId(new MeterId(BinContent.intToUnsignedLong(
1045 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common
1046 .types.rev130731.Meter.OFPMALL.getIntValue())));
1047 caseBuilder.setMultipartRequestMeter(mprMeterBuild.build());
1049 MultipartRequestInputBuilder mprInput =
1050 createMultipartHeader(MultipartType.OFPMPMETER, taskContext, xid);
1051 mprInput.setMultipartRequestBody(caseBuilder.build());
1052 Future<RpcResult<Void>> resultFromOFLib = getMessageService()
1053 .multipartRequest(mprInput.build(), getCookie());
1054 ListenableFuture<RpcResult<Void>> resultLib = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
1056 Futures.addCallback(resultLib, new ResultCallback<GetAllMeterStatisticsOutput>(result) {
1058 public GetAllMeterStatisticsOutput createResult() {
1059 GetAllMeterStatisticsOutputBuilder allMeterStatBuilder =
1060 new GetAllMeterStatisticsOutputBuilder()
1061 .setTransactionId(new TransactionId(BigInteger.valueOf(xid)));
1062 return allMeterStatBuilder.build();
1073 * @param taskContext
1078 public static OFRpcTask<GetMeterFeaturesInput, RpcResult<GetMeterFeaturesOutput>> createGetMeterFeaturesTask(
1079 final OFRpcTaskContext taskContext, final GetMeterFeaturesInput input,
1080 SwitchConnectionDistinguisher cookie) {
1081 OFRpcTask<GetMeterFeaturesInput, RpcResult<GetMeterFeaturesOutput>> task =
1082 new OFRpcTask<GetMeterFeaturesInput, RpcResult<GetMeterFeaturesOutput>>(taskContext, cookie, input) {
1085 public ListenableFuture<RpcResult<GetMeterFeaturesOutput>> call()
1087 final SettableFuture<RpcResult<GetMeterFeaturesOutput>> result = SettableFuture.create();
1089 if (taskContext.getSession().getPrimaryConductor().getVersion() == OFConstants.OFP_VERSION_1_0) {
1090 RpcResult<GetMeterFeaturesOutput> rpcResult = RpcResultBuilder.success(
1091 new GetMeterFeaturesOutputBuilder().build()).build();
1092 return Futures.immediateFuture(rpcResult);
1094 final Long xid = taskContext.getSession().getNextXid();
1096 MultipartRequestMeterFeaturesCaseBuilder mprMeterFeaturesBuild =
1097 new MultipartRequestMeterFeaturesCaseBuilder();
1099 MultipartRequestInputBuilder mprInput =
1100 createMultipartHeader(MultipartType.OFPMPMETERFEATURES, taskContext, xid);
1101 mprInput.setMultipartRequestBody(mprMeterFeaturesBuild.build());
1102 Future<RpcResult<Void>> resultFromOFLib = getMessageService()
1103 .multipartRequest(mprInput.build(), getCookie());
1104 ListenableFuture<RpcResult<Void>> resultLib = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
1106 Futures.addCallback(resultLib, new ResultCallback<GetMeterFeaturesOutput>(result) {
1108 public GetMeterFeaturesOutput createResult() {
1109 GetMeterFeaturesOutputBuilder meterFeaturesBuilder =
1110 new GetMeterFeaturesOutputBuilder()
1111 .setTransactionId(new TransactionId(BigInteger.valueOf(xid)));
1112 return meterFeaturesBuilder.build();
1123 * @param taskContext
1128 public static OFRpcTask<GetMeterStatisticsInput, RpcResult<GetMeterStatisticsOutput>> createGetMeterStatisticsTask(
1129 final OFRpcTaskContext taskContext, final GetMeterStatisticsInput input,
1130 SwitchConnectionDistinguisher cookie) {
1131 OFRpcTask<GetMeterStatisticsInput, RpcResult<GetMeterStatisticsOutput>> task =
1132 new OFRpcTask<GetMeterStatisticsInput, RpcResult<GetMeterStatisticsOutput>>(taskContext, cookie, input) {
1135 public ListenableFuture<RpcResult<GetMeterStatisticsOutput>> call()
1137 final SettableFuture<RpcResult<GetMeterStatisticsOutput>> result = SettableFuture.create();
1139 if (taskContext.getSession().getPrimaryConductor().getVersion() == OFConstants.OFP_VERSION_1_0) {
1140 RpcResult<GetMeterStatisticsOutput> rpcResult = RpcResultBuilder.success(
1141 new GetMeterStatisticsOutputBuilder().build()).build();
1142 return Futures.immediateFuture(rpcResult);
1144 final Long xid = taskContext.getSession().getNextXid();
1146 MultipartRequestMeterCaseBuilder caseBuilder =
1147 new MultipartRequestMeterCaseBuilder();
1148 MultipartRequestMeterBuilder mprMeterBuild =
1149 new MultipartRequestMeterBuilder();
1150 mprMeterBuild.setMeterId(new MeterId(input.getMeterId().getValue()));
1151 caseBuilder.setMultipartRequestMeter(mprMeterBuild.build());
1153 MultipartRequestInputBuilder mprInput =
1154 createMultipartHeader(MultipartType.OFPMPMETER, taskContext, xid);
1155 mprInput.setMultipartRequestBody(caseBuilder.build());
1156 Future<RpcResult<Void>> resultFromOFLib = getMessageService()
1157 .multipartRequest(mprInput.build(), getCookie());
1158 ListenableFuture<RpcResult<Void>> resultLib = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
1160 Futures.addCallback(resultLib, new ResultCallback<GetMeterStatisticsOutput>(result) {
1162 public GetMeterStatisticsOutput createResult() {
1163 GetMeterStatisticsOutputBuilder meterStatBuilder =
1164 new GetMeterStatisticsOutputBuilder()
1165 .setTransactionId(new TransactionId(BigInteger.valueOf(xid)));
1166 return meterStatBuilder.build();
1177 * @param taskContext
1182 public static OFRpcTask<GetAllNodeConnectorsStatisticsInput, RpcResult<GetAllNodeConnectorsStatisticsOutput>>
1183 createGetAllNodeConnectorsStatisticsTask(
1184 final OFRpcTaskContext taskContext, final GetAllNodeConnectorsStatisticsInput input,
1185 SwitchConnectionDistinguisher cookie) {
1186 OFRpcTask<GetAllNodeConnectorsStatisticsInput, RpcResult<GetAllNodeConnectorsStatisticsOutput>> task =
1187 new OFRpcTask<GetAllNodeConnectorsStatisticsInput, RpcResult<GetAllNodeConnectorsStatisticsOutput>>(taskContext, cookie, input) {
1190 public ListenableFuture<RpcResult<GetAllNodeConnectorsStatisticsOutput>> call()
1192 final SettableFuture<RpcResult<GetAllNodeConnectorsStatisticsOutput>> result = SettableFuture.create();
1194 final Long xid = taskContext.getSession().getNextXid();
1196 MultipartRequestPortStatsCaseBuilder caseBuilder =
1197 new MultipartRequestPortStatsCaseBuilder();
1198 MultipartRequestPortStatsBuilder mprPortStatsBuilder =
1199 new MultipartRequestPortStatsBuilder();
1201 mprPortStatsBuilder.setPortNo(OFConstants.OFPP_ANY);
1202 caseBuilder.setMultipartRequestPortStats(mprPortStatsBuilder.build());
1204 MultipartRequestInputBuilder mprInput =
1205 createMultipartHeader(MultipartType.OFPMPPORTSTATS, taskContext, xid);
1206 mprInput.setMultipartRequestBody(caseBuilder.build());
1207 Future<RpcResult<Void>> resultFromOFLib = getMessageService()
1208 .multipartRequest(mprInput.build(), getCookie());
1209 ListenableFuture<RpcResult<Void>> resultLib = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
1211 Futures.addCallback(resultLib, new ResultCallback<GetAllNodeConnectorsStatisticsOutput>(result) {
1213 public GetAllNodeConnectorsStatisticsOutput createResult() {
1214 GetAllNodeConnectorsStatisticsOutputBuilder allNodeConnectorStatBuilder =
1215 new GetAllNodeConnectorsStatisticsOutputBuilder()
1216 .setTransactionId(new TransactionId(BigInteger.valueOf(xid)));
1217 return allNodeConnectorStatBuilder.build();
1227 * @param taskContext
1232 public static OFRpcTask<GetNodeConnectorStatisticsInput, RpcResult<GetNodeConnectorStatisticsOutput>>
1233 createGetNodeConnectorStatisticsTask(
1234 final OFRpcTaskContext taskContext, final GetNodeConnectorStatisticsInput input,
1235 SwitchConnectionDistinguisher cookie) {
1236 OFRpcTask<GetNodeConnectorStatisticsInput, RpcResult<GetNodeConnectorStatisticsOutput>> task =
1237 new OFRpcTask<GetNodeConnectorStatisticsInput, RpcResult<GetNodeConnectorStatisticsOutput>>(taskContext, cookie, input) {
1240 public ListenableFuture<RpcResult<GetNodeConnectorStatisticsOutput>> call()
1242 final SettableFuture<RpcResult<GetNodeConnectorStatisticsOutput>> result = SettableFuture.create();
1244 final Long xid = taskContext.getSession().getNextXid();
1246 MultipartRequestPortStatsCaseBuilder caseBuilder =
1247 new MultipartRequestPortStatsCaseBuilder();
1248 MultipartRequestPortStatsBuilder mprPortStatsBuilder =
1249 new MultipartRequestPortStatsBuilder();
1250 // Set specific port
1252 .setPortNo(InventoryDataServiceUtil.portNumberfromNodeConnectorId(
1253 OpenflowVersion.get(taskContext.getSession().getFeatures().getVersion()),
1254 input.getNodeConnectorId()));
1255 caseBuilder.setMultipartRequestPortStats(mprPortStatsBuilder.build());
1257 MultipartRequestInputBuilder mprInput =
1258 createMultipartHeader(MultipartType.OFPMPPORTSTATS, taskContext, xid);
1259 mprInput.setMultipartRequestBody(caseBuilder.build());
1260 Future<RpcResult<Void>> resultFromOFLib = getMessageService()
1261 .multipartRequest(mprInput.build(), getCookie());
1262 ListenableFuture<RpcResult<Void>> resultLib = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
1264 Futures.addCallback(resultLib, new ResultCallback<GetNodeConnectorStatisticsOutput>(result) {
1266 public GetNodeConnectorStatisticsOutput createResult() {
1267 GetNodeConnectorStatisticsOutputBuilder allNodeConnectorStatBuilder =
1268 new GetNodeConnectorStatisticsOutputBuilder()
1269 .setTransactionId(new TransactionId(BigInteger.valueOf(xid)));
1270 return allNodeConnectorStatBuilder.build();
1280 * @param taskContext
1285 public static OFRpcTask<GetAllFlowStatisticsFromFlowTableInput, RpcResult<GetAllFlowStatisticsFromFlowTableOutput>>
1286 createGetAllFlowStatisticsFromFlowTableTask(
1287 final OFRpcTaskContext taskContext,
1288 final GetAllFlowStatisticsFromFlowTableInput input,
1289 SwitchConnectionDistinguisher cookie) {
1290 OFRpcTask<GetAllFlowStatisticsFromFlowTableInput, RpcResult<GetAllFlowStatisticsFromFlowTableOutput>> task =
1291 new OFRpcTask<GetAllFlowStatisticsFromFlowTableInput, RpcResult<GetAllFlowStatisticsFromFlowTableOutput>>(taskContext, cookie, input) {
1294 public ListenableFuture<RpcResult<GetAllFlowStatisticsFromFlowTableOutput>> call() throws Exception {
1295 final SettableFuture<RpcResult<GetAllFlowStatisticsFromFlowTableOutput>> result = SettableFuture.create();
1297 final Long xid = taskContext.getSession().getNextXid();
1299 MultipartRequestFlowBuilder mprFlowRequestBuilder = new MultipartRequestFlowBuilder();
1300 mprFlowRequestBuilder.setTableId(input.getTableId().getValue());
1301 mprFlowRequestBuilder.setOutPort(OFConstants.OFPP_ANY);
1302 mprFlowRequestBuilder.setOutGroup(OFConstants.OFPG_ANY);
1303 mprFlowRequestBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
1304 mprFlowRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
1305 FlowCreatorUtil.setWildcardedFlowMatch(taskContext.getSession()
1306 .getPrimaryConductor().getVersion(), mprFlowRequestBuilder);
1308 MultipartRequestFlowCaseBuilder multipartRequestFlowCaseBuilder = new MultipartRequestFlowCaseBuilder();
1309 multipartRequestFlowCaseBuilder.setMultipartRequestFlow(mprFlowRequestBuilder.build());
1311 MultipartRequestInputBuilder mprInput =
1312 createMultipartHeader(MultipartType.OFPMPFLOW, taskContext, xid);
1313 mprInput.setMultipartRequestBody(multipartRequestFlowCaseBuilder.build());
1314 Future<RpcResult<Void>> resultFromOFLib = getMessageService()
1315 .multipartRequest(mprInput.build(), getCookie());
1316 ListenableFuture<RpcResult<Void>> resultLib = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
1318 Futures.addCallback(resultLib, new ResultCallback<GetAllFlowStatisticsFromFlowTableOutput>(result) {
1320 public GetAllFlowStatisticsFromFlowTableOutput createResult() {
1321 GetAllFlowStatisticsFromFlowTableOutputBuilder allFlowStatsFromFlowTableBuilder =
1322 new GetAllFlowStatisticsFromFlowTableOutputBuilder()
1323 .setTransactionId(new TransactionId(BigInteger.valueOf(xid)));
1324 return allFlowStatsFromFlowTableBuilder.build();
1334 * @param taskContext
1339 public static OFRpcTask<GetAllFlowsStatisticsFromAllFlowTablesInput, RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput>>
1340 createGetAllFlowsStatisticsFromAllFlowTablesTask(
1341 final OFRpcTaskContext taskContext,
1342 final GetAllFlowsStatisticsFromAllFlowTablesInput input,
1343 SwitchConnectionDistinguisher cookie) {
1344 OFRpcTask<GetAllFlowsStatisticsFromAllFlowTablesInput,
1345 RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput>> task =
1346 new OFRpcTask<GetAllFlowsStatisticsFromAllFlowTablesInput,
1347 RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput>>(taskContext, cookie, input) {
1350 public ListenableFuture<RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput>> call() throws Exception {
1351 final SettableFuture<RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput>> result = SettableFuture.create();
1353 final Long xid = taskContext.getSession().getNextXid();
1355 // Create multipart request body for fetch all the group stats
1356 MultipartRequestFlowCaseBuilder multipartRequestFlowCaseBuilder =
1357 new MultipartRequestFlowCaseBuilder();
1358 MultipartRequestFlowBuilder mprFlowRequestBuilder =
1359 new MultipartRequestFlowBuilder();
1360 mprFlowRequestBuilder.setTableId(OFConstants.OFPTT_ALL);
1361 mprFlowRequestBuilder.setOutPort(OFConstants.OFPP_ANY);
1362 mprFlowRequestBuilder.setOutGroup(OFConstants.OFPG_ANY);
1363 mprFlowRequestBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
1364 mprFlowRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
1365 FlowCreatorUtil.setWildcardedFlowMatch(taskContext.getSession()
1366 .getPrimaryConductor().getVersion(), mprFlowRequestBuilder);
1368 MultipartRequestInputBuilder mprInput =
1369 createMultipartHeader(MultipartType.OFPMPFLOW, taskContext, xid);
1370 multipartRequestFlowCaseBuilder.setMultipartRequestFlow(mprFlowRequestBuilder.build());
1371 mprInput.setMultipartRequestBody(multipartRequestFlowCaseBuilder.build());
1372 Future<RpcResult<Void>> resultFromOFLib = getMessageService()
1373 .multipartRequest(mprInput.build(), getCookie());
1374 ListenableFuture<RpcResult<Void>> resultLib = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
1376 Futures.addCallback(resultLib, new ResultCallback<GetAllFlowsStatisticsFromAllFlowTablesOutput>(result) {
1378 public GetAllFlowsStatisticsFromAllFlowTablesOutput createResult() {
1379 GetAllFlowsStatisticsFromAllFlowTablesOutputBuilder allFlowStatsFromAllFlowTableBuilder =
1380 new GetAllFlowsStatisticsFromAllFlowTablesOutputBuilder()
1381 .setTransactionId(new TransactionId(BigInteger.valueOf(xid)));
1382 return allFlowStatsFromAllFlowTableBuilder.build();
1392 * @param taskContext
1397 public static OFRpcTask<GetFlowStatisticsFromFlowTableInput, RpcResult<GetFlowStatisticsFromFlowTableOutput>>
1398 createGetFlowStatisticsFromFlowTableTask(
1399 final OFRpcTaskContext taskContext,
1400 final GetFlowStatisticsFromFlowTableInput input, SwitchConnectionDistinguisher cookie) {
1401 OFRpcTask<GetFlowStatisticsFromFlowTableInput, RpcResult<GetFlowStatisticsFromFlowTableOutput>> task =
1402 new OFRpcTask<GetFlowStatisticsFromFlowTableInput, RpcResult<GetFlowStatisticsFromFlowTableOutput>>(taskContext, cookie, input) {
1405 public ListenableFuture<RpcResult<GetFlowStatisticsFromFlowTableOutput>> call() throws Exception {
1406 final SettableFuture<RpcResult<GetFlowStatisticsFromFlowTableOutput>> result = SettableFuture.create();
1408 final Long xid = taskContext.getSession().getNextXid();
1410 // Create multipart request body for fetch all the group stats
1411 MultipartRequestFlowCaseBuilder multipartRequestFlowCaseBuilder = new MultipartRequestFlowCaseBuilder();
1412 MultipartRequestFlowBuilder mprFlowRequestBuilder = new MultipartRequestFlowBuilder();
1413 mprFlowRequestBuilder.setTableId(input.getTableId());
1415 if (input.getOutPort() != null)
1416 mprFlowRequestBuilder.setOutPort(input.getOutPort().longValue());
1418 mprFlowRequestBuilder.setOutPort(OFConstants.OFPP_ANY);
1420 if (input.getOutGroup() != null)
1421 mprFlowRequestBuilder.setOutGroup(input.getOutGroup());
1423 mprFlowRequestBuilder.setOutGroup(OFConstants.OFPG_ANY);
1425 if (input.getCookie() != null)
1426 mprFlowRequestBuilder.setCookie(input.getCookie().getValue());
1428 mprFlowRequestBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
1430 if (input.getCookieMask() != null)
1431 mprFlowRequestBuilder.setCookieMask(input.getCookieMask().getValue());
1433 mprFlowRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
1435 // convert and inject match
1436 MatchReactor.getInstance().convert(input.getMatch(), taskContext.getSession()
1437 .getPrimaryConductor().getVersion(), mprFlowRequestBuilder,
1438 taskContext.getSession().getFeatures().getDatapathId());
1440 // Set request body to main multipart request
1441 multipartRequestFlowCaseBuilder.setMultipartRequestFlow(mprFlowRequestBuilder.build());
1442 MultipartRequestInputBuilder mprInput =
1443 createMultipartHeader(MultipartType.OFPMPFLOW, taskContext, xid);
1444 mprInput.setMultipartRequestBody(multipartRequestFlowCaseBuilder.build());
1445 Future<RpcResult<Void>> resultFromOFLib = getMessageService()
1446 .multipartRequest(mprInput.build(), getCookie());
1447 ListenableFuture<RpcResult<Void>> resultLib = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
1449 Futures.addCallback(resultLib, new ResultCallback<GetFlowStatisticsFromFlowTableOutput>(result) {
1451 public GetFlowStatisticsFromFlowTableOutput createResult() {
1452 GetFlowStatisticsFromFlowTableOutputBuilder flowStatsFromFlowTableBuilder =
1453 new GetFlowStatisticsFromFlowTableOutputBuilder()
1454 .setTransactionId(new TransactionId(BigInteger.valueOf(xid)));
1455 return flowStatsFromFlowTableBuilder.build();
1465 * @param taskContext
1470 public static OFRpcTask<GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput, RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>>
1471 createGetAggregateFlowStatisticsFromFlowTableForAllFlowsTask(
1472 final OFRpcTaskContext taskContext,
1473 final GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput input, SwitchConnectionDistinguisher cookie) {
1474 OFRpcTask<GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput, RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>> task =
1475 new OFRpcTask<GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput, RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>>(taskContext, cookie, input) {
1478 public ListenableFuture<RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>> call() throws Exception {
1479 final SettableFuture<RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>> result = SettableFuture.create();
1481 final Long xid = taskContext.getSession().getNextXid();
1483 // Create multipart request body for fetch all the group stats
1484 MultipartRequestAggregateCaseBuilder multipartRequestAggregateCaseBuilder = new MultipartRequestAggregateCaseBuilder();
1485 MultipartRequestAggregateBuilder mprAggregateRequestBuilder = new MultipartRequestAggregateBuilder();
1486 mprAggregateRequestBuilder.setTableId(input.getTableId().getValue());
1487 mprAggregateRequestBuilder.setOutPort(OFConstants.OFPP_ANY);
1488 mprAggregateRequestBuilder.setOutGroup(OFConstants.OFPG_ANY);
1489 mprAggregateRequestBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
1490 mprAggregateRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
1492 FlowCreatorUtil.setWildcardedFlowMatch(taskContext.getSession()
1493 .getPrimaryConductor().getVersion(), mprAggregateRequestBuilder);
1495 // Set request body to main multipart request
1496 multipartRequestAggregateCaseBuilder.setMultipartRequestAggregate(mprAggregateRequestBuilder.build());
1497 MultipartRequestInputBuilder mprInput =
1498 createMultipartHeader(MultipartType.OFPMPAGGREGATE, taskContext, xid);
1499 mprInput.setMultipartRequestBody(multipartRequestAggregateCaseBuilder.build());
1500 Future<RpcResult<Void>> resultFromOFLib = getMessageService()
1501 .multipartRequest(mprInput.build(), getCookie());
1502 ListenableFuture<RpcResult<Void>> resultLib = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
1504 Futures.addCallback(resultLib, new ResultCallback<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>(result) {
1506 public GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput createResult() {
1507 GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutputBuilder flowStatsFromFlowTableBuilder =
1508 new GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutputBuilder()
1509 .setTransactionId(new TransactionId(BigInteger.valueOf(xid)));
1510 return flowStatsFromFlowTableBuilder.build();
1520 * @param taskContext
1525 public static OFRpcTask<GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput, RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>>
1526 createGetAggregateFlowStatisticsFromFlowTableForGivenMatchTask(
1527 final OFRpcTaskContext taskContext,
1528 final GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput input, SwitchConnectionDistinguisher cookie) {
1529 OFRpcTask<GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput, RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>> task =
1530 new OFRpcTask<GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput, RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>>(taskContext, cookie, input) {
1533 public ListenableFuture<RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>> call() throws Exception {
1534 final SettableFuture<RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>> result = SettableFuture.create();
1536 final Long xid = taskContext.getSession().getNextXid();
1538 MultipartRequestAggregateCaseBuilder multipartRequestAggregateCaseBuilder = new MultipartRequestAggregateCaseBuilder();
1539 MultipartRequestAggregateBuilder mprAggregateRequestBuilder = new MultipartRequestAggregateBuilder();
1540 mprAggregateRequestBuilder.setTableId(input.getTableId());
1541 mprAggregateRequestBuilder.setOutPort(input.getOutPort().longValue());
1542 // TODO: repeating code
1543 if (taskContext.getSession().getPrimaryConductor().getVersion() ==
1544 OFConstants.OFP_VERSION_1_3) {
1545 mprAggregateRequestBuilder.setCookie(input.getCookie().getValue());
1546 mprAggregateRequestBuilder.setCookieMask(input.getCookieMask().getValue());
1547 mprAggregateRequestBuilder.setOutGroup(input.getOutGroup());
1549 mprAggregateRequestBuilder.setOutGroup(OFConstants.OFPG_ANY);
1550 mprAggregateRequestBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
1551 mprAggregateRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
1554 MatchReactor.getInstance().convert(input.getMatch(), taskContext.getSession()
1555 .getPrimaryConductor().getVersion(), mprAggregateRequestBuilder,
1556 taskContext.getSession().getFeatures().getDatapathId());
1558 FlowCreatorUtil.setWildcardedFlowMatch(taskContext.getSession()
1559 .getPrimaryConductor().getVersion(), mprAggregateRequestBuilder);
1561 // Set request body to main multipart request
1562 multipartRequestAggregateCaseBuilder.setMultipartRequestAggregate(mprAggregateRequestBuilder.build());
1563 MultipartRequestInputBuilder mprInput =
1564 createMultipartHeader(MultipartType.OFPMPAGGREGATE, taskContext, xid);
1565 mprInput.setMultipartRequestBody(multipartRequestAggregateCaseBuilder.build());
1566 Future<RpcResult<Void>> resultFromOFLib = getMessageService()
1567 .multipartRequest(mprInput.build(), getCookie());
1568 ListenableFuture<RpcResult<Void>> resultLib = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
1570 Futures.addCallback(resultLib, new ResultCallback<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>(result) {
1572 public GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput createResult() {
1573 GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder aggregFlowStatsFromFlowTableBuilder =
1574 new GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder()
1575 .setTransactionId(new TransactionId(BigInteger.valueOf(xid)));
1576 return aggregFlowStatsFromFlowTableBuilder.build();
1586 * @param taskContext
1591 public static OFRpcTask<GetFlowTablesStatisticsInput, RpcResult<GetFlowTablesStatisticsOutput>> createGetFlowTablesStatisticsTask(
1592 final OFRpcTaskContext taskContext, final GetFlowTablesStatisticsInput input, SwitchConnectionDistinguisher cookie) {
1593 OFRpcTask<GetFlowTablesStatisticsInput, RpcResult<GetFlowTablesStatisticsOutput>> task =
1594 new OFRpcTask<GetFlowTablesStatisticsInput, RpcResult<GetFlowTablesStatisticsOutput>>(taskContext, cookie, input) {
1597 public ListenableFuture<RpcResult<GetFlowTablesStatisticsOutput>> call() throws Exception {
1598 final SettableFuture<RpcResult<GetFlowTablesStatisticsOutput>> result = SettableFuture.create();
1600 final Long xid = taskContext.getSession().getNextXid();
1602 // Create multipart request body for fetch all the group stats
1603 MultipartRequestTableCaseBuilder multipartRequestTableCaseBuilder = new MultipartRequestTableCaseBuilder();
1604 MultipartRequestTableBuilder multipartRequestTableBuilder = new MultipartRequestTableBuilder();
1605 multipartRequestTableBuilder.setEmpty(true);
1606 multipartRequestTableCaseBuilder.setMultipartRequestTable(multipartRequestTableBuilder.build());
1608 // Set request body to main multipart request
1609 MultipartRequestInputBuilder mprInput =
1610 createMultipartHeader(MultipartType.OFPMPTABLE, taskContext, xid);
1611 mprInput.setMultipartRequestBody(multipartRequestTableCaseBuilder.build());
1612 Future<RpcResult<Void>> resultFromOFLib = getMessageService()
1613 .multipartRequest(mprInput.build(), getCookie());
1614 ListenableFuture<RpcResult<Void>> resultLib = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
1616 Futures.addCallback(resultLib, new ResultCallback<GetFlowTablesStatisticsOutput>(result) {
1618 public GetFlowTablesStatisticsOutput createResult() {
1619 GetFlowTablesStatisticsOutputBuilder flowTableStatsBuilder =
1620 new GetFlowTablesStatisticsOutputBuilder()
1621 .setTransactionId(new TransactionId(BigInteger.valueOf(xid)));
1622 return flowTableStatsBuilder.build();
1632 * @param taskContext
1637 public static OFRpcTask<GetAllQueuesStatisticsFromAllPortsInput, RpcResult<GetAllQueuesStatisticsFromAllPortsOutput>> createGetAllQueuesStatisticsFromAllPortsTask(
1638 final OFRpcTaskContext taskContext, final GetAllQueuesStatisticsFromAllPortsInput input, SwitchConnectionDistinguisher cookie) {
1639 OFRpcTask<GetAllQueuesStatisticsFromAllPortsInput, RpcResult<GetAllQueuesStatisticsFromAllPortsOutput>> task =
1640 new OFRpcTask<GetAllQueuesStatisticsFromAllPortsInput, RpcResult<GetAllQueuesStatisticsFromAllPortsOutput>>(taskContext, cookie, input) {
1643 public ListenableFuture<RpcResult<GetAllQueuesStatisticsFromAllPortsOutput>> call() throws Exception {
1644 final SettableFuture<RpcResult<GetAllQueuesStatisticsFromAllPortsOutput>> result = SettableFuture.create();
1646 final Long xid = taskContext.getSession().getNextXid();
1648 MultipartRequestQueueCaseBuilder caseBuilder = new MultipartRequestQueueCaseBuilder();
1649 MultipartRequestQueueBuilder mprQueueBuilder = new MultipartRequestQueueBuilder();
1651 mprQueueBuilder.setPortNo(OFConstants.OFPP_ANY);
1652 // Select all the ports
1653 mprQueueBuilder.setQueueId(OFConstants.OFPQ_ANY);
1654 caseBuilder.setMultipartRequestQueue(mprQueueBuilder.build());
1656 // Set request body to main multipart request
1657 MultipartRequestInputBuilder mprInput =
1658 createMultipartHeader(MultipartType.OFPMPQUEUE, taskContext, xid);
1659 mprInput.setMultipartRequestBody(caseBuilder.build());
1660 Future<RpcResult<Void>> resultFromOFLib = getMessageService()
1661 .multipartRequest(mprInput.build(), getCookie());
1662 ListenableFuture<RpcResult<Void>> resultLib = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
1664 Futures.addCallback(resultLib, new ResultCallback<GetAllQueuesStatisticsFromAllPortsOutput>(result) {
1666 public GetAllQueuesStatisticsFromAllPortsOutput createResult() {
1667 GetAllQueuesStatisticsFromAllPortsOutputBuilder allQueueStatsBuilder =
1668 new GetAllQueuesStatisticsFromAllPortsOutputBuilder()
1669 .setTransactionId(new TransactionId(BigInteger.valueOf(xid)));
1670 return allQueueStatsBuilder.build();
1680 * @param taskContext
1685 public static OFRpcTask<GetAllQueuesStatisticsFromGivenPortInput, RpcResult<GetAllQueuesStatisticsFromGivenPortOutput>> createGetAllQueuesStatisticsFromGivenPortTask(
1686 final OFRpcTaskContext taskContext, final GetAllQueuesStatisticsFromGivenPortInput input, SwitchConnectionDistinguisher cookie) {
1687 OFRpcTask<GetAllQueuesStatisticsFromGivenPortInput, RpcResult<GetAllQueuesStatisticsFromGivenPortOutput>> task =
1688 new OFRpcTask<GetAllQueuesStatisticsFromGivenPortInput, RpcResult<GetAllQueuesStatisticsFromGivenPortOutput>>(taskContext, cookie, input) {
1691 public ListenableFuture<RpcResult<GetAllQueuesStatisticsFromGivenPortOutput>> call() throws Exception {
1692 final SettableFuture<RpcResult<GetAllQueuesStatisticsFromGivenPortOutput>> result = SettableFuture.create();
1694 final Long xid = taskContext.getSession().getNextXid();
1696 MultipartRequestQueueCaseBuilder caseBuilder = new MultipartRequestQueueCaseBuilder();
1697 MultipartRequestQueueBuilder mprQueueBuilder = new MultipartRequestQueueBuilder();
1698 // Select all queues
1699 mprQueueBuilder.setQueueId(OFConstants.OFPQ_ANY);
1700 // Select specific port
1701 mprQueueBuilder.setPortNo(InventoryDataServiceUtil.portNumberfromNodeConnectorId(
1702 OpenflowVersion.get(taskContext.getSession().getFeatures().getVersion()),
1703 input.getNodeConnectorId()));
1704 caseBuilder.setMultipartRequestQueue(mprQueueBuilder.build());
1706 // Set request body to main multipart request
1707 MultipartRequestInputBuilder mprInput =
1708 createMultipartHeader(MultipartType.OFPMPQUEUE, taskContext, xid);
1709 mprInput.setMultipartRequestBody(caseBuilder.build());
1710 Future<RpcResult<Void>> resultFromOFLib = getMessageService()
1711 .multipartRequest(mprInput.build(), getCookie());
1712 ListenableFuture<RpcResult<Void>> resultLib = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
1714 Futures.addCallback(resultLib, new ResultCallback<GetAllQueuesStatisticsFromGivenPortOutput>(result) {
1716 public GetAllQueuesStatisticsFromGivenPortOutput createResult() {
1717 GetAllQueuesStatisticsFromGivenPortOutputBuilder allQueueStatsBuilder =
1718 new GetAllQueuesStatisticsFromGivenPortOutputBuilder()
1719 .setTransactionId(new TransactionId(BigInteger.valueOf(xid)));
1720 return allQueueStatsBuilder.build();
1730 * @param taskContext
1735 public static OFRpcTask<GetQueueStatisticsFromGivenPortInput, RpcResult<GetQueueStatisticsFromGivenPortOutput>> createGetQueueStatisticsFromGivenPortTask(
1736 final OFRpcTaskContext taskContext, final GetQueueStatisticsFromGivenPortInput input, SwitchConnectionDistinguisher cookie) {
1737 OFRpcTask<GetQueueStatisticsFromGivenPortInput, RpcResult<GetQueueStatisticsFromGivenPortOutput>> task =
1738 new OFRpcTask<GetQueueStatisticsFromGivenPortInput, RpcResult<GetQueueStatisticsFromGivenPortOutput>>(taskContext, cookie, input) {
1741 public ListenableFuture<RpcResult<GetQueueStatisticsFromGivenPortOutput>> call() throws Exception {
1742 final SettableFuture<RpcResult<GetQueueStatisticsFromGivenPortOutput>> result = SettableFuture.create();
1744 final Long xid = taskContext.getSession().getNextXid();
1746 MultipartRequestQueueCaseBuilder caseBuilder = new MultipartRequestQueueCaseBuilder();
1747 MultipartRequestQueueBuilder mprQueueBuilder = new MultipartRequestQueueBuilder();
1748 // Select specific queue
1749 mprQueueBuilder.setQueueId(input.getQueueId().getValue());
1750 // Select specific port
1751 mprQueueBuilder.setPortNo(InventoryDataServiceUtil.portNumberfromNodeConnectorId(
1752 OpenflowVersion.get(taskContext.getSession().getFeatures().getVersion()),
1753 input.getNodeConnectorId()));
1754 caseBuilder.setMultipartRequestQueue(mprQueueBuilder.build());
1756 // Set request body to main multipart request
1757 MultipartRequestInputBuilder mprInput =
1758 createMultipartHeader(MultipartType.OFPMPQUEUE, taskContext, xid);
1759 mprInput.setMultipartRequestBody(caseBuilder.build());
1760 Future<RpcResult<Void>> resultFromOFLib = getMessageService()
1761 .multipartRequest(mprInput.build(), getCookie());
1762 ListenableFuture<RpcResult<Void>> resultLib = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
1764 Futures.addCallback(resultLib, new ResultCallback<GetQueueStatisticsFromGivenPortOutput>(result) {
1766 public GetQueueStatisticsFromGivenPortOutput createResult() {
1767 GetQueueStatisticsFromGivenPortOutputBuilder queueStatsFromPortBuilder =
1768 new GetQueueStatisticsFromGivenPortOutputBuilder()
1769 .setTransactionId(new TransactionId(BigInteger.valueOf(xid)));
1770 return queueStatsFromPortBuilder.build();
1779 static MultipartRequestInputBuilder createMultipartHeader(MultipartType multipart,
1780 OFRpcTaskContext taskContext, Long xid) {
1781 MultipartRequestInputBuilder mprInput = new MultipartRequestInputBuilder();
1782 mprInput.setType(multipart);
1783 mprInput.setVersion(taskContext.getSession().getPrimaryConductor().getVersion());
1784 mprInput.setXid(xid);
1785 mprInput.setFlags(new MultipartRequestFlags(false));
1789 private static abstract class ResultCallback<T> implements FutureCallback<RpcResult<Void>> {
1791 private SettableFuture<RpcResult<T>> result;
1796 public ResultCallback(SettableFuture<RpcResult<T>> result) {
1797 this.result = result;
1800 public abstract T createResult();
1803 public void onSuccess(RpcResult<Void> resultArg) {
1804 result.set(RpcResultBuilder.success(createResult()).build());
1808 public void onFailure(Throwable t) {
1809 result.set(RpcResultBuilder.<T>failed().withWarning(
1811 OFConstants.ERROR_TAG_TIMEOUT,
1812 "something wrong happened",
1813 OFConstants.APPLICATION_TAG,
1819 * @param taskContext
1824 public static OFRpcTask<UpdatePortInput, RpcResult<UpdatePortOutput>> createUpdatePortTask(
1825 final OFRpcTaskContext taskContext, final UpdatePortInput input,
1826 final SwitchConnectionDistinguisher cookie) {
1827 OFRpcTask<UpdatePortInput, RpcResult<UpdatePortOutput>> task =
1828 new OFRpcTask<UpdatePortInput, RpcResult<UpdatePortOutput>>(taskContext, cookie, input) {
1831 public ListenableFuture<RpcResult<UpdatePortOutput>> call() {
1832 ListenableFuture<RpcResult<UpdatePortOutput>> result = SettableFuture.create();
1833 final Long xid = taskContext.getSession().getNextXid();
1834 Port inputPort = input.getUpdatedPort().getPort().getPort().get(0);
1836 PortModInput ofPortModInput = PortConvertor.toPortModInput(inputPort,
1837 taskContext.getSession().getPrimaryConductor().getVersion());
1839 PortModInputBuilder mdInput = new PortModInputBuilder(ofPortModInput);
1840 mdInput.setXid(xid);
1842 Future<RpcResult<UpdatePortOutput>> resultFromOFLib = getMessageService()
1843 .portMod(mdInput.build(), cookie);
1844 result = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
1855 * @param taskContext
1860 public static OFRpcTask<UpdateTableInput, RpcResult<UpdateTableOutput>> createUpdateTableTask(
1861 final OFRpcTaskContext taskContext, final UpdateTableInput input,
1862 final SwitchConnectionDistinguisher cookie) {
1863 OFRpcTask<UpdateTableInput, RpcResult<UpdateTableOutput>> task =
1864 new OFRpcTask<UpdateTableInput, RpcResult<UpdateTableOutput>>(taskContext, cookie, input) {
1867 public ListenableFuture<RpcResult<UpdateTableOutput>> call() {
1868 final SettableFuture<RpcResult<UpdateTableOutput>> result = SettableFuture.create();
1870 final Long xid = taskContext.getSession().getNextXid();
1872 MultipartRequestTableFeaturesCaseBuilder caseBuilder = new MultipartRequestTableFeaturesCaseBuilder();
1873 MultipartRequestTableFeaturesBuilder requestBuilder = new MultipartRequestTableFeaturesBuilder();
1874 List<TableFeatures> ofTableFeatureList = TableFeaturesConvertor
1875 .toTableFeaturesRequest(input.getUpdatedTable());
1876 requestBuilder.setTableFeatures(ofTableFeatureList);
1877 caseBuilder.setMultipartRequestTableFeatures(requestBuilder.build());
1879 // Set request body to main multipart request
1880 MultipartRequestInputBuilder mprInput =
1881 createMultipartHeader(MultipartType.OFPMPTABLEFEATURES, taskContext, xid);
1882 mprInput.setMultipartRequestBody(caseBuilder.build());
1884 Future<RpcResult<Void>> resultFromOFLib = getMessageService()
1885 .multipartRequest(mprInput.build(), getCookie());
1886 ListenableFuture<RpcResult<Void>> resultLib = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
1888 Futures.addCallback(resultLib, new ResultCallback<UpdateTableOutput>(result) {
1890 public UpdateTableOutput createResult() {
1891 UpdateTableOutputBuilder queueStatsFromPortBuilder =
1892 new UpdateTableOutputBuilder()
1893 .setTransactionId(new TransactionId(BigInteger.valueOf(xid)));
1894 return queueStatsFromPortBuilder.build();
1903 public static OFRpcTask<SetConfigInput, RpcResult<SetConfigOutput>> createSetNodeConfigTask(final OFRpcTaskContext taskContext,
1904 final SetConfigInput input,
1905 final SwitchConnectionDistinguisher cookie) {
1906 OFRpcTask<SetConfigInput, RpcResult<SetConfigOutput>> rpcTask = new OFRpcTask<SetConfigInput, RpcResult<SetConfigOutput>>(taskContext, cookie, input) {
1908 public ListenableFuture<RpcResult<SetConfigOutput>> call() throws Exception {
1910 final SettableFuture<RpcResult<SetConfigOutput>> result = SettableFuture.create();
1911 final Long xid = taskContext.getSession().getNextXid();
1913 SetConfigInputBuilder builder = new SetConfigInputBuilder();
1914 SwitchConfigFlag flag = SwitchConfigFlag.valueOf(input.getFlag());
1915 builder.setXid(xid);
1916 builder.setFlags(flag);
1917 builder.setMissSendLen(input.getMissSearchLength());
1918 builder.setVersion(getVersion());
1919 ListenableFuture<RpcResult<Void>> resultLib = JdkFutureAdapters.listenInPoolThread(taskContext.getSession().getPrimaryConductor().getConnectionAdapter().setConfig(builder.build()));
1920 Futures.addCallback(resultLib, new ResultCallback<SetConfigOutput>(result) {
1922 public SetConfigOutput createResult() {
1923 SetConfigOutputBuilder setConfigOutputBuilder = new SetConfigOutputBuilder();
1924 setConfigOutputBuilder.setTransactionId(new TransactionId(BigInteger.valueOf(xid)));
1925 return setConfigOutputBuilder.build();