Search in sources :

Example 6 with DefaultLoad

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;
}
Also used : DefaultLoad(org.onosproject.net.statistic.DefaultLoad) Load(org.onosproject.net.statistic.Load) DefaultLoad(org.onosproject.net.statistic.DefaultLoad) Link(org.onosproject.net.Link)

Example 7 with DefaultLoad

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;
}
Also used : DefaultLoad(org.onosproject.net.statistic.DefaultLoad) Load(org.onosproject.net.statistic.Load) DefaultLoad(org.onosproject.net.statistic.DefaultLoad) Link(org.onosproject.net.Link)

Example 8 with DefaultLoad

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));
}
Also used : DefaultLoad(org.onosproject.net.statistic.DefaultLoad) Load(org.onosproject.net.statistic.Load) JsonNode(com.fasterxml.jackson.databind.JsonNode) DefaultLoad(org.onosproject.net.statistic.DefaultLoad) Test(org.junit.Test)

Example 9 with DefaultLoad

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());
}
Also used : DefaultLoad(org.onosproject.net.statistic.DefaultLoad) Load(org.onosproject.net.statistic.Load) DefaultLoad(org.onosproject.net.statistic.DefaultLoad) Test(org.junit.Test) AbstractUiImplTest(org.onosproject.ui.impl.AbstractUiImplTest)

Aggregations

DefaultLoad (org.onosproject.net.statistic.DefaultLoad)9 Load (org.onosproject.net.statistic.Load)7 Test (org.junit.Test)3 Link (org.onosproject.net.Link)2 DefaultFlowEntry (org.onosproject.net.flow.DefaultFlowEntry)2 DefaultTypedFlowEntry (org.onosproject.net.flow.DefaultTypedFlowEntry)2 FlowEntry (org.onosproject.net.flow.FlowEntry)2 FlowRule (org.onosproject.net.flow.FlowRule)2 StoredFlowEntry (org.onosproject.net.flow.StoredFlowEntry)2 TypedStoredFlowEntry (org.onosproject.net.flow.TypedStoredFlowEntry)2 FlowEntryWithLoad (org.onosproject.net.statistic.FlowEntryWithLoad)2 PollInterval (org.onosproject.net.statistic.PollInterval)2 SummaryFlowEntryWithLoad (org.onosproject.net.statistic.SummaryFlowEntryWithLoad)2 TypedFlowEntryWithLoad (org.onosproject.net.statistic.TypedFlowEntryWithLoad)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 MoreObjects (com.google.common.base.MoreObjects)1 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)1 Predicate (com.google.common.base.Predicate)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 ArrayList (java.util.ArrayList)1