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.util.concurrent.Futures;
206 * RPC implementation of MD-switch
208 public class ModelDrivenSwitchImpl extends AbstractModelDrivenSwitch {
210 private static final Logger LOG = org.slf4j.LoggerFactory
211 .getLogger(ModelDrivenSwitchImpl.class);
212 private final NodeId nodeId;
213 private final IMessageDispatchService messageService ;
214 private short version = 0;
216 protected ModelDrivenSwitchImpl(NodeId nodeId,
217 InstanceIdentifier<Node> identifier, SessionContext context) {
218 super(identifier, context);
219 this.nodeId = nodeId;
220 messageService = sessionContext.getMessageDispatchService() ;
221 version = context.getPrimaryConductor().getVersion();
226 public Future<RpcResult<AddFlowOutput>> addFlow(AddFlowInput input) {
227 // Convert the AddFlowInput to FlowModInput
228 FlowModInput ofFlowModInput = FlowConvertor.toFlowModInput(input, version);
229 BarrierInputBuilder barrierInput = new BarrierInputBuilder();
230 barrierInput.setVersion(version);
232 // For Flow provisioning, the SwitchConnectionDistinguisher is set to null so
233 // the request can be routed through any connection to the switch
235 SwitchConnectionDistinguisher cookie = null ;
236 if (input.isBarrier()) {
237 Future<RpcResult<BarrierOutput>> barrierOFLib = messageService.barrier(barrierInput.build(), cookie);
240 LOG.debug("Calling the FlowMod RPC method on MessageDispatchService");
241 Future<RpcResult<UpdateFlowOutput>> resultFromOFLib = messageService.flowMod(ofFlowModInput, cookie) ;
243 RpcResult<UpdateFlowOutput> rpcResultFromOFLib = null ;
246 rpcResultFromOFLib = resultFromOFLib.get();
247 } catch( Exception ex ) {
248 LOG.error( " Error while getting result for AddFlow RPC" + ex.getMessage());
251 UpdateFlowOutput updateFlowOutput = rpcResultFromOFLib.getResult() ;
253 AddFlowOutputBuilder addFlowOutput = new AddFlowOutputBuilder() ;
254 addFlowOutput.setTransactionId(updateFlowOutput.getTransactionId()) ;
255 AddFlowOutput result = addFlowOutput.build();
257 Collection<RpcError> errors = rpcResultFromOFLib.getErrors() ;
258 RpcResult<AddFlowOutput> rpcResult = Rpcs.getRpcResult(true, result, errors);
260 LOG.debug("Returning the Add Flow RPC result to MD-SAL");
261 return Futures.immediateFuture(rpcResult);
265 public Future<RpcResult<AddGroupOutput>> addGroup(AddGroupInput input) {
266 // Convert the AddGroupInput to GroupModInput
267 GroupModInput ofGroupModInput = GroupConvertor.toGroupModInput(input, version);
270 // For Flow provisioning, the SwitchConnectionDistinguisher is set to null so
271 // the request can be routed through any connection to the switch
273 SwitchConnectionDistinguisher cookie = null ;
275 LOG.debug("Calling the GroupMod RPC method on MessageDispatchService");
276 Future<RpcResult<UpdateGroupOutput>> resultFromOFLib = messageService.groupMod(ofGroupModInput, cookie) ;
278 RpcResult<UpdateGroupOutput> rpcResultFromOFLib = null ;
281 rpcResultFromOFLib = resultFromOFLib.get();
282 } catch( Exception ex ) {
283 LOG.error( " Error while getting result for AddGroup RPC" + ex.getMessage());
286 UpdateGroupOutput updateGroupOutput = rpcResultFromOFLib.getResult() ;
288 AddGroupOutputBuilder addGroupOutput = new AddGroupOutputBuilder() ;
289 addGroupOutput.setTransactionId(updateGroupOutput.getTransactionId()) ;
290 AddGroupOutput result = addGroupOutput.build();
292 Collection<RpcError> errors = rpcResultFromOFLib.getErrors() ;
293 RpcResult<AddGroupOutput> rpcResult = Rpcs.getRpcResult(true, result, errors);
295 LOG.debug("Returning the Add Group RPC result to MD-SAL");
296 return Futures.immediateFuture(rpcResult);
300 public Future<RpcResult<AddMeterOutput>> addMeter(AddMeterInput input) {
301 // Convert the AddMeterInput to MeterModInput
302 MeterModInput ofMeterModInput = MeterConvertor.toMeterModInput(input, version);
304 // For Meter provisioning, the SwitchConnectionDistinguisher is set to null so
305 // the request can be routed through any connection to the switch
307 SwitchConnectionDistinguisher cookie = null ;
309 LOG.debug("Calling the MeterMod RPC method on MessageDispatchService");
310 Future<RpcResult<UpdateMeterOutput>> resultFromOFLib = messageService.meterMod(ofMeterModInput, cookie) ;
312 RpcResult<UpdateMeterOutput> rpcResultFromOFLib = null ;
315 rpcResultFromOFLib = resultFromOFLib.get();
316 } catch( Exception ex ) {
317 LOG.error( " Error while getting result for AddMeter RPC" + ex.getMessage());
320 UpdateMeterOutput updateMeterOutput = rpcResultFromOFLib.getResult() ;
322 AddMeterOutputBuilder addMeterOutput = new AddMeterOutputBuilder() ;
323 addMeterOutput.setTransactionId(updateMeterOutput.getTransactionId()) ;
324 AddMeterOutput result = addMeterOutput.build();
326 Collection<RpcError> errors = rpcResultFromOFLib.getErrors() ;
327 RpcResult<AddMeterOutput> rpcResult = Rpcs.getRpcResult(true, result, errors);
329 LOG.debug("Returning the Add Meter RPC result to MD-SAL");
330 return Futures.immediateFuture(rpcResult);
334 public Future<RpcResult<RemoveFlowOutput>> removeFlow(RemoveFlowInput input) {
335 // Convert the RemoveFlowInput to FlowModInput
336 FlowModInput ofFlowModInput = FlowConvertor.toFlowModInput(input, version);
337 BarrierInputBuilder barrierInput = new BarrierInputBuilder();
338 barrierInput.setVersion(version);
340 // For Flow provisioning, the SwitchConnectionDistinguisher is set to null so
341 // the request can be routed through any connection to the switch
343 SwitchConnectionDistinguisher cookie = null ;
344 if (input.isBarrier()) {
345 Future<RpcResult<BarrierOutput>> barrierOFLib = messageService.barrier(barrierInput.build(), cookie);
348 LOG.debug("Calling the FlowMod RPC method on MessageDispatchService");
349 Future<RpcResult<UpdateFlowOutput>> resultFromOFLib = messageService.flowMod(ofFlowModInput, cookie) ;
351 RpcResult<UpdateFlowOutput> rpcResultFromOFLib = null ;
354 rpcResultFromOFLib = resultFromOFLib.get();
355 } catch( Exception ex ) {
356 LOG.error( " Error while getting result for remove Flow RPC" + ex.getMessage());
359 UpdateFlowOutput updateFlowOutput = rpcResultFromOFLib.getResult() ;
361 RemoveFlowOutputBuilder removeFlowOutput = new RemoveFlowOutputBuilder() ;
362 removeFlowOutput.setTransactionId(updateFlowOutput.getTransactionId()) ;
363 RemoveFlowOutput result = removeFlowOutput.build();
365 Collection<RpcError> errors = rpcResultFromOFLib.getErrors() ;
366 RpcResult<RemoveFlowOutput> rpcResult = Rpcs.getRpcResult(true, result, errors);
368 LOG.debug("Returning the Remove Flow RPC result to MD-SAL");
369 return Futures.immediateFuture(rpcResult);
373 public Future<RpcResult<RemoveGroupOutput>> removeGroup(
374 RemoveGroupInput input) {
375 // Convert the RemoveGroupInput to GroupModInput
376 GroupModInput ofGroupModInput = GroupConvertor.toGroupModInput(input, version);
379 // For Flow provisioning, the SwitchConnectionDistinguisher is set to null so
380 // the request can be routed through any connection to the switch
382 SwitchConnectionDistinguisher cookie = null ;
384 LOG.debug("Calling the GroupMod RPC method on MessageDispatchService");
385 Future<RpcResult<UpdateGroupOutput>> resultFromOFLib = messageService.groupMod(ofGroupModInput, cookie) ;
387 RpcResult<UpdateGroupOutput> rpcResultFromOFLib = null ;
390 rpcResultFromOFLib = resultFromOFLib.get();
391 } catch( Exception ex ) {
392 LOG.error( " Error while getting result for RemoveGroup RPC" + ex.getMessage());
395 UpdateGroupOutput updateGroupOutput = rpcResultFromOFLib.getResult() ;
397 RemoveGroupOutputBuilder removeGroupOutput = new RemoveGroupOutputBuilder() ;
398 removeGroupOutput.setTransactionId(updateGroupOutput.getTransactionId()) ;
399 RemoveGroupOutput result = removeGroupOutput.build();
401 Collection<RpcError> errors = rpcResultFromOFLib.getErrors() ;
402 RpcResult<RemoveGroupOutput> rpcResult = Rpcs.getRpcResult(true, result, errors);
404 LOG.debug("Returning the Remove Group RPC result to MD-SAL");
405 return Futures.immediateFuture(rpcResult);
409 public Future<RpcResult<RemoveMeterOutput>> removeMeter(
410 RemoveMeterInput input) {
411 // Convert the RemoveMeterInput to MeterModInput
412 MeterModInput ofMeterModInput = MeterConvertor.toMeterModInput(input, version);
415 // For Meter provisioning, the SwitchConnectionDistinguisher is set to null so
416 // the request can be routed through any connection to the switch
418 SwitchConnectionDistinguisher cookie = null ;
420 LOG.debug("Calling the MeterMod RPC method on MessageDispatchService");
421 Future<RpcResult<UpdateMeterOutput>> resultFromOFLib = messageService.meterMod(ofMeterModInput, cookie) ;
423 RpcResult<UpdateMeterOutput> rpcResultFromOFLib = null ;
426 rpcResultFromOFLib = resultFromOFLib.get();
427 } catch( Exception ex ) {
428 LOG.error( " Error while getting result for RemoveMeter RPC" + ex.getMessage());
431 UpdateMeterOutput updatemeterOutput = rpcResultFromOFLib.getResult() ;
433 RemoveMeterOutputBuilder removeMeterOutput = new RemoveMeterOutputBuilder() ;
434 removeMeterOutput.setTransactionId(updatemeterOutput.getTransactionId()) ;
435 RemoveMeterOutput result = removeMeterOutput.build();
437 Collection<RpcError> errors = rpcResultFromOFLib.getErrors() ;
438 RpcResult<RemoveMeterOutput> rpcResult = Rpcs.getRpcResult(true, result, errors);
440 LOG.debug("Returning the Remove Meter RPC result to MD-SAL");
441 return Futures.immediateFuture(rpcResult);
445 public Future<RpcResult<Void>> transmitPacket(TransmitPacketInput input) {
446 LOG.info("TransmitPacket - {}",input);
447 // Convert TransmitPacket to PacketOutInput
449 // TODO VD create PacketConvertor and move convert logic there
451 // Build Port ID from TransmitPacketInput.Ingress
452 PortNumber inPortNr = null;
454 List<PathArgument> inArgs = input.getIngress().getValue().getPath();
455 if (inArgs.size() >= 3) {
456 InstanceIdentifier.IdentifiableItem item = Arguments.checkInstanceOf(inArgs.get(2), InstanceIdentifier.IdentifiableItem.class);
457 NodeConnectorKey key = Arguments.checkInstanceOf(item.getKey(), NodeConnectorKey.class);
458 String[] split = key.getId().getValue().split(":");
459 Long port = Long.decode(split[split.length-1]);
460 inPortNr = new PortNumber(port);
462 // TODO Ed could by in this way or Exception or something else ?
463 inPortNr = new PortNumber(0xfffffffdL);
466 // Build Buffer ID from TransmitPacketInput.Ingress
467 // TODO VD P! find how to fix PacketIn to add BufferID to augmetation
468 Long bufferId = OFConstants.OFP_NO_BUFFER;
470 PortNumber outPort = null;
471 NodeConnectorRef outRef = input.getEgress();
472 List<PathArgument> outArgs = outRef.getValue().getPathArguments();
473 if (outArgs.size() >= 3) {
474 InstanceIdentifier.IdentifiableItem item = Arguments.checkInstanceOf(outArgs.get(2), InstanceIdentifier.IdentifiableItem.class);
475 NodeConnectorKey key = Arguments.checkInstanceOf(item.getKey(), NodeConnectorKey.class);
476 String[] split = key.getId().getValue().split(":");
477 Long port = Long.decode(split[split.length-1]);
478 outPort = new PortNumber(port);
480 new Exception("PORT NR not exist in Egress"); //TODO : P4 search for some normal exception
483 // TODO VD P! wait for way to move Actions (e.g. augmentation)
485 // TODO VD implementation for testing PacketIn (REMOVE IT)
486 List<ActionsList> actions = new ArrayList<ActionsList>();
487 ActionsListBuilder asBuild = new ActionsListBuilder();
488 ActionBuilder aBuild = new ActionBuilder();
489 aBuild.setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output.class);
490 PortActionBuilder paBuild = new PortActionBuilder();
491 paBuild.setPort(outPort);
492 aBuild.addAugmentation(PortAction.class, paBuild.build());
493 MaxLengthActionBuilder mlBuild = new MaxLengthActionBuilder();
494 mlBuild.setMaxLength(0xffff);
495 aBuild.addAugmentation(MaxLengthAction.class, mlBuild.build());
496 asBuild.setAction(aBuild.build());
497 actions.add(asBuild.build());
499 PacketOutInputBuilder builder = new PacketOutInputBuilder();
500 builder.setActionsList(actions);
501 builder.setData(input.getPayload());
502 builder.setVersion(version);
503 builder.setXid(sessionContext.getNextXid());
504 builder.setInPort(inPortNr);
505 builder.setBufferId(bufferId);
506 // --------------------------------------------------------
508 PacketOutInput message = builder.build();
510 // TODO VD NULL for yet - find how to translate cookie from TransmitPacketInput
511 // SwitchConnectionDistinguisher cookie = ( "what is need to do" ) input.getCookie();
512 SwitchConnectionDistinguisher cookie = null ;
514 LOG.debug("Calling the transmitPacket RPC method");
515 return messageService.packetOut(message, cookie);
518 private FlowModInputBuilder toFlowModInputBuilder(Flow source) {
519 FlowModInputBuilder target = new FlowModInputBuilder();
520 target.setCookie(source.getCookie());
521 target.setIdleTimeout(source.getIdleTimeout());
522 target.setHardTimeout(source.getHardTimeout());
523 target.setMatch(toMatch(source.getMatch()));
528 private Match toMatch(
529 org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match match) {
530 MatchBuilder target = new MatchBuilder();
532 target.setMatchEntries(toMatchEntries(match));
537 private List<MatchEntries> toMatchEntries(
538 org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match match) {
539 List<MatchEntries> entries = new ArrayList<>();
545 public Future<RpcResult<UpdateFlowOutput>> updateFlow(UpdateFlowInput input) {
546 // Convert the UpdateFlowInput to FlowModInput
547 FlowModInput ofFlowModInput = FlowConvertor.toFlowModInput(input.getUpdatedFlow(), version);
548 BarrierInputBuilder barrierInput = new BarrierInputBuilder();
549 barrierInput.setVersion(version);
550 // Call the RPC method on MessageDispatchService
552 // For Flow provisioning, the SwitchConnectionDistinguisher is set to null so
553 // the request can be routed through any connection to the switch
555 SwitchConnectionDistinguisher cookie = null ;
556 if (input.getUpdatedFlow().isBarrier()) {
557 Future<RpcResult<BarrierOutput>> barrierOFLib = messageService.barrier(barrierInput.build(), cookie);
560 LOG.debug("Calling the FlowMod RPC method on MessageDispatchService");
561 Future<RpcResult<UpdateFlowOutput>> resultFromOFLib = messageService.flowMod(ofFlowModInput, cookie) ;
563 RpcResult<UpdateFlowOutput> rpcResultFromOFLib = null ;
566 rpcResultFromOFLib = resultFromOFLib.get();
567 } catch( Exception ex ) {
568 LOG.error( " Error while getting result for UpdateFlow RPC" + ex.getMessage());
571 UpdateFlowOutput updateFlowOutputOFLib = rpcResultFromOFLib.getResult() ;
573 UpdateFlowOutputBuilder updateFlowOutput = new UpdateFlowOutputBuilder() ;
574 updateFlowOutput.setTransactionId(updateFlowOutputOFLib.getTransactionId()) ;
575 UpdateFlowOutput result = updateFlowOutput.build();
577 Collection<RpcError> errors = rpcResultFromOFLib.getErrors() ;
578 RpcResult<UpdateFlowOutput> rpcResult = Rpcs.getRpcResult(true, result, errors);
580 LOG.debug("Returning the Update Flow RPC result to MD-SAL");
581 return Futures.immediateFuture(rpcResult);
585 public Future<RpcResult<UpdateGroupOutput>> updateGroup(
586 UpdateGroupInput input) {
587 // Convert the UpdateGroupInput to GroupModInput
588 GroupModInput ofGroupModInput = GroupConvertor.toGroupModInput(input.getUpdatedGroup(), version);
591 // For Flow provisioning, the SwitchConnectionDistinguisher is set to null so
592 // the request can be routed through any connection to the switch
594 SwitchConnectionDistinguisher cookie = null ;
596 LOG.debug("Calling the GroupMod RPC method on MessageDispatchService");
597 Future<RpcResult<UpdateGroupOutput>> resultFromOFLib = messageService.groupMod(ofGroupModInput, cookie) ;
599 RpcResult<UpdateGroupOutput> rpcResultFromOFLib = null ;
602 rpcResultFromOFLib = resultFromOFLib.get();
603 } catch( Exception ex ) {
604 LOG.error( " Error while getting result for updateGroup RPC" + ex.getMessage());
607 UpdateGroupOutput updateGroupOutputOFLib = rpcResultFromOFLib.getResult() ;
609 UpdateGroupOutputBuilder updateGroupOutput = new UpdateGroupOutputBuilder() ;
610 updateGroupOutput.setTransactionId(updateGroupOutputOFLib.getTransactionId()) ;
611 UpdateGroupOutput result = updateGroupOutput.build();
613 Collection<RpcError> errors = rpcResultFromOFLib.getErrors() ;
614 RpcResult<UpdateGroupOutput> rpcResult = Rpcs.getRpcResult(true, result, errors);
616 LOG.debug("Returning the Update Group RPC result to MD-SAL");
617 return Futures.immediateFuture(rpcResult);
621 public Future<RpcResult<UpdateMeterOutput>> updateMeter(
622 UpdateMeterInput input) {
623 // Convert the UpdateMeterInput to MeterModInput
624 MeterModInput ofMeterModInput = MeterConvertor.toMeterModInput(input.getUpdatedMeter(), version);
627 // For Meter provisioning, the SwitchConnectionDistinguisher is set to null so
628 // the request can be routed through any connection to the switch
630 SwitchConnectionDistinguisher cookie = null ;
632 LOG.debug("Calling the MeterMod RPC method on MessageDispatchService");
633 Future<RpcResult<UpdateMeterOutput>> resultFromOFLib = messageService.meterMod(ofMeterModInput, cookie) ;
635 RpcResult<UpdateMeterOutput> rpcResultFromOFLib = null ;
638 rpcResultFromOFLib = resultFromOFLib.get();
639 } catch( Exception ex ) {
640 LOG.error( " Error while getting result for UpdateMeter RPC" + ex.getMessage());
643 UpdateMeterOutput updateMeterOutputFromOFLib = rpcResultFromOFLib.getResult() ;
645 UpdateMeterOutputBuilder updateMeterOutput = new UpdateMeterOutputBuilder() ;
646 updateMeterOutput.setTransactionId(updateMeterOutputFromOFLib.getTransactionId()) ;
647 UpdateMeterOutput result = updateMeterOutput.build();
649 Collection<RpcError> errors = rpcResultFromOFLib.getErrors() ;
650 RpcResult<UpdateMeterOutput> rpcResult = Rpcs.getRpcResult(true, result, errors);
652 LOG.debug("Returning the Update Meter RPC result to MD-SAL");
653 return Futures.immediateFuture(rpcResult);
657 public NodeId getNodeId() {
662 * Methods for requesting statistics from switch
665 public Future<RpcResult<GetAllGroupStatisticsOutput>> getAllGroupStatistics(GetAllGroupStatisticsInput input) {
667 //Generate xid to associate it with the request
668 Long xid = this.getSessionContext().getNextXid();
670 LOG.debug("Prepare statistics request for all the groups - Transaction id - {}",xid);
672 // Create multipart request header
673 MultipartRequestInputBuilder mprInput = new MultipartRequestInputBuilder();
674 mprInput.setType(MultipartType.OFPMPGROUP);
675 mprInput.setVersion(version);
676 mprInput.setXid(xid);
677 mprInput.setFlags(new MultipartRequestFlags(false));
679 // Create multipart request body for fetch all the group stats
680 MultipartRequestGroupCaseBuilder caseBuilder = new MultipartRequestGroupCaseBuilder();
681 MultipartRequestGroupBuilder mprGroupBuild = new MultipartRequestGroupBuilder();
682 mprGroupBuild.setGroupId(new GroupId(BinContent.intToUnsignedLong(Group.OFPGALL.getIntValue())));
683 caseBuilder.setMultipartRequestGroup(mprGroupBuild.build());
685 //Set request body to main multipart request
686 mprInput.setMultipartRequestBody(caseBuilder.build());
688 //Send the request, no cookies associated, use any connection
689 LOG.debug("Send group statistics request to the switch :{}",mprGroupBuild);
690 this.messageService.multipartRequest(mprInput.build(), null);
692 // Prepare rpc return output. Set xid and send it back.
693 LOG.debug("Return results and transaction id back to caller");
694 GetAllGroupStatisticsOutputBuilder output = new GetAllGroupStatisticsOutputBuilder();
695 output.setTransactionId(generateTransactionId(xid));
696 output.setGroupStats(null);
698 Collection<RpcError> errors = Collections.emptyList();
699 RpcResult<GetAllGroupStatisticsOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
700 return Futures.immediateFuture(rpcResult);
705 public Future<RpcResult<GetGroupDescriptionOutput>> getGroupDescription(GetGroupDescriptionInput input) {
707 //Generate xid to associate it with the request
708 Long xid = this.getSessionContext().getNextXid();
710 LOG.debug("Prepare group description statistics request - Transaction id - {}",xid);
712 // Create multipart request header
713 MultipartRequestInputBuilder mprInput = new MultipartRequestInputBuilder();
714 mprInput.setType(MultipartType.OFPMPGROUPDESC);
715 mprInput.setVersion(version);
716 mprInput.setXid(xid);
717 mprInput.setFlags(new MultipartRequestFlags(false));
719 // Create multipart request body for fetch all the group description stats
720 MultipartRequestGroupDescCaseBuilder mprGroupDescBuild = new MultipartRequestGroupDescCaseBuilder();
722 //Set request body to main multipart request
723 mprInput.setMultipartRequestBody(mprGroupDescBuild.build());
725 //Send the request, no cookies associated, use any connection
726 LOG.debug("Send group desciption statistics request to switch : {}",mprGroupDescBuild);
727 this.messageService.multipartRequest(mprInput.build(), null);
729 // Prepare rpc return output. Set xid and send it back.
730 LOG.debug("Return results and transaction id back to caller");
731 GetGroupDescriptionOutputBuilder output = new GetGroupDescriptionOutputBuilder();
732 output.setTransactionId(generateTransactionId(xid));
733 output.setGroupDescStats(null);
735 Collection<RpcError> errors = Collections.emptyList();
736 RpcResult<GetGroupDescriptionOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
737 return Futures.immediateFuture(rpcResult);
742 public Future<RpcResult<GetGroupFeaturesOutput>> getGroupFeatures(GetGroupFeaturesInput input) {
744 //Generate xid to associate it with the request
745 Long xid = this.getSessionContext().getNextXid();
747 LOG.debug("Prepare group features statistics request - Transaction id - {}",xid);
749 // Create multipart request header
750 MultipartRequestInputBuilder mprInput = new MultipartRequestInputBuilder();
751 mprInput.setType(MultipartType.OFPMPGROUPFEATURES);
752 mprInput.setVersion(version);
753 mprInput.setXid(xid);
754 mprInput.setFlags(new MultipartRequestFlags(false));
756 // Create multipart request body for fetch all the group description stats
757 MultipartRequestGroupFeaturesCaseBuilder mprGroupFeaturesBuild = new MultipartRequestGroupFeaturesCaseBuilder();
759 //Set request body to main multipart request
760 mprInput.setMultipartRequestBody(mprGroupFeaturesBuild.build());
762 //Send the request, no cookies associated, use any connection
763 LOG.debug("Send group features statistics request :{}",mprGroupFeaturesBuild);
764 this.messageService.multipartRequest(mprInput.build(), null);
766 // Prepare rpc return output. Set xid and send it back.
767 LOG.debug("Return results and transaction id back to caller");
768 GetGroupFeaturesOutputBuilder output = new GetGroupFeaturesOutputBuilder();
769 output.setTransactionId(generateTransactionId(xid));
771 Collection<RpcError> errors = Collections.emptyList();
772 RpcResult<GetGroupFeaturesOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
773 return Futures.immediateFuture(rpcResult);
777 public Future<RpcResult<GetGroupStatisticsOutput>> getGroupStatistics(GetGroupStatisticsInput input) {
779 //Generate xid to associate it with the request
780 Long xid = this.getSessionContext().getNextXid();
782 LOG.debug("Prepare statistics request for node {} group ({}) - Transaction id - {}",input.getNode(),input.getGroupId(),xid);
784 // Create multipart request header
785 MultipartRequestInputBuilder mprInput = new MultipartRequestInputBuilder();
786 mprInput.setType(MultipartType.OFPMPGROUP);
787 mprInput.setVersion(version);
788 mprInput.setXid(xid);
789 mprInput.setFlags(new MultipartRequestFlags(false));
791 // Create multipart request body for fetch all the group stats
792 MultipartRequestGroupCaseBuilder caseBuilder = new MultipartRequestGroupCaseBuilder();
793 MultipartRequestGroupBuilder mprGroupBuild = new MultipartRequestGroupBuilder();
794 mprGroupBuild.setGroupId(new GroupId(input.getGroupId().getValue()));
795 caseBuilder.setMultipartRequestGroup(mprGroupBuild.build());
797 //Set request body to main multipart request
798 mprInput.setMultipartRequestBody(caseBuilder.build());
800 //Send the request, no cookies associated, use any connection
801 LOG.debug("Send group statistics request :{}",mprGroupBuild);
802 this.messageService.multipartRequest(mprInput.build(), null);
804 // Prepare rpc return output. Set xid and send it back.
805 LOG.debug("Return results and transaction id back to caller");
806 GetGroupStatisticsOutputBuilder output = new GetGroupStatisticsOutputBuilder();
807 output.setTransactionId(generateTransactionId(xid));
808 output.setGroupStats(null);
810 Collection<RpcError> errors = Collections.emptyList();
811 RpcResult<GetGroupStatisticsOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
812 return Futures.immediateFuture(rpcResult);
816 public Future<RpcResult<GetAllMeterConfigStatisticsOutput>> getAllMeterConfigStatistics(
817 GetAllMeterConfigStatisticsInput input) {
819 //Generate xid to associate it with the request
820 Long xid = this.getSessionContext().getNextXid();
822 LOG.debug("Prepare config request for all the meters - Transaction id - {}",xid);
824 // Create multipart request header
825 MultipartRequestInputBuilder mprInput = new MultipartRequestInputBuilder();
826 mprInput.setType(MultipartType.OFPMPMETERCONFIG);
827 mprInput.setVersion(version);
828 mprInput.setXid(xid);
829 mprInput.setFlags(new MultipartRequestFlags(false));
831 // Create multipart request body for fetch all the meter stats
832 MultipartRequestMeterConfigCaseBuilder caseBuilder = new MultipartRequestMeterConfigCaseBuilder();
833 MultipartRequestMeterConfigBuilder mprMeterConfigBuild = new MultipartRequestMeterConfigBuilder();
834 mprMeterConfigBuild.setMeterId(new MeterId(BinContent.intToUnsignedLong(Meter.OFPMALL.getIntValue())));
835 caseBuilder.setMultipartRequestMeterConfig(mprMeterConfigBuild.build());
837 //Set request body to main multipart request
838 mprInput.setMultipartRequestBody(caseBuilder.build());
840 //Send the request, no cookies associated, use any connection
841 LOG.debug("Send meter statistics request :{}",mprMeterConfigBuild);
842 this.messageService.multipartRequest(mprInput.build(), null);
844 // Prepare rpc return output. Set xid and send it back.
845 LOG.debug("Return results and transaction id back to caller");
846 GetAllMeterConfigStatisticsOutputBuilder output = new GetAllMeterConfigStatisticsOutputBuilder();
847 output.setTransactionId(generateTransactionId(xid));
848 output.setMeterConfigStats(null);
850 Collection<RpcError> errors = Collections.emptyList();
851 RpcResult<GetAllMeterConfigStatisticsOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
852 return Futures.immediateFuture(rpcResult);
856 public Future<RpcResult<GetAllMeterStatisticsOutput>> getAllMeterStatistics(GetAllMeterStatisticsInput input) {
858 //Generate xid to associate it with the request
859 Long xid = this.getSessionContext().getNextXid();
861 LOG.debug("Prepare statistics request for all the meters - Transaction id - {}",xid);
863 // Create multipart request header
864 MultipartRequestInputBuilder mprInput = new MultipartRequestInputBuilder();
865 mprInput.setType(MultipartType.OFPMPMETER);
866 mprInput.setVersion(version);
867 mprInput.setXid(xid);
868 mprInput.setFlags(new MultipartRequestFlags(false));
870 // Create multipart request body for fetch all the meter stats
871 MultipartRequestMeterCaseBuilder caseBuilder = new MultipartRequestMeterCaseBuilder();
872 MultipartRequestMeterBuilder mprMeterBuild = new MultipartRequestMeterBuilder();
873 mprMeterBuild.setMeterId(new MeterId(BinContent.intToUnsignedLong(Meter.OFPMALL.getIntValue())));
874 caseBuilder.setMultipartRequestMeter(mprMeterBuild.build());
876 //Set request body to main multipart request
877 mprInput.setMultipartRequestBody(caseBuilder.build());
879 //Send the request, no cookies associated, use any connection
880 LOG.debug("Send meter statistics request :{}",mprMeterBuild);
881 this.messageService.multipartRequest(mprInput.build(), null);
883 // Prepare rpc return output. Set xid and send it back.
884 LOG.debug("Return results and transaction id back to caller");
885 GetAllMeterStatisticsOutputBuilder output = new GetAllMeterStatisticsOutputBuilder();
886 output.setTransactionId(generateTransactionId(xid));
887 output.setMeterStats(null);
889 Collection<RpcError> errors = Collections.emptyList();
890 RpcResult<GetAllMeterStatisticsOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
891 return Futures.immediateFuture(rpcResult);
895 public Future<RpcResult<GetMeterFeaturesOutput>> getMeterFeatures(GetMeterFeaturesInput input) {
897 //Generate xid to associate it with the request
898 Long xid = this.getSessionContext().getNextXid();
900 LOG.debug("Prepare features statistics request for all the meters - Transaction id - {}",xid);
902 // Create multipart request header
903 MultipartRequestInputBuilder mprInput = new MultipartRequestInputBuilder();
904 mprInput.setType(MultipartType.OFPMPMETERFEATURES);
905 mprInput.setVersion(version);
906 mprInput.setXid(xid);
907 mprInput.setFlags(new MultipartRequestFlags(false));
909 // Create multipart request body for fetch all the group description stats
910 MultipartRequestMeterFeaturesCaseBuilder mprMeterFeaturesBuild = new MultipartRequestMeterFeaturesCaseBuilder();
912 //Set request body to main multipart request
913 mprInput.setMultipartRequestBody(mprMeterFeaturesBuild.build());
915 //Send the request, no cookies associated, use any connection
916 LOG.debug("Send meter features statistics request :{}",mprMeterFeaturesBuild);
917 this.messageService.multipartRequest(mprInput.build(), null);
919 // Prepare rpc return output. Set xid and send it back.
920 LOG.debug("Return results and transaction id back to caller");
921 GetMeterFeaturesOutputBuilder output = new GetMeterFeaturesOutputBuilder();
922 output.setTransactionId(generateTransactionId(xid));
924 Collection<RpcError> errors = Collections.emptyList();
925 RpcResult<GetMeterFeaturesOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
926 return Futures.immediateFuture(rpcResult);
930 public Future<RpcResult<GetMeterStatisticsOutput>> getMeterStatistics(GetMeterStatisticsInput input) {
931 //Generate xid to associate it with the request
932 Long xid = this.getSessionContext().getNextXid();
934 LOG.debug("Preprae statistics request for Meter ({}) - Transaction id - {}",input.getMeterId().getValue(),xid);
936 // Create multipart request header
937 MultipartRequestInputBuilder mprInput = new MultipartRequestInputBuilder();
938 mprInput.setType(MultipartType.OFPMPMETER);
939 mprInput.setVersion(version);
940 mprInput.setXid(xid);
941 mprInput.setFlags(new MultipartRequestFlags(false));
943 // Create multipart request body for fetch all the meter stats
944 MultipartRequestMeterCaseBuilder caseBuilder = new MultipartRequestMeterCaseBuilder();
945 MultipartRequestMeterBuilder mprMeterBuild = new MultipartRequestMeterBuilder();
946 //Select specific meter
947 mprMeterBuild.setMeterId(new MeterId(input.getMeterId().getValue()));
948 caseBuilder.setMultipartRequestMeter(mprMeterBuild.build());
950 //Set request body to main multipart request
951 mprInput.setMultipartRequestBody(caseBuilder.build());
953 //Send the request, no cookies associated, use any connection
954 LOG.debug("Send meter statistics request :{}",mprMeterBuild);
955 this.messageService.multipartRequest(mprInput.build(), null);
957 // Prepare rpc return output. Set xid and send it back.
958 LOG.debug("Return results and transaction id back to caller");
959 GetMeterStatisticsOutputBuilder output = new GetMeterStatisticsOutputBuilder();
960 output.setTransactionId(generateTransactionId(xid));
961 output.setMeterStats(null);
963 Collection<RpcError> errors = Collections.emptyList();
964 RpcResult<GetMeterStatisticsOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
965 return Futures.immediateFuture(rpcResult);
969 public Future<RpcResult<GetAllPortsStatisticsOutput>> getAllPortsStatistics(GetAllPortsStatisticsInput arg0) {
971 //Generate xid to associate it with the request
972 Long xid = this.getSessionContext().getNextXid();
974 LOG.info("Prepare port statistics request for all ports of node {} - TrasactionId - {}",arg0.getNode().getValue(),xid);
976 // Create multipart request header
977 MultipartRequestInputBuilder mprInput = new MultipartRequestInputBuilder();
978 mprInput.setType(MultipartType.OFPMPPORTSTATS);
979 mprInput.setVersion(version);
980 mprInput.setXid(xid);
981 mprInput.setFlags(new MultipartRequestFlags(false));
983 // Create multipart request body to fetch stats for all the port of the node
984 MultipartRequestPortStatsCaseBuilder caseBuilder = new MultipartRequestPortStatsCaseBuilder();
985 MultipartRequestPortStatsBuilder mprPortStatsBuilder = new MultipartRequestPortStatsBuilder();
987 mprPortStatsBuilder.setPortNo(OFConstants.OFPP_ANY);
988 caseBuilder.setMultipartRequestPortStats(mprPortStatsBuilder.build());
990 //Set request body to main multipart request
991 mprInput.setMultipartRequestBody(caseBuilder.build());
993 //Send the request, no cookies associated, use any connection
994 LOG.debug("Send port statistics request :{}",mprPortStatsBuilder.build().toString());
995 this.messageService.multipartRequest(mprInput.build(), null);
997 // Prepare rpc return output. Set xid and send it back.
998 GetAllPortsStatisticsOutputBuilder output = new GetAllPortsStatisticsOutputBuilder();
999 output.setTransactionId(generateTransactionId(xid));
1001 Collection<RpcError> errors = Collections.emptyList();
1002 RpcResult<GetAllPortsStatisticsOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
1003 return Futures.immediateFuture(rpcResult);
1007 public Future<RpcResult<GetPortStatisticsOutput>> getPortStatistics(GetPortStatisticsInput arg0) {
1008 //Generate xid to associate it with the request
1009 Long xid = this.getSessionContext().getNextXid();
1011 LOG.info("Prepare port statistics request for port {} of node {} - TrasactionId - {}",arg0.getNodeConnectorId(), arg0.getNode().getValue(),xid);
1013 // Create multipart request header
1014 MultipartRequestInputBuilder mprInput = new MultipartRequestInputBuilder();
1015 mprInput.setType(MultipartType.OFPMPPORTSTATS);
1016 mprInput.setVersion(version);
1017 mprInput.setXid(xid);
1018 mprInput.setFlags(new MultipartRequestFlags(false));
1020 // Create multipart request body to fetch stats for all the port of the node
1021 MultipartRequestPortStatsCaseBuilder caseBuilder = new MultipartRequestPortStatsCaseBuilder();
1022 MultipartRequestPortStatsBuilder mprPortStatsBuilder = new MultipartRequestPortStatsBuilder();
1025 mprPortStatsBuilder.setPortNo(InventoryDataServiceUtil.portNumberfromNodeConnectorId(arg0.getNodeConnectorId()));
1026 caseBuilder.setMultipartRequestPortStats(mprPortStatsBuilder.build());
1028 //Set request body to main multipart request
1029 mprInput.setMultipartRequestBody(caseBuilder.build());
1031 //Send the request, no cookies associated, use any connection
1032 LOG.debug("Send port statistics request :{}",mprPortStatsBuilder.build().toString());
1033 this.messageService.multipartRequest(mprInput.build(), null);
1035 // Prepare rpc return output. Set xid and send it back.
1036 GetPortStatisticsOutputBuilder output = new GetPortStatisticsOutputBuilder();
1037 output.setTransactionId(generateTransactionId(xid));
1039 Collection<RpcError> errors = Collections.emptyList();
1040 RpcResult<GetPortStatisticsOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
1041 return Futures.immediateFuture(rpcResult);
1044 private TransactionId generateTransactionId(Long xid){
1045 String stringXid =xid.toString();
1046 BigInteger bigIntXid = new BigInteger( stringXid );
1047 return new TransactionId(bigIntXid);
1052 public Future<RpcResult<GetPortOutput>> getPort() {
1053 // TODO Auto-generated method stub
1059 public Future<RpcResult<UpdatePortOutput>> updatePort(UpdatePortInput input) {
1060 PortModInput ofPortModInput = null ;
1061 RpcResult<UpdatePortOutput> rpcResultFromOFLib = null ;
1064 // For Flow provisioning, the SwitchConnectionDistinguisher is set to null so
1065 // the request can be routed through any connection to the switch
1067 SwitchConnectionDistinguisher cookie = null ;
1069 // NSF sends a list of port and the ModelDrivenSwitch will
1070 // send one port at a time towards the switch ( mutiple RPCs calls)
1071 List<Port> inputPorts = input.getUpdatedPort().getPort().getPort() ;
1073 // Get the Xid. The same Xid has to be sent in all the RPCs
1074 Long Xid = sessionContext.getNextXid();
1076 for( Port inputPort : inputPorts) {
1078 // Convert the UpdateGroupInput to GroupModInput
1079 ofPortModInput = PortConvertor.toPortModInput(inputPort, version) ;
1081 // Insert the Xid ( transaction Id) before calling the RPC on the OFLibrary
1083 PortModInputBuilder mdInput = new PortModInputBuilder();
1084 mdInput.setXid(Xid);
1085 mdInput.setVersion(ofPortModInput.getVersion()) ;
1086 mdInput.setPortNo(ofPortModInput.getPortNo()) ;
1087 mdInput.setMaskV10(ofPortModInput.getMaskV10()) ;
1088 mdInput.setMask(ofPortModInput.getMask()) ;
1089 mdInput.setHwAddress(ofPortModInput.getHwAddress());
1090 mdInput.setConfigV10(ofPortModInput.getConfigV10()) ;
1091 mdInput.setConfig(ofPortModInput.getConfig()) ;
1092 mdInput.setAdvertiseV10(ofPortModInput.getAdvertiseV10()) ;
1093 mdInput.setAdvertise(ofPortModInput.getAdvertise()) ;
1095 LOG.debug("Calling the PortMod RPC method on MessageDispatchService");
1096 Future<RpcResult<UpdatePortOutput>> resultFromOFLib = messageService.portMod(ofPortModInput, cookie) ;
1099 rpcResultFromOFLib = resultFromOFLib.get();
1100 } catch( Exception ex ) {
1101 LOG.error( " Error while getting result for updatePort RPC" + ex.getMessage());
1104 // The Future response value for all the RPCs except the last one is ignored
1107 //Extract the Xid only from the Future for the last RPC and
1108 // send it back to the NSF
1109 UpdatePortOutput updatePortOutputOFLib = rpcResultFromOFLib.getResult() ;
1111 UpdatePortOutputBuilder updatePortOutput = new UpdatePortOutputBuilder() ;
1112 updatePortOutput.setTransactionId(updatePortOutputOFLib.getTransactionId()) ;
1113 UpdatePortOutput result = updatePortOutput.build();
1115 Collection<RpcError> errors = rpcResultFromOFLib.getErrors() ;
1116 RpcResult<UpdatePortOutput> rpcResult = Rpcs.getRpcResult(true, result, errors);
1118 LOG.debug("Returning the Update Group RPC result to MD-SAL");
1119 return Futures.immediateFuture(rpcResult);
1124 public Future<RpcResult<UpdateTableOutput>> updateTable(
1125 UpdateTableInput input) {
1127 // Get the Xid. The same Xid has to be sent in all the Multipart requests
1128 Long xid = this.getSessionContext().getNextXid();
1130 LOG.debug("Prepare the Multipart Table Mod requests for Transaction Id {} ",xid);
1132 // Create multipart request header
1133 MultipartRequestInputBuilder mprInput = new MultipartRequestInputBuilder();
1134 mprInput.setType(MultipartType.OFPMPTABLEFEATURES);
1135 mprInput.setVersion((short)0x04);
1136 mprInput.setXid(xid);
1138 //Convert the list of all MD-SAL table feature object into OF library object
1139 List<TableFeatures> ofTableFeatureList = TableFeaturesConvertor.toTableFeaturesRequest(input.getUpdatedTable()) ;
1142 MultipartRequestTableFeaturesCaseBuilder caseRequest = new MultipartRequestTableFeaturesCaseBuilder();
1143 MultipartRequestTableFeaturesBuilder tableFeaturesRequest = new MultipartRequestTableFeaturesBuilder();
1145 mprInput.setFlags(new MultipartRequestFlags(true));
1147 tableFeaturesRequest.setTableFeatures(ofTableFeatureList) ;
1149 //Set request body to main multipart request
1150 caseRequest.setMultipartRequestTableFeatures(tableFeaturesRequest.build());
1151 mprInput.setMultipartRequestBody(caseRequest.build());
1153 //Send the request, no cookies associated, use any connection
1154 LOG.debug("Send Table Feature request :{}",ofTableFeatureList);
1155 this.messageService.multipartRequest(mprInput.build(), null);
1158 //Extract the Xid only from the Future for the last RPC and
1159 // send it back to the NSF
1160 LOG.debug("Returning the result and transaction id to NSF");
1161 LOG.debug("Return results and transaction id back to caller");
1162 UpdateTableOutputBuilder output = new UpdateTableOutputBuilder();
1163 output.setTransactionId(generateTransactionId(xid));
1165 Collection<RpcError> errors = Collections.emptyList();
1166 RpcResult<UpdateTableOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
1167 return Futures.immediateFuture(rpcResult);
1171 public Future<RpcResult<GetAllFlowStatisticsFromFlowTableOutput>> getAllFlowStatisticsFromFlowTable(
1172 GetAllFlowStatisticsFromFlowTableInput arg0) {
1174 //Generate xid to associate it with the request
1175 Long xid = this.getSessionContext().getNextXid();
1177 LOG.debug("Prepare statistics request to get flow stats for switch tables {} - Transaction id - {}"
1178 ,arg0.getTableId().getValue(),xid);
1180 // Create multipart request header
1181 MultipartRequestInputBuilder mprInput = new MultipartRequestInputBuilder();
1182 mprInput.setType(MultipartType.OFPMPFLOW);
1183 mprInput.setVersion(version);
1184 mprInput.setXid(xid);
1185 mprInput.setFlags(new MultipartRequestFlags(false));
1187 // Create multipart request body for fetch all the group stats
1188 MultipartRequestFlowCaseBuilder multipartRequestFlowCaseBuilder = new MultipartRequestFlowCaseBuilder ();
1189 MultipartRequestFlowBuilder mprFlowRequestBuilder = new MultipartRequestFlowBuilder();
1190 mprFlowRequestBuilder.setTableId(arg0.getTableId().getValue());
1191 mprFlowRequestBuilder.setOutPort(OFConstants.OFPP_ANY);
1192 mprFlowRequestBuilder.setOutGroup(OFConstants.OFPG_ANY);
1193 mprFlowRequestBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
1194 mprFlowRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
1196 if(version == OFConstants.OFP_VERSION_1_0){
1197 LOG.info("Target node is running openflow version 1.0");
1198 FlowWildcardsV10 wildCard = new FlowWildcardsV10(true,true,true,true,true,true,true,true,true,true);
1199 mprFlowRequestBuilder.setMatchV10(new MatchV10Builder().setWildcards(wildCard).build());
1201 if(version == OFConstants.OFP_VERSION_1_3){
1202 LOG.info("Target node is running openflow version 1.3+");
1203 mprFlowRequestBuilder.setMatch(new MatchBuilder().setType(OxmMatchType.class).build());
1207 //Set request body to main multipart request
1208 multipartRequestFlowCaseBuilder.setMultipartRequestFlow(mprFlowRequestBuilder.build());
1209 mprInput.setMultipartRequestBody(multipartRequestFlowCaseBuilder.build());
1211 //Send the request, no cookies associated, use any connection
1212 LOG.debug("Send flow statistics request to the switch :{}",mprFlowRequestBuilder);
1213 this.messageService.multipartRequest(mprInput.build(), null);
1215 // Prepare rpc return output. Set xid and send it back.
1216 LOG.debug("Return results and transaction id back to caller");
1217 GetAllFlowStatisticsFromFlowTableOutputBuilder output =
1218 new GetAllFlowStatisticsFromFlowTableOutputBuilder();
1219 output.setTransactionId(generateTransactionId(xid));
1220 output.setFlowAndStatisticsMapList(null);
1222 Collection<RpcError> errors = Collections.emptyList();
1223 RpcResult<GetAllFlowStatisticsFromFlowTableOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
1224 return Futures.immediateFuture(rpcResult);
1228 public Future<RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput>> getAllFlowsStatisticsFromAllFlowTables(
1229 GetAllFlowsStatisticsFromAllFlowTablesInput arg0) {
1231 //Generate xid to associate it with the request
1232 Long xid = this.getSessionContext().getNextXid();
1234 LOG.info("Prepare statistics request to get flow stats of all switch tables - Transaction id - {}",xid);
1236 // Create multipart request header
1237 MultipartRequestInputBuilder mprInput = new MultipartRequestInputBuilder();
1238 mprInput.setType(MultipartType.OFPMPFLOW);
1239 mprInput.setVersion(version);
1240 mprInput.setXid(xid);
1241 mprInput.setFlags(new MultipartRequestFlags(false));
1243 // Create multipart request body for fetch all the group stats
1244 MultipartRequestFlowCaseBuilder multipartRequestFlowCaseBuilder = new MultipartRequestFlowCaseBuilder();
1245 MultipartRequestFlowBuilder mprFlowRequestBuilder = new MultipartRequestFlowBuilder();
1246 mprFlowRequestBuilder.setTableId(OFConstants.OFPTT_ALL);
1247 mprFlowRequestBuilder.setOutPort(OFConstants.OFPP_ANY);
1248 mprFlowRequestBuilder.setOutGroup(OFConstants.OFPG_ANY);
1249 mprFlowRequestBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
1250 mprFlowRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
1251 mprFlowRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
1253 //TODO: repeating code
1254 if(version == OFConstants.OFP_VERSION_1_0){
1255 FlowWildcardsV10 wildCard = new FlowWildcardsV10(true,true,true,true,true,true,true,true,true,true);
1256 mprFlowRequestBuilder.setMatchV10(new MatchV10Builder().setWildcards(wildCard).build());
1258 if(version == OFConstants.OFP_VERSION_1_3){
1259 mprFlowRequestBuilder.setMatch(new MatchBuilder().setType(OxmMatchType.class).build());
1261 //Set request body to main multipart request
1262 multipartRequestFlowCaseBuilder.setMultipartRequestFlow(mprFlowRequestBuilder.build());
1263 mprInput.setMultipartRequestBody(multipartRequestFlowCaseBuilder.build());
1265 //Send the request, no cookies associated, use any connection
1266 LOG.debug("Send flow statistics request to the switch :{}",mprFlowRequestBuilder);
1267 this.messageService.multipartRequest(mprInput.build(), null);
1269 // Prepare rpc return output. Set xid and send it back.
1270 GetAllFlowsStatisticsFromAllFlowTablesOutputBuilder output =
1271 new GetAllFlowsStatisticsFromAllFlowTablesOutputBuilder();
1272 output.setTransactionId(generateTransactionId(xid));
1273 output.setFlowAndStatisticsMapList(null);
1275 Collection<RpcError> errors = Collections.emptyList();
1276 RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
1277 return Futures.immediateFuture(rpcResult);
1282 public Future<RpcResult<GetFlowStatisticsFromFlowTableOutput>> getFlowStatisticsFromFlowTable(
1283 GetFlowStatisticsFromFlowTableInput arg0) {
1284 //Generate xid to associate it with the request
1285 Long xid = this.getSessionContext().getNextXid();
1287 LOG.info("Prepare statistics request to get stats for flow {} for switch tables {} - Transaction id - {}"
1288 ,arg0.getMatch().toString(),arg0.getTableId(),xid);
1290 // Create multipart request header
1291 MultipartRequestInputBuilder mprInput = new MultipartRequestInputBuilder();
1292 mprInput.setType(MultipartType.OFPMPFLOW);
1293 mprInput.setVersion(version);
1294 mprInput.setXid(xid);
1295 mprInput.setFlags(new MultipartRequestFlags(false));
1297 // Create multipart request body for fetch all the group stats
1298 MultipartRequestFlowCaseBuilder multipartRequestFlowCaseBuilder = new MultipartRequestFlowCaseBuilder();
1299 MultipartRequestFlowBuilder mprFlowRequestBuilder = new MultipartRequestFlowBuilder();
1300 mprFlowRequestBuilder.setTableId(arg0.getTableId());
1301 mprFlowRequestBuilder.setOutPort(arg0.getOutPort().longValue());
1302 mprFlowRequestBuilder.setOutGroup(OFConstants.OFPG_ANY);
1303 mprFlowRequestBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
1304 mprFlowRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
1306 // convert and inject match
1307 MatchReactor.getInstance().convert(arg0.getMatch(), version, mprFlowRequestBuilder);
1308 //TODO: repeating code
1309 if(version == OFConstants.OFP_VERSION_1_3){
1310 mprFlowRequestBuilder.setCookie(arg0.getCookie());
1311 mprFlowRequestBuilder.setCookieMask(arg0.getCookieMask());
1312 mprFlowRequestBuilder.setOutGroup(arg0.getOutGroup());
1315 //Set request body to main multipart request
1316 multipartRequestFlowCaseBuilder.setMultipartRequestFlow(mprFlowRequestBuilder.build());
1317 mprInput.setMultipartRequestBody(multipartRequestFlowCaseBuilder.build());
1319 //Send the request, no cookies associated, use any connection
1320 LOG.debug("Send flow statistics request to the switch :{}",mprFlowRequestBuilder);
1321 this.messageService.multipartRequest(mprInput.build(), null);
1323 // Prepare rpc return output. Set xid and send it back.
1324 GetFlowStatisticsFromFlowTableOutputBuilder output =
1325 new GetFlowStatisticsFromFlowTableOutputBuilder();
1326 output.setTransactionId(generateTransactionId(xid));
1327 output.setFlowAndStatisticsMapList(null);
1329 Collection<RpcError> errors = Collections.emptyList();
1330 RpcResult<GetFlowStatisticsFromFlowTableOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
1331 return Futures.immediateFuture(rpcResult);
1335 public Future<RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>> getAggregateFlowStatisticsFromFlowTableForAllFlows(
1336 GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput arg0) {
1337 //Generate xid to associate it with the request
1338 Long xid = this.getSessionContext().getNextXid();
1340 LOG.info("Prepare aggregate flow statistics request to get aggregate flow stats for all the flow installed on switch table {} - Transaction id - {}"
1341 ,arg0.getTableId().getValue(),xid);
1343 // Create multipart request header
1344 MultipartRequestInputBuilder mprInput = new MultipartRequestInputBuilder();
1345 mprInput.setType(MultipartType.OFPMPAGGREGATE);
1346 mprInput.setVersion(version);
1347 mprInput.setXid(xid);
1348 mprInput.setFlags(new MultipartRequestFlags(false));
1350 // Create multipart request body for fetch all the group stats
1351 MultipartRequestAggregateCaseBuilder multipartRequestAggregateCaseBuilder = new MultipartRequestAggregateCaseBuilder ();
1352 MultipartRequestAggregateBuilder mprAggregateRequestBuilder = new MultipartRequestAggregateBuilder();
1353 mprAggregateRequestBuilder.setTableId(arg0.getTableId().getValue());
1354 mprAggregateRequestBuilder.setOutPort(OFConstants.OFPP_ANY);
1355 mprAggregateRequestBuilder.setOutGroup(OFConstants.OFPG_ANY);
1356 mprAggregateRequestBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
1357 mprAggregateRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
1359 //TODO: repeating code
1360 if(version == OFConstants.OFP_VERSION_1_0){
1361 FlowWildcardsV10 wildCard = new FlowWildcardsV10(true,true,true,true,true,true,true,true,true,true);
1362 mprAggregateRequestBuilder.setMatchV10(new MatchV10Builder().setWildcards(wildCard).build());
1364 if(version == OFConstants.OFP_VERSION_1_3){
1365 mprAggregateRequestBuilder.setMatch(new MatchBuilder().setType(OxmMatchType.class).build());
1369 //Set request body to main multipart request
1370 multipartRequestAggregateCaseBuilder.setMultipartRequestAggregate(mprAggregateRequestBuilder.build());
1371 mprInput.setMultipartRequestBody(multipartRequestAggregateCaseBuilder.build());
1373 //Send the request, no cookies associated, use any connection
1374 LOG.debug("Send request to the switch :{}",multipartRequestAggregateCaseBuilder.build().toString());
1375 this.messageService.multipartRequest(mprInput.build(), null);
1377 // Prepare rpc return output. Set xid and send it back.
1378 GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutputBuilder output =
1379 new GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutputBuilder();
1380 output.setTransactionId(generateTransactionId(xid));
1382 Collection<RpcError> errors = Collections.emptyList();
1383 RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
1384 return Futures.immediateFuture(rpcResult);
1388 public Future<RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>> getAggregateFlowStatisticsFromFlowTableForGivenMatch(
1389 GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput arg0) {
1391 //Generate xid to associate it with the request
1392 Long xid = this.getSessionContext().getNextXid();
1394 LOG.debug("Prepare agregate statistics request to get aggregate stats for flows matching {} and installed in flow tables {} - Transaction id - {}"
1395 ,arg0.getMatch().toString(),arg0.getTableId(),xid);
1397 // Create multipart request header
1398 MultipartRequestInputBuilder mprInput = new MultipartRequestInputBuilder();
1399 mprInput.setType(MultipartType.OFPMPAGGREGATE);
1400 mprInput.setVersion(version);
1401 mprInput.setXid(xid);
1402 mprInput.setFlags(new MultipartRequestFlags(false));
1404 // Create multipart request body for fetch all the group stats
1405 MultipartRequestAggregateCaseBuilder multipartRequestAggregateCaseBuilder = new MultipartRequestAggregateCaseBuilder ();
1406 MultipartRequestAggregateBuilder mprAggregateRequestBuilder = new MultipartRequestAggregateBuilder();
1407 mprAggregateRequestBuilder.setTableId(arg0.getTableId());
1408 mprAggregateRequestBuilder.setOutPort(arg0.getOutPort().longValue());
1409 mprAggregateRequestBuilder.setOutGroup(OFConstants.OFPG_ANY);
1410 mprAggregateRequestBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
1411 mprAggregateRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
1414 MatchReactor.getInstance().convert(arg0.getMatch(), version, mprAggregateRequestBuilder);
1415 //TODO: repeating code
1416 if(version == OFConstants.OFP_VERSION_1_3){
1417 mprAggregateRequestBuilder.setCookie(arg0.getCookie());
1418 mprAggregateRequestBuilder.setCookieMask(arg0.getCookieMask());
1419 mprAggregateRequestBuilder.setOutGroup(arg0.getOutGroup());
1422 //Set request body to main multipart request
1423 multipartRequestAggregateCaseBuilder.setMultipartRequestAggregate(mprAggregateRequestBuilder.build());
1424 mprInput.setMultipartRequestBody(multipartRequestAggregateCaseBuilder.build());
1426 //Send the request, no cookies associated, use any connection
1427 LOG.debug("Send request to the switch :{}",multipartRequestAggregateCaseBuilder.build().toString());
1428 this.messageService.multipartRequest(mprInput.build(), null);
1430 // Prepare rpc return output. Set xid and send it back.
1431 GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder output =
1432 new GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder();
1433 output.setTransactionId(generateTransactionId(xid));
1435 Collection<RpcError> errors = Collections.emptyList();
1436 RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
1437 return Futures.immediateFuture(rpcResult);
1441 public Future<RpcResult<GetFlowTablesStatisticsOutput>> getFlowTablesStatistics(GetFlowTablesStatisticsInput arg0) {
1442 //Generate xid to associate it with the request
1443 Long xid = this.getSessionContext().getNextXid();
1445 LOG.info("Prepare flow table statistics request to get flow table stats for all tables " +
1446 "from node {}- Transaction id - {}",arg0.getNode(),xid);
1448 // Create multipart request header
1449 MultipartRequestInputBuilder mprInput = new MultipartRequestInputBuilder();
1450 mprInput.setType(MultipartType.OFPMPTABLE);
1451 mprInput.setVersion(version);
1452 mprInput.setXid(xid);
1453 mprInput.setFlags(new MultipartRequestFlags(false));
1455 // Create multipart request body for fetch all the group stats
1456 MultipartRequestTableCaseBuilder multipartRequestTableCaseBuilder = new MultipartRequestTableCaseBuilder ();
1457 MultipartRequestTableBuilder multipartRequestTableBuilder = new MultipartRequestTableBuilder();
1458 multipartRequestTableBuilder.setEmpty(true);
1459 multipartRequestTableCaseBuilder.setMultipartRequestTable(multipartRequestTableBuilder.build());
1461 //Set request body to main multipart request
1462 mprInput.setMultipartRequestBody(multipartRequestTableCaseBuilder.build());
1464 //Send the request, no cookies associated, use any connection
1465 LOG.debug("Send request to the switch :{}",multipartRequestTableCaseBuilder.build().toString());
1466 this.messageService.multipartRequest(mprInput.build(), null);
1468 // Prepare rpc return output. Set xid and send it back.
1469 GetFlowTablesStatisticsOutputBuilder output = new GetFlowTablesStatisticsOutputBuilder();
1470 output.setTransactionId(generateTransactionId(xid));
1472 Collection<RpcError> errors = Collections.emptyList();
1473 RpcResult<GetFlowTablesStatisticsOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
1474 return Futures.immediateFuture(rpcResult);
1478 public Future<RpcResult<GetAllQueuesStatisticsFromAllPortsOutput>> getAllQueuesStatisticsFromAllPorts(
1479 GetAllQueuesStatisticsFromAllPortsInput arg0) {
1480 //Generate xid to associate it with the request
1481 Long xid = this.getSessionContext().getNextXid();
1483 LOG.info("Prepare queue statistics request to collect stats for all queues attached to all the ports of node {} - TrasactionId - {}",arg0.getNode().getValue(),xid);
1485 // Create multipart request header
1486 MultipartRequestInputBuilder mprInput = new MultipartRequestInputBuilder();
1487 mprInput.setType(MultipartType.OFPMPQUEUE);
1488 mprInput.setVersion(version);
1489 mprInput.setXid(xid);
1490 mprInput.setFlags(new MultipartRequestFlags(false));
1492 // Create multipart request body to fetch stats for all the port of the node
1493 MultipartRequestQueueCaseBuilder caseBuilder = new MultipartRequestQueueCaseBuilder();
1494 MultipartRequestQueueBuilder mprQueueBuilder = new MultipartRequestQueueBuilder();
1496 mprQueueBuilder.setPortNo(OFConstants.OFPP_ANY);
1497 //Select all the ports
1498 mprQueueBuilder.setQueueId(OFConstants.OFPQ_ANY);
1500 caseBuilder.setMultipartRequestQueue(mprQueueBuilder.build());
1502 //Set request body to main multipart request
1503 mprInput.setMultipartRequestBody(caseBuilder.build());
1505 //Send the request, no cookies associated, use any connection
1506 LOG.debug("Send queue statistics request :{}",mprQueueBuilder.build().toString());
1507 this.messageService.multipartRequest(mprInput.build(), null);
1509 // Prepare rpc return output. Set xid and send it back.
1510 GetAllQueuesStatisticsFromAllPortsOutputBuilder output = new GetAllQueuesStatisticsFromAllPortsOutputBuilder();
1511 output.setTransactionId(generateTransactionId(xid));
1512 output.setQueueIdAndStatisticsMap(null);
1514 Collection<RpcError> errors = Collections.emptyList();
1515 RpcResult<GetAllQueuesStatisticsFromAllPortsOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
1516 return Futures.immediateFuture(rpcResult);
1520 public Future<RpcResult<GetAllQueuesStatisticsFromGivenPortOutput>> getAllQueuesStatisticsFromGivenPort(
1521 GetAllQueuesStatisticsFromGivenPortInput arg0) {
1522 //Generate xid to associate it with the request
1523 Long xid = this.getSessionContext().getNextXid();
1525 LOG.info("Prepare queue statistics request to collect stats for " +
1526 "all queues attached to given port {} of node {} - TrasactionId - {}",arg0.getNodeConnectorId().toString(),arg0.getNode().getValue(),xid);
1528 // Create multipart request header
1529 MultipartRequestInputBuilder mprInput = new MultipartRequestInputBuilder();
1530 mprInput.setType(MultipartType.OFPMPQUEUE);
1531 mprInput.setVersion(version);
1532 mprInput.setXid(xid);
1533 mprInput.setFlags(new MultipartRequestFlags(false));
1535 // Create multipart request body to fetch stats for all the port of the node
1536 MultipartRequestQueueCaseBuilder caseBuilder = new MultipartRequestQueueCaseBuilder();
1537 MultipartRequestQueueBuilder mprQueueBuilder = new MultipartRequestQueueBuilder();
1539 mprQueueBuilder.setQueueId(OFConstants.OFPQ_ANY);
1540 //Select specific port
1541 mprQueueBuilder.setPortNo(InventoryDataServiceUtil.portNumberfromNodeConnectorId(arg0.getNodeConnectorId()));
1543 caseBuilder.setMultipartRequestQueue(mprQueueBuilder.build());
1545 //Set request body to main multipart request
1546 mprInput.setMultipartRequestBody(caseBuilder.build());
1548 //Send the request, no cookies associated, use any connection
1549 LOG.debug("Send queue statistics request :{}",mprQueueBuilder.build().toString());
1550 this.messageService.multipartRequest(mprInput.build(), null);
1552 // Prepare rpc return output. Set xid and send it back.
1553 GetAllQueuesStatisticsFromGivenPortOutputBuilder output = new GetAllQueuesStatisticsFromGivenPortOutputBuilder();
1554 output.setTransactionId(generateTransactionId(xid));
1555 output.setQueueIdAndStatisticsMap(null);
1557 Collection<RpcError> errors = Collections.emptyList();
1558 RpcResult<GetAllQueuesStatisticsFromGivenPortOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
1559 return Futures.immediateFuture(rpcResult);
1563 public Future<RpcResult<GetQueueStatisticsFromGivenPortOutput>> getQueueStatisticsFromGivenPort(
1564 GetQueueStatisticsFromGivenPortInput arg0) {
1565 //Generate xid to associate it with the request
1566 Long xid = this.getSessionContext().getNextXid();
1568 LOG.info("Prepare queue statistics request to collect stats for " +
1569 "given queue attached to given port {} of node {} - TrasactionId - {}",arg0.getQueueId().toString(),arg0.getNodeConnectorId().toString(),arg0.getNode().getValue(),xid);
1571 // Create multipart request header
1572 MultipartRequestInputBuilder mprInput = new MultipartRequestInputBuilder();
1573 mprInput.setType(MultipartType.OFPMPQUEUE);
1574 mprInput.setVersion(version);
1575 mprInput.setXid(xid);
1576 mprInput.setFlags(new MultipartRequestFlags(false));
1578 // Create multipart request body to fetch stats for all the port of the node
1579 MultipartRequestQueueCaseBuilder caseBuilder = new MultipartRequestQueueCaseBuilder();
1580 MultipartRequestQueueBuilder mprQueueBuilder = new MultipartRequestQueueBuilder();
1581 //Select specific queue
1582 mprQueueBuilder.setQueueId(arg0.getQueueId().getValue());
1583 //Select specific port
1584 mprQueueBuilder.setPortNo(InventoryDataServiceUtil.portNumberfromNodeConnectorId(arg0.getNodeConnectorId()));
1586 caseBuilder.setMultipartRequestQueue(mprQueueBuilder.build());
1588 //Set request body to main multipart request
1589 mprInput.setMultipartRequestBody(caseBuilder.build());
1591 //Send the request, no cookies associated, use any connection
1592 LOG.debug("Send queue statistics request :{}",mprQueueBuilder.build().toString());
1593 this.messageService.multipartRequest(mprInput.build(), null);
1595 // Prepare rpc return output. Set xid and send it back.
1596 GetQueueStatisticsFromGivenPortOutputBuilder output = new GetQueueStatisticsFromGivenPortOutputBuilder();
1597 output.setTransactionId(generateTransactionId(xid));
1598 output.setQueueIdAndStatisticsMap(null);
1600 Collection<RpcError> errors = Collections.emptyList();
1601 RpcResult<GetQueueStatisticsFromGivenPortOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
1602 return Futures.immediateFuture(rpcResult);
1606 public Future<RpcResult<GetAllFlowStatisticsOutput>> getAllFlowStatistics(GetAllFlowStatisticsInput arg0) {
1607 //TODO: Depricated, need to clean it up. Sal-Compatibility layes is dependent on it.
1608 // Once sal-compatibility layer is fixed this rpc call can be removed from yang file
1613 public Future<RpcResult<GetAllNodeConnectorStatisticsOutput>> getAllNodeConnectorStatistics(
1614 GetAllNodeConnectorStatisticsInput arg0) {
1615 // TODO Auto-generated method stub
1620 public Future<RpcResult<GetFlowStatisticsOutput>> getFlowStatistics(GetFlowStatisticsInput arg0) {
1621 //TODO: Depricated, need to clean it up. Sal-Compatibility layes is dependent on it.
1622 // Once sal-compatibility layer is fixed this rpc call can be removed from yang file
1627 public Future<RpcResult<GetFlowTableStatisticsOutput>> getFlowTableStatistics(GetFlowTableStatisticsInput arg0) {
1628 // TODO Auto-generated method stub
1633 public Future<RpcResult<GetNodeConnectorStatisticsOutput>> getNodeConnectorStatistics(
1634 GetNodeConnectorStatisticsInput arg0) {
1635 // TODO Auto-generated method stub