404f5abcf7f68fba56b59e621f61ae58cc791ef8
[openflowplugin.git] / openflowplugin / src / main / java / org / opendaylight / openflowplugin / openflow / md / core / sal / ModelDrivenSwitchImpl.java
1 /**
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.openflowplugin.openflow.md.core.sal;
9
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;
16
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;
202
203 import com.google.common.util.concurrent.Futures;
204
205 /**
206  * RPC implementation of MD-switch
207  */
208 public class ModelDrivenSwitchImpl extends AbstractModelDrivenSwitch {
209
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;
215
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();
222     }
223
224     
225     @Override
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);
231
232         // For Flow provisioning, the SwitchConnectionDistinguisher is set to null so
233         // the request can be routed through any connection to the switch
234
235         SwitchConnectionDistinguisher cookie = null ;
236         if (input.isBarrier()) {
237             Future<RpcResult<BarrierOutput>> barrierOFLib = messageService.barrier(barrierInput.build(), cookie);
238         }       
239
240         LOG.debug("Calling the FlowMod RPC method on MessageDispatchService");
241         Future<RpcResult<UpdateFlowOutput>> resultFromOFLib = messageService.flowMod(ofFlowModInput, cookie) ;
242
243         RpcResult<UpdateFlowOutput> rpcResultFromOFLib = null ;
244
245         try {
246                 rpcResultFromOFLib = resultFromOFLib.get();
247         } catch( Exception ex ) {
248                 LOG.error( " Error while getting result for AddFlow RPC" + ex.getMessage());
249         }
250
251         UpdateFlowOutput updateFlowOutput = rpcResultFromOFLib.getResult() ;
252
253         AddFlowOutputBuilder addFlowOutput = new AddFlowOutputBuilder() ;
254         addFlowOutput.setTransactionId(updateFlowOutput.getTransactionId()) ;
255         AddFlowOutput result = addFlowOutput.build();
256
257         Collection<RpcError> errors = rpcResultFromOFLib.getErrors() ;
258         RpcResult<AddFlowOutput> rpcResult = Rpcs.getRpcResult(true, result, errors);
259
260         LOG.debug("Returning the Add Flow RPC result to MD-SAL");
261         return Futures.immediateFuture(rpcResult);
262     }
263
264     @Override
265     public Future<RpcResult<AddGroupOutput>> addGroup(AddGroupInput input) {
266         // Convert the AddGroupInput to GroupModInput
267         GroupModInput ofGroupModInput = GroupConvertor.toGroupModInput(input, version);
268
269
270         // For Flow provisioning, the SwitchConnectionDistinguisher is set to null so
271         // the request can be routed through any connection to the switch
272
273         SwitchConnectionDistinguisher cookie = null ;
274
275         LOG.debug("Calling the GroupMod RPC method on MessageDispatchService");
276         Future<RpcResult<UpdateGroupOutput>> resultFromOFLib = messageService.groupMod(ofGroupModInput, cookie) ;
277
278         RpcResult<UpdateGroupOutput> rpcResultFromOFLib = null ;
279
280         try {
281                 rpcResultFromOFLib = resultFromOFLib.get();
282         } catch( Exception ex ) {
283                 LOG.error( " Error while getting result for AddGroup RPC" + ex.getMessage());
284         }
285
286         UpdateGroupOutput updateGroupOutput = rpcResultFromOFLib.getResult() ;
287
288         AddGroupOutputBuilder addGroupOutput = new AddGroupOutputBuilder() ;
289         addGroupOutput.setTransactionId(updateGroupOutput.getTransactionId()) ;
290         AddGroupOutput result = addGroupOutput.build();
291
292         Collection<RpcError> errors = rpcResultFromOFLib.getErrors() ;
293         RpcResult<AddGroupOutput> rpcResult = Rpcs.getRpcResult(true, result, errors);
294
295         LOG.debug("Returning the Add Group RPC result to MD-SAL");
296         return Futures.immediateFuture(rpcResult);
297     }
298
299     @Override
300     public Future<RpcResult<AddMeterOutput>> addMeter(AddMeterInput input) {
301         // Convert the AddMeterInput to MeterModInput
302         MeterModInput ofMeterModInput = MeterConvertor.toMeterModInput(input, version);
303
304         // For Meter provisioning, the SwitchConnectionDistinguisher is set to null so
305         // the request can be routed through any connection to the switch
306
307         SwitchConnectionDistinguisher cookie = null ;
308
309         LOG.debug("Calling the MeterMod RPC method on MessageDispatchService");
310         Future<RpcResult<UpdateMeterOutput>> resultFromOFLib = messageService.meterMod(ofMeterModInput, cookie) ;
311
312         RpcResult<UpdateMeterOutput> rpcResultFromOFLib = null ;
313
314         try {
315                 rpcResultFromOFLib = resultFromOFLib.get();
316         } catch( Exception ex ) {
317                 LOG.error( " Error while getting result for AddMeter RPC" + ex.getMessage());
318         }
319
320         UpdateMeterOutput updateMeterOutput = rpcResultFromOFLib.getResult() ;
321
322         AddMeterOutputBuilder addMeterOutput = new AddMeterOutputBuilder() ;
323         addMeterOutput.setTransactionId(updateMeterOutput.getTransactionId()) ;
324         AddMeterOutput result = addMeterOutput.build();
325
326         Collection<RpcError> errors = rpcResultFromOFLib.getErrors() ;
327         RpcResult<AddMeterOutput> rpcResult = Rpcs.getRpcResult(true, result, errors);
328
329         LOG.debug("Returning the Add Meter RPC result to MD-SAL");
330         return Futures.immediateFuture(rpcResult);
331     }
332
333     @Override
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);
339
340         // For Flow provisioning, the SwitchConnectionDistinguisher is set to null so
341         // the request can be routed through any connection to the switch
342
343         SwitchConnectionDistinguisher cookie = null ;
344         if (input.isBarrier()) {
345             Future<RpcResult<BarrierOutput>> barrierOFLib = messageService.barrier(barrierInput.build(), cookie);
346         }
347         
348         LOG.debug("Calling the FlowMod RPC method on MessageDispatchService");
349         Future<RpcResult<UpdateFlowOutput>> resultFromOFLib = messageService.flowMod(ofFlowModInput, cookie) ;
350
351         RpcResult<UpdateFlowOutput> rpcResultFromOFLib = null ;
352
353         try {
354                 rpcResultFromOFLib = resultFromOFLib.get();
355         } catch( Exception ex ) {
356                 LOG.error( " Error while getting result for remove Flow RPC" + ex.getMessage());
357         }
358
359         UpdateFlowOutput updateFlowOutput = rpcResultFromOFLib.getResult() ;
360
361         RemoveFlowOutputBuilder removeFlowOutput = new RemoveFlowOutputBuilder() ;
362         removeFlowOutput.setTransactionId(updateFlowOutput.getTransactionId()) ;
363         RemoveFlowOutput result = removeFlowOutput.build();
364
365         Collection<RpcError> errors = rpcResultFromOFLib.getErrors() ;
366         RpcResult<RemoveFlowOutput> rpcResult = Rpcs.getRpcResult(true, result, errors);
367
368         LOG.debug("Returning the Remove Flow RPC result to MD-SAL");
369         return Futures.immediateFuture(rpcResult);
370     }
371
372     @Override
373     public Future<RpcResult<RemoveGroupOutput>> removeGroup(
374             RemoveGroupInput input) {
375         // Convert the RemoveGroupInput to GroupModInput
376         GroupModInput ofGroupModInput = GroupConvertor.toGroupModInput(input, version);
377
378
379         // For Flow provisioning, the SwitchConnectionDistinguisher is set to null so
380         // the request can be routed through any connection to the switch
381
382         SwitchConnectionDistinguisher cookie = null ;
383
384         LOG.debug("Calling the GroupMod RPC method on MessageDispatchService");
385         Future<RpcResult<UpdateGroupOutput>> resultFromOFLib = messageService.groupMod(ofGroupModInput, cookie) ;
386
387         RpcResult<UpdateGroupOutput> rpcResultFromOFLib = null ;
388
389         try {
390                 rpcResultFromOFLib = resultFromOFLib.get();
391         } catch( Exception ex ) {
392                 LOG.error( " Error while getting result for RemoveGroup RPC" + ex.getMessage());
393         }
394
395         UpdateGroupOutput updateGroupOutput = rpcResultFromOFLib.getResult() ;
396
397         RemoveGroupOutputBuilder removeGroupOutput = new RemoveGroupOutputBuilder() ;
398         removeGroupOutput.setTransactionId(updateGroupOutput.getTransactionId()) ;
399         RemoveGroupOutput result = removeGroupOutput.build();
400
401         Collection<RpcError> errors = rpcResultFromOFLib.getErrors() ;
402         RpcResult<RemoveGroupOutput> rpcResult = Rpcs.getRpcResult(true, result, errors);
403
404         LOG.debug("Returning the Remove Group RPC result to MD-SAL");
405         return Futures.immediateFuture(rpcResult);
406     }
407
408     @Override
409     public Future<RpcResult<RemoveMeterOutput>> removeMeter(
410             RemoveMeterInput input) {
411         // Convert the RemoveMeterInput to MeterModInput
412         MeterModInput ofMeterModInput = MeterConvertor.toMeterModInput(input, version);
413
414
415         // For Meter provisioning, the SwitchConnectionDistinguisher is set to null so
416         // the request can be routed through any connection to the switch
417
418         SwitchConnectionDistinguisher cookie = null ;
419
420         LOG.debug("Calling the MeterMod RPC method on MessageDispatchService");
421         Future<RpcResult<UpdateMeterOutput>> resultFromOFLib = messageService.meterMod(ofMeterModInput, cookie) ;
422
423         RpcResult<UpdateMeterOutput> rpcResultFromOFLib = null ;
424
425         try {
426                 rpcResultFromOFLib = resultFromOFLib.get();
427         } catch( Exception ex ) {
428                 LOG.error( " Error while getting result for RemoveMeter RPC" + ex.getMessage());
429         }
430
431         UpdateMeterOutput updatemeterOutput = rpcResultFromOFLib.getResult() ;
432
433         RemoveMeterOutputBuilder removeMeterOutput = new RemoveMeterOutputBuilder() ;
434         removeMeterOutput.setTransactionId(updatemeterOutput.getTransactionId()) ;
435         RemoveMeterOutput result = removeMeterOutput.build();
436
437         Collection<RpcError> errors = rpcResultFromOFLib.getErrors() ;
438         RpcResult<RemoveMeterOutput> rpcResult = Rpcs.getRpcResult(true, result, errors);
439
440         LOG.debug("Returning the Remove Meter RPC result to MD-SAL");
441         return Futures.immediateFuture(rpcResult);
442     }
443
444     @Override
445     public Future<RpcResult<Void>> transmitPacket(TransmitPacketInput input) {
446         LOG.info("TransmitPacket - {}",input);
447         // Convert TransmitPacket to PacketOutInput
448         
449         // TODO VD create PacketConvertor and move convert logic there
450         
451         // Build Port ID from TransmitPacketInput.Ingress
452         PortNumber inPortNr = null;
453         
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);
461         } else {
462             // TODO Ed could by in this way or Exception or something else ?
463             inPortNr = new PortNumber(0xfffffffdL);
464         }
465         
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;
469         
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);
479         } else {
480             new Exception("PORT NR not exist in Egress"); //TODO : P4 search for some normal exception
481         }
482         
483         // TODO VD P! wait for way to move Actions (e.g. augmentation)
484         
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());
498         
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         // --------------------------------------------------------
507         
508         PacketOutInput message = builder.build();
509         
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 ;
513         
514         LOG.debug("Calling the transmitPacket RPC method");
515         return messageService.packetOut(message, cookie);
516     }
517
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()));
524
525         return target;
526     }
527
528     private Match toMatch(
529             org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match match) {
530         MatchBuilder target = new MatchBuilder();
531
532         target.setMatchEntries(toMatchEntries(match));
533
534         return null;
535     }
536
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<>();
540
541         return null;
542     }
543
544     @Override
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
551
552         // For Flow provisioning, the SwitchConnectionDistinguisher is set to null so
553         // the request can be routed through any connection to the switch
554
555         SwitchConnectionDistinguisher cookie = null ;
556         if (input.getUpdatedFlow().isBarrier()) {
557             Future<RpcResult<BarrierOutput>> barrierOFLib = messageService.barrier(barrierInput.build(), cookie);
558         }
559         
560         LOG.debug("Calling the FlowMod RPC method on MessageDispatchService");
561         Future<RpcResult<UpdateFlowOutput>> resultFromOFLib = messageService.flowMod(ofFlowModInput, cookie) ;
562
563         RpcResult<UpdateFlowOutput> rpcResultFromOFLib = null ;
564
565         try {
566                 rpcResultFromOFLib = resultFromOFLib.get();
567         } catch( Exception ex ) {
568                 LOG.error( " Error while getting result for UpdateFlow RPC" + ex.getMessage());
569         }
570
571         UpdateFlowOutput updateFlowOutputOFLib = rpcResultFromOFLib.getResult() ;
572
573         UpdateFlowOutputBuilder updateFlowOutput = new UpdateFlowOutputBuilder() ;
574         updateFlowOutput.setTransactionId(updateFlowOutputOFLib.getTransactionId()) ;
575         UpdateFlowOutput result = updateFlowOutput.build();
576
577         Collection<RpcError> errors = rpcResultFromOFLib.getErrors() ;
578         RpcResult<UpdateFlowOutput> rpcResult = Rpcs.getRpcResult(true, result, errors);
579
580         LOG.debug("Returning the Update Flow RPC result to MD-SAL");
581         return Futures.immediateFuture(rpcResult);
582     }
583
584     @Override
585     public Future<RpcResult<UpdateGroupOutput>> updateGroup(
586             UpdateGroupInput input) {
587         // Convert the UpdateGroupInput to GroupModInput
588         GroupModInput ofGroupModInput = GroupConvertor.toGroupModInput(input.getUpdatedGroup(), version);
589
590
591         // For Flow provisioning, the SwitchConnectionDistinguisher is set to null so
592         // the request can be routed through any connection to the switch
593
594         SwitchConnectionDistinguisher cookie = null ;
595
596         LOG.debug("Calling the GroupMod RPC method on MessageDispatchService");
597         Future<RpcResult<UpdateGroupOutput>> resultFromOFLib = messageService.groupMod(ofGroupModInput, cookie) ;
598
599         RpcResult<UpdateGroupOutput> rpcResultFromOFLib = null ;
600
601         try {
602                 rpcResultFromOFLib = resultFromOFLib.get();
603         } catch( Exception ex ) {
604                 LOG.error( " Error while getting result for updateGroup RPC" + ex.getMessage());
605         }
606
607         UpdateGroupOutput updateGroupOutputOFLib = rpcResultFromOFLib.getResult() ;
608
609         UpdateGroupOutputBuilder updateGroupOutput = new UpdateGroupOutputBuilder() ;
610         updateGroupOutput.setTransactionId(updateGroupOutputOFLib.getTransactionId()) ;
611         UpdateGroupOutput result = updateGroupOutput.build();
612
613         Collection<RpcError> errors = rpcResultFromOFLib.getErrors() ;
614         RpcResult<UpdateGroupOutput> rpcResult = Rpcs.getRpcResult(true, result, errors);
615
616         LOG.debug("Returning the Update Group RPC result to MD-SAL");
617         return Futures.immediateFuture(rpcResult);
618     }
619
620     @Override
621     public Future<RpcResult<UpdateMeterOutput>> updateMeter(
622             UpdateMeterInput input) {
623         // Convert the UpdateMeterInput to MeterModInput
624         MeterModInput ofMeterModInput = MeterConvertor.toMeterModInput(input.getUpdatedMeter(), version);
625
626
627         // For Meter provisioning, the SwitchConnectionDistinguisher is set to null so
628         // the request can be routed through any connection to the switch
629
630         SwitchConnectionDistinguisher cookie = null ;
631
632         LOG.debug("Calling the MeterMod RPC method on MessageDispatchService");
633         Future<RpcResult<UpdateMeterOutput>> resultFromOFLib = messageService.meterMod(ofMeterModInput, cookie) ;
634
635         RpcResult<UpdateMeterOutput> rpcResultFromOFLib = null ;
636
637         try {
638                 rpcResultFromOFLib = resultFromOFLib.get();
639         } catch( Exception ex ) {
640                 LOG.error( " Error while getting result for UpdateMeter RPC" + ex.getMessage());
641         }
642
643         UpdateMeterOutput updateMeterOutputFromOFLib = rpcResultFromOFLib.getResult() ;
644
645         UpdateMeterOutputBuilder updateMeterOutput = new UpdateMeterOutputBuilder() ;
646         updateMeterOutput.setTransactionId(updateMeterOutputFromOFLib.getTransactionId()) ;
647         UpdateMeterOutput result = updateMeterOutput.build();
648
649         Collection<RpcError> errors = rpcResultFromOFLib.getErrors() ;
650         RpcResult<UpdateMeterOutput> rpcResult = Rpcs.getRpcResult(true, result, errors);
651
652         LOG.debug("Returning the Update Meter RPC result to MD-SAL");
653         return Futures.immediateFuture(rpcResult);
654     }
655
656     @Override
657     public NodeId getNodeId() {
658         return nodeId;
659     }
660
661     /*
662      * Methods for requesting statistics from switch
663      */
664     @Override
665     public Future<RpcResult<GetAllGroupStatisticsOutput>> getAllGroupStatistics(GetAllGroupStatisticsInput input) {
666
667         //Generate xid to associate it with the request
668         Long xid = this.getSessionContext().getNextXid();
669
670         LOG.debug("Prepare statistics request for all the groups - Transaction id - {}",xid);
671
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));
678
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());
684         
685         //Set request body to main multipart request
686         mprInput.setMultipartRequestBody(caseBuilder.build());
687
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);
691
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);
697
698         Collection<RpcError> errors = Collections.emptyList();
699         RpcResult<GetAllGroupStatisticsOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
700         return Futures.immediateFuture(rpcResult);
701
702     }
703
704     @Override
705     public Future<RpcResult<GetGroupDescriptionOutput>> getGroupDescription(GetGroupDescriptionInput input) {
706
707         //Generate xid to associate it with the request
708         Long xid = this.getSessionContext().getNextXid();
709
710         LOG.debug("Prepare group description statistics request - Transaction id - {}",xid);
711
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));
718
719         // Create multipart request body for fetch all the group description stats
720         MultipartRequestGroupDescCaseBuilder mprGroupDescBuild = new MultipartRequestGroupDescCaseBuilder();
721
722         //Set request body to main multipart request
723         mprInput.setMultipartRequestBody(mprGroupDescBuild.build());
724
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);
728
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);
734
735         Collection<RpcError> errors = Collections.emptyList();
736         RpcResult<GetGroupDescriptionOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
737         return Futures.immediateFuture(rpcResult);
738
739     }
740
741     @Override
742     public Future<RpcResult<GetGroupFeaturesOutput>> getGroupFeatures(GetGroupFeaturesInput input) {
743
744         //Generate xid to associate it with the request
745         Long xid = this.getSessionContext().getNextXid();
746
747         LOG.debug("Prepare group features statistics request - Transaction id - {}",xid);
748
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));
755
756         // Create multipart request body for fetch all the group description stats
757         MultipartRequestGroupFeaturesCaseBuilder mprGroupFeaturesBuild = new MultipartRequestGroupFeaturesCaseBuilder();
758
759         //Set request body to main multipart request
760         mprInput.setMultipartRequestBody(mprGroupFeaturesBuild.build());
761
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);
765
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));
770
771         Collection<RpcError> errors = Collections.emptyList();
772         RpcResult<GetGroupFeaturesOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
773         return Futures.immediateFuture(rpcResult);
774     }
775
776     @Override
777     public Future<RpcResult<GetGroupStatisticsOutput>> getGroupStatistics(GetGroupStatisticsInput input) {
778
779         //Generate xid to associate it with the request
780         Long xid = this.getSessionContext().getNextXid();
781
782         LOG.debug("Prepare statistics request for node {} group ({}) - Transaction id - {}",input.getNode(),input.getGroupId(),xid);
783
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));
790
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());
796         
797         //Set request body to main multipart request
798         mprInput.setMultipartRequestBody(caseBuilder.build());
799
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);
803
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);
809
810         Collection<RpcError> errors = Collections.emptyList();
811         RpcResult<GetGroupStatisticsOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
812         return Futures.immediateFuture(rpcResult);
813     }
814
815     @Override
816     public Future<RpcResult<GetAllMeterConfigStatisticsOutput>> getAllMeterConfigStatistics(
817             GetAllMeterConfigStatisticsInput input) {
818
819         //Generate xid to associate it with the request
820         Long xid = this.getSessionContext().getNextXid();
821
822         LOG.debug("Prepare config request for all the meters - Transaction id - {}",xid);
823
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));
830
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());
836         
837         //Set request body to main multipart request
838         mprInput.setMultipartRequestBody(caseBuilder.build());
839
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);
843
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);
849
850         Collection<RpcError> errors = Collections.emptyList();
851         RpcResult<GetAllMeterConfigStatisticsOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
852         return Futures.immediateFuture(rpcResult);
853     }
854
855     @Override
856     public Future<RpcResult<GetAllMeterStatisticsOutput>> getAllMeterStatistics(GetAllMeterStatisticsInput input) {
857
858         //Generate xid to associate it with the request
859         Long xid = this.getSessionContext().getNextXid();
860
861         LOG.debug("Prepare statistics request for all the meters - Transaction id - {}",xid);
862
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));
869
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());
875         
876         //Set request body to main multipart request
877         mprInput.setMultipartRequestBody(caseBuilder.build());
878
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);
882
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);
888
889         Collection<RpcError> errors = Collections.emptyList();
890         RpcResult<GetAllMeterStatisticsOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
891         return Futures.immediateFuture(rpcResult);
892     }
893
894     @Override
895     public Future<RpcResult<GetMeterFeaturesOutput>> getMeterFeatures(GetMeterFeaturesInput input) {
896
897         //Generate xid to associate it with the request
898         Long xid = this.getSessionContext().getNextXid();
899
900         LOG.debug("Prepare features statistics request for all the meters - Transaction id - {}",xid);
901
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));
908
909         // Create multipart request body for fetch all the group description stats
910         MultipartRequestMeterFeaturesCaseBuilder mprMeterFeaturesBuild = new MultipartRequestMeterFeaturesCaseBuilder();
911
912         //Set request body to main multipart request
913         mprInput.setMultipartRequestBody(mprMeterFeaturesBuild.build());
914
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);
918
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));
923
924         Collection<RpcError> errors = Collections.emptyList();
925         RpcResult<GetMeterFeaturesOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
926         return Futures.immediateFuture(rpcResult);
927     }
928
929     @Override
930     public Future<RpcResult<GetMeterStatisticsOutput>> getMeterStatistics(GetMeterStatisticsInput input) {
931         //Generate xid to associate it with the request
932         Long xid = this.getSessionContext().getNextXid();
933
934         LOG.debug("Preprae statistics request for Meter ({}) - Transaction id - {}",input.getMeterId().getValue(),xid);
935
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));
942
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());
949         
950         //Set request body to main multipart request
951         mprInput.setMultipartRequestBody(caseBuilder.build());
952
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);
956
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);
962
963         Collection<RpcError> errors = Collections.emptyList();
964         RpcResult<GetMeterStatisticsOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
965         return Futures.immediateFuture(rpcResult);
966     }
967     
968     @Override
969     public Future<RpcResult<GetAllPortsStatisticsOutput>> getAllPortsStatistics(GetAllPortsStatisticsInput arg0) {
970
971         //Generate xid to associate it with the request
972         Long xid = this.getSessionContext().getNextXid();
973
974         LOG.info("Prepare port statistics request for all ports of node {} - TrasactionId - {}",arg0.getNode().getValue(),xid);
975
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));
982
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();
986         //Select all ports 
987         mprPortStatsBuilder.setPortNo(OFConstants.OFPP_ANY);
988         caseBuilder.setMultipartRequestPortStats(mprPortStatsBuilder.build());
989         
990         //Set request body to main multipart request
991         mprInput.setMultipartRequestBody(caseBuilder.build());
992
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);
996
997         // Prepare rpc return output. Set xid and send it back.
998         GetAllPortsStatisticsOutputBuilder output = new GetAllPortsStatisticsOutputBuilder();
999         output.setTransactionId(generateTransactionId(xid));
1000
1001         Collection<RpcError> errors = Collections.emptyList();
1002         RpcResult<GetAllPortsStatisticsOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
1003         return Futures.immediateFuture(rpcResult);
1004     }
1005
1006     @Override
1007     public Future<RpcResult<GetPortStatisticsOutput>> getPortStatistics(GetPortStatisticsInput arg0) {
1008         //Generate xid to associate it with the request
1009         Long xid = this.getSessionContext().getNextXid();
1010
1011         LOG.info("Prepare port statistics request for port {} of node {} - TrasactionId - {}",arg0.getNodeConnectorId(), arg0.getNode().getValue(),xid);
1012
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));
1019
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();
1023
1024         //Set specific port 
1025         mprPortStatsBuilder.setPortNo(InventoryDataServiceUtil.portNumberfromNodeConnectorId(arg0.getNodeConnectorId()));
1026         caseBuilder.setMultipartRequestPortStats(mprPortStatsBuilder.build());
1027         
1028         //Set request body to main multipart request
1029         mprInput.setMultipartRequestBody(caseBuilder.build());
1030
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);
1034
1035         // Prepare rpc return output. Set xid and send it back.
1036         GetPortStatisticsOutputBuilder output = new GetPortStatisticsOutputBuilder();
1037         output.setTransactionId(generateTransactionId(xid));
1038
1039         Collection<RpcError> errors = Collections.emptyList();
1040         RpcResult<GetPortStatisticsOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
1041         return Futures.immediateFuture(rpcResult);
1042     }
1043
1044     private TransactionId generateTransactionId(Long xid){
1045         String stringXid =xid.toString();
1046         BigInteger bigIntXid = new BigInteger( stringXid );
1047         return new TransactionId(bigIntXid);
1048
1049     }
1050
1051     @Override
1052     public Future<RpcResult<GetPortOutput>> getPort() {
1053         // TODO Auto-generated method stub
1054         return null;
1055     }
1056     
1057
1058     @Override
1059     public Future<RpcResult<UpdatePortOutput>> updatePort(UpdatePortInput input) {
1060         PortModInput ofPortModInput = null ;
1061         RpcResult<UpdatePortOutput> rpcResultFromOFLib = null ;
1062                 
1063                                 
1064         // For Flow provisioning, the SwitchConnectionDistinguisher is set to null so  
1065         // the request can be routed through any connection to the switch
1066         
1067         SwitchConnectionDistinguisher cookie = null ;
1068         
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() ;
1072                 
1073         // Get the Xid. The same Xid has to be sent in all the RPCs
1074         Long Xid = sessionContext.getNextXid();
1075                 
1076         for( Port inputPort : inputPorts) {
1077                    
1078             // Convert the UpdateGroupInput to GroupModInput 
1079             ofPortModInput = PortConvertor.toPortModInput(inputPort, version) ;
1080                                                         
1081             // Insert the Xid ( transaction Id) before calling the RPC on the OFLibrary
1082                         
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()) ;
1094
1095             LOG.debug("Calling the PortMod RPC method on MessageDispatchService");
1096             Future<RpcResult<UpdatePortOutput>> resultFromOFLib = messageService.portMod(ofPortModInput, cookie) ;
1097
1098             try { 
1099                 rpcResultFromOFLib = resultFromOFLib.get();
1100             } catch( Exception ex ) {
1101                 LOG.error( " Error while getting result for updatePort RPC" + ex.getMessage());
1102             }
1103
1104             // The Future response value for all the RPCs except the last one is ignored
1105
1106         }
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() ;
1110         
1111         UpdatePortOutputBuilder updatePortOutput = new UpdatePortOutputBuilder() ;
1112         updatePortOutput.setTransactionId(updatePortOutputOFLib.getTransactionId()) ;
1113         UpdatePortOutput result = updatePortOutput.build();
1114         
1115         Collection<RpcError> errors = rpcResultFromOFLib.getErrors() ;
1116         RpcResult<UpdatePortOutput> rpcResult = Rpcs.getRpcResult(true, result, errors); 
1117         
1118         LOG.debug("Returning the Update Group RPC result to MD-SAL");
1119         return Futures.immediateFuture(rpcResult);
1120
1121     }
1122     
1123     @Override
1124     public Future<RpcResult<UpdateTableOutput>> updateTable(
1125                         UpdateTableInput input) {
1126
1127         // Get the Xid. The same Xid has to be sent in all the Multipart requests
1128         Long xid = this.getSessionContext().getNextXid();
1129
1130         LOG.debug("Prepare the Multipart Table Mod requests for Transaction Id {} ",xid);
1131
1132         // Create multipart request header
1133         MultipartRequestInputBuilder mprInput = new MultipartRequestInputBuilder();
1134         mprInput.setType(MultipartType.OFPMPTABLEFEATURES);
1135         mprInput.setVersion((short)0x04);
1136         mprInput.setXid(xid);
1137
1138         //Convert the list of all MD-SAL table feature object into OF library object
1139         List<TableFeatures> ofTableFeatureList = TableFeaturesConvertor.toTableFeaturesRequest(input.getUpdatedTable()) ;
1140         
1141
1142         MultipartRequestTableFeaturesCaseBuilder caseRequest = new MultipartRequestTableFeaturesCaseBuilder();
1143         MultipartRequestTableFeaturesBuilder tableFeaturesRequest = new MultipartRequestTableFeaturesBuilder();
1144
1145         mprInput.setFlags(new MultipartRequestFlags(true));
1146         
1147         tableFeaturesRequest.setTableFeatures(ofTableFeatureList) ;
1148         
1149         //Set request body to main multipart request
1150         caseRequest.setMultipartRequestTableFeatures(tableFeaturesRequest.build());
1151         mprInput.setMultipartRequestBody(caseRequest.build());
1152
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);
1156         
1157         
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));
1164
1165         Collection<RpcError> errors = Collections.emptyList();
1166         RpcResult<UpdateTableOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
1167         return Futures.immediateFuture(rpcResult);
1168     }
1169
1170     @Override
1171     public Future<RpcResult<GetAllFlowStatisticsFromFlowTableOutput>> getAllFlowStatisticsFromFlowTable(
1172             GetAllFlowStatisticsFromFlowTableInput arg0) {
1173
1174         //Generate xid to associate it with the request
1175         Long xid = this.getSessionContext().getNextXid();
1176
1177         LOG.debug("Prepare statistics request to get flow stats for switch tables {} - Transaction id - {}"
1178                 ,arg0.getTableId().getValue(),xid);
1179
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));
1186
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);
1195         
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());
1200         }
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());
1204         }
1205
1206
1207         //Set request body to main multipart request
1208         multipartRequestFlowCaseBuilder.setMultipartRequestFlow(mprFlowRequestBuilder.build());
1209         mprInput.setMultipartRequestBody(multipartRequestFlowCaseBuilder.build());
1210
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);
1214
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);
1221
1222         Collection<RpcError> errors = Collections.emptyList();
1223         RpcResult<GetAllFlowStatisticsFromFlowTableOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
1224         return Futures.immediateFuture(rpcResult);
1225     }
1226
1227     @Override
1228     public Future<RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput>> getAllFlowsStatisticsFromAllFlowTables(
1229             GetAllFlowsStatisticsFromAllFlowTablesInput arg0) {
1230         
1231         //Generate xid to associate it with the request
1232         Long xid = this.getSessionContext().getNextXid();
1233
1234         LOG.info("Prepare statistics request to get flow stats of all switch tables - Transaction id - {}",xid);
1235
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));
1242
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);
1252         
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());
1257         }
1258         if(version == OFConstants.OFP_VERSION_1_3){
1259             mprFlowRequestBuilder.setMatch(new MatchBuilder().setType(OxmMatchType.class).build());
1260         }
1261         //Set request body to main multipart request
1262         multipartRequestFlowCaseBuilder.setMultipartRequestFlow(mprFlowRequestBuilder.build());
1263         mprInput.setMultipartRequestBody(multipartRequestFlowCaseBuilder.build());
1264
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);
1268
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);
1274
1275         Collection<RpcError> errors = Collections.emptyList();
1276         RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
1277         return Futures.immediateFuture(rpcResult);
1278
1279     }
1280
1281     @Override
1282     public Future<RpcResult<GetFlowStatisticsFromFlowTableOutput>> getFlowStatisticsFromFlowTable(
1283             GetFlowStatisticsFromFlowTableInput arg0) {
1284         //Generate xid to associate it with the request
1285         Long xid = this.getSessionContext().getNextXid();
1286
1287         LOG.info("Prepare statistics request to get stats for flow {} for switch tables {} - Transaction id - {}"
1288                 ,arg0.getMatch().toString(),arg0.getTableId(),xid);
1289
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));
1296
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);
1305
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());
1313         }
1314
1315         //Set request body to main multipart request
1316         multipartRequestFlowCaseBuilder.setMultipartRequestFlow(mprFlowRequestBuilder.build());
1317         mprInput.setMultipartRequestBody(multipartRequestFlowCaseBuilder.build());
1318
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);
1322
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);
1328
1329         Collection<RpcError> errors = Collections.emptyList();
1330         RpcResult<GetFlowStatisticsFromFlowTableOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
1331         return Futures.immediateFuture(rpcResult);
1332     }
1333
1334     @Override
1335     public Future<RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>> getAggregateFlowStatisticsFromFlowTableForAllFlows(
1336             GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput arg0) {
1337         //Generate xid to associate it with the request
1338         Long xid = this.getSessionContext().getNextXid();
1339
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);
1342
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));
1349
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);
1358         
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());
1363         }
1364         if(version == OFConstants.OFP_VERSION_1_3){
1365             mprAggregateRequestBuilder.setMatch(new MatchBuilder().setType(OxmMatchType.class).build());
1366         }
1367
1368
1369         //Set request body to main multipart request
1370         multipartRequestAggregateCaseBuilder.setMultipartRequestAggregate(mprAggregateRequestBuilder.build());
1371         mprInput.setMultipartRequestBody(multipartRequestAggregateCaseBuilder.build());
1372
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);
1376
1377         // Prepare rpc return output. Set xid and send it back.
1378         GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutputBuilder output = 
1379                 new GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutputBuilder();
1380         output.setTransactionId(generateTransactionId(xid));
1381
1382         Collection<RpcError> errors = Collections.emptyList();
1383         RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
1384         return Futures.immediateFuture(rpcResult);
1385     }
1386
1387     @Override
1388     public Future<RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>> getAggregateFlowStatisticsFromFlowTableForGivenMatch(
1389             GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput arg0) {
1390
1391         //Generate xid to associate it with the request
1392         Long xid = this.getSessionContext().getNextXid();
1393
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);
1396
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));
1403
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);
1412
1413
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());
1420         }
1421
1422         //Set request body to main multipart request
1423         multipartRequestAggregateCaseBuilder.setMultipartRequestAggregate(mprAggregateRequestBuilder.build());
1424         mprInput.setMultipartRequestBody(multipartRequestAggregateCaseBuilder.build());
1425
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);
1429
1430         // Prepare rpc return output. Set xid and send it back.
1431         GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder output = 
1432                 new GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder();
1433         output.setTransactionId(generateTransactionId(xid));
1434
1435         Collection<RpcError> errors = Collections.emptyList();
1436         RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
1437         return Futures.immediateFuture(rpcResult);
1438     }
1439
1440     @Override
1441     public Future<RpcResult<GetFlowTablesStatisticsOutput>> getFlowTablesStatistics(GetFlowTablesStatisticsInput arg0) {
1442         //Generate xid to associate it with the request
1443         Long xid = this.getSessionContext().getNextXid();
1444
1445         LOG.info("Prepare flow table statistics request to get flow table stats for all tables " +
1446                         "from node {}- Transaction id - {}",arg0.getNode(),xid);
1447
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));
1454
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());
1460         
1461         //Set request body to main multipart request
1462         mprInput.setMultipartRequestBody(multipartRequestTableCaseBuilder.build());
1463
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);
1467
1468         // Prepare rpc return output. Set xid and send it back.
1469         GetFlowTablesStatisticsOutputBuilder output = new GetFlowTablesStatisticsOutputBuilder();
1470         output.setTransactionId(generateTransactionId(xid));
1471
1472         Collection<RpcError> errors = Collections.emptyList();
1473         RpcResult<GetFlowTablesStatisticsOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
1474         return Futures.immediateFuture(rpcResult);
1475     }
1476
1477     @Override
1478     public Future<RpcResult<GetAllQueuesStatisticsFromAllPortsOutput>> getAllQueuesStatisticsFromAllPorts(
1479             GetAllQueuesStatisticsFromAllPortsInput arg0) {
1480         //Generate xid to associate it with the request
1481         Long xid = this.getSessionContext().getNextXid();
1482
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);
1484
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));
1491
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();
1495         //Select all ports 
1496         mprQueueBuilder.setPortNo(OFConstants.OFPP_ANY);
1497         //Select all the ports
1498         mprQueueBuilder.setQueueId(OFConstants.OFPQ_ANY);
1499         
1500         caseBuilder.setMultipartRequestQueue(mprQueueBuilder.build());
1501         
1502         //Set request body to main multipart request
1503         mprInput.setMultipartRequestBody(caseBuilder.build());
1504
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);
1508
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);
1513
1514         Collection<RpcError> errors = Collections.emptyList();
1515         RpcResult<GetAllQueuesStatisticsFromAllPortsOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
1516         return Futures.immediateFuture(rpcResult);
1517     }
1518
1519     @Override
1520     public Future<RpcResult<GetAllQueuesStatisticsFromGivenPortOutput>> getAllQueuesStatisticsFromGivenPort(
1521             GetAllQueuesStatisticsFromGivenPortInput arg0) {
1522         //Generate xid to associate it with the request
1523         Long xid = this.getSessionContext().getNextXid();
1524
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);
1527
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));
1534
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();
1538         //Select all queues
1539         mprQueueBuilder.setQueueId(OFConstants.OFPQ_ANY);
1540         //Select specific port
1541         mprQueueBuilder.setPortNo(InventoryDataServiceUtil.portNumberfromNodeConnectorId(arg0.getNodeConnectorId()));
1542         
1543         caseBuilder.setMultipartRequestQueue(mprQueueBuilder.build());
1544         
1545         //Set request body to main multipart request
1546         mprInput.setMultipartRequestBody(caseBuilder.build());
1547
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);
1551
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);
1556
1557         Collection<RpcError> errors = Collections.emptyList();
1558         RpcResult<GetAllQueuesStatisticsFromGivenPortOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
1559         return Futures.immediateFuture(rpcResult);
1560     }
1561
1562     @Override
1563     public Future<RpcResult<GetQueueStatisticsFromGivenPortOutput>> getQueueStatisticsFromGivenPort(
1564             GetQueueStatisticsFromGivenPortInput arg0) {
1565         //Generate xid to associate it with the request
1566         Long xid = this.getSessionContext().getNextXid();
1567
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);
1570
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));
1577
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()));
1585         
1586         caseBuilder.setMultipartRequestQueue(mprQueueBuilder.build());
1587         
1588         //Set request body to main multipart request
1589         mprInput.setMultipartRequestBody(caseBuilder.build());
1590
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);
1594
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);
1599
1600         Collection<RpcError> errors = Collections.emptyList();
1601         RpcResult<GetQueueStatisticsFromGivenPortOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
1602         return Futures.immediateFuture(rpcResult);
1603     }
1604
1605     @Override
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 
1609         return null;
1610     }
1611
1612     @Override
1613     public Future<RpcResult<GetAllNodeConnectorStatisticsOutput>> getAllNodeConnectorStatistics(
1614             GetAllNodeConnectorStatisticsInput arg0) {
1615         // TODO Auto-generated method stub
1616         return null;
1617     }
1618
1619     @Override
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 
1623         return null;
1624     }
1625
1626     @Override
1627     public Future<RpcResult<GetFlowTableStatisticsOutput>> getFlowTableStatistics(GetFlowTableStatisticsInput arg0) {
1628         // TODO Auto-generated method stub
1629         return null;
1630     }
1631
1632     @Override
1633     public Future<RpcResult<GetNodeConnectorStatisticsOutput>> getNodeConnectorStatistics(
1634             GetNodeConnectorStatisticsInput arg0) {
1635         // TODO Auto-generated method stub
1636         return null;
1637     }
1638
1639 }