use of com.hazelcast.cluster.Member 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());
}
}
use of com.hazelcast.cluster.Member in project hazelcast by hazelcast.
the class MigrationCommitOperation method run.
@Override
public void run() {
NodeEngine nodeEngine = getNodeEngine();
final Member localMember = nodeEngine.getLocalMember();
if (!localMember.getUuid().equals(expectedMemberUuid)) {
throw new IllegalStateException("This " + localMember + " is migration commit destination but most probably it's restarted " + "and not the expected target.");
}
InternalPartitionServiceImpl service = getService();
success = service.commitMigrationOnDestination(migration, getCallerAddress());
}
use of com.hazelcast.cluster.Member in project hazelcast by hazelcast.
the class PartitionStateGeneratorImpl method createNodeGroups.
private Queue<NodeGroup> createNodeGroups(Collection<MemberGroup> memberGroups) {
Queue<NodeGroup> nodeGroups = new LinkedList<>();
if (memberGroups == null || memberGroups.isEmpty()) {
return nodeGroups;
}
for (MemberGroup memberGroup : memberGroups) {
NodeGroup nodeGroup;
if (memberGroup.size() == 0) {
continue;
}
if (memberGroup instanceof SingleMemberGroup || memberGroup.size() == 1) {
nodeGroup = new SingleNodeGroup();
Member next = memberGroup.iterator().next();
nodeGroup.addNode(PartitionReplica.from(next));
} else {
nodeGroup = new DefaultNodeGroup();
Iterator<Member> iter = memberGroup.iterator();
while (iter.hasNext()) {
Member next = iter.next();
nodeGroup.addNode(PartitionReplica.from(next));
}
}
nodeGroups.add(nodeGroup);
}
return nodeGroups;
}
use of com.hazelcast.cluster.Member in project hazelcast by hazelcast.
the class PartitionReplicaSyncResponse method nodeNotOwnsBackup.
/**
* Fail all replication operations with the exception that this node is no longer the replica with the sent index
*/
private void nodeNotOwnsBackup(InternalPartitionImpl partition) {
int partitionId = getPartitionId();
int replicaIndex = getReplicaIndex();
NodeEngine nodeEngine = getNodeEngine();
ILogger logger = getLogger();
if (logger.isFinestEnabled()) {
int currentReplicaIndex = partition.getReplicaIndex(PartitionReplica.from(nodeEngine.getLocalMember()));
logger.finest("This node is not backup replica of partitionId=" + partitionId + ", replicaIndex=" + replicaIndex + " anymore. current replicaIndex=" + currentReplicaIndex);
}
if (operations != null) {
PartitionReplica replica = partition.getReplica(replicaIndex);
Member targetMember = null;
if (replica != null) {
ClusterServiceImpl clusterService = (ClusterServiceImpl) nodeEngine.getClusterService();
targetMember = clusterService.getMember(replica.address(), replica.uuid());
}
Throwable throwable = new WrongTargetException(nodeEngine.getLocalMember(), targetMember, partitionId, replicaIndex, getClass().getName());
for (Operation op : operations) {
prepareOperation(op);
onOperationFailure(op, throwable);
}
}
}
use of com.hazelcast.cluster.Member in project hazelcast by hazelcast.
the class PlacementAwareMemberGroupFactory method createInternalMemberGroups.
@Override
protected Set<MemberGroup> createInternalMemberGroups(Collection<? extends Member> allMembers) {
Map<String, MemberGroup> groups = createHashMap(allMembers.size());
for (Member member : allMembers) {
String placementInfo = member.getAttribute(PartitionGroupMetaData.PARTITION_GROUP_PLACEMENT);
if (placementInfo == null) {
throw new IllegalArgumentException("Not enough metadata information is provided. " + "A group name indicating the placement group must be provided with " + "PLACEMENT_AWARE partition group.");
}
MemberGroup group = groups.get(placementInfo);
if (group == null) {
group = new DefaultMemberGroup();
groups.put(placementInfo, group);
}
group.addMember(member);
}
return new HashSet<>(groups.values());
}
Aggregations