本文整理汇总了Java中kafka.consumer.FetchedDataChunk类的典型用法代码示例。如果您正苦于以下问题:Java FetchedDataChunk类的具体用法?Java FetchedDataChunk怎么用?Java FetchedDataChunk使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FetchedDataChunk类属于kafka.consumer包,在下文中一共展示了FetchedDataChunk类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: MockKafkaStream
import kafka.consumer.FetchedDataChunk; //导入依赖的package包/类
public MockKafkaStream(int numStreams) {
this.queues = Lists.newArrayList();
this.mockStreams = Lists.newArrayList();
this.offsets = Lists.newArrayList();
for (int i = 0; i < numStreams; i++) {
BlockingQueue<FetchedDataChunk> queue = Queues.newLinkedBlockingQueue();
this.queues.add(queue);
this.mockStreams.add(createMockStream(queue));
this.offsets.add(new AtomicLong(0));
}
this.nextStream = new AtomicLong(-1);
}
示例2: createMockStream
import kafka.consumer.FetchedDataChunk; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private static KafkaStream<byte[], byte[]> createMockStream(BlockingQueue<FetchedDataChunk> queue) {
KafkaStream<byte[], byte[]> stream = (KafkaStream<byte[], byte[]>) Mockito.mock(KafkaStream.class);
ConsumerIterator<byte[], byte[]> it =
new ConsumerIterator<>(queue, -1, new DefaultDecoder(new VerifiableProperties()), new DefaultDecoder(new VerifiableProperties()), "clientId");
Mockito.when(stream.iterator()).thenReturn(it);
return stream;
}
示例3: pushToStream
import kafka.consumer.FetchedDataChunk; //导入依赖的package包/类
public void pushToStream(String message) {
int streamNo = (int) this.nextStream.incrementAndGet() % this.queues.size();
AtomicLong offset = this.offsets.get(streamNo);
BlockingQueue<FetchedDataChunk> queue = this.queues.get(streamNo);
AtomicLong thisOffset = new AtomicLong(offset.incrementAndGet());
List<Message> seq = Lists.newArrayList();
seq.add(new Message(message.getBytes(Charsets.UTF_8)));
ByteBufferMessageSet messageSet = new ByteBufferMessageSet(NoCompressionCodec$.MODULE$, offset, JavaConversions.asScalaBuffer(seq));
FetchedDataChunk chunk = new FetchedDataChunk(messageSet,
new PartitionTopicInfo("topic", streamNo, queue, thisOffset, thisOffset, new AtomicInteger(1), "clientId"),
thisOffset.get());
queue.add(chunk);
}
示例4: shutdown
import kafka.consumer.FetchedDataChunk; //导入依赖的package包/类
public void shutdown() {
for (BlockingQueue<FetchedDataChunk> queue : this.queues) {
queue.add(ZookeeperConsumerConnector.shutdownCommand());
}
}