Search in sources :

Example 26 with SocketAddress

use of org.neo4j.configuration.helpers.SocketAddress in project neo4j-documentation by neo4j.

the class EmbeddedNeo4jClusterUsingBuilder method main.

public static void main(final String[] args) throws IOException {
    System.out.println("Starting database ...");
    FileUtils.deleteDirectory(homeDirectory);
    // tag::startCore[]
    var defaultAdvertised = new SocketAddress("core01.example.com");
    var defaultListen = new SocketAddress("0.0.0.0");
    var initialMembers = List.of(new SocketAddress("core01.example.com"), new SocketAddress("core02.example.com"), new SocketAddress("core03.example.com"));
    var managementService = new ClusterDatabaseManagementServiceBuilder(homeDirectory).setConfig(GraphDatabaseSettings.mode, CORE).setConfig(GraphDatabaseSettings.default_advertised_address, defaultAdvertised).setConfig(GraphDatabaseSettings.default_listen_address, defaultListen).setConfig(CausalClusteringSettings.discovery_type, DiscoveryType.LIST).setConfig(CausalClusteringSettings.initial_discovery_members, initialMembers).setConfig(BoltConnector.enabled, true).setConfig(HttpConnector.enabled, true).build();
    // end::startCore[]
    // This is the neo4j.conf that should go together with the loading of the property file in EmbeddedNeo4jClusterUsingNeo4jConf
    // but kept in this example file because it should be equivalent to the above configuration.
    /* tag::neo4jConf[]

        dbms.mode=CORE
        dbms.default_advertised_address=core01.example.com
        dbms.default_listen_address=0.0.0.0
        causal_clustering.discovery_type=LIST
        causal_clustering.initial_discovery_members=core01.example.com,core02.example.com,core03.example.com
        dbms.connector.bolt.enabled=true
        dbms.connector.http.enabled=true

        end::neo4jConf[] */
    managementService.shutdown();
}
Also used : SocketAddress(org.neo4j.configuration.helpers.SocketAddress) ClusterDatabaseManagementServiceBuilder(com.neo4j.dbms.api.ClusterDatabaseManagementServiceBuilder)

Example 27 with SocketAddress

use of org.neo4j.configuration.helpers.SocketAddress in project neo4j-documentation by neo4j.

the class EmbeddedNeo4jWithBolt method main.

public static void main(final String[] args) throws IOException {
    System.out.println("Starting database ...");
    FileUtils.deleteDirectory(DB_PATH);
    // tag::startDb[]
    DatabaseManagementService managementService = new DatabaseManagementServiceBuilder(DB_PATH).setConfig(BoltConnector.enabled, true).setConfig(BoltConnector.listen_address, new SocketAddress("localhost", 7687)).build();
    // end::startDb[]
    managementService.shutdown();
}
Also used : DatabaseManagementServiceBuilder(org.neo4j.dbms.api.DatabaseManagementServiceBuilder) SocketAddress(org.neo4j.configuration.helpers.SocketAddress) DatabaseManagementService(org.neo4j.dbms.api.DatabaseManagementService)

Example 28 with SocketAddress

use of org.neo4j.configuration.helpers.SocketAddress in project neo4j-documentation by neo4j.

the class Neo4jInstance method newEnterpriseInstance.

public DatabaseManagementService newEnterpriseInstance() throws IOException {
    Files.createDirectories(baseDatabaseDirectory);
    DatabaseManagementService managementService = new EnterpriseDatabaseManagementServiceBuilder(databaseDirectory()).setConfig(Map.of(OnlineBackupSettings.online_backup_listen_address, new SocketAddress("127.0.0.1", 0), OnlineBackupSettings.online_backup_enabled, java.lang.Boolean.FALSE, GraphDatabaseSettings.auth_enabled, true)).build();
    registerShutdownHook(managementService);
    return managementService;
}
Also used : EnterpriseDatabaseManagementServiceBuilder(com.neo4j.dbms.api.EnterpriseDatabaseManagementServiceBuilder) SocketAddress(org.neo4j.configuration.helpers.SocketAddress) DatabaseManagementService(org.neo4j.dbms.api.DatabaseManagementService)

Example 29 with SocketAddress

use of org.neo4j.configuration.helpers.SocketAddress in project neo4j by neo4j.

the class AbstractNeoWebServer method registerHttpAddressAfterStartup.

private void registerHttpAddressAfterStartup() {
    if (httpEnabled) {
        InetSocketAddress localHttpAddress = webServer.getLocalHttpAddress();
        connectorPortRegister.register(HttpConnector.NAME, localHttpAddress);
        if (httpAdvertisedAddress.getPort() == 0) {
            httpAdvertisedAddress = new SocketAddress(localHttpAddress.getHostString(), localHttpAddress.getPort());
        }
    }
}
Also used : InetSocketAddress(java.net.InetSocketAddress) InetSocketAddress(java.net.InetSocketAddress) SocketAddress(org.neo4j.configuration.helpers.SocketAddress)

Example 30 with SocketAddress

use of org.neo4j.configuration.helpers.SocketAddress in project neo4j by neo4j.

the class AbstractInProcessNeo4jBuilder method setWorkingDirectory.

private void setWorkingDirectory(Path workingDir) {
    setDirectory(workingDir);
    withConfig(auth_enabled, false);
    withConfig(pagecache_memory, "8m");
    withConfig(HttpConnector.enabled, true);
    withConfig(HttpConnector.listen_address, new SocketAddress("localhost", 0));
    withConfig(HttpsConnector.enabled, false);
    withConfig(HttpsConnector.listen_address, new SocketAddress("localhost", 0));
    withConfig(BoltConnector.enabled, true);
    withConfig(BoltConnector.listen_address, new SocketAddress("localhost", 0));
}
Also used : SocketAddress(org.neo4j.configuration.helpers.SocketAddress)

Aggregations

SocketAddress (org.neo4j.configuration.helpers.SocketAddress)54 Test (org.junit.jupiter.api.Test)27 InetSocketAddress (java.net.InetSocketAddress)12 AssertableLogProvider (org.neo4j.logging.AssertableLogProvider)11 Test (org.junit.Test)5 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)5 HostnamePort (org.neo4j.internal.helpers.HostnamePort)5 MapValueBuilder (org.neo4j.values.virtual.MapValueBuilder)5 EnumSource (org.junit.jupiter.params.provider.EnumSource)4 SslPolicyConfig (org.neo4j.configuration.ssl.SslPolicyConfig)4 BeforeEach (org.junit.jupiter.api.BeforeEach)3 EnterpriseDatabaseManagementServiceBuilder (com.neo4j.dbms.api.EnterpriseDatabaseManagementServiceBuilder)2 IOException (java.io.IOException)2 ServerSocket (java.net.ServerSocket)2 HashMap (java.util.HashMap)2 DynamicTest (org.junit.jupiter.api.DynamicTest)2 DynamicTest.dynamicTest (org.junit.jupiter.api.DynamicTest.dynamicTest)2 Config (org.neo4j.configuration.Config)2 ConnectorPortRegister (org.neo4j.configuration.connectors.ConnectorPortRegister)2 DatabaseManagementService (org.neo4j.dbms.api.DatabaseManagementService)2