use of com.hazelcast.spi.impl.operationservice.impl.operations.PartitionIteratingOperation in project hazelcast by hazelcast.
the class OperationDescriptors method toOperationDesc.
public static String toOperationDesc(Operation op) {
Class<? extends Operation> operationClass = op.getClass();
if (PartitionIteratingOperation.class.isAssignableFrom(operationClass)) {
PartitionIteratingOperation partitionIteratingOperation = (PartitionIteratingOperation) op;
OperationFactory operationFactory = partitionIteratingOperation.getOperationFactory();
String desc = DESCRIPTORS.get(operationFactory.getClass().getName());
if (desc == null) {
desc = PartitionIteratingOperation.class.getSimpleName() + "(" + operationFactory.getClass().getName() + ")";
DESCRIPTORS.put(operationFactory.getClass().getName(), desc);
}
return desc;
} else if (Backup.class.isAssignableFrom(operationClass)) {
Backup backup = (Backup) op;
Operation backupOperation = backup.getBackupOp();
String desc = DESCRIPTORS.get(backupOperation.getClass().getName());
if (desc == null) {
desc = Backup.class.getSimpleName() + "(" + backup.getBackupOp().getClass().getName() + ")";
DESCRIPTORS.put(backupOperation.getClass().getName(), desc);
}
return desc;
} else {
return operationClass.getName();
}
}
use of com.hazelcast.spi.impl.operationservice.impl.operations.PartitionIteratingOperation in project hazelcast by hazelcast.
the class InvokeOnPartitions method invokeOnAllPartitions.
private void invokeOnAllPartitions() {
if (memberPartitions.isEmpty()) {
future.complete(Collections.EMPTY_MAP);
return;
}
for (final Map.Entry<Address, List<Integer>> mp : memberPartitions.entrySet()) {
final Address address = mp.getKey();
List<Integer> partitions = mp.getValue();
PartitionIteratingOperation op = new PartitionIteratingOperation(operationFactory, toIntArray(partitions));
operationService.createInvocationBuilder(serviceName, op, address).setTryCount(TRY_COUNT).setTryPauseMillis(TRY_PAUSE_MILLIS).invoke().whenCompleteAsync(new FirstAttemptExecutionCallback(partitions));
}
}
use of com.hazelcast.spi.impl.operationservice.impl.operations.PartitionIteratingOperation 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.spi.impl.operationservice.impl.operations.PartitionIteratingOperation 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.spi.impl.operationservice.impl.operations.PartitionIteratingOperation in project hazelcast by hazelcast.
the class OperationDescriptorsTest method testPartitionIteratingOperation.
@Test
public void testPartitionIteratingOperation() {
PartitionIteratingOperation op = new PartitionIteratingOperation(new DummyOperationFactory(), new int[0]);
String result = toOperationDesc(op);
assertEquals(format("PartitionIteratingOperation(%s)", DummyOperationFactory.class.getName()), result);
}
Aggregations