NIFI-2598: This closes #889. Fixed issue with static init of properties in HiveConnectionPool

This commit is contained in:
Matt Burgess 2016-08-18 13:21:15 -04:00 committed by joewitt
parent e0e4b3407a
commit a74bc2c7c7
1 changed files with 8 additions and 8 deletions

View File

@ -17,6 +17,7 @@
package org.apache.nifi.dbcp.hive; package org.apache.nifi.dbcp.hive;
import java.io.File; import java.io.File;
import org.apache.commons.dbcp.BasicDataSource; import org.apache.commons.dbcp.BasicDataSource;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.security.UserGroupInformation; import org.apache.hadoop.security.UserGroupInformation;
@ -51,6 +52,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
import org.apache.nifi.controller.ControllerServiceInitializationContext; import org.apache.nifi.controller.ControllerServiceInitializationContext;
/** /**
@ -122,7 +124,7 @@ public class HiveConnectionPool extends AbstractControllerService implements Hiv
private static final long TICKET_RENEWAL_PERIOD = 60000; private static final long TICKET_RENEWAL_PERIOD = 60000;
private final static List<PropertyDescriptor> properties; private List<PropertyDescriptor> properties;
private String connectionUrl = "unknown"; private String connectionUrl = "unknown";
@ -136,7 +138,8 @@ public class HiveConnectionPool extends AbstractControllerService implements Hiv
private volatile File kerberosConfigFile = null; private volatile File kerberosConfigFile = null;
private volatile KerberosProperties kerberosProperties; private volatile KerberosProperties kerberosProperties;
static { @Override
protected void init(final ControllerServiceInitializationContext context) {
List<PropertyDescriptor> props = new ArrayList<>(); List<PropertyDescriptor> props = new ArrayList<>();
props.add(DATABASE_URL); props.add(DATABASE_URL);
props.add(HIVE_CONFIGURATION_RESOURCES); props.add(HIVE_CONFIGURATION_RESOURCES);
@ -144,15 +147,12 @@ public class HiveConnectionPool extends AbstractControllerService implements Hiv
props.add(DB_PASSWORD); props.add(DB_PASSWORD);
props.add(MAX_WAIT_TIME); props.add(MAX_WAIT_TIME);
props.add(MAX_TOTAL_CONNECTIONS); props.add(MAX_TOTAL_CONNECTIONS);
properties = props;
}
@Override
protected void init(final ControllerServiceInitializationContext context) {
kerberosConfigFile = context.getKerberosConfigurationFile(); kerberosConfigFile = context.getKerberosConfigurationFile();
kerberosProperties = new KerberosProperties(kerberosConfigFile); kerberosProperties = new KerberosProperties(kerberosConfigFile);
properties.add(kerberosProperties.getKerberosPrincipal()); props.add(kerberosProperties.getKerberosPrincipal());
properties.add(kerberosProperties.getKerberosKeytab()); props.add(kerberosProperties.getKerberosKeytab());
properties = props;
} }
@Override @Override