Source:
public Firehose connect(final InputRowParser<ByteBuffer> firehoseParser, File temporaryDirectory) throws IOException { Set<String> newDimExclus = Sets.union( firehoseParser.getParseSpec().getDimensionsSpec().getDimensionExclusions(), Sets.newHashSet("feed") ); final InputRowParser<ByteBuffer> theParser = firehoseParser.withParseSpec( firehoseParser.getParseSpec() .withDimensionsSpec( firehoseParser.getParseSpec() .getDimensionsSpec() .withDimensionExclusions( newDimExclus ) ) ); final ConsumerConnector connector = Consumer.createJavaConsumerConnector(new ConsumerConfig(consumerProps)); final Map<String, List<KafkaStream<byte[], byte[]>>> streams = connector.createMessageStreams( ImmutableMap.of( feed, 1 ) ); final List<KafkaStream<byte[], byte[]>> streamList = streams.get(feed); if (streamList == null || streamList.size() != 1) { return null; } final KafkaStream<byte[], byte[]> stream = streamList.get(0); final ConsumerIterator<byte[], byte[]> iter = stream.iterator(); return new Firehose() { Iterator<InputRow> nextIterator = Iterators.emptyIterator(); @Override public boolean hasMore() { return iter.hasNext() || nextIterator.hasNext(); } @Nullable @Override public InputRow nextRow() { try { if (!nextIterator.hasNext()) { final byte[] message = iter.next().message(); if (message == null) { return null; } nextIterator = theParser.parseBatch(ByteBuffer.wrap(message)).iterator(); } return nextIterator.next(); } catch (InvalidMessageException e) { log.error(e, "Message failed its checksum and it is corrupt, will skip it"); return null; } } @Override public Runnable commit() { return new Runnable() { @Override public void run() { log.info("committing offsets"); connector.commitOffsets(); } }; } @Override public void close() throws IOException { connector.shutdown(); } }; }

Target:
public Firehose connect(final InputRowParser<ByteBuffer> firehoseParser, File temporaryDirectory) throws IOException { Set<String> newDimExclus = Sets.union( firehoseParser.getParseSpec().getDimensionsSpec().getDimensionExclusions(), Sets.newHashSet("feed") ); final InputRowParser<ByteBuffer> theParser = firehoseParser.withParseSpec( firehoseParser.getParseSpec() .withDimensionsSpec( firehoseParser.getParseSpec() .getDimensionsSpec() .withDimensionExclusions( newDimExclus ) ) ); final ConsumerConnector connector = Consumer.createJavaConsumerConnector(new ConsumerConfig(consumerProps)); final Map<String, List<KafkaStream<byte[], byte[]>>> streams = connector.createMessageStreams( ImmutableMap.of( feed, 1 ) ); final List<KafkaStream<byte[], byte[]>> streamList = streams.get(feed); if (streamList == null || streamList.size() != 1) { return null; } final KafkaStream<byte[], byte[]> stream = streamList.get(0); final ConsumerIterator<byte[], byte[]> iter = stream.iterator(); return new Firehose() { Iterator<InputRow> nextIterator = Iterators.emptyIterator(); @Override public boolean hasMore() { return nextIterator.hasNext() || iter.hasNext(); } @Nullable @Override public InputRow nextRow() { try { if (!nextIterator.hasNext()) { final byte[] message = iter.next().message(); if (message == null) { return null; } nextIterator = theParser.parseBatch(ByteBuffer.wrap(message)).iterator(); } return nextIterator.next(); } catch (InvalidMessageException e) { log.error(e, "Message failed its checksum and it is corrupt, will skip it"); return null; } } @Override public Runnable commit() { return new Runnable() { @Override public void run() { log.info("committing offsets"); connector.commitOffsets(); } }; } @Override public void close() throws IOException { connector.shutdown(); } }; }