Package org.apache.storm.kafka.spout
Class ByTopicRecordTranslator<K,V> 
java.lang.Object
org.apache.storm.kafka.spout.ByTopicRecordTranslator<K,V> 
- Type Parameters:
- K- the key of the incoming Records
- V- the value of the incoming Records
- All Implemented Interfaces:
- Serializable,- Func<org.apache.kafka.clients.consumer.ConsumerRecord<K,,- V>, - List<Object>> - RecordTranslator<K,- V> 
Based off of a given Kafka topic a ConsumerRecord came from it will be translated to a Storm tuple
 and emitted to a given stream.
- See Also:
- 
Field SummaryFields inherited from interface org.apache.storm.kafka.spout.RecordTranslatorDEFAULT_STREAM
- 
Constructor SummaryConstructorsConstructorDescriptionByTopicRecordTranslator(Func<org.apache.kafka.clients.consumer.ConsumerRecord<K, V>, List<Object>> func, Fields fields) Create a simple record translator that will use func to extract the fields of the tuple, named by fields, and emit them to the default stream.ByTopicRecordTranslator(Func<org.apache.kafka.clients.consumer.ConsumerRecord<K, V>, List<Object>> func, Fields fields, String stream) Create a simple record translator that will use func to extract the fields of the tuple, named by fields, and emit them to stream.ByTopicRecordTranslator(RecordTranslator<K, V> defaultTranslator) Create a record translator with the given default translator.
- 
Method SummaryModifier and TypeMethodDescriptionTranslate the ConsumerRecord into a list of objects that can be emitted.forTopic(String topic, Func<org.apache.kafka.clients.consumer.ConsumerRecord<K, V>, List<Object>> func, Fields fields) Configure a translator for a given topic with tuples to be emitted to the default stream.forTopic(String topic, Func<org.apache.kafka.clients.consumer.ConsumerRecord<K, V>, List<Object>> func, Fields fields, String stream) Configure a translator for a given topic.forTopic(String topic, RecordTranslator<K, V> translator) Configure a translator for a given kafka topic.getFieldsFor(String stream) Get the fields associated with a stream.streams()Get the list of streams this translator will handle.
- 
Constructor Details- 
ByTopicRecordTranslatorpublic ByTopicRecordTranslator(Func<org.apache.kafka.clients.consumer.ConsumerRecord<K, V>, List<Object>> func, Fields fields, String stream) Create a simple record translator that will use func to extract the fields of the tuple, named by fields, and emit them to stream. This will handle all topics not explicitly set elsewhere.- Parameters:
- func- extracts and turns them into a list of objects to be emitted
- fields- the names of the fields extracted
- stream- the stream to emit these fields on.
 
- 
ByTopicRecordTranslatorpublic ByTopicRecordTranslator(Func<org.apache.kafka.clients.consumer.ConsumerRecord<K, V>, List<Object>> func, Fields fields) Create a simple record translator that will use func to extract the fields of the tuple, named by fields, and emit them to the default stream. This will handle all topics not explicitly set elsewhere.- Parameters:
- func- extracts and turns them into a list of objects to be emitted
- fields- the names of the fields extracted
 
- 
ByTopicRecordTranslatorCreate a record translator with the given default translator.- Parameters:
- defaultTranslator- a translator that will be used for all topics not explicitly set with one of the variants of- forTopic(java.lang.String, org.apache.storm.kafka.spout.RecordTranslator).
 
 
- 
- 
Method Details- 
forTopicpublic ByTopicRecordTranslator<K,V> forTopic(String topic, Func<org.apache.kafka.clients.consumer.ConsumerRecord<K, V>, List<Object>> func, Fields fields) Configure a translator for a given topic with tuples to be emitted to the default stream.- Parameters:
- topic- the topic this should be used for
- func- extracts and turns them into a list of objects to be emitted
- fields- the names of the fields extracted
- Returns:
- this to be able to chain configuration
- Throws:
- IllegalStateException- if the topic is already registered to another translator
- IllegalArgumentException- if the Fields for the stream this emits to do not match any already configured Fields for the same stream
 
- 
forTopicpublic ByTopicRecordTranslator<K,V> forTopic(String topic, Func<org.apache.kafka.clients.consumer.ConsumerRecord<K, V>, List<Object>> func, Fields fields, String stream) Configure a translator for a given topic.- Parameters:
- topic- the topic this should be used for
- func- extracts and turns them into a list of objects to be emitted
- fields- the names of the fields extracted
- stream- the stream to emit the tuples to.
- Returns:
- this to be able to chain configuration
- Throws:
- IllegalStateException- if the topic is already registered to another translator
- IllegalArgumentException- if the Fields for the stream this emits to do not match any already configured Fields for the same stream
 
- 
forTopicConfigure a translator for a given kafka topic.- Parameters:
- topic- the topic this translator should handle
- translator- the translator itself
- Returns:
- this to be able to chain configuration
- Throws:
- IllegalStateException- if the topic is already registered to another translator
- IllegalArgumentException- if the Fields for the stream this emits to do not match any already configured Fields for the same stream
 
- 
applyDescription copied from interface:RecordTranslatorTranslate the ConsumerRecord into a list of objects that can be emitted.- Specified by:
- applyin interface- Func<K,- V> 
- Specified by:
- applyin interface- RecordTranslator<K,- V> 
- Parameters:
- record- the record to translate
- Returns:
- the objects in the tuple.  Return a KafkaTupleif you want to route the tuple to a non-default stream. Returnnullto discard an invalidConsumerRecordifKafkaSpoutConfig.Builder.setEmitNullTuples(boolean)is set tofalse.
 
- 
getFieldsForDescription copied from interface:RecordTranslatorGet the fields associated with a stream. The streams passed in are returned by theRecordTranslator.streams()method.- Specified by:
- getFieldsForin interface- RecordTranslator<K,- V> 
- Parameters:
- stream- the stream the fields are for
- Returns:
- the fields for that stream.
 
- 
streamsDescription copied from interface:RecordTranslatorGet the list of streams this translator will handle.- Specified by:
- streamsin interface- RecordTranslator<K,- V> 
- Returns:
- the list of streams that this will handle.
 
 
-