de.flapdoodle.embed.mongo.config.DownloadConfigBuilder Java Examples

The following examples show how to use de.flapdoodle.embed.mongo.config.DownloadConfigBuilder. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EmbedMongoConfiguration.java    From syndesis with Apache License 2.0 5 votes vote down vote up
private static void startEmbeddedMongo() {
    final IStreamProcessor logDestination = new Slf4jStreamProcessor(LoggerFactory.getLogger("embeddeddmongo"), Slf4jLevel.INFO);
    final IStreamProcessor daemon = Processors.named("mongod", logDestination);
    final IStreamProcessor error = Processors.named("mongod-error", logDestination);
    final IStreamProcessor command = Processors.named("mongod-command", logDestination);
    final ProcessOutput processOutput = new ProcessOutput(daemon, error, command);
    final IRuntimeConfig runtimeConfig = new RuntimeConfigBuilder()
        .defaults(Command.MongoD)
        .artifactStore(new ExtractedArtifactStoreBuilder()
            .defaults(Command.MongoD)
            .extractDir(new FixedPath(".extracted"))
            .download(new DownloadConfigBuilder()
                .defaultsForCommand(Command.MongoD)
                .artifactStorePath(new FixedPath(".cache"))
                .build())
            .build())
        .processOutput(processOutput)
        .build();

    try {
        final IMongodConfig mongodConfig = createEmbeddedMongoConfiguration();

        final MongodExecutable mongodExecutable = MongodStarter.getInstance(runtimeConfig)
            .prepare(mongodConfig);


        mongodExecutable.start();
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
 
Example #2
Source File: MongoDbResource.java    From ditto with Eclipse Public License 2.0 5 votes vote down vote up
private static MongodExecutable configureMongoDb(final String bindIp,
        final int mongoDbPort,
        final IProxyFactory proxyFactory,
        final Logger logger) throws IOException {

    final Command command = Command.MongoD;

    final ProcessOutput processOutput;
    if (logger != null) {
        processOutput = ProcessOutput.getInstance("mongod", logger);
    } else {
        processOutput = ProcessOutput.getDefaultInstanceSilent();
    }

    final MongodStarter mongodStarter = MongodStarter.getInstance(new RuntimeConfigBuilder()
            .defaults(command)
            .processOutput(processOutput)
            .artifactStore(new ExtractedArtifactStoreBuilder()
                    .defaults(command)
                    .download(new DownloadConfigBuilder()
                            .defaultsForCommand(command)
                            .proxyFactory(proxyFactory)
                            .progressListener(new StandardConsoleProgressListener())
                            .build()))
            .build());

    return mongodStarter.prepare(new MongodConfigBuilder()
            .net(new Net(bindIp, mongoDbPort, false))
            .version(Version.Main.V3_6)
            .cmdOptions(new MongoCmdOptionsBuilder()
                    .useStorageEngine("wiredTiger")
                    .useNoJournal(false)
                    .build())
            .build());
}
 
Example #3
Source File: Mongo42xDownloadConfigBuilder.java    From mongodb-aggregate-query-support with Apache License 2.0 5 votes vote down vote up
public DownloadConfigBuilder defaults() {
  fileNaming().setDefault(new UUIDTempNaming());
  downloadPath().setDefault(new Mongo42xDownloadPath());
  progressListener().setDefault(new StandardConsoleProgressListener());
  artifactStorePath().setDefault(defaultArtifactDownloadLocation());
  downloadPrefix().setDefault(new DownloadPrefix("embedmongo-download"));
  userAgent().setDefault(new UserAgent("Mozilla/5.0 (compatible; Embedded MongoDB; +https://github.com/flapdoodle-oss/embedmongo.flapdoodle.de)"));
  return this;
}
 
Example #4
Source File: MongodManager.java    From jpa-unit with Apache License 2.0 5 votes vote down vote up
private void startMongo(final List<IMongodConfig> mongodConfigList) throws IOException {
    // @formatter:off
    final ProcessOutput processOutput = new ProcessOutput(
            logTo(LOGGER, Slf4jLevel.INFO),
            logTo(LOGGER, Slf4jLevel.ERROR),
            named("[console>]", logTo(LOGGER, Slf4jLevel.DEBUG)));

    final IRuntimeConfig runtimeConfig = new RuntimeConfigBuilder()
            .defaultsWithLogger(Command.MongoD,LOGGER)
            .processOutput(processOutput)
            .artifactStore(new ExtractedArtifactStoreBuilder()
                .defaults(Command.MongoD)
                .download(new DownloadConfigBuilder()
                    .defaultsForCommand(Command.MongoD)
                    .progressListener(new Slf4jProgressListener(LOGGER))
                    .build()))
            .build();
    // @formatter:on
    final MongodStarter starter = MongodStarter.getInstance(runtimeConfig);

    for (final IMongodConfig mongodConfig : mongodConfigList) {
        final MongodExecutable mongodExecutable = starter.prepare(mongodConfig);
        final MongodProcess mongod = mongodExecutable.start();

        mongoProcesses.put(mongod, mongodExecutable);
    }
}
 
Example #5
Source File: Mongo42xDownloadConfigBuilder.java    From mongodb-aggregate-query-support with Apache License 2.0 4 votes vote down vote up
public DownloadConfigBuilder packageResolverForCommand(Command command) {
  packageResolver(new Mongo42xPaths(command));
  return this;
}
 
Example #6
Source File: MongoJavaRDDFT.java    From deep-spark with Apache License 2.0 4 votes vote down vote up
@BeforeSuite
public static void init() throws IOException {
    Command command = Command.MongoD;

    try {
        Files.forceDelete(new File(DB_FOLDER_NAME));
    } catch (Exception e) {

    }

    new File(DB_FOLDER_NAME).mkdirs();

    IMongodConfig mongodConfig = new MongodConfigBuilder()
            .version(Version.Main.PRODUCTION)
            .configServer(false)
            .replication(new Storage(DB_FOLDER_NAME, null, 0))
            .net(new Net(PORT, Network.localhostIsIPv6()))
            .cmdOptions(new MongoCmdOptionsBuilder()
                    .syncDelay(10)
                    .useNoPrealloc(true)
                    .useSmallFiles(true)
                    .useNoJournal(true)
                    .build())
            .build();

    IRuntimeConfig runtimeConfig = new RuntimeConfigBuilder()
            .defaults(command)
            .artifactStore(new ArtifactStoreBuilder()
                    .defaults(command)
                    .download(new DownloadConfigBuilder()
                            .defaultsForCommand(command)
                            .downloadPath("https://s3-eu-west-1.amazonaws.com/stratio-mongodb-distribution/")))
            .build();

    MongodStarter runtime = MongodStarter.getInstance(runtimeConfig);

    mongodExecutable = null;

    mongodExecutable = runtime.prepare(mongodConfig);

    mongod = mongodExecutable.start();

}