@TriggerSerially @Tags(value={"hive","streaming","put","database","store"}) @CapabilityDescription(value="This processor uses Hive Streaming to send flow file data to an Apache Hive table. The incoming flow file is expected to be in Avro format and the table must exist in Hive. Please see the Hive documentation for requirements on the Hive table (format, partitions, etc.). The partition values are extracted from the Avro record based on the names of the partition columns as specified in the processor.") @WritesAttributes(value=@WritesAttribute(attribute="hivestreaming.record.count",description="This attribute is written on the flow files routed to the \'success\' and \'failure\' relationships, and contains the number of records from the incoming flow file written successfully and unsuccessfully, respectively.")) public class PutHiveStreaming extends AbstractProcessor
| Modifier and Type | Class and Description |
|---|---|
protected class |
PutHiveStreaming.HiveStreamingRecord |
| Constructor and Description |
|---|
PutHiveStreaming() |
| Modifier and Type | Method and Description |
|---|---|
private void |
abortAllWriters()
Abort current Txn on all writers
|
private void |
abortAndCloseWriters() |
private void |
appendRecordsToFlowFile(ProcessSession session,
List<PutHiveStreaming.HiveStreamingRecord> records,
AtomicReference<FlowFile> appendFlowFile,
org.apache.avro.file.DataFileWriter<org.apache.avro.generic.GenericRecord> avroWriter,
org.apache.avro.file.DataFileStream<org.apache.avro.generic.GenericRecord> reader) |
void |
cleanup() |
private void |
closeAllWriters()
Closes all writers and remove them from cache
|
private void |
flushAllWriters(boolean rollToNext) |
protected KerberosProperties |
getKerberosProperties() |
private HiveWriter |
getOrCreateWriter(org.apache.hive.hcatalog.streaming.HiveEndPoint endPoint) |
Set<Relationship> |
getRelationships() |
protected List<PropertyDescriptor> |
getSupportedPropertyDescriptors() |
protected void |
init(ProcessorInitializationContext context) |
protected org.apache.hive.hcatalog.streaming.HiveEndPoint |
makeHiveEndPoint(List<String> partitionValues,
HiveOptions options) |
protected HiveWriter |
makeHiveWriter(org.apache.hive.hcatalog.streaming.HiveEndPoint endPoint,
ExecutorService callTimeoutPool,
org.apache.hadoop.security.UserGroupInformation ugi,
HiveOptions options) |
void |
onTrigger(ProcessContext context,
ProcessSession session) |
private void |
retireEldestWriter()
Locate writer that has not been used for longest time and retire it
|
private int |
retireIdleWriters()
Locate all writers past idle timeout and retire them
|
private void |
sendHeartBeatOnAllWriters() |
void |
setup(ProcessContext context) |
private void |
setupHeartBeatTimer() |
onTriggergetControllerServiceLookup, getIdentifier, getLogger, getNodeTypeProvider, initialize, isConfigurationRestored, isScheduled, toString, updateConfiguredRestoredTrue, updateScheduledFalse, updateScheduledTruecustomValidate, equals, getPropertyDescriptor, getPropertyDescriptors, getSupportedDynamicPropertyDescriptor, hashCode, onPropertyModified, validateclone, finalize, getClass, notify, notifyAll, wait, wait, waitgetPropertyDescriptor, getPropertyDescriptors, onPropertyModified, validatepublic static final String HIVE_STREAMING_RECORD_COUNT_ATTR
private static final Validator GREATER_THAN_ONE_VALIDATOR
public static final PropertyDescriptor METASTORE_URI
public static final PropertyDescriptor HIVE_CONFIGURATION_RESOURCES
public static final PropertyDescriptor DB_NAME
public static final PropertyDescriptor TABLE_NAME
public static final PropertyDescriptor PARTITION_COLUMNS
public static final PropertyDescriptor AUTOCREATE_PARTITIONS
public static final PropertyDescriptor MAX_OPEN_CONNECTIONS
public static final PropertyDescriptor HEARTBEAT_INTERVAL
public static final PropertyDescriptor TXNS_PER_BATCH
public static final Relationship REL_SUCCESS
public static final Relationship REL_FAILURE
public static final Relationship REL_RETRY
private List<PropertyDescriptor> propertyDescriptors
private Set<Relationship> relationships
private static final long TICKET_RENEWAL_PERIOD
protected KerberosProperties kerberosProperties
private volatile File kerberosConfigFile
protected volatile HiveConfigurator hiveConfigurator
protected volatile org.apache.hadoop.security.UserGroupInformation ugi
protected final AtomicBoolean isInitialized
protected HiveOptions options
protected ExecutorService callTimeoutPool
protected transient Timer heartBeatTimer
protected AtomicBoolean sendHeartBeat
protected Map<org.apache.hive.hcatalog.streaming.HiveEndPoint,HiveWriter> allWriters
protected void init(ProcessorInitializationContext context)
init in class AbstractSessionFactoryProcessorprotected List<PropertyDescriptor> getSupportedPropertyDescriptors()
getSupportedPropertyDescriptors in class AbstractConfigurableComponentpublic Set<Relationship> getRelationships()
getRelationships in interface ProcessorgetRelationships in class AbstractSessionFactoryProcessor@OnScheduled public void setup(ProcessContext context)
public void onTrigger(ProcessContext context, ProcessSession session) throws ProcessException
onTrigger in class AbstractProcessorProcessExceptionprivate void appendRecordsToFlowFile(ProcessSession session, List<PutHiveStreaming.HiveStreamingRecord> records, AtomicReference<FlowFile> appendFlowFile, org.apache.avro.file.DataFileWriter<org.apache.avro.generic.GenericRecord> avroWriter, org.apache.avro.file.DataFileStream<org.apache.avro.generic.GenericRecord> reader) throws IOException
IOException@OnStopped public void cleanup()
private void setupHeartBeatTimer()
private void sendHeartBeatOnAllWriters()
throws InterruptedException
InterruptedExceptionprivate void flushAllWriters(boolean rollToNext)
throws HiveWriter.CommitFailure,
HiveWriter.TxnBatchFailure,
HiveWriter.TxnFailure,
InterruptedException
private void abortAndCloseWriters()
private void abortAllWriters()
throws InterruptedException,
org.apache.hive.hcatalog.streaming.StreamingException,
HiveWriter.TxnBatchFailure
InterruptedExceptionorg.apache.hive.hcatalog.streaming.StreamingExceptionHiveWriter.TxnBatchFailureprivate void closeAllWriters()
private HiveWriter getOrCreateWriter(org.apache.hive.hcatalog.streaming.HiveEndPoint endPoint) throws HiveWriter.ConnectFailure, InterruptedException
private void retireEldestWriter()
private int retireIdleWriters()
protected org.apache.hive.hcatalog.streaming.HiveEndPoint makeHiveEndPoint(List<String> partitionValues, HiveOptions options) throws org.apache.hive.hcatalog.streaming.ConnectionError
org.apache.hive.hcatalog.streaming.ConnectionErrorprotected HiveWriter makeHiveWriter(org.apache.hive.hcatalog.streaming.HiveEndPoint endPoint, ExecutorService callTimeoutPool, org.apache.hadoop.security.UserGroupInformation ugi, HiveOptions options) throws HiveWriter.ConnectFailure, InterruptedException
protected KerberosProperties getKerberosProperties()
Copyright © 2017 Apache NiFi Project. All rights reserved.