Search in sources :

Example 1 with MongoImportConfigBuilder

use of de.flapdoodle.embed.mongo.config.MongoImportConfigBuilder in project drill by apache.

the class TestTableGenerator method generateTable.

public static void generateTable(String dbName, String collection, String jsonFile, Boolean jsonArray, Boolean upsert, Boolean drop) throws InterruptedException, IOException {
    logger.info("Started importing file {} into collection {} ", jsonFile, collection);
    IMongoImportConfig mongoImportConfig = new MongoImportConfigBuilder().version(Version.Main.PRODUCTION).net(new Net(MONGOS_PORT, Network.localhostIsIPv6())).db(dbName).collection(collection).upsert(upsert).dropCollection(drop).jsonArray(jsonArray).importFile(jsonFile).build();
    MongoImportExecutable importExecutable = MongoImportStarter.getDefaultInstance().prepare(mongoImportConfig);
    MongoImportProcess importProcess = importExecutable.start();
    // import is in a separate process, we should wait until the process exit
    while (importProcess.isProcessRunning()) {
        Thread.sleep(1000);
    }
    logger.info("Imported file {} into collection {} ", jsonFile, collection);
}
Also used : MongoImportProcess(de.flapdoodle.embed.mongo.MongoImportProcess) IMongoImportConfig(de.flapdoodle.embed.mongo.config.IMongoImportConfig) Net(de.flapdoodle.embed.mongo.config.Net) MongoImportConfigBuilder(de.flapdoodle.embed.mongo.config.MongoImportConfigBuilder) MongoImportExecutable(de.flapdoodle.embed.mongo.MongoImportExecutable)

Aggregations

MongoImportExecutable (de.flapdoodle.embed.mongo.MongoImportExecutable)1 MongoImportProcess (de.flapdoodle.embed.mongo.MongoImportProcess)1 IMongoImportConfig (de.flapdoodle.embed.mongo.config.IMongoImportConfig)1 MongoImportConfigBuilder (de.flapdoodle.embed.mongo.config.MongoImportConfigBuilder)1 Net (de.flapdoodle.embed.mongo.config.Net)1