Search in sources :

Example 11 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 12 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 13 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)

Example 14 with MemberImpl

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

the class PartitionStateGeneratorImpl method createNodeGroups.

private Queue<NodeGroup> createNodeGroups(Collection<MemberGroup> memberGroups) {
    Queue<NodeGroup> nodeGroups = new LinkedList<NodeGroup>();
    if (memberGroups == null || memberGroups.isEmpty()) {
        return nodeGroups;
    }
    for (MemberGroup memberGroup : memberGroups) {
        NodeGroup nodeGroup;
        if (memberGroup.size() == 0) {
            continue;
        }
        if (memberGroup instanceof SingleMemberGroup || memberGroup.size() == 1) {
            nodeGroup = new SingleNodeGroup();
            MemberImpl next = (MemberImpl) memberGroup.iterator().next();
            nodeGroup.addNode(next.getAddress());
        } else {
            nodeGroup = new DefaultNodeGroup();
            Iterator<Member> iter = memberGroup.iterator();
            while (iter.hasNext()) {
                MemberImpl next = (MemberImpl) iter.next();
                nodeGroup.addNode(next.getAddress());
            }
        }
        nodeGroups.add(nodeGroup);
    }
    return nodeGroups;
}
Also used : MemberGroup(com.hazelcast.partition.membergroup.MemberGroup) SingleMemberGroup(com.hazelcast.partition.membergroup.SingleMemberGroup) SingleMemberGroup(com.hazelcast.partition.membergroup.SingleMemberGroup) MemberImpl(com.hazelcast.instance.MemberImpl) Member(com.hazelcast.core.Member) LinkedList(java.util.LinkedList)

Example 15 with MemberImpl

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

the class MemberSelectingCollectionTest method before.

@Before
public void before() throws Exception {
    thisMember = new MemberImpl(new Address("localhost", 5701), MemberVersion.of("3.8.0"), true, true);
    liteMember = new MemberImpl(new Address("localhost", 5702), MemberVersion.of("3.8.0"), false, true);
    dataMember = new MemberImpl(new Address("localhost", 5704), MemberVersion.of("3.8.0"), false, false);
    nonExistingMember = new MemberImpl(new Address("localhost", 5705), MemberVersion.of("3.8.0"), false, false);
    members = createMembers();
}
Also used : Address(com.hazelcast.nio.Address) MemberImpl(com.hazelcast.instance.MemberImpl) Before(org.junit.Before)

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