use of com.srotya.sidewinder.core.storage.DBMetadata in project sidewinder by srotya.
the class DiskStorageEngine method loadDatabases.
protected void loadDatabases() throws IOException {
for (String dataDir : dataDirs) {
File mdDir = new File(dataDir);
if (!mdDir.exists()) {
return;
}
File[] dbs = mdDir.listFiles();
for (File db : dbs) {
if (!db.isDirectory()) {
continue;
}
Map<String, Measurement> measurementMap = new ConcurrentHashMap<>();
String dbName = db.getName();
databaseMap.put(dbName, measurementMap);
DBMetadata metadata = readMetadata(dbName);
dbMetadataMap.put(dbName, metadata);
logger.info("Loading database:" + dbName);
loadMeasurements(dbName, measurementMap, metadata);
}
}
}
use of com.srotya.sidewinder.core.storage.DBMetadata in project sidewinder by srotya.
the class DiskStorageEngine method getOrCreateDatabase.
@Override
public Map<String, Measurement> getOrCreateDatabase(String dbName) throws IOException {
Map<String, Measurement> measurementMap = databaseMap.get(dbName);
if (measurementMap == null) {
synchronized (databaseMap) {
if ((measurementMap = databaseMap.get(dbName)) == null) {
measurementMap = new ConcurrentHashMap<>();
databaseMap.put(dbName, measurementMap);
createDatabaseDirectory(dbName);
DBMetadata metadata = new DBMetadata();
metadata.setRetentionHours(defaultRetentionHours);
dbMetadataMap.put(dbName, metadata);
saveDBMetadata(dbName, metadata);
logger.info("Created new database:" + dbName + "\t with retention period:" + defaultRetentionHours + " hours");
metricsDbCounter.inc();
}
}
}
return measurementMap;
}
use of com.srotya.sidewinder.core.storage.DBMetadata in project sidewinder by srotya.
the class MemStorageEngine method getOrCreateDatabase.
@Override
public Map<String, Measurement> getOrCreateDatabase(String dbName) {
Map<String, Measurement> measurementMap = databaseMap.get(dbName);
if (measurementMap == null) {
synchronized (databaseMap) {
if ((measurementMap = databaseMap.get(dbName)) == null) {
measurementMap = new ConcurrentHashMap<>();
databaseMap.put(dbName, measurementMap);
DBMetadata metadata = new DBMetadata();
metadata.setRetentionHours(defaultRetentionHours);
dbMetadataMap.put(dbName, metadata);
logger.info("Created new database:" + dbName + "\t with retention period:" + defaultRetentionHours + " hours");
metricsDbCounter.inc();
}
}
}
return measurementMap;
}
Aggregations