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);
}
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);
}
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;
}
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;
}
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;
}
Aggregations