use of com.sleepycat.je.EnvironmentStats in project voldemort by voldemort.
the class BdbSplitStorageEngineTest method getMaxCacheUsage.
private long getMaxCacheUsage(EnvironmentConfig environmentConfig, DatabaseConfig databaseConfig) throws DatabaseException {
File dirA = new File(bdbMasterDir + "/" + "storeA");
if (!dirA.exists()) {
dirA.mkdirs();
}
Environment environmentA = new Environment(dirA, environmentConfig);
Database databaseA = environmentA.openDatabase(null, "storeA", databaseConfig);
BdbStorageEngine storeA = BdbStorageEngineTest.makeBdbStorageEngine("storeA", environmentA, databaseA, new BdbRuntimeConfig(), this.prefixPartitionId);
File dirB = new File(bdbMasterDir + "/" + "storeB");
if (!dirB.exists()) {
dirB.mkdirs();
}
Environment environmentB = new Environment(dirB, environmentConfig);
Database databaseB = environmentB.openDatabase(null, "storeB", databaseConfig);
BdbStorageEngine storeB = BdbStorageEngineTest.makeBdbStorageEngine("storeB", environmentB, databaseB, new BdbRuntimeConfig(), this.prefixPartitionId);
long maxCacheUsage = 0;
for (int i = 0; i <= 10000; i++) {
byte[] value = new byte[(int) (CACHE_SIZE / 10000)];
// try to push values in cache
storeA.put(TestUtils.toByteArray(i + "A"), new Versioned<byte[]>(value), null);
storeA.get(TestUtils.toByteArray(i + "A"), null);
storeB.put(TestUtils.toByteArray(i + "B"), new Versioned<byte[]>(value), null);
storeB.get(TestUtils.toByteArray(i + "B"), null);
EnvironmentStats statsA = environmentA.getStats(new StatsConfig());
EnvironmentStats statsB = environmentB.getStats(new StatsConfig());
long totalCacheSize = statsA.getCacheTotalBytes() + statsB.getCacheTotalBytes();
System.out.println("A.size:" + statsA.getCacheTotalBytes() + " B.size:" + statsB.getCacheTotalBytes() + " total:" + totalCacheSize + " max:" + maxCacheUsage + " cacheMax:" + environmentA.getConfig().getCacheSize());
System.out.println("Shared.A:" + statsA.getSharedCacheTotalBytes() + " nSharedEnv:" + statsA.getNSharedCacheEnvironments());
maxCacheUsage = Math.max(maxCacheUsage, totalCacheSize);
}
return maxCacheUsage;
}
use of com.sleepycat.je.EnvironmentStats in project qpid-broker-j by apache.
the class EnvironmentUtils method getEnvironmentStatistics.
public static Map<String, Map<String, Object>> getEnvironmentStatistics(Environment environment, boolean reset) {
StatsConfig config = new StatsConfig();
config.setClear(reset);
config.setFast(false);
EnvironmentStats stats = environment.getStats(config);
Collection<StatGroup> statGroups = stats.getStatGroups();
return getStatsFromStatGroup(statGroups);
}
Aggregations