space metrics, heap metrics

This commit is contained in:
Jonathan Shook
2024-10-11 15:16:12 -05:00
parent ddd39d9237
commit 4fa93955c0
5 changed files with 63 additions and 37 deletions

View File

@@ -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;
}

View File

@@ -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) {