All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.nosqlbench.engine.api.activityapi.errorhandling.modular.ResultCode Maven / Gradle / Ivy

Go to download

The engine API for nosqlbench; Provides the interfaces needed to build internal modules for the nosqlbench core engine

There is a newer version: 5.17.0
Show newest version
package io.nosqlbench.engine.api.activityapi.errorhandling.modular;

import io.nosqlbench.nb.annotations.Service;
import io.nosqlbench.nb.api.config.standard.ConfigModel;
import io.nosqlbench.nb.api.config.standard.NBConfigModel;
import io.nosqlbench.nb.api.config.standard.NBMapConfigurable;
import io.nosqlbench.nb.api.config.standard.Param;

import java.util.Map;

@Service(value = ErrorHandler.class, selector = "code")
public class ResultCode implements ErrorHandler, NBMapConfigurable {

    private byte code;

    @Override
    public ErrorDetail handleError(String name, Throwable t, long cycle, long durationInNanos, ErrorDetail detail) {
        return detail.withResultCode(code);
    }

    @Override
    public void applyConfig(Map providedConfig) {
        this.code = Byte.valueOf(providedConfig.get("code").toString());
    }

    @Override
    public NBConfigModel getConfigModel() {
        return ConfigModel.of(this.getClass())
            .add(Param.required("code", Byte.class))
            .asReadOnly();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy