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);
}
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);
}
}
}
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;
}
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();
}
}
Aggregations