X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=opendaylight%2Fmd-sal%2Fcompatibility%2Fsal-compatibility%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fcompatibility%2Fadsal%2FFlowStatisticsAdapter.java;h=c5cbecabedae35c96eb1fd0cad2ae5059253d074;hb=4eb724db3877173d502ba38c6d83bec780b38bb2;hp=c7af60285abfb819590e2e8dd2004d0d75e6f01c;hpb=07c30f447bd1366ba18e6f0f41ac768a16dbc901;p=controller.git diff --git a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/adsal/FlowStatisticsAdapter.java b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/adsal/FlowStatisticsAdapter.java index c7af60285a..c5cbecabed 100644 --- a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/adsal/FlowStatisticsAdapter.java +++ b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/adsal/FlowStatisticsAdapter.java @@ -1,3 +1,10 @@ +/* + * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ package org.opendaylight.controller.sal.compatibility.adsal; import java.math.BigInteger; @@ -6,7 +13,6 @@ import java.util.List; 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; @@ -57,6 +63,9 @@ import org.opendaylight.yangtools.yang.common.RpcResult; 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); @@ -66,7 +75,7 @@ public class FlowStatisticsAdapter implements OpendaylightFlowStatisticsService, @Override public Future> 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; } @@ -74,13 +83,13 @@ public class FlowStatisticsAdapter implements OpendaylightFlowStatisticsService, @Override public Future> 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> getAllFlowStatisticsFromFlowTable( + public ListenableFuture> getAllFlowStatisticsFromFlowTable( GetAllFlowStatisticsFromFlowTableInput input) { GetAllFlowStatisticsFromFlowTableOutput rpcResultType = null; boolean rpcResultBool = false; @@ -92,7 +101,7 @@ public class FlowStatisticsAdapter implements OpendaylightFlowStatisticsService, 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()); @@ -105,9 +114,9 @@ public class FlowStatisticsAdapter implements OpendaylightFlowStatisticsService, * Essentially this API will return the same result as getAllFlowStatisticsFromFlowTable */ @Override - public Future> getAllFlowsStatisticsFromAllFlowTables( + public ListenableFuture> getAllFlowsStatisticsFromAllFlowTables( GetAllFlowsStatisticsFromAllFlowTablesInput input) { - + GetAllFlowsStatisticsFromAllFlowTablesOutput rpcResultType = null; boolean rpcResultBool = false; @@ -118,7 +127,7 @@ public class FlowStatisticsAdapter implements OpendaylightFlowStatisticsService, 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()); @@ -128,7 +137,7 @@ public class FlowStatisticsAdapter implements OpendaylightFlowStatisticsService, } @Override - public Future> getFlowStatisticsFromFlowTable( + public ListenableFuture> getFlowStatisticsFromFlowTable( GetFlowStatisticsFromFlowTableInput input) { GetFlowStatisticsFromFlowTableOutput rpcResultType = null; boolean rpcResultBool = false; @@ -163,7 +172,7 @@ public class FlowStatisticsAdapter implements OpendaylightFlowStatisticsService, public void nodeConnectorStatisticsUpdated(Node node, List ncStatsList) { NodeConnectorStatisticsUpdateBuilder nodeConnectorStatisticsUpdateBuilder = new NodeConnectorStatisticsUpdateBuilder(); List nodeConnectorStatistics = toOdNodeConnectorStatistics(ncStatsList); - + nodeConnectorStatisticsUpdateBuilder.setNodeConnectorStatisticsAndPortNumberMap(nodeConnectorStatistics); nodeConnectorStatisticsUpdateBuilder.setMoreReplies(false); nodeConnectorStatisticsUpdateBuilder.setTransactionId(null); @@ -173,9 +182,9 @@ public class FlowStatisticsAdapter implements OpendaylightFlowStatisticsService, @Override public void nodeTableStatisticsUpdated(Node node, List tableStatsList) { - - FlowTableStatisticsUpdateBuilder flowTableStatisticsUpdateBuilder = new FlowTableStatisticsUpdateBuilder(); - + + FlowTableStatisticsUpdateBuilder flowTableStatisticsUpdateBuilder = new FlowTableStatisticsUpdateBuilder(); + List flowTableStatistics = toOdFlowTableStatistics(tableStatsList); flowTableStatisticsUpdateBuilder.setFlowTableAndStatisticsMap(flowTableStatistics); flowTableStatisticsUpdateBuilder.setMoreReplies(false); @@ -187,7 +196,7 @@ public class FlowStatisticsAdapter implements OpendaylightFlowStatisticsService, @Override public void descriptionStatisticsUpdated(Node node, NodeDescription nodeDescription) { // TODO which *StatisticsUpdated interface should be used? - + } private List toOdFlowsStatistics(List flowsOnNode) { @@ -227,7 +236,7 @@ public class FlowStatisticsAdapter implements OpendaylightFlowStatisticsService, } private List toOdFlowTableStatistics(List tableStatsList) { - + List flowTableStatsMap = new ArrayList(); for (NodeTableStatistics nodeTableStatistics : tableStatsList) { FlowTableAndStatisticsMapBuilder flowTableAndStatisticsMapBuilder = new FlowTableAndStatisticsMapBuilder(); @@ -238,7 +247,7 @@ public class FlowStatisticsAdapter implements OpendaylightFlowStatisticsService, flowTableAndStatisticsMapBuilder.setTableId(new TableId((short)nodeTableStatistics.getNodeTable().getID())); flowTableStatsMap.add(flowTableAndStatisticsMapBuilder.build()); } - + return flowTableStatsMap; } @@ -247,7 +256,7 @@ public class FlowStatisticsAdapter implements OpendaylightFlowStatisticsService, List nodeConnectorStatisticsList = new ArrayList(); for(NodeConnectorStatistics ofNodeConnectorStatistics : ncStatsList){ NodeConnectorStatisticsAndPortNumberMapBuilder nodeConnectorStatisticsAndPortNumberMapBuilder = new NodeConnectorStatisticsAndPortNumberMapBuilder(); - + nodeConnectorStatisticsAndPortNumberMapBuilder.setBytes(extractBytes(ofNodeConnectorStatistics)); nodeConnectorStatisticsAndPortNumberMapBuilder.setCollisionCount(toBI(ofNodeConnectorStatistics.getCollisionCount())); nodeConnectorStatisticsAndPortNumberMapBuilder.setDuration(null); @@ -261,7 +270,7 @@ public class FlowStatisticsAdapter implements OpendaylightFlowStatisticsService, nodeConnectorStatisticsAndPortNumberMapBuilder.setTransmitErrors(toBI(ofNodeConnectorStatistics.getTransmitErrorCount())); nodeConnectorStatisticsList.add(nodeConnectorStatisticsAndPortNumberMapBuilder.build()); } - + return nodeConnectorStatisticsList; }