Search in sources :

Example 36 with Member

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());
    }
}
Also used : TargetNotMemberException(com.hazelcast.spi.exception.TargetNotMemberException) PartitionReplica(com.hazelcast.internal.partition.PartitionReplica) Member(com.hazelcast.cluster.Member)

Example 37 with Member

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());
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) InternalPartitionServiceImpl(com.hazelcast.internal.partition.impl.InternalPartitionServiceImpl) Member(com.hazelcast.cluster.Member)

Example 38 with Member

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;
}
Also used : MemberGroup(com.hazelcast.spi.partitiongroup.MemberGroup) SingleMemberGroup(com.hazelcast.internal.partition.membergroup.SingleMemberGroup) SingleMemberGroup(com.hazelcast.internal.partition.membergroup.SingleMemberGroup) Member(com.hazelcast.cluster.Member) LinkedList(java.util.LinkedList)

Example 39 with Member

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);
        }
    }
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) PartitionReplica(com.hazelcast.internal.partition.PartitionReplica) ClusterServiceImpl(com.hazelcast.internal.cluster.impl.ClusterServiceImpl) ILogger(com.hazelcast.logging.ILogger) Operation(com.hazelcast.spi.impl.operationservice.Operation) PartitionAwareOperation(com.hazelcast.spi.impl.operationservice.PartitionAwareOperation) UrgentSystemOperation(com.hazelcast.spi.impl.operationservice.UrgentSystemOperation) BackupOperation(com.hazelcast.spi.impl.operationservice.BackupOperation) Member(com.hazelcast.cluster.Member) WrongTargetException(com.hazelcast.spi.exception.WrongTargetException)

Example 40 with Member

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());
}
Also used : MemberGroup(com.hazelcast.spi.partitiongroup.MemberGroup) Member(com.hazelcast.cluster.Member) HashSet(java.util.HashSet)

Aggregations

Member (com.hazelcast.cluster.Member)429 Test (org.junit.Test)210 QuickTest (com.hazelcast.test.annotation.QuickTest)191 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)164 HazelcastInstance (com.hazelcast.core.HazelcastInstance)116 IExecutorService (com.hazelcast.core.IExecutorService)73 Address (com.hazelcast.cluster.Address)62 ArrayList (java.util.ArrayList)55 Future (java.util.concurrent.Future)53 UUID (java.util.UUID)43 Config (com.hazelcast.config.Config)42 CountDownLatch (java.util.concurrent.CountDownLatch)38 Map (java.util.Map)33 HashMap (java.util.HashMap)31 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)28 MultiExecutionCallback (com.hazelcast.core.MultiExecutionCallback)25 List (java.util.List)25 MemberImpl (com.hazelcast.cluster.impl.MemberImpl)24 Operation (com.hazelcast.spi.impl.operationservice.Operation)24 IMap (com.hazelcast.map.IMap)23