Search in sources :

Example 6 with MemberInfo

use of com.hazelcast.internal.cluster.MemberInfo in project hazelcast by hazelcast.

the class MemberInfoUpdateOperation method toString.

@Override
protected void toString(StringBuilder sb) {
    super.toString(sb);
    sb.append(", targetUuid=").append(targetUuid);
    sb.append(", members=");
    for (MemberInfo address : memberInfos) {
        sb.append(address).append(' ');
    }
}
Also used : MemberInfo(com.hazelcast.internal.cluster.MemberInfo)

Example 7 with MemberInfo

use of com.hazelcast.internal.cluster.MemberInfo in project hazelcast by hazelcast.

the class MemberListTest method testOutOfSyncMemberListTwoMasters.

/*
     * Sets up a situation where the member list is out of order on node2. Both
     * node2 and node1 think they are masters and both think each other are in
     * their clusters.
     */
@Test
public void testOutOfSyncMemberListTwoMasters() throws Exception {
    List<HazelcastInstance> instanceList = buildInstances(3, 35701);
    final HazelcastInstance h1 = instanceList.get(0);
    final HazelcastInstance h2 = instanceList.get(1);
    final HazelcastInstance h3 = instanceList.get(2);
    final MemberImpl m1 = (MemberImpl) h1.getCluster().getLocalMember();
    final MemberImpl m2 = (MemberImpl) h2.getCluster().getLocalMember();
    final MemberImpl m3 = (MemberImpl) h3.getCluster().getLocalMember();
    // All three nodes join into one cluster
    assertClusterSizeEventually(3, h1);
    assertClusterSizeEventually(3, h2);
    assertClusterSizeEventually(3, h3);
    final Node n2 = TestUtil.getNode(h2);
    // Simulates node2 getting an out of order member list. That causes node2 to think it's the master.
    List<MemberInfo> members = new ArrayList<MemberInfo>();
    members.add(new MemberInfo(m2.getAddress(), m2.getUuid(), Collections.<String, Object>emptyMap(), n2.getVersion()));
    members.add(new MemberInfo(m3.getAddress(), m3.getUuid(), Collections.<String, Object>emptyMap(), n2.getVersion()));
    members.add(new MemberInfo(m1.getAddress(), m1.getUuid(), Collections.<String, Object>emptyMap(), n2.getVersion()));
    n2.clusterService.updateMembers(members, n2.getMasterAddress());
    n2.setMasterAddress(m2.getAddress());
    // Give the cluster some time to figure things out. The merge and heartbeat code should have kicked in by this point
    sleepSeconds(30);
    assertMasterEquals(m1, h1);
    assertMasterEquals(m1, h2);
    assertMasterEquals(m1, h3);
    assertClusterSize(3, h1);
    assertClusterSize(3, h2);
    assertClusterSize(3, h3);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) MemberInfo(com.hazelcast.internal.cluster.MemberInfo) MemberImpl(com.hazelcast.instance.MemberImpl) Node(com.hazelcast.instance.Node) ArrayList(java.util.ArrayList) NightlyTest(com.hazelcast.test.annotation.NightlyTest) Test(org.junit.Test)

Example 8 with MemberInfo

use of com.hazelcast.internal.cluster.MemberInfo in project hazelcast by hazelcast.

the class MemberListTest method testSameMasterDifferentMemberList.

/*
     * Sets up situation where all nodes have the same master, but node 2's list
     * doesn't contain node 3.
     */
@Test
public void testSameMasterDifferentMemberList() throws Exception {
    List<HazelcastInstance> instanceList = buildInstances(3, 45701);
    final HazelcastInstance h1 = instanceList.get(0);
    final HazelcastInstance h2 = instanceList.get(1);
    final HazelcastInstance h3 = instanceList.get(2);
    final MemberImpl m1 = (MemberImpl) h1.getCluster().getLocalMember();
    final MemberImpl m2 = (MemberImpl) h2.getCluster().getLocalMember();
    // All three nodes join into one cluster
    assertClusterSizeEventually(3, h1);
    assertClusterSizeEventually(3, h2);
    assertClusterSizeEventually(3, h3);
    final Node n2 = TestUtil.getNode(h2);
    // Simulates node2 getting an out of order member list. That causes node2 to think it's the master.
    List<MemberInfo> members = new ArrayList<MemberInfo>();
    members.add(new MemberInfo(m1.getAddress(), m1.getUuid(), Collections.<String, Object>emptyMap(), n2.getVersion()));
    members.add(new MemberInfo(m2.getAddress(), m2.getUuid(), Collections.<String, Object>emptyMap(), n2.getVersion()));
    n2.clusterService.updateMembers(members, n2.getMasterAddress());
    // Give the cluster some time to figure things out. The merge and heartbeat code should have kicked in by this point
    sleepSeconds(30);
    assertMasterEquals(m1, h1);
    assertMasterEquals(m1, h2);
    assertMasterEquals(m1, h3);
    assertClusterSize(3, h1);
    assertClusterSize(3, h2);
    assertClusterSize(3, h3);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) MemberInfo(com.hazelcast.internal.cluster.MemberInfo) MemberImpl(com.hazelcast.instance.MemberImpl) Node(com.hazelcast.instance.Node) ArrayList(java.util.ArrayList) NightlyTest(com.hazelcast.test.annotation.NightlyTest) Test(org.junit.Test)

Example 9 with MemberInfo

use of com.hazelcast.internal.cluster.MemberInfo in project hazelcast by hazelcast.

the class ClusterDataSerializationTest method testSerializationOf_memberInfo.

@Test
public void testSerializationOf_memberInfo() throws UnknownHostException {
    // member attributes, test an integer, a String and an IdentifiedDataSerializable as values
    Map<String, Object> attributes = new HashMap<String, Object>();
    attributes.put("a", 2);
    attributes.put("b", "b");
    attributes.put("c", new Address("127.0.0.1", 5999));
    MemberInfo memberInfo = new MemberInfo(new Address("127.0.0.1", 5071), UUID.randomUUID().toString(), attributes, false, MemberVersion.of(BUILD_INFO.getVersion()));
    Data serialized = SERIALIZATION_SERVICE.toData(memberInfo);
    MemberInfo deserialized = SERIALIZATION_SERVICE.toObject(serialized);
    assertEquals(deserialized.getAddress(), memberInfo.getAddress());
    assertEquals(deserialized.getVersion(), memberInfo.getVersion());
    assertEquals(deserialized.getUuid(), memberInfo.getUuid());
    assertEquals(deserialized.getAttributes().get("a"), memberInfo.getAttributes().get("a"));
    assertEquals(deserialized.getAttributes().get("b"), memberInfo.getAttributes().get("b"));
    assertEquals(deserialized.getAttributes().get("c"), memberInfo.getAttributes().get("c"));
}
Also used : Address(com.hazelcast.nio.Address) MemberInfo(com.hazelcast.internal.cluster.MemberInfo) HashMap(java.util.HashMap) Data(com.hazelcast.nio.serialization.Data) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 10 with MemberInfo

use of com.hazelcast.internal.cluster.MemberInfo 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)

Aggregations

MemberInfo (com.hazelcast.internal.cluster.MemberInfo)13 MemberImpl (com.hazelcast.instance.MemberImpl)7 MemberInfoUpdateOperation (com.hazelcast.internal.cluster.impl.operations.MemberInfoUpdateOperation)4 Address (com.hazelcast.nio.Address)4 AuthenticationFailureOperation (com.hazelcast.internal.cluster.impl.operations.AuthenticationFailureOperation)3 BeforeJoinCheckFailureOperation (com.hazelcast.internal.cluster.impl.operations.BeforeJoinCheckFailureOperation)3 ConfigMismatchOperation (com.hazelcast.internal.cluster.impl.operations.ConfigMismatchOperation)3 FinalizeJoinOperation (com.hazelcast.internal.cluster.impl.operations.FinalizeJoinOperation)3 GroupMismatchOperation (com.hazelcast.internal.cluster.impl.operations.GroupMismatchOperation)3 JoinRequestOperation (com.hazelcast.internal.cluster.impl.operations.JoinRequestOperation)3 MasterDiscoveryOperation (com.hazelcast.internal.cluster.impl.operations.MasterDiscoveryOperation)3 PostJoinOperation (com.hazelcast.internal.cluster.impl.operations.PostJoinOperation)3 SetMasterOperation (com.hazelcast.internal.cluster.impl.operations.SetMasterOperation)3 ArrayList (java.util.ArrayList)3 Test (org.junit.Test)3 HazelcastInstance (com.hazelcast.core.HazelcastInstance)2 Node (com.hazelcast.instance.Node)2 TriggerMemberListPublishOperation (com.hazelcast.internal.cluster.impl.operations.TriggerMemberListPublishOperation)2 PartitionRuntimeState (com.hazelcast.internal.partition.PartitionRuntimeState)2 Operation (com.hazelcast.spi.Operation)2