use of org.smartdata.model.StorageCapacity in project SSM by Intel-bigdata.
the class TestMetaStore method testInsertStoragesTable.
@Test
public void testInsertStoragesTable() throws Exception {
StorageCapacity storage1 = new StorageCapacity("Flash", 12343333L, 2223333L);
StorageCapacity storage2 = new StorageCapacity("RAM", 12342233L, 2223663L);
StorageCapacity[] storages = { storage1, storage2 };
metaStore.insertUpdateStoragesTable(storages);
StorageCapacity storageCapacity1 = metaStore.getStorageCapacity("Flash");
StorageCapacity storageCapacity2 = metaStore.getStorageCapacity("RAM");
Assert.assertTrue(storageCapacity1.equals(storage1));
Assert.assertTrue(storageCapacity2.equals(storage2));
Assert.assertTrue(metaStore.updateStoragesTable("Flash", 123456L, 4562233L));
Assert.assertTrue(metaStore.getStorageCapacity("Flash").getCapacity() == 123456L);
}
use of org.smartdata.model.StorageCapacity in project SSM by Intel-bigdata.
the class TestMetaStore method testGetStorageCapacity.
@Test
public void testGetStorageCapacity() throws Exception {
StorageCapacity storage1 = new StorageCapacity("HDD", 12343333L, 2223333L);
StorageCapacity storage2 = new StorageCapacity("RAM", 12342233L, 2223663L);
StorageCapacity[] storages = { storage1, storage2 };
metaStore.insertUpdateStoragesTable(storages);
Assert.assertTrue(metaStore.getStorageCapacity("HDD").equals(storage1));
Assert.assertTrue(metaStore.getStorageCapacity("RAM").equals(storage2));
StorageCapacity storage3 = new StorageCapacity("HDD", 100L, 10L);
metaStore.insertUpdateStoragesTable(storage3);
Assert.assertTrue(metaStore.getStorageCapacity("HDD").equals(storage3));
}
use of org.smartdata.model.StorageCapacity in project SSM by Intel-bigdata.
the class StorageDao method getStorageTablesItem.
public Map<String, StorageCapacity> getStorageTablesItem() {
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
String sql = "SELECT * FROM storage";
List<StorageCapacity> list = jdbcTemplate.query(sql, new RowMapper<StorageCapacity>() {
public StorageCapacity mapRow(ResultSet rs, int rowNum) throws SQLException {
return new StorageCapacity(rs.getString("type"), rs.getLong("time_stamp"), rs.getLong("capacity"), rs.getLong("free"));
}
});
Map<String, StorageCapacity> map = new HashMap<>();
for (StorageCapacity s : list) {
map.put(s.getType(), s);
}
return map;
}
use of org.smartdata.model.StorageCapacity in project SSM by Intel-bigdata.
the class StorageDao method getStorageCapacity.
public StorageCapacity getStorageCapacity(String type) {
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
String sql = "SELECT * FROM storage WHERE type = ?";
return jdbcTemplate.queryForObject(sql, new Object[] { type }, new RowMapper<StorageCapacity>() {
public StorageCapacity mapRow(ResultSet rs, int rowNum) throws SQLException {
return new StorageCapacity(rs.getString("type"), rs.getLong("time_stamp"), rs.getLong("capacity"), rs.getLong("free"));
}
});
}
Aggregations