Search in sources :

Example 11 with ListenSocketAddress

use of org.neo4j.helpers.ListenSocketAddress in project neo4j by neo4j.

the class GraphDatabaseSettingsTest method shouldBeAbleToOverrideHttpListenAddressWithJustOneParameter.

@Test
public void shouldBeAbleToOverrideHttpListenAddressWithJustOneParameter() throws Exception {
    // given
    Config config = Config.embeddedDefaults(stringMap("dbms.connector.http.enabled", "true", "dbms.connector.http.listen_address", ":8000"));
    // then
    assertEquals(1, config.enabledHttpConnectors().size());
    HttpConnector httpConnector = config.enabledHttpConnectors().get(0);
    assertEquals(new ListenSocketAddress("localhost", 8000), config.get(httpConnector.listen_address));
}
Also used : HttpConnector(org.neo4j.kernel.configuration.HttpConnector) Config(org.neo4j.kernel.configuration.Config) ListenSocketAddress(org.neo4j.helpers.ListenSocketAddress) Test(org.junit.Test)

Example 12 with ListenSocketAddress

use of org.neo4j.helpers.ListenSocketAddress in project neo4j by neo4j.

the class ListenAddressSettingsTest method shouldCombineDefaultHostnameWithExplicitPortWhenOnlyAPortProvided.

@Test
public void shouldCombineDefaultHostnameWithExplicitPortWhenOnlyAPortProvided() throws Exception {
    // given
    Map<String, String> config = stringMap(GraphDatabaseSettings.default_listen_address.name(), "server1.example.com", listen_address_setting.name(), ":4000");
    // when
    ListenSocketAddress listenSocketAddress = listen_address_setting.apply(config::get);
    // then
    assertEquals("server1.example.com", listenSocketAddress.getHostname());
    assertEquals(4000, listenSocketAddress.getPort());
}
Also used : ListenSocketAddress(org.neo4j.helpers.ListenSocketAddress) Test(org.junit.Test)

Example 13 with ListenSocketAddress

use of org.neo4j.helpers.ListenSocketAddress in project neo4j by neo4j.

the class ListenAddressSettingsTest method shouldCombineDefaultHostnameWithSettingSpecificPortWhenNoValueProvided.

@Test
public void shouldCombineDefaultHostnameWithSettingSpecificPortWhenNoValueProvided() throws Exception {
    // given
    Map<String, String> config = stringMap(GraphDatabaseSettings.default_listen_address.name(), "server1.example.com");
    // when
    ListenSocketAddress listenSocketAddress = listen_address_setting.apply(config::get);
    // then
    assertEquals("server1.example.com", listenSocketAddress.getHostname());
    assertEquals(1234, listenSocketAddress.getPort());
}
Also used : ListenSocketAddress(org.neo4j.helpers.ListenSocketAddress) Test(org.junit.Test)

Example 14 with ListenSocketAddress

use of org.neo4j.helpers.ListenSocketAddress in project neo4j by neo4j.

the class ServerConfigIT method shouldPickUpAddressFromConfig.

@Test
public void shouldPickUpAddressFromConfig() throws Exception {
    ListenSocketAddress nonDefaultAddress = new ListenSocketAddress("0.0.0.0", 4321);
    server = server().onAddress(nonDefaultAddress).usingDataDir(folder.directory(name.getMethodName()).getAbsolutePath()).build();
    server.start();
    assertEquals(nonDefaultAddress, server.getAddress());
    JaxRsResponse response = new RestRequest(server.baseUri()).get();
    assertThat(response.getStatus(), is(200));
    response.close();
}
Also used : RestRequest(org.neo4j.server.rest.RestRequest) ListenSocketAddress(org.neo4j.helpers.ListenSocketAddress) JaxRsResponse(org.neo4j.server.rest.JaxRsResponse) Test(org.junit.Test)

Example 15 with ListenSocketAddress

use of org.neo4j.helpers.ListenSocketAddress in project neo4j by neo4j.

the class JettyThreadLimitTest method shouldHaveConfigurableJettyThreadPoolSize.

@Test
public void shouldHaveConfigurableJettyThreadPoolSize() throws Exception {
    Jetty9WebServer server = new Jetty9WebServer(NullLogProvider.getInstance(), Config.empty());
    int numCores = 1;
    // 12 is the new min max Threads value, for one core
    int configuredMaxThreads = 12;
    // In this configuration, 1 thread will become an acceptor...
    int acceptorThreads = 1;
    // ... and 1 thread will become a selector...
    int selectorThreads = 1;
    // ... and the rest are job threads
    int jobThreads = configuredMaxThreads - acceptorThreads - selectorThreads;
    server.setMaxThreads(numCores);
    server.setAddress(new ListenSocketAddress("localhost", 7480));
    try {
        server.start();
        QueuedThreadPool threadPool = (QueuedThreadPool) server.getJetty().getThreadPool();
        threadPool.start();
        CountDownLatch startLatch = new CountDownLatch(jobThreads);
        CountDownLatch endLatch = loadThreadPool(threadPool, configuredMaxThreads + 1, startLatch);
        // Wait for threadPool to create threads
        startLatch.await();
        int threads = threadPool.getThreads();
        assertEquals("Wrong number of threads in pool", configuredMaxThreads, threads);
        endLatch.countDown();
    } finally {
        server.stop();
    }
}
Also used : QueuedThreadPool(org.eclipse.jetty.util.thread.QueuedThreadPool) ListenSocketAddress(org.neo4j.helpers.ListenSocketAddress) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test)

Aggregations

ListenSocketAddress (org.neo4j.helpers.ListenSocketAddress)26 Test (org.junit.Test)23 Config (org.neo4j.kernel.configuration.Config)15 BoltConnector (org.neo4j.kernel.configuration.BoltConnector)8 AdvertisedSocketAddress (org.neo4j.helpers.AdvertisedSocketAddress)4 HttpConnector (org.neo4j.kernel.configuration.HttpConnector)4 ServerSocket (java.net.ServerSocket)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 BiFunction (java.util.function.BiFunction)2 NettyServer (org.neo4j.bolt.transport.NettyServer)2 Configuration (org.neo4j.graphdb.config.Configuration)2 Setting (org.neo4j.graphdb.config.Setting)2 JobScheduler (org.neo4j.kernel.impl.util.JobScheduler)2 AssertableLogProvider (org.neo4j.logging.AssertableLogProvider)2 InterfacesConfig (com.hazelcast.config.InterfacesConfig)1 JoinConfig (com.hazelcast.config.JoinConfig)1 MemberAttributeConfig (com.hazelcast.config.MemberAttributeConfig)1 NetworkConfig (com.hazelcast.config.NetworkConfig)1