Search in sources :

Example 1 with MemberImpl

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))));
}
Also used : Address(com.hazelcast.nio.Address) AdvertisedSocketAddress(org.neo4j.helpers.AdvertisedSocketAddress) HashMap(java.util.HashMap) BoltConnector(org.neo4j.kernel.configuration.BoltConnector) Config(org.neo4j.kernel.configuration.Config) MemberImpl(com.hazelcast.client.impl.MemberImpl) ArrayList(java.util.ArrayList) Matchers.anyString(org.mockito.Matchers.anyString) MemberId(org.neo4j.causalclustering.identity.MemberId) Member(com.hazelcast.core.Member) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 2 with MemberImpl

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);
    }
}
Also used : Address(com.hazelcast.nio.Address) AdvertisedSocketAddress(org.neo4j.helpers.AdvertisedSocketAddress) HashMap(java.util.HashMap) BoltConnector(org.neo4j.kernel.configuration.BoltConnector) Config(org.neo4j.kernel.configuration.Config) MemberImpl(com.hazelcast.client.impl.MemberImpl) ArrayList(java.util.ArrayList) AdvertisedSocketAddress(org.neo4j.helpers.AdvertisedSocketAddress) Matchers.anyString(org.mockito.Matchers.anyString) MemberId(org.neo4j.causalclustering.identity.MemberId) Member(com.hazelcast.core.Member) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

MemberImpl (com.hazelcast.client.impl.MemberImpl)2 Member (com.hazelcast.core.Member)2 Address (com.hazelcast.nio.Address)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Test (org.junit.Test)2 Matchers.anyString (org.mockito.Matchers.anyString)2 MemberId (org.neo4j.causalclustering.identity.MemberId)2 AdvertisedSocketAddress (org.neo4j.helpers.AdvertisedSocketAddress)2 BoltConnector (org.neo4j.kernel.configuration.BoltConnector)2 Config (org.neo4j.kernel.configuration.Config)2