allow both count and counter in old and new versions of error handler

This commit is contained in:
Jonathan Shook
2021-03-10 13:00:45 -06:00
parent 63158fcdd1
commit 345877c0fa
2 changed files with 32 additions and 20 deletions

View File

@@ -1,26 +1,12 @@
package io.nosqlbench.engine.api.activityapi.errorhandling.modular.handlers;
import io.nosqlbench.engine.api.activityapi.errorhandling.ErrorMetrics;
import io.nosqlbench.engine.api.activityapi.errorhandling.modular.ErrorDetail;
import io.nosqlbench.engine.api.activityapi.errorhandling.modular.ErrorHandler;
import io.nosqlbench.engine.api.metrics.ExceptionCountMetrics;
import io.nosqlbench.nb.annotations.Service;
import java.util.function.Supplier;
@Service(value = ErrorHandler.class, selector = "counter")
public class CountErrorHandler implements ErrorHandler, ErrorMetrics.Aware {
private ExceptionCountMetrics exceptionCountMetrics;
@Override
public ErrorDetail handleError(Throwable t, long cycle, long durationInNanos, ErrorDetail detail) {
exceptionCountMetrics.count(t);
return detail;
}
@Override
public void setErrorMetricsSupplier(Supplier<ErrorMetrics> supplier) {
this.exceptionCountMetrics = supplier.get().getExceptionCountMetrics();
}
/**
* This is here to allow the classic name 'count' to work although the
* modern error handler scheme uses canonical metric type names.
*/
@Service(value = ErrorHandler.class, selector = "count")
public class CountErrorHandler extends CounterErrorHandler {
}

View File

@@ -0,0 +1,26 @@
package io.nosqlbench.engine.api.activityapi.errorhandling.modular.handlers;
import io.nosqlbench.engine.api.activityapi.errorhandling.ErrorMetrics;
import io.nosqlbench.engine.api.activityapi.errorhandling.modular.ErrorDetail;
import io.nosqlbench.engine.api.activityapi.errorhandling.modular.ErrorHandler;
import io.nosqlbench.engine.api.metrics.ExceptionCountMetrics;
import io.nosqlbench.nb.annotations.Service;
import java.util.function.Supplier;
@Service(value = ErrorHandler.class, selector = "counter")
public class CounterErrorHandler implements ErrorHandler, ErrorMetrics.Aware {
private ExceptionCountMetrics exceptionCountMetrics;
@Override
public ErrorDetail handleError(Throwable t, long cycle, long durationInNanos, ErrorDetail detail) {
exceptionCountMetrics.count(t);
return detail;
}
@Override
public void setErrorMetricsSupplier(Supplier<ErrorMetrics> supplier) {
this.exceptionCountMetrics = supplier.get().getExceptionCountMetrics();
}
}