dbPoolInCache = dbCache.get(dbKey);
if(dbPoolInCache == null) {
File dbFolder = getLocalStorageFolder(tablespace, partition, version);
if(!dbFolder.exists()) {
log.warn("Asked for " + dbFolder + " but it doesn't exist!");
throw new DNodeException(EXCEPTION_ORDINARY, "Requested tablespace (" + tablespace
+ ") + version (" + version + ") is not available.");
}
File metadata = getLocalMetadataFile(tablespace, partition, version);
ThriftReader reader = new ThriftReader(metadata);
PartitionMetadata partitionMetadata = (PartitionMetadata) reader
.read(new PartitionMetadata());
reader.close();
dbPoolInCache = loadManagerInEHCache(tablespace, version, partition, dbFolder, partitionMetadata);
}
}
// Query the {@link SQLite4JavaManager} and return
String result = ((EngineManager) dbPoolInCache.getObjectValue())
.query(query, maxResultsPerQuery);
long time = performanceTool.endQuery();
log.info("serving query [" + tablespace + "]" + " [" + version + "] [" + partition + "] ["
+ query + "] time [" + time + "] OK.");
// double prob = performanceTool.getHistogram().getLeftAccumulatedProbability(time);
// if(prob > 0.95) {
// // slow query!
// log.warn("[SLOW QUERY] Query time over 95 percentil: [" + query + "] time [" + time + "]");
// slowQueries++;
// }
if(time > absoluteSlowQueryLimit) {
// slow query!
log.warn("[SLOW QUERY] Query time over absolute slow query time (" + absoluteSlowQueryLimit
+ ") : [" + query + "] time [" + time + "]");
slowQueries++;
}
return result;
} catch(Throwable e) {
unexpectedException(e);
throw new DNodeException(EXCEPTION_UNEXPECTED, e.getMessage());
}
} catch(DNodeException e) {
log.info("serving query [" + tablespace + "]" + " [" + version + "] [" + partition + "] [" + query
+ "] FAILED [" + e.getMsg() + "]");
failedQueries.incrementAndGet();