mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
space metrics, heap metrics
This commit is contained in:
@@ -131,7 +131,7 @@ public abstract class BaseDriverAdapter<R extends Op, S> extends NBBaseComponent
|
||||
@Override
|
||||
public final synchronized DriverSpaceCache<? extends S> getSpaceCache() {
|
||||
if (spaceCache == null) {
|
||||
spaceCache = new DriverSpaceCache<>(getSpaceInitializer(getConfiguration()));
|
||||
spaceCache = new DriverSpaceCache<>(this, getSpaceInitializer(getConfiguration()));
|
||||
}
|
||||
return spaceCache;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,10 @@
|
||||
|
||||
package io.nosqlbench.adapters.api.activityimpl.uniform;
|
||||
|
||||
import io.nosqlbench.nb.api.components.core.NBBaseComponent;
|
||||
import io.nosqlbench.nb.api.components.core.NBComponent;
|
||||
import io.nosqlbench.nb.api.engine.metrics.instruments.MetricCategory;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@@ -42,14 +46,21 @@ import java.util.function.Function;
|
||||
* @param <S>
|
||||
* The type which will represent the cache for a given type of adapter.
|
||||
*/
|
||||
public class DriverSpaceCache<S> {
|
||||
public class DriverSpaceCache<S> extends NBBaseComponent {
|
||||
|
||||
private final ConcurrentHashMap<String, S> cache = new ConcurrentHashMap<>();
|
||||
|
||||
private final Function<String, S> newSpaceFunction;
|
||||
|
||||
public DriverSpaceCache(Function<String, S> newSpaceFunction) {
|
||||
public DriverSpaceCache(NBComponent parent, Function<String, S> newSpaceFunction) {
|
||||
super(parent);
|
||||
this.newSpaceFunction = newSpaceFunction;
|
||||
this.create().gauge(
|
||||
"spaces",
|
||||
() -> (double) this.getElements().size(),
|
||||
MetricCategory.Internals,
|
||||
"the number of spaces instantiated by this adapter instance"
|
||||
);
|
||||
}
|
||||
|
||||
public S get(String name) {
|
||||
|
||||
Reference in New Issue
Block a user