Skip to content
This repository has been archived by the owner on Jul 22, 2021. It is now read-only.

Commit

Permalink
NIFIREG-174 Fixing start-up to look for the system properties specify…
Browse files Browse the repository at this point in the history
…ing the location of properties and bootstrap, and fallback to relative paths

This closes #124.

Signed-off-by: Kevin Doran <kdoran@apache.org>
  • Loading branch information
bbende authored and kevdoran committed Jun 13, 2018
1 parent aa8b4be commit ee6c1f2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -942,6 +942,7 @@ public boolean accept(final File dir, final String filename) {
cmd.add(classPath);
cmd.addAll(javaAdditionalArgs);
cmd.add("-Dnifi.registry.properties.file.path=" + nifiRegistryPropsFilename);
cmd.add("-Dnifi.registry.bootstrap.config.file.path=" + bootstrapConfigFile.getAbsolutePath());
cmd.add("-Dnifi.registry.bootstrap.listen.port=" + listenPort);
cmd.add("-Dapp=NiFiRegistry");
cmd.add("-Dorg.apache.nifi.registry.bootstrap.config.log.dir=" + nifiRegistryLogDir);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,11 @@ public class NiFiRegistry {

public static final String BOOTSTRAP_PORT_PROPERTY = "nifi.registry.bootstrap.listen.port";

public static final String REGISTRY_BOOTSTRAP_FILE_LOCATION = "conf/bootstrap.conf";
public static final String REGISTRY_PROPERTIES_FILE_LOCATION = "conf/nifi-registry.properties";
public static final String NIFI_REGISTRY_PROPERTIES_FILE_PATH_PROPERTY = "nifi.registry.properties.file.path";
public static final String NIFI_REGISTRY_BOOTSTRAP_FILE_PATH_PROPERTY = "nifi.registry.bootstrap.config.file.path";

public static final String RELATIVE_BOOTSTRAP_FILE_LOCATION = "conf/bootstrap.conf";
public static final String RELATIVE_PROPERTIES_FILE_LOCATION = "conf/nifi-registry.properties";

private final JettyServer server;
private final BootstrapListener bootstrapListener;
Expand Down Expand Up @@ -147,8 +150,9 @@ public static void main(String[] args) {
final CryptoKeyProvider masterKeyProvider;
final NiFiRegistryProperties properties;
try {
masterKeyProvider = new BootstrapFileCryptoKeyProvider(REGISTRY_BOOTSTRAP_FILE_LOCATION);
LOGGER.info("Read property protection key from {}", REGISTRY_BOOTSTRAP_FILE_LOCATION);
final String bootstrapConfigFilePath = System.getProperty(NIFI_REGISTRY_BOOTSTRAP_FILE_PATH_PROPERTY, RELATIVE_BOOTSTRAP_FILE_LOCATION);
masterKeyProvider = new BootstrapFileCryptoKeyProvider(bootstrapConfigFilePath);
LOGGER.info("Read property protection key from {}", bootstrapConfigFilePath);
properties = initializeProperties(masterKeyProvider);
} catch (final IllegalArgumentException iae) {
throw new RuntimeException("Unable to load properties: " + iae, iae);
Expand All @@ -174,7 +178,8 @@ private static NiFiRegistryProperties initializeProperties(CryptoKeyProvider mas
try {
try {
// Load properties using key. If properties are protected and key missing, throw RuntimeException
NiFiRegistryProperties properties = NiFiRegistryPropertiesLoader.withKey(key).load(REGISTRY_PROPERTIES_FILE_LOCATION);
final String nifiRegistryPropertiesFilePath = System.getProperty(NIFI_REGISTRY_PROPERTIES_FILE_PATH_PROPERTY, RELATIVE_PROPERTIES_FILE_LOCATION);
final NiFiRegistryProperties properties = NiFiRegistryPropertiesLoader.withKey(key).load(nifiRegistryPropertiesFilePath);
LOGGER.info("Loaded {} properties", properties.size());
return properties;
} catch (SensitivePropertyProtectionException e) {
Expand Down

0 comments on commit ee6c1f2

Please sign in to comment.