use of com.hazelcast.internal.partition.PartitionReplica in project hazelcast by hazelcast.
the class PartitionDataSerializerHook method createFactory.
@Override
public DataSerializableFactory createFactory() {
ConstructorFunction<Integer, IdentifiedDataSerializable>[] constructors = new ConstructorFunction[LEN];
constructors[PARTITION_RUNTIME_STATE] = arg -> new PartitionRuntimeState();
constructors[ASSIGN_PARTITIONS] = arg -> new AssignPartitions();
constructors[PARTITION_BACKUP_REPLICA_ANTI_ENTROPY] = arg -> new PartitionBackupReplicaAntiEntropyOperation();
constructors[FETCH_PARTITION_STATE] = arg -> new FetchPartitionStateOperation();
constructors[HAS_ONGOING_MIGRATION] = arg -> new HasOngoingMigration();
constructors[MIGRATION_COMMIT] = arg -> new MigrationCommitOperation();
constructors[PARTITION_STATE_OP] = arg -> new PartitionStateOperation();
constructors[PROMOTION_COMMIT] = arg -> new PromotionCommitOperation();
constructors[REPLICA_SYNC_REQUEST] = arg -> new PartitionReplicaSyncRequest();
constructors[REPLICA_SYNC_RESPONSE] = arg -> new PartitionReplicaSyncResponse();
constructors[REPLICA_SYNC_RETRY_RESPONSE] = arg -> new PartitionReplicaSyncRetryResponse();
constructors[SAFE_STATE_CHECK] = arg -> new SafeStateCheckOperation();
constructors[SHUTDOWN_REQUEST] = arg -> new ShutdownRequestOperation();
constructors[SHUTDOWN_RESPONSE] = arg -> new ShutdownResponseOperation();
constructors[REPLICA_FRAGMENT_MIGRATION_STATE] = arg -> new ReplicaFragmentMigrationState();
constructors[MIGRATION] = arg -> new MigrationOperation();
constructors[MIGRATION_REQUEST] = arg -> new MigrationRequestOperation();
constructors[NON_FRAGMENTED_SERVICE_NAMESPACE] = arg -> NonFragmentedServiceNamespace.INSTANCE;
constructors[PARTITION_REPLICA] = arg -> new PartitionReplica();
constructors[PUBLISH_COMPLETED_MIGRATIONS] = arg -> new PublishCompletedMigrationsOperation();
constructors[PARTITION_STATE_CHECK_OP] = arg -> new PartitionStateCheckOperation();
constructors[REPLICA_MIGRATION_EVENT] = arg -> new ReplicaMigrationEventImpl();
constructors[MIGRATION_EVENT] = arg -> new MigrationStateImpl();
constructors[PARTITION_LOST_EVENT] = arg -> new PartitionLostEventImpl();
constructors[REPLICA_SYNC_REQUEST_OFFLOADABLE] = arg -> new PartitionReplicaSyncRequestOffloadable();
return new ArrayDataSerializableFactory(constructors);
}
use of com.hazelcast.internal.partition.PartitionReplica in project hazelcast by hazelcast.
the class PartitionReplicaStateChecker method invokeReplicaSyncOperations.
@SuppressWarnings("checkstyle:npathcomplexity")
private int invokeReplicaSyncOperations(int maxBackupCount, Semaphore semaphore, AtomicBoolean result) {
MemberImpl localMember = node.getLocalMember();
BiConsumer<Object, Throwable> callback = new ReplicaSyncResponseCallback(result, semaphore);
ClusterServiceImpl clusterService = node.getClusterService();
ClusterState clusterState = clusterService.getClusterState();
int ownedCount = 0;
for (InternalPartition partition : partitionStateManager.getPartitions()) {
PartitionReplica owner = partition.getOwnerReplicaOrNull();
if (owner == null) {
result.set(false);
continue;
}
if (!owner.isIdentical(localMember)) {
continue;
}
ownedCount++;
if (maxBackupCount == 0) {
if (partition.isMigrating()) {
result.set(false);
}
continue;
}
for (int index = 1; index <= maxBackupCount; index++) {
PartitionReplica replicaOwner = partition.getReplica(index);
if (replicaOwner == null) {
result.set(false);
semaphore.release();
continue;
}
// because to be able to change cluster state, we ensure that there are no ongoing/pending migrations
if (!clusterState.isJoinAllowed() && clusterService.isMissingMember(replicaOwner.address(), replicaOwner.uuid())) {
semaphore.release();
continue;
}
int partitionId = partition.getPartitionId();
PartitionSpecificRunnable task = new CheckPartitionReplicaVersionTask(nodeEngine, partitionId, index, callback);
nodeEngine.getOperationService().execute(task);
}
}
return ownedCount;
}
use of com.hazelcast.internal.partition.PartitionReplica in project hazelcast by hazelcast.
the class PartitionStateManager method reset.
void reset() {
initialized = false;
stateStamp = INITIAL_STAMP;
// local member uuid changes during ClusterService reset
PartitionReplica localReplica = PartitionReplica.from(node.getLocalMember());
for (InternalPartitionImpl partition : partitions) {
partition.reset(localReplica);
}
}
use of com.hazelcast.internal.partition.PartitionReplica in project hazelcast by hazelcast.
the class BaseMigrationOperation method verifyPartitionOwner.
/**
* Verifies that this node is the owner of the partition.
*/
private void verifyPartitionOwner() {
InternalPartition partition = getPartition();
PartitionReplica owner = partition.getOwnerReplicaOrNull();
if (owner == null) {
throw new RetryableHazelcastException("Cannot migrate at the moment! Owner of the partition is null => " + migrationInfo);
}
if (!owner.isIdentical(getNodeEngine().getLocalMember())) {
throw new RetryableHazelcastException("Owner of partition is not this node! => " + toString());
}
}
use of com.hazelcast.internal.partition.PartitionReplica in project hazelcast by hazelcast.
the class BaseMigrationOperation method verifyExistingDestination.
/**
* Verifies that the destination is a cluster member.
*/
final void verifyExistingDestination() {
PartitionReplica destination = migrationInfo.getDestination();
Member target = getNodeEngine().getClusterService().getMember(destination.address(), destination.uuid());
if (target == null) {
throw new TargetNotMemberException("Destination of migration could not be found! => " + toString());
}
}
Aggregations