use of com.hazelcast.internal.partition.MigrationInfo in project hazelcast by hazelcast.
the class ClusterDataSerializerHook method createFactory.
@Override
public DataSerializableFactory createFactory() {
ConstructorFunction<Integer, IdentifiedDataSerializable>[] constructors = new ConstructorFunction[LEN];
constructors[AUTH_FAILURE] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
public IdentifiedDataSerializable createNew(Integer arg) {
return new AuthenticationFailureOperation();
}
};
constructors[ADDRESS] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
public IdentifiedDataSerializable createNew(Integer arg) {
return new Address();
}
};
constructors[MEMBER] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
public IdentifiedDataSerializable createNew(Integer arg) {
return new MemberImpl();
}
};
constructors[HEARTBEAT] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
public IdentifiedDataSerializable createNew(Integer arg) {
return new HeartbeatOperation();
}
};
constructors[CONFIG_CHECK] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
public IdentifiedDataSerializable createNew(Integer arg) {
return new ConfigCheck();
}
};
constructors[BIND_MESSAGE] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
public IdentifiedDataSerializable createNew(Integer arg) {
return new BindMessage();
}
};
constructors[MEMBER_INFO_UPDATE] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
public IdentifiedDataSerializable createNew(Integer arg) {
return new MemberInfoUpdateOperation();
}
};
constructors[FINALIZE_JOIN] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
public IdentifiedDataSerializable createNew(Integer arg) {
return new FinalizeJoinOperation();
}
};
constructors[AUTHORIZATION] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
public IdentifiedDataSerializable createNew(Integer arg) {
return new AuthorizationOperation();
}
};
constructors[BEFORE_JOIN_CHECK_FAILURE] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
public IdentifiedDataSerializable createNew(Integer arg) {
return new BeforeJoinCheckFailureOperation();
}
};
constructors[CHANGE_CLUSTER_STATE] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
public IdentifiedDataSerializable createNew(Integer arg) {
return new ChangeClusterStateOperation();
}
};
constructors[CONFIG_MISMATCH] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
public IdentifiedDataSerializable createNew(Integer arg) {
return new ConfigMismatchOperation();
}
};
constructors[GROUP_MISMATCH] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
public IdentifiedDataSerializable createNew(Integer arg) {
return new GroupMismatchOperation();
}
};
constructors[SPLIT_BRAIN_MERGE_VALIDATION] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
public IdentifiedDataSerializable createNew(Integer arg) {
return new SplitBrainMergeValidationOperation();
}
};
constructors[JOIN_REQUEST_OP] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
public IdentifiedDataSerializable createNew(Integer arg) {
return new JoinRequestOperation();
}
};
constructors[LOCK_CLUSTER_STATE] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
public IdentifiedDataSerializable createNew(Integer arg) {
return new LockClusterStateOperation();
}
};
constructors[MASTER_CLAIM] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
public IdentifiedDataSerializable createNew(Integer arg) {
return new MasterClaimOperation();
}
};
constructors[MASTER_CONFIRM] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
public IdentifiedDataSerializable createNew(Integer arg) {
return new MasterConfirmationOperation();
}
};
constructors[MASTER_DISCOVERY] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
public IdentifiedDataSerializable createNew(Integer arg) {
return new MasterDiscoveryOperation();
}
};
constructors[MEMBER_ATTR_CHANGED] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
public IdentifiedDataSerializable createNew(Integer arg) {
return new MemberAttributeChangedOperation();
}
};
constructors[MEMBER_REMOVE] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
public IdentifiedDataSerializable createNew(Integer arg) {
return new MemberRemoveOperation();
}
};
constructors[MERGE_CLUSTERS] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
public IdentifiedDataSerializable createNew(Integer arg) {
return new MergeClustersOperation();
}
};
constructors[POST_JOIN] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
public IdentifiedDataSerializable createNew(Integer arg) {
return new PostJoinOperation();
}
};
constructors[ROLLBACK_CLUSTER_STATE] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
public IdentifiedDataSerializable createNew(Integer arg) {
return new RollbackClusterStateOperation();
}
};
constructors[SET_MASTER] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
public IdentifiedDataSerializable createNew(Integer arg) {
return new SetMasterOperation();
}
};
constructors[SHUTDOWN_NODE] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
public IdentifiedDataSerializable createNew(Integer arg) {
return new ShutdownNodeOperation();
}
};
constructors[TRIGGER_MEMBER_LIST_PUBLISH] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
public IdentifiedDataSerializable createNew(Integer arg) {
return new TriggerMemberListPublishOperation();
}
};
constructors[CLUSTER_STATE_TRANSACTION_LOG_RECORD] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
public IdentifiedDataSerializable createNew(Integer arg) {
return new ClusterStateTransactionLogRecord();
}
};
constructors[MEMBER_INFO] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
public IdentifiedDataSerializable createNew(Integer arg) {
return new MemberInfo();
}
};
constructors[JOIN_MESSAGE] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
public IdentifiedDataSerializable createNew(Integer arg) {
return new JoinMessage();
}
};
constructors[JOIN_REQUEST] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
public IdentifiedDataSerializable createNew(Integer arg) {
return new JoinRequest();
}
};
constructors[MIGRATION_INFO] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
public IdentifiedDataSerializable createNew(Integer arg) {
return new MigrationInfo();
}
};
constructors[MEMBER_VERSION] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
public IdentifiedDataSerializable createNew(Integer arg) {
return new MemberVersion();
}
};
constructors[CLUSTER_STATE_CHANGE] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
public IdentifiedDataSerializable createNew(Integer arg) {
return new ClusterStateChange();
}
};
constructors[SPLIT_BRAIN_JOIN_MESSAGE] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
public IdentifiedDataSerializable createNew(Integer arg) {
return new SplitBrainJoinMessage();
}
};
constructors[VERSION] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {
public IdentifiedDataSerializable createNew(Integer arg) {
return new Version();
}
};
return new ArrayDataSerializableFactory(constructors);
}
use of com.hazelcast.internal.partition.MigrationInfo in project hazelcast by hazelcast.
the class InternalPartitionServiceImpl method createPartitionStateInternal.
public PartitionRuntimeState createPartitionStateInternal() {
lock.lock();
try {
if (!partitionStateManager.isInitialized()) {
return null;
}
List<MigrationInfo> completedMigrations = migrationManager.getCompletedMigrationsCopy();
InternalPartition[] partitions = partitionStateManager.getPartitions();
PartitionRuntimeState state = new PartitionRuntimeState(partitions, completedMigrations, getPartitionStateVersion());
state.setActiveMigration(migrationManager.getActiveMigration());
return state;
} finally {
lock.unlock();
}
}
use of com.hazelcast.internal.partition.MigrationInfo in project hazelcast by hazelcast.
the class MigrationManager method evictCompletedMigrations.
private void evictCompletedMigrations(MigrationInfo currentMigration) {
partitionServiceLock.lock();
try {
assert completedMigrations.contains(currentMigration) : currentMigration + " to evict is not in completed migrations";
Iterator<MigrationInfo> iter = completedMigrations.iterator();
while (iter.hasNext()) {
MigrationInfo migration = iter.next();
iter.remove();
// evict completed migrations including current migration
if (migration.equals(currentMigration)) {
return;
}
}
} finally {
partitionServiceLock.unlock();
}
}
use of com.hazelcast.internal.partition.MigrationInfo in project hazelcast by hazelcast.
the class MigrationPlanner method prioritize.
private void prioritize(List<MigrationInfo> migrations, int i) {
MigrationInfo migration = migrations.get(i);
log("Trying to prioritize migration: %s", migration);
if (migration.getSourceCurrentReplicaIndex() != -1) {
log("Skipping non-copy migration: %s", migration);
return;
}
int k = i - 1;
for (; k >= 0; k--) {
MigrationInfo other = migrations.get(k);
if (other.getSourceCurrentReplicaIndex() == -1) {
log("Cannot prioritize against a copy / shift up. other: %s", other);
break;
}
if (migration.getDestination().equals(other.getSource()) || migration.getDestination().equals(other.getDestination())) {
log("Cannot prioritize against a conflicting migration. other: %s", other);
break;
}
if (other.getSourceNewReplicaIndex() != -1 && other.getSourceNewReplicaIndex() < migration.getDestinationNewReplicaIndex()) {
log("Cannot prioritize against a hotter shift down. other: %s", other);
break;
}
}
if ((k + 1) != i) {
log("Prioritizing migration to: %d", (k + 1));
migrations.remove(i);
migrations.add(k + 1, migration);
}
}
use of com.hazelcast.internal.partition.MigrationInfo in project hazelcast by hazelcast.
the class InternalPartitionServiceImpl method isMemberAllowedToJoin.
@Override
public boolean isMemberAllowedToJoin(Address address) {
lock.lock();
try {
ClusterState clusterState = node.getClusterService().getClusterState();
if (clusterState == ClusterState.FROZEN || clusterState == ClusterState.PASSIVE) {
logger.fine(address + " can join since cluster state is " + clusterState);
return true;
}
if (partitionStateManager.isPresentInPartitionTable(address)) {
logger.fine(address + " is in partition table");
return false;
}
final MigrationRunnable activeTask = migrationManager.getActiveTask();
if (activeTask instanceof MigrationManager.MigrateTask) {
final MigrationManager.MigrateTask migrateTask = (MigrationManager.MigrateTask) activeTask;
final MigrationInfo migrationInfo = migrateTask.migrationInfo;
if (address.equals(migrationInfo.getSource()) || address.equals(migrationInfo.getDestination())) {
logger.fine(address + " cannot join since " + migrationInfo);
return false;
}
}
return true;
} finally {
lock.unlock();
}
}
Aggregations