当前位置: 首页>>代码示例>>Java>>正文


Java Command类代码示例

本文整理汇总了Java中ru.yandex.qatools.embed.postgresql.Command的典型用法代码示例。如果您正苦于以下问题:Java Command类的具体用法?Java Command怎么用?Java Command使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Command类属于ru.yandex.qatools.embed.postgresql包,在下文中一共展示了Command类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: start

import ru.yandex.qatools.embed.postgresql.Command; //导入依赖的package包/类
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();
}
 
开发者ID:honourednihilist,项目名称:gradle-postgresql-embedded,代码行数:37,代码来源:EmbeddedPostgres.java

示例2: startEmbeddedPostgres

import ru.yandex.qatools.embed.postgresql.Command; //导入依赖的package包/类
/**
 * 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)
        // .progressListener(new LoggingProgressListener(logger, Level.ALL))
          .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.V9_6,
      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...");
  }
}
 
开发者ID:folio-org,项目名称:raml-module-builder,代码行数:51,代码来源:PostgresClient.java

示例3: initializePostgresql

import ru.yandex.qatools.embed.postgresql.Command; //导入依赖的package包/类
String initializePostgresql() throws SQLException, IOException,
                              URISyntaxException {

    String password = System.getProperty(NAVI_PASSWORD, "changeMe"); // TODO no default
    final Command cmd = Command.Postgres;
    // the cached directory should contain pgsql folder
    final FixedPath cachedDir = new FixedPath(UAAS_POSTGRES);
    ArtifactStoreBuilder download = new CachedArtifactStoreBuilder().defaults(cmd)
                                                                    .tempDir(cachedDir)
                                                                    .download(new DownloadConfigBuilder().defaultsForCommand(cmd)
                                                                                                         .packageResolver(new PackagePaths(cmd,
                                                                                                                                           cachedDir))
                                                                                                         .build());
    IRuntimeConfig runtimeConfig = new RuntimeConfigBuilder().defaults(cmd)
                                                             .artifactStore(download)
                                                             .build();

    PostgresStarter<PostgresExecutable, PostgresProcess> runtime = PostgresStarter.getInstance(runtimeConfig);

    log.info("Starting Postgres");
    final PostgresConfig config = new PostgresConfig(PRODUCTION,
                                                     new Net("localhost",
                                                             findFreePort()),
                                                     new Storage(NAVI,
                                                                 UAAS_STATE),
                                                     new Timeout(),
                                                     new Credentials(NAVI,
                                                                     password));
    // pass info regarding encoding, locale, collate, ctype, instead of setting global environment settings
    config.getAdditionalInitDbParams()
          .addAll(Arrays.asList("-E", "UTF-8", "--locale=en_US.UTF-8",
                                "--lc-collate=en_US.UTF-8",
                                "--lc-ctype=en_US.UTF-8"));
    PostgresExecutable exec = runtime.prepare(config);
    PostgresProcess process = exec.start();
    Runtime.getRuntime()
           .addShutdownHook(new Thread(() -> process.stop(),
                                       "Local NAVI shutdown"));

    String uri = String.format("jdbc:postgresql://%s:%s/%s?user=%s&password=%s",
                               config.net()
                                     .host(),
                               config.net()
                                     .port(),
                               config.storage()
                                     .dbName(),
                               config.credentials()
                                     .username(),
                               config.credentials()
                                     .password());

    DbaConfiguration dbaConfig = new DbaConfiguration();
    dbaConfig.coreDb = config.storage()
                             .dbName();
    dbaConfig.corePort = config.net()
                               .port();
    dbaConfig.coreServer = config.net()
                                 .host();
    dbaConfig.coreUsername = config.credentials()
                                   .username();
    dbaConfig.corePassword = config.credentials()
                                   .password();
    try {
        new Loader(dbaConfig).bootstrap();
    } catch (Exception e) {
        throw new IllegalStateException("Cannot bootstrap CORE", e);
    }
    return uri;
}
 
开发者ID:ChiralBehaviors,项目名称:Ultrastructure,代码行数:70,代码来源:EmbeddedConfiguration.java


注:本文中的ru.yandex.qatools.embed.postgresql.Command类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。