public class HdfsSystemConsumer
extends org.apache.samza.util.BlockingEnvelopeMap
BlockingEnvelopeMap.
Events will be parsed from HDFS and placed into a blocking queue in BlockingEnvelopeMap.
There will be one MultiFileHdfsReader for each SystemStreamPartition,
each MultiFileHdfsReader is running within its own thread.
┌───────────────────────────────────────┐ ┌─────────────────────┐
│ │ │ │
│ MultiFileHdfsReader_1 - Thread1 │───────────▶│ SSP1-BlockingQueue ├──────┐
│ │ │ │ │
└───────────────────────────────────────┘ └─────────────────────┘ │
│
┌───────────────────────────────────────┐ ┌─────────────────────┐ │
│ │ │ │ │
│ MultiFileHdfsReader_2 - Thread2 │───────────▶│ SSP2-BlockingQueue ├──────┤ ┌──────────────────────────┐
│ │ │ │ ├───────▶│ │
└───────────────────────────────────────┘ └─────────────────────┘ └───────▶│ SystemConsumer.poll() │
┌───────▶│ │
│ └──────────────────────────┘
... ... │
│
│
┌───────────────────────────────────────┐ ┌─────────────────────┐ │
│ │ │ │ │
│ MultiFileHdfsReader_N - ThreadN │───────────▶│ SSPN-BlockingQueue ├──────┘
│ │ │ │
└───────────────────────────────────────┘ └─────────────────────┘
Since each thread has only one reader and has its own blocking queue, there are essentially no communication
among reader threads.
Thread safety between reader threads and Samza main thread is guaranteed by the blocking queues stand in the middle.| Modifier and Type | Class and Description |
|---|---|
static class |
HdfsSystemConsumer.HdfsSystemConsumerMetrics |
| Constructor and Description |
|---|
HdfsSystemConsumer(java.lang.String systemName,
org.apache.samza.config.Config config,
HdfsSystemConsumer.HdfsSystemConsumerMetrics consumerMetrics) |
| Modifier and Type | Method and Description |
|---|---|
protected java.util.concurrent.BlockingQueue<org.apache.samza.system.IncomingMessageEnvelope> |
newBlockingQueue() |
java.util.Map<org.apache.samza.system.SystemStreamPartition,java.util.List<org.apache.samza.system.IncomingMessageEnvelope>> |
poll(java.util.Set<org.apache.samza.system.SystemStreamPartition> systemStreamPartitions,
long timeout) |
void |
register(org.apache.samza.system.SystemStreamPartition systemStreamPartition,
java.lang.String offset) |
void |
start() |
void |
stop() |
public HdfsSystemConsumer(java.lang.String systemName,
org.apache.samza.config.Config config,
HdfsSystemConsumer.HdfsSystemConsumerMetrics consumerMetrics)
public void start()
public void stop()
protected java.util.concurrent.BlockingQueue<org.apache.samza.system.IncomingMessageEnvelope> newBlockingQueue()
newBlockingQueue in class org.apache.samza.util.BlockingEnvelopeMappublic void register(org.apache.samza.system.SystemStreamPartition systemStreamPartition,
java.lang.String offset)
register in interface org.apache.samza.system.SystemConsumerregister in class org.apache.samza.util.BlockingEnvelopeMappublic java.util.Map<org.apache.samza.system.SystemStreamPartition,java.util.List<org.apache.samza.system.IncomingMessageEnvelope>> poll(java.util.Set<org.apache.samza.system.SystemStreamPartition> systemStreamPartitions,
long timeout)
throws java.lang.InterruptedException
poll in interface org.apache.samza.system.SystemConsumerpoll in class org.apache.samza.util.BlockingEnvelopeMapjava.lang.InterruptedException