Search in sources :

Example 1 with HdfsState

use of org.apache.storm.hdfs.trident.HdfsState in project storm by apache.

the class TestHdfsDataSourcesProvider method testHdfsSink.

@SuppressWarnings("unchecked")
@Test
public void testHdfsSink() {
    ISqlTridentDataSource ds = DataSourcesRegistry.constructTridentDataSource(URI.create(hdfsURI), null, null, TBL_PROPERTIES, FIELDS);
    Assert.assertNotNull(ds);
    ISqlTridentDataSource.SqlTridentConsumer consumer = ds.getConsumer();
    Assert.assertEquals(HdfsStateFactory.class, consumer.getStateFactory().getClass());
    Assert.assertEquals(HdfsUpdater.class, consumer.getStateUpdater().getClass());
    HdfsState state = (HdfsState) consumer.getStateFactory().makeState(Collections.emptyMap(), null, 0, 1);
    StateUpdater stateUpdater = consumer.getStateUpdater();
    HdfsFileOptions options = mock(HdfsFileOptions.class);
    Whitebox.setInternalState(state, "options", options);
    List<TridentTuple> tupleList = mockTupleList();
    for (TridentTuple t : tupleList) {
        stateUpdater.updateState(state, Collections.singletonList(t), null);
        try {
            verify(options).execute(Collections.singletonList(t));
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
Also used : ISqlTridentDataSource(org.apache.storm.sql.runtime.ISqlTridentDataSource) IOException(java.io.IOException) HdfsState(org.apache.storm.hdfs.trident.HdfsState) StateUpdater(org.apache.storm.trident.state.StateUpdater) HdfsFileOptions(org.apache.storm.hdfs.trident.HdfsState.HdfsFileOptions) TridentTuple(org.apache.storm.trident.tuple.TridentTuple) Test(org.junit.Test)

Aggregations

IOException (java.io.IOException)1 HdfsState (org.apache.storm.hdfs.trident.HdfsState)1 HdfsFileOptions (org.apache.storm.hdfs.trident.HdfsState.HdfsFileOptions)1 ISqlTridentDataSource (org.apache.storm.sql.runtime.ISqlTridentDataSource)1 StateUpdater (org.apache.storm.trident.state.StateUpdater)1 TridentTuple (org.apache.storm.trident.tuple.TridentTuple)1 Test (org.junit.Test)1