mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
allow both count and counter in old and new versions of error handler
This commit is contained in:
@@ -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 {
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user