Search in sources :

Example 66 with MemberImpl

use of com.hazelcast.instance.MemberImpl in project hazelcast by hazelcast.

the class HeartbeatOperation method run.

@Override
public void run() {
    ClusterServiceImpl service = getService();
    MemberImpl member = service.getMember(getCallerAddress());
    if (member == null) {
        ILogger logger = getLogger();
        if (logger.isFineEnabled()) {
            logger.fine("Heartbeat received from an unknown endpoint: " + getCallerAddress());
        }
        return;
    }
    service.getClusterHeartbeatManager().onHeartbeat(member, timestamp);
}
Also used : MemberImpl(com.hazelcast.instance.MemberImpl) ClusterServiceImpl(com.hazelcast.internal.cluster.impl.ClusterServiceImpl) ILogger(com.hazelcast.logging.ILogger)

Example 67 with MemberImpl

use of com.hazelcast.instance.MemberImpl in project hazelcast by hazelcast.

the class ClusterServiceImpl method removeMembersDeadWhileClusterIsNotActive.

void removeMembersDeadWhileClusterIsNotActive() {
    lock.lock();
    try {
        MemberMap memberMap = memberMapRef.get();
        MemberMap membersRemovedInNotActiveState = membersRemovedInNotActiveStateRef.get();
        Collection<MemberImpl> members = membersRemovedInNotActiveState.getMembers();
        membersRemovedInNotActiveStateRef.set(MemberMap.empty());
        for (MemberImpl member : members) {
            onMemberRemove(member, memberMap);
        }
    } finally {
        lock.unlock();
    }
}
Also used : MemberImpl(com.hazelcast.instance.MemberImpl)

Example 68 with MemberImpl

use of com.hazelcast.instance.MemberImpl in project hazelcast by hazelcast.

the class ClusterServiceImpl method sendMemberListToMember.

public void sendMemberListToMember(Address target) {
    if (!isMaster()) {
        return;
    }
    if (thisAddress.equals(target)) {
        return;
    }
    MemberImpl member = getMember(target);
    String memberUuid = member != null ? member.getUuid() : null;
    Collection<MemberImpl> members = getMemberImpls();
    MemberInfoUpdateOperation op = new MemberInfoUpdateOperation(memberUuid, createMemberInfoList(members), clusterClock.getClusterTime(), null, false);
    nodeEngine.getOperationService().send(op, target);
}
Also used : MemberImpl(com.hazelcast.instance.MemberImpl) MemberInfoUpdateOperation(com.hazelcast.internal.cluster.impl.operations.MemberInfoUpdateOperation)

Example 69 with MemberImpl

use of com.hazelcast.instance.MemberImpl in project hazelcast by hazelcast.

the class ClusterServiceImpl method doUpdateMembers.

private void doUpdateMembers(Collection<MemberInfo> members) {
    MemberMap currentMemberMap = memberMapRef.get();
    String scopeId = thisAddress.getScopeId();
    Collection<MemberImpl> newMembers = new LinkedList<MemberImpl>();
    MemberImpl[] updatedMembers = new MemberImpl[members.size()];
    int memberIndex = 0;
    for (MemberInfo memberInfo : members) {
        Address address = memberInfo.getAddress();
        MemberImpl member = currentMemberMap.getMember(address);
        if (member == null) {
            member = createMember(memberInfo, scopeId);
            newMembers.add(member);
            long now = clusterClock.getClusterTime();
            clusterHeartbeatManager.onHeartbeat(member, now);
            clusterHeartbeatManager.acceptMasterConfirmation(member, now);
            repairPartitionTableIfReturningMember(member);
        }
        updatedMembers[memberIndex++] = member;
    }
    setMembers(updatedMembers);
    sendMembershipEvents(currentMemberMap.getMembers(), newMembers);
    MemberMap membersRemovedInNotActiveState = membersRemovedInNotActiveStateRef.get();
    membersRemovedInNotActiveStateRef.set(MemberMap.cloneExcluding(membersRemovedInNotActiveState, updatedMembers));
    clusterHeartbeatManager.heartbeat();
    logger.info(membersString());
}
Also used : MemberInfo(com.hazelcast.internal.cluster.MemberInfo) Address(com.hazelcast.nio.Address) MemberImpl(com.hazelcast.instance.MemberImpl) LinkedList(java.util.LinkedList)

Example 70 with MemberImpl

use of com.hazelcast.instance.MemberImpl in project hazelcast by hazelcast.

the class ClusterServiceImpl method membersString.

public String membersString() {
    StringBuilder sb = new StringBuilder("\n\nMembers [");
    Collection<MemberImpl> members = getMemberImpls();
    sb.append(members != null ? members.size() : 0);
    sb.append("] {");
    if (members != null) {
        for (Member member : members) {
            sb.append("\n\t").append(member);
        }
    }
    sb.append("\n}\n");
    return sb.toString();
}
Also used : MemberImpl(com.hazelcast.instance.MemberImpl) Member(com.hazelcast.core.Member)

Aggregations

MemberImpl (com.hazelcast.instance.MemberImpl)86 Address (com.hazelcast.nio.Address)37 Test (org.junit.Test)18 Member (com.hazelcast.core.Member)17 QuickTest (com.hazelcast.test.annotation.QuickTest)16 ParallelTest (com.hazelcast.test.annotation.ParallelTest)14 ArrayList (java.util.ArrayList)12 InetAddress (java.net.InetAddress)9 Future (java.util.concurrent.Future)9 HashSet (java.util.HashSet)8 HazelcastInstance (com.hazelcast.core.HazelcastInstance)7 MemberInfo (com.hazelcast.internal.cluster.MemberInfo)7 ClusterService (com.hazelcast.internal.cluster.ClusterService)5 MemberInfoUpdateOperation (com.hazelcast.internal.cluster.impl.operations.MemberInfoUpdateOperation)5 PartitionRuntimeState (com.hazelcast.internal.partition.PartitionRuntimeState)5 ILogger (com.hazelcast.logging.ILogger)5 OperationService (com.hazelcast.spi.OperationService)5 InternalOperationService (com.hazelcast.spi.impl.operationservice.InternalOperationService)5 Before (org.junit.Before)5 ClusterServiceImpl (com.hazelcast.internal.cluster.impl.ClusterServiceImpl)4