13 Mart 2023 Pazartesi

Operation Thread - Fixed Java Pool (FJP)

Giriş
Kısaca iki tane farklı ortam değişkeni var. Bunlar şöyle
hazelcast.operation.generic.thread.count // executor service
hazelcast.operation.thread.count // map get put
1. Non-Partition-aware Operations
Açıklaması şöyle. Core sayısının yarısı veya en az 2 tane yaratılır. 
To execute operations that are not partition-aware, e.g., IExecutorService.executeOnMember(command, member), generic operation threads are used. When the Hazelcast instance is started, an array of operation threads is created. The size of this array has a default value of the number of cores divided by two with a minimum value of 2. It can be changed using the hazelcast.operation.generic.thread.count property.
2. Partition-aware operations
Açıklaması şöyle
These threads execute Hazelcast operations, such as map put or get operations
Açıklaması şöyle. Core sayısı kadar veya en az 2 tane Partition Thread yaratılır. 
To execute partition-aware operations, an array of operation threads is created. The default value of this array’s size is the number of cores and it has a minimum value of 2. This value can be changed using the hazelcast.operation.thread.count property.

Each operation thread has its own work queue and it consumes messages from this work queue. If a partition-aware operation needs to be scheduled, the right thread is found using the formula below.

threadIndex = partitionId % partition thread-count

After the threadIndex is determined, the operation is put in the work queue of that operation thread. This means the followings:
  • A single operation thread executes operations for multiple partitions; if there are 271 partitions and 10 partition threads, then roughly every operation thread executes operations for 27 partitions.
  • Each partition belongs to only 1 operation thread. All operations for a partition are always handled by exactly the same operation thread.
  • Concurrency control is not needed to deal with partition-aware operations because once a partition-aware operation is put in the work queue of a partition-aware operation thread, only 1 thread is able to touch that partition.
Örnek - XML
Şöyle yaparız
<hazelcast>
  <properties>
    <property name="hazelcast.operation.thread.count">10</property>
  </properties>
  ...
</hazelcast>
2.1 Nasıl Çalışır
Açıklaması şöyle
Each operation thread has its own work queue and it consumes messages from this work queue. If a partition-aware operation needs to be scheduled, the right thread is found using the formula below.

threadIndex = partitionId % partition thread-count

After the threadIndex is determined, the operation is put in the work queue of that operation thread. This means the followings:
  • A single operation thread executes operations for multiple partitions; if there are 271 partitions and 10 partition threads, then roughly every operation thread executes operations for 27 partitions.
  • Each partition belongs to only 1 operation thread. All operations for a partition are always handled by exactly the same operation thread.
  • Concurrency control is not needed to deal with partition-aware operations because once a partition-aware operation is put in the work queue of a partition-aware operation thread, only 1 thread is able to touch that partition.
2.2 Partition Thread İsmi
hz.XXX.partition-operation.thread-N şeklinde. Eğer örneğin 16 işlemci varsa son kısım, thread-0 ve thread-15 arasında bir şey olur
hz.XXX.partition-operation.thread-0
Örnek
Put işlemi için çağrı şöyle. Buraya kadar her şey partition-operation.thread üzerinde çalışıyor
interceptPut:641, MapServiceContextImpl (com.hazelcast.map.impl)
putInternal:946, DefaultRecordStore (com.hazelcast.map.impl.recordstore)
putIfAbsent:1218, DefaultRecordStore (com.hazelcast.map.impl.recordstore)
runInternal:39, PutIfAbsentOperation (com.hazelcast.map.impl.operation)
run:153, MapOperation (com.hazelcast.map.impl.operation)
call:173, MapOperation (com.hazelcast.map.impl.operation)
call:295, OperationRunnerImpl (com.hazelcast.spi.impl.operationservice.impl)
run:270, OperationRunnerImpl (com.hazelcast.spi.impl.operationservice.impl)
run:219, OperationRunnerImpl (com.hazelcast.spi.impl.operationservice.impl)
process:180, OperationThread (com.hazelcast.spi.impl.operationexecutor.impl)
process:144, OperationThread (com.hazelcast.spi.impl.operationexecutor.impl)
loop:134, OperationThread (com.hazelcast.spi.impl.operationexecutor.impl)
executeRun:115, OperationThread (com.hazelcast.spi.impl.operationexecutor.impl)
run:111, HazelcastManagedThread (com.hazelcast.internal.util.executor)



Hiç yorum yok:

Yorum Gönder

THIRD-PARTY.txt Dosyası

Kullanılan harici kütüphanelerin sürümleri bu dosyada Dosyanın yolu şöyle hazelcast/licenses/THIRD-PARTY.txt