Search in sources :

Example 1 with BoltConnector

use of org.neo4j.kernel.configuration.BoltConnector in project neo4j by neo4j.

the class GraphDatabaseSettingsTest method shouldSupportMultipleBoltConnectorsWithDefaultAndCustomName.

@Test
public void shouldSupportMultipleBoltConnectorsWithDefaultAndCustomName() throws Exception {
    Config config = Config.embeddedDefaults(stringMap("dbms.connector.bolt.type", "BOLT", "dbms.connector.bolt.enabled", "true", "dbms.connector.bolt.listen_address", ":8000", "dbms.connector.bolt2.type", "BOLT", "dbms.connector.bolt2.enabled", "true", "dbms.connector.bolt2.listen_address", ":9000"));
    // when
    BoltConnector boltConnector1 = config.boltConnectors().get(0);
    BoltConnector boltConnector2 = config.boltConnectors().get(1);
    // then
    assertEquals(new ListenSocketAddress("localhost", 8000), config.get(boltConnector1.listen_address));
    assertEquals(new ListenSocketAddress("localhost", 9000), config.get(boltConnector2.listen_address));
}
Also used : BoltConnector(org.neo4j.kernel.configuration.BoltConnector) Config(org.neo4j.kernel.configuration.Config) ListenSocketAddress(org.neo4j.helpers.ListenSocketAddress) Test(org.junit.Test)

Example 2 with BoltConnector

use of org.neo4j.kernel.configuration.BoltConnector in project neo4j by neo4j.

the class GraphDatabaseSettingsTest method shouldEnableBoltByDefault.

@Test
public void shouldEnableBoltByDefault() throws Exception {
    // given
    Config config = Config.serverDefaults();
    // when
    BoltConnector boltConnector = config.boltConnectors().get(0);
    ListenSocketAddress listenSocketAddress = config.get(boltConnector.listen_address);
    // then
    assertEquals(new ListenSocketAddress("localhost", 7687), listenSocketAddress);
}
Also used : BoltConnector(org.neo4j.kernel.configuration.BoltConnector) Config(org.neo4j.kernel.configuration.Config) ListenSocketAddress(org.neo4j.helpers.ListenSocketAddress) Test(org.junit.Test)

Example 3 with BoltConnector

use of org.neo4j.kernel.configuration.BoltConnector in project neo4j by neo4j.

the class GraphDatabaseSettingsTest method groupToScopeSetting.

@Test
public void groupToScopeSetting() throws Exception {
    // given
    String hostname = "my_other_host";
    int port = 9999;
    String scoping = "bla";
    Map<String, String> config = stringMap(GraphDatabaseSettings.default_advertised_address.name(), hostname, new BoltConnector(scoping).advertised_address.name(), ":" + port);
    // when
    BoltConnector boltConnector = new BoltConnector(scoping);
    Setting<AdvertisedSocketAddress> advertised_address = boltConnector.advertised_address;
    AdvertisedSocketAddress advertisedSocketAddress = advertised_address.apply(config::get);
    // then
    assertEquals(hostname, advertisedSocketAddress.getHostname());
    assertEquals(port, advertisedSocketAddress.getPort());
}
Also used : BoltConnector(org.neo4j.kernel.configuration.BoltConnector) AdvertisedSocketAddress(org.neo4j.helpers.AdvertisedSocketAddress) Test(org.junit.Test)

Example 4 with BoltConnector

use of org.neo4j.kernel.configuration.BoltConnector in project neo4j by neo4j.

the class GraphDatabaseSettingsTest method shouldStillSupportCustomNameForBoltConnector.

@Test
public void shouldStillSupportCustomNameForBoltConnector() throws Exception {
    Config config = Config.embeddedDefaults(stringMap("dbms.connector.random_name_that_will_be_unsupported.type", "BOLT", "dbms.connector.random_name_that_will_be_unsupported.enabled", "true", "dbms.connector.random_name_that_will_be_unsupported.listen_address", ":8000"));
    // when
    BoltConnector boltConnector = config.boltConnectors().get(0);
    // then
    assertEquals(new ListenSocketAddress("localhost", 8000), config.get(boltConnector.listen_address));
}
Also used : BoltConnector(org.neo4j.kernel.configuration.BoltConnector) Config(org.neo4j.kernel.configuration.Config) ListenSocketAddress(org.neo4j.helpers.ListenSocketAddress) Test(org.junit.Test)

Example 5 with BoltConnector

use of org.neo4j.kernel.configuration.BoltConnector 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)

Aggregations

BoltConnector (org.neo4j.kernel.configuration.BoltConnector)21 Config (org.neo4j.kernel.configuration.Config)13 Test (org.junit.Test)12 ListenSocketAddress (org.neo4j.helpers.ListenSocketAddress)6 HashMap (java.util.HashMap)5 AdvertisedSocketAddress (org.neo4j.helpers.AdvertisedSocketAddress)5 Matchers.anyString (org.mockito.Matchers.anyString)3 MemberId (org.neo4j.causalclustering.identity.MemberId)3 MemberImpl (com.hazelcast.client.impl.MemberImpl)2 Member (com.hazelcast.core.Member)2 Address (com.hazelcast.nio.Address)2 File (java.io.File)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 GraphDatabaseFactory (org.neo4j.graphdb.factory.GraphDatabaseFactory)2 HttpConnector (org.neo4j.kernel.configuration.HttpConnector)2 Matchers.containsString (org.hamcrest.Matchers.containsString)1 SocketConnection (org.neo4j.bolt.v1.transport.socket.client.SocketConnection)1 CoreTopologyService (org.neo4j.causalclustering.discovery.CoreTopologyService)1 HazelcastDiscoveryServiceFactory (org.neo4j.causalclustering.discovery.HazelcastDiscoveryServiceFactory)1