org.metricssampler.extensions.base.DefaultSamplerConfig Maven / Gradle / Ivy
package org.metricssampler.extensions.base;
import static org.metricssampler.util.Preconditions.checkArgumentNotNull;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.metricssampler.config.InputConfig;
import org.metricssampler.config.OutputConfig;
import org.metricssampler.config.SamplerConfig;
import org.metricssampler.config.SelectorConfig;
import org.metricssampler.config.ValueTransformerConfig;
public class DefaultSamplerConfig extends SamplerConfig {
private final InputConfig input;
private final List outputs;
private final List selectors;
private final Map variables;
private final Map globalVariables;
private final boolean quiet;
private final int initialResetTimeout;
private final int regularResetTimeout;
public DefaultSamplerConfig(final String name, final String pool, final int interval, final boolean ignored, final boolean disabled, final InputConfig input,
final List outputs, final List selectors, final Map variables,
final Map globalVariables, final List valueTransformers, final boolean quiet, final int initialResetTimeout, final int regularResetTimeout) {
super(name, pool, interval, ignored, disabled, globalVariables, valueTransformers);
checkArgumentNotNull(input, "input");
checkArgumentNotNull(outputs, "outputs");
checkArgumentNotNull(selectors, "selectors");
checkArgumentNotNull(variables, "variables");
checkArgumentNotNull(globalVariables, "globalVariables");
this.input = input;
this.outputs = outputs;
this.selectors = selectors;
this.variables = Collections.unmodifiableMap(variables);
this.globalVariables = Collections.unmodifiableMap(globalVariables);
this.quiet = quiet;
this.initialResetTimeout = initialResetTimeout;
this.regularResetTimeout = regularResetTimeout;
}
public InputConfig getInput() {
return input;
}
public List getOutputs() {
return Collections.unmodifiableList(outputs);
}
public List getSelectors() {
return Collections.unmodifiableList(selectors);
}
public Map getVariables() {
return variables;
}
@Override
public Map getGlobalVariables() {
return globalVariables;
}
/**
* @return the timeout in seconds that the sampler will wait after successfully connecting the input to reset so that the matched JMX beans are reloaded. This will be
* repeated until the number of the matched beans remains unchanged for two consecutive reconnects.
*/
public int getInitialResetTimeout() {
return initialResetTimeout;
}
/**
* @return the timeout in seconds that the sampler will wait after successfully connecting the input to reset so that the matched JMX beans are reloaded. This will be
* done on a regular basis.
*/
public int getRegularResetTimeout() {
return regularResetTimeout;
}
@Override
public String toString() {
return getClass().getSimpleName() + "[" + input + "->" + outputs + "]";
}
/**
* @return {@code true} if the sampler should not be very chatty about connectivity problems. This is useful for cases when we want to
* monitor services that are not available all the time. Without setting this to {@code true} the sampler would constantly log
* stack traces because it fails to open the reader.
*/
public boolean isQuiet() {
return quiet;
}
}