Giriş
Şu satırı dahil ederiz
import com.hazelcast.client.impl.spi.impl.ClientPartitionServiceImpl;
Kalıtım şöyle
ClientPartitionService
ClientPartitionServiceImpl
public final class ClientPartitionServiceImpl implements ClientPartitionService {
private final HazelcastClientInstanceImpl client;
private final ILogger logger;
private final AtomicReference<PartitionTable> partitionTable =
new AtomicReference<>(new PartitionTable(null, -1, new Int2ObjectHashMap<>()));
private final AtomicInteger partitionCount = new AtomicInteger(0);
...
}getPartitionCount metodu
Kod şöyle.
@Override
public int getPartitionCount() {
return partitionCount.get();
}getPartitionId metodu
Kod şöyle. Bu metod ClientProxy tarafından kullanılır
invokeOnPartitionOwner metodu@Overridepublic int getPartitionId(@Nonnull Data key) {int pc = getPartitionCount();if (pc == 0) {// Partition count can not be zero for the sync mode.// On the sync mode, we are waiting for the first connection to be established.// We are initializing the partition count with // the value coming from the server with authentication.// This exception is used only for async mode client.throw new HazelcastClientOfflineException();}int hash = key.getPartitionHash();return HashUtil.hashToIndex(hash, pc);}
Kod şöyle. Belirtilen partitionId'ye sahip UUID bulunur. Bu UUID ile connection bulunur ve gönderilir.
@Override
public boolean invokeOnPartitionOwner(ClientInvocation invocation, int partitionId) {
UUID partitionOwner = partitionService.getPartitionOwner(partitionId);
if (partitionOwner == null) {
if (invocationLogger.isFinestEnabled()) {
invocationLogger.finest("Partition owner is not assigned yet");
}
return false;
}
return invokeOnTarget(invocation, partitionOwner);
}
Hiç yorum yok:
Yorum Gönder