Search in sources :

Example 21 with MemberImpl

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

the class MembershipManager method onMemberRemove.

void onMemberRemove(MemberImpl... deadMembers) {
    if (deadMembers.length == 0) {
        return;
    }
    // sync calls
    node.getPartitionService().memberRemoved(deadMembers);
    for (MemberImpl deadMember : deadMembers) {
        nodeEngine.onMemberLeft(deadMember);
    }
    node.getNodeExtension().onMemberListChange();
}
Also used : MemberImpl(com.hazelcast.cluster.impl.MemberImpl)

Example 22 with MemberImpl

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

the class MemberHeartbeatPlugin method render.

private void render(DiagnosticsLogWriter writer, ClusterServiceImpl clusterService) {
    ClusterHeartbeatManager clusterHeartbeatManager = clusterService.getClusterHeartbeatManager();
    long expectedIntervalMillis = clusterHeartbeatManager.getHeartbeatIntervalMillis();
    long nowMillis = System.currentTimeMillis();
    for (MemberImpl member : clusterService.getMemberImpls()) {
        long lastHeartbeatMillis = clusterHeartbeatManager.getLastHeartbeatTime(member);
        if (lastHeartbeatMillis == 0L) {
            // member without a heartbeat; lets skip it
            continue;
        }
        long noHeartbeatMillis = nowMillis - lastHeartbeatMillis;
        float deviation = HUNDRED * ((float) (noHeartbeatMillis - expectedIntervalMillis)) / expectedIntervalMillis;
        if (deviation >= maxDeviationPercentage) {
            startLazyMainSection(writer);
            writer.startSection("member" + member.getAddress());
            writer.writeKeyValueEntry("deviation(%)", deviation);
            writer.writeKeyValueEntry("noHeartbeat(ms)", noHeartbeatMillis);
            writer.writeKeyValueEntry("lastHeartbeat(ms)", lastHeartbeatMillis);
            writer.writeKeyValueEntryAsDateTime("lastHeartbeat(date-time)", lastHeartbeatMillis);
            writer.writeKeyValueEntry("now(ms)", nowMillis);
            writer.writeKeyValueEntryAsDateTime("now(date-time)", nowMillis);
            writer.endSection();
        }
    }
    endLazyMainSection(writer);
}
Also used : ClusterHeartbeatManager(com.hazelcast.internal.cluster.impl.ClusterHeartbeatManager) MemberImpl(com.hazelcast.cluster.impl.MemberImpl)

Example 23 with MemberImpl

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

the class LockSupportServiceImpl method memberRemoved.

@Override
public void memberRemoved(MembershipServiceEvent event) {
    final MemberImpl member = event.getMember();
    final UUID uuid = member.getUuid();
    releaseLocksOwnedBy(uuid);
}
Also used : MemberImpl(com.hazelcast.cluster.impl.MemberImpl) UUID(java.util.UUID)

Example 24 with MemberImpl

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

the class PartitionReplicaStateChecker method invokeReplicaSyncOperations.

@SuppressWarnings("checkstyle:npathcomplexity")
private int invokeReplicaSyncOperations(int maxBackupCount, Semaphore semaphore, AtomicBoolean result) {
    MemberImpl localMember = node.getLocalMember();
    BiConsumer<Object, Throwable> callback = new ReplicaSyncResponseCallback(result, semaphore);
    ClusterServiceImpl clusterService = node.getClusterService();
    ClusterState clusterState = clusterService.getClusterState();
    int ownedCount = 0;
    for (InternalPartition partition : partitionStateManager.getPartitions()) {
        PartitionReplica owner = partition.getOwnerReplicaOrNull();
        if (owner == null) {
            result.set(false);
            continue;
        }
        if (!owner.isIdentical(localMember)) {
            continue;
        }
        ownedCount++;
        if (maxBackupCount == 0) {
            if (partition.isMigrating()) {
                result.set(false);
            }
            continue;
        }
        for (int index = 1; index <= maxBackupCount; index++) {
            PartitionReplica replicaOwner = partition.getReplica(index);
            if (replicaOwner == null) {
                result.set(false);
                semaphore.release();
                continue;
            }
            // because to be able to change cluster state, we ensure that there are no ongoing/pending migrations
            if (!clusterState.isJoinAllowed() && clusterService.isMissingMember(replicaOwner.address(), replicaOwner.uuid())) {
                semaphore.release();
                continue;
            }
            int partitionId = partition.getPartitionId();
            PartitionSpecificRunnable task = new CheckPartitionReplicaVersionTask(nodeEngine, partitionId, index, callback);
            nodeEngine.getOperationService().execute(task);
        }
    }
    return ownedCount;
}
Also used : ClusterState(com.hazelcast.cluster.ClusterState) PartitionReplica(com.hazelcast.internal.partition.PartitionReplica) MemberImpl(com.hazelcast.cluster.impl.MemberImpl) ClusterServiceImpl(com.hazelcast.internal.cluster.impl.ClusterServiceImpl) InternalPartition(com.hazelcast.internal.partition.InternalPartition) PartitionSpecificRunnable(com.hazelcast.spi.impl.PartitionSpecificRunnable)

Example 25 with MemberImpl

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

the class TopicService method dispatchEvent.

@Override
public void dispatchEvent(Object event, Object listener) {
    TopicEvent topicEvent = (TopicEvent) event;
    ClusterService clusterService = nodeEngine.getClusterService();
    MemberImpl member = clusterService.getMember(topicEvent.publisherAddress);
    if (member == null) {
        member = new MemberImpl.Builder(topicEvent.publisherAddress).version(nodeEngine.getVersion()).build();
    }
    Message message = new DataAwareMessage(topicEvent.name, topicEvent.data, topicEvent.publishTime, member, nodeEngine.getSerializationService());
    incrementReceivedMessages(topicEvent.name);
    MessageListener messageListener = (MessageListener) listener;
    messageListener.onMessage(message);
}
Also used : ClusterService(com.hazelcast.internal.cluster.ClusterService) Message(com.hazelcast.topic.Message) MemberImpl(com.hazelcast.cluster.impl.MemberImpl) MessageListener(com.hazelcast.topic.MessageListener)

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