2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.openflowplugin.openflow.md.core.sal;
10 import com.google.common.base.Optional;
11 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
13 import com.google.common.util.concurrent.Futures;
14 import com.google.common.util.concurrent.ListenableFuture;
16 import java.math.BigInteger;
17 import java.util.concurrent.Future;
18 import java.util.concurrent.TimeUnit;
19 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
20 import org.opendaylight.openflowplugin.api.OFConstants;
21 import org.opendaylight.openflowplugin.api.openflow.md.core.SwitchConnectionDistinguisher;
22 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.PacketOutConvertor;
23 import org.opendaylight.openflowplugin.api.openflow.md.core.session.IMessageDispatchService;
24 import org.opendaylight.openflowplugin.openflow.md.core.session.OFSessionUtil;
25 import org.opendaylight.openflowplugin.api.openflow.md.core.session.SessionContext;
26 import org.opendaylight.openflowplugin.openflow.md.core.session.SwitchConnectionCookieOFImpl;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowOutput;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInput;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowOutput;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInput;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowOutput;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableInput;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableOutput;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesInput;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesOutput;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableInput;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableOutput;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsInput;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsOutput;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInput;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupOutput;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInput;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupOutput;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupInput;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupOutput;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsInput;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsOutput;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupDescriptionInput;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupDescriptionOutput;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupFeaturesInput;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupFeaturesOutput;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupStatisticsInput;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupStatisticsOutput;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterInput;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterOutput;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterInput;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterOutput;
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterInput;
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterOutput;
67 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsInput;
68 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsOutput;
69 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterStatisticsInput;
70 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterStatisticsOutput;
71 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterFeaturesInput;
72 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterFeaturesOutput;
73 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsInput;
74 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsOutput;
75 import org.opendaylight.yang.gen.v1.urn.opendaylight.module.config.rev141015.SetConfigInput;
76 import org.opendaylight.yang.gen.v1.urn.opendaylight.module.config.rev141015.SetConfigOutput;
77 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags;
78 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
79 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
80 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput;
81 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestDescCaseBuilder;
82 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortDescCaseBuilder;
83 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableFeaturesCaseBuilder;
84 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.MultipartRequestTableFeaturesBuilder;
85 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.ConnectionCookie;
86 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput;
87 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.UpdatePortInput;
88 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.UpdatePortOutput;
89 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllNodeConnectorsStatisticsInput;
90 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllNodeConnectorsStatisticsOutput;
91 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetNodeConnectorStatisticsInput;
92 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetNodeConnectorStatisticsOutput;
93 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromAllPortsInput;
94 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromAllPortsOutput;
95 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromGivenPortInput;
96 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromGivenPortOutput;
97 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetQueueStatisticsFromGivenPortInput;
98 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetQueueStatisticsFromGivenPortOutput;
99 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableInput;
100 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableOutput;
101 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
102 import org.opendaylight.yangtools.yang.common.RpcResult;
103 import org.slf4j.Logger;
106 * RPC implementation of MD-switch
108 public class ModelDrivenSwitchImpl extends AbstractModelDrivenSwitch {
110 private static final Logger LOG = org.slf4j.LoggerFactory.getLogger(ModelDrivenSwitchImpl.class);
111 private final NodeId nodeId;
112 private final IMessageDispatchService messageService;
113 private short version = 0;
114 private OFRpcTaskContext rpcTaskContext;
116 // TODO:read timeout from configSubsystem
117 protected long maxTimeout = 1000;
118 protected TimeUnit maxTimeoutUnit = TimeUnit.MILLISECONDS;
120 protected ModelDrivenSwitchImpl(final NodeId nodeId, final InstanceIdentifier<Node> identifier,
121 final SessionContext sessionContext) {
122 super(identifier, sessionContext);
123 this.nodeId = nodeId;
124 messageService = sessionContext.getMessageDispatchService();
125 version = sessionContext.getPrimaryConductor().getVersion();
126 final NotificationProviderService rpcNotificationProviderService = OFSessionUtil.getSessionManager().getNotificationProviderService();
128 rpcTaskContext = new OFRpcTaskContext();
129 rpcTaskContext.setSession(sessionContext);
130 rpcTaskContext.setMessageService(messageService);
131 rpcTaskContext.setRpcNotificationProviderService(rpcNotificationProviderService);
132 rpcTaskContext.setMaxTimeout(maxTimeout);
133 rpcTaskContext.setMaxTimeoutUnit(maxTimeoutUnit);
134 rpcTaskContext.setRpcPool(OFSessionUtil.getSessionManager().getRpcPool());
135 rpcTaskContext.setMessageSpy(OFSessionUtil.getSessionManager().getMessageSpy());
140 public Future<RpcResult<AddFlowOutput>> addFlow(final AddFlowInput input) {
141 LOG.debug("Calling the FlowMod RPC method on MessageDispatchService");
142 // use primary connection
143 SwitchConnectionDistinguisher cookie = null;
145 OFRpcTask<AddFlowInput, RpcResult<UpdateFlowOutput>> task =
146 OFRpcTaskFactory.createAddFlowTask(rpcTaskContext, input, cookie);
147 ListenableFuture<RpcResult<UpdateFlowOutput>> result = task.submit();
149 return Futures.transform(result, OFRpcFutureResultTransformFactory.createForAddFlowOutput());
154 public Future<RpcResult<AddGroupOutput>> addGroup(final AddGroupInput input) {
155 LOG.debug("Calling the GroupMod RPC method on MessageDispatchService");
157 // use primary connection
158 SwitchConnectionDistinguisher cookie = null;
160 OFRpcTask<AddGroupInput, RpcResult<UpdateGroupOutput>> task =
161 OFRpcTaskFactory.createAddGroupTask(rpcTaskContext, input, cookie);
162 ListenableFuture<RpcResult<UpdateGroupOutput>> result = task.submit();
164 return Futures.transform(result, OFRpcFutureResultTransformFactory.createForAddGroupOutput());
168 public Future<RpcResult<AddMeterOutput>> addMeter(final AddMeterInput input) {
169 LOG.debug("Calling the MeterMod RPC method on MessageDispatchService");
171 // use primary connection
172 SwitchConnectionDistinguisher cookie = null;
174 OFRpcTask<AddMeterInput, RpcResult<UpdateMeterOutput>> task =
175 OFRpcTaskFactory.createAddMeterTask(rpcTaskContext, input, cookie);
176 ListenableFuture<RpcResult<UpdateMeterOutput>> result = task.submit();
178 return Futures.transform(result, OFRpcFutureResultTransformFactory.createForAddMeterOutput());
182 public Future<RpcResult<RemoveFlowOutput>> removeFlow(final RemoveFlowInput input) {
183 LOG.debug("Calling the removeFlow RPC method on MessageDispatchService");
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();
191 return Futures.transform(result, OFRpcFutureResultTransformFactory.createForRemoveFlowOutput());
195 public Future<RpcResult<RemoveGroupOutput>> removeGroup(final RemoveGroupInput input) {
196 LOG.debug("Calling the Remove Group RPC method on MessageDispatchService");
198 SwitchConnectionDistinguisher cookie = null;
199 OFRpcTask<RemoveGroupInput, RpcResult<UpdateGroupOutput>> task =
200 OFRpcTaskFactory.createRemoveGroupTask(rpcTaskContext, input, cookie);
201 ListenableFuture<RpcResult<UpdateGroupOutput>> result = task.submit();
203 return Futures.transform(result, OFRpcFutureResultTransformFactory.createForRemoveGroupOutput());
207 public Future<RpcResult<RemoveMeterOutput>> removeMeter(final RemoveMeterInput input) {
208 LOG.debug("Calling the Remove MeterMod RPC method on MessageDispatchService");
210 SwitchConnectionDistinguisher cookie = null;
211 OFRpcTask<RemoveMeterInput, RpcResult<UpdateMeterOutput>> task =
212 OFRpcTaskFactory.createRemoveMeterTask(rpcTaskContext, input, cookie);
213 ListenableFuture<RpcResult<UpdateMeterOutput>> result = task.submit();
215 return Futures.transform(result, OFRpcFutureResultTransformFactory.createForRemoveMeterOutput());
219 public Future<RpcResult<Void>> transmitPacket(final TransmitPacketInput input) {
220 LOG.debug("TransmitPacket - {}", input);
221 // Convert TransmitPacket to PacketOutInput
222 PacketOutInput message = PacketOutConvertor.toPacketOutInput(input, version, sessionContext.getNextXid(),
223 sessionContext.getFeatures().getDatapathId());
225 SwitchConnectionDistinguisher cookie = null;
226 ConnectionCookie connectionCookie = input.getConnectionCookie();
227 if (connectionCookie != null && connectionCookie.getValue() != null) {
228 cookie = new SwitchConnectionCookieOFImpl(connectionCookie.getValue());
231 LOG.debug("Calling the transmitPacket RPC method");
232 return messageService.packetOut(message, cookie);
236 public Future<RpcResult<UpdateFlowOutput>> updateFlow(final UpdateFlowInput input) {
237 LOG.debug("Calling the updateFlow RPC method on MessageDispatchService");
239 // use primary connection
240 SwitchConnectionDistinguisher cookie = null;
241 final ReadWriteTransaction rwTx = OFSessionUtil.getSessionManager().getDataBroker().newReadWriteTransaction();
242 OFRpcTask<UpdateFlowInput, RpcResult<UpdateFlowOutput>> task =
243 OFRpcTaskFactory.createUpdateFlowTask(rpcTaskContext, input, cookie, rwTx);
244 ListenableFuture<RpcResult<UpdateFlowOutput>> result = task.submit();
250 public Future<RpcResult<UpdateGroupOutput>> updateGroup(final UpdateGroupInput input) {
251 LOG.debug("Calling the update Group Mod RPC method on MessageDispatchService");
253 // use primary connection
254 SwitchConnectionDistinguisher cookie = null;
256 OFRpcTask<UpdateGroupInput, RpcResult<UpdateGroupOutput>> task =
257 OFRpcTaskFactory.createUpdateGroupTask(rpcTaskContext, input, cookie);
258 ListenableFuture<RpcResult<UpdateGroupOutput>> result = task.submit();
264 public Future<RpcResult<UpdateMeterOutput>> updateMeter(final UpdateMeterInput input) {
265 LOG.debug("Calling the MeterMod RPC method on MessageDispatchService");
267 // use primary connection
268 SwitchConnectionDistinguisher cookie = null;
270 OFRpcTask<UpdateMeterInput, RpcResult<UpdateMeterOutput>> task =
271 OFRpcTaskFactory.createUpdateMeterTask(rpcTaskContext, input, cookie);
272 ListenableFuture<RpcResult<UpdateMeterOutput>> result = task.submit();
278 public NodeId getNodeId() {
284 public Future<RpcResult<GetAllGroupStatisticsOutput>> getAllGroupStatistics(final GetAllGroupStatisticsInput input) {
285 // use primary connection
286 LOG.debug("Calling the getAllGroupStatistics RPC method on MessageDispatchService");
287 SwitchConnectionDistinguisher cookie = null;
289 OFRpcTask<GetAllGroupStatisticsInput, RpcResult<GetAllGroupStatisticsOutput>> task =
290 OFRpcTaskFactory.createGetAllGroupStatisticsTask(rpcTaskContext, input, cookie);
291 ListenableFuture<RpcResult<GetAllGroupStatisticsOutput>> result = task.submit();
298 public Future<RpcResult<GetGroupDescriptionOutput>> getGroupDescription(final GetGroupDescriptionInput input) {
299 LOG.debug("Calling the getGroupDescription RPC method on MessageDispatchService");
301 OFRpcTask<GetGroupDescriptionInput, RpcResult<GetGroupDescriptionOutput>> task =
302 OFRpcTaskFactory.createGetGroupDescriptionTask(rpcTaskContext, input, null);
303 return task.submit();
307 public Future<RpcResult<GetGroupFeaturesOutput>> getGroupFeatures(final GetGroupFeaturesInput input) {
308 LOG.debug("Calling the getGroupFeatures RPC method on MessageDispatchService");
310 OFRpcTask<GetGroupFeaturesInput, RpcResult<GetGroupFeaturesOutput>> task =
311 OFRpcTaskFactory.createGetGroupFeaturesTask(rpcTaskContext, input, null);
312 return task.submit();
316 public Future<RpcResult<GetGroupStatisticsOutput>> getGroupStatistics(final GetGroupStatisticsInput input) {
317 LOG.debug("Calling the getGroupStatistics RPC method on MessageDispatchService");
319 OFRpcTask<GetGroupStatisticsInput, RpcResult<GetGroupStatisticsOutput>> task =
320 OFRpcTaskFactory.createGetGroupStatisticsTask(rpcTaskContext, input, null);
321 return task.submit();
325 public Future<RpcResult<GetAllMeterConfigStatisticsOutput>> getAllMeterConfigStatistics(
326 final GetAllMeterConfigStatisticsInput input) {
327 LOG.debug("Calling the getAllMeterConfigStatistics RPC method on MessageDispatchService");
329 OFRpcTask<GetAllMeterConfigStatisticsInput, RpcResult<GetAllMeterConfigStatisticsOutput>> task =
330 OFRpcTaskFactory.createGetAllMeterConfigStatisticsTask(rpcTaskContext, input, null);
331 return task.submit();
335 public Future<RpcResult<GetAllMeterStatisticsOutput>> getAllMeterStatistics(
336 final GetAllMeterStatisticsInput input) {
337 LOG.debug("Calling the getAllMeterStatistics RPC method on MessageDispatchService");
339 OFRpcTask<GetAllMeterStatisticsInput, RpcResult<GetAllMeterStatisticsOutput>> task =
340 OFRpcTaskFactory.createGetAllMeterStatisticsTask(rpcTaskContext, input, null);
341 return task.submit();
345 public Future<RpcResult<GetMeterFeaturesOutput>> getMeterFeatures(
346 final GetMeterFeaturesInput input) {
347 LOG.debug("Calling the getMeterFeatures RPC method on MessageDispatchService");
349 OFRpcTask<GetMeterFeaturesInput, RpcResult<GetMeterFeaturesOutput>> task =
350 OFRpcTaskFactory.createGetMeterFeaturesTask(rpcTaskContext, input, null);
351 return task.submit();
355 public Future<RpcResult<GetMeterStatisticsOutput>> getMeterStatistics(
356 final GetMeterStatisticsInput input) {
357 LOG.debug("Calling the getMeterStatistics RPC method on MessageDispatchService");
359 OFRpcTask<GetMeterStatisticsInput, RpcResult<GetMeterStatisticsOutput>> task =
360 OFRpcTaskFactory.createGetMeterStatisticsTask(rpcTaskContext, input, null);
361 return task.submit();
365 public Future<RpcResult<GetAllNodeConnectorsStatisticsOutput>> getAllNodeConnectorsStatistics(
366 final GetAllNodeConnectorsStatisticsInput input) {
367 LOG.debug("Calling the getAllNodeConnectorsStatistics RPC method on MessageDispatchService");
369 OFRpcTask<GetAllNodeConnectorsStatisticsInput, RpcResult<GetAllNodeConnectorsStatisticsOutput>> task =
370 OFRpcTaskFactory.createGetAllNodeConnectorsStatisticsTask(rpcTaskContext, input, null);
371 return task.submit();
375 public Future<RpcResult<GetNodeConnectorStatisticsOutput>> getNodeConnectorStatistics(
376 final GetNodeConnectorStatisticsInput input) {
377 LOG.debug("Calling the getNodeConnectorStatistics RPC method on MessageDispatchService");
379 OFRpcTask<GetNodeConnectorStatisticsInput, RpcResult<GetNodeConnectorStatisticsOutput>> task =
380 OFRpcTaskFactory.createGetNodeConnectorStatisticsTask(rpcTaskContext, input, null);
381 return task.submit();
385 public Future<RpcResult<UpdatePortOutput>> updatePort(final UpdatePortInput input) {
386 LOG.debug("Calling the updatePort RPC method on MessageDispatchService");
388 OFRpcTask<UpdatePortInput, RpcResult<UpdatePortOutput>> task =
389 OFRpcTaskFactory.createUpdatePortTask(rpcTaskContext, input, null);
390 return task.submit();
394 public Future<RpcResult<UpdateTableOutput>> updateTable(final UpdateTableInput input) {
395 LOG.debug("Calling the updateTable RPC method on MessageDispatchService");
397 OFRpcTask<UpdateTableInput, RpcResult<UpdateTableOutput>> task =
398 OFRpcTaskFactory.createUpdateTableTask(rpcTaskContext, input, null);
399 return task.submit();
403 public Future<RpcResult<GetAllFlowStatisticsFromFlowTableOutput>> getAllFlowStatisticsFromFlowTable(
404 final GetAllFlowStatisticsFromFlowTableInput input) {
405 LOG.debug("Calling the getAllFlowStatisticsFromFlowTable RPC method on MessageDispatchService");
407 OFRpcTask<GetAllFlowStatisticsFromFlowTableInput, RpcResult<GetAllFlowStatisticsFromFlowTableOutput>> task =
408 OFRpcTaskFactory.createGetAllFlowStatisticsFromFlowTableTask(rpcTaskContext, input, null);
409 return task.submit();
413 public Future<RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput>> getAllFlowsStatisticsFromAllFlowTables(
414 final GetAllFlowsStatisticsFromAllFlowTablesInput input) {
415 LOG.debug("Calling the getAllFlowsStatisticsFromAllFlowTables RPC method on MessageDispatchService");
417 OFRpcTask<GetAllFlowsStatisticsFromAllFlowTablesInput, RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput>> task =
418 OFRpcTaskFactory.createGetAllFlowsStatisticsFromAllFlowTablesTask(rpcTaskContext, input, null);
419 return task.submit();
423 public Future<RpcResult<GetFlowStatisticsFromFlowTableOutput>> getFlowStatisticsFromFlowTable(
424 final GetFlowStatisticsFromFlowTableInput input) {
425 LOG.debug("Calling the getFlowStatisticsFromFlowTable RPC method on MessageDispatchService");
427 OFRpcTask<GetFlowStatisticsFromFlowTableInput, RpcResult<GetFlowStatisticsFromFlowTableOutput>> task =
428 OFRpcTaskFactory.createGetFlowStatisticsFromFlowTableTask(rpcTaskContext, input, null);
429 return task.submit();
433 public Future<RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>> getAggregateFlowStatisticsFromFlowTableForAllFlows(
434 final GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput input) {
435 LOG.debug("Calling the getAggregateFlowStatisticsFromFlowTableForAllFlows RPC method on MessageDispatchService");
437 OFRpcTask<GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput, RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>> task =
438 OFRpcTaskFactory.createGetAggregateFlowStatisticsFromFlowTableForAllFlowsTask(rpcTaskContext, input, null);
439 return task.submit();
443 public Future<RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>> getAggregateFlowStatisticsFromFlowTableForGivenMatch(
444 final GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput input) {
445 LOG.debug("Calling the getAggregateFlowStatisticsFromFlowTableForGivenMatch RPC method on MessageDispatchService");
447 OFRpcTask<GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput, RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>> task =
448 OFRpcTaskFactory.createGetAggregateFlowStatisticsFromFlowTableForGivenMatchTask(rpcTaskContext, input, null);
449 return task.submit();
453 public Future<RpcResult<GetFlowTablesStatisticsOutput>> getFlowTablesStatistics(
454 final GetFlowTablesStatisticsInput input) {
455 LOG.debug("Calling the getFlowTablesStatistics RPC method on MessageDispatchService");
457 OFRpcTask<GetFlowTablesStatisticsInput, RpcResult<GetFlowTablesStatisticsOutput>> task =
458 OFRpcTaskFactory.createGetFlowTablesStatisticsTask(rpcTaskContext, input, null);
459 return task.submit();
463 public Future<RpcResult<GetAllQueuesStatisticsFromAllPortsOutput>> getAllQueuesStatisticsFromAllPorts(
464 final GetAllQueuesStatisticsFromAllPortsInput input) {
465 LOG.debug("Calling the getAllQueuesStatisticsFromAllPorts RPC method on MessageDispatchService");
467 OFRpcTask<GetAllQueuesStatisticsFromAllPortsInput, RpcResult<GetAllQueuesStatisticsFromAllPortsOutput>> task =
468 OFRpcTaskFactory.createGetAllQueuesStatisticsFromAllPortsTask(rpcTaskContext, input, null);
469 return task.submit();
473 public Future<RpcResult<GetAllQueuesStatisticsFromGivenPortOutput>> getAllQueuesStatisticsFromGivenPort(
474 final GetAllQueuesStatisticsFromGivenPortInput input) {
475 LOG.debug("Calling the getAllQueuesStatisticsFromGivenPort RPC method on MessageDispatchService");
477 OFRpcTask<GetAllQueuesStatisticsFromGivenPortInput, RpcResult<GetAllQueuesStatisticsFromGivenPortOutput>> task =
478 OFRpcTaskFactory.createGetAllQueuesStatisticsFromGivenPortTask(rpcTaskContext, input, null);
479 return task.submit();
483 public Future<RpcResult<GetQueueStatisticsFromGivenPortOutput>> getQueueStatisticsFromGivenPort(
484 final GetQueueStatisticsFromGivenPortInput input) {
485 LOG.debug("Calling the getQueueStatisticsFromGivenPort RPC method on MessageDispatchService");
487 OFRpcTask<GetQueueStatisticsFromGivenPortInput, RpcResult<GetQueueStatisticsFromGivenPortOutput>> task =
488 OFRpcTaskFactory.createGetQueueStatisticsFromGivenPortTask(rpcTaskContext, input, null);
489 return task.submit();
493 public Future<RpcResult<SetConfigOutput>> setConfig(SetConfigInput input) {
494 OFRpcTask<SetConfigInput, RpcResult<SetConfigOutput>> task = OFRpcTaskFactory.createSetNodeConfigTask(rpcTaskContext, input, null);
495 return task.submit();
498 public Optional<BigInteger> sendEmptyTableFeatureRequest() {
499 LOG.debug("Send table feature request to {}",nodeId);
501 final Long xid = rpcTaskContext.getSession().getNextXid();
503 MultipartRequestTableFeaturesCaseBuilder caseBuilder = new MultipartRequestTableFeaturesCaseBuilder();
504 MultipartRequestTableFeaturesBuilder requestBuilder = new MultipartRequestTableFeaturesBuilder();
505 caseBuilder.setMultipartRequestTableFeatures(requestBuilder.build());
507 MultipartRequestInputBuilder mprInput = new MultipartRequestInputBuilder();
508 mprInput.setType(MultipartType.OFPMPTABLEFEATURES);
509 mprInput.setVersion(rpcTaskContext.getSession().getPrimaryConductor().getVersion());
510 mprInput.setXid(xid);
511 mprInput.setFlags(new MultipartRequestFlags(false));
513 mprInput.setMultipartRequestBody(caseBuilder.build());
515 Future<RpcResult<Void>> resultFromOFLib = rpcTaskContext.getMessageService()
516 .multipartRequest(mprInput.build(), null);
518 return Optional.of(BigInteger.valueOf(xid));
523 public void requestSwitchDetails(){
524 // post-handshake actions
525 if (version == OFConstants.OFP_VERSION_1_3) {
533 * Send an OFPMP_DESC request message to the switch
535 private void requestDesc() {
536 MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
537 builder.setType(MultipartType.OFPMPDESC);
538 builder.setVersion(version);
539 builder.setFlags(new MultipartRequestFlags(false));
540 builder.setMultipartRequestBody(new MultipartRequestDescCaseBuilder()
542 builder.setXid(getSessionContext().getNextXid());
543 rpcTaskContext.getSession().getPrimaryConductor().getConnectionAdapter().multipartRequest(builder.build());
546 private void requestPorts() {
547 MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
548 builder.setType(MultipartType.OFPMPPORTDESC);
549 builder.setVersion(version);
550 builder.setFlags(new MultipartRequestFlags(false));
551 builder.setMultipartRequestBody(new MultipartRequestPortDescCaseBuilder()
553 builder.setXid(getSessionContext().getNextXid());
554 rpcTaskContext.getSession().getPrimaryConductor().getConnectionAdapter().multipartRequest(builder.build());