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));
}
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());
}
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());
}
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();
}
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();
}
}
Aggregations