use of org.onosproject.net.statistic.DefaultLoad in project onos by opennetworkinglab.
the class StatisticManager method min.
@Override
public Link min(Path path) {
checkPermission(STATISTIC_READ);
if (path.links().isEmpty()) {
return null;
}
Load minLoad = new DefaultLoad();
Link minLink = null;
for (Link link : path.links()) {
Load load = loadInternal(link.src());
if (load.rate() < minLoad.rate()) {
minLoad = load;
minLink = link;
}
}
return minLink;
}
use of org.onosproject.net.statistic.DefaultLoad in project onos by opennetworkinglab.
the class StatisticManager method max.
@Override
public Link max(Path path) {
checkPermission(STATISTIC_READ);
if (path.links().isEmpty()) {
return null;
}
Load maxLoad = new DefaultLoad();
Link maxLink = null;
for (Link link : path.links()) {
Load load = loadInternal(link.src());
if (load.rate() > maxLoad.rate()) {
maxLoad = load;
maxLink = link;
}
}
return maxLink;
}
use of org.onosproject.net.statistic.DefaultLoad in project onos by opennetworkinglab.
the class LoadCodecTest method testLoadEncode.
/**
* Tests encoding of a Load object.
*/
@Test
public void testLoadEncode() {
final long startTime = System.currentTimeMillis();
final Load load = new DefaultLoad(20, 10, 1);
final JsonNode node = new LoadCodec().encode(load, new MockCodecContext());
assertThat(node.get("valid").asBoolean(), is(true));
assertThat(node.get("latest").asLong(), is(20L));
assertThat(node.get("rate").asLong(), is(10L));
assertThat(node.get("time").asLong(), greaterThanOrEqualTo(startTime));
}
use of org.onosproject.net.statistic.DefaultLoad in project onos by opennetworkinglab.
the class TrafficLinkTest method basic.
@Test
public void basic() {
title("basic");
TrafficLink tl = createALink();
Load bigLoad = new DefaultLoad(2000, 0);
tl.addLoad(bigLoad);
print(tl);
assertEquals("bad bytes value", 2000, tl.bytes());
// NOTE: rate is bytes / period (10 seconds)
assertEquals("bad rate value", 200, tl.rate());
// this load does not represent flows
assertEquals("bad flow count", 0, tl.flows());
}
Aggregations