diff --git a/core/src/main/java/org/polypheny/db/docker/DockerContainer.java b/core/src/main/java/org/polypheny/db/docker/DockerContainer.java index bd0f43c745..8effb41f2a 100644 --- a/core/src/main/java/org/polypheny/db/docker/DockerContainer.java +++ b/core/src/main/java/org/polypheny/db/docker/DockerContainer.java @@ -16,6 +16,12 @@ package org.polypheny.db.docker; +import com.github.dockerjava.api.DockerClient; +import com.github.dockerjava.api.command.InspectContainerResponse; +import com.github.dockerjava.core.DefaultDockerClientConfig; +import com.github.dockerjava.core.DockerClientConfig; +import com.github.dockerjava.core.DockerClientImpl; +import com.github.dockerjava.httpclient5.ApacheDockerHttpClient; import java.io.EOFException; import java.io.IOException; import java.io.InputStream; @@ -26,6 +32,7 @@ import java.net.SocketException; import java.net.StandardSocketOptions; import java.nio.charset.StandardCharsets; +import java.time.Duration; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -250,6 +257,27 @@ public HostAndPort connectToContainer( int port ) { } + public HostAndPort connectToContainerDirectly( int port ) { + DockerClientConfig config = DefaultDockerClientConfig + .createDefaultConfigBuilder() + .build(); + + ApacheDockerHttpClient httpClient = new ApacheDockerHttpClient.Builder() + .dockerHost( config.getDockerHost() ) + .sslConfig( config.getSSLConfig() ) + .responseTimeout( Duration.ofSeconds( RuntimeConfig.DOCKER_TIMEOUT.getInteger() ) ) + .connectionTimeout( Duration.ofSeconds( RuntimeConfig.DOCKER_TIMEOUT.getInteger() ) ) + .build(); + + DockerClient client = DockerClientImpl.getInstance( config, httpClient ); + + InspectContainerResponse resp = client.inspectContainerCmd( this.containerId ).exec(); + + String ip = resp.getNetworkSettings().getNetworks().get( "polypheny-internal" ).getIpAddress(); + return new HostAndPort( ip, port ); + } + + /** * The container gets probed until the defined ready supplier returns true or the timeout is reached */ diff --git a/plugins/postgres-adapter/src/main/java/org/polypheny/db/adapter/postgres/store/PostgresqlStore.java b/plugins/postgres-adapter/src/main/java/org/polypheny/db/adapter/postgres/store/PostgresqlStore.java index 7349eea5f0..242a55c5b3 100644 --- a/plugins/postgres-adapter/src/main/java/org/polypheny/db/adapter/postgres/store/PostgresqlStore.java +++ b/plugins/postgres-adapter/src/main/java/org/polypheny/db/adapter/postgres/store/PostgresqlStore.java @@ -38,6 +38,7 @@ import org.polypheny.db.adapter.jdbc.connection.TransactionalConnectionFactory; import org.polypheny.db.adapter.jdbc.stores.AbstractJdbcStore; import org.polypheny.db.adapter.postgres.PostgresqlSqlDialect; +import org.polypheny.db.catalog.Catalog; import org.polypheny.db.catalog.entity.allocation.AllocationTable; import org.polypheny.db.catalog.entity.logical.LogicalColumn; import org.polypheny.db.catalog.entity.logical.LogicalIndex; @@ -58,6 +59,7 @@ import org.polypheny.db.type.PolyType; import org.polypheny.db.type.PolyTypeFamily; import org.polypheny.db.util.PasswordGenerator; +import org.polypheny.db.util.RunMode; @Slf4j @@ -372,7 +374,13 @@ private boolean testDockerConnection() { return false; } - HostAndPort hp = container.connectToContainer( 5432 ); + HostAndPort hp; + if ( Catalog.mode == RunMode.BENCHMARK ) { + log.warn( "Using direct Docker connection in benchmark mode" ); + hp = container.connectToContainerDirectly( 5432 ); + } else { + hp = container.connectToContainer( 5432 ); + } this.host = hp.host(); this.port = hp.port();