finished stats service
Change-Id: Ic1edef3e9cabefb2cbfdd8eecc465b3fa7f96bd9
Showing
1 changed file
with
38 additions
and
4 deletions
| ... | @@ -20,7 +20,6 @@ import org.onlab.onos.net.statistic.Load; | ... | @@ -20,7 +20,6 @@ import org.onlab.onos.net.statistic.Load; |
| 20 | import org.onlab.onos.net.statistic.StatisticService; | 20 | import org.onlab.onos.net.statistic.StatisticService; |
| 21 | import org.onlab.onos.net.statistic.StatisticStore; | 21 | import org.onlab.onos.net.statistic.StatisticStore; |
| 22 | import org.slf4j.Logger; | 22 | import org.slf4j.Logger; |
| 23 | - | ||
| 24 | import java.util.Set; | 23 | import java.util.Set; |
| 25 | 24 | ||
| 26 | import static org.slf4j.LoggerFactory.getLogger; | 25 | import static org.slf4j.LoggerFactory.getLogger; |
| ... | @@ -68,17 +67,52 @@ public class StatisticManager implements StatisticService { | ... | @@ -68,17 +67,52 @@ public class StatisticManager implements StatisticService { |
| 68 | 67 | ||
| 69 | @Override | 68 | @Override |
| 70 | public Link max(Path path) { | 69 | public Link max(Path path) { |
| 71 | - return null; | 70 | + if (path.links().isEmpty()) { |
| 71 | + return null; | ||
| 72 | + } | ||
| 73 | + Load maxLoad = new DefaultLoad(); | ||
| 74 | + Link maxLink = null; | ||
| 75 | + for (Link link : path.links()) { | ||
| 76 | + Load load = loadInternal(link.src()); | ||
| 77 | + if (load.rate() > maxLoad.rate()) { | ||
| 78 | + maxLoad = load; | ||
| 79 | + maxLink = link; | ||
| 80 | + } | ||
| 81 | + } | ||
| 82 | + return maxLink; | ||
| 72 | } | 83 | } |
| 73 | 84 | ||
| 74 | @Override | 85 | @Override |
| 75 | public Link min(Path path) { | 86 | public Link min(Path path) { |
| 76 | - return null; | 87 | + if (path.links().isEmpty()) { |
| 88 | + return null; | ||
| 89 | + } | ||
| 90 | + Load minLoad = new DefaultLoad(); | ||
| 91 | + Link minLink = null; | ||
| 92 | + for (Link link : path.links()) { | ||
| 93 | + Load load = loadInternal(link.src()); | ||
| 94 | + if (load.rate() < minLoad.rate()) { | ||
| 95 | + minLoad = load; | ||
| 96 | + minLink = link; | ||
| 97 | + } | ||
| 98 | + } | ||
| 99 | + return minLink; | ||
| 77 | } | 100 | } |
| 78 | 101 | ||
| 79 | @Override | 102 | @Override |
| 80 | public FlowRule highestHitter(ConnectPoint connectPoint) { | 103 | public FlowRule highestHitter(ConnectPoint connectPoint) { |
| 81 | - return null; | 104 | + Set<FlowEntry> hitters = statisticStore.getCurrentStatistic(connectPoint); |
| 105 | + if (hitters.isEmpty()) { | ||
| 106 | + return null; | ||
| 107 | + } | ||
| 108 | + | ||
| 109 | + FlowEntry max = hitters.iterator().next(); | ||
| 110 | + for (FlowEntry entry : hitters) { | ||
| 111 | + if (entry.bytes() > max.bytes()) { | ||
| 112 | + max = entry; | ||
| 113 | + } | ||
| 114 | + } | ||
| 115 | + return max; | ||
| 82 | } | 116 | } |
| 83 | 117 | ||
| 84 | private Load loadInternal(ConnectPoint connectPoint) { | 118 | private Load loadInternal(ConnectPoint connectPoint) { | ... | ... |
-
Please register or login to post a comment