Search in sources :

Example 16 with MemberImpl

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

the class ClusterServiceImpl method sendMembershipEvents.

private void sendMembershipEvents(Collection<MemberImpl> currentMembers, Collection<MemberImpl> newMembers) {
    Set<Member> eventMembers = new LinkedHashSet<Member>(currentMembers);
    if (!newMembers.isEmpty()) {
        if (newMembers.size() == 1) {
            MemberImpl newMember = newMembers.iterator().next();
            // sync call
            node.getPartitionService().memberAdded(newMember);
            // async events
            eventMembers.add(newMember);
            sendMembershipEventNotifications(newMember, unmodifiableSet(eventMembers), true);
        } else {
            for (MemberImpl newMember : newMembers) {
                // sync call
                node.getPartitionService().memberAdded(newMember);
                // async events
                eventMembers.add(newMember);
                sendMembershipEventNotifications(newMember, unmodifiableSet(new LinkedHashSet<Member>(eventMembers)), true);
            }
        }
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) MemberImpl(com.hazelcast.instance.MemberImpl) Member(com.hazelcast.core.Member)

Example 17 with MemberImpl

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

the class ClusterServiceImpl method shrinkMembersRemovedWhileClusterIsNotActiveState.

public void shrinkMembersRemovedWhileClusterIsNotActiveState(Collection<String> memberUuidsToRemove) {
    lock.lock();
    try {
        Set<MemberImpl> membersRemovedInNotActiveState = new LinkedHashSet<MemberImpl>(membersRemovedInNotActiveStateRef.get().getMembers());
        Iterator<MemberImpl> it = membersRemovedInNotActiveState.iterator();
        while (it.hasNext()) {
            MemberImpl member = it.next();
            if (memberUuidsToRemove.contains(member.getUuid())) {
                logger.fine("Removing " + member + " from members removed while in cluster not active state");
                it.remove();
            }
        }
        membersRemovedInNotActiveStateRef.set(MemberMap.createNew(membersRemovedInNotActiveState.toArray(new MemberImpl[0])));
    } finally {
        lock.unlock();
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) MemberImpl(com.hazelcast.instance.MemberImpl)

Example 18 with MemberImpl

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

the class MasterConfirmationOperation method run.

@Override
public void run() {
    final Address endpoint = getCallerAddress();
    if (endpoint == null) {
        return;
    }
    final ClusterServiceImpl clusterService = getService();
    final ILogger logger = getLogger();
    final MemberImpl member = clusterService.getMember(endpoint);
    if (member == null) {
        logger.warning("MasterConfirmation has been received from " + endpoint + ", but it is not a member of this cluster!");
        OperationService operationService = getNodeEngine().getOperationService();
        operationService.send(new MemberRemoveOperation(clusterService.getThisAddress()), endpoint);
    } else {
        if (clusterService.isMaster()) {
            clusterService.getClusterHeartbeatManager().acceptMasterConfirmation(member, timestamp);
        } else {
            logger.warning(endpoint + " has sent MasterConfirmation, but this node is not master!");
        }
    }
}
Also used : Address(com.hazelcast.nio.Address) MemberImpl(com.hazelcast.instance.MemberImpl) ClusterServiceImpl(com.hazelcast.internal.cluster.impl.ClusterServiceImpl) ILogger(com.hazelcast.logging.ILogger) OperationService(com.hazelcast.spi.OperationService)

Example 19 with MemberImpl

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

the class TimedMemberStateFactory method createTimedMemberState.

public TimedMemberState createTimedMemberState() {
    MemberStateImpl memberState = new MemberStateImpl();
    Collection<StatisticsAwareService> services = instance.node.nodeEngine.getServices(StatisticsAwareService.class);
    TimedMemberState timedMemberState = new TimedMemberState();
    createMemberState(timedMemberState, memberState, services);
    timedMemberState.setMaster(instance.node.isMaster());
    timedMemberState.setMemberList(new ArrayList<String>());
    if (timedMemberState.getMaster()) {
        Set<Member> memberSet = instance.getCluster().getMembers();
        for (Member member : memberSet) {
            MemberImpl memberImpl = (MemberImpl) member;
            Address address = memberImpl.getAddress();
            timedMemberState.getMemberList().add(address.getHost() + ":" + address.getPort());
        }
    }
    timedMemberState.setMemberState(memberState);
    GroupConfig groupConfig = instance.getConfig().getGroupConfig();
    timedMemberState.setClusterName(groupConfig.getName());
    return timedMemberState;
}
Also used : StatisticsAwareService(com.hazelcast.spi.StatisticsAwareService) Address(com.hazelcast.nio.Address) GroupConfig(com.hazelcast.config.GroupConfig) MemberStateImpl(com.hazelcast.monitor.impl.MemberStateImpl) MemberImpl(com.hazelcast.instance.MemberImpl) Member(com.hazelcast.core.Member) TimedMemberState(com.hazelcast.monitor.TimedMemberState)

Example 20 with MemberImpl

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

the class MigrationManager method commitMigrationToDestination.

private boolean commitMigrationToDestination(Address destination, MigrationInfo migration) {
    assert migration != null : "No migrations to commit! destination=" + destination;
    if (node.getThisAddress().equals(destination)) {
        if (logger.isFinestEnabled()) {
            logger.finest("Shortcutting migration commit, since destination is master. -> " + migration);
        }
        return true;
    }
    MemberImpl member = node.getClusterService().getMember(destination);
    if (member == null) {
        logger.warning("Destination " + destination + " is not member anymore");
        return false;
    }
    try {
        if (logger.isFinestEnabled()) {
            logger.finest("Sending commit operation to " + destination + " for " + migration);
        }
        PartitionRuntimeState partitionState = partitionService.createMigrationCommitPartitionState(migration);
        String destinationUuid = member.getUuid();
        MigrationCommitOperation operation = new MigrationCommitOperation(partitionState, destinationUuid);
        Future<Boolean> future = nodeEngine.getOperationService().createInvocationBuilder(SERVICE_NAME, operation, destination).setTryCount(Integer.MAX_VALUE).setCallTimeout(Long.MAX_VALUE).invoke();
        boolean result = future.get();
        if (logger.isFinestEnabled()) {
            logger.finest("Migration commit result " + result + " from " + destination + " for " + migration);
        }
        return result;
    } catch (Throwable t) {
        logMigrationCommitFailure(destination, migration, t);
    }
    return false;
}
Also used : MigrationCommitOperation(com.hazelcast.internal.partition.operation.MigrationCommitOperation) MemberImpl(com.hazelcast.instance.MemberImpl) PartitionRuntimeState(com.hazelcast.internal.partition.PartitionRuntimeState) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean)

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