Search in sources :

Example 1 with MemberImpl

use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.

the class MapPublisherCreateMessageTask method call.

@Override
protected Object call() throws Exception {
    ClusterService clusterService = clientEngine.getClusterService();
    Collection<MemberImpl> members = clusterService.getMemberImpls();
    List<Future> futures = new ArrayList<Future>(members.size());
    createInvocations(members, futures);
    return fetchMapSnapshotFrom(futures);
}
Also used : ClusterService(com.hazelcast.internal.cluster.ClusterService) MemberImpl(com.hazelcast.cluster.impl.MemberImpl) ArrayList(java.util.ArrayList) Future(java.util.concurrent.Future)

Example 2 with MemberImpl

use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.

the class ClusterJoinManager method checkIfJoinRequestFromAnExistingMember.

@SuppressWarnings("checkstyle:cyclomaticcomplexity")
private boolean checkIfJoinRequestFromAnExistingMember(JoinMessage joinMessage, ServerConnection connection) {
    Address targetAddress = joinMessage.getAddress();
    MemberImpl member = clusterService.getMember(targetAddress);
    if (member == null) {
        return checkIfUsingAnExistingMemberUuid(joinMessage);
    }
    if (joinMessage.getUuid().equals(member.getUuid())) {
        sendMasterAnswer(targetAddress);
        if (clusterService.isMaster() && !isMastershipClaimInProgress()) {
            if (logger.isFineEnabled()) {
                logger.fine(format("Ignoring join request, member already exists: %s", joinMessage));
            }
            // send members update back to node trying to join again...
            boolean deferPartitionProcessing = isMemberRestartingWithPersistence(member.getAttributes());
            OnJoinOp preJoinOp = preparePreJoinOps();
            OnJoinOp postJoinOp = preparePostJoinOp();
            PartitionRuntimeState partitionRuntimeState = node.getPartitionService().createPartitionState();
            Operation op = new FinalizeJoinOp(member.getUuid(), clusterService.getMembershipManager().getMembersView(), preJoinOp, postJoinOp, clusterClock.getClusterTime(), clusterService.getClusterId(), clusterClock.getClusterStartTime(), clusterStateManager.getState(), clusterService.getClusterVersion(), partitionRuntimeState, deferPartitionProcessing);
            op.setCallerUuid(clusterService.getThisUuid());
            invokeClusterOp(op, targetAddress);
        }
        return true;
    }
    // after I suspect from the target.
    if (clusterService.isMaster() || targetAddress.equals(clusterService.getMasterAddress())) {
        String msg = format("New join request has been received from an existing endpoint %s." + " Removing old member and processing join request...", member);
        logger.warning(msg);
        clusterService.suspectMember(member, msg, false);
        ServerConnection existing = node.getServer().getConnectionManager(MEMBER).get(targetAddress);
        if (existing != connection) {
            if (existing != null) {
                existing.close(msg, null);
            }
            node.getServer().getConnectionManager(MEMBER).register(targetAddress, joinMessage.getUuid(), connection);
        }
    }
    return true;
}
Also used : Address(com.hazelcast.cluster.Address) OnJoinOp(com.hazelcast.internal.cluster.impl.operations.OnJoinOp) MemberImpl(com.hazelcast.cluster.impl.MemberImpl) PartitionRuntimeState(com.hazelcast.internal.partition.PartitionRuntimeState) ServerConnection(com.hazelcast.internal.server.ServerConnection) Operation(com.hazelcast.spi.impl.operationservice.Operation) FinalizeJoinOp(com.hazelcast.internal.cluster.impl.operations.FinalizeJoinOp)

Example 3 with MemberImpl

use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.

the class ClusterServiceImpl method suspectAddressIfNotConnected.

public void suspectAddressIfNotConnected(Address address) {
    lock.lock();
    try {
        MemberImpl member = getMember(address);
        if (member == null) {
            if (logger.isFineEnabled()) {
                logger.fine("Cannot suspect " + address + ", since it's not a member.");
            }
            return;
        }
        Connection conn = node.getServer().getConnectionManager(MEMBER).get(address);
        if (conn != null && conn.isAlive()) {
            if (logger.isFineEnabled()) {
                logger.fine("Cannot suspect " + member + ", since there's a live connection -> " + conn);
            }
            return;
        }
        suspectMember(member, "No connection", false);
    } finally {
        lock.unlock();
    }
}
Also used : MemberImpl(com.hazelcast.cluster.impl.MemberImpl) Connection(com.hazelcast.internal.nio.Connection)

Example 4 with MemberImpl

use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.

the class ClusterServiceImpl method getMasterMember.

private MemberImpl getMasterMember() {
    MemberImpl master;
    lock.lock();
    try {
        Address masterAddress = getMasterAddress();
        if (masterAddress == null) {
            throw new IllegalStateException("Master is not known yet!");
        }
        master = getMember(masterAddress);
    } finally {
        lock.unlock();
    }
    return master;
}
Also used : Address(com.hazelcast.cluster.Address) MemberImpl(com.hazelcast.cluster.impl.MemberImpl)

Example 5 with MemberImpl

use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.

the class PartialDisconnectionHandler method update.

/**
 * Updates the disconnected members set for the given member if the given
 * timestamp is greater than the highest observed timestamp.
 *
 * @return true if the internal disconnected members set is updated.
 */
boolean update(MemberImpl member, long timestamp, Collection<MemberImpl> disconnectedMembers) {
    if (timestamp < lastUpdated) {
        return false;
    }
    Set<MemberImpl> currentDisconnectedMembers = disconnections.get(member);
    if (currentDisconnectedMembers == null) {
        if (disconnectedMembers.isEmpty()) {
            return false;
        }
        currentDisconnectedMembers = new HashSet<>();
        disconnections.put(member, currentDisconnectedMembers);
    }
    boolean updated = false;
    for (MemberImpl disconnectedMember : disconnectedMembers) {
        if (currentDisconnectedMembers.add(disconnectedMember) && !disconnections.getOrDefault(disconnectedMember, emptySet()).contains(member)) {
            lastUpdated = timestamp;
            updated = true;
        }
    }
    if (currentDisconnectedMembers.retainAll(disconnectedMembers)) {
        lastUpdated = timestamp;
        updated = true;
    }
    if (currentDisconnectedMembers.isEmpty()) {
        disconnections.remove(member);
    }
    return updated;
}
Also used : MemberImpl(com.hazelcast.cluster.impl.MemberImpl)

Aggregations

MemberImpl (com.hazelcast.cluster.impl.MemberImpl)123 Address (com.hazelcast.cluster.Address)41 Test (org.junit.Test)37 QuickTest (com.hazelcast.test.annotation.QuickTest)34 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)32 Member (com.hazelcast.cluster.Member)21 HazelcastInstance (com.hazelcast.core.HazelcastInstance)16 UUID (java.util.UUID)14 ArrayList (java.util.ArrayList)10 MemberInfo (com.hazelcast.internal.cluster.MemberInfo)9 HashMap (java.util.HashMap)9 InetAddress (java.net.InetAddress)8 HashSet (java.util.HashSet)8 ClusterService (com.hazelcast.internal.cluster.ClusterService)7 Config (com.hazelcast.config.Config)6 Future (java.util.concurrent.Future)6 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)5 StaticMemberNodeContext (com.hazelcast.instance.StaticMemberNodeContext)4 HazelcastInstanceFactory.newHazelcastInstance (com.hazelcast.instance.impl.HazelcastInstanceFactory.newHazelcastInstance)4 MembersUpdateOp (com.hazelcast.internal.cluster.impl.operations.MembersUpdateOp)4