use of com.hazelcast.internal.partition.InternalPartitionService in project hazelcast by hazelcast.
the class BaseMigrationOperation method verifyPartitionStateVersion.
private void verifyPartitionStateVersion() {
InternalPartitionService partitionService = getService();
int localPartitionStateVersion = partitionService.getPartitionStateVersion();
if (partitionStateVersion != localPartitionStateVersion) {
if (getNodeEngine().getThisAddress().equals(migrationInfo.getMaster())) {
return;
}
// this is expected when cluster member list changes during migration
throw new PartitionStateVersionMismatchException(partitionStateVersion, localPartitionStateVersion);
}
}
use of com.hazelcast.internal.partition.InternalPartitionService in project hazelcast by hazelcast.
the class OperationBackupHandler method syncBackups.
int syncBackups(int requestedSyncBackups, int requestedAsyncBackups, boolean syncForced) {
if (syncForced) {
// if force sync enabled, then the sum of the backups
requestedSyncBackups += requestedAsyncBackups;
}
InternalPartitionService partitionService = node.getPartitionService();
int maxBackupCount = partitionService.getMaxAllowedBackupCount();
return min(maxBackupCount, requestedSyncBackups);
}
use of com.hazelcast.internal.partition.InternalPartitionService in project hazelcast by hazelcast.
the class OperationBackupHandler method makeBackups.
private int makeBackups(BackupAwareOperation backupAwareOp, int partitionId, long[] replicaVersions, int syncBackups, int asyncBackups) {
int sendSyncBackups;
int totalBackups = syncBackups + asyncBackups;
InternalPartitionService partitionService = node.getPartitionService();
InternalPartition partition = partitionService.getPartition(partitionId);
if (totalBackups == 1) {
sendSyncBackups = sendSingleBackup(backupAwareOp, partition, replicaVersions, syncBackups);
} else {
sendSyncBackups = sendMultipleBackups(backupAwareOp, partition, replicaVersions, syncBackups, totalBackups);
}
return sendSyncBackups;
}
use of com.hazelcast.internal.partition.InternalPartitionService in project hazelcast by hazelcast.
the class OperationBackupHandler method sendBackups0.
int sendBackups0(BackupAwareOperation backupAwareOp) throws Exception {
int requestedSyncBackups = requestedSyncBackups(backupAwareOp);
int requestedAsyncBackups = requestedAsyncBackups(backupAwareOp);
int requestedTotalBackups = requestedTotalBackups(backupAwareOp);
if (requestedTotalBackups == 0) {
return 0;
}
Operation op = (Operation) backupAwareOp;
InternalPartitionService partitionService = node.getPartitionService();
long[] replicaVersions = partitionService.incrementPartitionReplicaVersions(op.getPartitionId(), requestedTotalBackups);
boolean syncForced = backpressureRegulator.isSyncForced(backupAwareOp);
int syncBackups = syncBackups(requestedSyncBackups, requestedAsyncBackups, syncForced);
int asyncBackups = asyncBackups(requestedSyncBackups, requestedAsyncBackups, syncForced);
// TODO: This could cause a problem with back pressure
if (!op.returnsResponse()) {
asyncBackups += syncBackups;
syncBackups = 0;
}
if (syncBackups + asyncBackups == 0) {
return 0;
}
return makeBackups(backupAwareOp, op.getPartitionId(), replicaVersions, syncBackups, asyncBackups);
}
use of com.hazelcast.internal.partition.InternalPartitionService in project hazelcast by hazelcast.
the class OperationServiceImpl method invokeOnPartitions.
@Override
public Map<Integer, Object> invokeOnPartitions(String serviceName, OperationFactory operationFactory, Collection<Integer> partitions) throws Exception {
Map<Address, List<Integer>> memberPartitions = new HashMap<Address, List<Integer>>(3);
InternalPartitionService partitionService = nodeEngine.getPartitionService();
for (int partition : partitions) {
Address owner = partitionService.getPartitionOwnerOrWait(partition);
if (!memberPartitions.containsKey(owner)) {
memberPartitions.put(owner, new ArrayList<Integer>());
}
memberPartitions.get(owner).add(partition);
}
InvokeOnPartitions invokeOnPartitions = new InvokeOnPartitions(this, serviceName, operationFactory, memberPartitions);
return invokeOnPartitions.invoke();
}
Aggregations