use of com.hazelcast.internal.partition.InternalPartitionService in project hazelcast by hazelcast.
the class ClusterStateManager method checkMigrationsAndPartitionStateVersion.
private void checkMigrationsAndPartitionStateVersion(ClusterStateChange stateChange, int partitionStateVersion) {
final InternalPartitionService partitionService = node.getPartitionService();
final int thisPartitionStateVersion = partitionService.getPartitionStateVersion();
if (partitionService.hasOnGoingMigrationLocal()) {
throw new IllegalStateException("Still have pending migration tasks, " + "cannot lock cluster state! New state: " + stateChange + ", current state: " + getState());
} else if (partitionStateVersion != thisPartitionStateVersion) {
throw new IllegalStateException("Can not lock cluster state! Partition tables have different versions! " + "Expected version: " + partitionStateVersion + " Current version: " + thisPartitionStateVersion);
}
}
use of com.hazelcast.internal.partition.InternalPartitionService in project hazelcast by hazelcast.
the class Backup method beforeRun.
@Override
public void beforeRun() throws Exception {
NodeEngine nodeEngine = getNodeEngine();
int partitionId = getPartitionId();
InternalPartitionService partitionService = (InternalPartitionService) nodeEngine.getPartitionService();
ILogger logger = getLogger();
IPartition partition = partitionService.getPartition(partitionId);
Address owner = partition.getReplicaAddress(getReplicaIndex());
if (!nodeEngine.getThisAddress().equals(owner)) {
valid = false;
if (logger.isFinestEnabled()) {
logger.finest("Wrong target! " + toString() + " cannot be processed! Target should be: " + owner);
}
} else if (partitionService.isPartitionReplicaVersionStale(getPartitionId(), replicaVersions, getReplicaIndex())) {
valid = false;
if (logger.isFineEnabled()) {
long[] currentVersions = partitionService.getPartitionReplicaVersions(partitionId);
logger.fine("Ignoring stale backup! Current-versions: " + Arrays.toString(currentVersions) + ", Backup-versions: " + Arrays.toString(replicaVersions));
}
}
}
use of com.hazelcast.internal.partition.InternalPartitionService in project hazelcast by hazelcast.
the class Backup method run.
@Override
public void run() throws Exception {
if (!valid) {
onExecutionFailure(new IllegalStateException("Wrong target! " + toString() + " cannot be processed!"));
return;
}
ensureBackupOperationInitialized();
backupOp.beforeRun();
backupOp.run();
backupOp.afterRun();
NodeEngineImpl nodeEngine = (NodeEngineImpl) getNodeEngine();
InternalPartitionService partitionService = nodeEngine.getPartitionService();
partitionService.updatePartitionReplicaVersions(getPartitionId(), replicaVersions, getReplicaIndex());
}
use of com.hazelcast.internal.partition.InternalPartitionService in project hazelcast by hazelcast.
the class XAService method clearPartitionReplica.
private void clearPartitionReplica(int partitionId) {
InternalPartitionService partitionService = nodeEngine.getPartitionService();
Iterator<Map.Entry<SerializableXID, List<XATransaction>>> iterator = transactions.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<SerializableXID, List<XATransaction>> entry = iterator.next();
SerializableXID xid = entry.getKey();
int xidPartitionId = partitionService.getPartitionId(xid);
if (xidPartitionId == partitionId) {
iterator.remove();
}
}
}
use of com.hazelcast.internal.partition.InternalPartitionService in project hazelcast by hazelcast.
the class OperationBackupHandler method asyncBackups.
int asyncBackups(int requestedSyncBackups, int requestedAsyncBackups, boolean syncForced) {
if (syncForced || requestedAsyncBackups == 0) {
// if there are no asyncBackups then we are also done.
return 0;
}
InternalPartitionService partitionService = node.getPartitionService();
int maxBackupCount = partitionService.getMaxAllowedBackupCount();
return min(maxBackupCount - requestedSyncBackups, requestedAsyncBackups);
}
Aggregations