use of org.apache.storm.mongodb.common.MongoDBClient in project storm by apache.
the class MongoState method prepare.
protected void prepare() {
Validate.notEmpty(options.url, "url can not be blank or null");
Validate.notEmpty(options.collectionName, "collectionName can not be blank or null");
this.mongoClient = new MongoDBClient(options.url, options.collectionName);
}
use of org.apache.storm.mongodb.common.MongoDBClient in project storm by apache.
the class TestMongoDataSourcesProvider method testMongoSink.
@SuppressWarnings("unchecked")
@Test
public void testMongoSink() {
ISqlTridentDataSource ds = DataSourcesRegistry.constructTridentDataSource(URI.create("mongodb://127.0.0.1:27017/test"), null, null, TBL_PROPERTIES, FIELDS);
Assert.assertNotNull(ds);
ISqlTridentDataSource.SqlTridentConsumer consumer = ds.getConsumer();
Assert.assertEquals(MongoStateFactory.class, consumer.getStateFactory().getClass());
Assert.assertEquals(MongoStateUpdater.class, consumer.getStateUpdater().getClass());
MongoState state = (MongoState) consumer.getStateFactory().makeState(Collections.emptyMap(), null, 0, 1);
StateUpdater stateUpdater = consumer.getStateUpdater();
MongoDBClient mongoClient = mock(MongoDBClient.class);
Whitebox.setInternalState(state, "mongoClient", mongoClient);
List<TridentTuple> tupleList = mockTupleList();
for (TridentTuple t : tupleList) {
stateUpdater.updateState(state, Collections.singletonList(t), null);
verify(mongoClient).insert(argThat(new MongoArgMatcher(t)), eq(true));
}
verifyNoMoreInteractions(mongoClient);
}
use of org.apache.storm.mongodb.common.MongoDBClient in project storm by apache.
the class AbstractMongoBolt method prepare.
@Override
public void prepare(Map stormConf, TopologyContext context, OutputCollector collector) {
this.collector = collector;
this.mongoClient = new MongoDBClient(url, collectionName);
}
Aggregations