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 java.math.BigInteger;
11 import java.util.Collection;
12 import java.util.Collections;
13 import java.util.List;
14 import java.util.concurrent.Future;
16 import org.opendaylight.controller.sal.common.util.RpcErrors;
17 import org.opendaylight.controller.sal.common.util.Rpcs;
18 import org.opendaylight.openflowjava.protocol.api.util.BinContent;
19 import org.opendaylight.openflowplugin.openflow.md.OFConstants;
20 import org.opendaylight.openflowplugin.openflow.md.core.SwitchConnectionDistinguisher;
21 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.FlowConvertor;
22 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.GroupConvertor;
23 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.MeterConvertor;
24 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.PortConvertor;
25 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.TableFeaturesConvertor;
26 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchReactor;
27 import org.opendaylight.openflowplugin.openflow.md.util.FlowCreatorUtil;
28 import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
29 import org.opendaylight.openflowplugin.openflow.md.util.OpenflowVersion;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowAdded;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowAddedBuilder;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowRemoved;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowRemovedBuilder;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowUpdated;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowUpdatedBuilder;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInput;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInputBuilder;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInput;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowOutput;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutputBuilder;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableInput;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableOutput;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableOutputBuilder;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesInput;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesOutput;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesOutputBuilder;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableInput;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableOutput;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableOutputBuilder;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsInput;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsOutput;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsOutputBuilder;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionId;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.Port;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInput;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.GroupAdded;
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.GroupAddedBuilder;
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.GroupRemoved;
67 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.GroupRemovedBuilder;
68 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.GroupUpdated;
69 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.GroupUpdatedBuilder;
70 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInput;
71 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupInput;
72 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupOutput;
73 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsInput;
74 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsOutput;
75 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsOutputBuilder;
76 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupDescriptionInput;
77 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupDescriptionOutput;
78 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupDescriptionOutputBuilder;
79 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupFeaturesInput;
80 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupFeaturesOutput;
81 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupFeaturesOutputBuilder;
82 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupStatisticsInput;
83 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupStatisticsOutput;
84 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupStatisticsOutputBuilder;
85 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group;
86 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterInput;
87 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.MeterAdded;
88 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.MeterAddedBuilder;
89 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.MeterRemoved;
90 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.MeterRemovedBuilder;
91 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.MeterUpdated;
92 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.MeterUpdatedBuilder;
93 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterInput;
94 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterInput;
95 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterOutput;
96 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsInput;
97 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsOutput;
98 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsOutputBuilder;
99 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterStatisticsInput;
100 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterStatisticsOutput;
101 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterStatisticsOutputBuilder;
102 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterFeaturesInput;
103 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterFeaturesOutput;
104 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterFeaturesOutputBuilder;
105 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsInput;
106 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsOutput;
107 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsOutputBuilder;
108 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.Meter;
109 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId;
110 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId;
111 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags;
112 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
113 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInputBuilder;
114 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInputBuilder;
115 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInputBuilder;
116 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
117 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput;
118 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInputBuilder;
119 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestAggregateCaseBuilder;
120 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlowCaseBuilder;
121 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupCaseBuilder;
122 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupDescCaseBuilder;
123 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupFeaturesCaseBuilder;
124 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterCaseBuilder;
125 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterConfigCaseBuilder;
126 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterFeaturesCaseBuilder;
127 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortStatsCaseBuilder;
128 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestQueueCaseBuilder;
129 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableCaseBuilder;
130 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableFeaturesCaseBuilder;
131 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.aggregate._case.MultipartRequestAggregateBuilder;
132 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.flow._case.MultipartRequestFlowBuilder;
133 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.group._case.MultipartRequestGroupBuilder;
134 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.meter._case.MultipartRequestMeterBuilder;
135 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.meter.config._case.MultipartRequestMeterConfigBuilder;
136 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.port.stats._case.MultipartRequestPortStatsBuilder;
137 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.queue._case.MultipartRequestQueueBuilder;
138 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table._case.MultipartRequestTableBuilder;
139 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.MultipartRequestTableFeaturesBuilder;
140 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;
141 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.UpdatePortInput;
142 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.UpdatePortOutput;
143 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllNodeConnectorsStatisticsInput;
144 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllNodeConnectorsStatisticsOutput;
145 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllNodeConnectorsStatisticsOutputBuilder;
146 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetNodeConnectorStatisticsInput;
147 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetNodeConnectorStatisticsOutput;
148 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetNodeConnectorStatisticsOutputBuilder;
149 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromAllPortsInput;
150 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromAllPortsOutput;
151 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromAllPortsOutputBuilder;
152 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromGivenPortInput;
153 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromGivenPortOutput;
154 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromGivenPortOutputBuilder;
155 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetQueueStatisticsFromGivenPortInput;
156 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetQueueStatisticsFromGivenPortOutput;
157 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetQueueStatisticsFromGivenPortOutputBuilder;
158 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableInput;
159 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableOutput;
160 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableOutputBuilder;
161 import org.opendaylight.yangtools.yang.common.RpcError;
162 import org.opendaylight.yangtools.yang.common.RpcError.ErrorSeverity;
163 import org.opendaylight.yangtools.yang.common.RpcError.ErrorType;
164 import org.opendaylight.yangtools.yang.common.RpcResult;
166 import com.google.common.util.concurrent.FutureCallback;
167 import com.google.common.util.concurrent.Futures;
168 import com.google.common.util.concurrent.JdkFutureAdapters;
169 import com.google.common.util.concurrent.ListenableFuture;
170 import com.google.common.util.concurrent.SettableFuture;
175 public abstract class OFRpcTaskFactory {
181 * @return UpdateFlow task
183 public static OFRpcTask<AddFlowInput, RpcResult<UpdateFlowOutput>> createAddFlowTask(
184 OFRpcTaskContext taskContext, AddFlowInput input,
185 SwitchConnectionDistinguisher cookie) {
186 OFRpcTask<AddFlowInput, RpcResult<UpdateFlowOutput>> task =
187 new OFRpcTask<AddFlowInput, RpcResult<UpdateFlowOutput>>(taskContext, cookie, input) {
190 public ListenableFuture<RpcResult<UpdateFlowOutput>> call() {
191 ListenableFuture<RpcResult<UpdateFlowOutput>> result = SettableFuture.create();
193 Collection<RpcError> barrierErrors = OFRpcTaskUtil.manageBarrier(getTaskContext(), getInput().isBarrier(), getCookie());
194 if (!barrierErrors.isEmpty()) {
195 OFRpcTaskUtil.wrapBarrierErrors(((SettableFuture<RpcResult<UpdateFlowOutput>>) result), barrierErrors);
197 // Convert the AddFlowInput to FlowModInput
198 FlowModInputBuilder ofFlowModInput = FlowConvertor.toFlowModInput(getInput(),
199 getVersion(), getSession().getFeatures().getDatapathId());
200 final Long xId = getSession().getNextXid();
201 ofFlowModInput.setXid(xId);
203 Future<RpcResult<UpdateFlowOutput>> resultFromOFLib =
204 getMessageService().flowMod(ofFlowModInput.build(), getCookie());
205 result = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
207 OFRpcTaskUtil.hookFutureNotification(this, result,
208 getRpcNotificationProviderService(), createFlowAddedNotification(xId, getInput()));
222 protected static NotificationComposer<FlowAdded> createFlowAddedNotification(
223 final Long xId, final AddFlowInput input) {
224 return new NotificationComposer<FlowAdded>() {
226 public FlowAdded compose() {
227 FlowAddedBuilder newFlow = new FlowAddedBuilder((Flow) input);
228 newFlow.setTransactionId(new TransactionId(BigInteger.valueOf(xId.intValue())));
229 newFlow.setFlowRef(input.getFlowRef());
230 return newFlow.build();
239 * @return UpdateFlow task
241 public static OFRpcTask<UpdateFlowInput, RpcResult<UpdateFlowOutput>> createUpdateFlowTask(
242 OFRpcTaskContext taskContext, UpdateFlowInput input,
243 SwitchConnectionDistinguisher cookie) {
245 OFRpcTask<UpdateFlowInput, RpcResult<UpdateFlowOutput>> task =
246 new OFRpcTask<UpdateFlowInput, RpcResult<UpdateFlowOutput>>(taskContext, cookie, input) {
249 public ListenableFuture<RpcResult<UpdateFlowOutput>> call() {
250 ListenableFuture<RpcResult<UpdateFlowOutput>> result = null;
251 Collection<RpcError> barrierErrors = OFRpcTaskUtil.manageBarrier(getTaskContext(),
252 getInput().getUpdatedFlow().isBarrier(), getCookie());
253 if (!barrierErrors.isEmpty()) {
254 OFRpcTaskUtil.wrapBarrierErrors(((SettableFuture<RpcResult<UpdateFlowOutput>>) result), barrierErrors);
258 Long xId = getSession().getNextXid();
259 boolean updatedFlow = (getInput().getUpdatedFlow().getMatch().equals(getInput().getOriginalFlow().getMatch())) &&
260 (getInput().getUpdatedFlow().getPriority().equals(getInput().getOriginalFlow().getPriority()));
263 if (updatedFlow == false) {
264 // if neither match nor priority matches, then we would need to remove the flow and add it
266 RemoveFlowInputBuilder removeflow = new RemoveFlowInputBuilder(getInput().getOriginalFlow());
267 FlowModInputBuilder ofFlowRemoveInput = FlowConvertor.toFlowModInput(removeflow.build(),
268 getVersion(),getSession().getFeatures().getDatapathId());
269 ofFlowRemoveInput.setXid(xId);
270 Future<RpcResult<UpdateFlowOutput>> resultFromOFLibRemove = getMessageService().
271 flowMod(ofFlowRemoveInput.build(), getCookie());
273 AddFlowInputBuilder addFlow = new AddFlowInputBuilder(getInput().getUpdatedFlow());
274 flow = addFlow.build();
277 flow = getInput().getUpdatedFlow();
280 FlowModInputBuilder ofFlowModInput = FlowConvertor.toFlowModInput(flow, getVersion(),
281 getSession().getFeatures().getDatapathId());
283 ofFlowModInput.setXid(xId);
285 Future<RpcResult<UpdateFlowOutput>> resultFromOFLib =
286 getMessageService().flowMod(ofFlowModInput.build(), getCookie());
287 result = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
289 OFRpcTaskUtil.hookFutureNotification(this, result,
290 getRpcNotificationProviderService(), createFlowUpdatedNotification(xId, getInput()));
303 protected static NotificationComposer<FlowUpdated> createFlowUpdatedNotification(
304 final Long xId, final UpdateFlowInput input) {
305 return new NotificationComposer<FlowUpdated>() {
307 public FlowUpdated compose() {
308 FlowUpdatedBuilder updFlow = new FlowUpdatedBuilder(input.getUpdatedFlow());
309 updFlow.setTransactionId(new TransactionId(BigInteger.valueOf(xId.intValue())));
310 updFlow.setFlowRef(input.getFlowRef());
311 return updFlow.build();
320 * @return update group task
322 public static OFRpcTask<AddGroupInput, RpcResult<UpdateGroupOutput>> createAddGroupTask(
323 final OFRpcTaskContext taskContext, AddGroupInput input,
324 final SwitchConnectionDistinguisher cookie) {
325 OFRpcTask<AddGroupInput, RpcResult<UpdateGroupOutput>> task =
326 new OFRpcTask<AddGroupInput, RpcResult<UpdateGroupOutput>>(taskContext, cookie, input) {
329 public ListenableFuture<RpcResult<UpdateGroupOutput>> call() {
330 ListenableFuture<RpcResult<UpdateGroupOutput>> result = SettableFuture.create();
332 Collection<RpcError> barrierErrors = OFRpcTaskUtil.manageBarrier(getTaskContext(), getInput().isBarrier(), getCookie());
333 if (!barrierErrors.isEmpty()) {
334 OFRpcTaskUtil.wrapBarrierErrors(((SettableFuture<RpcResult<UpdateGroupOutput>>) result), barrierErrors);
336 // Convert the AddGroupInput to GroupModInput
337 GroupModInputBuilder ofGroupModInput = GroupConvertor.toGroupModInput(getInput(),
338 getVersion(), getSession().getFeatures().getDatapathId());
339 final Long xId = getSession().getNextXid();
340 ofGroupModInput.setXid(xId);
342 Future<RpcResult<UpdateGroupOutput>> resultFromOFLib = getMessageService()
343 .groupMod(ofGroupModInput.build(), getCookie());
344 result = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
346 OFRpcTaskUtil.hookFutureNotification(this, result,
347 getRpcNotificationProviderService(), createGroupAddedNotification(xId, getInput()));
363 protected static NotificationComposer<GroupAdded> createGroupAddedNotification(
364 final Long xId, final AddGroupInput input) {
365 return new NotificationComposer<GroupAdded>() {
367 public GroupAdded compose() {
368 GroupAddedBuilder groupMod = new GroupAddedBuilder((Group) input);
369 groupMod.setTransactionId(new TransactionId(BigInteger.valueOf(xId.intValue())));
370 groupMod.setGroupRef(input.getGroupRef());
371 return groupMod.build();
380 * @return update meter task
382 public static OFRpcTask<AddMeterInput, RpcResult<UpdateMeterOutput>> createAddMeterTask(
383 OFRpcTaskContext taskContext, AddMeterInput input,
384 SwitchConnectionDistinguisher cookie) {
385 OFRpcTask<AddMeterInput, RpcResult<UpdateMeterOutput>> task =
386 new OFRpcTask<AddMeterInput, RpcResult<UpdateMeterOutput>>(taskContext, cookie, input) {
389 public ListenableFuture<RpcResult<UpdateMeterOutput>> call() {
390 ListenableFuture<RpcResult<UpdateMeterOutput>> result = SettableFuture.create();
392 Collection<RpcError> barrierErrors = OFRpcTaskUtil.manageBarrier(getTaskContext(), getInput().isBarrier(), getCookie());
393 if (!barrierErrors.isEmpty()) {
394 OFRpcTaskUtil.wrapBarrierErrors(((SettableFuture<RpcResult<UpdateMeterOutput>>) result), barrierErrors);
396 // Convert the AddGroupInput to GroupModInput
397 MeterModInputBuilder ofMeterModInput = MeterConvertor.toMeterModInput(getInput(), getVersion());
398 final Long xId = getSession().getNextXid();
399 ofMeterModInput.setXid(xId);
401 Future<RpcResult<UpdateMeterOutput>> resultFromOFLib = getMessageService()
402 .meterMod(ofMeterModInput.build(), getCookie());
403 result = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
405 OFRpcTaskUtil.hookFutureNotification(this, result,
406 getRpcNotificationProviderService(), createMeterAddedNotification(xId, getInput()));
422 protected static NotificationComposer<MeterAdded> createMeterAddedNotification(
423 final Long xId, final AddMeterInput input) {
424 return new NotificationComposer<MeterAdded>() {
426 public MeterAdded compose() {
427 MeterAddedBuilder meterMod = new MeterAddedBuilder((Meter) input);
428 meterMod.setTransactionId(new TransactionId(BigInteger.valueOf(xId.intValue())));
429 meterMod.setMeterRef(input.getMeterRef());
430 return meterMod.build();
439 * @return UpdateFlow task
441 public static OFRpcTask<UpdateGroupInput, RpcResult<UpdateGroupOutput>> createUpdateGroupTask(
442 OFRpcTaskContext taskContext, UpdateGroupInput input,
443 SwitchConnectionDistinguisher cookie) {
444 OFRpcTask<UpdateGroupInput, RpcResult<UpdateGroupOutput>> task =
445 new OFRpcTask<UpdateGroupInput, RpcResult<UpdateGroupOutput>>(taskContext, cookie, input) {
448 public ListenableFuture<RpcResult<UpdateGroupOutput>> call() {
449 ListenableFuture<RpcResult<UpdateGroupOutput>> result = null;
450 Collection<RpcError> barrierErrors = OFRpcTaskUtil.manageBarrier(getTaskContext(),
451 getInput().getUpdatedGroup().isBarrier(), getCookie());
452 if (!barrierErrors.isEmpty()) {
453 OFRpcTaskUtil.wrapBarrierErrors(((SettableFuture<RpcResult<UpdateGroupOutput>>) result), barrierErrors);
455 // Convert the UpdateGroupInput to GroupModInput
456 GroupModInputBuilder ofGroupModInput = GroupConvertor.toGroupModInput(
457 getInput().getUpdatedGroup(), getVersion(),
458 getSession().getFeatures().getDatapathId());
459 final Long xId = getSession().getNextXid();
460 ofGroupModInput.setXid(xId);
462 Future<RpcResult<UpdateGroupOutput>> resultFromOFLib =
463 getMessageService().groupMod(ofGroupModInput.build(), getCookie());
464 result = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
466 OFRpcTaskUtil.hookFutureNotification(this, result,
467 getRpcNotificationProviderService(), createGroupUpdatedNotification(xId, getInput()));
480 protected static NotificationComposer<GroupUpdated> createGroupUpdatedNotification(
481 final Long xId, final UpdateGroupInput input) {
482 return new NotificationComposer<GroupUpdated>() {
484 public GroupUpdated compose() {
485 GroupUpdatedBuilder groupMod = new GroupUpdatedBuilder(input.getUpdatedGroup());
486 groupMod.setTransactionId(new TransactionId(BigInteger.valueOf(xId.intValue())));
487 groupMod.setGroupRef(input.getGroupRef());
488 return groupMod.build();
497 * @return update meter task
499 public static OFRpcTask<UpdateMeterInput, RpcResult<UpdateMeterOutput>> createUpdateMeterTask(
500 OFRpcTaskContext taskContext, UpdateMeterInput input,
501 SwitchConnectionDistinguisher cookie) {
502 OFRpcTask<UpdateMeterInput, RpcResult<UpdateMeterOutput>> task =
503 new OFRpcTask<UpdateMeterInput, RpcResult<UpdateMeterOutput>>(taskContext, cookie, input) {
506 public ListenableFuture<RpcResult<UpdateMeterOutput>> call() {
507 ListenableFuture<RpcResult<UpdateMeterOutput>> result = null;
508 Collection<RpcError> barrierErrors = OFRpcTaskUtil.manageBarrier(getTaskContext(),
509 getInput().getUpdatedMeter().isBarrier(), getCookie());
510 if (!barrierErrors.isEmpty()) {
511 OFRpcTaskUtil.wrapBarrierErrors(((SettableFuture<RpcResult<UpdateMeterOutput>>) result), barrierErrors);
513 // Convert the UpdateMeterInput to MeterModInput
514 MeterModInputBuilder ofMeterModInput = MeterConvertor.toMeterModInput(
515 getInput().getUpdatedMeter(), getVersion());
516 final Long xId = getSession().getNextXid();
517 ofMeterModInput.setXid(xId);
519 Future<RpcResult<UpdateMeterOutput>> resultFromOFLib =
520 getMessageService().meterMod(ofMeterModInput.build(), getCookie());
521 result = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
523 OFRpcTaskUtil.hookFutureNotification(this, result,
524 getRpcNotificationProviderService(), createMeterUpdatedNotification(xId, getInput()));
537 protected static NotificationComposer<MeterUpdated> createMeterUpdatedNotification(
538 final Long xId, final UpdateMeterInput input) {
539 return new NotificationComposer<MeterUpdated>() {
541 public MeterUpdated compose() {
542 MeterUpdatedBuilder meterMod = new MeterUpdatedBuilder(input.getUpdatedMeter());
543 meterMod.setTransactionId(new TransactionId(BigInteger.valueOf(xId.intValue())));
544 meterMod.setMeterRef(input.getMeterRef());
545 return meterMod.build();
557 public static OFRpcTask<RemoveFlowInput, RpcResult<UpdateFlowOutput>> createRemoveFlowTask(
558 OFRpcTaskContext taskContext, RemoveFlowInput input,
559 SwitchConnectionDistinguisher cookie) {
560 OFRpcTask<RemoveFlowInput, RpcResult<UpdateFlowOutput>> task =
561 new OFRpcTask<RemoveFlowInput, RpcResult<UpdateFlowOutput>>(taskContext, cookie, input) {
564 public ListenableFuture<RpcResult<UpdateFlowOutput>> call() {
565 ListenableFuture<RpcResult<UpdateFlowOutput>> result = SettableFuture.create();
567 Collection<RpcError> barrierErrors = OFRpcTaskUtil.manageBarrier(getTaskContext(), getInput().isBarrier(), getCookie());
568 if (!barrierErrors.isEmpty()) {
569 OFRpcTaskUtil.wrapBarrierErrors(((SettableFuture<RpcResult<UpdateFlowOutput>>) result), barrierErrors);
571 // Convert the AddFlowInput to FlowModInput
572 FlowModInputBuilder ofFlowModInput = FlowConvertor.toFlowModInput(getInput(),
573 getVersion(), getSession().getFeatures().getDatapathId());
574 final Long xId = getSession().getNextXid();
575 ofFlowModInput.setXid(xId);
577 Future<RpcResult<UpdateFlowOutput>> resultFromOFLib =
578 getMessageService().flowMod(ofFlowModInput.build(), getCookie());
579 result = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
581 OFRpcTaskUtil.hookFutureNotification(this, result,
582 getRpcNotificationProviderService(), createFlowRemovedNotification(xId, getInput()));
596 protected static NotificationComposer<FlowRemoved> createFlowRemovedNotification(
597 final Long xId, final RemoveFlowInput input) {
598 return new NotificationComposer<FlowRemoved>() {
600 public FlowRemoved compose() {
601 FlowRemovedBuilder removedFlow = new FlowRemovedBuilder((Flow) input);
602 removedFlow.setTransactionId(new TransactionId(BigInteger.valueOf(xId.intValue())));
603 removedFlow.setFlowRef(input.getFlowRef());
604 return removedFlow.build();
616 public static OFRpcTask<RemoveGroupInput, RpcResult<UpdateGroupOutput>> createRemoveGroupTask(
617 final OFRpcTaskContext taskContext, RemoveGroupInput input,
618 final SwitchConnectionDistinguisher cookie) {
619 OFRpcTask<RemoveGroupInput, RpcResult<UpdateGroupOutput>> task =
620 new OFRpcTask<RemoveGroupInput, RpcResult<UpdateGroupOutput>>(taskContext, cookie, input) {
623 public ListenableFuture<RpcResult<UpdateGroupOutput>> call() {
624 ListenableFuture<RpcResult<UpdateGroupOutput>> result = SettableFuture.create();
626 Collection<RpcError> barrierErrors = OFRpcTaskUtil.manageBarrier(getTaskContext(), getInput().isBarrier(), getCookie());
627 if (!barrierErrors.isEmpty()) {
628 OFRpcTaskUtil.wrapBarrierErrors(((SettableFuture<RpcResult<UpdateGroupOutput>>) result), barrierErrors);
630 // Convert the AddGroupInput to GroupModInput
631 GroupModInputBuilder ofGroupModInput = GroupConvertor.toGroupModInput(getInput(),
632 getVersion(), getSession().getFeatures().getDatapathId());
633 final Long xId = getSession().getNextXid();
634 ofGroupModInput.setXid(xId);
636 Future<RpcResult<UpdateGroupOutput>> resultFromOFLib = getMessageService()
637 .groupMod(ofGroupModInput.build(), getCookie());
638 result = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
640 OFRpcTaskUtil.hookFutureNotification(this, result,
641 getRpcNotificationProviderService(), createGroupRemovedNotification(xId, getInput()));
656 protected static NotificationComposer<GroupRemoved> createGroupRemovedNotification(
657 final Long xId, final RemoveGroupInput input) {
658 return new NotificationComposer<GroupRemoved>() {
660 public GroupRemoved compose() {
661 GroupRemovedBuilder removedGroup = new GroupRemovedBuilder((Group) input);
662 removedGroup.setTransactionId(new TransactionId(BigInteger.valueOf(xId.intValue())));
663 removedGroup.setGroupRef(input.getGroupRef());
664 return removedGroup.build();
675 public static OFRpcTask<RemoveMeterInput, RpcResult<UpdateMeterOutput>> createRemoveMeterTask(
676 OFRpcTaskContext taskContext, RemoveMeterInput input,
677 SwitchConnectionDistinguisher cookie) {
678 OFRpcTask<RemoveMeterInput, RpcResult<UpdateMeterOutput>> task =
679 new OFRpcTask<RemoveMeterInput, RpcResult<UpdateMeterOutput>>(taskContext, cookie, input) {
682 public ListenableFuture<RpcResult<UpdateMeterOutput>> call() {
683 ListenableFuture<RpcResult<UpdateMeterOutput>> result = SettableFuture.create();
685 Collection<RpcError> barrierErrors = OFRpcTaskUtil.manageBarrier(getTaskContext(), getInput().isBarrier(), getCookie());
686 if (!barrierErrors.isEmpty()) {
687 OFRpcTaskUtil.wrapBarrierErrors(((SettableFuture<RpcResult<UpdateMeterOutput>>) result), barrierErrors);
689 // Convert the AddGroupInput to GroupModInput
690 MeterModInputBuilder ofMeterModInput = MeterConvertor.toMeterModInput(getInput(), getVersion());
691 final Long xId = getSession().getNextXid();
692 ofMeterModInput.setXid(xId);
694 Future<RpcResult<UpdateMeterOutput>> resultFromOFLib = getMessageService()
695 .meterMod(ofMeterModInput.build(), getCookie());
696 result = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
698 OFRpcTaskUtil.hookFutureNotification(this, result,
699 getRpcNotificationProviderService(), createMeterRemovedNotification(xId, getInput()));
715 protected static NotificationComposer<MeterRemoved> createMeterRemovedNotification(
716 final Long xId, final RemoveMeterInput input) {
717 return new NotificationComposer<MeterRemoved>() {
719 public MeterRemoved compose() {
720 MeterRemovedBuilder meterRemoved = new MeterRemovedBuilder((Meter) input);
721 meterRemoved.setTransactionId(new TransactionId(BigInteger.valueOf(xId.intValue())));
722 meterRemoved.setMeterRef(input.getMeterRef());
723 return meterRemoved.build();
734 public static OFRpcTask<GetAllGroupStatisticsInput, RpcResult<GetAllGroupStatisticsOutput>> createGetAllGroupStatisticsTask(
735 final OFRpcTaskContext taskContext, GetAllGroupStatisticsInput input,
736 SwitchConnectionDistinguisher cookie) {
737 OFRpcTask<GetAllGroupStatisticsInput, RpcResult<GetAllGroupStatisticsOutput>> task =
738 new OFRpcTask<GetAllGroupStatisticsInput, RpcResult<GetAllGroupStatisticsOutput>>(taskContext, cookie, input) {
741 public ListenableFuture<RpcResult<GetAllGroupStatisticsOutput>> call() {
742 final SettableFuture<RpcResult<GetAllGroupStatisticsOutput>> result = SettableFuture.create();
744 if (taskContext.getSession().getPrimaryConductor().getVersion() == OFConstants.OFP_VERSION_1_0) {
745 Collection<RpcError> errors = Collections.emptyList();
746 RpcResult<GetAllGroupStatisticsOutput> rpcResult = Rpcs.getRpcResult(true,
747 new GetAllGroupStatisticsOutputBuilder().build(), errors);
749 return Futures.immediateFuture(rpcResult);
752 // Generate xid to associate it with the request
753 final Long xid = taskContext.getSession().getNextXid();
755 // Create multipart request body for fetch all the group stats
756 MultipartRequestGroupCaseBuilder caseBuilder = new MultipartRequestGroupCaseBuilder();
757 MultipartRequestGroupBuilder mprGroupBuild = new MultipartRequestGroupBuilder();
758 mprGroupBuild.setGroupId(new GroupId(BinContent.intToUnsignedLong(
759 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731
760 .Group.OFPGALL.getIntValue())));
761 caseBuilder.setMultipartRequestGroup(mprGroupBuild.build());
763 // Create multipart request header
764 MultipartRequestInputBuilder mprInput = createMultipartHeader(MultipartType.OFPMPGROUP,
767 // Set request body to main multipart request
768 mprInput.setMultipartRequestBody(caseBuilder.build());
770 // Send the request, no cookies associated, use any connection
772 Future<RpcResult<Void>> resultFromOFLib = getMessageService()
773 .multipartRequest(mprInput.build(), getCookie());
774 ListenableFuture<RpcResult<Void>> resultLib = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
776 Futures.addCallback(resultLib, new ResultCallback<GetAllGroupStatisticsOutput>(result) {
778 public GetAllGroupStatisticsOutput createResult() {
779 GetAllGroupStatisticsOutputBuilder groupStatBuilder = new GetAllGroupStatisticsOutputBuilder()
780 .setTransactionId(new TransactionId(BigInteger.valueOf(xid)));
781 return groupStatBuilder.build();
798 public static OFRpcTask<GetGroupDescriptionInput, RpcResult<GetGroupDescriptionOutput>> createGetGroupDescriptionTask(
799 final OFRpcTaskContext taskContext, GetGroupDescriptionInput input,
800 SwitchConnectionDistinguisher cookie) {
801 OFRpcTask<GetGroupDescriptionInput, RpcResult<GetGroupDescriptionOutput>> task =
802 new OFRpcTask<GetGroupDescriptionInput, RpcResult<GetGroupDescriptionOutput>>(taskContext, cookie, input) {
805 public ListenableFuture<RpcResult<GetGroupDescriptionOutput>> call()
807 final SettableFuture<RpcResult<GetGroupDescriptionOutput>> result = SettableFuture.create();
809 if (taskContext.getSession().getPrimaryConductor().getVersion() == OFConstants.OFP_VERSION_1_0) {
810 Collection<RpcError> errors = Collections.emptyList();
811 RpcResult<GetGroupDescriptionOutput> rpcResult = Rpcs.getRpcResult(true,
812 new GetGroupDescriptionOutputBuilder().build(), errors);
813 return Futures.immediateFuture(rpcResult);
815 final Long xid = taskContext.getSession().getNextXid();
817 MultipartRequestGroupDescCaseBuilder mprGroupDescCaseBuild =
818 new MultipartRequestGroupDescCaseBuilder();
819 MultipartRequestInputBuilder mprInput =
820 createMultipartHeader(MultipartType.OFPMPGROUPDESC, taskContext);
821 mprInput.setMultipartRequestBody(mprGroupDescCaseBuild.build());
822 Future<RpcResult<Void>> resultFromOFLib = getMessageService()
823 .multipartRequest(mprInput.build(), getCookie());
824 ListenableFuture<RpcResult<Void>> resultLib = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
826 Futures.addCallback(resultLib, new ResultCallback<GetGroupDescriptionOutput>(result) {
828 public GetGroupDescriptionOutput createResult() {
829 GetGroupDescriptionOutputBuilder groupStatBuilder = new GetGroupDescriptionOutputBuilder()
830 .setTransactionId(new TransactionId(BigInteger.valueOf(xid)));
831 return groupStatBuilder.build();
847 public static OFRpcTask<GetGroupFeaturesInput, RpcResult<GetGroupFeaturesOutput>> createGetGroupFeaturesTask(
848 final OFRpcTaskContext taskContext, GetGroupFeaturesInput input,
849 SwitchConnectionDistinguisher cookie) {
850 OFRpcTask<GetGroupFeaturesInput, RpcResult<GetGroupFeaturesOutput>> task =
851 new OFRpcTask<GetGroupFeaturesInput, RpcResult<GetGroupFeaturesOutput>>(taskContext, cookie, input) {
854 public ListenableFuture<RpcResult<GetGroupFeaturesOutput>> call()
856 final SettableFuture<RpcResult<GetGroupFeaturesOutput>> result = SettableFuture.create();
858 if (taskContext.getSession().getPrimaryConductor().getVersion() == OFConstants.OFP_VERSION_1_0) {
859 Collection<RpcError> errors = Collections.emptyList();
860 RpcResult<GetGroupFeaturesOutput> rpcResult = Rpcs.getRpcResult(true,
861 new GetGroupFeaturesOutputBuilder().build(), errors);
862 return Futures.immediateFuture(rpcResult);
864 final Long xid = taskContext.getSession().getNextXid();
866 MultipartRequestGroupFeaturesCaseBuilder mprGroupFeaturesBuild =
867 new MultipartRequestGroupFeaturesCaseBuilder();
868 MultipartRequestInputBuilder mprInput =
869 createMultipartHeader(MultipartType.OFPMPGROUPFEATURES, taskContext);
870 mprInput.setMultipartRequestBody(mprGroupFeaturesBuild.build());
871 Future<RpcResult<Void>> resultFromOFLib = getMessageService()
872 .multipartRequest(mprInput.build(), getCookie());
873 ListenableFuture<RpcResult<Void>> resultLib = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
875 Futures.addCallback(resultLib, new ResultCallback<GetGroupFeaturesOutput>(result) {
877 public GetGroupFeaturesOutput createResult() {
878 GetGroupFeaturesOutputBuilder groupFeatureBuilder = new GetGroupFeaturesOutputBuilder()
879 .setTransactionId(new TransactionId(BigInteger.valueOf(xid)));
880 return groupFeatureBuilder.build();
896 public static OFRpcTask<GetGroupStatisticsInput, RpcResult<GetGroupStatisticsOutput>> createGetGroupStatisticsTask(
897 final OFRpcTaskContext taskContext, final GetGroupStatisticsInput input,
898 SwitchConnectionDistinguisher cookie) {
899 OFRpcTask<GetGroupStatisticsInput, RpcResult<GetGroupStatisticsOutput>> task =
900 new OFRpcTask<GetGroupStatisticsInput, RpcResult<GetGroupStatisticsOutput>>(taskContext, cookie, input) {
903 public ListenableFuture<RpcResult<GetGroupStatisticsOutput>> call()
905 final SettableFuture<RpcResult<GetGroupStatisticsOutput>> result = SettableFuture.create();
907 if (taskContext.getSession().getPrimaryConductor().getVersion() == OFConstants.OFP_VERSION_1_0) {
908 Collection<RpcError> errors = Collections.emptyList();
909 RpcResult<GetGroupStatisticsOutput> rpcResult = Rpcs.getRpcResult(true,
910 new GetGroupStatisticsOutputBuilder().build(), errors);
911 return Futures.immediateFuture(rpcResult);
913 final Long xid = taskContext.getSession().getNextXid();
915 MultipartRequestGroupCaseBuilder caseBuilder = new MultipartRequestGroupCaseBuilder();
916 MultipartRequestGroupBuilder mprGroupBuild = new MultipartRequestGroupBuilder();
917 mprGroupBuild.setGroupId(new GroupId(input.getGroupId().getValue()));
918 caseBuilder.setMultipartRequestGroup(mprGroupBuild.build());
920 MultipartRequestInputBuilder mprInput =
921 createMultipartHeader(MultipartType.OFPMPGROUP, taskContext);
922 mprInput.setMultipartRequestBody(caseBuilder.build());
923 Future<RpcResult<Void>> resultFromOFLib = getMessageService()
924 .multipartRequest(mprInput.build(), getCookie());
925 ListenableFuture<RpcResult<Void>> resultLib = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
927 Futures.addCallback(resultLib, new ResultCallback<GetGroupStatisticsOutput>(result) {
929 public GetGroupStatisticsOutput createResult() {
930 GetGroupStatisticsOutputBuilder groupStatisticsBuilder =
931 new GetGroupStatisticsOutputBuilder()
932 .setTransactionId(new TransactionId(BigInteger.valueOf(xid)));
933 return groupStatisticsBuilder.build();
949 public static OFRpcTask<GetAllMeterConfigStatisticsInput, RpcResult<GetAllMeterConfigStatisticsOutput>> createGetAllMeterConfigStatisticsTask(
950 final OFRpcTaskContext taskContext, final GetAllMeterConfigStatisticsInput input,
951 SwitchConnectionDistinguisher cookie) {
952 OFRpcTask<GetAllMeterConfigStatisticsInput, RpcResult<GetAllMeterConfigStatisticsOutput>> task =
953 new OFRpcTask<GetAllMeterConfigStatisticsInput, RpcResult<GetAllMeterConfigStatisticsOutput>>(taskContext, cookie, input) {
956 public ListenableFuture<RpcResult<GetAllMeterConfigStatisticsOutput>> call()
958 final SettableFuture<RpcResult<GetAllMeterConfigStatisticsOutput>> result = SettableFuture.create();
960 if (taskContext.getSession().getPrimaryConductor().getVersion() == OFConstants.OFP_VERSION_1_0) {
961 Collection<RpcError> errors = Collections.emptyList();
962 RpcResult<GetAllMeterConfigStatisticsOutput> rpcResult = Rpcs.getRpcResult(true,
963 new GetAllMeterConfigStatisticsOutputBuilder().build(), errors);
964 return Futures.immediateFuture(rpcResult);
966 final Long xid = taskContext.getSession().getNextXid();
968 MultipartRequestMeterConfigCaseBuilder caseBuilder =
969 new MultipartRequestMeterConfigCaseBuilder();
970 MultipartRequestMeterConfigBuilder mprMeterConfigBuild =
971 new MultipartRequestMeterConfigBuilder();
972 mprMeterConfigBuild.setMeterId(new MeterId(BinContent.intToUnsignedLong(
973 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common
974 .types.rev130731.Meter.OFPMALL.getIntValue())));
975 caseBuilder.setMultipartRequestMeterConfig(mprMeterConfigBuild.build());
977 MultipartRequestInputBuilder mprInput =
978 createMultipartHeader(MultipartType.OFPMPMETERCONFIG, taskContext);
979 mprInput.setMultipartRequestBody(caseBuilder.build());
980 Future<RpcResult<Void>> resultFromOFLib = getMessageService()
981 .multipartRequest(mprInput.build(), getCookie());
982 ListenableFuture<RpcResult<Void>> resultLib = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
984 Futures.addCallback(resultLib, new ResultCallback<GetAllMeterConfigStatisticsOutput>(result) {
986 public GetAllMeterConfigStatisticsOutput createResult() {
987 GetAllMeterConfigStatisticsOutputBuilder allMeterConfStatBuilder =
988 new GetAllMeterConfigStatisticsOutputBuilder()
989 .setTransactionId(new TransactionId(BigInteger.valueOf(xid)));
990 return allMeterConfStatBuilder.build();
1001 * @param taskContext
1006 public static OFRpcTask<GetAllMeterStatisticsInput, RpcResult<GetAllMeterStatisticsOutput>> createGetAllMeterStatisticsTask(
1007 final OFRpcTaskContext taskContext, final GetAllMeterStatisticsInput input,
1008 SwitchConnectionDistinguisher cookie) {
1009 OFRpcTask<GetAllMeterStatisticsInput, RpcResult<GetAllMeterStatisticsOutput>> task =
1010 new OFRpcTask<GetAllMeterStatisticsInput, RpcResult<GetAllMeterStatisticsOutput>>(taskContext, cookie, input) {
1013 public ListenableFuture<RpcResult<GetAllMeterStatisticsOutput>> call()
1015 final SettableFuture<RpcResult<GetAllMeterStatisticsOutput>> result = SettableFuture.create();
1017 if (taskContext.getSession().getPrimaryConductor().getVersion() == OFConstants.OFP_VERSION_1_0) {
1018 Collection<RpcError> errors = Collections.emptyList();
1019 RpcResult<GetAllMeterStatisticsOutput> rpcResult = Rpcs.getRpcResult(true,
1020 new GetAllMeterStatisticsOutputBuilder().build(), errors);
1021 return Futures.immediateFuture(rpcResult);
1023 final Long xid = taskContext.getSession().getNextXid();
1025 MultipartRequestMeterCaseBuilder caseBuilder =
1026 new MultipartRequestMeterCaseBuilder();
1027 MultipartRequestMeterBuilder mprMeterBuild =
1028 new MultipartRequestMeterBuilder();
1029 mprMeterBuild.setMeterId(new MeterId(BinContent.intToUnsignedLong(
1030 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common
1031 .types.rev130731.Meter.OFPMALL.getIntValue())));
1032 caseBuilder.setMultipartRequestMeter(mprMeterBuild.build());
1034 MultipartRequestInputBuilder mprInput =
1035 createMultipartHeader(MultipartType.OFPMPMETER, taskContext);
1036 mprInput.setMultipartRequestBody(caseBuilder.build());
1037 Future<RpcResult<Void>> resultFromOFLib = getMessageService()
1038 .multipartRequest(mprInput.build(), getCookie());
1039 ListenableFuture<RpcResult<Void>> resultLib = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
1041 Futures.addCallback(resultLib, new ResultCallback<GetAllMeterStatisticsOutput>(result) {
1043 public GetAllMeterStatisticsOutput createResult() {
1044 GetAllMeterStatisticsOutputBuilder allMeterStatBuilder =
1045 new GetAllMeterStatisticsOutputBuilder()
1046 .setTransactionId(new TransactionId(BigInteger.valueOf(xid)));
1047 return allMeterStatBuilder.build();
1058 * @param taskContext
1063 public static OFRpcTask<GetMeterFeaturesInput, RpcResult<GetMeterFeaturesOutput>> createGetMeterFeaturesTask(
1064 final OFRpcTaskContext taskContext, final GetMeterFeaturesInput input,
1065 SwitchConnectionDistinguisher cookie) {
1066 OFRpcTask<GetMeterFeaturesInput, RpcResult<GetMeterFeaturesOutput>> task =
1067 new OFRpcTask<GetMeterFeaturesInput, RpcResult<GetMeterFeaturesOutput>>(taskContext, cookie, input) {
1070 public ListenableFuture<RpcResult<GetMeterFeaturesOutput>> call()
1072 final SettableFuture<RpcResult<GetMeterFeaturesOutput>> result = SettableFuture.create();
1074 if (taskContext.getSession().getPrimaryConductor().getVersion() == OFConstants.OFP_VERSION_1_0) {
1075 Collection<RpcError> errors = Collections.emptyList();
1076 RpcResult<GetMeterFeaturesOutput> rpcResult = Rpcs.getRpcResult(true,
1077 new GetMeterFeaturesOutputBuilder().build(), errors);
1078 return Futures.immediateFuture(rpcResult);
1080 final Long xid = taskContext.getSession().getNextXid();
1082 MultipartRequestMeterFeaturesCaseBuilder mprMeterFeaturesBuild =
1083 new MultipartRequestMeterFeaturesCaseBuilder();
1085 MultipartRequestInputBuilder mprInput =
1086 createMultipartHeader(MultipartType.OFPMPMETERFEATURES, taskContext);
1087 mprInput.setMultipartRequestBody(mprMeterFeaturesBuild.build());
1088 Future<RpcResult<Void>> resultFromOFLib = getMessageService()
1089 .multipartRequest(mprInput.build(), getCookie());
1090 ListenableFuture<RpcResult<Void>> resultLib = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
1092 Futures.addCallback(resultLib, new ResultCallback<GetMeterFeaturesOutput>(result) {
1094 public GetMeterFeaturesOutput createResult() {
1095 GetMeterFeaturesOutputBuilder meterFeaturesBuilder =
1096 new GetMeterFeaturesOutputBuilder()
1097 .setTransactionId(new TransactionId(BigInteger.valueOf(xid)));
1098 return meterFeaturesBuilder.build();
1109 * @param taskContext
1114 public static OFRpcTask<GetMeterStatisticsInput, RpcResult<GetMeterStatisticsOutput>> createGetMeterStatisticsTask(
1115 final OFRpcTaskContext taskContext, final GetMeterStatisticsInput input,
1116 SwitchConnectionDistinguisher cookie) {
1117 OFRpcTask<GetMeterStatisticsInput, RpcResult<GetMeterStatisticsOutput>> task =
1118 new OFRpcTask<GetMeterStatisticsInput, RpcResult<GetMeterStatisticsOutput>>(taskContext, cookie, input) {
1121 public ListenableFuture<RpcResult<GetMeterStatisticsOutput>> call()
1123 final SettableFuture<RpcResult<GetMeterStatisticsOutput>> result = SettableFuture.create();
1125 if (taskContext.getSession().getPrimaryConductor().getVersion() == OFConstants.OFP_VERSION_1_0) {
1126 Collection<RpcError> errors = Collections.emptyList();
1127 RpcResult<GetMeterStatisticsOutput> rpcResult = Rpcs.getRpcResult(true,
1128 new GetMeterStatisticsOutputBuilder().build(), errors);
1129 return Futures.immediateFuture(rpcResult);
1131 final Long xid = taskContext.getSession().getNextXid();
1133 MultipartRequestMeterCaseBuilder caseBuilder =
1134 new MultipartRequestMeterCaseBuilder();
1135 MultipartRequestMeterBuilder mprMeterBuild =
1136 new MultipartRequestMeterBuilder();
1137 mprMeterBuild.setMeterId(new MeterId(input.getMeterId().getValue()));
1138 caseBuilder.setMultipartRequestMeter(mprMeterBuild.build());
1140 MultipartRequestInputBuilder mprInput =
1141 createMultipartHeader(MultipartType.OFPMPMETER, taskContext);
1142 mprInput.setMultipartRequestBody(caseBuilder.build());
1143 Future<RpcResult<Void>> resultFromOFLib = getMessageService()
1144 .multipartRequest(mprInput.build(), getCookie());
1145 ListenableFuture<RpcResult<Void>> resultLib = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
1147 Futures.addCallback(resultLib, new ResultCallback<GetMeterStatisticsOutput>(result) {
1149 public GetMeterStatisticsOutput createResult() {
1150 GetMeterStatisticsOutputBuilder meterStatBuilder =
1151 new GetMeterStatisticsOutputBuilder()
1152 .setTransactionId(new TransactionId(BigInteger.valueOf(xid)));
1153 return meterStatBuilder.build();
1164 * @param taskContext
1169 public static OFRpcTask<GetAllNodeConnectorsStatisticsInput, RpcResult<GetAllNodeConnectorsStatisticsOutput>>
1170 createGetAllNodeConnectorsStatisticsTask(
1171 final OFRpcTaskContext taskContext, final GetAllNodeConnectorsStatisticsInput input,
1172 SwitchConnectionDistinguisher cookie) {
1173 OFRpcTask<GetAllNodeConnectorsStatisticsInput, RpcResult<GetAllNodeConnectorsStatisticsOutput>> task =
1174 new OFRpcTask<GetAllNodeConnectorsStatisticsInput, RpcResult<GetAllNodeConnectorsStatisticsOutput>>(taskContext, cookie, input) {
1177 public ListenableFuture<RpcResult<GetAllNodeConnectorsStatisticsOutput>> call()
1179 final SettableFuture<RpcResult<GetAllNodeConnectorsStatisticsOutput>> result = SettableFuture.create();
1181 final Long xid = taskContext.getSession().getNextXid();
1183 MultipartRequestPortStatsCaseBuilder caseBuilder =
1184 new MultipartRequestPortStatsCaseBuilder();
1185 MultipartRequestPortStatsBuilder mprPortStatsBuilder =
1186 new MultipartRequestPortStatsBuilder();
1188 mprPortStatsBuilder.setPortNo(OFConstants.OFPP_ANY);
1189 caseBuilder.setMultipartRequestPortStats(mprPortStatsBuilder.build());
1191 MultipartRequestInputBuilder mprInput =
1192 createMultipartHeader(MultipartType.OFPMPPORTSTATS, taskContext);
1193 mprInput.setMultipartRequestBody(caseBuilder.build());
1194 Future<RpcResult<Void>> resultFromOFLib = getMessageService()
1195 .multipartRequest(mprInput.build(), getCookie());
1196 ListenableFuture<RpcResult<Void>> resultLib = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
1198 Futures.addCallback(resultLib, new ResultCallback<GetAllNodeConnectorsStatisticsOutput>(result) {
1200 public GetAllNodeConnectorsStatisticsOutput createResult() {
1201 GetAllNodeConnectorsStatisticsOutputBuilder allNodeConnectorStatBuilder =
1202 new GetAllNodeConnectorsStatisticsOutputBuilder()
1203 .setTransactionId(new TransactionId(BigInteger.valueOf(xid)));
1204 return allNodeConnectorStatBuilder.build();
1214 * @param taskContext
1219 public static OFRpcTask<GetNodeConnectorStatisticsInput, RpcResult<GetNodeConnectorStatisticsOutput>>
1220 createGetNodeConnectorStatisticsTask(
1221 final OFRpcTaskContext taskContext, final GetNodeConnectorStatisticsInput input,
1222 SwitchConnectionDistinguisher cookie) {
1223 OFRpcTask<GetNodeConnectorStatisticsInput, RpcResult<GetNodeConnectorStatisticsOutput>> task =
1224 new OFRpcTask<GetNodeConnectorStatisticsInput, RpcResult<GetNodeConnectorStatisticsOutput>>(taskContext, cookie, input) {
1227 public ListenableFuture<RpcResult<GetNodeConnectorStatisticsOutput>> call()
1229 final SettableFuture<RpcResult<GetNodeConnectorStatisticsOutput>> result = SettableFuture.create();
1231 final Long xid = taskContext.getSession().getNextXid();
1233 MultipartRequestPortStatsCaseBuilder caseBuilder =
1234 new MultipartRequestPortStatsCaseBuilder();
1235 MultipartRequestPortStatsBuilder mprPortStatsBuilder =
1236 new MultipartRequestPortStatsBuilder();
1237 // Set specific port
1239 .setPortNo(InventoryDataServiceUtil.portNumberfromNodeConnectorId(
1240 OpenflowVersion.get(taskContext.getSession().getFeatures().getVersion()),
1241 input.getNodeConnectorId()));
1242 caseBuilder.setMultipartRequestPortStats(mprPortStatsBuilder.build());
1244 MultipartRequestInputBuilder mprInput =
1245 createMultipartHeader(MultipartType.OFPMPPORTSTATS, taskContext);
1246 mprInput.setMultipartRequestBody(caseBuilder.build());
1247 Future<RpcResult<Void>> resultFromOFLib = getMessageService()
1248 .multipartRequest(mprInput.build(), getCookie());
1249 ListenableFuture<RpcResult<Void>> resultLib = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
1251 Futures.addCallback(resultLib, new ResultCallback<GetNodeConnectorStatisticsOutput>(result) {
1253 public GetNodeConnectorStatisticsOutput createResult() {
1254 GetNodeConnectorStatisticsOutputBuilder allNodeConnectorStatBuilder =
1255 new GetNodeConnectorStatisticsOutputBuilder()
1256 .setTransactionId(new TransactionId(BigInteger.valueOf(xid)));
1257 return allNodeConnectorStatBuilder.build();
1267 * @param taskContext
1272 public static OFRpcTask<GetAllFlowStatisticsFromFlowTableInput, RpcResult<GetAllFlowStatisticsFromFlowTableOutput>>
1273 createGetAllFlowStatisticsFromFlowTableTask(
1274 final OFRpcTaskContext taskContext,
1275 final GetAllFlowStatisticsFromFlowTableInput input,
1276 SwitchConnectionDistinguisher cookie) {
1277 OFRpcTask<GetAllFlowStatisticsFromFlowTableInput, RpcResult<GetAllFlowStatisticsFromFlowTableOutput>> task =
1278 new OFRpcTask<GetAllFlowStatisticsFromFlowTableInput, RpcResult<GetAllFlowStatisticsFromFlowTableOutput>>(taskContext, cookie, input) {
1281 public ListenableFuture<RpcResult<GetAllFlowStatisticsFromFlowTableOutput>> call() throws Exception {
1282 final SettableFuture<RpcResult<GetAllFlowStatisticsFromFlowTableOutput>> result = SettableFuture.create();
1284 final Long xid = taskContext.getSession().getNextXid();
1286 MultipartRequestFlowCaseBuilder multipartRequestFlowCaseBuilder = new MultipartRequestFlowCaseBuilder();
1287 MultipartRequestFlowBuilder mprFlowRequestBuilder = new MultipartRequestFlowBuilder();
1288 mprFlowRequestBuilder.setTableId(input.getTableId().getValue());
1289 mprFlowRequestBuilder.setOutPort(OFConstants.OFPP_ANY);
1290 mprFlowRequestBuilder.setOutGroup(OFConstants.OFPG_ANY);
1291 mprFlowRequestBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
1292 mprFlowRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
1293 FlowCreatorUtil.setWildcardedFlowMatch(taskContext.getSession()
1294 .getPrimaryConductor().getVersion(), mprFlowRequestBuilder);
1296 MultipartRequestInputBuilder mprInput =
1297 createMultipartHeader(MultipartType.OFPMPFLOW, taskContext);
1298 mprInput.setMultipartRequestBody(multipartRequestFlowCaseBuilder.build());
1299 Future<RpcResult<Void>> resultFromOFLib = getMessageService()
1300 .multipartRequest(mprInput.build(), getCookie());
1301 ListenableFuture<RpcResult<Void>> resultLib = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
1303 Futures.addCallback(resultLib, new ResultCallback<GetAllFlowStatisticsFromFlowTableOutput>(result) {
1305 public GetAllFlowStatisticsFromFlowTableOutput createResult() {
1306 GetAllFlowStatisticsFromFlowTableOutputBuilder allFlowStatsFromFlowTableBuilder =
1307 new GetAllFlowStatisticsFromFlowTableOutputBuilder()
1308 .setTransactionId(new TransactionId(BigInteger.valueOf(xid)));
1309 return allFlowStatsFromFlowTableBuilder.build();
1319 * @param taskContext
1324 public static OFRpcTask<GetAllFlowsStatisticsFromAllFlowTablesInput, RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput>>
1325 createGetAllFlowsStatisticsFromAllFlowTablesTask(
1326 final OFRpcTaskContext taskContext,
1327 final GetAllFlowsStatisticsFromAllFlowTablesInput input,
1328 SwitchConnectionDistinguisher cookie) {
1329 OFRpcTask<GetAllFlowsStatisticsFromAllFlowTablesInput,
1330 RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput>> task =
1331 new OFRpcTask<GetAllFlowsStatisticsFromAllFlowTablesInput,
1332 RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput>>(taskContext, cookie, input) {
1335 public ListenableFuture<RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput>> call() throws Exception {
1336 final SettableFuture<RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput>> result = SettableFuture.create();
1338 final Long xid = taskContext.getSession().getNextXid();
1340 // Create multipart request body for fetch all the group stats
1341 MultipartRequestFlowCaseBuilder multipartRequestFlowCaseBuilder =
1342 new MultipartRequestFlowCaseBuilder();
1343 MultipartRequestFlowBuilder mprFlowRequestBuilder =
1344 new MultipartRequestFlowBuilder();
1345 mprFlowRequestBuilder.setTableId(OFConstants.OFPTT_ALL);
1346 mprFlowRequestBuilder.setOutPort(OFConstants.OFPP_ANY);
1347 mprFlowRequestBuilder.setOutGroup(OFConstants.OFPG_ANY);
1348 mprFlowRequestBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
1349 mprFlowRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
1350 FlowCreatorUtil.setWildcardedFlowMatch(taskContext.getSession()
1351 .getPrimaryConductor().getVersion(), mprFlowRequestBuilder);
1353 MultipartRequestInputBuilder mprInput =
1354 createMultipartHeader(MultipartType.OFPMPFLOW, taskContext);
1355 multipartRequestFlowCaseBuilder.setMultipartRequestFlow(mprFlowRequestBuilder.build());
1356 mprInput.setMultipartRequestBody(multipartRequestFlowCaseBuilder.build());
1357 Future<RpcResult<Void>> resultFromOFLib = getMessageService()
1358 .multipartRequest(mprInput.build(), getCookie());
1359 ListenableFuture<RpcResult<Void>> resultLib = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
1361 Futures.addCallback(resultLib, new ResultCallback<GetAllFlowsStatisticsFromAllFlowTablesOutput>(result) {
1363 public GetAllFlowsStatisticsFromAllFlowTablesOutput createResult() {
1364 GetAllFlowsStatisticsFromAllFlowTablesOutputBuilder allFlowStatsFromAllFlowTableBuilder =
1365 new GetAllFlowsStatisticsFromAllFlowTablesOutputBuilder()
1366 .setTransactionId(new TransactionId(BigInteger.valueOf(xid)));
1367 return allFlowStatsFromAllFlowTableBuilder.build();
1377 * @param taskContext
1382 public static OFRpcTask<GetFlowStatisticsFromFlowTableInput, RpcResult<GetFlowStatisticsFromFlowTableOutput>>
1383 createGetFlowStatisticsFromFlowTableTask(
1384 final OFRpcTaskContext taskContext,
1385 final GetFlowStatisticsFromFlowTableInput input,SwitchConnectionDistinguisher cookie) {
1386 OFRpcTask<GetFlowStatisticsFromFlowTableInput, RpcResult<GetFlowStatisticsFromFlowTableOutput>> task =
1387 new OFRpcTask<GetFlowStatisticsFromFlowTableInput, RpcResult<GetFlowStatisticsFromFlowTableOutput>>(taskContext, cookie, input) {
1390 public ListenableFuture<RpcResult<GetFlowStatisticsFromFlowTableOutput>> call() throws Exception {
1391 final SettableFuture<RpcResult<GetFlowStatisticsFromFlowTableOutput>> result = SettableFuture.create();
1393 final Long xid = taskContext.getSession().getNextXid();
1395 // Create multipart request body for fetch all the group stats
1396 MultipartRequestFlowCaseBuilder multipartRequestFlowCaseBuilder = new MultipartRequestFlowCaseBuilder();
1397 MultipartRequestFlowBuilder mprFlowRequestBuilder = new MultipartRequestFlowBuilder();
1398 mprFlowRequestBuilder.setTableId(input.getTableId());
1400 if (input.getOutPort() != null)
1401 mprFlowRequestBuilder.setOutPort(input.getOutPort().longValue());
1403 mprFlowRequestBuilder.setOutPort(OFConstants.OFPP_ANY);
1405 if (input.getOutGroup() != null)
1406 mprFlowRequestBuilder.setOutGroup(input.getOutGroup());
1408 mprFlowRequestBuilder.setOutGroup(OFConstants.OFPG_ANY);
1410 if (input.getCookie() != null)
1411 mprFlowRequestBuilder.setCookie(input.getCookie().getValue());
1413 mprFlowRequestBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
1415 if (input.getCookieMask() != null)
1416 mprFlowRequestBuilder.setCookieMask(input.getCookieMask().getValue());
1418 mprFlowRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
1420 // convert and inject match
1421 MatchReactor.getInstance().convert(input.getMatch(), taskContext.getSession()
1422 .getPrimaryConductor().getVersion(), mprFlowRequestBuilder,
1423 taskContext.getSession().getFeatures().getDatapathId());
1425 // Set request body to main multipart request
1426 multipartRequestFlowCaseBuilder.setMultipartRequestFlow(mprFlowRequestBuilder.build());
1427 MultipartRequestInputBuilder mprInput =
1428 createMultipartHeader(MultipartType.OFPMPFLOW, taskContext);
1429 mprInput.setMultipartRequestBody(multipartRequestFlowCaseBuilder.build());
1430 Future<RpcResult<Void>> resultFromOFLib = getMessageService()
1431 .multipartRequest(mprInput.build(), getCookie());
1432 ListenableFuture<RpcResult<Void>> resultLib = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
1434 Futures.addCallback(resultLib, new ResultCallback<GetFlowStatisticsFromFlowTableOutput>(result) {
1436 public GetFlowStatisticsFromFlowTableOutput createResult() {
1437 GetFlowStatisticsFromFlowTableOutputBuilder flowStatsFromFlowTableBuilder =
1438 new GetFlowStatisticsFromFlowTableOutputBuilder()
1439 .setTransactionId(new TransactionId(BigInteger.valueOf(xid)));
1440 return flowStatsFromFlowTableBuilder.build();
1450 * @param taskContext
1455 public static OFRpcTask<GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput, RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>>
1456 createGetAggregateFlowStatisticsFromFlowTableForAllFlowsTask(
1457 final OFRpcTaskContext taskContext,
1458 final GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput input,SwitchConnectionDistinguisher cookie) {
1459 OFRpcTask<GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput, RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>> task =
1460 new OFRpcTask<GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput, RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>>(taskContext, cookie, input) {
1463 public ListenableFuture<RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>> call() throws Exception {
1464 final SettableFuture<RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>> result = SettableFuture.create();
1466 final Long xid = taskContext.getSession().getNextXid();
1468 // Create multipart request body for fetch all the group stats
1469 MultipartRequestAggregateCaseBuilder multipartRequestAggregateCaseBuilder = new MultipartRequestAggregateCaseBuilder();
1470 MultipartRequestAggregateBuilder mprAggregateRequestBuilder = new MultipartRequestAggregateBuilder();
1471 mprAggregateRequestBuilder.setTableId(input.getTableId().getValue());
1472 mprAggregateRequestBuilder.setOutPort(OFConstants.OFPP_ANY);
1473 mprAggregateRequestBuilder.setOutGroup(OFConstants.OFPG_ANY);
1474 mprAggregateRequestBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
1475 mprAggregateRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
1477 FlowCreatorUtil.setWildcardedFlowMatch(taskContext.getSession()
1478 .getPrimaryConductor().getVersion(), mprAggregateRequestBuilder);
1480 // Set request body to main multipart request
1481 multipartRequestAggregateCaseBuilder.setMultipartRequestAggregate(mprAggregateRequestBuilder.build());
1482 MultipartRequestInputBuilder mprInput =
1483 createMultipartHeader(MultipartType.OFPMPAGGREGATE, taskContext);
1484 mprInput.setMultipartRequestBody(multipartRequestAggregateCaseBuilder.build());
1485 Future<RpcResult<Void>> resultFromOFLib = getMessageService()
1486 .multipartRequest(mprInput.build(), getCookie());
1487 ListenableFuture<RpcResult<Void>> resultLib = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
1489 Futures.addCallback(resultLib, new ResultCallback<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>(result) {
1491 public GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput createResult() {
1492 GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutputBuilder flowStatsFromFlowTableBuilder =
1493 new GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutputBuilder()
1494 .setTransactionId(new TransactionId(BigInteger.valueOf(xid)));
1495 return flowStatsFromFlowTableBuilder.build();
1505 * @param taskContext
1510 public static OFRpcTask<GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput, RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>>
1511 createGetAggregateFlowStatisticsFromFlowTableForGivenMatchTask(
1512 final OFRpcTaskContext taskContext,
1513 final GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput input,SwitchConnectionDistinguisher cookie) {
1514 OFRpcTask<GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput, RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>> task =
1515 new OFRpcTask<GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput, RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>>(taskContext, cookie, input) {
1518 public ListenableFuture<RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>> call() throws Exception {
1519 final SettableFuture<RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>> result = SettableFuture.create();
1521 final Long xid = taskContext.getSession().getNextXid();
1523 MultipartRequestAggregateCaseBuilder multipartRequestAggregateCaseBuilder = new MultipartRequestAggregateCaseBuilder();
1524 MultipartRequestAggregateBuilder mprAggregateRequestBuilder = new MultipartRequestAggregateBuilder();
1525 mprAggregateRequestBuilder.setTableId(input.getTableId());
1526 mprAggregateRequestBuilder.setOutPort(input.getOutPort().longValue());
1527 // TODO: repeating code
1528 if (taskContext.getSession().getPrimaryConductor().getVersion() ==
1529 OFConstants.OFP_VERSION_1_3) {
1530 mprAggregateRequestBuilder.setCookie(input.getCookie().getValue());
1531 mprAggregateRequestBuilder.setCookieMask(input.getCookieMask().getValue());
1532 mprAggregateRequestBuilder.setOutGroup(input.getOutGroup());
1534 mprAggregateRequestBuilder.setOutGroup(OFConstants.OFPG_ANY);
1535 mprAggregateRequestBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
1536 mprAggregateRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
1539 MatchReactor.getInstance().convert(input.getMatch(), taskContext.getSession()
1540 .getPrimaryConductor().getVersion(), mprAggregateRequestBuilder,
1541 taskContext.getSession().getFeatures().getDatapathId());
1543 FlowCreatorUtil.setWildcardedFlowMatch(taskContext.getSession()
1544 .getPrimaryConductor().getVersion(), mprAggregateRequestBuilder);
1546 // Set request body to main multipart request
1547 multipartRequestAggregateCaseBuilder.setMultipartRequestAggregate(mprAggregateRequestBuilder.build());
1548 MultipartRequestInputBuilder mprInput =
1549 createMultipartHeader(MultipartType.OFPMPAGGREGATE, taskContext);
1550 mprInput.setMultipartRequestBody(multipartRequestAggregateCaseBuilder.build());
1551 Future<RpcResult<Void>> resultFromOFLib = getMessageService()
1552 .multipartRequest(mprInput.build(), getCookie());
1553 ListenableFuture<RpcResult<Void>> resultLib = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
1555 Futures.addCallback(resultLib, new ResultCallback<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>(result) {
1557 public GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput createResult() {
1558 GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder aggregFlowStatsFromFlowTableBuilder =
1559 new GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder()
1560 .setTransactionId(new TransactionId(BigInteger.valueOf(xid)));
1561 return aggregFlowStatsFromFlowTableBuilder.build();
1571 * @param taskContext
1576 public static OFRpcTask<GetFlowTablesStatisticsInput, RpcResult<GetFlowTablesStatisticsOutput>> createGetFlowTablesStatisticsTask(
1577 final OFRpcTaskContext taskContext, final GetFlowTablesStatisticsInput input,SwitchConnectionDistinguisher cookie) {
1578 OFRpcTask<GetFlowTablesStatisticsInput, RpcResult<GetFlowTablesStatisticsOutput>> task =
1579 new OFRpcTask<GetFlowTablesStatisticsInput, RpcResult<GetFlowTablesStatisticsOutput>>(taskContext, cookie, input) {
1582 public ListenableFuture<RpcResult<GetFlowTablesStatisticsOutput>> call() throws Exception {
1583 final SettableFuture<RpcResult<GetFlowTablesStatisticsOutput>> result = SettableFuture.create();
1585 final Long xid = taskContext.getSession().getNextXid();
1587 // Create multipart request body for fetch all the group stats
1588 MultipartRequestTableCaseBuilder multipartRequestTableCaseBuilder = new MultipartRequestTableCaseBuilder();
1589 MultipartRequestTableBuilder multipartRequestTableBuilder = new MultipartRequestTableBuilder();
1590 multipartRequestTableBuilder.setEmpty(true);
1591 multipartRequestTableCaseBuilder.setMultipartRequestTable(multipartRequestTableBuilder.build());
1593 // Set request body to main multipart request
1594 MultipartRequestInputBuilder mprInput =
1595 createMultipartHeader(MultipartType.OFPMPTABLE, taskContext);
1596 mprInput.setMultipartRequestBody(multipartRequestTableCaseBuilder.build());
1597 Future<RpcResult<Void>> resultFromOFLib = getMessageService()
1598 .multipartRequest(mprInput.build(), getCookie());
1599 ListenableFuture<RpcResult<Void>> resultLib = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
1601 Futures.addCallback(resultLib, new ResultCallback<GetFlowTablesStatisticsOutput>(result) {
1603 public GetFlowTablesStatisticsOutput createResult() {
1604 GetFlowTablesStatisticsOutputBuilder flowTableStatsBuilder =
1605 new GetFlowTablesStatisticsOutputBuilder()
1606 .setTransactionId(new TransactionId(BigInteger.valueOf(xid)));
1607 return flowTableStatsBuilder.build();
1617 * @param taskContext
1622 public static OFRpcTask<GetAllQueuesStatisticsFromAllPortsInput, RpcResult<GetAllQueuesStatisticsFromAllPortsOutput>> createGetAllQueuesStatisticsFromAllPortsTask(
1623 final OFRpcTaskContext taskContext, final GetAllQueuesStatisticsFromAllPortsInput input,SwitchConnectionDistinguisher cookie) {
1624 OFRpcTask<GetAllQueuesStatisticsFromAllPortsInput, RpcResult<GetAllQueuesStatisticsFromAllPortsOutput>> task =
1625 new OFRpcTask<GetAllQueuesStatisticsFromAllPortsInput, RpcResult<GetAllQueuesStatisticsFromAllPortsOutput>>(taskContext, cookie, input) {
1628 public ListenableFuture<RpcResult<GetAllQueuesStatisticsFromAllPortsOutput>> call() throws Exception {
1629 final SettableFuture<RpcResult<GetAllQueuesStatisticsFromAllPortsOutput>> result = SettableFuture.create();
1631 final Long xid = taskContext.getSession().getNextXid();
1633 MultipartRequestQueueCaseBuilder caseBuilder = new MultipartRequestQueueCaseBuilder();
1634 MultipartRequestQueueBuilder mprQueueBuilder = new MultipartRequestQueueBuilder();
1636 mprQueueBuilder.setPortNo(OFConstants.OFPP_ANY);
1637 // Select all the ports
1638 mprQueueBuilder.setQueueId(OFConstants.OFPQ_ANY);
1639 caseBuilder.setMultipartRequestQueue(mprQueueBuilder.build());
1641 // Set request body to main multipart request
1642 MultipartRequestInputBuilder mprInput =
1643 createMultipartHeader(MultipartType.OFPMPQUEUE, taskContext);
1644 mprInput.setMultipartRequestBody(caseBuilder.build());
1645 Future<RpcResult<Void>> resultFromOFLib = getMessageService()
1646 .multipartRequest(mprInput.build(), getCookie());
1647 ListenableFuture<RpcResult<Void>> resultLib = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
1649 Futures.addCallback(resultLib, new ResultCallback<GetAllQueuesStatisticsFromAllPortsOutput>(result) {
1651 public GetAllQueuesStatisticsFromAllPortsOutput createResult() {
1652 GetAllQueuesStatisticsFromAllPortsOutputBuilder allQueueStatsBuilder =
1653 new GetAllQueuesStatisticsFromAllPortsOutputBuilder()
1654 .setTransactionId(new TransactionId(BigInteger.valueOf(xid)));
1655 return allQueueStatsBuilder.build();
1665 * @param taskContext
1670 public static OFRpcTask<GetAllQueuesStatisticsFromGivenPortInput, RpcResult<GetAllQueuesStatisticsFromGivenPortOutput>> createGetAllQueuesStatisticsFromGivenPortTask(
1671 final OFRpcTaskContext taskContext, final GetAllQueuesStatisticsFromGivenPortInput input,SwitchConnectionDistinguisher cookie) {
1672 OFRpcTask<GetAllQueuesStatisticsFromGivenPortInput, RpcResult<GetAllQueuesStatisticsFromGivenPortOutput>> task =
1673 new OFRpcTask<GetAllQueuesStatisticsFromGivenPortInput, RpcResult<GetAllQueuesStatisticsFromGivenPortOutput>>(taskContext, cookie, input) {
1676 public ListenableFuture<RpcResult<GetAllQueuesStatisticsFromGivenPortOutput>> call() throws Exception {
1677 final SettableFuture<RpcResult<GetAllQueuesStatisticsFromGivenPortOutput>> result = SettableFuture.create();
1679 final Long xid = taskContext.getSession().getNextXid();
1681 MultipartRequestQueueCaseBuilder caseBuilder = new MultipartRequestQueueCaseBuilder();
1682 MultipartRequestQueueBuilder mprQueueBuilder = new MultipartRequestQueueBuilder();
1683 // Select all queues
1684 mprQueueBuilder.setQueueId(OFConstants.OFPQ_ANY);
1685 // Select specific port
1686 mprQueueBuilder.setPortNo(InventoryDataServiceUtil.portNumberfromNodeConnectorId(
1687 OpenflowVersion.get(taskContext.getSession().getFeatures().getVersion()),
1688 input.getNodeConnectorId()));
1689 caseBuilder.setMultipartRequestQueue(mprQueueBuilder.build());
1691 // Set request body to main multipart request
1692 MultipartRequestInputBuilder mprInput =
1693 createMultipartHeader(MultipartType.OFPMPQUEUE, taskContext);
1694 mprInput.setMultipartRequestBody(caseBuilder.build());
1695 Future<RpcResult<Void>> resultFromOFLib = getMessageService()
1696 .multipartRequest(mprInput.build(), getCookie());
1697 ListenableFuture<RpcResult<Void>> resultLib = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
1699 Futures.addCallback(resultLib, new ResultCallback<GetAllQueuesStatisticsFromGivenPortOutput>(result) {
1701 public GetAllQueuesStatisticsFromGivenPortOutput createResult() {
1702 GetAllQueuesStatisticsFromGivenPortOutputBuilder allQueueStatsBuilder =
1703 new GetAllQueuesStatisticsFromGivenPortOutputBuilder()
1704 .setTransactionId(new TransactionId(BigInteger.valueOf(xid)));
1705 return allQueueStatsBuilder.build();
1715 * @param taskContext
1720 public static OFRpcTask<GetQueueStatisticsFromGivenPortInput, RpcResult<GetQueueStatisticsFromGivenPortOutput>> createGetQueueStatisticsFromGivenPortTask(
1721 final OFRpcTaskContext taskContext, final GetQueueStatisticsFromGivenPortInput input,SwitchConnectionDistinguisher cookie) {
1722 OFRpcTask<GetQueueStatisticsFromGivenPortInput, RpcResult<GetQueueStatisticsFromGivenPortOutput>> task =
1723 new OFRpcTask<GetQueueStatisticsFromGivenPortInput, RpcResult<GetQueueStatisticsFromGivenPortOutput>>(taskContext, cookie, input) {
1726 public ListenableFuture<RpcResult<GetQueueStatisticsFromGivenPortOutput>> call() throws Exception {
1727 final SettableFuture<RpcResult<GetQueueStatisticsFromGivenPortOutput>> result = SettableFuture.create();
1729 final Long xid = taskContext.getSession().getNextXid();
1731 MultipartRequestQueueCaseBuilder caseBuilder = new MultipartRequestQueueCaseBuilder();
1732 MultipartRequestQueueBuilder mprQueueBuilder = new MultipartRequestQueueBuilder();
1733 // Select specific queue
1734 mprQueueBuilder.setQueueId(input.getQueueId().getValue());
1735 // Select specific port
1736 mprQueueBuilder.setPortNo(InventoryDataServiceUtil.portNumberfromNodeConnectorId(
1737 OpenflowVersion.get(taskContext.getSession().getFeatures().getVersion()),
1738 input.getNodeConnectorId()));
1739 caseBuilder.setMultipartRequestQueue(mprQueueBuilder.build());
1741 // Set request body to main multipart request
1742 MultipartRequestInputBuilder mprInput =
1743 createMultipartHeader(MultipartType.OFPMPQUEUE, taskContext);
1744 mprInput.setMultipartRequestBody(caseBuilder.build());
1745 Future<RpcResult<Void>> resultFromOFLib = getMessageService()
1746 .multipartRequest(mprInput.build(), getCookie());
1747 ListenableFuture<RpcResult<Void>> resultLib = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
1749 Futures.addCallback(resultLib, new ResultCallback<GetQueueStatisticsFromGivenPortOutput>(result) {
1751 public GetQueueStatisticsFromGivenPortOutput createResult() {
1752 GetQueueStatisticsFromGivenPortOutputBuilder queueStatsFromPortBuilder =
1753 new GetQueueStatisticsFromGivenPortOutputBuilder()
1754 .setTransactionId(new TransactionId(BigInteger.valueOf(xid)));
1755 return queueStatsFromPortBuilder.build();
1764 static MultipartRequestInputBuilder createMultipartHeader(MultipartType multipart,
1765 OFRpcTaskContext taskContext) {
1766 MultipartRequestInputBuilder mprInput = new MultipartRequestInputBuilder();
1767 mprInput.setType(multipart);
1768 mprInput.setVersion(taskContext.getSession().getPrimaryConductor().getVersion());
1769 mprInput.setXid(taskContext.getSession().getNextXid());
1770 mprInput.setFlags(new MultipartRequestFlags(false));
1774 private static abstract class ResultCallback<T> implements FutureCallback<RpcResult<Void>> {
1776 private SettableFuture<RpcResult<T>> result;
1781 public ResultCallback(SettableFuture<RpcResult<T>> result) {
1782 this.result = result;
1785 public abstract T createResult();
1788 public void onSuccess(RpcResult<Void> resultArg) {
1789 Collection<RpcError> errors = Collections.emptyList();
1790 result.set(Rpcs.getRpcResult(true, createResult(), errors));
1794 public void onFailure(Throwable t) {
1795 result.set(Rpcs.<T>getRpcResult(false,
1796 Collections.singletonList(RpcErrors.getRpcError(OFConstants.APPLICATION_TAG,
1797 OFConstants.ERROR_TAG_TIMEOUT,
1798 "something wrong happened", ErrorSeverity.WARNING, "",
1799 ErrorType.RPC, t))));
1804 * @param taskContext
1809 public static OFRpcTask<UpdatePortInput, RpcResult<UpdatePortOutput>> createUpdatePortTask(
1810 final OFRpcTaskContext taskContext, final UpdatePortInput input,
1811 final SwitchConnectionDistinguisher cookie) {
1812 OFRpcTask<UpdatePortInput, RpcResult<UpdatePortOutput>> task =
1813 new OFRpcTask<UpdatePortInput, RpcResult<UpdatePortOutput>>(taskContext, cookie, input) {
1816 public ListenableFuture<RpcResult<UpdatePortOutput>> call() {
1817 ListenableFuture<RpcResult<UpdatePortOutput>> result = SettableFuture.create();
1818 final Long xid = taskContext.getSession().getNextXid();
1819 Port inputPort = input.getUpdatedPort().getPort().getPort().get(0);
1821 PortModInput ofPortModInput = PortConvertor.toPortModInput(inputPort,
1822 taskContext.getSession().getPrimaryConductor().getVersion());
1824 PortModInputBuilder mdInput = new PortModInputBuilder(ofPortModInput);
1825 mdInput.setXid(xid);
1827 Future<RpcResult<UpdatePortOutput>> resultFromOFLib = getMessageService()
1828 .portMod(mdInput.build(), cookie);
1829 result = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
1840 * @param taskContext
1845 public static OFRpcTask<UpdateTableInput, RpcResult<UpdateTableOutput>> createUpdateTableTask(
1846 final OFRpcTaskContext taskContext, final UpdateTableInput input,
1847 final SwitchConnectionDistinguisher cookie) {
1848 OFRpcTask<UpdateTableInput, RpcResult<UpdateTableOutput>> task =
1849 new OFRpcTask<UpdateTableInput, RpcResult<UpdateTableOutput>>(taskContext, cookie, input) {
1852 public ListenableFuture<RpcResult<UpdateTableOutput>> call() {
1853 final SettableFuture<RpcResult<UpdateTableOutput>> result = SettableFuture.create();
1855 final Long xid = taskContext.getSession().getNextXid();
1857 MultipartRequestTableFeaturesCaseBuilder caseBuilder = new MultipartRequestTableFeaturesCaseBuilder();
1858 MultipartRequestTableFeaturesBuilder requestBuilder = new MultipartRequestTableFeaturesBuilder();
1859 List<TableFeatures> ofTableFeatureList = TableFeaturesConvertor
1860 .toTableFeaturesRequest(input.getUpdatedTable());
1861 requestBuilder.setTableFeatures(ofTableFeatureList);
1862 caseBuilder.setMultipartRequestTableFeatures(requestBuilder.build());
1864 // Set request body to main multipart request
1865 MultipartRequestInputBuilder mprInput =
1866 createMultipartHeader(MultipartType.OFPMPTABLEFEATURES, taskContext);
1867 mprInput.setMultipartRequestBody(caseBuilder.build());
1869 Future<RpcResult<Void>> resultFromOFLib = getMessageService()
1870 .multipartRequest(mprInput.build(), getCookie());
1871 ListenableFuture<RpcResult<Void>> resultLib = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
1873 Futures.addCallback(resultLib, new ResultCallback<UpdateTableOutput>(result) {
1875 public UpdateTableOutput createResult() {
1876 UpdateTableOutputBuilder queueStatsFromPortBuilder =
1877 new UpdateTableOutputBuilder()
1878 .setTransactionId(new TransactionId(BigInteger.valueOf(xid)));
1879 return queueStatsFromPortBuilder.build();