private GenericOperationThread[] initGenericThreads(String hzName, NodeExtension nodeExtension, ClassLoader configClassLoader) { // 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 = createThreadPoolName(hzName, baseName) + threadId; OperationRunner operationRunner = genericOperationRunners[threadIndex]; GenericOperationThread operationThread = new GenericOperationThread( threadName, threadIndex, genericQueue, logger, nodeExtension, operationRunner, priority, configClassLoader); threads[threadIndex] = operationThread; operationRunner.setCurrentThread(operationThread); if (threadIndex == priorityThreadCount - 1) { threadId = 0; } else { threadId++; } } return threads; }
private GenericOperationThread[] initGenericThreads(String hzName, NodeExtension nodeExtension, ClassLoader configClassLoader) { // 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 = createThreadPoolName(hzName, baseName) + threadId; OperationRunner operationRunner = genericOperationRunners[threadIndex]; GenericOperationThread operationThread = new GenericOperationThread( threadName, threadIndex, genericQueue, logger, nodeExtension, operationRunner, priority, configClassLoader); threads[threadIndex] = operationThread; operationRunner.setCurrentThread(operationThread); if (threadIndex == priorityThreadCount - 1) { threadId = 0; } else { threadId++; } } return threads; }
private PartitionOperationThread[] initPartitionThreads(HazelcastProperties properties, String hzName, NodeExtension nodeExtension, ClassLoader configClassLoader) { int threadCount = properties.getInteger(PARTITION_OPERATION_THREAD_COUNT); if (threadCount <= 0) { // default partition operation thread count int coreSize = RuntimeAvailableProcessors.get(); threadCount = Math.max(2, coreSize); } IdleStrategy idleStrategy = getIdleStrategy(properties, IDLE_STRATEGY); PartitionOperationThread[] threads = new PartitionOperationThread[threadCount]; for (int threadId = 0; threadId < threads.length; threadId++) { String threadName = createThreadPoolName(hzName, "partition-operation") + threadId; // the normalQueue will be a blocking queue. We don't want to idle, because there are many operation threads. MPSCQueue<Object> normalQueue = new MPSCQueue<Object>(idleStrategy); OperationQueue operationQueue = new OperationQueueImpl(normalQueue, new ConcurrentLinkedQueue<Object>()); PartitionOperationThread partitionThread = new PartitionOperationThread(threadName, threadId, operationQueue, logger, nodeExtension, partitionOperationRunners, configClassLoader); threads[threadId] = partitionThread; normalQueue.setConsumerThread(partitionThread); } // we need to assign the PartitionOperationThreads to all OperationRunners they own for (int partitionId = 0; partitionId < partitionOperationRunners.length; partitionId++) { int threadId = getPartitionThreadId(partitionId, threadCount); Thread thread = threads[threadId]; OperationRunner runner = partitionOperationRunners[partitionId]; runner.setCurrentThread(thread); } return threads; }
private PartitionOperationThread[] initPartitionThreads(HazelcastProperties properties, String hzName, NodeExtension nodeExtension, ClassLoader configClassLoader) { int threadCount = properties.getInteger(PARTITION_OPERATION_THREAD_COUNT); if (threadCount <= 0) { // default partition operation thread count int coreSize = RuntimeAvailableProcessors.get(); threadCount = Math.max(2, coreSize); } IdleStrategy idleStrategy = getIdleStrategy(properties, IDLE_STRATEGY); PartitionOperationThread[] threads = new PartitionOperationThread[threadCount]; for (int threadId = 0; threadId < threads.length; threadId++) { String threadName = createThreadPoolName(hzName, "partition-operation") + threadId; // the normalQueue will be a blocking queue. We don't want to idle, because there are many operation threads. MPSCQueue<Object> normalQueue = new MPSCQueue<Object>(idleStrategy); OperationQueue operationQueue = new OperationQueueImpl(normalQueue, new ConcurrentLinkedQueue<Object>()); PartitionOperationThread partitionThread = new PartitionOperationThread(threadName, threadId, operationQueue, logger, nodeExtension, partitionOperationRunners, configClassLoader); threads[threadId] = partitionThread; normalQueue.setConsumerThread(partitionThread); } // we need to assign the PartitionOperationThreads to all OperationRunners they own for (int partitionId = 0; partitionId < partitionOperationRunners.length; partitionId++) { int threadId = getPartitionThreadId(partitionId, threadCount); Thread thread = threads[threadId]; OperationRunner runner = partitionOperationRunners[partitionId]; runner.setCurrentThread(thread); } return threads; }