Search in sources :

Example 1 with LatencyDistribution

use of com.hazelcast.internal.util.LatencyDistribution in project hazelcast by hazelcast.

the class InvocationRegistry method retire.

public void retire(Invocation invocation) {
    if (!profilerEnabled) {
        return;
    }
    Operation op = invocation.op;
    Class c = op.getClass();
    if (op instanceof PartitionIteratingOperation) {
        c = ((PartitionIteratingOperation) op).getOperationFactory().getClass();
    }
    LatencyDistribution distribution = latencyDistributions.computeIfAbsent(c, k -> new LatencyDistribution());
    distribution.done(invocation.firstInvocationTimeNanos);
}
Also used : PartitionIteratingOperation(com.hazelcast.spi.impl.operationservice.impl.operations.PartitionIteratingOperation) Operation(com.hazelcast.spi.impl.operationservice.Operation) PartitionIteratingOperation(com.hazelcast.spi.impl.operationservice.impl.operations.PartitionIteratingOperation) LatencyDistribution(com.hazelcast.internal.util.LatencyDistribution)

Example 2 with LatencyDistribution

use of com.hazelcast.internal.util.LatencyDistribution in project hazelcast by hazelcast.

the class OperationRunnerImpl method run.

@Override
public void run(Runnable task) {
    long startNanos = System.nanoTime();
    boolean publishCurrentTask = publishCurrentTask();
    if (publishCurrentTask) {
        currentTask = task;
    }
    try {
        task.run();
    } finally {
        if (publishCurrentTask) {
            currentTask = null;
        }
        if (opLatencyDistributions != null) {
            Class c = task.getClass();
            LatencyDistribution distribution = opLatencyDistributions.computeIfAbsent(c, k -> new LatencyDistribution());
            distribution.done(startNanos);
        }
    }
}
Also used : LatencyDistribution(com.hazelcast.internal.util.LatencyDistribution)

Example 3 with LatencyDistribution

use of com.hazelcast.internal.util.LatencyDistribution in project hazelcast by hazelcast.

the class OperationRunnerImpl method run.

/**
 * Runs the provided operation.
 *
 * @param op         the operation to execute
 * @param startNanos the time, as returned by {@link System#nanoTime} when this operation
 *                   started execution
 * @return {@code true} if this operation was not executed and should be retried at a later time,
 * {@code false} if the operation should not be retried, either because it
 * timed out or has run successfully
 */
private boolean run(Operation op, long startNanos) {
    executedOperationsCounter.inc();
    boolean publishCurrentTask = publishCurrentTask();
    if (publishCurrentTask) {
        currentTask = op;
    }
    try {
        checkNodeState(op);
        if (timeout(op)) {
            return false;
        }
        ensureNoPartitionProblems(op);
        ensureNoSplitBrain(op);
        if (op.isTenantAvailable()) {
            op.pushThreadContext();
            op.beforeRun();
            call(op);
        } else {
            return true;
        }
    } catch (Throwable e) {
        handleOperationError(op, e);
    } finally {
        op.afterRunFinal();
        if (publishCurrentTask) {
            currentTask = null;
        }
        op.popThreadContext();
        if (opLatencyDistributions != null) {
            Class c = op.getClass();
            if (op instanceof PartitionIteratingOperation) {
                c = ((PartitionIteratingOperation) op).getOperationFactory().getClass();
            }
            LatencyDistribution distribution = opLatencyDistributions.computeIfAbsent(c, k -> new LatencyDistribution());
            distribution.recordNanos(System.nanoTime() - startNanos);
        }
    }
    return false;
}
Also used : PartitionIteratingOperation(com.hazelcast.spi.impl.operationservice.impl.operations.PartitionIteratingOperation) LatencyDistribution(com.hazelcast.internal.util.LatencyDistribution)

Example 4 with LatencyDistribution

use of com.hazelcast.internal.util.LatencyDistribution in project hazelcast by hazelcast.

the class OperationProfilerPlugin method write.

static void write(DiagnosticsLogWriter writer, ConcurrentMap<Class, LatencyDistribution> opLatencyDistribution) {
    for (Map.Entry<Class, LatencyDistribution> entry : opLatencyDistribution.entrySet()) {
        LatencyDistribution distribution = entry.getValue();
        if (distribution.count() == 0) {
            continue;
        }
        writer.startSection(entry.getKey().getName());
        writer.writeKeyValueEntry("count", distribution.count());
        writer.writeKeyValueEntry("totalTime(us)", distribution.totalMicros());
        writer.writeKeyValueEntry("avg(us)", distribution.avgMicros());
        writer.writeKeyValueEntry("max(us)", distribution.maxMicros());
        writer.startSection("latency-distribution");
        for (int bucket = 0; bucket < distribution.bucketCount(); bucket++) {
            long value = distribution.bucket(bucket);
            if (value > 0) {
                writer.writeKeyValueEntry(LatencyDistribution.LATENCY_KEYS[bucket], value);
            }
        }
        writer.endSection();
        writer.endSection();
    }
}
Also used : Map(java.util.Map) ConcurrentMap(java.util.concurrent.ConcurrentMap) LatencyDistribution(com.hazelcast.internal.util.LatencyDistribution)

Aggregations

LatencyDistribution (com.hazelcast.internal.util.LatencyDistribution)4 PartitionIteratingOperation (com.hazelcast.spi.impl.operationservice.impl.operations.PartitionIteratingOperation)2 Operation (com.hazelcast.spi.impl.operationservice.Operation)1 Map (java.util.Map)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1