use of com.hazelcast.instance.MemberImpl 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);
}
use of com.hazelcast.instance.MemberImpl 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);
}
use of com.hazelcast.instance.MemberImpl in project hazelcast by hazelcast.
the class AdvancedClusterStateTest method changeClusterState_shouldFail_whenMemberRemoved_duringTx.
@Test(expected = IllegalStateException.class)
public void changeClusterState_shouldFail_whenMemberRemoved_duringTx() throws Exception {
final TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory();
HazelcastInstance[] instances = new HazelcastInstance[3];
for (int i = 0; i < 3; i++) {
instances[i] = factory.newHazelcastInstance();
}
HazelcastInstance hz = instances[instances.length - 1];
ClusterServiceImpl clusterService = (ClusterServiceImpl) getClusterService(hz);
Collection<Member> initialMembers = new ArrayList<Member>(clusterService.getMembers());
MemberImpl fakeMember = new MemberImpl((MemberImpl) clusterService.getLocalMember());
initialMembers.add(fakeMember);
changeClusterState(hz, ClusterState.PASSIVE, initialMembers);
}
use of com.hazelcast.instance.MemberImpl in project hazelcast by hazelcast.
the class MemberMapTest method cloneAdding_failsWithDuplicateAddress.
@Test(expected = IllegalArgumentException.class)
public void cloneAdding_failsWithDuplicateAddress() {
MemberImpl[] members = new MemberImpl[3];
for (int i = 0; i < members.length; i++) {
members[i] = newMember(5000 + i);
}
MemberImpl member = newMember(5000);
MemberMap.cloneAdding(MemberMap.createNew(members), member);
}
use of com.hazelcast.instance.MemberImpl in project hazelcast by hazelcast.
the class MemberMapTest method testConstructor_whenMapsHaveDifferentMembers_thenThrowAssertionError.
@Test(expected = AssertionError.class)
@RequireAssertEnabled
public void testConstructor_whenMapsHaveDifferentMembers_thenThrowAssertionError() {
Map<Address, MemberImpl> addressMap = new HashMap<Address, MemberImpl>();
Map<String, MemberImpl> uuidMap = new HashMap<String, MemberImpl>();
MemberImpl addressMember = newMember(5701);
MemberImpl uuidMember = newMember(5702);
addressMap.put(addressMember.getAddress(), addressMember);
uuidMap.put(uuidMember.getUuid(), uuidMember);
new MemberMap(addressMap, uuidMap);
}
Aggregations