Search in sources :

Example 1 with Command

use of de.flapdoodle.embed.mongo.Command in project flow.service.workflow by boomerang-io.

the class MongoConfig method afterPropertiesSet.

@Override
public void afterPropertiesSet() throws Exception {
    String proxyHost = System.getProperty("http.proxyHost");
    String proxyPort = System.getProperty("http.proxyPort");
    MongodStarter starter = null;
    ProcessOutput processOutput = enableMongoLogs ? ProcessOutput.getDefaultInstance("mongo") : ProcessOutput.getDefaultInstanceSilent();
    Command command = Command.MongoD;
    if (StringUtils.hasText(proxyHost) && StringUtils.hasText(proxyPort)) {
        final DownloadConfig downloadConfig = Defaults.downloadConfigFor(command).proxyFactory(new HttpProxyFactory(proxyHost, Integer.parseInt(proxyPort))).build();
        RuntimeConfig runtimeConfig = Defaults.runtimeConfigFor(command).processOutput(processOutput).artifactStore(Defaults.extractedArtifactStoreFor(command).withDownloadConfig(downloadConfig)).build();
        starter = MongodStarter.getInstance(runtimeConfig);
    } else {
        RuntimeConfig runtimeConfig = Defaults.runtimeConfigFor(command).processOutput(processOutput).build();
        starter = MongodStarter.getInstance(runtimeConfig);
    }
    if (starter != null) {
        MongodConfig mongodConfig = MongodConfig.builder().version(Version.Main.PRODUCTION).build();
        executable = starter.prepare(mongodConfig);
        MongodProcess mongodProcess = executable.start();
        this.mongoPort = mongodProcess.getConfig().net().getPort();
    }
}
Also used : Command(de.flapdoodle.embed.mongo.Command) DownloadConfig(de.flapdoodle.embed.process.config.store.DownloadConfig) ProcessOutput(de.flapdoodle.embed.process.config.io.ProcessOutput) MongodConfig(de.flapdoodle.embed.mongo.config.MongodConfig) MongodProcess(de.flapdoodle.embed.mongo.MongodProcess) MongodStarter(de.flapdoodle.embed.mongo.MongodStarter) HttpProxyFactory(de.flapdoodle.embed.process.config.store.HttpProxyFactory) RuntimeConfig(de.flapdoodle.embed.process.config.RuntimeConfig) ConnectionString(com.mongodb.ConnectionString)

Aggregations

ConnectionString (com.mongodb.ConnectionString)1 Command (de.flapdoodle.embed.mongo.Command)1 MongodProcess (de.flapdoodle.embed.mongo.MongodProcess)1 MongodStarter (de.flapdoodle.embed.mongo.MongodStarter)1 MongodConfig (de.flapdoodle.embed.mongo.config.MongodConfig)1 RuntimeConfig (de.flapdoodle.embed.process.config.RuntimeConfig)1 ProcessOutput (de.flapdoodle.embed.process.config.io.ProcessOutput)1 DownloadConfig (de.flapdoodle.embed.process.config.store.DownloadConfig)1 HttpProxyFactory (de.flapdoodle.embed.process.config.store.HttpProxyFactory)1