use of de.flapdoodle.embed.mongo.MongoImportProcess 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);
}
Aggregations