use of com.hazelcast.spi.impl.PartitionSpecificRunnable in project hazelcast by hazelcast.
the class OperationExecutorImpl_ExecutePartitionSpecificRunnableTest method whenGeneric.
@Test
public void whenGeneric() {
initExecutor();
final AtomicReference<Thread> executingThead = new AtomicReference<Thread>();
PartitionSpecificRunnable task = new PartitionSpecificRunnable() {
@Override
public void run() {
executingThead.set(Thread.currentThread());
}
@Override
public int getPartitionId() {
return -1;
}
};
executor.execute(task);
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertInstanceOf(GenericOperationThread.class, executingThead.get());
}
});
}
use of com.hazelcast.spi.impl.PartitionSpecificRunnable in project hazelcast by hazelcast.
the class OperationThread method process.
private void process(Object task) {
try {
if (task.getClass() == Packet.class) {
Packet packet = (Packet) task;
currentRunner = getOperationRunner(packet.getPartitionId());
currentRunner.run(packet);
completedPacketCount.inc();
} else if (task instanceof Operation) {
Operation operation = (Operation) task;
currentRunner = getOperationRunner(operation.getPartitionId());
currentRunner.run(operation);
completedOperationCount.inc();
} else if (task instanceof PartitionSpecificRunnable) {
PartitionSpecificRunnable runnable = (PartitionSpecificRunnable) task;
currentRunner = getOperationRunner(runnable.getPartitionId());
currentRunner.run(runnable);
completedPartitionSpecificRunnableCount.inc();
} else if (task instanceof Runnable) {
Runnable runnable = (Runnable) task;
runnable.run();
completedRunnableCount.inc();
} else {
throw new IllegalStateException("Unhandled task type for task:" + task);
}
completedTotalCount.inc();
} catch (Throwable t) {
errorCount.inc();
inspectOutOfMemoryError(t);
logger.severe("Failed to process packet: " + task + " on " + getName(), t);
} finally {
currentRunner = null;
}
}
Aggregations