Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for Bdb Space stats. Fixes issue 169 #74

Closed
wants to merge 6 commits into from
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 52 additions & 15 deletions src/java/voldemort/store/bdb/stats/BdbEnvironmentStats.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
package voldemort.store.bdb.stats;

import java.util.concurrent.Callable;

import com.sleepycat.je.Environment;
import com.sleepycat.je.EnvironmentConfig;
import com.sleepycat.je.EnvironmentStats;
import com.sleepycat.je.StatsConfig;
import voldemort.VoldemortException;
import voldemort.annotations.Experimental;
import voldemort.annotations.jmx.JmxGetter;
import voldemort.annotations.jmx.JmxOperation;
import voldemort.utils.CachedCallable;

import java.util.concurrent.Callable;
import com.sleepycat.je.Environment;
import com.sleepycat.je.EnvironmentConfig;
import com.sleepycat.je.EnvironmentStats;
import com.sleepycat.je.StatsConfig;

public class BdbEnvironmentStats {

private final Environment environment;
private final CachedCallable<EnvironmentStats> fastStats;
private final CachedCallable<DbSpace> fastDbStats;
private boolean sorted = false;

public BdbEnvironmentStats(Environment environment, long ttlMs) {
this.environment = environment;
Expand All @@ -26,6 +29,14 @@ public EnvironmentStats call() throws Exception {
}
};
fastStats = new CachedCallable<EnvironmentStats>(fastStatsCallable, ttlMs);

Callable<DbSpace> fastDbStatsCallable = new Callable<DbSpace>() {

public DbSpace call() throws Exception {
return getBdbStats();
}
};
fastDbStats = new CachedCallable<DbSpace>(fastDbStatsCallable, ttlMs);
}

private EnvironmentStats getEnvironmentStats(boolean fast) {
Expand All @@ -34,6 +45,33 @@ private EnvironmentStats getEnvironmentStats(boolean fast) {
return environment.getStats(config);
}

private DbSpace getBdbStats() {
return new DbSpace(environment, sorted);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is nt sorted always false here? can you remove the variable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

}

private DbSpace getFastDbStats() {
try {
return fastDbStats.call();
} catch(Exception e) {
throw new VoldemortException(e);
}
}

@JmxGetter(name = "BdbTotalSize")
public long getBdbTotalSize() {
return getFastDbStats().getTotal().totalSize();
}

@JmxGetter(name = "BdbTotalUsage")
public long getBdbTotalUsage() {
return getFastDbStats().getTotal().utilization();
}

@JmxOperation(description = "Displays the disk space utilization for an environment.")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this a JMXOperation vs JMXGetter? Please make these changes and I will pull this in.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

public String getBdbSummariesAsString() {
return getFastDbStats().getSummariesAsString();
}

private EnvironmentStats getFastStats() {
try {
return fastStats.call();
Expand Down Expand Up @@ -159,13 +197,13 @@ public long getNumWritesTotal() {

@JmxGetter(name = "PercentRandomWrites")
public double getPercentRandomWrites() {
return safeGetPercentage(getNumRandomWrites(), getNumWritesTotal());
return safeGetPercentage(getNumRandomWrites(), getNumWritesTotal());
}

@JmxGetter(name = "PercentageRandomWriteBytes")
public double getPercentageRandomWriteBytes() {
return safeGetPercentage(getNumRandomWriteBytes(), getNumRandomWriteBytes() +
getNumSequentialWriteBytes());
return safeGetPercentage(getNumRandomWriteBytes(), getNumRandomWriteBytes()
+ getNumSequentialWriteBytes());
}

@JmxGetter(name = "NumReadsTotal")
Expand All @@ -180,8 +218,8 @@ public double getPercentageRandomReads() {

@JmxGetter(name = "PercentageRandomReadBytes")
public double getPercentageRandomReadBytes() {
return safeGetPercentage(getNumRandomWriteBytes(), getNumRandomReadBytes() +
getNumSequentialReadBytes());
return safeGetPercentage(getNumRandomWriteBytes(), getNumRandomReadBytes()
+ getNumSequentialReadBytes());
}

@Experimental
Expand All @@ -193,17 +231,16 @@ public double getPercentageCacheHits() {
@Experimental
@JmxGetter(name = "PercentageCacheMisses")
public double getPercentageCacheMisses() {
return safeGetPercentage(getNumCacheMiss(),
getNumReadsTotal() + getNumWritesTotal());
return safeGetPercentage(getNumCacheMiss(), getNumReadsTotal() + getNumWritesTotal());
}

@JmxGetter(name = "PercentageContended")
public double getPercentageContended() {
return safeGetPercentage(getNumAcquiresWithContention(),
getNumAcquiresWithContention() + getNumAcquiresNoWaiters());
return safeGetPercentage(getNumAcquiresWithContention(), getNumAcquiresWithContention()
+ getNumAcquiresNoWaiters());
}

public static double safeGetPercentage(long rawNum, long total) {
return total == 0 ? 0.0d : rawNum / (float)total;
return total == 0 ? 0.0d : rawNum / (float) total;
}
}