import java.util.concurrent.Future;
import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
-import org.opendaylight.controller.sal.common.util.Futures;
-import org.opendaylight.controller.sal.common.util.Rpcs;
import org.opendaylight.controller.sal.compatibility.FromSalConversionsUtils;
import org.opendaylight.controller.sal.compatibility.InventoryMapping;
import org.opendaylight.controller.sal.compatibility.NodeMapping;
import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMapBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId;
import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
+
public class FlowStatisticsAdapter implements OpendaylightFlowStatisticsService, IReadServiceListener{
private static final Logger LOG = LoggerFactory.getLogger(FlowStatisticsAdapter.class);
@Override
public Future<RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>> getAggregateFlowStatisticsFromFlowTableForAllFlows(
GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput input) {
- //TODO: No supported API exist in AD-SAL, it can either be implemented by fetching all the stats of the flows and
+ //TODO: No supported API exist in AD-SAL, it can either be implemented by fetching all the stats of the flows and
// generating aggregate flow statistics out of those individual flow stats.
return null;
}
@Override
public Future<RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>> getAggregateFlowStatisticsFromFlowTableForGivenMatch(
GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput input) {
- //TODO: No supported API exist in AD-SAL, it can either be implemented by fetching all the stats of the flows and
+ //TODO: No supported API exist in AD-SAL, it can either be implemented by fetching all the stats of the flows and
// generating aggregate flow statistics out of those individual flow stats.
return null;
}
@Override
- public Future<RpcResult<GetAllFlowStatisticsFromFlowTableOutput>> getAllFlowStatisticsFromFlowTable(
+ public ListenableFuture<RpcResult<GetAllFlowStatisticsFromFlowTableOutput>> getAllFlowStatisticsFromFlowTable(
GetAllFlowStatisticsFromFlowTableInput input) {
GetAllFlowStatisticsFromFlowTableOutput rpcResultType = null;
boolean rpcResultBool = false;
GetAllFlowStatisticsFromFlowTableOutputBuilder builder = new GetAllFlowStatisticsFromFlowTableOutputBuilder();
builder.setTransactionId(new TransactionId(new BigInteger("0")));
rpcResultType = builder.setFlowAndStatisticsMapList(flowsStatistics).build();
-
+
rpcResultBool = true;
} catch (ConstructionException e) {
LOG.error(e.getMessage());
}
- return Futures.immediateFuture(Rpcs.getRpcResult(rpcResultBool, rpcResultType, null));
+ return Futures.immediateFuture(RpcResultBuilder.<GetAllFlowStatisticsFromFlowTableOutput>
+ status(rpcResultBool).withResult(rpcResultType).build());
}
/**
* Essentially this API will return the same result as getAllFlowStatisticsFromFlowTable
*/
@Override
- public Future<RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput>> getAllFlowsStatisticsFromAllFlowTables(
+ public ListenableFuture<RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput>> getAllFlowsStatisticsFromAllFlowTables(
GetAllFlowsStatisticsFromAllFlowTablesInput input) {
-
+
GetAllFlowsStatisticsFromAllFlowTablesOutput rpcResultType = null;
boolean rpcResultBool = false;
GetAllFlowsStatisticsFromAllFlowTablesOutputBuilder builder = new GetAllFlowsStatisticsFromAllFlowTablesOutputBuilder();
builder.setTransactionId(new TransactionId(new BigInteger("0")));
rpcResultType = builder.setFlowAndStatisticsMapList(flowsStatistics).build();
-
+
rpcResultBool = true;
} catch (ConstructionException e) {
LOG.error(e.getMessage());
}
- return Futures.immediateFuture(Rpcs.getRpcResult(rpcResultBool, rpcResultType, null));
+ return Futures.immediateFuture(RpcResultBuilder.<GetAllFlowsStatisticsFromAllFlowTablesOutput>
+ status(rpcResultBool).withResult(rpcResultType).build());
}
@Override
- public Future<RpcResult<GetFlowStatisticsFromFlowTableOutput>> getFlowStatisticsFromFlowTable(
+ public ListenableFuture<RpcResult<GetFlowStatisticsFromFlowTableOutput>> getFlowStatisticsFromFlowTable(
GetFlowStatisticsFromFlowTableInput input) {
GetFlowStatisticsFromFlowTableOutput rpcResultType = null;
boolean rpcResultBool = false;
LOG.error(e.getMessage());
}
- return Futures.immediateFuture(Rpcs.getRpcResult(rpcResultBool, rpcResultType, null));
+ return Futures.immediateFuture(RpcResultBuilder.<GetFlowStatisticsFromFlowTableOutput>
+ status(rpcResultBool).withResult(rpcResultType).build());
}
@Override
public void nodeConnectorStatisticsUpdated(Node node, List<NodeConnectorStatistics> ncStatsList) {
NodeConnectorStatisticsUpdateBuilder nodeConnectorStatisticsUpdateBuilder = new NodeConnectorStatisticsUpdateBuilder();
List<NodeConnectorStatisticsAndPortNumberMap> nodeConnectorStatistics = toOdNodeConnectorStatistics(ncStatsList);
-
+
nodeConnectorStatisticsUpdateBuilder.setNodeConnectorStatisticsAndPortNumberMap(nodeConnectorStatistics);
nodeConnectorStatisticsUpdateBuilder.setMoreReplies(false);
nodeConnectorStatisticsUpdateBuilder.setTransactionId(null);
@Override
public void nodeTableStatisticsUpdated(Node node, List<NodeTableStatistics> tableStatsList) {
-
- FlowTableStatisticsUpdateBuilder flowTableStatisticsUpdateBuilder = new FlowTableStatisticsUpdateBuilder();
-
+
+ FlowTableStatisticsUpdateBuilder flowTableStatisticsUpdateBuilder = new FlowTableStatisticsUpdateBuilder();
+
List<FlowTableAndStatisticsMap> flowTableStatistics = toOdFlowTableStatistics(tableStatsList);
flowTableStatisticsUpdateBuilder.setFlowTableAndStatisticsMap(flowTableStatistics);
flowTableStatisticsUpdateBuilder.setMoreReplies(false);
@Override
public void descriptionStatisticsUpdated(Node node, NodeDescription nodeDescription) {
// TODO which *StatisticsUpdated interface should be used?
-
+
}
private List<FlowAndStatisticsMapList> toOdFlowsStatistics(List<FlowOnNode> flowsOnNode) {
}
private List<FlowTableAndStatisticsMap> toOdFlowTableStatistics(List<NodeTableStatistics> tableStatsList) {
-
+
List<FlowTableAndStatisticsMap> flowTableStatsMap = new ArrayList<FlowTableAndStatisticsMap>();
for (NodeTableStatistics nodeTableStatistics : tableStatsList) {
FlowTableAndStatisticsMapBuilder flowTableAndStatisticsMapBuilder = new FlowTableAndStatisticsMapBuilder();
flowTableAndStatisticsMapBuilder.setTableId(new TableId((short)nodeTableStatistics.getNodeTable().getID()));
flowTableStatsMap.add(flowTableAndStatisticsMapBuilder.build());
}
-
+
return flowTableStatsMap;
}
List<NodeConnectorStatisticsAndPortNumberMap> nodeConnectorStatisticsList = new ArrayList<NodeConnectorStatisticsAndPortNumberMap>();
for(NodeConnectorStatistics ofNodeConnectorStatistics : ncStatsList){
NodeConnectorStatisticsAndPortNumberMapBuilder nodeConnectorStatisticsAndPortNumberMapBuilder = new NodeConnectorStatisticsAndPortNumberMapBuilder();
-
+
nodeConnectorStatisticsAndPortNumberMapBuilder.setBytes(extractBytes(ofNodeConnectorStatistics));
nodeConnectorStatisticsAndPortNumberMapBuilder.setCollisionCount(toBI(ofNodeConnectorStatistics.getCollisionCount()));
nodeConnectorStatisticsAndPortNumberMapBuilder.setDuration(null);
nodeConnectorStatisticsAndPortNumberMapBuilder.setTransmitErrors(toBI(ofNodeConnectorStatistics.getTransmitErrorCount()));
nodeConnectorStatisticsList.add(nodeConnectorStatisticsAndPortNumberMapBuilder.build());
}
-
+
return nodeConnectorStatisticsList;
}