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 com.google.common.util.concurrent.Futures;
12 import com.google.common.util.concurrent.ListenableFuture;
13 import java.math.BigInteger;
14 import java.util.concurrent.Future;
15 import java.util.concurrent.TimeUnit;
16 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
17 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
18 import org.opendaylight.openflowplugin.api.OFConstants;
19 import org.opendaylight.openflowplugin.api.openflow.md.core.SwitchConnectionDistinguisher;
20 import org.opendaylight.openflowplugin.api.openflow.md.core.session.IMessageDispatchService;
21 import org.opendaylight.openflowplugin.api.openflow.md.core.session.SessionContext;
22 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;
23 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.PacketOutConvertor;
24 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.PacketOutConvertorData;
25 import org.opendaylight.openflowplugin.openflow.md.core.session.OFSessionUtil;
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 final PacketOutConvertorData data = new PacketOutConvertorData(version);
223 data.setDatapathId(sessionContext.getFeatures().getDatapathId());
224 data.setXid(sessionContext.getNextXid());
226 final java.util.Optional<PacketOutInput> message = ConvertorManager.getInstance().convert(input, data);
228 SwitchConnectionDistinguisher cookie = null;
229 ConnectionCookie connectionCookie = input.getConnectionCookie();
230 if (connectionCookie != null && connectionCookie.getValue() != null) {
231 cookie = new SwitchConnectionCookieOFImpl(connectionCookie.getValue());
234 LOG.debug("Calling the transmitPacket RPC method");
235 return messageService.packetOut(message
236 .orElse(PacketOutConvertor.defaultResult(version)), cookie);
240 public Future<RpcResult<UpdateFlowOutput>> updateFlow(final UpdateFlowInput input) {
241 LOG.debug("Calling the updateFlow RPC method on MessageDispatchService");
243 // use primary connection
244 SwitchConnectionDistinguisher cookie = null;
245 final ReadWriteTransaction rwTx = OFSessionUtil.getSessionManager().getDataBroker().newReadWriteTransaction();
246 OFRpcTask<UpdateFlowInput, RpcResult<UpdateFlowOutput>> task =
247 OFRpcTaskFactory.createUpdateFlowTask(rpcTaskContext, input, cookie, rwTx);
248 ListenableFuture<RpcResult<UpdateFlowOutput>> result = task.submit();
254 public Future<RpcResult<UpdateGroupOutput>> updateGroup(final UpdateGroupInput input) {
255 LOG.debug("Calling the update Group Mod RPC method on MessageDispatchService");
257 // use primary connection
258 SwitchConnectionDistinguisher cookie = null;
260 OFRpcTask<UpdateGroupInput, RpcResult<UpdateGroupOutput>> task =
261 OFRpcTaskFactory.createUpdateGroupTask(rpcTaskContext, input, cookie);
262 ListenableFuture<RpcResult<UpdateGroupOutput>> result = task.submit();
268 public Future<RpcResult<UpdateMeterOutput>> updateMeter(final UpdateMeterInput input) {
269 LOG.debug("Calling the MeterMod RPC method on MessageDispatchService");
271 // use primary connection
272 SwitchConnectionDistinguisher cookie = null;
274 OFRpcTask<UpdateMeterInput, RpcResult<UpdateMeterOutput>> task =
275 OFRpcTaskFactory.createUpdateMeterTask(rpcTaskContext, input, cookie);
276 ListenableFuture<RpcResult<UpdateMeterOutput>> result = task.submit();
282 public NodeId getNodeId() {
288 public Future<RpcResult<GetAllGroupStatisticsOutput>> getAllGroupStatistics(final GetAllGroupStatisticsInput input) {
289 // use primary connection
290 LOG.debug("Calling the getAllGroupStatistics RPC method on MessageDispatchService");
291 SwitchConnectionDistinguisher cookie = null;
293 OFRpcTask<GetAllGroupStatisticsInput, RpcResult<GetAllGroupStatisticsOutput>> task =
294 OFRpcTaskFactory.createGetAllGroupStatisticsTask(rpcTaskContext, input, cookie);
295 ListenableFuture<RpcResult<GetAllGroupStatisticsOutput>> result = task.submit();
302 public Future<RpcResult<GetGroupDescriptionOutput>> getGroupDescription(final GetGroupDescriptionInput input) {
303 LOG.debug("Calling the getGroupDescription RPC method on MessageDispatchService");
305 OFRpcTask<GetGroupDescriptionInput, RpcResult<GetGroupDescriptionOutput>> task =
306 OFRpcTaskFactory.createGetGroupDescriptionTask(rpcTaskContext, input, null);
307 return task.submit();
311 public Future<RpcResult<GetGroupFeaturesOutput>> getGroupFeatures(final GetGroupFeaturesInput input) {
312 LOG.debug("Calling the getGroupFeatures RPC method on MessageDispatchService");
314 OFRpcTask<GetGroupFeaturesInput, RpcResult<GetGroupFeaturesOutput>> task =
315 OFRpcTaskFactory.createGetGroupFeaturesTask(rpcTaskContext, input, null);
316 return task.submit();
320 public Future<RpcResult<GetGroupStatisticsOutput>> getGroupStatistics(final GetGroupStatisticsInput input) {
321 LOG.debug("Calling the getGroupStatistics RPC method on MessageDispatchService");
323 OFRpcTask<GetGroupStatisticsInput, RpcResult<GetGroupStatisticsOutput>> task =
324 OFRpcTaskFactory.createGetGroupStatisticsTask(rpcTaskContext, input, null);
325 return task.submit();
329 public Future<RpcResult<GetAllMeterConfigStatisticsOutput>> getAllMeterConfigStatistics(
330 final GetAllMeterConfigStatisticsInput input) {
331 LOG.debug("Calling the getAllMeterConfigStatistics RPC method on MessageDispatchService");
333 OFRpcTask<GetAllMeterConfigStatisticsInput, RpcResult<GetAllMeterConfigStatisticsOutput>> task =
334 OFRpcTaskFactory.createGetAllMeterConfigStatisticsTask(rpcTaskContext, input, null);
335 return task.submit();
339 public Future<RpcResult<GetAllMeterStatisticsOutput>> getAllMeterStatistics(
340 final GetAllMeterStatisticsInput input) {
341 LOG.debug("Calling the getAllMeterStatistics RPC method on MessageDispatchService");
343 OFRpcTask<GetAllMeterStatisticsInput, RpcResult<GetAllMeterStatisticsOutput>> task =
344 OFRpcTaskFactory.createGetAllMeterStatisticsTask(rpcTaskContext, input, null);
345 return task.submit();
349 public Future<RpcResult<GetMeterFeaturesOutput>> getMeterFeatures(
350 final GetMeterFeaturesInput input) {
351 LOG.debug("Calling the getMeterFeatures RPC method on MessageDispatchService");
353 OFRpcTask<GetMeterFeaturesInput, RpcResult<GetMeterFeaturesOutput>> task =
354 OFRpcTaskFactory.createGetMeterFeaturesTask(rpcTaskContext, input, null);
355 return task.submit();
359 public Future<RpcResult<GetMeterStatisticsOutput>> getMeterStatistics(
360 final GetMeterStatisticsInput input) {
361 LOG.debug("Calling the getMeterStatistics RPC method on MessageDispatchService");
363 OFRpcTask<GetMeterStatisticsInput, RpcResult<GetMeterStatisticsOutput>> task =
364 OFRpcTaskFactory.createGetMeterStatisticsTask(rpcTaskContext, input, null);
365 return task.submit();
369 public Future<RpcResult<GetAllNodeConnectorsStatisticsOutput>> getAllNodeConnectorsStatistics(
370 final GetAllNodeConnectorsStatisticsInput input) {
371 LOG.debug("Calling the getAllNodeConnectorsStatistics RPC method on MessageDispatchService");
373 OFRpcTask<GetAllNodeConnectorsStatisticsInput, RpcResult<GetAllNodeConnectorsStatisticsOutput>> task =
374 OFRpcTaskFactory.createGetAllNodeConnectorsStatisticsTask(rpcTaskContext, input, null);
375 return task.submit();
379 public Future<RpcResult<GetNodeConnectorStatisticsOutput>> getNodeConnectorStatistics(
380 final GetNodeConnectorStatisticsInput input) {
381 LOG.debug("Calling the getNodeConnectorStatistics RPC method on MessageDispatchService");
383 OFRpcTask<GetNodeConnectorStatisticsInput, RpcResult<GetNodeConnectorStatisticsOutput>> task =
384 OFRpcTaskFactory.createGetNodeConnectorStatisticsTask(rpcTaskContext, input, null);
385 return task.submit();
389 public Future<RpcResult<UpdatePortOutput>> updatePort(final UpdatePortInput input) {
390 LOG.debug("Calling the updatePort RPC method on MessageDispatchService");
392 OFRpcTask<UpdatePortInput, RpcResult<UpdatePortOutput>> task =
393 OFRpcTaskFactory.createUpdatePortTask(rpcTaskContext, input, null);
394 return task.submit();
398 public Future<RpcResult<UpdateTableOutput>> updateTable(final UpdateTableInput input) {
399 LOG.debug("Calling the updateTable RPC method on MessageDispatchService");
401 OFRpcTask<UpdateTableInput, RpcResult<UpdateTableOutput>> task =
402 OFRpcTaskFactory.createUpdateTableTask(rpcTaskContext, input, null);
403 return task.submit();
407 public Future<RpcResult<GetAllFlowStatisticsFromFlowTableOutput>> getAllFlowStatisticsFromFlowTable(
408 final GetAllFlowStatisticsFromFlowTableInput input) {
409 LOG.debug("Calling the getAllFlowStatisticsFromFlowTable RPC method on MessageDispatchService");
411 OFRpcTask<GetAllFlowStatisticsFromFlowTableInput, RpcResult<GetAllFlowStatisticsFromFlowTableOutput>> task =
412 OFRpcTaskFactory.createGetAllFlowStatisticsFromFlowTableTask(rpcTaskContext, input, null);
413 return task.submit();
417 public Future<RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput>> getAllFlowsStatisticsFromAllFlowTables(
418 final GetAllFlowsStatisticsFromAllFlowTablesInput input) {
419 LOG.debug("Calling the getAllFlowsStatisticsFromAllFlowTables RPC method on MessageDispatchService");
421 OFRpcTask<GetAllFlowsStatisticsFromAllFlowTablesInput, RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput>> task =
422 OFRpcTaskFactory.createGetAllFlowsStatisticsFromAllFlowTablesTask(rpcTaskContext, input, null);
423 return task.submit();
427 public Future<RpcResult<GetFlowStatisticsFromFlowTableOutput>> getFlowStatisticsFromFlowTable(
428 final GetFlowStatisticsFromFlowTableInput input) {
429 LOG.debug("Calling the getFlowStatisticsFromFlowTable RPC method on MessageDispatchService");
431 OFRpcTask<GetFlowStatisticsFromFlowTableInput, RpcResult<GetFlowStatisticsFromFlowTableOutput>> task =
432 OFRpcTaskFactory.createGetFlowStatisticsFromFlowTableTask(rpcTaskContext, input, null);
433 return task.submit();
437 public Future<RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>> getAggregateFlowStatisticsFromFlowTableForAllFlows(
438 final GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput input) {
439 LOG.debug("Calling the getAggregateFlowStatisticsFromFlowTableForAllFlows RPC method on MessageDispatchService");
441 OFRpcTask<GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput, RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>> task =
442 OFRpcTaskFactory.createGetAggregateFlowStatisticsFromFlowTableForAllFlowsTask(rpcTaskContext, input, null);
443 return task.submit();
447 public Future<RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>> getAggregateFlowStatisticsFromFlowTableForGivenMatch(
448 final GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput input) {
449 LOG.debug("Calling the getAggregateFlowStatisticsFromFlowTableForGivenMatch RPC method on MessageDispatchService");
451 OFRpcTask<GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput, RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>> task =
452 OFRpcTaskFactory.createGetAggregateFlowStatisticsFromFlowTableForGivenMatchTask(rpcTaskContext, input, null);
453 return task.submit();
457 public Future<RpcResult<GetFlowTablesStatisticsOutput>> getFlowTablesStatistics(
458 final GetFlowTablesStatisticsInput input) {
459 LOG.debug("Calling the getFlowTablesStatistics RPC method on MessageDispatchService");
461 OFRpcTask<GetFlowTablesStatisticsInput, RpcResult<GetFlowTablesStatisticsOutput>> task =
462 OFRpcTaskFactory.createGetFlowTablesStatisticsTask(rpcTaskContext, input, null);
463 return task.submit();
467 public Future<RpcResult<GetAllQueuesStatisticsFromAllPortsOutput>> getAllQueuesStatisticsFromAllPorts(
468 final GetAllQueuesStatisticsFromAllPortsInput input) {
469 LOG.debug("Calling the getAllQueuesStatisticsFromAllPorts RPC method on MessageDispatchService");
471 OFRpcTask<GetAllQueuesStatisticsFromAllPortsInput, RpcResult<GetAllQueuesStatisticsFromAllPortsOutput>> task =
472 OFRpcTaskFactory.createGetAllQueuesStatisticsFromAllPortsTask(rpcTaskContext, input, null);
473 return task.submit();
477 public Future<RpcResult<GetAllQueuesStatisticsFromGivenPortOutput>> getAllQueuesStatisticsFromGivenPort(
478 final GetAllQueuesStatisticsFromGivenPortInput input) {
479 LOG.debug("Calling the getAllQueuesStatisticsFromGivenPort RPC method on MessageDispatchService");
481 OFRpcTask<GetAllQueuesStatisticsFromGivenPortInput, RpcResult<GetAllQueuesStatisticsFromGivenPortOutput>> task =
482 OFRpcTaskFactory.createGetAllQueuesStatisticsFromGivenPortTask(rpcTaskContext, input, null);
483 return task.submit();
487 public Future<RpcResult<GetQueueStatisticsFromGivenPortOutput>> getQueueStatisticsFromGivenPort(
488 final GetQueueStatisticsFromGivenPortInput input) {
489 LOG.debug("Calling the getQueueStatisticsFromGivenPort RPC method on MessageDispatchService");
491 OFRpcTask<GetQueueStatisticsFromGivenPortInput, RpcResult<GetQueueStatisticsFromGivenPortOutput>> task =
492 OFRpcTaskFactory.createGetQueueStatisticsFromGivenPortTask(rpcTaskContext, input, null);
493 return task.submit();
497 public Future<RpcResult<SetConfigOutput>> setConfig(SetConfigInput input) {
498 OFRpcTask<SetConfigInput, RpcResult<SetConfigOutput>> task = OFRpcTaskFactory.createSetNodeConfigTask(rpcTaskContext, input, null);
499 return task.submit();
502 public Optional<BigInteger> sendEmptyTableFeatureRequest() {
503 LOG.debug("Send table feature request to {}",nodeId);
505 final Long xid = rpcTaskContext.getSession().getNextXid();
507 MultipartRequestTableFeaturesCaseBuilder caseBuilder = new MultipartRequestTableFeaturesCaseBuilder();
508 MultipartRequestTableFeaturesBuilder requestBuilder = new MultipartRequestTableFeaturesBuilder();
509 caseBuilder.setMultipartRequestTableFeatures(requestBuilder.build());
511 MultipartRequestInputBuilder mprInput = new MultipartRequestInputBuilder();
512 mprInput.setType(MultipartType.OFPMPTABLEFEATURES);
513 mprInput.setVersion(rpcTaskContext.getSession().getPrimaryConductor().getVersion());
514 mprInput.setXid(xid);
515 mprInput.setFlags(new MultipartRequestFlags(false));
517 mprInput.setMultipartRequestBody(caseBuilder.build());
519 Future<RpcResult<Void>> resultFromOFLib = rpcTaskContext.getMessageService()
520 .multipartRequest(mprInput.build(), null);
522 return Optional.of(BigInteger.valueOf(xid));
527 public void requestSwitchDetails(){
528 // post-handshake actions
529 if (version == OFConstants.OFP_VERSION_1_3) {
537 * Send an OFPMP_DESC request message to the switch
539 private void requestDesc() {
540 MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
541 builder.setType(MultipartType.OFPMPDESC);
542 builder.setVersion(version);
543 builder.setFlags(new MultipartRequestFlags(false));
544 builder.setMultipartRequestBody(new MultipartRequestDescCaseBuilder()
546 builder.setXid(getSessionContext().getNextXid());
547 rpcTaskContext.getSession().getPrimaryConductor().getConnectionAdapter().multipartRequest(builder.build());
550 private void requestPorts() {
551 MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
552 builder.setType(MultipartType.OFPMPPORTDESC);
553 builder.setVersion(version);
554 builder.setFlags(new MultipartRequestFlags(false));
555 builder.setMultipartRequestBody(new MultipartRequestPortDescCaseBuilder()
557 builder.setXid(getSessionContext().getNextXid());
558 rpcTaskContext.getSession().getPrimaryConductor().getConnectionAdapter().multipartRequest(builder.build());