Search in sources :

Example 1 with Load

use of org.onosproject.net.statistic.Load in project onos by opennetworkinglab.

the class GetStatisticsCommand method doExecute.

@Override
protected void doExecute() {
    StatisticService service = get(StatisticService.class);
    DeviceId ingressDeviceId = deviceId(getDeviceId(connectPoint));
    PortNumber ingressPortNumber = portNumber(getPortNumber(connectPoint));
    ConnectPoint cp = new ConnectPoint(ingressDeviceId, ingressPortNumber);
    Load load = service.load(cp);
    print("Load on %s -> %s", cp, load);
}
Also used : Load(org.onosproject.net.statistic.Load) DeviceId(org.onosproject.net.DeviceId) StatisticService(org.onosproject.net.statistic.StatisticService) PortNumber(org.onosproject.net.PortNumber) ConnectPoint(org.onosproject.net.ConnectPoint)

Example 2 with Load

use of org.onosproject.net.statistic.Load in project onos by opennetworkinglab.

the class FlowStatisticManager method loadSummaryPortInternal.

private SummaryFlowEntryWithLoad loadSummaryPortInternal(ConnectPoint cp) {
    checkPermission(STATISTIC_READ);
    Set<FlowEntry> currentStats;
    Set<FlowEntry> previousStats;
    TypedStatistics typedStatistics;
    synchronized (statisticStore) {
        currentStats = statisticStore.getCurrentStatistic(cp);
        if (currentStats == null) {
            return new SummaryFlowEntryWithLoad(cp, new DefaultLoad());
        }
        previousStats = statisticStore.getPreviousStatistic(cp);
        if (previousStats == null) {
            return new SummaryFlowEntryWithLoad(cp, new DefaultLoad());
        }
        // copy to local flow entry
        typedStatistics = new TypedStatistics(currentStats, previousStats);
        // Check for validity of this stats data
        checkLoadValidity(currentStats, previousStats);
    }
    // current and previous set is not empty!
    Set<FlowEntry> currentSet = typedStatistics.current();
    Set<FlowEntry> previousSet = typedStatistics.previous();
    PollInterval pollIntervalInstance = PollInterval.getInstance();
    // We assume that default pollInterval is flowPollFrequency in case adaptiveFlowSampling is true or false
    Load totalLoad = new DefaultLoad(aggregateBytesSet(currentSet), aggregateBytesSet(previousSet), pollIntervalInstance.getPollInterval());
    Map<FlowRule, FlowEntry> currentMap;
    Map<FlowRule, FlowEntry> previousMap;
    currentMap = typedStatistics.currentImmediate();
    previousMap = typedStatistics.previousImmediate();
    Load immediateLoad = new DefaultLoad(aggregateBytesMap(currentMap), aggregateBytesMap(previousMap), pollIntervalInstance.getPollInterval());
    currentMap = typedStatistics.currentShort();
    previousMap = typedStatistics.previousShort();
    Load shortLoad = new DefaultLoad(aggregateBytesMap(currentMap), aggregateBytesMap(previousMap), pollIntervalInstance.getPollInterval());
    currentMap = typedStatistics.currentMid();
    previousMap = typedStatistics.previousMid();
    Load midLoad = new DefaultLoad(aggregateBytesMap(currentMap), aggregateBytesMap(previousMap), pollIntervalInstance.getMidPollInterval());
    currentMap = typedStatistics.currentLong();
    previousMap = typedStatistics.previousLong();
    Load longLoad = new DefaultLoad(aggregateBytesMap(currentMap), aggregateBytesMap(previousMap), pollIntervalInstance.getLongPollInterval());
    currentMap = typedStatistics.currentUnknown();
    previousMap = typedStatistics.previousUnknown();
    Load unknownLoad = new DefaultLoad(aggregateBytesMap(currentMap), aggregateBytesMap(previousMap), pollIntervalInstance.getPollInterval());
    return new SummaryFlowEntryWithLoad(cp, totalLoad, immediateLoad, shortLoad, midLoad, longLoad, unknownLoad);
}
Also used : DefaultLoad(org.onosproject.net.statistic.DefaultLoad) Load(org.onosproject.net.statistic.Load) SummaryFlowEntryWithLoad(org.onosproject.net.statistic.SummaryFlowEntryWithLoad) TypedFlowEntryWithLoad(org.onosproject.net.statistic.TypedFlowEntryWithLoad) FlowEntryWithLoad(org.onosproject.net.statistic.FlowEntryWithLoad) PollInterval(org.onosproject.net.statistic.PollInterval) SummaryFlowEntryWithLoad(org.onosproject.net.statistic.SummaryFlowEntryWithLoad) FlowRule(org.onosproject.net.flow.FlowRule) FlowEntry(org.onosproject.net.flow.FlowEntry) DefaultTypedFlowEntry(org.onosproject.net.flow.DefaultTypedFlowEntry) DefaultFlowEntry(org.onosproject.net.flow.DefaultFlowEntry) TypedStoredFlowEntry(org.onosproject.net.flow.TypedStoredFlowEntry) StoredFlowEntry(org.onosproject.net.flow.StoredFlowEntry) DefaultLoad(org.onosproject.net.statistic.DefaultLoad)

Example 3 with Load

use of org.onosproject.net.statistic.Load in project onos by opennetworkinglab.

the class FlowStatisticManager method typedFlowEntryLoadByInstInternal.

private List<FlowEntryWithLoad> typedFlowEntryLoadByInstInternal(ConnectPoint cp, Map<FlowRule, FlowEntry> currentMap, Map<FlowRule, FlowEntry> previousMap, boolean isAllInstType, Instruction.Type instType) {
    List<FlowEntryWithLoad> fel = new ArrayList<>();
    currentMap.values().forEach(fe -> {
        if (isAllInstType || fe.treatment().allInstructions().stream().filter(i -> i.type() == instType).findAny().isPresent()) {
            long currentBytes = fe.bytes();
            long previousBytes = previousMap.getOrDefault(fe, new DefaultFlowEntry(fe)).bytes();
            long liveTypePollInterval = getLiveTypePollInterval(fe.liveType());
            Load fLoad = new DefaultLoad(currentBytes, previousBytes, liveTypePollInterval);
            fel.add(new FlowEntryWithLoad(cp, fe, fLoad));
        }
    });
    return fel;
}
Also used : SummaryFlowEntryWithLoad(org.onosproject.net.statistic.SummaryFlowEntryWithLoad) TypedFlowEntryWithLoad(org.onosproject.net.statistic.TypedFlowEntryWithLoad) FlowEntryWithLoad(org.onosproject.net.statistic.FlowEntryWithLoad) Comparators(org.onosproject.utils.Comparators) PortNumber(org.onosproject.net.PortNumber) DeviceService(org.onosproject.net.device.DeviceService) AppGuard.checkPermission(org.onosproject.security.AppGuard.checkPermission) FlowEntry(org.onosproject.net.flow.FlowEntry) DefaultLoad(org.onosproject.net.statistic.DefaultLoad) PollInterval(org.onosproject.net.statistic.PollInterval) DefaultTypedFlowEntry(org.onosproject.net.flow.DefaultTypedFlowEntry) HashMap(java.util.HashMap) ConnectPoint(org.onosproject.net.ConnectPoint) Load(org.onosproject.net.statistic.Load) ArrayList(java.util.ArrayList) SummaryFlowEntryWithLoad(org.onosproject.net.statistic.SummaryFlowEntryWithLoad) Component(org.osgi.service.component.annotations.Component) Port(org.onosproject.net.Port) Map(java.util.Map) Activate(org.osgi.service.component.annotations.Activate) DefaultFlowEntry(org.onosproject.net.flow.DefaultFlowEntry) ImmutableSet(com.google.common.collect.ImmutableSet) Logger(org.slf4j.Logger) Device(org.onosproject.net.Device) Deactivate(org.osgi.service.component.annotations.Deactivate) Instruction(org.onosproject.net.flow.instructions.Instruction) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) MoreObjects(com.google.common.base.MoreObjects) TypedFlowEntryWithLoad(org.onosproject.net.statistic.TypedFlowEntryWithLoad) Set(java.util.Set) FlowEntryWithLoad(org.onosproject.net.statistic.FlowEntryWithLoad) Collectors(java.util.stream.Collectors) FlowStatisticService(org.onosproject.net.statistic.FlowStatisticService) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) Objects(java.util.Objects) List(java.util.List) StatisticStore(org.onosproject.net.statistic.StatisticStore) TreeMap(java.util.TreeMap) Predicate(com.google.common.base.Predicate) FlowRule(org.onosproject.net.flow.FlowRule) LoggerFactory.getLogger(org.slf4j.LoggerFactory.getLogger) TypedStoredFlowEntry(org.onosproject.net.flow.TypedStoredFlowEntry) STATISTIC_READ(org.onosproject.security.AppPermission.Type.STATISTIC_READ) StoredFlowEntry(org.onosproject.net.flow.StoredFlowEntry) Reference(org.osgi.service.component.annotations.Reference) DefaultLoad(org.onosproject.net.statistic.DefaultLoad) Load(org.onosproject.net.statistic.Load) SummaryFlowEntryWithLoad(org.onosproject.net.statistic.SummaryFlowEntryWithLoad) TypedFlowEntryWithLoad(org.onosproject.net.statistic.TypedFlowEntryWithLoad) FlowEntryWithLoad(org.onosproject.net.statistic.FlowEntryWithLoad) DefaultFlowEntry(org.onosproject.net.flow.DefaultFlowEntry) ArrayList(java.util.ArrayList) DefaultLoad(org.onosproject.net.statistic.DefaultLoad)

Example 4 with Load

use of org.onosproject.net.statistic.Load in project onos by opennetworkinglab.

the class PortStatisticsManager method load.

@Override
public Load load(ConnectPoint connectPoint, MetricType metricType) {
    DataPoint c = current.get(connectPoint);
    DataPoint p = previous.get(connectPoint);
    long now = System.currentTimeMillis();
    if (c != null && p != null && (now - c.time < STALE_LIMIT)) {
        if (c.time > p.time + SECOND) {
            long cve = getEgressValue(c.stats, metricType);
            long cvi = getIngressValue(c.stats, metricType);
            long pve = getEgressValue(p.stats, metricType);
            long pvi = getIngressValue(p.stats, metricType);
            // Use max of either Tx or Rx load as the total load of a port
            Load load = null;
            if (cve >= pve) {
                load = new DefaultLoad(cve, pve, (int) (c.time - p.time) / SECOND);
            }
            if (cvi >= pvi) {
                Load rcvLoad = new DefaultLoad(cvi, pvi, (int) (c.time - p.time) / SECOND);
                load = ((load == null) || (rcvLoad.rate() > load.rate())) ? rcvLoad : load;
            }
            return load;
        }
    }
    return null;
}
Also used : DefaultLoad(org.onosproject.net.statistic.DefaultLoad) Load(org.onosproject.net.statistic.Load) DefaultLoad(org.onosproject.net.statistic.DefaultLoad)

Example 5 with Load

use of org.onosproject.net.statistic.Load 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)

Aggregations

Load (org.onosproject.net.statistic.Load)10 DefaultLoad (org.onosproject.net.statistic.DefaultLoad)7 Link (org.onosproject.net.Link)4 ConnectPoint (org.onosproject.net.ConnectPoint)3 Test (org.junit.Test)2 PortNumber (org.onosproject.net.PortNumber)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 StatisticService (org.onosproject.net.statistic.StatisticService)2 SummaryFlowEntryWithLoad (org.onosproject.net.statistic.SummaryFlowEntryWithLoad)2 TypedFlowEntryWithLoad (org.onosproject.net.statistic.TypedFlowEntryWithLoad)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1