Giriş
Şu satırı dahil ederiz
import com.hazelcast.internal.partition.IPartitionService ;
Kalıtım şöyle
CoreService
IPartitionService
InternalPartitionServiceImpl
Partition Arrangement
Açıklaması şöyle
Initial partition arrangement by default occurs lazily when the first partition operation hits the cluster. So once a partition op appears for execution, partition assignments will be split across the 2 members
constructor
InternalPartitionServiceImpl içindeki kod şöyle. İşte meşhur 271 sayısı ClusterProperty.PARTITION_COUNT sabitinden geliyor.
public InternalPartitionServiceImpl(Node node) {
HazelcastProperties properties = node.getProperties();
this.partitionCount = properties.getInteger(ClusterProperty.PARTITION_COUNT);
...
}getPartitionCount metodu
Cluster içinde kaç tane partition olduğunu belirtir
isPartitionAssignmentDone metodu
Bu member için partition ataması yapılıp yapılmadığını belirtir
Örnek
Şöyle yaparız
if (!nodeEngine.getPartitionService().isPartitionAssignmentDone()
&& !hazelcastInstance.getCluster().getClusterState().isMigrationAllowed()) {
// partitions have not been assigned yet and migrations are not allowed
// so sql catalog can have no values -> skip check, because we anyway cannot
// iterate over sqlCatalog values (operation will fail with exception, since
// partition assignments do not exist and cannot be triggered).
logger.info("Skipping data connection consistency check because"
+ " initial partition assignment is not done yet.");
return;
}
Hiç yorum yok:
Yorum Gönder