@Override public void updateState(HdfsState state, List<TridentTuple> tuples, TridentCollector collector) { state.updateState(tuples, collector); } }
@Test public void testRecoverOneBatch() throws Exception { HdfsState state = createHdfsState(); // batch 1 is played with 25 tuples initially. state.beginCommit(1L); state.updateState(createMockTridentTuples(25), null); // batch 1 is replayed with 50 tuples. int replayBatchSize = 50; state.beginCommit(1L); state.updateState(createMockTridentTuples(replayBatchSize), null); state.commit(1L); // close the state to force flush state.close(); // Ensure that the original batch1 is discarded and new one is persisted. List<String> lines = getLinesFromCurrentDataFile(); Assert.assertEquals(replayBatchSize, lines.size()); List<String> expected = new ArrayList<>(); for (int i = 0; i < replayBatchSize; i++) { expected.add("data"); } Assert.assertEquals(expected, lines); }
@Test public void testUpdateState() throws Exception { HdfsState state = createHdfsState(); state.beginCommit(1L); int tupleCount = 100; state.updateState(createMockTridentTuples(tupleCount), null); state.commit(1L); state.close(); List<String> lines = getLinesFromCurrentDataFile(); List<String> expected = new ArrayList<>(); for (int i = 0; i < tupleCount; i++) { expected.add("data"); } Assert.assertEquals(tupleCount, lines.size()); Assert.assertEquals(expected, lines); }
state.updateState(createMockTridentTuples(batch1Count), null); state.commit(1L); state.updateState(createMockTridentTuples(batch2Count), null); state.commit(2L); state.updateState(createMockTridentTuples(batch3Count), null); state.commit(3L); state.updateState(createMockTridentTuples(batch3ReplayCount), null); state.commit(3L); state.close();
@Override public void updateState(HdfsState state, List<TridentTuple> tuples, TridentCollector collector) { state.updateState(tuples, collector); } }
@Override public void updateState(HdfsState state, List<TridentTuple> tuples, TridentCollector collector) { state.updateState(tuples, collector); } }