reverting to patch set 7
[openflowplugin.git] / openflowplugin / src / main / java / org / opendaylight / openflowplugin / openflow / md / core / sal / ModelDrivenSwitchImpl.java
1 /**
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.openflowplugin.openflow.md.core.sal;
9
10 import java.math.BigInteger;
11 import java.util.ArrayList;
12 import java.util.List;
13 import java.util.concurrent.Future;
14 import java.util.concurrent.TimeUnit;
15
16 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
17 import org.opendaylight.openflowplugin.openflow.md.core.SwitchConnectionDistinguisher;
18 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.PacketOutConvertor;
19 import org.opendaylight.openflowplugin.openflow.md.core.session.IMessageDispatchService;
20 import org.opendaylight.openflowplugin.openflow.md.core.session.OFSessionUtil;
21 import org.opendaylight.openflowplugin.openflow.md.core.session.SessionContext;
22 import org.opendaylight.openflowplugin.openflow.md.core.session.SwitchConnectionCookieOFImpl;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowOutput;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInput;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowOutput;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInput;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowOutput;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableInput;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableOutput;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesInput;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesOutput;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableInput;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableOutput;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsInput;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsOutput;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionId;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInput;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupOutput;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInput;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupOutput;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupInput;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupOutput;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsInput;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsOutput;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupDescriptionInput;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupDescriptionOutput;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupFeaturesInput;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupFeaturesOutput;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupStatisticsInput;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupStatisticsOutput;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterInput;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterOutput;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterInput;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterOutput;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterInput;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterOutput;
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsInput;
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsOutput;
67 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterStatisticsInput;
68 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterStatisticsOutput;
69 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterFeaturesInput;
70 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterFeaturesOutput;
71 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsInput;
72 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsOutput;
73 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.Match;
74 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.MatchBuilder;
75 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;
76 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInputBuilder;
77 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput;
78 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.ConnectionCookie;
79 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput;
80 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.UpdatePortInput;
81 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.UpdatePortOutput;
82 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllNodeConnectorsStatisticsInput;
83 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllNodeConnectorsStatisticsOutput;
84 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetNodeConnectorStatisticsInput;
85 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetNodeConnectorStatisticsOutput;
86 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromAllPortsInput;
87 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromAllPortsOutput;
88 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromGivenPortInput;
89 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromGivenPortOutput;
90 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetQueueStatisticsFromGivenPortInput;
91 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetQueueStatisticsFromGivenPortOutput;
92 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableInput;
93 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableOutput;
94 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
95 import org.opendaylight.yangtools.yang.common.RpcResult;
96 import org.slf4j.Logger;
97
98 import com.google.common.util.concurrent.Futures;
99 import com.google.common.util.concurrent.JdkFutureAdapters;
100 import com.google.common.util.concurrent.ListenableFuture;
101
102 /**
103  * RPC implementation of MD-switch
104  */
105 public class ModelDrivenSwitchImpl extends AbstractModelDrivenSwitch {
106
107     private static final Logger LOG = org.slf4j.LoggerFactory.getLogger(ModelDrivenSwitchImpl.class);
108     private final NodeId nodeId;
109     private final IMessageDispatchService messageService;
110     private short version = 0;
111     private NotificationProviderService rpcNotificationProviderService;
112     private OFRpcTaskContext rpcTaskContext;
113     
114     // TODO:read timeout from configSubsystem
115     protected long maxTimeout = 1000;
116     protected TimeUnit maxTimeoutUnit = TimeUnit.MILLISECONDS;
117     
118     protected ModelDrivenSwitchImpl(final NodeId nodeId, final InstanceIdentifier<Node> identifier, 
119             final SessionContext sessionContext) {
120         super(identifier, sessionContext);
121         this.nodeId = nodeId;
122         messageService = sessionContext.getMessageDispatchService();
123         version = sessionContext.getPrimaryConductor().getVersion();
124         rpcNotificationProviderService = OFSessionUtil.getSessionManager().getNotificationProviderService();
125         
126         rpcTaskContext = new OFRpcTaskContext();
127         rpcTaskContext.setSession(sessionContext);
128         rpcTaskContext.setMessageService(messageService);
129         rpcTaskContext.setRpcNotificationProviderService(rpcNotificationProviderService);
130         rpcTaskContext.setMaxTimeout(maxTimeout);
131         rpcTaskContext.setMaxTimeoutUnit(maxTimeoutUnit);
132         rpcTaskContext.setRpcPool(OFSessionUtil.getSessionManager().getRpcPool());
133         rpcTaskContext.setMessageSpy(OFSessionUtil.getSessionManager().getMessageSpy());
134     }
135
136     @Override
137     public Future<RpcResult<AddFlowOutput>> addFlow(final AddFlowInput input) {
138         LOG.debug("Calling the FlowMod RPC method on MessageDispatchService");
139         // use primary connection
140         SwitchConnectionDistinguisher cookie = null;
141         
142         OFRpcTask<AddFlowInput, RpcResult<UpdateFlowOutput>> task = 
143                 OFRpcTaskFactory.createAddFlowTask(rpcTaskContext, input, cookie);
144         ListenableFuture<RpcResult<UpdateFlowOutput>> result = task.submit();
145         
146         return Futures.transform(JdkFutureAdapters.listenInPoolThread(result), 
147                 OFRpcFutureResultTransformFactory.createForAddFlowOutput());
148     }
149
150
151     @Override
152     public Future<RpcResult<AddGroupOutput>> addGroup(final AddGroupInput input) {
153         LOG.debug("Calling the GroupMod RPC method on MessageDispatchService");
154         
155         // use primary connection
156         SwitchConnectionDistinguisher cookie = null;
157         
158         OFRpcTask<AddGroupInput, RpcResult<UpdateGroupOutput>> task = 
159                 OFRpcTaskFactory.createAddGroupTask(rpcTaskContext, input, cookie);
160         ListenableFuture<RpcResult<UpdateGroupOutput>> result = task.submit();
161         
162         return Futures.transform(JdkFutureAdapters.listenInPoolThread(result), 
163                 OFRpcFutureResultTransformFactory.createForAddGroupOutput());
164     }
165
166     @Override
167     public Future<RpcResult<AddMeterOutput>> addMeter(final AddMeterInput input) {
168         LOG.debug("Calling the MeterMod RPC method on MessageDispatchService");
169         
170         // use primary connection
171         SwitchConnectionDistinguisher cookie = null;
172         
173         OFRpcTask<AddMeterInput, RpcResult<UpdateMeterOutput>> task = 
174                 OFRpcTaskFactory.createAddMeterTask(rpcTaskContext, input, cookie);
175         ListenableFuture<RpcResult<UpdateMeterOutput>> result = task.submit();
176         
177         return Futures.transform(JdkFutureAdapters.listenInPoolThread(result), 
178                 OFRpcFutureResultTransformFactory.createForAddMeterOutput());
179     }
180
181     @Override
182     public Future<RpcResult<RemoveFlowOutput>> removeFlow(final RemoveFlowInput input) {
183         LOG.debug("Calling the removeFlow RPC method on MessageDispatchService");
184         
185         // use primary connection
186         SwitchConnectionDistinguisher cookie = null;
187         OFRpcTask<RemoveFlowInput, RpcResult<UpdateFlowOutput>> task = 
188                 OFRpcTaskFactory.createRemoveFlowTask(rpcTaskContext, input, cookie);
189         ListenableFuture<RpcResult<UpdateFlowOutput>> result = task.submit();
190
191         return Futures.transform(JdkFutureAdapters.listenInPoolThread(result), 
192                 OFRpcFutureResultTransformFactory.createForRemoveFlowOutput());
193     }
194
195     @Override
196     public Future<RpcResult<RemoveGroupOutput>> removeGroup(final RemoveGroupInput input) {
197         LOG.debug("Calling the Remove Group RPC method on MessageDispatchService");
198
199         SwitchConnectionDistinguisher cookie = null;
200         OFRpcTask<RemoveGroupInput, RpcResult<UpdateGroupOutput>> task = 
201                 OFRpcTaskFactory.createRemoveGroupTask(rpcTaskContext, input, cookie);
202         ListenableFuture<RpcResult<UpdateGroupOutput>> result = task.submit();
203         
204         return Futures.transform(JdkFutureAdapters.listenInPoolThread(result), 
205                 OFRpcFutureResultTransformFactory.createForRemoveGroupOutput());
206     }
207
208     @Override
209     public Future<RpcResult<RemoveMeterOutput>> removeMeter(final RemoveMeterInput input) {
210         LOG.debug("Calling the Remove MeterMod RPC method on MessageDispatchService");
211
212         SwitchConnectionDistinguisher cookie = null;
213         OFRpcTask<RemoveMeterInput, RpcResult<UpdateMeterOutput>> task = 
214                 OFRpcTaskFactory.createRemoveMeterTask(rpcTaskContext, input, cookie);
215         ListenableFuture<RpcResult<UpdateMeterOutput>> result = task.submit();
216         
217         return Futures.transform(JdkFutureAdapters.listenInPoolThread(result), 
218                 OFRpcFutureResultTransformFactory.createForRemoveMeterOutput());
219     }
220
221     @Override
222     public Future<RpcResult<Void>> transmitPacket(final TransmitPacketInput input) {
223         LOG.debug("TransmitPacket - {}", input);
224         // Convert TransmitPacket to PacketOutInput
225         PacketOutInput message = PacketOutConvertor.toPacketOutInput(input, version, sessionContext.getNextXid(),
226                 sessionContext.getFeatures().getDatapathId());
227
228         SwitchConnectionDistinguisher cookie = null;
229         ConnectionCookie connectionCookie = input.getConnectionCookie();
230         if (connectionCookie != null && connectionCookie.getValue() != null) {
231             cookie = new SwitchConnectionCookieOFImpl(connectionCookie.getValue());
232         }
233
234         LOG.debug("Calling the transmitPacket RPC method");
235         return messageService.packetOut(message, cookie);
236     }
237
238     private FlowModInputBuilder toFlowModInputBuilder(final Flow source) {
239         FlowModInputBuilder target = new FlowModInputBuilder();
240         target.setCookie(source.getCookie().getValue());
241         target.setIdleTimeout(source.getIdleTimeout());
242         target.setHardTimeout(source.getHardTimeout());
243         target.setMatch(toMatch(source.getMatch()));
244
245         return target;
246     }
247
248     private Match toMatch(final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match match) {
249         MatchBuilder target = new MatchBuilder();
250
251         target.setMatchEntries(toMatchEntries(match));
252
253         return null;
254     }
255
256     private List<MatchEntries> toMatchEntries(
257             final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match match) {
258         List<MatchEntries> entries = new ArrayList<>();
259
260         return null;
261     }
262
263     @Override
264     public Future<RpcResult<UpdateFlowOutput>> updateFlow(final UpdateFlowInput input) {
265         LOG.debug("Calling the updateFlow RPC method on MessageDispatchService");
266         
267         // use primary connection
268         SwitchConnectionDistinguisher cookie = null;
269         
270         OFRpcTask<UpdateFlowInput, RpcResult<UpdateFlowOutput>> task = 
271                 OFRpcTaskFactory.createUpdateFlowTask(rpcTaskContext, input, cookie);
272         ListenableFuture<RpcResult<UpdateFlowOutput>> result = task.submit();
273         
274         return result;
275     }
276
277     @Override
278     public Future<RpcResult<UpdateGroupOutput>> updateGroup(final UpdateGroupInput input) {
279         LOG.debug("Calling the update Group Mod RPC method on MessageDispatchService");
280         
281         // use primary connection
282         SwitchConnectionDistinguisher cookie = null;
283         
284         OFRpcTask<UpdateGroupInput, RpcResult<UpdateGroupOutput>> task = 
285                 OFRpcTaskFactory.createUpdateGroupTask(rpcTaskContext, input, cookie);
286         ListenableFuture<RpcResult<UpdateGroupOutput>> result = task.submit();
287         
288         return result;
289     }
290
291     @Override
292     public Future<RpcResult<UpdateMeterOutput>> updateMeter(final UpdateMeterInput input) {
293         LOG.debug("Calling the MeterMod RPC method on MessageDispatchService");
294         
295         // use primary connection
296         SwitchConnectionDistinguisher cookie = null;
297         
298         OFRpcTask<UpdateMeterInput, RpcResult<UpdateMeterOutput>> task = 
299                 OFRpcTaskFactory.createUpdateMeterTask(rpcTaskContext, input, cookie);
300         ListenableFuture<RpcResult<UpdateMeterOutput>> result = task.submit();
301         
302         return result;
303     }
304
305     @Override
306     public NodeId getNodeId() {
307         return nodeId;
308     }
309
310     
311     @Override
312     public Future<RpcResult<GetAllGroupStatisticsOutput>> getAllGroupStatistics(final GetAllGroupStatisticsInput input) {
313      // use primary connection
314         LOG.debug("Calling the getAllGroupStatistics RPC method on MessageDispatchService");
315         SwitchConnectionDistinguisher cookie = null;
316         
317         OFRpcTask<GetAllGroupStatisticsInput, RpcResult<GetAllGroupStatisticsOutput>> task = 
318                 OFRpcTaskFactory.createGetAllGroupStatisticsTask(rpcTaskContext, input, cookie);
319         ListenableFuture<RpcResult<GetAllGroupStatisticsOutput>> result = task.submit();
320         
321         return result;
322
323     }
324
325     @Override
326     public Future<RpcResult<GetGroupDescriptionOutput>> getGroupDescription(final GetGroupDescriptionInput input) {
327         LOG.debug("Calling the getGroupDescription RPC method on MessageDispatchService");
328         SwitchConnectionDistinguisher cookie = null;
329         
330         OFRpcTask<GetGroupDescriptionInput, RpcResult<GetGroupDescriptionOutput>> task = 
331                 OFRpcTaskFactory.createGetGroupDescriptionTask(rpcTaskContext, input, cookie);
332         ListenableFuture<RpcResult<GetGroupDescriptionOutput>> result = task.submit();
333         return result;
334     }
335     
336     @Override
337     public Future<RpcResult<GetGroupFeaturesOutput>> getGroupFeatures(final GetGroupFeaturesInput input) {
338         LOG.debug("Calling the getGroupFeatures RPC method on MessageDispatchService");
339         SwitchConnectionDistinguisher cookie = null;
340         
341         OFRpcTask<GetGroupFeaturesInput, RpcResult<GetGroupFeaturesOutput>> task = 
342                 OFRpcTaskFactory.createGetGroupFeaturesTask(rpcTaskContext, input, cookie);
343         ListenableFuture<RpcResult<GetGroupFeaturesOutput>> result = task.submit();
344         return result;
345     }
346     
347     @Override
348     public Future<RpcResult<GetGroupStatisticsOutput>> getGroupStatistics(final GetGroupStatisticsInput input) {
349         LOG.debug("Calling the getGroupStatistics RPC method on MessageDispatchService");
350         SwitchConnectionDistinguisher cookie = null;
351         
352         OFRpcTask<GetGroupStatisticsInput, RpcResult<GetGroupStatisticsOutput>> task = 
353                 OFRpcTaskFactory.createGetGroupStatisticsTask(rpcTaskContext, input, cookie);
354         ListenableFuture<RpcResult<GetGroupStatisticsOutput>> result = task.submit();
355         return result;
356     }
357
358     @Override
359     public Future<RpcResult<GetAllMeterConfigStatisticsOutput>> getAllMeterConfigStatistics(
360             final GetAllMeterConfigStatisticsInput input) {
361         LOG.debug("Calling the getAllMeterConfigStatistics RPC method on MessageDispatchService");
362         SwitchConnectionDistinguisher cookie = null;
363         
364         OFRpcTask<GetAllMeterConfigStatisticsInput, RpcResult<GetAllMeterConfigStatisticsOutput>> task = 
365                 OFRpcTaskFactory.createGetAllMeterConfigStatisticsTask(rpcTaskContext, input, cookie);
366         ListenableFuture<RpcResult<GetAllMeterConfigStatisticsOutput>> result = task.submit();
367         return result;
368     }
369     
370     @Override
371     public Future<RpcResult<GetAllMeterStatisticsOutput>> getAllMeterStatistics(
372             final GetAllMeterStatisticsInput input) {
373         LOG.debug("Calling the getAllMeterStatistics RPC method on MessageDispatchService");
374         SwitchConnectionDistinguisher cookie = null;
375         
376         OFRpcTask<GetAllMeterStatisticsInput, RpcResult<GetAllMeterStatisticsOutput>> task = 
377                 OFRpcTaskFactory.createGetAllMeterStatisticsTask(rpcTaskContext, input, cookie);
378         ListenableFuture<RpcResult<GetAllMeterStatisticsOutput>> result = task.submit();
379         return result;
380     }
381     
382     @Override
383     public Future<RpcResult<GetMeterFeaturesOutput>> getMeterFeatures(
384             final GetMeterFeaturesInput input) {
385         LOG.debug("Calling the getMeterFeatures RPC method on MessageDispatchService");
386         SwitchConnectionDistinguisher cookie = null;
387         
388         OFRpcTask<GetMeterFeaturesInput, RpcResult<GetMeterFeaturesOutput>> task = 
389                 OFRpcTaskFactory.createGetMeterFeaturesTask(rpcTaskContext, input, cookie);
390         ListenableFuture<RpcResult<GetMeterFeaturesOutput>> result = task.submit();
391         return result;
392     }
393     
394     @Override
395     public Future<RpcResult<GetMeterStatisticsOutput>> getMeterStatistics(
396             final GetMeterStatisticsInput input) {
397         LOG.debug("Calling the getMeterStatistics RPC method on MessageDispatchService");
398         SwitchConnectionDistinguisher cookie = null;
399         
400         OFRpcTask<GetMeterStatisticsInput, RpcResult<GetMeterStatisticsOutput>> task = 
401                 OFRpcTaskFactory.createGetMeterStatisticsTask(rpcTaskContext, input, cookie);
402         ListenableFuture<RpcResult<GetMeterStatisticsOutput>> result = task.submit();
403         return result;
404     }
405     
406     @Override
407     public Future<RpcResult<GetAllNodeConnectorsStatisticsOutput>> getAllNodeConnectorsStatistics(
408             final GetAllNodeConnectorsStatisticsInput input) {
409         LOG.debug("Calling the getAllNodeConnectorsStatistics RPC method on MessageDispatchService");
410         SwitchConnectionDistinguisher cookie = null;
411         
412         OFRpcTask<GetAllNodeConnectorsStatisticsInput, RpcResult<GetAllNodeConnectorsStatisticsOutput>> task = 
413                 OFRpcTaskFactory.createGetAllNodeConnectorsStatisticsTask(rpcTaskContext, input, cookie);
414         ListenableFuture<RpcResult<GetAllNodeConnectorsStatisticsOutput>> result = task.submit();
415         return result;
416     }
417     
418     @Override
419     public Future<RpcResult<GetNodeConnectorStatisticsOutput>> getNodeConnectorStatistics(
420             final GetNodeConnectorStatisticsInput input) {
421         LOG.debug("Calling the getNodeConnectorStatistics RPC method on MessageDispatchService");
422         SwitchConnectionDistinguisher cookie = null;
423         
424         OFRpcTask<GetNodeConnectorStatisticsInput, RpcResult<GetNodeConnectorStatisticsOutput>> task = 
425                 OFRpcTaskFactory.createGetNodeConnectorStatisticsTask(rpcTaskContext, input, cookie);
426         ListenableFuture<RpcResult<GetNodeConnectorStatisticsOutput>> result = task.submit();
427         return result;
428     }
429
430     private static TransactionId generateTransactionId(final Long xid) {
431         BigInteger bigIntXid = BigInteger.valueOf(xid);
432         return new TransactionId(bigIntXid);
433     }
434     
435     @Override
436     public Future<RpcResult<UpdatePortOutput>> updatePort(final UpdatePortInput input) {
437         LOG.debug("Calling the updatePort RPC method on MessageDispatchService");
438         
439         // use primary connection
440         SwitchConnectionDistinguisher cookie = null;
441         
442         OFRpcTask<UpdatePortInput, RpcResult<UpdatePortOutput>> task = 
443                 OFRpcTaskFactory.createUpdatePortTask(rpcTaskContext, input, cookie);
444         ListenableFuture<RpcResult<UpdatePortOutput>> result = task.submit();
445         
446         return result;
447     }
448
449     @Override
450     public Future<RpcResult<UpdateTableOutput>> updateTable(final UpdateTableInput input) {
451         LOG.debug("Calling the updateTable RPC method on MessageDispatchService");
452         
453         SwitchConnectionDistinguisher cookie = null;
454         
455         OFRpcTask<UpdateTableInput, RpcResult<UpdateTableOutput>> task = 
456                 OFRpcTaskFactory.createUpdateTableTask(rpcTaskContext, input, cookie);
457         ListenableFuture<RpcResult<UpdateTableOutput>> result = task.submit();
458         
459         return result;
460     }
461
462     @Override
463     public Future<RpcResult<GetAllFlowStatisticsFromFlowTableOutput>> getAllFlowStatisticsFromFlowTable(
464             final GetAllFlowStatisticsFromFlowTableInput input) {
465         LOG.debug("Calling the getAllFlowStatisticsFromFlowTable RPC method on MessageDispatchService");
466         SwitchConnectionDistinguisher cookie = null;
467         
468         OFRpcTask<GetAllFlowStatisticsFromFlowTableInput, RpcResult<GetAllFlowStatisticsFromFlowTableOutput>> task = 
469                 OFRpcTaskFactory.createGetAllFlowStatisticsFromFlowTableTask(rpcTaskContext, input, cookie);
470         ListenableFuture<RpcResult<GetAllFlowStatisticsFromFlowTableOutput>> result = task.submit();
471         return result;
472     }
473     
474     @Override
475     public Future<RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput>> getAllFlowsStatisticsFromAllFlowTables(
476             final GetAllFlowsStatisticsFromAllFlowTablesInput input) {
477         LOG.debug("Calling the getAllFlowsStatisticsFromAllFlowTables RPC method on MessageDispatchService");
478         SwitchConnectionDistinguisher cookie = null;
479         
480         OFRpcTask<GetAllFlowsStatisticsFromAllFlowTablesInput, RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput>> task = 
481                 OFRpcTaskFactory.createGetAllFlowsStatisticsFromAllFlowTablesTask(rpcTaskContext, input, cookie);
482         ListenableFuture<RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput>> result = task.submit();
483         return result;
484     }
485     
486     @Override
487     public Future<RpcResult<GetFlowStatisticsFromFlowTableOutput>> getFlowStatisticsFromFlowTable(
488             final GetFlowStatisticsFromFlowTableInput input) {
489         LOG.debug("Calling the getFlowStatisticsFromFlowTable RPC method on MessageDispatchService");
490         SwitchConnectionDistinguisher cookie = null;
491         
492         OFRpcTask<GetFlowStatisticsFromFlowTableInput, RpcResult<GetFlowStatisticsFromFlowTableOutput>> task = 
493                 OFRpcTaskFactory.createGetFlowStatisticsFromFlowTableTask(rpcTaskContext, input, cookie);
494         ListenableFuture<RpcResult<GetFlowStatisticsFromFlowTableOutput>> result = task.submit();
495         return result;
496     }
497     
498     @Override
499     public Future<RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>> getAggregateFlowStatisticsFromFlowTableForAllFlows(
500             final GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput input) {
501         LOG.debug("Calling the getAggregateFlowStatisticsFromFlowTableForAllFlows RPC method on MessageDispatchService");
502         SwitchConnectionDistinguisher cookie = null;
503         
504         OFRpcTask<GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput, RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>> task = 
505                 OFRpcTaskFactory.createGetAggregateFlowStatisticsFromFlowTableForAllFlowsTask(rpcTaskContext, input, cookie);
506         ListenableFuture<RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>> result = task.submit();
507         return result;
508     }
509     
510     @Override
511     public Future<RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>> getAggregateFlowStatisticsFromFlowTableForGivenMatch(
512             final GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput input) {
513         LOG.debug("Calling the getAggregateFlowStatisticsFromFlowTableForGivenMatch RPC method on MessageDispatchService");
514         SwitchConnectionDistinguisher cookie = null;
515         
516         OFRpcTask<GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput, RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>> task = 
517                 OFRpcTaskFactory.createGetAggregateFlowStatisticsFromFlowTableForGivenMatchTask(rpcTaskContext, input, cookie);
518         ListenableFuture<RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>> result = task.submit();
519         return result;
520     }
521     
522     @Override
523     public Future<RpcResult<GetFlowTablesStatisticsOutput>> getFlowTablesStatistics(
524             final GetFlowTablesStatisticsInput input) {
525         LOG.debug("Calling the getFlowTablesStatistics RPC method on MessageDispatchService");
526         SwitchConnectionDistinguisher cookie = null;
527         
528         OFRpcTask<GetFlowTablesStatisticsInput, RpcResult<GetFlowTablesStatisticsOutput>> task = 
529                 OFRpcTaskFactory.createGetFlowTablesStatisticsTask(rpcTaskContext, input, cookie);
530         ListenableFuture<RpcResult<GetFlowTablesStatisticsOutput>> result = task.submit();
531         return result;
532     }
533     
534     @Override
535     public Future<RpcResult<GetAllQueuesStatisticsFromAllPortsOutput>> getAllQueuesStatisticsFromAllPorts(
536             final GetAllQueuesStatisticsFromAllPortsInput input) {
537         LOG.debug("Calling the getAllQueuesStatisticsFromAllPorts RPC method on MessageDispatchService");
538         SwitchConnectionDistinguisher cookie = null;
539         
540         OFRpcTask<GetAllQueuesStatisticsFromAllPortsInput, RpcResult<GetAllQueuesStatisticsFromAllPortsOutput>> task = 
541                 OFRpcTaskFactory.createGetAllQueuesStatisticsFromAllPortsTask(rpcTaskContext, input, cookie);
542         ListenableFuture<RpcResult<GetAllQueuesStatisticsFromAllPortsOutput>> result = task.submit();
543         return result;
544     }
545     
546     @Override
547     public Future<RpcResult<GetAllQueuesStatisticsFromGivenPortOutput>> getAllQueuesStatisticsFromGivenPort(
548             final GetAllQueuesStatisticsFromGivenPortInput input) {
549         LOG.debug("Calling the getAllQueuesStatisticsFromGivenPort RPC method on MessageDispatchService");
550         SwitchConnectionDistinguisher cookie = null;
551         
552         OFRpcTask<GetAllQueuesStatisticsFromGivenPortInput, RpcResult<GetAllQueuesStatisticsFromGivenPortOutput>> task = 
553                 OFRpcTaskFactory.createGetAllQueuesStatisticsFromGivenPortTask(rpcTaskContext, input, cookie);
554         ListenableFuture<RpcResult<GetAllQueuesStatisticsFromGivenPortOutput>> result = task.submit();
555         return result;
556     }
557     
558     @Override
559     public Future<RpcResult<GetQueueStatisticsFromGivenPortOutput>> getQueueStatisticsFromGivenPort(
560             final GetQueueStatisticsFromGivenPortInput input) {
561         LOG.debug("Calling the getQueueStatisticsFromGivenPort RPC method on MessageDispatchService");
562         SwitchConnectionDistinguisher cookie = null;
563         
564         OFRpcTask<GetQueueStatisticsFromGivenPortInput, RpcResult<GetQueueStatisticsFromGivenPortOutput>> task = 
565                 OFRpcTaskFactory.createGetQueueStatisticsFromGivenPortTask(rpcTaskContext, input, cookie);
566         ListenableFuture<RpcResult<GetQueueStatisticsFromGivenPortOutput>> result = task.submit();
567         return result;
568     }
569 }