use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.
the class MemberMapTest method cloneExcluding.
@Test
public void cloneExcluding() {
MemberImpl[] members = newMembers(6);
MemberImpl exclude0 = members[0];
MemberImpl exclude1 = new MemberImpl.Builder(newAddress(6000)).version(VERSION).uuid(members[1].getUuid()).build();
MemberImpl exclude2 = new MemberImpl.Builder(members[2].getAddress()).version(VERSION).uuid(newUnsecureUUID()).build();
MemberMap map = MemberMap.cloneExcluding(MemberMap.createNew(members), exclude0, exclude1, exclude2);
int numOfExcludedMembers = 3;
assertEquals(members.length - numOfExcludedMembers, map.getMembers().size());
assertEquals(members.length - numOfExcludedMembers, map.getAddresses().size());
assertEquals(members.length - numOfExcludedMembers, map.size());
for (int i = 0; i < numOfExcludedMembers; i++) {
MemberImpl member = members[i];
assertNotContains(map, member.getAddress());
assertNotContains(map, member.getUuid());
assertNull(map.getMember(member.getAddress()));
assertNull(map.getMember(member.getUuid()));
}
for (int i = numOfExcludedMembers; i < members.length; i++) {
MemberImpl member = members[i];
assertContains(map, member.getAddress());
assertContains(map, member.getUuid());
assertSame(member, map.getMember(member.getAddress()));
assertSame(member, map.getMember(member.getUuid()));
}
assertMemberSet(map);
}
use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.
the class MemberMapTest method createNew.
@Test
public void createNew() {
MemberImpl[] members = newMembers(5);
MemberMap map = MemberMap.createNew(members);
assertEquals(members.length, map.getMembers().size());
assertEquals(members.length, map.getAddresses().size());
assertEquals(members.length, map.size());
for (MemberImpl member : members) {
assertContains(map, member.getAddress());
assertContains(map, member.getUuid());
assertSame(member, map.getMember(member.getAddress()));
assertSame(member, map.getMember(member.getUuid()));
}
assertMemberSet(map);
}
use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.
the class MembersViewTest method getAddresses.
@Test
public void getAddresses() {
MemberImpl[] members = MemberMapTest.newMembers(3);
MembersView view = MembersView.createNew(1, Arrays.asList(members));
Set<Address> addresses = view.getAddresses();
assertEquals(members.length, addresses.size());
for (MemberImpl member : members) {
assertTrue(addresses.contains(member.getAddress()));
}
}
use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.
the class MembersViewTest method cloneAdding.
@Test
public void cloneAdding() {
int version = 6;
MemberImpl[] members = MemberMapTest.newMembers(4);
List<MemberInfo> additionalMembers = Arrays.asList(new MemberInfo(newMember(6000)), new MemberInfo(newMember(7000)));
MembersView view = MembersView.cloneAdding(MembersView.createNew(version, Arrays.asList(members)), additionalMembers);
assertEquals(version + additionalMembers.size(), view.getVersion());
MemberImpl[] newMembers = Arrays.copyOf(members, members.length + additionalMembers.size());
for (int i = 0; i < additionalMembers.size(); i++) {
newMembers[members.length + i] = additionalMembers.get(i).toMember();
}
assertMembersViewEquals(newMembers, view);
}
use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.
the class MembersViewTest method containsMember.
@Test
public void containsMember() {
MemberImpl[] members = MemberMapTest.newMembers(3);
MembersView view = MembersView.createNew(1, Arrays.asList(members));
for (MemberImpl member : members) {
assertTrue(view.containsMember(member.getAddress(), member.getUuid()));
}
}
Aggregations