From 6c9291ad530c3b47ed58db9d2c23195cf5f07df7 Mon Sep 17 00:00:00 2001 From: Matt Burgess Date: Tue, 13 Sep 2016 10:20:27 -0400 Subject: [PATCH] NIFI-2765: Fixed Kerberos support for PutHiveStreaming This closes #1012. Signed-off-by: Bryan Bende --- .../processors/hive/PutHiveStreaming.java | 45 +++++++++---------- 1 file changed, 20 insertions(+), 25 deletions(-) diff --git a/nifi-nar-bundles/nifi-hive-bundle/nifi-hive-processors/src/main/java/org/apache/nifi/processors/hive/PutHiveStreaming.java b/nifi-nar-bundles/nifi-hive-bundle/nifi-hive-processors/src/main/java/org/apache/nifi/processors/hive/PutHiveStreaming.java index b4822b2614..84eda83c0a 100644 --- a/nifi-nar-bundles/nifi-hive-bundle/nifi-hive-processors/src/main/java/org/apache/nifi/processors/hive/PutHiveStreaming.java +++ b/nifi-nar-bundles/nifi-hive-bundle/nifi-hive-processors/src/main/java/org/apache/nifi/processors/hive/PutHiveStreaming.java @@ -238,8 +238,8 @@ public class PutHiveStreaming extends AbstractProcessor { + "can be used to provide a retry capability since full rollback is not possible.") .build(); - private final static List propertyDescriptors; - private final static Set relationships; + private List propertyDescriptors; + private Set relationships; private static final long TICKET_RENEWAL_PERIOD = 60000; @@ -258,21 +258,24 @@ public class PutHiveStreaming extends AbstractProcessor { protected Map allWriters; - /* - * Will ensure that the list of property descriptors is build only once. - * Will also create a Set of relationships - */ - static { - propertyDescriptors = new ArrayList<>(); - propertyDescriptors.add(METASTORE_URI); - propertyDescriptors.add(HIVE_CONFIGURATION_RESOURCES); - propertyDescriptors.add(DB_NAME); - propertyDescriptors.add(TABLE_NAME); - propertyDescriptors.add(PARTITION_COLUMNS); - propertyDescriptors.add(AUTOCREATE_PARTITIONS); - propertyDescriptors.add(MAX_OPEN_CONNECTIONS); - propertyDescriptors.add(HEARTBEAT_INTERVAL); - propertyDescriptors.add(TXNS_PER_BATCH); + @Override + protected void init(ProcessorInitializationContext context) { + List props = new ArrayList<>(); + props.add(METASTORE_URI); + props.add(HIVE_CONFIGURATION_RESOURCES); + props.add(DB_NAME); + props.add(TABLE_NAME); + props.add(PARTITION_COLUMNS); + props.add(AUTOCREATE_PARTITIONS); + props.add(MAX_OPEN_CONNECTIONS); + props.add(HEARTBEAT_INTERVAL); + props.add(TXNS_PER_BATCH); + + kerberosConfigFile = context.getKerberosConfigurationFile(); + kerberosProperties = new KerberosProperties(kerberosConfigFile); + props.add(kerberosProperties.getKerberosPrincipal()); + props.add(kerberosProperties.getKerberosKeytab()); + propertyDescriptors = Collections.unmodifiableList(props); Set _relationships = new HashSet<>(); _relationships.add(REL_SUCCESS); @@ -281,14 +284,6 @@ public class PutHiveStreaming extends AbstractProcessor { relationships = Collections.unmodifiableSet(_relationships); } - @Override - protected void init(ProcessorInitializationContext context) { - kerberosConfigFile = context.getKerberosConfigurationFile(); - kerberosProperties = new KerberosProperties(kerberosConfigFile); - propertyDescriptors.add(kerberosProperties.getKerberosPrincipal()); - propertyDescriptors.add(kerberosProperties.getKerberosKeytab()); - } - @Override protected List getSupportedPropertyDescriptors() { return propertyDescriptors;