Search in sources :

Example 11 with OperationRunner

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);
        }
    });
}
Also used : AssertTask(com.hazelcast.test.AssertTask) OperationRunner(com.hazelcast.spi.impl.operationexecutor.OperationRunner) Operation(com.hazelcast.spi.Operation) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 12 with OperationRunner

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;
}
Also used : OperationRunner(com.hazelcast.spi.impl.operationexecutor.OperationRunner)

Example 13 with OperationRunner

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());
    }
}
Also used : Backup(com.hazelcast.spi.impl.operationservice.impl.operations.Backup) OperationRunner(com.hazelcast.spi.impl.operationexecutor.OperationRunner) UrgentSystemOperation(com.hazelcast.spi.UrgentSystemOperation) Operation(com.hazelcast.spi.Operation)

Aggregations

OperationRunner (com.hazelcast.spi.impl.operationexecutor.OperationRunner)13 Operation (com.hazelcast.spi.Operation)5 QuickTest (com.hazelcast.test.annotation.QuickTest)5 Test (org.junit.Test)5 AssertTask (com.hazelcast.test.AssertTask)4 Packet (com.hazelcast.nio.Packet)3 OperationHostileThread (com.hazelcast.spi.impl.operationexecutor.OperationHostileThread)2 OperationRunnerFactory (com.hazelcast.spi.impl.operationexecutor.OperationRunnerFactory)2 HazelcastThreadGroup (com.hazelcast.instance.HazelcastThreadGroup)1 NodeExtension (com.hazelcast.instance.NodeExtension)1 MPSCQueue (com.hazelcast.internal.util.concurrent.MPSCQueue)1 ILogger (com.hazelcast.logging.ILogger)1 UrgentSystemOperation (com.hazelcast.spi.UrgentSystemOperation)1 PartitionSpecificRunnable (com.hazelcast.spi.impl.PartitionSpecificRunnable)1 PartitionOperationThread (com.hazelcast.spi.impl.operationexecutor.impl.PartitionOperationThread)1 Backup (com.hazelcast.spi.impl.operationservice.impl.operations.Backup)1 ParallelTest (com.hazelcast.test.annotation.ParallelTest)1