@Override public void close() throws IOException { firehose.close(); } }
@Override public Runnable commit() { return firehose.commit(); }
@Override public boolean hasMore() { return currentFirehose.hasMore(); }
@Nullable @Override public InputRow nextRow() { return firehose.nextRow(); }
@Override public boolean hasMore() { return i < count && delegateFirehose.hasMore(); }
@Nullable @Override public InputRow nextRow() { Preconditions.checkArgument(i++ < count, "Max events limit reached."); return delegateFirehose.nextRow(); }
@Override public boolean hasMore() { if (savedInputRow != null) { return true; } while (firehose.hasMore()) { final InputRow row = firehose.nextRow(); if (predicate.apply(row)) { savedInputRow = row; return true; } // Do not silently discard the rows if (ignored % IGNORE_THRESHOLD == 0) { log.warn("[%,d] InputRow(s) ignored as they do not satisfy the predicate", ignored); } ignored++; } return false; }
@Override public boolean hasMore() { return firehose.hasMore(); }
inputRow = firehose.nextRow();
@Override public void close() throws IOException { synchronized (shutdownLock) { if (!shutdown) { shutdown = true; firehose.close(); } } } }
@Override public Runnable commit() { return currentFirehose.commit(); }
@Test public void testSimple() throws Exception { int count = 0; long sum = 0; try (final Firehose firehose = factory.connect(ROW_PARSER, null)) { while (firehose.hasMore()) { final InputRow row = firehose.nextRow(); count++; sum += row.getMetric(METRICS[0]).longValue(); } } Assert.assertEquals("count", expectedCount, count); Assert.assertEquals("sum", expectedSum, sum); }
private boolean runFirehose(Firehose firehose) { final Supplier<Committer> committerSupplier = Committers.supplierFromFirehose(firehose); while (firehose.hasMore()) { if (Thread.interrupted() || stopping) { return false; } Plumbers.addNextRow(committerSupplier, firehose, plumber, config.isReportParseExceptions(), metrics); } return true; }
@Nullable @Override public InputRow nextRow() { return firehose.nextRow(); }
@Override public void close() throws IOException { currentFirehose.close(); } }
@Override public Runnable commit() { return delegateFirehose.commit(); }
@Test public void testWithLargeCacheAndSmallFetch() throws IOException { final TestPrefetchableTextFilesFirehoseFactory factory = TestPrefetchableTextFilesFirehoseFactory.with(TEST_DIR, 2048, 1024); final List<Row> rows = new ArrayList<>(); final File firehoseTmpDir = createFirehoseTmpDir("testWithLargeCacheAndSmallFetch"); try (Firehose firehose = factory.connect(parser, firehoseTmpDir)) { while (firehose.hasMore()) { rows.add(firehose.nextRow()); } } assertResult(rows); assertNumRemainingCacheFiles(firehoseTmpDir, 2); }
while (firehose != null && (!gracefullyStopped || firehoseDrainableByClosing) && firehose.hasMore()) { Plumbers.addNextRow( committerSupplier,
@Nullable @Override public InputRow nextRow() { Preconditions.checkArgument(i++ < count, "Max events limit reached."); return delegateFirehose.nextRow(); }