use of org.neo4j.configuration.helpers.SocketAddress in project neo4j by neo4j.
the class JettyThreadLimitIT method shouldHaveConfigurableJettyThreadPoolSize.
@Test
void shouldHaveConfigurableJettyThreadPoolSize() throws Exception {
Jetty9WebServer server = new Jetty9WebServer(NullLogProvider.getInstance(), Config.defaults(), NetworkConnectionTracker.NO_OP, mock(ByteBufferPool.class));
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.setHttpAddress(new SocketAddress("localhost", 0));
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(configuredMaxThreads, threads, "Wrong number of threads in pool");
endLatch.countDown();
} finally {
server.stop();
}
}
use of org.neo4j.configuration.helpers.SocketAddress in project neo4j by neo4j.
the class InProcessServerBuilderIT method shouldAllowCustomServerAndDbConfig.
@Test
void shouldAllowCustomServerAndDbConfig() throws Exception {
// Given
trustAllSSLCerts();
// Get default trusted cypher suites
SSLServerSocketFactory ssf = (SSLServerSocketFactory) SSLServerSocketFactory.getDefault();
List<String> defaultCiphers = Arrays.asList(ssf.getDefaultCipherSuites());
// When
SslPolicyConfig pem = SslPolicyConfig.forScope(HTTPS);
var certificates = directory.directory("certificates");
SelfSignedCertificateFactory.create(certificates, "private.key", "public.crt");
Files.createDirectories(certificates.resolve("trusted"));
Files.createDirectories(certificates.resolve("revoked"));
try (Neo4j neo4j = getTestBuilder(directory.homePath()).withConfig(HttpConnector.enabled, true).withConfig(HttpConnector.listen_address, new SocketAddress("localhost", 0)).withConfig(HttpsConnector.enabled, true).withConfig(HttpsConnector.listen_address, new SocketAddress("localhost", 0)).withConfig(GraphDatabaseSettings.dense_node_threshold, 20).withConfig(pem.enabled, Boolean.TRUE).withConfig(pem.base_directory, certificates).withConfig(pem.ciphers, defaultCiphers).withConfig(pem.tls_versions, List.of("TLSv1.2", "TLSv1.1", "TLSv1")).withConfig(pem.client_auth, ClientAuth.NONE).withConfig(pem.trust_all, true).build()) {
// Then
assertThat(HTTP.GET(neo4j.httpURI().toString()).status()).isEqualTo(200);
assertThat(HTTP.GET(neo4j.httpsURI().toString()).status()).isEqualTo(200);
Config config = ((GraphDatabaseAPI) neo4j.defaultDatabaseService()).getDependencyResolver().resolveDependency(Config.class);
assertEquals(20, config.get(GraphDatabaseSettings.dense_node_threshold));
}
}
use of org.neo4j.configuration.helpers.SocketAddress in project neo4j by neo4j.
the class Neo4jWithSocket method configure.
private Map<Setting<?>, Object> configure(Consumer<Map<Setting<?>, Object>> overrideSettingsFunction) {
Map<Setting<?>, Object> settings = new HashMap<>();
settings.put(GraphDatabaseSettings.auth_enabled, false);
settings.put(BoltConnector.enabled, true);
settings.put(BoltConnector.listen_address, new SocketAddress("localhost", 0));
settings.put(BoltConnector.encryption_level, DISABLED);
configure.accept(settings);
overrideSettingsFunction.accept(settings);
return settings;
}
use of org.neo4j.configuration.helpers.SocketAddress in project neo4j by neo4j.
the class MultipleBoltServerPortsStressTest method setUp.
@BeforeEach
void setUp(TestInfo testInfo) throws IOException {
server.setGraphDatabaseFactory(new SharedAuthManagerDbmsBuilder());
server.setConfigure(settings -> {
settings.put(BoltConnector.enabled, true);
settings.put(BoltConnector.listen_address, new SocketAddress(0));
settings.put(GraphDatabaseSettings.routing_enabled, true);
settings.put(GraphDatabaseSettings.routing_listen_address, new SocketAddress(0));
});
server.init(testInfo);
util = new TransportTestUtil(newMessageEncoder());
}
use of org.neo4j.configuration.helpers.SocketAddress in project neo4j by neo4j.
the class OcspStaplingIT method setup.
@BeforeEach
void setup(TestInfo testInfo) throws IOException {
server.setConfigure(settings -> {
SslPolicyConfig policy = SslPolicyConfig.forScope(BOLT);
settings.put(policy.enabled, true);
settings.put(policy.public_certificate, endUserCertFile.toAbsolutePath());
settings.put(policy.private_key, endUserKeyFile.toAbsolutePath());
settings.put(BoltConnector.enabled, true);
settings.put(BoltConnector.encryption_level, OPTIONAL);
settings.put(CommonConnectorConfig.ocsp_stapling_enabled, true);
settings.put(BoltConnector.listen_address, new SocketAddress("localhost", 0));
});
server.init(testInfo);
}
Aggregations