use of org.smartdata.model.Utilization in project SSM by Intel-bigdata.
the class StatesManager method getStorageUtilization.
public Utilization getStorageUtilization(String resourceName) throws IOException {
try {
long now = System.currentTimeMillis();
if (!resourceName.equals("cache")) {
long capacity = serverContext.getMetaStore().getStoreCapacityOfDifferentStorageType(resourceName);
long free = serverContext.getMetaStore().getStoreFreeOfDifferentStorageType(resourceName);
return new Utilization(now, capacity, capacity - free);
} else {
StorageCapacity storageCapacity = serverContext.getMetaStore().getStorageCapacity("cache");
return new Utilization(now, storageCapacity.getCapacity(), storageCapacity.getCapacity() - storageCapacity.getFree());
}
} catch (MetaStoreException e) {
throw new IOException(e);
}
}
use of org.smartdata.model.Utilization in project SSM by Intel-bigdata.
the class SmartEngine method getHistUtilization.
public List<Utilization> getHistUtilization(String resourceName, long granularity, long begin, long end) throws IOException {
long now = System.currentTimeMillis();
if (begin == end && Math.abs(begin - now) <= 5) {
return Arrays.asList(getUtilization(resourceName));
}
List<StorageCapacity> cs = serverContext.getMetaStore().getStorageHistoryData(resourceName, granularity, begin, end);
List<Utilization> us = new ArrayList<>(cs.size());
for (StorageCapacity c : cs) {
us.add(new Utilization(c.getTimeStamp(), c.getCapacity(), c.getUsed()));
}
return us;
}
use of org.smartdata.model.Utilization in project SSM by Intel-bigdata.
the class SmartEngine method getFackData.
private List<Utilization> getFackData(String resourceName, long granularity, long begin, long end) {
List<Utilization> utils = new ArrayList<>();
long ts = begin;
if (ts % granularity != 0) {
ts += granularity;
ts = (ts / granularity) * granularity;
}
Random rand = new Random(ts);
for (; ts <= end; ts += granularity) {
utils.add(new Utilization(ts, 100, rand.nextInt(100)));
}
return utils;
}
Aggregations