@@ -0,0 +1,1335 @@
+package cz.cuni.mff.d3s.spl.sources;%0A%0Aimport java.lang.management.ManagementFactory;%0Aimport java.lang.management.OperatingSystemMXBean;%0A%0Aimport cz.cuni.mff.d3s.spl.core.Data;%0Aimport cz.cuni.mff.d3s.spl.core.StatisticSnapshot;%0A%0A/** Data source representing current system load.%0A * %0A */%0Apublic class SystemLoad implements Data %7B%0A%0A%09public static final SystemLoad INSTANCE = new SystemLoad();%0A%09%0A%09private OperatingSystemMXBean osMxBean;%0A%09%0A%09private SystemLoad() %7B%0A%09%09osMxBean = ManagementFactory.getOperatingSystemMXBean();%0A%09%7D%0A%09%0A%09@Override%0A%09public StatisticSnapshot getStatisticSnapshot() %7B%0A%09%09double load = osMxBean.getSystemLoadAverage();%0A%09%09if (load %3C 0) %7B%0A%09%09%09load = 0.1; // FIXME: what to do with this%0A%09%09%7D%0A%09%09return new LoadStatistics(load);%0A%09%7D%0A%0A%09@Override%0A%09public void addValue(long when, long value) %7B%0A%09%09throw new UnsupportedOperationException();%0A%09%7D%0A%0A%09@Override%0A%09public void __clear() %7B%0A%09%09/* Do nothing. */%0A%09%7D%0A%09%0A%09private class LoadStatistics implements StatisticSnapshot %7B%0A%09%09private double mean;%0A%09%09%0A%09%09public LoadStatistics(double load) %7B%0A%09%09%09mean = load;%0A%09%09%7D%0A%0A%09%09@Override%0A%09%09public double getArithmeticMean() %7B%0A%09%09%09return mean;%0A%09%09%7D%0A%0A%09%09@Override%0A%09%09public long getSampleCount() %7B%0A%09%09%09return 1000; // FIXME%0A%09%09%7D%0A%0A%09%09@Override%0A%09%09public long%5B%5D getSamples() %7B%0A%09%09%09throw new UnsupportedOperationException(%22Original samples not available.%22);%0A%09%09%7D%0A%09%09%0A%09%7D%0A%7D%0A

Add data source for system load