Search in sources :

Example 1 with ProbeFunction

use of com.hazelcast.internal.metrics.ProbeFunction in project hazelcast by hazelcast.

the class DoubleGaugeImpl method read.

@Override
public double read() {
    ProbeInstance probeInstance = getProbeInstance();
    ProbeFunction function = null;
    Object source = null;
    if (probeInstance != null) {
        function = probeInstance.function;
        source = probeInstance.source;
    }
    if (function == null || source == null) {
        clearProbeInstance();
        return DEFAULT_VALUE;
    }
    try {
        if (function instanceof LongProbeFunction) {
            LongProbeFunction longFunction = (LongProbeFunction) function;
            return longFunction.get(source);
        } else {
            DoubleProbeFunction doubleFunction = (DoubleProbeFunction) function;
            return doubleFunction.get(source);
        }
    } catch (Exception e) {
        metricsRegistry.logger.warning("Failed to access probe:" + name, e);
        return DEFAULT_VALUE;
    }
}
Also used : LongProbeFunction(com.hazelcast.internal.metrics.LongProbeFunction) DoubleProbeFunction(com.hazelcast.internal.metrics.DoubleProbeFunction) ProbeFunction(com.hazelcast.internal.metrics.ProbeFunction) LongProbeFunction(com.hazelcast.internal.metrics.LongProbeFunction) DoubleProbeFunction(com.hazelcast.internal.metrics.DoubleProbeFunction)

Example 2 with ProbeFunction

use of com.hazelcast.internal.metrics.ProbeFunction in project hazelcast by hazelcast.

the class LongGaugeImpl method read.

@Override
public long read() {
    ProbeInstance probeInstance = getProbeInstance();
    ProbeFunction function = null;
    Object source = null;
    if (probeInstance != null) {
        function = probeInstance.function;
        source = probeInstance.source;
    }
    if (function == null || source == null) {
        clearProbeInstance();
        return DEFAULT_VALUE;
    }
    try {
        if (function instanceof LongProbeFunction) {
            LongProbeFunction longFunction = (LongProbeFunction) function;
            return longFunction.get(source);
        } else {
            DoubleProbeFunction doubleFunction = (DoubleProbeFunction) function;
            double doubleResult = doubleFunction.get(source);
            return Math.round(doubleResult);
        }
    } catch (Exception e) {
        metricsRegistry.logger.warning("Failed to access probe:" + name, e);
        return DEFAULT_VALUE;
    }
}
Also used : LongProbeFunction(com.hazelcast.internal.metrics.LongProbeFunction) DoubleProbeFunction(com.hazelcast.internal.metrics.DoubleProbeFunction) ProbeFunction(com.hazelcast.internal.metrics.ProbeFunction) LongProbeFunction(com.hazelcast.internal.metrics.LongProbeFunction) DoubleProbeFunction(com.hazelcast.internal.metrics.DoubleProbeFunction)

Example 3 with ProbeFunction

use of com.hazelcast.internal.metrics.ProbeFunction in project hazelcast by hazelcast.

the class MetricsRegistryImpl method render.

private void render(ProbeRenderer renderer, ProbeInstance probeInstance) {
    ProbeFunction function = probeInstance.function;
    Object source = probeInstance.source;
    String name = probeInstance.name;
    if (function == null || source == null) {
        renderer.renderNoValue(name);
        return;
    }
    try {
        if (function instanceof LongProbeFunction) {
            LongProbeFunction longFunction = (LongProbeFunction) function;
            renderer.renderLong(name, longFunction.get(source));
        } else {
            DoubleProbeFunction doubleFunction = (DoubleProbeFunction) function;
            renderer.renderDouble(name, doubleFunction.get(source));
        }
    } catch (Exception e) {
        renderer.renderException(name, e);
    }
}
Also used : LongProbeFunction(com.hazelcast.internal.metrics.LongProbeFunction) DoubleProbeFunction(com.hazelcast.internal.metrics.DoubleProbeFunction) LongProbeFunction(com.hazelcast.internal.metrics.LongProbeFunction) ProbeFunction(com.hazelcast.internal.metrics.ProbeFunction) DoubleProbeFunction(com.hazelcast.internal.metrics.DoubleProbeFunction)

Aggregations

DoubleProbeFunction (com.hazelcast.internal.metrics.DoubleProbeFunction)3 LongProbeFunction (com.hazelcast.internal.metrics.LongProbeFunction)3 ProbeFunction (com.hazelcast.internal.metrics.ProbeFunction)3