finished stats service
Change-Id: Ic1edef3e9cabefb2cbfdd8eecc465b3fa7f96bd9
Showing
1 changed file
with
35 additions
and
1 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,19 +67,54 @@ public class StatisticManager implements StatisticService { | ... | @@ -68,19 +67,54 @@ public class StatisticManager implements StatisticService { |
68 | 67 | ||
69 | @Override | 68 | @Override |
70 | public Link max(Path path) { | 69 | public Link max(Path path) { |
70 | + if (path.links().isEmpty()) { | ||
71 | return null; | 71 | return null; |
72 | } | 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; | ||
83 | + } | ||
73 | 84 | ||
74 | @Override | 85 | @Override |
75 | public Link min(Path path) { | 86 | public Link min(Path path) { |
87 | + if (path.links().isEmpty()) { | ||
76 | return null; | 88 | return null; |
77 | } | 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; | ||
100 | + } | ||
78 | 101 | ||
79 | @Override | 102 | @Override |
80 | public FlowRule highestHitter(ConnectPoint connectPoint) { | 103 | public FlowRule highestHitter(ConnectPoint connectPoint) { |
104 | + Set<FlowEntry> hitters = statisticStore.getCurrentStatistic(connectPoint); | ||
105 | + if (hitters.isEmpty()) { | ||
81 | return null; | 106 | return null; |
82 | } | 107 | } |
83 | 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; | ||
116 | + } | ||
117 | + | ||
84 | private Load loadInternal(ConnectPoint connectPoint) { | 118 | private Load loadInternal(ConnectPoint connectPoint) { |
85 | Set<FlowEntry> current; | 119 | Set<FlowEntry> current; |
86 | Set<FlowEntry> previous; | 120 | Set<FlowEntry> previous; | ... | ... |
-
Please register or login to post a comment