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.net.Inet4Address;
11 import java.net.Inet6Address;
12 import java.net.InetAddress;
13 import java.net.InetSocketAddress;
14 import java.util.concurrent.Future;
15 import java.util.concurrent.TimeUnit;
17 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
18 import org.opendaylight.openflowplugin.openflow.md.core.SwitchConnectionDistinguisher;
19 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.PacketOutConvertor;
20 import org.opendaylight.openflowplugin.openflow.md.core.session.IMessageDispatchService;
21 import org.opendaylight.openflowplugin.openflow.md.core.session.OFSessionUtil;
22 import org.opendaylight.openflowplugin.openflow.md.core.session.SessionContext;
23 import org.opendaylight.openflowplugin.openflow.md.core.session.SwitchConnectionCookieOFImpl;
24 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
25 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
26 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.GetNodeIpAddressInput;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.GetNodeIpAddressOutput;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.GetNodeIpAddressOutputBuilder;
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.AddFlowOutput;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInput;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowOutput;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInput;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowOutput;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableInput;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableOutput;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesInput;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesOutput;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableInput;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableOutput;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsInput;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsOutput;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInput;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupOutput;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInput;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupOutput;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupInput;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupOutput;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsInput;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsOutput;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupDescriptionInput;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupDescriptionOutput;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupFeaturesInput;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupFeaturesOutput;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupStatisticsInput;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupStatisticsOutput;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterInput;
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterOutput;
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterInput;
67 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterOutput;
68 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterInput;
69 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterOutput;
70 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsInput;
71 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsOutput;
72 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterStatisticsInput;
73 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterStatisticsOutput;
74 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterFeaturesInput;
75 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterFeaturesOutput;
76 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsInput;
77 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsOutput;
78 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput;
79 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.ConnectionCookie;
80 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput;
81 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.UpdatePortInput;
82 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.UpdatePortOutput;
83 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllNodeConnectorsStatisticsInput;
84 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllNodeConnectorsStatisticsOutput;
85 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetNodeConnectorStatisticsInput;
86 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetNodeConnectorStatisticsOutput;
87 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromAllPortsInput;
88 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromAllPortsOutput;
89 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromGivenPortInput;
90 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromGivenPortOutput;
91 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetQueueStatisticsFromGivenPortInput;
92 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetQueueStatisticsFromGivenPortOutput;
93 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableInput;
94 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableOutput;
95 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
96 import org.opendaylight.yangtools.yang.common.RpcResult;
97 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
98 import org.slf4j.Logger;
100 import com.google.common.util.concurrent.Futures;
101 import com.google.common.util.concurrent.ListenableFuture;
104 * RPC implementation of MD-switch
106 public class ModelDrivenSwitchImpl extends AbstractModelDrivenSwitch {
108 private static final Logger LOG = org.slf4j.LoggerFactory.getLogger(ModelDrivenSwitchImpl.class);
109 private final NodeId nodeId;
110 private final IMessageDispatchService messageService;
111 private short version = 0;
112 private NotificationProviderService rpcNotificationProviderService;
113 private OFRpcTaskContext rpcTaskContext;
115 // TODO:read timeout from configSubsystem
116 protected long maxTimeout = 1000;
117 protected TimeUnit maxTimeoutUnit = TimeUnit.MILLISECONDS;
119 protected ModelDrivenSwitchImpl(final NodeId nodeId, final InstanceIdentifier<Node> identifier,
120 final SessionContext sessionContext) {
121 super(identifier, sessionContext);
122 this.nodeId = nodeId;
123 messageService = sessionContext.getMessageDispatchService();
124 version = sessionContext.getPrimaryConductor().getVersion();
125 rpcNotificationProviderService = OFSessionUtil.getSessionManager().getNotificationProviderService();
127 rpcTaskContext = new OFRpcTaskContext();
128 rpcTaskContext.setSession(sessionContext);
129 rpcTaskContext.setMessageService(messageService);
130 rpcTaskContext.setRpcNotificationProviderService(rpcNotificationProviderService);
131 rpcTaskContext.setMaxTimeout(maxTimeout);
132 rpcTaskContext.setMaxTimeoutUnit(maxTimeoutUnit);
133 rpcTaskContext.setRpcPool(OFSessionUtil.getSessionManager().getRpcPool());
134 rpcTaskContext.setMessageSpy(OFSessionUtil.getSessionManager().getMessageSpy());
138 public Future<RpcResult<AddFlowOutput>> addFlow(final AddFlowInput input) {
139 LOG.debug("Calling the FlowMod RPC method on MessageDispatchService");
140 // use primary connection
141 SwitchConnectionDistinguisher cookie = null;
143 OFRpcTask<AddFlowInput, RpcResult<UpdateFlowOutput>> task =
144 OFRpcTaskFactory.createAddFlowTask(rpcTaskContext, input, cookie);
145 ListenableFuture<RpcResult<UpdateFlowOutput>> result = task.submit();
147 return Futures.transform(result, OFRpcFutureResultTransformFactory.createForAddFlowOutput());
152 public Future<RpcResult<AddGroupOutput>> addGroup(final AddGroupInput input) {
153 LOG.debug("Calling the GroupMod RPC method on MessageDispatchService");
155 // use primary connection
156 SwitchConnectionDistinguisher cookie = null;
158 OFRpcTask<AddGroupInput, RpcResult<UpdateGroupOutput>> task =
159 OFRpcTaskFactory.createAddGroupTask(rpcTaskContext, input, cookie);
160 ListenableFuture<RpcResult<UpdateGroupOutput>> result = task.submit();
162 return Futures.transform(result, OFRpcFutureResultTransformFactory.createForAddGroupOutput());
166 public Future<RpcResult<AddMeterOutput>> addMeter(final AddMeterInput input) {
167 LOG.debug("Calling the MeterMod RPC method on MessageDispatchService");
169 // use primary connection
170 SwitchConnectionDistinguisher cookie = null;
172 OFRpcTask<AddMeterInput, RpcResult<UpdateMeterOutput>> task =
173 OFRpcTaskFactory.createAddMeterTask(rpcTaskContext, input, cookie);
174 ListenableFuture<RpcResult<UpdateMeterOutput>> result = task.submit();
176 return Futures.transform(result, OFRpcFutureResultTransformFactory.createForAddMeterOutput());
180 public Future<RpcResult<RemoveFlowOutput>> removeFlow(final RemoveFlowInput input) {
181 LOG.debug("Calling the removeFlow RPC method on MessageDispatchService");
183 // use primary connection
184 SwitchConnectionDistinguisher cookie = null;
185 OFRpcTask<RemoveFlowInput, RpcResult<UpdateFlowOutput>> task =
186 OFRpcTaskFactory.createRemoveFlowTask(rpcTaskContext, input, cookie);
187 ListenableFuture<RpcResult<UpdateFlowOutput>> result = task.submit();
189 return Futures.transform(result, OFRpcFutureResultTransformFactory.createForRemoveFlowOutput());
193 public Future<RpcResult<RemoveGroupOutput>> removeGroup(final RemoveGroupInput input) {
194 LOG.debug("Calling the Remove Group RPC method on MessageDispatchService");
196 SwitchConnectionDistinguisher cookie = null;
197 OFRpcTask<RemoveGroupInput, RpcResult<UpdateGroupOutput>> task =
198 OFRpcTaskFactory.createRemoveGroupTask(rpcTaskContext, input, cookie);
199 ListenableFuture<RpcResult<UpdateGroupOutput>> result = task.submit();
201 return Futures.transform(result, OFRpcFutureResultTransformFactory.createForRemoveGroupOutput());
205 public Future<RpcResult<RemoveMeterOutput>> removeMeter(final RemoveMeterInput input) {
206 LOG.debug("Calling the Remove MeterMod RPC method on MessageDispatchService");
208 SwitchConnectionDistinguisher cookie = null;
209 OFRpcTask<RemoveMeterInput, RpcResult<UpdateMeterOutput>> task =
210 OFRpcTaskFactory.createRemoveMeterTask(rpcTaskContext, input, cookie);
211 ListenableFuture<RpcResult<UpdateMeterOutput>> result = task.submit();
213 return Futures.transform(result, OFRpcFutureResultTransformFactory.createForRemoveMeterOutput());
217 public Future<RpcResult<Void>> transmitPacket(final TransmitPacketInput input) {
218 LOG.debug("TransmitPacket - {}", input);
219 // Convert TransmitPacket to PacketOutInput
220 PacketOutInput message = PacketOutConvertor.toPacketOutInput(input, version, sessionContext.getNextXid(),
221 sessionContext.getFeatures().getDatapathId());
223 SwitchConnectionDistinguisher cookie = null;
224 ConnectionCookie connectionCookie = input.getConnectionCookie();
225 if (connectionCookie != null && connectionCookie.getValue() != null) {
226 cookie = new SwitchConnectionCookieOFImpl(connectionCookie.getValue());
229 LOG.debug("Calling the transmitPacket RPC method");
230 return messageService.packetOut(message, cookie);
234 public Future<RpcResult<UpdateFlowOutput>> updateFlow(final UpdateFlowInput input) {
235 LOG.debug("Calling the updateFlow RPC method on MessageDispatchService");
237 // use primary connection
238 SwitchConnectionDistinguisher cookie = null;
240 OFRpcTask<UpdateFlowInput, RpcResult<UpdateFlowOutput>> task =
241 OFRpcTaskFactory.createUpdateFlowTask(rpcTaskContext, input, cookie);
242 ListenableFuture<RpcResult<UpdateFlowOutput>> result = task.submit();
248 public Future<RpcResult<UpdateGroupOutput>> updateGroup(final UpdateGroupInput input) {
249 LOG.debug("Calling the update Group Mod RPC method on MessageDispatchService");
251 // use primary connection
252 SwitchConnectionDistinguisher cookie = null;
254 OFRpcTask<UpdateGroupInput, RpcResult<UpdateGroupOutput>> task =
255 OFRpcTaskFactory.createUpdateGroupTask(rpcTaskContext, input, cookie);
256 ListenableFuture<RpcResult<UpdateGroupOutput>> result = task.submit();
262 public Future<RpcResult<UpdateMeterOutput>> updateMeter(final UpdateMeterInput input) {
263 LOG.debug("Calling the MeterMod RPC method on MessageDispatchService");
265 // use primary connection
266 SwitchConnectionDistinguisher cookie = null;
268 OFRpcTask<UpdateMeterInput, RpcResult<UpdateMeterOutput>> task =
269 OFRpcTaskFactory.createUpdateMeterTask(rpcTaskContext, input, cookie);
270 ListenableFuture<RpcResult<UpdateMeterOutput>> result = task.submit();
276 public NodeId getNodeId() {
282 public Future<RpcResult<GetAllGroupStatisticsOutput>> getAllGroupStatistics(final GetAllGroupStatisticsInput input) {
283 // use primary connection
284 LOG.debug("Calling the getAllGroupStatistics RPC method on MessageDispatchService");
285 SwitchConnectionDistinguisher cookie = null;
287 OFRpcTask<GetAllGroupStatisticsInput, RpcResult<GetAllGroupStatisticsOutput>> task =
288 OFRpcTaskFactory.createGetAllGroupStatisticsTask(rpcTaskContext, input, cookie);
289 ListenableFuture<RpcResult<GetAllGroupStatisticsOutput>> result = task.submit();
296 public Future<RpcResult<GetGroupDescriptionOutput>> getGroupDescription(final GetGroupDescriptionInput input) {
297 LOG.debug("Calling the getGroupDescription RPC method on MessageDispatchService");
298 SwitchConnectionDistinguisher cookie = null;
300 OFRpcTask<GetGroupDescriptionInput, RpcResult<GetGroupDescriptionOutput>> task =
301 OFRpcTaskFactory.createGetGroupDescriptionTask(rpcTaskContext, input, cookie);
302 ListenableFuture<RpcResult<GetGroupDescriptionOutput>> result = task.submit();
307 public Future<RpcResult<GetGroupFeaturesOutput>> getGroupFeatures(final GetGroupFeaturesInput input) {
308 LOG.debug("Calling the getGroupFeatures RPC method on MessageDispatchService");
309 SwitchConnectionDistinguisher cookie = null;
311 OFRpcTask<GetGroupFeaturesInput, RpcResult<GetGroupFeaturesOutput>> task =
312 OFRpcTaskFactory.createGetGroupFeaturesTask(rpcTaskContext, input, cookie);
313 ListenableFuture<RpcResult<GetGroupFeaturesOutput>> result = task.submit();
318 public Future<RpcResult<GetGroupStatisticsOutput>> getGroupStatistics(final GetGroupStatisticsInput input) {
319 LOG.debug("Calling the getGroupStatistics RPC method on MessageDispatchService");
320 SwitchConnectionDistinguisher cookie = null;
322 OFRpcTask<GetGroupStatisticsInput, RpcResult<GetGroupStatisticsOutput>> task =
323 OFRpcTaskFactory.createGetGroupStatisticsTask(rpcTaskContext, input, cookie);
324 ListenableFuture<RpcResult<GetGroupStatisticsOutput>> result = task.submit();
329 public Future<RpcResult<GetAllMeterConfigStatisticsOutput>> getAllMeterConfigStatistics(
330 final GetAllMeterConfigStatisticsInput input) {
331 LOG.debug("Calling the getAllMeterConfigStatistics RPC method on MessageDispatchService");
332 SwitchConnectionDistinguisher cookie = null;
334 OFRpcTask<GetAllMeterConfigStatisticsInput, RpcResult<GetAllMeterConfigStatisticsOutput>> task =
335 OFRpcTaskFactory.createGetAllMeterConfigStatisticsTask(rpcTaskContext, input, cookie);
336 ListenableFuture<RpcResult<GetAllMeterConfigStatisticsOutput>> result = task.submit();
341 public Future<RpcResult<GetAllMeterStatisticsOutput>> getAllMeterStatistics(
342 final GetAllMeterStatisticsInput input) {
343 LOG.debug("Calling the getAllMeterStatistics RPC method on MessageDispatchService");
344 SwitchConnectionDistinguisher cookie = null;
346 OFRpcTask<GetAllMeterStatisticsInput, RpcResult<GetAllMeterStatisticsOutput>> task =
347 OFRpcTaskFactory.createGetAllMeterStatisticsTask(rpcTaskContext, input, cookie);
348 ListenableFuture<RpcResult<GetAllMeterStatisticsOutput>> result = task.submit();
353 public Future<RpcResult<GetMeterFeaturesOutput>> getMeterFeatures(
354 final GetMeterFeaturesInput input) {
355 LOG.debug("Calling the getMeterFeatures RPC method on MessageDispatchService");
356 SwitchConnectionDistinguisher cookie = null;
358 OFRpcTask<GetMeterFeaturesInput, RpcResult<GetMeterFeaturesOutput>> task =
359 OFRpcTaskFactory.createGetMeterFeaturesTask(rpcTaskContext, input, cookie);
360 ListenableFuture<RpcResult<GetMeterFeaturesOutput>> result = task.submit();
365 public Future<RpcResult<GetMeterStatisticsOutput>> getMeterStatistics(
366 final GetMeterStatisticsInput input) {
367 LOG.debug("Calling the getMeterStatistics RPC method on MessageDispatchService");
368 SwitchConnectionDistinguisher cookie = null;
370 OFRpcTask<GetMeterStatisticsInput, RpcResult<GetMeterStatisticsOutput>> task =
371 OFRpcTaskFactory.createGetMeterStatisticsTask(rpcTaskContext, input, cookie);
372 ListenableFuture<RpcResult<GetMeterStatisticsOutput>> result = task.submit();
377 public Future<RpcResult<GetAllNodeConnectorsStatisticsOutput>> getAllNodeConnectorsStatistics(
378 final GetAllNodeConnectorsStatisticsInput input) {
379 LOG.debug("Calling the getAllNodeConnectorsStatistics RPC method on MessageDispatchService");
380 SwitchConnectionDistinguisher cookie = null;
382 OFRpcTask<GetAllNodeConnectorsStatisticsInput, RpcResult<GetAllNodeConnectorsStatisticsOutput>> task =
383 OFRpcTaskFactory.createGetAllNodeConnectorsStatisticsTask(rpcTaskContext, input, cookie);
384 ListenableFuture<RpcResult<GetAllNodeConnectorsStatisticsOutput>> result = task.submit();
389 public Future<RpcResult<GetNodeConnectorStatisticsOutput>> getNodeConnectorStatistics(
390 final GetNodeConnectorStatisticsInput input) {
391 LOG.debug("Calling the getNodeConnectorStatistics RPC method on MessageDispatchService");
392 SwitchConnectionDistinguisher cookie = null;
394 OFRpcTask<GetNodeConnectorStatisticsInput, RpcResult<GetNodeConnectorStatisticsOutput>> task =
395 OFRpcTaskFactory.createGetNodeConnectorStatisticsTask(rpcTaskContext, input, cookie);
396 ListenableFuture<RpcResult<GetNodeConnectorStatisticsOutput>> result = task.submit();
401 public Future<RpcResult<UpdatePortOutput>> updatePort(final UpdatePortInput input) {
402 LOG.debug("Calling the updatePort RPC method on MessageDispatchService");
404 // use primary connection
405 SwitchConnectionDistinguisher cookie = null;
407 OFRpcTask<UpdatePortInput, RpcResult<UpdatePortOutput>> task =
408 OFRpcTaskFactory.createUpdatePortTask(rpcTaskContext, input, cookie);
409 ListenableFuture<RpcResult<UpdatePortOutput>> result = task.submit();
415 public Future<RpcResult<UpdateTableOutput>> updateTable(final UpdateTableInput input) {
416 LOG.debug("Calling the updateTable RPC method on MessageDispatchService");
418 SwitchConnectionDistinguisher cookie = null;
420 OFRpcTask<UpdateTableInput, RpcResult<UpdateTableOutput>> task =
421 OFRpcTaskFactory.createUpdateTableTask(rpcTaskContext, input, cookie);
422 ListenableFuture<RpcResult<UpdateTableOutput>> result = task.submit();
428 public Future<RpcResult<GetAllFlowStatisticsFromFlowTableOutput>> getAllFlowStatisticsFromFlowTable(
429 final GetAllFlowStatisticsFromFlowTableInput input) {
430 LOG.debug("Calling the getAllFlowStatisticsFromFlowTable RPC method on MessageDispatchService");
431 SwitchConnectionDistinguisher cookie = null;
433 OFRpcTask<GetAllFlowStatisticsFromFlowTableInput, RpcResult<GetAllFlowStatisticsFromFlowTableOutput>> task =
434 OFRpcTaskFactory.createGetAllFlowStatisticsFromFlowTableTask(rpcTaskContext, input, cookie);
435 ListenableFuture<RpcResult<GetAllFlowStatisticsFromFlowTableOutput>> result = task.submit();
440 public Future<RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput>> getAllFlowsStatisticsFromAllFlowTables(
441 final GetAllFlowsStatisticsFromAllFlowTablesInput input) {
442 LOG.debug("Calling the getAllFlowsStatisticsFromAllFlowTables RPC method on MessageDispatchService");
443 SwitchConnectionDistinguisher cookie = null;
445 OFRpcTask<GetAllFlowsStatisticsFromAllFlowTablesInput, RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput>> task =
446 OFRpcTaskFactory.createGetAllFlowsStatisticsFromAllFlowTablesTask(rpcTaskContext, input, cookie);
447 ListenableFuture<RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput>> result = task.submit();
452 public Future<RpcResult<GetFlowStatisticsFromFlowTableOutput>> getFlowStatisticsFromFlowTable(
453 final GetFlowStatisticsFromFlowTableInput input) {
454 LOG.debug("Calling the getFlowStatisticsFromFlowTable RPC method on MessageDispatchService");
455 SwitchConnectionDistinguisher cookie = null;
457 OFRpcTask<GetFlowStatisticsFromFlowTableInput, RpcResult<GetFlowStatisticsFromFlowTableOutput>> task =
458 OFRpcTaskFactory.createGetFlowStatisticsFromFlowTableTask(rpcTaskContext, input, cookie);
459 ListenableFuture<RpcResult<GetFlowStatisticsFromFlowTableOutput>> result = task.submit();
464 public Future<RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>> getAggregateFlowStatisticsFromFlowTableForAllFlows(
465 final GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput input) {
466 LOG.debug("Calling the getAggregateFlowStatisticsFromFlowTableForAllFlows RPC method on MessageDispatchService");
467 SwitchConnectionDistinguisher cookie = null;
469 OFRpcTask<GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput, RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>> task =
470 OFRpcTaskFactory.createGetAggregateFlowStatisticsFromFlowTableForAllFlowsTask(rpcTaskContext, input, cookie);
471 ListenableFuture<RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>> result = task.submit();
476 public Future<RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>> getAggregateFlowStatisticsFromFlowTableForGivenMatch(
477 final GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput input) {
478 LOG.debug("Calling the getAggregateFlowStatisticsFromFlowTableForGivenMatch RPC method on MessageDispatchService");
479 SwitchConnectionDistinguisher cookie = null;
481 OFRpcTask<GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput, RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>> task =
482 OFRpcTaskFactory.createGetAggregateFlowStatisticsFromFlowTableForGivenMatchTask(rpcTaskContext, input, cookie);
483 ListenableFuture<RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>> result = task.submit();
488 public Future<RpcResult<GetFlowTablesStatisticsOutput>> getFlowTablesStatistics(
489 final GetFlowTablesStatisticsInput input) {
490 LOG.debug("Calling the getFlowTablesStatistics RPC method on MessageDispatchService");
491 SwitchConnectionDistinguisher cookie = null;
493 OFRpcTask<GetFlowTablesStatisticsInput, RpcResult<GetFlowTablesStatisticsOutput>> task =
494 OFRpcTaskFactory.createGetFlowTablesStatisticsTask(rpcTaskContext, input, cookie);
495 ListenableFuture<RpcResult<GetFlowTablesStatisticsOutput>> result = task.submit();
500 public Future<RpcResult<GetAllQueuesStatisticsFromAllPortsOutput>> getAllQueuesStatisticsFromAllPorts(
501 final GetAllQueuesStatisticsFromAllPortsInput input) {
502 LOG.debug("Calling the getAllQueuesStatisticsFromAllPorts RPC method on MessageDispatchService");
503 SwitchConnectionDistinguisher cookie = null;
505 OFRpcTask<GetAllQueuesStatisticsFromAllPortsInput, RpcResult<GetAllQueuesStatisticsFromAllPortsOutput>> task =
506 OFRpcTaskFactory.createGetAllQueuesStatisticsFromAllPortsTask(rpcTaskContext, input, cookie);
507 ListenableFuture<RpcResult<GetAllQueuesStatisticsFromAllPortsOutput>> result = task.submit();
512 public Future<RpcResult<GetAllQueuesStatisticsFromGivenPortOutput>> getAllQueuesStatisticsFromGivenPort(
513 final GetAllQueuesStatisticsFromGivenPortInput input) {
514 LOG.debug("Calling the getAllQueuesStatisticsFromGivenPort RPC method on MessageDispatchService");
515 SwitchConnectionDistinguisher cookie = null;
517 OFRpcTask<GetAllQueuesStatisticsFromGivenPortInput, RpcResult<GetAllQueuesStatisticsFromGivenPortOutput>> task =
518 OFRpcTaskFactory.createGetAllQueuesStatisticsFromGivenPortTask(rpcTaskContext, input, cookie);
519 ListenableFuture<RpcResult<GetAllQueuesStatisticsFromGivenPortOutput>> result = task.submit();
524 public Future<RpcResult<GetQueueStatisticsFromGivenPortOutput>> getQueueStatisticsFromGivenPort(
525 final GetQueueStatisticsFromGivenPortInput input) {
526 LOG.debug("Calling the getQueueStatisticsFromGivenPort RPC method on MessageDispatchService");
527 SwitchConnectionDistinguisher cookie = null;
529 OFRpcTask<GetQueueStatisticsFromGivenPortInput, RpcResult<GetQueueStatisticsFromGivenPortOutput>> task =
530 OFRpcTaskFactory.createGetQueueStatisticsFromGivenPortTask(rpcTaskContext, input, cookie);
531 ListenableFuture<RpcResult<GetQueueStatisticsFromGivenPortOutput>> result = task.submit();
536 public Future<RpcResult<GetNodeIpAddressOutput>> getNodeIpAddress(GetNodeIpAddressInput input) {
537 if (!sessionContext.isValid()) {
538 return Futures.immediateFuture(RpcResultBuilder
539 .<GetNodeIpAddressOutput> failed()
540 .withError(org.opendaylight.yangtools.yang.common.RpcError.ErrorType.TRANSPORT,
541 "Session is not valid.").build());
543 InetSocketAddress remoteAddress = sessionContext.getPrimaryConductor().getConnectionAdapter()
545 if (remoteAddress == null) {
546 return Futures.immediateFuture(RpcResultBuilder
547 .<GetNodeIpAddressOutput> failed()
548 .withError(org.opendaylight.yangtools.yang.common.RpcError.ErrorType.TRANSPORT,
549 "No connection with switch.").build());
551 IpAddress ipAddress = resolveIpAddress(remoteAddress.getAddress());
552 GetNodeIpAddressOutput result = new GetNodeIpAddressOutputBuilder().setIpAddress(ipAddress).build();
553 return Futures.immediateFuture(RpcResultBuilder.<GetNodeIpAddressOutput> success(result).build());
556 private static IpAddress resolveIpAddress(InetAddress address) {
557 String hostAddress = address.getHostAddress();
558 if (address instanceof Inet4Address) {
559 return new IpAddress(new Ipv4Address(hostAddress));
561 if (address instanceof Inet6Address) {
562 return new IpAddress(new Ipv6Address(hostAddress));
564 throw new IllegalArgumentException("Unsupported IP address type!");