use of com.hazelcast.internal.partition.impl.PartitionReplicaManager in project hazelcast by hazelcast.
the class ReplicaSyncResponse method postProcessReplicaSync.
private void postProcessReplicaSync(InternalPartitionServiceImpl partitionService, int currentReplicaIndex) {
int partitionId = getPartitionId();
int replicaIndex = getReplicaIndex();
PartitionReplicaManager replicaManager = partitionService.getReplicaManager();
if (replicaIndex == currentReplicaIndex) {
replicaManager.finalizeReplicaSync(partitionId, replicaIndex, replicaVersions);
} else {
replicaManager.clearReplicaSyncRequest(partitionId, replicaIndex);
if (currentReplicaIndex < 0) {
replicaManager.clearPartitionReplicaVersions(partitionId);
} else if (currentReplicaIndex > 0) {
replicaManager.triggerPartitionReplicaSync(partitionId, currentReplicaIndex, 0);
}
}
}
use of com.hazelcast.internal.partition.impl.PartitionReplicaManager in project hazelcast by hazelcast.
the class CheckReplicaVersion method run.
@Override
public void run() throws Exception {
InternalPartitionServiceImpl partitionService = getService();
int partitionId = getPartitionId();
int replicaIndex = getReplicaIndex();
PartitionReplicaManager replicaManager = partitionService.getReplicaManager();
long[] currentVersions = replicaManager.getPartitionReplicaVersions(partitionId);
long currentVersion = currentVersions[replicaIndex - 1];
if (replicaManager.isPartitionReplicaVersionDirty(partitionId) || currentVersion != version) {
logBackupVersionMismatch(currentVersion);
replicaManager.triggerPartitionReplicaSync(partitionId, replicaIndex, 0L);
response = false;
} else {
response = true;
}
}
use of com.hazelcast.internal.partition.impl.PartitionReplicaManager in project hazelcast by hazelcast.
the class FinalizeMigrationOperation method rollbackDestination.
private void rollbackDestination() {
int partitionId = getPartitionId();
InternalPartitionServiceImpl partitionService = getService();
PartitionReplicaManager replicaManager = partitionService.getReplicaManager();
ILogger logger = getLogger();
int destinationCurrentReplicaIndex = migrationInfo.getDestinationCurrentReplicaIndex();
if (destinationCurrentReplicaIndex == -1) {
replicaManager.clearPartitionReplicaVersions(partitionId);
if (logger.isFinestEnabled()) {
logger.finest("Replica versions are cleared in destination after failed migration. partitionId=" + partitionId);
}
} else {
int replicaOffset = migrationInfo.getDestinationCurrentReplicaIndex() <= 1 ? 1 : migrationInfo.getDestinationCurrentReplicaIndex();
long[] versions = updatePartitionReplicaVersions(replicaManager, partitionId, replicaOffset - 1);
if (logger.isFinestEnabled()) {
logger.finest("Replica versions are rolled back in destination after failed migration. partitionId=" + partitionId + " replica versions=" + Arrays.toString(versions));
}
}
}
use of com.hazelcast.internal.partition.impl.PartitionReplicaManager in project hazelcast by hazelcast.
the class FinalizeMigrationOperation method commitSource.
private void commitSource() {
int partitionId = getPartitionId();
InternalPartitionServiceImpl partitionService = getService();
PartitionReplicaManager replicaManager = partitionService.getReplicaManager();
ILogger logger = getLogger();
int sourceNewReplicaIndex = migrationInfo.getSourceNewReplicaIndex();
if (sourceNewReplicaIndex < 0) {
replicaManager.clearPartitionReplicaVersions(partitionId);
if (logger.isFinestEnabled()) {
logger.finest("Replica versions are cleared in source after migration. partitionId=" + partitionId);
}
} else if (migrationInfo.getSourceCurrentReplicaIndex() != sourceNewReplicaIndex && sourceNewReplicaIndex > 1) {
long[] versions = updatePartitionReplicaVersions(replicaManager, partitionId, sourceNewReplicaIndex - 1);
if (logger.isFinestEnabled()) {
logger.finest("Replica versions are set after SHIFT DOWN migration. partitionId=" + partitionId + " replica versions=" + Arrays.toString(versions));
}
}
}
use of com.hazelcast.internal.partition.impl.PartitionReplicaManager in project hazelcast by hazelcast.
the class MigrationOperation method afterMigrate.
private void afterMigrate() {
if (success) {
InternalPartitionServiceImpl partitionService = getService();
PartitionReplicaManager replicaManager = partitionService.getReplicaManager();
int destinationNewReplicaIndex = migrationInfo.getDestinationNewReplicaIndex();
int replicaOffset = destinationNewReplicaIndex <= 1 ? 1 : destinationNewReplicaIndex;
replicaManager.setPartitionReplicaVersions(migrationInfo.getPartitionId(), replicaVersions, replicaOffset);
if (getLogger().isFinestEnabled()) {
getLogger().finest("ReplicaVersions are set after migration. partitionId=" + migrationInfo.getPartitionId() + " replicaVersions=" + Arrays.toString(replicaVersions));
}
} else if (getLogger().isFinestEnabled()) {
getLogger().finest("ReplicaVersions are not set since migration failed. partitionId=" + migrationInfo.getPartitionId());
}
migrationInfo.doneProcessing();
}
Aggregations