use of ru.yandex.qatools.embed.postgresql.config.PostgresDownloadConfigBuilder in project raml-module-builder by folio-org.
the class PostgresClient method startEmbeddedPostgres.
/**
* Start an embedded PostgreSQL using the configuration of {@link #getConnectionConfig()}.
* It also sets embedded mode to true, see {@link #setIsEmbedded(boolean)}, but
* doesn't change the configuration.
*
* @throws IOException when starting embedded PostgreSQL fails
*/
public void startEmbeddedPostgres() throws IOException {
// starting Postgres
embeddedMode = true;
if (postgresProcess == null || !postgresProcess.isProcessRunning()) {
// turns off the default functionality of unzipping on every run.
IRuntimeConfig runtimeConfig = new RuntimeConfigBuilder().defaults(Command.Postgres).artifactStore(new NonCachedPostgresArtifactStoreBuilder().defaults(Command.Postgres).download(new PostgresDownloadConfigBuilder().defaultsForCommand(Command.Postgres).build())).build();
PostgresStarter<PostgresExecutable, PostgresProcess> runtime = PostgresStarter.getInstance(runtimeConfig);
int port = postgreSQLClientConfig.getInteger(PORT);
String username = postgreSQLClientConfig.getString(_USERNAME);
String password = postgreSQLClientConfig.getString(_PASSWORD);
String database = postgreSQLClientConfig.getString(DATABASE);
String locale = "en_US.UTF-8";
String OS = System.getProperty("os.name").toLowerCase();
if (OS.indexOf("win") >= 0) {
locale = "american_usa";
}
final PostgresConfig config = new PostgresConfig(Version.Main.V10, new AbstractPostgresConfig.Net(DEFAULT_IP, port), new AbstractPostgresConfig.Storage(database), new AbstractPostgresConfig.Timeout(20000), new AbstractPostgresConfig.Credentials(username, password));
config.getAdditionalInitDbParams().addAll(Arrays.asList("-E", "UTF-8", "--locale", locale));
postgresProcess = runtime.prepare(config).start();
log.info("embedded postgress started....");
} else {
log.info("embedded postgress is already running...");
}
}
use of ru.yandex.qatools.embed.postgresql.config.PostgresDownloadConfigBuilder in project gradle-postgresql-embedded by honourednihilist.
the class EmbeddedPostgres method start.
public synchronized void start() throws IOException {
if (process != null) {
throw new IllegalStateException();
}
Command command = Command.Postgres;
IDownloadConfig downloadConfig = new PostgresDownloadConfigBuilder().defaultsForCommand(command).artifactStorePath(new FixedPath(artifactStorePath)).build();
ArtifactStoreBuilder artifactStoreBuilder = new PostgresArtifactStoreBuilder().defaults(command).download(downloadConfig);
LogWatchStreamProcessor logWatch = new LogWatchStreamProcessor("started", new HashSet<>(singletonList("failed")), new Slf4jStreamProcessor(getLogger("postgres"), Slf4jLevel.TRACE));
IRuntimeConfig runtimeConfig = new RuntimeConfigBuilder().defaults(command).processOutput(new ProcessOutput(logWatch, logWatch, logWatch)).artifactStore(artifactStoreBuilder).build();
PostgresStarter<PostgresExecutable, PostgresProcess> starter = new PostgresStarter<>(PostgresExecutable.class, runtimeConfig);
PostgresConfig config = new PostgresConfig(version, new AbstractPostgresConfig.Net(host, port == 0 ? Network.getFreeServerPort() : port), new AbstractPostgresConfig.Storage(dbName), new AbstractPostgresConfig.Timeout(), new AbstractPostgresConfig.Credentials(username, password));
process = starter.prepare(config).start();
jdbcUrl = "jdbc:postgresql://" + config.net().host() + ":" + config.net().port() + "/" + config.storage().dbName();
}
Aggregations