2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.openflowplugin.openflow.md.core.sal;
10 import java.math.BigInteger;
11 import java.util.ArrayList;
12 import java.util.Collection;
13 import java.util.Collections;
14 import java.util.List;
15 import java.util.concurrent.Future;
17 import org.opendaylight.controller.sal.common.util.Arguments;
18 import org.opendaylight.controller.sal.common.util.Rpcs;
19 import org.opendaylight.openflowjava.protocol.api.util.BinContent;
20 import org.opendaylight.openflowplugin.openflow.md.OFConstants;
21 import org.opendaylight.openflowplugin.openflow.md.core.SwitchConnectionDistinguisher;
22 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.FlowConvertor;
23 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.GroupConvertor;
24 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.MeterConvertor;
25 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.PortConvertor;
26 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.TableFeaturesConvertor;
27 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchReactor;
28 import org.opendaylight.openflowplugin.openflow.md.core.session.IMessageDispatchService;
29 import org.opendaylight.openflowplugin.openflow.md.core.session.SessionContext;
30 import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
31 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowOutput;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowOutputBuilder;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInput;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowOutput;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowOutputBuilder;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInput;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowOutput;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowOutputBuilder;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutputBuilder;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableInput;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableOutput;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableOutputBuilder;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsInput;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsOutput;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesInput;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesOutput;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesOutputBuilder;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllNodeConnectorStatisticsInput;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllNodeConnectorStatisticsOutput;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableInput;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableOutput;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableOutputBuilder;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsInput;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsOutput;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowTableStatisticsInput;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowTableStatisticsOutput;
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetNodeConnectorStatisticsInput;
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetNodeConnectorStatisticsOutput;
67 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsInput;
68 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsOutput;
69 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsOutputBuilder;
70 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionId;
71 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.Port;
72 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow;
73 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInput;
74 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupOutput;
75 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupOutputBuilder;
76 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInput;
77 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupOutput;
78 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupOutputBuilder;
79 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupInput;
80 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupOutput;
81 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupOutputBuilder;
82 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsInput;
83 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsOutput;
84 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsOutputBuilder;
85 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupDescriptionInput;
86 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupDescriptionOutput;
87 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupDescriptionOutputBuilder;
88 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupFeaturesInput;
89 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupFeaturesOutput;
90 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupFeaturesOutputBuilder;
91 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupStatisticsInput;
92 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupStatisticsOutput;
93 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupStatisticsOutputBuilder;
94 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef;
95 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
96 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey;
97 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
98 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterInput;
99 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterOutput;
100 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterOutputBuilder;
101 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterInput;
102 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterOutput;
103 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterOutputBuilder;
104 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterInput;
105 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterOutput;
106 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterOutputBuilder;
107 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsInput;
108 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsOutput;
109 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsOutputBuilder;
110 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterStatisticsInput;
111 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterStatisticsOutput;
112 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterStatisticsOutputBuilder;
113 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterFeaturesInput;
114 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterFeaturesOutput;
115 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterFeaturesOutputBuilder;
116 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsInput;
117 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsOutput;
118 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsOutputBuilder;
119 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction;
120 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthActionBuilder;
121 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction;
122 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortActionBuilder;
123 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.ActionsList;
124 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.ActionsListBuilder;
125 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.actions.list.Action;
126 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.actions.list.ActionBuilder;
127 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10;
128 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Group;
129 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId;
130 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Meter;
131 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId;
132 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags;
133 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
134 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
135 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmMatchType;
136 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10Builder;
137 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.MatchEntries;
138 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput;
139 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInputBuilder;
140 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput;
141 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput;
142 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInputBuilder;
143 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInput;
144 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInput;
145 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
146 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput;
147 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInputBuilder;
148 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput;
149 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInputBuilder;
150 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.match.grouping.Match;
151 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.match.grouping.MatchBuilder;
152 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestAggregateCaseBuilder;
153 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlowCaseBuilder;
154 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupCaseBuilder;
155 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupDescCaseBuilder;
156 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupFeaturesCaseBuilder;
157 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterCaseBuilder;
158 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterConfigCaseBuilder;
159 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterFeaturesCaseBuilder;
160 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortStatsCaseBuilder;
161 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestQueueCaseBuilder;
162 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableCaseBuilder;
163 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableFeaturesCaseBuilder;
164 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.aggregate._case.MultipartRequestAggregateBuilder;
165 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.flow._case.MultipartRequestFlowBuilder;
166 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.group._case.MultipartRequestGroupBuilder;
167 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.meter._case.MultipartRequestMeterBuilder;
168 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.meter.config._case.MultipartRequestMeterConfigBuilder;
169 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.port.stats._case.MultipartRequestPortStatsBuilder;
170 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.queue._case.MultipartRequestQueueBuilder;
171 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table._case.MultipartRequestTableBuilder;
172 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.MultipartRequestTableFeaturesBuilder;
173 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.multipart.request.table.features.TableFeatures;
174 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput;
175 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.GetPortOutput;
176 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.UpdatePortInput;
177 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.UpdatePortOutput;
178 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.UpdatePortOutputBuilder;
179 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllPortsStatisticsInput;
180 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllPortsStatisticsOutput;
181 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllPortsStatisticsOutputBuilder;
182 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetPortStatisticsInput;
183 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetPortStatisticsOutput;
184 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetPortStatisticsOutputBuilder;
185 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromAllPortsInput;
186 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromAllPortsOutput;
187 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromAllPortsOutputBuilder;
188 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromGivenPortInput;
189 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromGivenPortOutput;
190 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromGivenPortOutputBuilder;
191 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetQueueStatisticsFromGivenPortInput;
192 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetQueueStatisticsFromGivenPortOutput;
193 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetQueueStatisticsFromGivenPortOutputBuilder;
194 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableInput;
195 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableOutput;
196 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableOutputBuilder;
197 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
198 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument;
199 import org.opendaylight.yangtools.yang.common.RpcError;
200 import org.opendaylight.yangtools.yang.common.RpcResult;
201 import org.slf4j.Logger;
203 import com.google.common.base.Objects;
204 import com.google.common.util.concurrent.Futures;
207 * RPC implementation of MD-switch
209 public class ModelDrivenSwitchImpl extends AbstractModelDrivenSwitch {
211 private static final Logger LOG = org.slf4j.LoggerFactory
212 .getLogger(ModelDrivenSwitchImpl.class);
213 private final NodeId nodeId;
214 private final IMessageDispatchService messageService ;
215 private short version = 0;
217 protected ModelDrivenSwitchImpl(NodeId nodeId,
218 InstanceIdentifier<Node> identifier, SessionContext context) {
219 super(identifier, context);
220 this.nodeId = nodeId;
221 messageService = sessionContext.getMessageDispatchService() ;
222 version = context.getPrimaryConductor().getVersion();
227 public Future<RpcResult<AddFlowOutput>> addFlow(AddFlowInput input) {
228 // Convert the AddFlowInput to FlowModInput
229 FlowModInput ofFlowModInput = FlowConvertor.toFlowModInput(input, version);
230 BarrierInputBuilder barrierInput = new BarrierInputBuilder();
231 barrierInput.setVersion(version);
233 // For Flow provisioning, the SwitchConnectionDistinguisher is set to null so
234 // the request can be routed through any connection to the switch
236 SwitchConnectionDistinguisher cookie = null ;
237 if (Objects.firstNonNull(input.isBarrier(), Boolean.FALSE)) {
238 Future<RpcResult<BarrierOutput>> barrierOFLib = messageService.barrier(barrierInput.build(), cookie);
241 LOG.debug("Calling the FlowMod RPC method on MessageDispatchService");
242 Future<RpcResult<UpdateFlowOutput>> resultFromOFLib = messageService.flowMod(ofFlowModInput, cookie) ;
244 RpcResult<UpdateFlowOutput> rpcResultFromOFLib = null ;
247 rpcResultFromOFLib = resultFromOFLib.get();
248 } catch( Exception ex ) {
249 LOG.error( " Error while getting result for AddFlow RPC" + ex.getMessage());
252 UpdateFlowOutput updateFlowOutput = rpcResultFromOFLib.getResult() ;
254 AddFlowOutputBuilder addFlowOutput = new AddFlowOutputBuilder() ;
255 addFlowOutput.setTransactionId(updateFlowOutput.getTransactionId()) ;
256 AddFlowOutput result = addFlowOutput.build();
258 Collection<RpcError> errors = rpcResultFromOFLib.getErrors() ;
259 RpcResult<AddFlowOutput> rpcResult = Rpcs.getRpcResult(true, result, errors);
261 LOG.debug("Returning the Add Flow RPC result to MD-SAL");
262 return Futures.immediateFuture(rpcResult);
266 public Future<RpcResult<AddGroupOutput>> addGroup(AddGroupInput input) {
267 // Convert the AddGroupInput to GroupModInput
268 GroupModInput ofGroupModInput = GroupConvertor.toGroupModInput(input, version);
271 // For Flow provisioning, the SwitchConnectionDistinguisher is set to null so
272 // the request can be routed through any connection to the switch
274 SwitchConnectionDistinguisher cookie = null ;
276 LOG.debug("Calling the GroupMod RPC method on MessageDispatchService");
277 Future<RpcResult<UpdateGroupOutput>> resultFromOFLib = messageService.groupMod(ofGroupModInput, cookie) ;
279 RpcResult<UpdateGroupOutput> rpcResultFromOFLib = null ;
282 rpcResultFromOFLib = resultFromOFLib.get();
283 } catch( Exception ex ) {
284 LOG.error( " Error while getting result for AddGroup RPC" + ex.getMessage());
287 UpdateGroupOutput updateGroupOutput = rpcResultFromOFLib.getResult() ;
289 AddGroupOutputBuilder addGroupOutput = new AddGroupOutputBuilder() ;
290 addGroupOutput.setTransactionId(updateGroupOutput.getTransactionId()) ;
291 AddGroupOutput result = addGroupOutput.build();
293 Collection<RpcError> errors = rpcResultFromOFLib.getErrors() ;
294 RpcResult<AddGroupOutput> rpcResult = Rpcs.getRpcResult(true, result, errors);
296 LOG.debug("Returning the Add Group RPC result to MD-SAL");
297 return Futures.immediateFuture(rpcResult);
301 public Future<RpcResult<AddMeterOutput>> addMeter(AddMeterInput input) {
302 // Convert the AddMeterInput to MeterModInput
303 MeterModInput ofMeterModInput = MeterConvertor.toMeterModInput(input, version);
305 // For Meter provisioning, the SwitchConnectionDistinguisher is set to null so
306 // the request can be routed through any connection to the switch
308 SwitchConnectionDistinguisher cookie = null ;
310 LOG.debug("Calling the MeterMod RPC method on MessageDispatchService");
311 Future<RpcResult<UpdateMeterOutput>> resultFromOFLib = messageService.meterMod(ofMeterModInput, cookie) ;
313 RpcResult<UpdateMeterOutput> rpcResultFromOFLib = null ;
316 rpcResultFromOFLib = resultFromOFLib.get();
317 } catch( Exception ex ) {
318 LOG.error( " Error while getting result for AddMeter RPC" + ex.getMessage());
321 UpdateMeterOutput updateMeterOutput = rpcResultFromOFLib.getResult() ;
323 AddMeterOutputBuilder addMeterOutput = new AddMeterOutputBuilder() ;
324 addMeterOutput.setTransactionId(updateMeterOutput.getTransactionId()) ;
325 AddMeterOutput result = addMeterOutput.build();
327 Collection<RpcError> errors = rpcResultFromOFLib.getErrors() ;
328 RpcResult<AddMeterOutput> rpcResult = Rpcs.getRpcResult(true, result, errors);
330 LOG.debug("Returning the Add Meter RPC result to MD-SAL");
331 return Futures.immediateFuture(rpcResult);
335 public Future<RpcResult<RemoveFlowOutput>> removeFlow(RemoveFlowInput input) {
336 // Convert the RemoveFlowInput to FlowModInput
337 FlowModInput ofFlowModInput = FlowConvertor.toFlowModInput(input, version);
338 BarrierInputBuilder barrierInput = new BarrierInputBuilder();
339 barrierInput.setVersion(version);
341 // For Flow provisioning, the SwitchConnectionDistinguisher is set to null so
342 // the request can be routed through any connection to the switch
344 SwitchConnectionDistinguisher cookie = null ;
345 if (Objects.firstNonNull(input.isBarrier(), Boolean.FALSE)) {
346 Future<RpcResult<BarrierOutput>> barrierOFLib = messageService.barrier(barrierInput.build(), cookie);
349 LOG.debug("Calling the FlowMod RPC method on MessageDispatchService");
350 Future<RpcResult<UpdateFlowOutput>> resultFromOFLib = messageService.flowMod(ofFlowModInput, cookie) ;
352 RpcResult<UpdateFlowOutput> rpcResultFromOFLib = null ;
355 rpcResultFromOFLib = resultFromOFLib.get();
356 } catch( Exception ex ) {
357 LOG.error( " Error while getting result for remove Flow RPC" + ex.getMessage());
360 UpdateFlowOutput updateFlowOutput = rpcResultFromOFLib.getResult() ;
362 RemoveFlowOutputBuilder removeFlowOutput = new RemoveFlowOutputBuilder() ;
363 removeFlowOutput.setTransactionId(updateFlowOutput.getTransactionId()) ;
364 RemoveFlowOutput result = removeFlowOutput.build();
366 Collection<RpcError> errors = rpcResultFromOFLib.getErrors() ;
367 RpcResult<RemoveFlowOutput> rpcResult = Rpcs.getRpcResult(true, result, errors);
369 LOG.debug("Returning the Remove Flow RPC result to MD-SAL");
370 return Futures.immediateFuture(rpcResult);
374 public Future<RpcResult<RemoveGroupOutput>> removeGroup(
375 RemoveGroupInput input) {
376 // Convert the RemoveGroupInput to GroupModInput
377 GroupModInput ofGroupModInput = GroupConvertor.toGroupModInput(input, version);
380 // For Flow provisioning, the SwitchConnectionDistinguisher is set to null so
381 // the request can be routed through any connection to the switch
383 SwitchConnectionDistinguisher cookie = null ;
385 LOG.debug("Calling the GroupMod RPC method on MessageDispatchService");
386 Future<RpcResult<UpdateGroupOutput>> resultFromOFLib = messageService.groupMod(ofGroupModInput, cookie) ;
388 RpcResult<UpdateGroupOutput> rpcResultFromOFLib = null ;
391 rpcResultFromOFLib = resultFromOFLib.get();
392 } catch( Exception ex ) {
393 LOG.error( " Error while getting result for RemoveGroup RPC" + ex.getMessage());
396 UpdateGroupOutput updateGroupOutput = rpcResultFromOFLib.getResult() ;
398 RemoveGroupOutputBuilder removeGroupOutput = new RemoveGroupOutputBuilder() ;
399 removeGroupOutput.setTransactionId(updateGroupOutput.getTransactionId()) ;
400 RemoveGroupOutput result = removeGroupOutput.build();
402 Collection<RpcError> errors = rpcResultFromOFLib.getErrors() ;
403 RpcResult<RemoveGroupOutput> rpcResult = Rpcs.getRpcResult(true, result, errors);
405 LOG.debug("Returning the Remove Group RPC result to MD-SAL");
406 return Futures.immediateFuture(rpcResult);
410 public Future<RpcResult<RemoveMeterOutput>> removeMeter(
411 RemoveMeterInput input) {
412 // Convert the RemoveMeterInput to MeterModInput
413 MeterModInput ofMeterModInput = MeterConvertor.toMeterModInput(input, version);
416 // For Meter provisioning, the SwitchConnectionDistinguisher is set to null so
417 // the request can be routed through any connection to the switch
419 SwitchConnectionDistinguisher cookie = null ;
421 LOG.debug("Calling the MeterMod RPC method on MessageDispatchService");
422 Future<RpcResult<UpdateMeterOutput>> resultFromOFLib = messageService.meterMod(ofMeterModInput, cookie) ;
424 RpcResult<UpdateMeterOutput> rpcResultFromOFLib = null ;
427 rpcResultFromOFLib = resultFromOFLib.get();
428 } catch( Exception ex ) {
429 LOG.error( " Error while getting result for RemoveMeter RPC" + ex.getMessage());
432 UpdateMeterOutput updatemeterOutput = rpcResultFromOFLib.getResult() ;
434 RemoveMeterOutputBuilder removeMeterOutput = new RemoveMeterOutputBuilder() ;
435 removeMeterOutput.setTransactionId(updatemeterOutput.getTransactionId()) ;
436 RemoveMeterOutput result = removeMeterOutput.build();
438 Collection<RpcError> errors = rpcResultFromOFLib.getErrors() ;
439 RpcResult<RemoveMeterOutput> rpcResult = Rpcs.getRpcResult(true, result, errors);
441 LOG.debug("Returning the Remove Meter RPC result to MD-SAL");
442 return Futures.immediateFuture(rpcResult);
446 public Future<RpcResult<Void>> transmitPacket(TransmitPacketInput input) {
447 LOG.info("TransmitPacket - {}",input);
448 // Convert TransmitPacket to PacketOutInput
450 // TODO VD create PacketConvertor and move convert logic there
452 // Build Port ID from TransmitPacketInput.Ingress
453 PortNumber inPortNr = null;
455 List<PathArgument> inArgs = input.getIngress().getValue().getPath();
456 if (inArgs.size() >= 3) {
457 InstanceIdentifier.IdentifiableItem item = Arguments.checkInstanceOf(inArgs.get(2), InstanceIdentifier.IdentifiableItem.class);
458 NodeConnectorKey key = Arguments.checkInstanceOf(item.getKey(), NodeConnectorKey.class);
459 String[] split = key.getId().getValue().split(":");
460 Long port = Long.decode(split[split.length-1]);
461 inPortNr = new PortNumber(port);
463 // TODO Ed could by in this way or Exception or something else ?
464 inPortNr = new PortNumber(0xfffffffdL);
467 // Build Buffer ID from TransmitPacketInput.Ingress
468 // TODO VD P! find how to fix PacketIn to add BufferID to augmetation
469 Long bufferId = OFConstants.OFP_NO_BUFFER;
471 PortNumber outPort = null;
472 NodeConnectorRef outRef = input.getEgress();
473 List<PathArgument> outArgs = outRef.getValue().getPathArguments();
474 if (outArgs.size() >= 3) {
475 InstanceIdentifier.IdentifiableItem item = Arguments.checkInstanceOf(outArgs.get(2), InstanceIdentifier.IdentifiableItem.class);
476 NodeConnectorKey key = Arguments.checkInstanceOf(item.getKey(), NodeConnectorKey.class);
477 String[] split = key.getId().getValue().split(":");
478 Long port = Long.decode(split[split.length-1]);
479 outPort = new PortNumber(port);
481 new Exception("PORT NR not exist in Egress"); //TODO : P4 search for some normal exception
484 // TODO VD P! wait for way to move Actions (e.g. augmentation)
486 // TODO VD implementation for testing PacketIn (REMOVE IT)
487 List<ActionsList> actions = new ArrayList<ActionsList>();
488 ActionsListBuilder asBuild = new ActionsListBuilder();
489 ActionBuilder aBuild = new ActionBuilder();
490 aBuild.setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output.class);
491 PortActionBuilder paBuild = new PortActionBuilder();
492 paBuild.setPort(outPort);
493 aBuild.addAugmentation(PortAction.class, paBuild.build());
494 MaxLengthActionBuilder mlBuild = new MaxLengthActionBuilder();
495 mlBuild.setMaxLength(0xffff);
496 aBuild.addAugmentation(MaxLengthAction.class, mlBuild.build());
497 asBuild.setAction(aBuild.build());
498 actions.add(asBuild.build());
500 PacketOutInputBuilder builder = new PacketOutInputBuilder();
501 builder.setActionsList(actions);
502 builder.setData(input.getPayload());
503 builder.setVersion(version);
504 builder.setXid(sessionContext.getNextXid());
505 builder.setInPort(inPortNr);
506 builder.setBufferId(bufferId);
507 // --------------------------------------------------------
509 PacketOutInput message = builder.build();
511 // TODO VD NULL for yet - find how to translate cookie from TransmitPacketInput
512 // SwitchConnectionDistinguisher cookie = ( "what is need to do" ) input.getCookie();
513 SwitchConnectionDistinguisher cookie = null ;
515 LOG.debug("Calling the transmitPacket RPC method");
516 return messageService.packetOut(message, cookie);
519 private FlowModInputBuilder toFlowModInputBuilder(Flow source) {
520 FlowModInputBuilder target = new FlowModInputBuilder();
521 target.setCookie(source.getCookie());
522 target.setIdleTimeout(source.getIdleTimeout());
523 target.setHardTimeout(source.getHardTimeout());
524 target.setMatch(toMatch(source.getMatch()));
529 private Match toMatch(
530 org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match match) {
531 MatchBuilder target = new MatchBuilder();
533 target.setMatchEntries(toMatchEntries(match));
538 private List<MatchEntries> toMatchEntries(
539 org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match match) {
540 List<MatchEntries> entries = new ArrayList<>();
546 public Future<RpcResult<UpdateFlowOutput>> updateFlow(UpdateFlowInput input) {
547 // Convert the UpdateFlowInput to FlowModInput
548 FlowModInput ofFlowModInput = FlowConvertor.toFlowModInput(input.getUpdatedFlow(), version);
549 BarrierInputBuilder barrierInput = new BarrierInputBuilder();
550 barrierInput.setVersion(version);
551 // Call the RPC method on MessageDispatchService
553 // For Flow provisioning, the SwitchConnectionDistinguisher is set to null so
554 // the request can be routed through any connection to the switch
556 SwitchConnectionDistinguisher cookie = null ;
557 if (Objects.firstNonNull(input.getUpdatedFlow().isBarrier(), Boolean.FALSE)) {
558 Future<RpcResult<BarrierOutput>> barrierOFLib = messageService.barrier(barrierInput.build(), cookie);
561 LOG.debug("Calling the FlowMod RPC method on MessageDispatchService");
562 Future<RpcResult<UpdateFlowOutput>> resultFromOFLib = messageService.flowMod(ofFlowModInput, cookie) ;
564 RpcResult<UpdateFlowOutput> rpcResultFromOFLib = null ;
567 rpcResultFromOFLib = resultFromOFLib.get();
568 } catch( Exception ex ) {
569 LOG.error( " Error while getting result for UpdateFlow RPC" + ex.getMessage());
572 UpdateFlowOutput updateFlowOutputOFLib = rpcResultFromOFLib.getResult() ;
574 UpdateFlowOutputBuilder updateFlowOutput = new UpdateFlowOutputBuilder() ;
575 updateFlowOutput.setTransactionId(updateFlowOutputOFLib.getTransactionId()) ;
576 UpdateFlowOutput result = updateFlowOutput.build();
578 Collection<RpcError> errors = rpcResultFromOFLib.getErrors() ;
579 RpcResult<UpdateFlowOutput> rpcResult = Rpcs.getRpcResult(true, result, errors);
581 LOG.debug("Returning the Update Flow RPC result to MD-SAL");
582 return Futures.immediateFuture(rpcResult);
586 public Future<RpcResult<UpdateGroupOutput>> updateGroup(
587 UpdateGroupInput input) {
588 // Convert the UpdateGroupInput to GroupModInput
589 GroupModInput ofGroupModInput = GroupConvertor.toGroupModInput(input.getUpdatedGroup(), version);
592 // For Flow provisioning, the SwitchConnectionDistinguisher is set to null so
593 // the request can be routed through any connection to the switch
595 SwitchConnectionDistinguisher cookie = null ;
597 LOG.debug("Calling the GroupMod RPC method on MessageDispatchService");
598 Future<RpcResult<UpdateGroupOutput>> resultFromOFLib = messageService.groupMod(ofGroupModInput, cookie) ;
600 RpcResult<UpdateGroupOutput> rpcResultFromOFLib = null ;
603 rpcResultFromOFLib = resultFromOFLib.get();
604 } catch( Exception ex ) {
605 LOG.error( " Error while getting result for updateGroup RPC" + ex.getMessage());
608 UpdateGroupOutput updateGroupOutputOFLib = rpcResultFromOFLib.getResult() ;
610 UpdateGroupOutputBuilder updateGroupOutput = new UpdateGroupOutputBuilder() ;
611 updateGroupOutput.setTransactionId(updateGroupOutputOFLib.getTransactionId()) ;
612 UpdateGroupOutput result = updateGroupOutput.build();
614 Collection<RpcError> errors = rpcResultFromOFLib.getErrors() ;
615 RpcResult<UpdateGroupOutput> rpcResult = Rpcs.getRpcResult(true, result, errors);
617 LOG.debug("Returning the Update Group RPC result to MD-SAL");
618 return Futures.immediateFuture(rpcResult);
622 public Future<RpcResult<UpdateMeterOutput>> updateMeter(
623 UpdateMeterInput input) {
624 // Convert the UpdateMeterInput to MeterModInput
625 MeterModInput ofMeterModInput = MeterConvertor.toMeterModInput(input.getUpdatedMeter(), version);
628 // For Meter provisioning, the SwitchConnectionDistinguisher is set to null so
629 // the request can be routed through any connection to the switch
631 SwitchConnectionDistinguisher cookie = null ;
633 LOG.debug("Calling the MeterMod RPC method on MessageDispatchService");
634 Future<RpcResult<UpdateMeterOutput>> resultFromOFLib = messageService.meterMod(ofMeterModInput, cookie) ;
636 RpcResult<UpdateMeterOutput> rpcResultFromOFLib = null ;
639 rpcResultFromOFLib = resultFromOFLib.get();
640 } catch( Exception ex ) {
641 LOG.error( " Error while getting result for UpdateMeter RPC" + ex.getMessage());
644 UpdateMeterOutput updateMeterOutputFromOFLib = rpcResultFromOFLib.getResult() ;
646 UpdateMeterOutputBuilder updateMeterOutput = new UpdateMeterOutputBuilder() ;
647 updateMeterOutput.setTransactionId(updateMeterOutputFromOFLib.getTransactionId()) ;
648 UpdateMeterOutput result = updateMeterOutput.build();
650 Collection<RpcError> errors = rpcResultFromOFLib.getErrors() ;
651 RpcResult<UpdateMeterOutput> rpcResult = Rpcs.getRpcResult(true, result, errors);
653 LOG.debug("Returning the Update Meter RPC result to MD-SAL");
654 return Futures.immediateFuture(rpcResult);
658 public NodeId getNodeId() {
663 * Methods for requesting statistics from switch
666 public Future<RpcResult<GetAllGroupStatisticsOutput>> getAllGroupStatistics(GetAllGroupStatisticsInput input) {
668 //Generate xid to associate it with the request
669 Long xid = this.getSessionContext().getNextXid();
671 LOG.debug("Prepare statistics request for all the groups - Transaction id - {}",xid);
673 // Create multipart request header
674 MultipartRequestInputBuilder mprInput = new MultipartRequestInputBuilder();
675 mprInput.setType(MultipartType.OFPMPGROUP);
676 mprInput.setVersion(version);
677 mprInput.setXid(xid);
678 mprInput.setFlags(new MultipartRequestFlags(false));
680 // Create multipart request body for fetch all the group stats
681 MultipartRequestGroupCaseBuilder caseBuilder = new MultipartRequestGroupCaseBuilder();
682 MultipartRequestGroupBuilder mprGroupBuild = new MultipartRequestGroupBuilder();
683 mprGroupBuild.setGroupId(new GroupId(BinContent.intToUnsignedLong(Group.OFPGALL.getIntValue())));
684 caseBuilder.setMultipartRequestGroup(mprGroupBuild.build());
686 //Set request body to main multipart request
687 mprInput.setMultipartRequestBody(caseBuilder.build());
689 //Send the request, no cookies associated, use any connection
690 LOG.debug("Send group statistics request to the switch :{}",mprGroupBuild);
691 this.messageService.multipartRequest(mprInput.build(), null);
693 // Prepare rpc return output. Set xid and send it back.
694 LOG.debug("Return results and transaction id back to caller");
695 GetAllGroupStatisticsOutputBuilder output = new GetAllGroupStatisticsOutputBuilder();
696 output.setTransactionId(generateTransactionId(xid));
697 output.setGroupStats(null);
699 Collection<RpcError> errors = Collections.emptyList();
700 RpcResult<GetAllGroupStatisticsOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
701 return Futures.immediateFuture(rpcResult);
706 public Future<RpcResult<GetGroupDescriptionOutput>> getGroupDescription(GetGroupDescriptionInput input) {
708 //Generate xid to associate it with the request
709 Long xid = this.getSessionContext().getNextXid();
711 LOG.debug("Prepare group description statistics request - Transaction id - {}",xid);
713 // Create multipart request header
714 MultipartRequestInputBuilder mprInput = new MultipartRequestInputBuilder();
715 mprInput.setType(MultipartType.OFPMPGROUPDESC);
716 mprInput.setVersion(version);
717 mprInput.setXid(xid);
718 mprInput.setFlags(new MultipartRequestFlags(false));
720 // Create multipart request body for fetch all the group description stats
721 MultipartRequestGroupDescCaseBuilder mprGroupDescBuild = new MultipartRequestGroupDescCaseBuilder();
723 //Set request body to main multipart request
724 mprInput.setMultipartRequestBody(mprGroupDescBuild.build());
726 //Send the request, no cookies associated, use any connection
727 LOG.debug("Send group desciption statistics request to switch : {}",mprGroupDescBuild);
728 this.messageService.multipartRequest(mprInput.build(), null);
730 // Prepare rpc return output. Set xid and send it back.
731 LOG.debug("Return results and transaction id back to caller");
732 GetGroupDescriptionOutputBuilder output = new GetGroupDescriptionOutputBuilder();
733 output.setTransactionId(generateTransactionId(xid));
734 output.setGroupDescStats(null);
736 Collection<RpcError> errors = Collections.emptyList();
737 RpcResult<GetGroupDescriptionOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
738 return Futures.immediateFuture(rpcResult);
743 public Future<RpcResult<GetGroupFeaturesOutput>> getGroupFeatures(GetGroupFeaturesInput input) {
745 //Generate xid to associate it with the request
746 Long xid = this.getSessionContext().getNextXid();
748 LOG.debug("Prepare group features statistics request - Transaction id - {}",xid);
750 // Create multipart request header
751 MultipartRequestInputBuilder mprInput = new MultipartRequestInputBuilder();
752 mprInput.setType(MultipartType.OFPMPGROUPFEATURES);
753 mprInput.setVersion(version);
754 mprInput.setXid(xid);
755 mprInput.setFlags(new MultipartRequestFlags(false));
757 // Create multipart request body for fetch all the group description stats
758 MultipartRequestGroupFeaturesCaseBuilder mprGroupFeaturesBuild = new MultipartRequestGroupFeaturesCaseBuilder();
760 //Set request body to main multipart request
761 mprInput.setMultipartRequestBody(mprGroupFeaturesBuild.build());
763 //Send the request, no cookies associated, use any connection
764 LOG.debug("Send group features statistics request :{}",mprGroupFeaturesBuild);
765 this.messageService.multipartRequest(mprInput.build(), null);
767 // Prepare rpc return output. Set xid and send it back.
768 LOG.debug("Return results and transaction id back to caller");
769 GetGroupFeaturesOutputBuilder output = new GetGroupFeaturesOutputBuilder();
770 output.setTransactionId(generateTransactionId(xid));
772 Collection<RpcError> errors = Collections.emptyList();
773 RpcResult<GetGroupFeaturesOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
774 return Futures.immediateFuture(rpcResult);
778 public Future<RpcResult<GetGroupStatisticsOutput>> getGroupStatistics(GetGroupStatisticsInput input) {
780 //Generate xid to associate it with the request
781 Long xid = this.getSessionContext().getNextXid();
783 LOG.debug("Prepare statistics request for node {} group ({}) - Transaction id - {}",input.getNode(),input.getGroupId(),xid);
785 // Create multipart request header
786 MultipartRequestInputBuilder mprInput = new MultipartRequestInputBuilder();
787 mprInput.setType(MultipartType.OFPMPGROUP);
788 mprInput.setVersion(version);
789 mprInput.setXid(xid);
790 mprInput.setFlags(new MultipartRequestFlags(false));
792 // Create multipart request body for fetch all the group stats
793 MultipartRequestGroupCaseBuilder caseBuilder = new MultipartRequestGroupCaseBuilder();
794 MultipartRequestGroupBuilder mprGroupBuild = new MultipartRequestGroupBuilder();
795 mprGroupBuild.setGroupId(new GroupId(input.getGroupId().getValue()));
796 caseBuilder.setMultipartRequestGroup(mprGroupBuild.build());
798 //Set request body to main multipart request
799 mprInput.setMultipartRequestBody(caseBuilder.build());
801 //Send the request, no cookies associated, use any connection
802 LOG.debug("Send group statistics request :{}",mprGroupBuild);
803 this.messageService.multipartRequest(mprInput.build(), null);
805 // Prepare rpc return output. Set xid and send it back.
806 LOG.debug("Return results and transaction id back to caller");
807 GetGroupStatisticsOutputBuilder output = new GetGroupStatisticsOutputBuilder();
808 output.setTransactionId(generateTransactionId(xid));
809 output.setGroupStats(null);
811 Collection<RpcError> errors = Collections.emptyList();
812 RpcResult<GetGroupStatisticsOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
813 return Futures.immediateFuture(rpcResult);
817 public Future<RpcResult<GetAllMeterConfigStatisticsOutput>> getAllMeterConfigStatistics(
818 GetAllMeterConfigStatisticsInput input) {
820 //Generate xid to associate it with the request
821 Long xid = this.getSessionContext().getNextXid();
823 LOG.debug("Prepare config request for all the meters - Transaction id - {}",xid);
825 // Create multipart request header
826 MultipartRequestInputBuilder mprInput = new MultipartRequestInputBuilder();
827 mprInput.setType(MultipartType.OFPMPMETERCONFIG);
828 mprInput.setVersion(version);
829 mprInput.setXid(xid);
830 mprInput.setFlags(new MultipartRequestFlags(false));
832 // Create multipart request body for fetch all the meter stats
833 MultipartRequestMeterConfigCaseBuilder caseBuilder = new MultipartRequestMeterConfigCaseBuilder();
834 MultipartRequestMeterConfigBuilder mprMeterConfigBuild = new MultipartRequestMeterConfigBuilder();
835 mprMeterConfigBuild.setMeterId(new MeterId(BinContent.intToUnsignedLong(Meter.OFPMALL.getIntValue())));
836 caseBuilder.setMultipartRequestMeterConfig(mprMeterConfigBuild.build());
838 //Set request body to main multipart request
839 mprInput.setMultipartRequestBody(caseBuilder.build());
841 //Send the request, no cookies associated, use any connection
842 LOG.debug("Send meter statistics request :{}",mprMeterConfigBuild);
843 this.messageService.multipartRequest(mprInput.build(), null);
845 // Prepare rpc return output. Set xid and send it back.
846 LOG.debug("Return results and transaction id back to caller");
847 GetAllMeterConfigStatisticsOutputBuilder output = new GetAllMeterConfigStatisticsOutputBuilder();
848 output.setTransactionId(generateTransactionId(xid));
849 output.setMeterConfigStats(null);
851 Collection<RpcError> errors = Collections.emptyList();
852 RpcResult<GetAllMeterConfigStatisticsOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
853 return Futures.immediateFuture(rpcResult);
857 public Future<RpcResult<GetAllMeterStatisticsOutput>> getAllMeterStatistics(GetAllMeterStatisticsInput input) {
859 //Generate xid to associate it with the request
860 Long xid = this.getSessionContext().getNextXid();
862 LOG.debug("Prepare statistics request for all the meters - Transaction id - {}",xid);
864 // Create multipart request header
865 MultipartRequestInputBuilder mprInput = new MultipartRequestInputBuilder();
866 mprInput.setType(MultipartType.OFPMPMETER);
867 mprInput.setVersion(version);
868 mprInput.setXid(xid);
869 mprInput.setFlags(new MultipartRequestFlags(false));
871 // Create multipart request body for fetch all the meter stats
872 MultipartRequestMeterCaseBuilder caseBuilder = new MultipartRequestMeterCaseBuilder();
873 MultipartRequestMeterBuilder mprMeterBuild = new MultipartRequestMeterBuilder();
874 mprMeterBuild.setMeterId(new MeterId(BinContent.intToUnsignedLong(Meter.OFPMALL.getIntValue())));
875 caseBuilder.setMultipartRequestMeter(mprMeterBuild.build());
877 //Set request body to main multipart request
878 mprInput.setMultipartRequestBody(caseBuilder.build());
880 //Send the request, no cookies associated, use any connection
881 LOG.debug("Send meter statistics request :{}",mprMeterBuild);
882 this.messageService.multipartRequest(mprInput.build(), null);
884 // Prepare rpc return output. Set xid and send it back.
885 LOG.debug("Return results and transaction id back to caller");
886 GetAllMeterStatisticsOutputBuilder output = new GetAllMeterStatisticsOutputBuilder();
887 output.setTransactionId(generateTransactionId(xid));
888 output.setMeterStats(null);
890 Collection<RpcError> errors = Collections.emptyList();
891 RpcResult<GetAllMeterStatisticsOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
892 return Futures.immediateFuture(rpcResult);
896 public Future<RpcResult<GetMeterFeaturesOutput>> getMeterFeatures(GetMeterFeaturesInput input) {
898 //Generate xid to associate it with the request
899 Long xid = this.getSessionContext().getNextXid();
901 LOG.debug("Prepare features statistics request for all the meters - Transaction id - {}",xid);
903 // Create multipart request header
904 MultipartRequestInputBuilder mprInput = new MultipartRequestInputBuilder();
905 mprInput.setType(MultipartType.OFPMPMETERFEATURES);
906 mprInput.setVersion(version);
907 mprInput.setXid(xid);
908 mprInput.setFlags(new MultipartRequestFlags(false));
910 // Create multipart request body for fetch all the group description stats
911 MultipartRequestMeterFeaturesCaseBuilder mprMeterFeaturesBuild = new MultipartRequestMeterFeaturesCaseBuilder();
913 //Set request body to main multipart request
914 mprInput.setMultipartRequestBody(mprMeterFeaturesBuild.build());
916 //Send the request, no cookies associated, use any connection
917 LOG.debug("Send meter features statistics request :{}",mprMeterFeaturesBuild);
918 this.messageService.multipartRequest(mprInput.build(), null);
920 // Prepare rpc return output. Set xid and send it back.
921 LOG.debug("Return results and transaction id back to caller");
922 GetMeterFeaturesOutputBuilder output = new GetMeterFeaturesOutputBuilder();
923 output.setTransactionId(generateTransactionId(xid));
925 Collection<RpcError> errors = Collections.emptyList();
926 RpcResult<GetMeterFeaturesOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
927 return Futures.immediateFuture(rpcResult);
931 public Future<RpcResult<GetMeterStatisticsOutput>> getMeterStatistics(GetMeterStatisticsInput input) {
932 //Generate xid to associate it with the request
933 Long xid = this.getSessionContext().getNextXid();
935 LOG.debug("Preprae statistics request for Meter ({}) - Transaction id - {}",input.getMeterId().getValue(),xid);
937 // Create multipart request header
938 MultipartRequestInputBuilder mprInput = new MultipartRequestInputBuilder();
939 mprInput.setType(MultipartType.OFPMPMETER);
940 mprInput.setVersion(version);
941 mprInput.setXid(xid);
942 mprInput.setFlags(new MultipartRequestFlags(false));
944 // Create multipart request body for fetch all the meter stats
945 MultipartRequestMeterCaseBuilder caseBuilder = new MultipartRequestMeterCaseBuilder();
946 MultipartRequestMeterBuilder mprMeterBuild = new MultipartRequestMeterBuilder();
947 //Select specific meter
948 mprMeterBuild.setMeterId(new MeterId(input.getMeterId().getValue()));
949 caseBuilder.setMultipartRequestMeter(mprMeterBuild.build());
951 //Set request body to main multipart request
952 mprInput.setMultipartRequestBody(caseBuilder.build());
954 //Send the request, no cookies associated, use any connection
955 LOG.debug("Send meter statistics request :{}",mprMeterBuild);
956 this.messageService.multipartRequest(mprInput.build(), null);
958 // Prepare rpc return output. Set xid and send it back.
959 LOG.debug("Return results and transaction id back to caller");
960 GetMeterStatisticsOutputBuilder output = new GetMeterStatisticsOutputBuilder();
961 output.setTransactionId(generateTransactionId(xid));
962 output.setMeterStats(null);
964 Collection<RpcError> errors = Collections.emptyList();
965 RpcResult<GetMeterStatisticsOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
966 return Futures.immediateFuture(rpcResult);
970 public Future<RpcResult<GetAllPortsStatisticsOutput>> getAllPortsStatistics(GetAllPortsStatisticsInput arg0) {
972 //Generate xid to associate it with the request
973 Long xid = this.getSessionContext().getNextXid();
975 LOG.info("Prepare port statistics request for all ports of node {} - TrasactionId - {}",arg0.getNode().getValue(),xid);
977 // Create multipart request header
978 MultipartRequestInputBuilder mprInput = new MultipartRequestInputBuilder();
979 mprInput.setType(MultipartType.OFPMPPORTSTATS);
980 mprInput.setVersion(version);
981 mprInput.setXid(xid);
982 mprInput.setFlags(new MultipartRequestFlags(false));
984 // Create multipart request body to fetch stats for all the port of the node
985 MultipartRequestPortStatsCaseBuilder caseBuilder = new MultipartRequestPortStatsCaseBuilder();
986 MultipartRequestPortStatsBuilder mprPortStatsBuilder = new MultipartRequestPortStatsBuilder();
988 mprPortStatsBuilder.setPortNo(OFConstants.OFPP_ANY);
989 caseBuilder.setMultipartRequestPortStats(mprPortStatsBuilder.build());
991 //Set request body to main multipart request
992 mprInput.setMultipartRequestBody(caseBuilder.build());
994 //Send the request, no cookies associated, use any connection
995 LOG.debug("Send port statistics request :{}",mprPortStatsBuilder.build().toString());
996 this.messageService.multipartRequest(mprInput.build(), null);
998 // Prepare rpc return output. Set xid and send it back.
999 GetAllPortsStatisticsOutputBuilder output = new GetAllPortsStatisticsOutputBuilder();
1000 output.setTransactionId(generateTransactionId(xid));
1002 Collection<RpcError> errors = Collections.emptyList();
1003 RpcResult<GetAllPortsStatisticsOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
1004 return Futures.immediateFuture(rpcResult);
1008 public Future<RpcResult<GetPortStatisticsOutput>> getPortStatistics(GetPortStatisticsInput arg0) {
1009 //Generate xid to associate it with the request
1010 Long xid = this.getSessionContext().getNextXid();
1012 LOG.info("Prepare port statistics request for port {} of node {} - TrasactionId - {}",arg0.getNodeConnectorId(), arg0.getNode().getValue(),xid);
1014 // Create multipart request header
1015 MultipartRequestInputBuilder mprInput = new MultipartRequestInputBuilder();
1016 mprInput.setType(MultipartType.OFPMPPORTSTATS);
1017 mprInput.setVersion(version);
1018 mprInput.setXid(xid);
1019 mprInput.setFlags(new MultipartRequestFlags(false));
1021 // Create multipart request body to fetch stats for all the port of the node
1022 MultipartRequestPortStatsCaseBuilder caseBuilder = new MultipartRequestPortStatsCaseBuilder();
1023 MultipartRequestPortStatsBuilder mprPortStatsBuilder = new MultipartRequestPortStatsBuilder();
1026 mprPortStatsBuilder.setPortNo(InventoryDataServiceUtil.portNumberfromNodeConnectorId(arg0.getNodeConnectorId()));
1027 caseBuilder.setMultipartRequestPortStats(mprPortStatsBuilder.build());
1029 //Set request body to main multipart request
1030 mprInput.setMultipartRequestBody(caseBuilder.build());
1032 //Send the request, no cookies associated, use any connection
1033 LOG.debug("Send port statistics request :{}",mprPortStatsBuilder.build().toString());
1034 this.messageService.multipartRequest(mprInput.build(), null);
1036 // Prepare rpc return output. Set xid and send it back.
1037 GetPortStatisticsOutputBuilder output = new GetPortStatisticsOutputBuilder();
1038 output.setTransactionId(generateTransactionId(xid));
1040 Collection<RpcError> errors = Collections.emptyList();
1041 RpcResult<GetPortStatisticsOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
1042 return Futures.immediateFuture(rpcResult);
1045 private TransactionId generateTransactionId(Long xid){
1046 String stringXid =xid.toString();
1047 BigInteger bigIntXid = new BigInteger( stringXid );
1048 return new TransactionId(bigIntXid);
1053 public Future<RpcResult<GetPortOutput>> getPort() {
1054 // TODO Auto-generated method stub
1060 public Future<RpcResult<UpdatePortOutput>> updatePort(UpdatePortInput input) {
1061 PortModInput ofPortModInput = null ;
1062 RpcResult<UpdatePortOutput> rpcResultFromOFLib = null ;
1065 // For Flow provisioning, the SwitchConnectionDistinguisher is set to null so
1066 // the request can be routed through any connection to the switch
1068 SwitchConnectionDistinguisher cookie = null ;
1070 // NSF sends a list of port and the ModelDrivenSwitch will
1071 // send one port at a time towards the switch ( mutiple RPCs calls)
1072 List<Port> inputPorts = input.getUpdatedPort().getPort().getPort() ;
1074 // Get the Xid. The same Xid has to be sent in all the RPCs
1075 Long Xid = sessionContext.getNextXid();
1077 for( Port inputPort : inputPorts) {
1079 // Convert the UpdateGroupInput to GroupModInput
1080 ofPortModInput = PortConvertor.toPortModInput(inputPort, version) ;
1082 // Insert the Xid ( transaction Id) before calling the RPC on the OFLibrary
1084 PortModInputBuilder mdInput = new PortModInputBuilder();
1085 mdInput.setXid(Xid);
1086 mdInput.setVersion(ofPortModInput.getVersion()) ;
1087 mdInput.setPortNo(ofPortModInput.getPortNo()) ;
1088 mdInput.setMaskV10(ofPortModInput.getMaskV10()) ;
1089 mdInput.setMask(ofPortModInput.getMask()) ;
1090 mdInput.setHwAddress(ofPortModInput.getHwAddress());
1091 mdInput.setConfigV10(ofPortModInput.getConfigV10()) ;
1092 mdInput.setConfig(ofPortModInput.getConfig()) ;
1093 mdInput.setAdvertiseV10(ofPortModInput.getAdvertiseV10()) ;
1094 mdInput.setAdvertise(ofPortModInput.getAdvertise()) ;
1096 LOG.debug("Calling the PortMod RPC method on MessageDispatchService");
1097 Future<RpcResult<UpdatePortOutput>> resultFromOFLib = messageService.portMod(ofPortModInput, cookie) ;
1100 rpcResultFromOFLib = resultFromOFLib.get();
1101 } catch( Exception ex ) {
1102 LOG.error( " Error while getting result for updatePort RPC" + ex.getMessage());
1105 // The Future response value for all the RPCs except the last one is ignored
1108 //Extract the Xid only from the Future for the last RPC and
1109 // send it back to the NSF
1110 UpdatePortOutput updatePortOutputOFLib = rpcResultFromOFLib.getResult() ;
1112 UpdatePortOutputBuilder updatePortOutput = new UpdatePortOutputBuilder() ;
1113 updatePortOutput.setTransactionId(updatePortOutputOFLib.getTransactionId()) ;
1114 UpdatePortOutput result = updatePortOutput.build();
1116 Collection<RpcError> errors = rpcResultFromOFLib.getErrors() ;
1117 RpcResult<UpdatePortOutput> rpcResult = Rpcs.getRpcResult(true, result, errors);
1119 LOG.debug("Returning the Update Group RPC result to MD-SAL");
1120 return Futures.immediateFuture(rpcResult);
1125 public Future<RpcResult<UpdateTableOutput>> updateTable(
1126 UpdateTableInput input) {
1128 // Get the Xid. The same Xid has to be sent in all the Multipart requests
1129 Long xid = this.getSessionContext().getNextXid();
1131 LOG.debug("Prepare the Multipart Table Mod requests for Transaction Id {} ",xid);
1133 // Create multipart request header
1134 MultipartRequestInputBuilder mprInput = new MultipartRequestInputBuilder();
1135 mprInput.setType(MultipartType.OFPMPTABLEFEATURES);
1136 mprInput.setVersion((short)0x04);
1137 mprInput.setXid(xid);
1139 //Convert the list of all MD-SAL table feature object into OF library object
1140 List<TableFeatures> ofTableFeatureList = TableFeaturesConvertor.toTableFeaturesRequest(input.getUpdatedTable()) ;
1143 MultipartRequestTableFeaturesCaseBuilder caseRequest = new MultipartRequestTableFeaturesCaseBuilder();
1144 MultipartRequestTableFeaturesBuilder tableFeaturesRequest = new MultipartRequestTableFeaturesBuilder();
1146 mprInput.setFlags(new MultipartRequestFlags(true));
1148 tableFeaturesRequest.setTableFeatures(ofTableFeatureList) ;
1150 //Set request body to main multipart request
1151 caseRequest.setMultipartRequestTableFeatures(tableFeaturesRequest.build());
1152 mprInput.setMultipartRequestBody(caseRequest.build());
1154 //Send the request, no cookies associated, use any connection
1155 LOG.debug("Send Table Feature request :{}",ofTableFeatureList);
1156 this.messageService.multipartRequest(mprInput.build(), null);
1159 //Extract the Xid only from the Future for the last RPC and
1160 // send it back to the NSF
1161 LOG.debug("Returning the result and transaction id to NSF");
1162 LOG.debug("Return results and transaction id back to caller");
1163 UpdateTableOutputBuilder output = new UpdateTableOutputBuilder();
1164 output.setTransactionId(generateTransactionId(xid));
1166 Collection<RpcError> errors = Collections.emptyList();
1167 RpcResult<UpdateTableOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
1168 return Futures.immediateFuture(rpcResult);
1172 public Future<RpcResult<GetAllFlowStatisticsFromFlowTableOutput>> getAllFlowStatisticsFromFlowTable(
1173 GetAllFlowStatisticsFromFlowTableInput arg0) {
1175 //Generate xid to associate it with the request
1176 Long xid = this.getSessionContext().getNextXid();
1178 LOG.debug("Prepare statistics request to get flow stats for switch tables {} - Transaction id - {}"
1179 ,arg0.getTableId().getValue(),xid);
1181 // Create multipart request header
1182 MultipartRequestInputBuilder mprInput = new MultipartRequestInputBuilder();
1183 mprInput.setType(MultipartType.OFPMPFLOW);
1184 mprInput.setVersion(version);
1185 mprInput.setXid(xid);
1186 mprInput.setFlags(new MultipartRequestFlags(false));
1188 // Create multipart request body for fetch all the group stats
1189 MultipartRequestFlowCaseBuilder multipartRequestFlowCaseBuilder = new MultipartRequestFlowCaseBuilder ();
1190 MultipartRequestFlowBuilder mprFlowRequestBuilder = new MultipartRequestFlowBuilder();
1191 mprFlowRequestBuilder.setTableId(arg0.getTableId().getValue());
1192 mprFlowRequestBuilder.setOutPort(OFConstants.OFPP_ANY);
1193 mprFlowRequestBuilder.setOutGroup(OFConstants.OFPG_ANY);
1194 mprFlowRequestBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
1195 mprFlowRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
1197 if(version == OFConstants.OFP_VERSION_1_0){
1198 LOG.info("Target node is running openflow version 1.0");
1199 FlowWildcardsV10 wildCard = new FlowWildcardsV10(true,true,true,true,true,true,true,true,true,true);
1200 mprFlowRequestBuilder.setMatchV10(new MatchV10Builder().setWildcards(wildCard).build());
1202 if(version == OFConstants.OFP_VERSION_1_3){
1203 LOG.info("Target node is running openflow version 1.3+");
1204 mprFlowRequestBuilder.setMatch(new MatchBuilder().setType(OxmMatchType.class).build());
1208 //Set request body to main multipart request
1209 multipartRequestFlowCaseBuilder.setMultipartRequestFlow(mprFlowRequestBuilder.build());
1210 mprInput.setMultipartRequestBody(multipartRequestFlowCaseBuilder.build());
1212 //Send the request, no cookies associated, use any connection
1213 LOG.debug("Send flow statistics request to the switch :{}",mprFlowRequestBuilder);
1214 this.messageService.multipartRequest(mprInput.build(), null);
1216 // Prepare rpc return output. Set xid and send it back.
1217 LOG.debug("Return results and transaction id back to caller");
1218 GetAllFlowStatisticsFromFlowTableOutputBuilder output =
1219 new GetAllFlowStatisticsFromFlowTableOutputBuilder();
1220 output.setTransactionId(generateTransactionId(xid));
1221 output.setFlowAndStatisticsMapList(null);
1223 Collection<RpcError> errors = Collections.emptyList();
1224 RpcResult<GetAllFlowStatisticsFromFlowTableOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
1225 return Futures.immediateFuture(rpcResult);
1229 public Future<RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput>> getAllFlowsStatisticsFromAllFlowTables(
1230 GetAllFlowsStatisticsFromAllFlowTablesInput arg0) {
1232 //Generate xid to associate it with the request
1233 Long xid = this.getSessionContext().getNextXid();
1235 LOG.info("Prepare statistics request to get flow stats of all switch tables - Transaction id - {}",xid);
1237 // Create multipart request header
1238 MultipartRequestInputBuilder mprInput = new MultipartRequestInputBuilder();
1239 mprInput.setType(MultipartType.OFPMPFLOW);
1240 mprInput.setVersion(version);
1241 mprInput.setXid(xid);
1242 mprInput.setFlags(new MultipartRequestFlags(false));
1244 // Create multipart request body for fetch all the group stats
1245 MultipartRequestFlowCaseBuilder multipartRequestFlowCaseBuilder = new MultipartRequestFlowCaseBuilder();
1246 MultipartRequestFlowBuilder mprFlowRequestBuilder = new MultipartRequestFlowBuilder();
1247 mprFlowRequestBuilder.setTableId(OFConstants.OFPTT_ALL);
1248 mprFlowRequestBuilder.setOutPort(OFConstants.OFPP_ANY);
1249 mprFlowRequestBuilder.setOutGroup(OFConstants.OFPG_ANY);
1250 mprFlowRequestBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
1251 mprFlowRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
1252 mprFlowRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
1254 //TODO: repeating code
1255 if(version == OFConstants.OFP_VERSION_1_0){
1256 FlowWildcardsV10 wildCard = new FlowWildcardsV10(true,true,true,true,true,true,true,true,true,true);
1257 mprFlowRequestBuilder.setMatchV10(new MatchV10Builder().setWildcards(wildCard).build());
1259 if(version == OFConstants.OFP_VERSION_1_3){
1260 mprFlowRequestBuilder.setMatch(new MatchBuilder().setType(OxmMatchType.class).build());
1262 //Set request body to main multipart request
1263 multipartRequestFlowCaseBuilder.setMultipartRequestFlow(mprFlowRequestBuilder.build());
1264 mprInput.setMultipartRequestBody(multipartRequestFlowCaseBuilder.build());
1266 //Send the request, no cookies associated, use any connection
1267 LOG.debug("Send flow statistics request to the switch :{}",mprFlowRequestBuilder);
1268 this.messageService.multipartRequest(mprInput.build(), null);
1270 // Prepare rpc return output. Set xid and send it back.
1271 GetAllFlowsStatisticsFromAllFlowTablesOutputBuilder output =
1272 new GetAllFlowsStatisticsFromAllFlowTablesOutputBuilder();
1273 output.setTransactionId(generateTransactionId(xid));
1274 output.setFlowAndStatisticsMapList(null);
1276 Collection<RpcError> errors = Collections.emptyList();
1277 RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
1278 return Futures.immediateFuture(rpcResult);
1283 public Future<RpcResult<GetFlowStatisticsFromFlowTableOutput>> getFlowStatisticsFromFlowTable(
1284 GetFlowStatisticsFromFlowTableInput arg0) {
1285 //Generate xid to associate it with the request
1286 Long xid = this.getSessionContext().getNextXid();
1288 LOG.info("Prepare statistics request to get stats for flow {} for switch tables {} - Transaction id - {}"
1289 ,arg0.getMatch().toString(),arg0.getTableId(),xid);
1291 // Create multipart request header
1292 MultipartRequestInputBuilder mprInput = new MultipartRequestInputBuilder();
1293 mprInput.setType(MultipartType.OFPMPFLOW);
1294 mprInput.setVersion(version);
1295 mprInput.setXid(xid);
1296 mprInput.setFlags(new MultipartRequestFlags(false));
1298 // Create multipart request body for fetch all the group stats
1299 MultipartRequestFlowCaseBuilder multipartRequestFlowCaseBuilder = new MultipartRequestFlowCaseBuilder();
1300 MultipartRequestFlowBuilder mprFlowRequestBuilder = new MultipartRequestFlowBuilder();
1301 mprFlowRequestBuilder.setTableId(arg0.getTableId());
1302 mprFlowRequestBuilder.setOutPort(arg0.getOutPort().longValue());
1303 mprFlowRequestBuilder.setOutGroup(OFConstants.OFPG_ANY);
1304 mprFlowRequestBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
1305 mprFlowRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
1307 // convert and inject match
1308 MatchReactor.getInstance().convert(arg0.getMatch(), version, mprFlowRequestBuilder);
1309 //TODO: repeating code
1310 if(version == OFConstants.OFP_VERSION_1_3){
1311 mprFlowRequestBuilder.setCookie(arg0.getCookie());
1312 mprFlowRequestBuilder.setCookieMask(arg0.getCookieMask());
1313 mprFlowRequestBuilder.setOutGroup(arg0.getOutGroup());
1316 //Set request body to main multipart request
1317 multipartRequestFlowCaseBuilder.setMultipartRequestFlow(mprFlowRequestBuilder.build());
1318 mprInput.setMultipartRequestBody(multipartRequestFlowCaseBuilder.build());
1320 //Send the request, no cookies associated, use any connection
1321 LOG.debug("Send flow statistics request to the switch :{}",mprFlowRequestBuilder);
1322 this.messageService.multipartRequest(mprInput.build(), null);
1324 // Prepare rpc return output. Set xid and send it back.
1325 GetFlowStatisticsFromFlowTableOutputBuilder output =
1326 new GetFlowStatisticsFromFlowTableOutputBuilder();
1327 output.setTransactionId(generateTransactionId(xid));
1328 output.setFlowAndStatisticsMapList(null);
1330 Collection<RpcError> errors = Collections.emptyList();
1331 RpcResult<GetFlowStatisticsFromFlowTableOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
1332 return Futures.immediateFuture(rpcResult);
1336 public Future<RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>> getAggregateFlowStatisticsFromFlowTableForAllFlows(
1337 GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput arg0) {
1338 //Generate xid to associate it with the request
1339 Long xid = this.getSessionContext().getNextXid();
1341 LOG.info("Prepare aggregate flow statistics request to get aggregate flow stats for all the flow installed on switch table {} - Transaction id - {}"
1342 ,arg0.getTableId().getValue(),xid);
1344 // Create multipart request header
1345 MultipartRequestInputBuilder mprInput = new MultipartRequestInputBuilder();
1346 mprInput.setType(MultipartType.OFPMPAGGREGATE);
1347 mprInput.setVersion(version);
1348 mprInput.setXid(xid);
1349 mprInput.setFlags(new MultipartRequestFlags(false));
1351 // Create multipart request body for fetch all the group stats
1352 MultipartRequestAggregateCaseBuilder multipartRequestAggregateCaseBuilder = new MultipartRequestAggregateCaseBuilder ();
1353 MultipartRequestAggregateBuilder mprAggregateRequestBuilder = new MultipartRequestAggregateBuilder();
1354 mprAggregateRequestBuilder.setTableId(arg0.getTableId().getValue());
1355 mprAggregateRequestBuilder.setOutPort(OFConstants.OFPP_ANY);
1356 mprAggregateRequestBuilder.setOutGroup(OFConstants.OFPG_ANY);
1357 mprAggregateRequestBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
1358 mprAggregateRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
1360 //TODO: repeating code
1361 if(version == OFConstants.OFP_VERSION_1_0){
1362 FlowWildcardsV10 wildCard = new FlowWildcardsV10(true,true,true,true,true,true,true,true,true,true);
1363 mprAggregateRequestBuilder.setMatchV10(new MatchV10Builder().setWildcards(wildCard).build());
1365 if(version == OFConstants.OFP_VERSION_1_3){
1366 mprAggregateRequestBuilder.setMatch(new MatchBuilder().setType(OxmMatchType.class).build());
1370 //Set request body to main multipart request
1371 multipartRequestAggregateCaseBuilder.setMultipartRequestAggregate(mprAggregateRequestBuilder.build());
1372 mprInput.setMultipartRequestBody(multipartRequestAggregateCaseBuilder.build());
1374 //Send the request, no cookies associated, use any connection
1375 LOG.debug("Send request to the switch :{}",multipartRequestAggregateCaseBuilder.build().toString());
1376 this.messageService.multipartRequest(mprInput.build(), null);
1378 // Prepare rpc return output. Set xid and send it back.
1379 GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutputBuilder output =
1380 new GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutputBuilder();
1381 output.setTransactionId(generateTransactionId(xid));
1383 Collection<RpcError> errors = Collections.emptyList();
1384 RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
1385 return Futures.immediateFuture(rpcResult);
1389 public Future<RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>> getAggregateFlowStatisticsFromFlowTableForGivenMatch(
1390 GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput arg0) {
1392 //Generate xid to associate it with the request
1393 Long xid = this.getSessionContext().getNextXid();
1395 LOG.debug("Prepare agregate statistics request to get aggregate stats for flows matching {} and installed in flow tables {} - Transaction id - {}"
1396 ,arg0.getMatch().toString(),arg0.getTableId(),xid);
1398 // Create multipart request header
1399 MultipartRequestInputBuilder mprInput = new MultipartRequestInputBuilder();
1400 mprInput.setType(MultipartType.OFPMPAGGREGATE);
1401 mprInput.setVersion(version);
1402 mprInput.setXid(xid);
1403 mprInput.setFlags(new MultipartRequestFlags(false));
1405 // Create multipart request body for fetch all the group stats
1406 MultipartRequestAggregateCaseBuilder multipartRequestAggregateCaseBuilder = new MultipartRequestAggregateCaseBuilder ();
1407 MultipartRequestAggregateBuilder mprAggregateRequestBuilder = new MultipartRequestAggregateBuilder();
1408 mprAggregateRequestBuilder.setTableId(arg0.getTableId());
1409 mprAggregateRequestBuilder.setOutPort(arg0.getOutPort().longValue());
1410 mprAggregateRequestBuilder.setOutGroup(OFConstants.OFPG_ANY);
1411 mprAggregateRequestBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
1412 mprAggregateRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
1415 MatchReactor.getInstance().convert(arg0.getMatch(), version, mprAggregateRequestBuilder);
1416 //TODO: repeating code
1417 if(version == OFConstants.OFP_VERSION_1_3){
1418 mprAggregateRequestBuilder.setCookie(arg0.getCookie());
1419 mprAggregateRequestBuilder.setCookieMask(arg0.getCookieMask());
1420 mprAggregateRequestBuilder.setOutGroup(arg0.getOutGroup());
1423 //Set request body to main multipart request
1424 multipartRequestAggregateCaseBuilder.setMultipartRequestAggregate(mprAggregateRequestBuilder.build());
1425 mprInput.setMultipartRequestBody(multipartRequestAggregateCaseBuilder.build());
1427 //Send the request, no cookies associated, use any connection
1428 LOG.debug("Send request to the switch :{}",multipartRequestAggregateCaseBuilder.build().toString());
1429 this.messageService.multipartRequest(mprInput.build(), null);
1431 // Prepare rpc return output. Set xid and send it back.
1432 GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder output =
1433 new GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder();
1434 output.setTransactionId(generateTransactionId(xid));
1436 Collection<RpcError> errors = Collections.emptyList();
1437 RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
1438 return Futures.immediateFuture(rpcResult);
1442 public Future<RpcResult<GetFlowTablesStatisticsOutput>> getFlowTablesStatistics(GetFlowTablesStatisticsInput arg0) {
1443 //Generate xid to associate it with the request
1444 Long xid = this.getSessionContext().getNextXid();
1446 LOG.info("Prepare flow table statistics request to get flow table stats for all tables " +
1447 "from node {}- Transaction id - {}",arg0.getNode(),xid);
1449 // Create multipart request header
1450 MultipartRequestInputBuilder mprInput = new MultipartRequestInputBuilder();
1451 mprInput.setType(MultipartType.OFPMPTABLE);
1452 mprInput.setVersion(version);
1453 mprInput.setXid(xid);
1454 mprInput.setFlags(new MultipartRequestFlags(false));
1456 // Create multipart request body for fetch all the group stats
1457 MultipartRequestTableCaseBuilder multipartRequestTableCaseBuilder = new MultipartRequestTableCaseBuilder ();
1458 MultipartRequestTableBuilder multipartRequestTableBuilder = new MultipartRequestTableBuilder();
1459 multipartRequestTableBuilder.setEmpty(true);
1460 multipartRequestTableCaseBuilder.setMultipartRequestTable(multipartRequestTableBuilder.build());
1462 //Set request body to main multipart request
1463 mprInput.setMultipartRequestBody(multipartRequestTableCaseBuilder.build());
1465 //Send the request, no cookies associated, use any connection
1466 LOG.debug("Send request to the switch :{}",multipartRequestTableCaseBuilder.build().toString());
1467 this.messageService.multipartRequest(mprInput.build(), null);
1469 // Prepare rpc return output. Set xid and send it back.
1470 GetFlowTablesStatisticsOutputBuilder output = new GetFlowTablesStatisticsOutputBuilder();
1471 output.setTransactionId(generateTransactionId(xid));
1473 Collection<RpcError> errors = Collections.emptyList();
1474 RpcResult<GetFlowTablesStatisticsOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
1475 return Futures.immediateFuture(rpcResult);
1479 public Future<RpcResult<GetAllQueuesStatisticsFromAllPortsOutput>> getAllQueuesStatisticsFromAllPorts(
1480 GetAllQueuesStatisticsFromAllPortsInput arg0) {
1481 //Generate xid to associate it with the request
1482 Long xid = this.getSessionContext().getNextXid();
1484 LOG.info("Prepare queue statistics request to collect stats for all queues attached to all the ports of node {} - TrasactionId - {}",arg0.getNode().getValue(),xid);
1486 // Create multipart request header
1487 MultipartRequestInputBuilder mprInput = new MultipartRequestInputBuilder();
1488 mprInput.setType(MultipartType.OFPMPQUEUE);
1489 mprInput.setVersion(version);
1490 mprInput.setXid(xid);
1491 mprInput.setFlags(new MultipartRequestFlags(false));
1493 // Create multipart request body to fetch stats for all the port of the node
1494 MultipartRequestQueueCaseBuilder caseBuilder = new MultipartRequestQueueCaseBuilder();
1495 MultipartRequestQueueBuilder mprQueueBuilder = new MultipartRequestQueueBuilder();
1497 mprQueueBuilder.setPortNo(OFConstants.OFPP_ANY);
1498 //Select all the ports
1499 mprQueueBuilder.setQueueId(OFConstants.OFPQ_ANY);
1501 caseBuilder.setMultipartRequestQueue(mprQueueBuilder.build());
1503 //Set request body to main multipart request
1504 mprInput.setMultipartRequestBody(caseBuilder.build());
1506 //Send the request, no cookies associated, use any connection
1507 LOG.debug("Send queue statistics request :{}",mprQueueBuilder.build().toString());
1508 this.messageService.multipartRequest(mprInput.build(), null);
1510 // Prepare rpc return output. Set xid and send it back.
1511 GetAllQueuesStatisticsFromAllPortsOutputBuilder output = new GetAllQueuesStatisticsFromAllPortsOutputBuilder();
1512 output.setTransactionId(generateTransactionId(xid));
1513 output.setQueueIdAndStatisticsMap(null);
1515 Collection<RpcError> errors = Collections.emptyList();
1516 RpcResult<GetAllQueuesStatisticsFromAllPortsOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
1517 return Futures.immediateFuture(rpcResult);
1521 public Future<RpcResult<GetAllQueuesStatisticsFromGivenPortOutput>> getAllQueuesStatisticsFromGivenPort(
1522 GetAllQueuesStatisticsFromGivenPortInput arg0) {
1523 //Generate xid to associate it with the request
1524 Long xid = this.getSessionContext().getNextXid();
1526 LOG.info("Prepare queue statistics request to collect stats for " +
1527 "all queues attached to given port {} of node {} - TrasactionId - {}",arg0.getNodeConnectorId().toString(),arg0.getNode().getValue(),xid);
1529 // Create multipart request header
1530 MultipartRequestInputBuilder mprInput = new MultipartRequestInputBuilder();
1531 mprInput.setType(MultipartType.OFPMPQUEUE);
1532 mprInput.setVersion(version);
1533 mprInput.setXid(xid);
1534 mprInput.setFlags(new MultipartRequestFlags(false));
1536 // Create multipart request body to fetch stats for all the port of the node
1537 MultipartRequestQueueCaseBuilder caseBuilder = new MultipartRequestQueueCaseBuilder();
1538 MultipartRequestQueueBuilder mprQueueBuilder = new MultipartRequestQueueBuilder();
1540 mprQueueBuilder.setQueueId(OFConstants.OFPQ_ANY);
1541 //Select specific port
1542 mprQueueBuilder.setPortNo(InventoryDataServiceUtil.portNumberfromNodeConnectorId(arg0.getNodeConnectorId()));
1544 caseBuilder.setMultipartRequestQueue(mprQueueBuilder.build());
1546 //Set request body to main multipart request
1547 mprInput.setMultipartRequestBody(caseBuilder.build());
1549 //Send the request, no cookies associated, use any connection
1550 LOG.debug("Send queue statistics request :{}",mprQueueBuilder.build().toString());
1551 this.messageService.multipartRequest(mprInput.build(), null);
1553 // Prepare rpc return output. Set xid and send it back.
1554 GetAllQueuesStatisticsFromGivenPortOutputBuilder output = new GetAllQueuesStatisticsFromGivenPortOutputBuilder();
1555 output.setTransactionId(generateTransactionId(xid));
1556 output.setQueueIdAndStatisticsMap(null);
1558 Collection<RpcError> errors = Collections.emptyList();
1559 RpcResult<GetAllQueuesStatisticsFromGivenPortOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
1560 return Futures.immediateFuture(rpcResult);
1564 public Future<RpcResult<GetQueueStatisticsFromGivenPortOutput>> getQueueStatisticsFromGivenPort(
1565 GetQueueStatisticsFromGivenPortInput arg0) {
1566 //Generate xid to associate it with the request
1567 Long xid = this.getSessionContext().getNextXid();
1569 LOG.info("Prepare queue statistics request to collect stats for " +
1570 "given queue attached to given port {} of node {} - TrasactionId - {}",arg0.getQueueId().toString(),arg0.getNodeConnectorId().toString(),arg0.getNode().getValue(),xid);
1572 // Create multipart request header
1573 MultipartRequestInputBuilder mprInput = new MultipartRequestInputBuilder();
1574 mprInput.setType(MultipartType.OFPMPQUEUE);
1575 mprInput.setVersion(version);
1576 mprInput.setXid(xid);
1577 mprInput.setFlags(new MultipartRequestFlags(false));
1579 // Create multipart request body to fetch stats for all the port of the node
1580 MultipartRequestQueueCaseBuilder caseBuilder = new MultipartRequestQueueCaseBuilder();
1581 MultipartRequestQueueBuilder mprQueueBuilder = new MultipartRequestQueueBuilder();
1582 //Select specific queue
1583 mprQueueBuilder.setQueueId(arg0.getQueueId().getValue());
1584 //Select specific port
1585 mprQueueBuilder.setPortNo(InventoryDataServiceUtil.portNumberfromNodeConnectorId(arg0.getNodeConnectorId()));
1587 caseBuilder.setMultipartRequestQueue(mprQueueBuilder.build());
1589 //Set request body to main multipart request
1590 mprInput.setMultipartRequestBody(caseBuilder.build());
1592 //Send the request, no cookies associated, use any connection
1593 LOG.debug("Send queue statistics request :{}",mprQueueBuilder.build().toString());
1594 this.messageService.multipartRequest(mprInput.build(), null);
1596 // Prepare rpc return output. Set xid and send it back.
1597 GetQueueStatisticsFromGivenPortOutputBuilder output = new GetQueueStatisticsFromGivenPortOutputBuilder();
1598 output.setTransactionId(generateTransactionId(xid));
1599 output.setQueueIdAndStatisticsMap(null);
1601 Collection<RpcError> errors = Collections.emptyList();
1602 RpcResult<GetQueueStatisticsFromGivenPortOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
1603 return Futures.immediateFuture(rpcResult);
1607 public Future<RpcResult<GetAllFlowStatisticsOutput>> getAllFlowStatistics(GetAllFlowStatisticsInput arg0) {
1608 //TODO: Depricated, need to clean it up. Sal-Compatibility layes is dependent on it.
1609 // Once sal-compatibility layer is fixed this rpc call can be removed from yang file
1614 public Future<RpcResult<GetAllNodeConnectorStatisticsOutput>> getAllNodeConnectorStatistics(
1615 GetAllNodeConnectorStatisticsInput arg0) {
1616 // TODO Auto-generated method stub
1621 public Future<RpcResult<GetFlowStatisticsOutput>> getFlowStatistics(GetFlowStatisticsInput arg0) {
1622 //TODO: Depricated, need to clean it up. Sal-Compatibility layes is dependent on it.
1623 // Once sal-compatibility layer is fixed this rpc call can be removed from yang file
1628 public Future<RpcResult<GetFlowTableStatisticsOutput>> getFlowTableStatistics(GetFlowTableStatisticsInput arg0) {
1629 // TODO Auto-generated method stub
1634 public Future<RpcResult<GetNodeConnectorStatisticsOutput>> getNodeConnectorStatistics(
1635 GetNodeConnectorStatisticsInput arg0) {
1636 // TODO Auto-generated method stub