Search in sources :

Example 16 with MemberImpl

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

the class ClusterHeartbeatManager method onInvalidHeartbeat.

private void onInvalidHeartbeat(MembersViewMetadata senderMembersViewMetadata) {
    Address senderAddress = senderMembersViewMetadata.getMemberAddress();
    if (clusterService.isMaster()) {
        if (!clusterService.getClusterJoinManager().isMastershipClaimInProgress()) {
            logger.fine("Sending explicit suspicion to " + senderAddress + " for heartbeat " + senderMembersViewMetadata + ", because it is not a member of this cluster" + " or its heartbeat cannot be validated!");
            clusterService.sendExplicitSuspicion(senderMembersViewMetadata);
        }
    } else {
        MemberImpl master = clusterService.getMember(clusterService.getMasterAddress());
        if (clusterService.getMembershipManager().isMemberSuspected(master)) {
            logger.fine("Not sending heartbeat complaint for " + senderMembersViewMetadata + " to suspected master: " + master.getAddress());
            return;
        }
        logger.fine("Sending heartbeat complaint to master " + master.getAddress() + " for heartbeat " + senderMembersViewMetadata + ", because it is not a member of this cluster" + " or its heartbeat cannot be validated!");
        sendHeartbeatComplaintToMaster(senderMembersViewMetadata);
    }
}
Also used : Address(com.hazelcast.cluster.Address) MemberImpl(com.hazelcast.cluster.impl.MemberImpl)

Example 17 with MemberImpl

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

the class ClusterHeartbeatManager method resetHeartbeats.

/**
 * Reset all heartbeats to the current cluster time. Called when system clock jump is detected.
 */
private void resetHeartbeats() {
    SplitBrainProtectionServiceImpl splitBrainProtectionService = nodeEngine.getSplitBrainProtectionService();
    long now = clusterClock.getClusterTime();
    for (MemberImpl member : clusterService.getMemberImpls()) {
        heartbeatFailureDetector.heartbeat(member, now);
        splitBrainProtectionService.onHeartbeat(member, now);
    }
}
Also used : SplitBrainProtectionServiceImpl(com.hazelcast.splitbrainprotection.impl.SplitBrainProtectionServiceImpl) MemberImpl(com.hazelcast.cluster.impl.MemberImpl)

Example 18 with MemberImpl

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

the class ClusterStateManager method changeClusterState.

void changeClusterState(@Nonnull ClusterStateChange stateChange, @Nonnull MemberMap memberMap, @Nonnull TransactionOptions options, long partitionStateStamp, boolean isTransient) {
    checkParameters(stateChange, options);
    if (isCurrentStateEqualToRequestedOne(stateChange)) {
        return;
    }
    ClusterState oldState = getState();
    ClusterState requestedState = stateChange.getClusterStateOrNull();
    NodeEngineImpl nodeEngine = node.getNodeEngine();
    TransactionManagerServiceImpl txManagerService = (TransactionManagerServiceImpl) nodeEngine.getTransactionManagerService();
    Transaction tx = txManagerService.newAllowedDuringPassiveStateTransaction(options);
    notifyBeforeStateChange(oldState, requestedState, isTransient);
    tx.begin();
    try {
        UUID txnId = tx.getTxnId();
        Collection<MemberImpl> members = memberMap.getMembers();
        int memberListVersion = memberMap.getVersion();
        addTransactionRecords(stateChange, tx, members, memberListVersion, partitionStateStamp, isTransient);
        lockClusterStateOnAllMembers(stateChange, nodeEngine, options.getTimeoutMillis(), txnId, members, memberListVersion, partitionStateStamp);
        checkMemberListChange(memberListVersion);
        tx.prepare();
    } catch (Throwable e) {
        tx.rollback();
        notifyAfterStateChange(oldState, requestedState, isTransient);
        if (e instanceof TargetNotMemberException || e.getCause() instanceof MemberLeftException) {
            throw new IllegalStateException("Cluster members changed during state change!", e);
        }
        throw ExceptionUtil.rethrow(e);
    }
    try {
        tx.commit();
    } catch (Throwable e) {
        if (e instanceof TargetNotMemberException || e.getCause() instanceof MemberLeftException) {
            // if new state is passive or frozen. They will be able to rejoin later.
            return;
        }
        throw ExceptionUtil.rethrow(e);
    } finally {
        notifyAfterStateChange(oldState, requestedState, isTransient);
    }
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) ClusterState(com.hazelcast.cluster.ClusterState) TargetNotMemberException(com.hazelcast.spi.exception.TargetNotMemberException) Transaction(com.hazelcast.transaction.impl.Transaction) TransactionManagerServiceImpl(com.hazelcast.transaction.impl.TransactionManagerServiceImpl) MemberImpl(com.hazelcast.cluster.impl.MemberImpl) UUID(java.util.UUID) MemberLeftException(com.hazelcast.core.MemberLeftException)

Example 19 with MemberImpl

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

the class MemberMap method createNew.

/**
 * Creates a new {@code MemberMap} including given members.
 *
 * @param version version
 * @param members members
 * @return a new {@code MemberMap}
 */
static MemberMap createNew(int version, MemberImpl... members) {
    Map<Address, MemberImpl> addressMap = createLinkedHashMap(members.length);
    Map<UUID, MemberImpl> uuidMap = createLinkedHashMap(members.length);
    for (MemberImpl member : members) {
        putMember(addressMap, uuidMap, member);
    }
    return new MemberMap(version, addressMap, uuidMap);
}
Also used : Address(com.hazelcast.cluster.Address) MemberImpl(com.hazelcast.cluster.impl.MemberImpl) UUID(java.util.UUID)

Example 20 with MemberImpl

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

the class MembershipManager method createMember.

private MemberImpl createMember(MemberInfo memberInfo, Map<String, String> attributes) {
    Address address = memberInfo.getAddress();
    Address thisAddress = node.getThisAddress();
    String ipV6ScopeId = thisAddress.getScopeId();
    address.setScopeId(ipV6ScopeId);
    boolean localMember = thisAddress.equals(address);
    MemberImpl.Builder builder;
    if (memberInfo.getAddressMap() != null && memberInfo.getAddressMap().containsKey(MEMBER)) {
        builder = new MemberImpl.Builder(memberInfo.getAddressMap());
    } else {
        builder = new MemberImpl.Builder(memberInfo.getAddress());
    }
    return builder.version(memberInfo.getVersion()).localMember(localMember).uuid(memberInfo.getUuid()).attributes(attributes).liteMember(memberInfo.isLiteMember()).memberListJoinVersion(memberInfo.getMemberListJoinVersion()).instance(node.hazelcastInstance).build();
}
Also used : Address(com.hazelcast.cluster.Address) 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