Search in sources :

Example 1 with Utilization

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);
    }
}
Also used : MetaStoreException(org.smartdata.metastore.MetaStoreException) Utilization(org.smartdata.model.Utilization) StorageCapacity(org.smartdata.model.StorageCapacity) IOException(java.io.IOException)

Example 2 with Utilization

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;
}
Also used : Utilization(org.smartdata.model.Utilization) StorageCapacity(org.smartdata.model.StorageCapacity) ArrayList(java.util.ArrayList)

Example 3 with Utilization

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;
}
Also used : Utilization(org.smartdata.model.Utilization) Random(java.util.Random) ArrayList(java.util.ArrayList)

Aggregations

Utilization (org.smartdata.model.Utilization)3 ArrayList (java.util.ArrayList)2 StorageCapacity (org.smartdata.model.StorageCapacity)2 IOException (java.io.IOException)1 Random (java.util.Random)1 MetaStoreException (org.smartdata.metastore.MetaStoreException)1