use of com.hazelcast.client.impl.MemberImpl in project neo4j by neo4j.
the class HazelcastClusterTopologyTest method shouldLogAndExcludeMembersWithMissingAttributes.
@Test
public void shouldLogAndExcludeMembersWithMissingAttributes() throws Exception {
// given
Set<Member> hazelcastMembers = new HashSet<>();
List<MemberId> coreMembers = new ArrayList<>();
for (int i = 0; i < 4; i++) {
MemberId memberId = new MemberId(UUID.randomUUID());
coreMembers.add(memberId);
Config config = Config.defaults();
HashMap<String, String> settings = new HashMap<>();
settings.put(new BoltConnector("bolt").type.name(), "BOLT");
settings.put(new BoltConnector("bolt").enabled.name(), "true");
settings.put(new BoltConnector("bolt").advertised_address.name(), "bolt:" + (i + 1));
settings.put(new BoltConnector("http").type.name(), "HTTP");
settings.put(new BoltConnector("http").enabled.name(), "true");
settings.put(new BoltConnector("http").advertised_address.name(), "http:" + (i + 1));
config.augment(settings);
Map<String, Object> attributes = buildMemberAttributesForCore(memberId, config).getAttributes();
if (i == 2) {
attributes.remove(HazelcastClusterTopology.RAFT_SERVER);
}
hazelcastMembers.add(new MemberImpl(new Address("localhost", i), null, attributes, false));
}
// when
Map<MemberId, CoreServerInfo> map = toCoreMemberMap(hazelcastMembers, NullLog.getInstance(), hzInstance);
// then
assertThat(map.keySet(), hasItems(coreMembers.get(0), coreMembers.get(1), coreMembers.get(3)));
assertThat(map.keySet(), not(hasItems(coreMembers.get(2))));
}
use of com.hazelcast.client.impl.MemberImpl in project neo4j by neo4j.
the class HazelcastClusterTopologyTest method shouldCollectMembersAsAMap.
@Test
public void shouldCollectMembersAsAMap() throws Exception {
// given
Set<Member> hazelcastMembers = new HashSet<>();
List<MemberId> coreMembers = new ArrayList<>();
for (int i = 0; i < 5; i++) {
MemberId memberId = new MemberId(UUID.randomUUID());
coreMembers.add(memberId);
Config config = Config.defaults();
HashMap<String, String> settings = new HashMap<>();
settings.put(CausalClusteringSettings.transaction_advertised_address.name(), "tx:" + (i + 1));
settings.put(CausalClusteringSettings.raft_advertised_address.name(), "raft:" + (i + 1));
settings.put(new BoltConnector("bolt").type.name(), "BOLT");
settings.put(new BoltConnector("bolt").enabled.name(), "true");
settings.put(new BoltConnector("bolt").advertised_address.name(), "bolt:" + (i + 1));
settings.put(new BoltConnector("http").type.name(), "HTTP");
settings.put(new BoltConnector("http").enabled.name(), "true");
settings.put(new BoltConnector("http").advertised_address.name(), "http:" + (i + 1));
config.augment(settings);
Map<String, Object> attributes = buildMemberAttributesForCore(memberId, config).getAttributes();
hazelcastMembers.add(new MemberImpl(new Address("localhost", i), null, attributes, false));
}
// when
Map<MemberId, CoreServerInfo> coreMemberMap = toCoreMemberMap(hazelcastMembers, NullLog.getInstance(), hzInstance);
// then
for (int i = 0; i < 5; i++) {
CoreServerInfo coreServerInfo = coreMemberMap.get(coreMembers.get(i));
assertEquals(new AdvertisedSocketAddress("tx", i + 1), coreServerInfo.getCatchupServer());
assertEquals(new AdvertisedSocketAddress("raft", i + 1), coreServerInfo.getRaftServer());
assertEquals(new AdvertisedSocketAddress("bolt", i + 1), coreServerInfo.connectors().boltAddress());
assertEquals(coreServerInfo.groups(), GROUPS);
}
}
Aggregations