You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2021/05/07 00:24:21 UTC

[GitHub] [incubator-pinot] Jackie-Jiang commented on a change in pull request #6842: Core Pinot Environment Provider Implementation Logic to fetch Failureā€¦

Jackie-Jiang commented on a change in pull request #6842:
URL: https://github.com/apache/incubator-pinot/pull/6842#discussion_r627845646



##########
File path: pinot-server/src/main/java/org/apache/pinot/server/starter/helix/HelixServerStarter.java
##########
@@ -261,12 +270,39 @@ private void updateInstanceConfigIfNeeded(String host, int port) {
         "Failed to update instance config");
   }
 
+  // Fetch the overridden server configs for the invoked environment provider
+  private void populateFailureDomain() {
+    String className = _serverConf.getProperty(ENVIRONMENT_PROVIDER_CLASS_NAME);
+    if (className == null) return;
+    PinotEnvironmentProvider pinotEnvironmentProvider = PinotEnvironmentProviderFactory.getEnvironmentProvider(className.toLowerCase());
+    _serverConf = pinotEnvironmentProvider.getEnvironment(_serverConf.toMap());
+    Map<String, Object> overriddenPinotConfigurationMap = _serverConf.toMap();
+    String failureDomain = overriddenPinotConfigurationMap.containsKey(INSTANCE_FAILURE_DOMAIN.toLowerCase()) ?
+        String.valueOf(overriddenPinotConfigurationMap.get(INSTANCE_FAILURE_DOMAIN.toLowerCase())) : null;
+    if (failureDomain == null) {
+      LOGGER.info("No failure domain information found for instance: {}", _instanceId);
+      return;
+    }
+    Map<String, String> failureDomainMap = new HashMap<>();
+    failureDomainMap.put(FAILURE_DOMAIN_IDENTIFIER, failureDomain);

Review comment:
       How about other environment properties? We should put all of them here

##########
File path: pinot-spi/src/main/java/org/apache/pinot/spi/environmentprovider/PinotEnvironmentProvider.java
##########
@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.spi.environmentprovider;
+
+import java.util.Map;
+import org.apache.pinot.spi.env.PinotConfiguration;
+
+/**
+ *  Environment Provider interface implemented by different cloud
+ *  providers to customize the base pinot configuration to add environment
+ *  variables & instance specific configuration
+ */
+public interface PinotEnvironmentProvider {
+
+  String INSTANCE_FAILURE_DOMAIN = "pinot.environment.instance.failureDomain";
+  /**
+   * Customize base pinot configuration to add environment variable & instance specific configuration
+   * @param baseConfiguration Base configuration provided by the invoking service
+   * @return Custom Pinot Configuration
+   */
+  PinotConfiguration getEnvironment(Map<String, Object> baseConfiguration);

Review comment:
       Why do we need to pass in the instance config twice (once in `init` and once `here`)? We should only pass it once.
   Since the environment properties will be stored as a map field in the ZNRecord, we should probably just return a `Map<String, String>` here.
   ```suggestion
     Map<String, String> getEnvironment();
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org