@Test public void assertPropertyPriorities() throws IOException { Map<String, Object> baseProperties = new HashMap<>(); Map<String, String> mockedEnvironmentVariables = new HashMap<>(); String configFile2 = File.createTempFile("pinot-configuration-test-2", ".properties").getAbsolutePath(); String configFile3 = File.createTempFile("pinot-configuration-test-3", ".properties").getAbsolutePath(); baseProperties.put("controller.host", "cli-argument-controller-host"); baseProperties.put("config.paths", "classpath:/pinot-configuration-1.properties"); mockedEnvironmentVariables.put("PINOT_CONTROLLER_HOST", "env-var-controller-host"); mockedEnvironmentVariables.put("PINOT_CONTROLLER_PORT", "env-var-controller-port"); mockedEnvironmentVariables.put("PINOT_RELAXEDPROPERTY_TEST", "true"); mockedEnvironmentVariables.put("PINOT_CONFIG_PATHS", configFile2 + "," + configFile3); copyClasspathResource("/pinot-configuration-2.properties", configFile2); copyClasspathResource("/pinot-configuration-3.properties", configFile3); PinotConfiguration configuration = new PinotConfiguration(baseProperties, mockedEnvironmentVariables); Assert.assertEquals(configuration.getProperty("controller.host"), "cli-argument-controller-host"); Assert.assertEquals(configuration.getProperty("controller.port"), "env-var-controller-port"); Assert.assertEquals(configuration.getProperty("controller.cluster-name"), "config-path-1-cluster-name"); Assert.assertEquals(configuration.getProperty("controller.timeout"), "config-path-2-timeout"); Assert.assertEquals(configuration.getProperty("controller.config-paths-multi-value-test-1"), "config-path-2-config-paths-multi-value-test-1"); Assert.assertEquals(configuration.getProperty("controller.config-paths-multi-value-test-2"), "config-path-3-config-paths-multi-value-test-2"); Assert.assertEquals(configuration.getProperty("relaxed-property.test"), "true"); }
private static String getProperty(String name, Configuration configuration) { return Optional.of(configuration.getStringArray(relaxPropertyName(name))) .filter(values -> values.length > 0) .map(Arrays::stream) .map(stream -> stream.collect(Collectors.joining(","))) .orElse(null); }
PinotConfiguration { private static String getProperty(String name, Configuration configuration) { return Optional.of(configuration.getStringArray(relaxPropertyName(name))) .filter(values -> values.length > 0) .map(Arrays::stream) .map(stream -> stream.collect(Collectors.joining(","))) .orElse(null); } }
PinotConfiguration { private static String getProperty(String name, Configuration configuration) { return Optional.of(configuration.getStringArray(relaxPropertyName(name))) .filter(values -> values.length > 0) .map(Arrays::stream) .map(stream -> stream.collect(Collectors.joining(","))) .orElse(null); } PinotConfiguration();  PinotConfiguration(Configuration baseConfiguration);  PinotConfiguration(Map<String, Object> baseProperties);  PinotConfiguration(Map<String, Object> baseProperties, Map<String, String> environmentVariables);  PinotConfiguration(PinotFSSpec pinotFSSpec); }
PinotConfiguration { private static String getProperty(String name, Configuration configuration) { return Optional.of(configuration.getStringArray(relaxPropertyName(name))) .filter(values -> values.length > 0) .map(Arrays::stream) .map(stream -> stream.collect(Collectors.joining(","))) .orElse(null); } PinotConfiguration();  PinotConfiguration(Configuration baseConfiguration);  PinotConfiguration(Map<String, Object> baseProperties);  PinotConfiguration(Map<String, Object> baseProperties, Map<String, String> environmentVariables);  PinotConfiguration(PinotFSSpec pinotFSSpec); void addProperty(String name, Object value); PinotConfiguration clone(); boolean containsKey(String key); List<String> getKeys(); String getProperty(String name); boolean getProperty(String name, boolean defaultValue); T getProperty(String name, Class<T> returnType); double getProperty(String name, double defaultValue); int getProperty(String name, int defaultValue); List<String> getProperty(String name, List<String> defaultValues); long getProperty(String name, long defaultValue); String getProperty(String name, String defaultValue); Object getRawProperty(String name); Object getRawProperty(String name, Object defaultValue); void setProperty(String name, Object value); PinotConfiguration subset(String prefix); Map<String, Object> toMap(); }
PinotConfiguration { private static String getProperty(String name, Configuration configuration) { return Optional.of(configuration.getStringArray(relaxPropertyName(name))) .filter(values -> values.length > 0) .map(Arrays::stream) .map(stream -> stream.collect(Collectors.joining(","))) .orElse(null); } PinotConfiguration();  PinotConfiguration(Configuration baseConfiguration);  PinotConfiguration(Map<String, Object> baseProperties);  PinotConfiguration(Map<String, Object> baseProperties, Map<String, String> environmentVariables);  PinotConfiguration(PinotFSSpec pinotFSSpec); void addProperty(String name, Object value); PinotConfiguration clone(); boolean containsKey(String key); List<String> getKeys(); String getProperty(String name); boolean getProperty(String name, boolean defaultValue); T getProperty(String name, Class<T> returnType); double getProperty(String name, double defaultValue); int getProperty(String name, int defaultValue); List<String> getProperty(String name, List<String> defaultValues); long getProperty(String name, long defaultValue); String getProperty(String name, String defaultValue); Object getRawProperty(String name); Object getRawProperty(String name, Object defaultValue); void setProperty(String name, Object value); PinotConfiguration subset(String prefix); Map<String, Object> toMap(); static final String CONFIG_PATHS_KEY; }