use of com.hazelcast.spi.impl.operationexecutor.OperationRunner in project hazelcast by hazelcast.
the class OperationExecutorImpl_GetOperationRunnerTest method test_whenCallerIsGenericOperationThread.
@Test
public void test_whenCallerIsGenericOperationThread() {
initExecutor();
Operation nestedOp = new DummyOperation(-1);
final GetCurrentThreadOperationHandlerOperation op = new GetCurrentThreadOperationHandlerOperation(nestedOp);
op.setPartitionId(Operation.GENERIC_PARTITION_ID);
executor.execute(op);
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
boolean found = false;
OperationRunner foundHandler = op.getResponse();
for (OperationRunner h : executor.getGenericOperationRunners()) {
if (foundHandler == h) {
found = true;
break;
}
}
assertTrue("handler is not found is one of the generic handlers", found);
}
});
}
use of com.hazelcast.spi.impl.operationexecutor.OperationRunner in project hazelcast by hazelcast.
the class OperationExecutorImpl method initGenericThreads.
private GenericOperationThread[] initGenericThreads(HazelcastThreadGroup threadGroup, NodeExtension nodeExtension) {
// we created as many generic operation handlers, as there are generic threads
int threadCount = genericOperationRunners.length;
GenericOperationThread[] threads = new GenericOperationThread[threadCount];
int threadId = 0;
for (int threadIndex = 0; threadIndex < threads.length; threadIndex++) {
boolean priority = threadIndex < priorityThreadCount;
String baseName = priority ? "priority-generic-operation" : "generic-operation";
String threadName = threadGroup.getThreadPoolNamePrefix(baseName) + threadId;
OperationRunner operationRunner = genericOperationRunners[threadIndex];
GenericOperationThread operationThread = new GenericOperationThread(threadName, threadIndex, genericQueue, logger, threadGroup, nodeExtension, operationRunner, priority);
threads[threadIndex] = operationThread;
operationRunner.setCurrentThread(operationThread);
if (threadIndex == priorityThreadCount - 1) {
threadId = 0;
} else {
threadId++;
}
}
return threads;
}
use of com.hazelcast.spi.impl.operationexecutor.OperationRunner in project hazelcast by hazelcast.
the class OperationExecutorImpl method scan.
private void scan(OperationRunner[] runners, LiveOperations result) {
for (OperationRunner runner : runners) {
Object task = runner.currentTask();
if (!(task instanceof Operation) || task.getClass() == Backup.class) {
continue;
}
Operation operation = (Operation) task;
result.add(operation.getCallerAddress(), operation.getCallId());
}
}
Aggregations