use of org.apache.rya.mongodb.batch.MongoDbBatchWriter in project incubator-rya by apache.
the class MongoDBRyaBatchWriterIT method testMongoCollectionFlush.
@Test
public void testMongoCollectionFlush() throws Exception {
final MongoDBStorageStrategy<RyaStatement> storageStrategy = new SimpleMongoDBStorageStrategy();
final List<Document> documents = Lists.newArrayList(toDocument(storageStrategy.serialize(statement(1))), toDocument(storageStrategy.serialize(statement(2))), toDocument(storageStrategy.serialize(statement(2))), null, toDocument(storageStrategy.serialize(statement(3))), toDocument(storageStrategy.serialize(statement(3))), toDocument(storageStrategy.serialize(statement(4))));
final MongoCollectionType mongoCollectionType = new MongoCollectionType(getRyaCollection());
final MongoDbBatchWriterConfig mongoDbBatchWriterConfig = MongoDbBatchWriterUtils.getMongoDbBatchWriterConfig(conf);
final MongoDbBatchWriter<Document> mongoDbBatchWriter = new MongoDbBatchWriter<>(mongoCollectionType, mongoDbBatchWriterConfig);
mongoDbBatchWriter.start();
mongoDbBatchWriter.addObjectsToQueue(documents);
mongoDbBatchWriter.flush();
Thread.sleep(1_000);
mongoDbBatchWriter.addObjectsToQueue(documents);
mongoDbBatchWriter.flush();
Thread.sleep(1_000);
mongoDbBatchWriter.shutdown();
assertEquals(4, getRyaCollection().count());
}
use of org.apache.rya.mongodb.batch.MongoDbBatchWriter in project incubator-rya by apache.
the class MongoDBRyaBatchWriterIT method testDbCollectionFlush.
@Test
public void testDbCollectionFlush() throws Exception {
final MongoDBStorageStrategy<RyaStatement> storageStrategy = new SimpleMongoDBStorageStrategy();
final List<DBObject> objects = Lists.newArrayList(storageStrategy.serialize(statement(1)), storageStrategy.serialize(statement(2)), storageStrategy.serialize(statement(2)), null, storageStrategy.serialize(statement(3)), storageStrategy.serialize(statement(3)), storageStrategy.serialize(statement(4)));
final DbCollectionType collectionType = new DbCollectionType(getRyaDbCollection());
final MongoDbBatchWriterConfig mongoDbBatchWriterConfig = MongoDbBatchWriterUtils.getMongoDbBatchWriterConfig(conf);
final MongoDbBatchWriter<DBObject> mongoDbBatchWriter = new MongoDbBatchWriter<>(collectionType, mongoDbBatchWriterConfig);
mongoDbBatchWriter.start();
mongoDbBatchWriter.addObjectsToQueue(objects);
mongoDbBatchWriter.flush();
Thread.sleep(1_000);
mongoDbBatchWriter.addObjectsToQueue(objects);
mongoDbBatchWriter.flush();
Thread.sleep(1_000);
mongoDbBatchWriter.shutdown();
assertEquals(4, getRyaDbCollection().count());
}
Aggregations