use of org.smartdata.model.StorageCapacity in project SSM by Intel-bigdata.
the class TestStorageHistoryDao method testInsertGetStorageTable.
@Test
public void testInsertGetStorageTable() throws Exception {
StorageCapacity[] storageCapacities = new StorageCapacity[3];
storageCapacities[0] = new StorageCapacity("type1", 1000L, 10L, 1L);
storageCapacities[1] = new StorageCapacity("type1", 2000L, 10L, 2L);
storageCapacities[2] = new StorageCapacity("type1", 3000L, 10L, 3L);
storageHistDao.insertStorageHistTable(storageCapacities, 1000);
List<StorageCapacity> capacities = storageHistDao.getStorageHistoryData("type1", 1000, 1000, 3000);
Assert.assertTrue(capacities.size() == storageCapacities.length);
Assert.assertEquals(storageCapacities.length, storageHistDao.getNumberOfStorageHistoryData("type1", 1000));
storageHistDao.deleteOldRecords("type1", 1000, 1000L);
Assert.assertEquals(storageCapacities.length - 1, storageHistDao.getNumberOfStorageHistoryData("type1", 1000));
}
use of org.smartdata.model.StorageCapacity in project SSM by Intel-bigdata.
the class TestStorageDao method testInsertGetStorageTable.
@Test
public void testInsertGetStorageTable() throws Exception {
StorageCapacity[] storageCapacities = new StorageCapacity[2];
storageCapacities[0] = new StorageCapacity("type1", 1L, 1L);
storageCapacities[1] = new StorageCapacity("type2", 2L, 2L);
storageDao.insertUpdateStoragesTable(storageCapacities);
Assert.assertTrue(storageDao.getStorageCapacity("type1").equals(storageCapacities[0]));
Map<String, StorageCapacity> map = storageDao.getStorageTablesItem();
Assert.assertTrue(map.get("type2").equals(storageCapacities[1]));
}
use of org.smartdata.model.StorageCapacity 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.StorageCapacity in project SSM by Intel-bigdata.
the class StorageHistoryDao method getStorageHistoryData.
public List<StorageCapacity> getStorageHistoryData(String type, long interval, long startTime, long endTime) {
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
String sql = "SELECT * FROM storage_hist WHERE type = ? AND " + "time_stamp BETWEEN ? AND ?";
List<StorageCapacity> data = jdbcTemplate.query(sql, new Object[] { type + "-" + interval, startTime, endTime }, new StorageHistoryRowMapper());
for (StorageCapacity sc : data) {
sc.setType(type);
}
return data;
}
use of org.smartdata.model.StorageCapacity 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;
}
Aggregations