mcvsubbu commented on a change in pull request #6842: URL: https://github.com/apache/incubator-pinot/pull/6842#discussion_r631441793
########## File path: pinot-server/src/main/java/org/apache/pinot/server/starter/helix/HelixServerStarter.java ########## @@ -218,6 +251,8 @@ private void registerServiceStatusHandler() { } private void updateInstanceConfigIfNeeded(String host, int port) { + Map<String, String> environmentProperties = new HashMap<>(); Review comment: Move this to line 284 ########## File path: pinot-server/src/main/java/org/apache/pinot/server/starter/helix/HelixServerStarter.java ########## @@ -244,6 +279,24 @@ private void updateInstanceConfigIfNeeded(String host, int port) { needToUpdateInstanceConfig = true; } + // Update instance config with environment properties + if (_pinotEnvironmentProvider != null) { + // Retrieve failure domain information and add to the environment properties map + String failureDomain = _pinotEnvironmentProvider.getFailureDomain(); + environmentProperties.put(CommonConstants.INSTANCE_FAILURE_DOMAIN, failureDomain); + + // Fetch existing environment properties map from instance configs + Map<String, String> existingEnvironmentConfigsMap = instanceConfig.getRecord().getMapField( + CommonConstants.ENVIRONMENT_IDENTIFIER); + + if (existingEnvironmentConfigsMap != null && !existingEnvironmentConfigsMap.equals(environmentProperties)) { + instanceConfig.getRecord().setMapField(CommonConstants.ENVIRONMENT_IDENTIFIER, environmentProperties); + LOGGER.info("Updated instance config for instance: {} with environment specific properties: {}", Review comment: The log message here (says "Updated...") and the one below (says "Updating....") are misleading in sequence. Suggest this change ```suggestion LOGGER.info("Adding env properties for instance {} with environment specific properties: {}", ``` ########## File path: pinot-spi/src/main/java/org/apache/pinot/spi/utils/CommonConstants.java ########## @@ -23,6 +23,10 @@ public class CommonConstants { + public static final String ENVIRONMENT_IDENTIFIER = "environment"; + public static final String INSTANCE_FAILURE_DOMAIN = "failureDomain"; + public static final String DEFAULT_FAILURE_DOMAIN = "-1"; Review comment: ```suggestion public static final String DEFAULT_FAILURE_DOMAIN = "No such domain"; ``` ########## File path: pinot-spi/src/main/java/org/apache/pinot/spi/environmentprovider/PinotEnvironmentProviderFactory.java ########## @@ -0,0 +1,84 @@ +/** + * 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 com.google.common.base.Preconditions; +import com.google.common.collect.Iterables; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.apache.pinot.spi.env.PinotConfiguration; +import org.apache.pinot.spi.plugin.PluginManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * This factory class initializes the PinotEnvironmentProvider class. + * It creates a PinotEnvironment object based on the URI found. + */ +public class PinotEnvironmentProviderFactory { + + private PinotEnvironmentProviderFactory() { + } + + private static final Logger LOGGER = LoggerFactory.getLogger(PinotEnvironmentProviderFactory.class); + private static final String CLASS = "class"; + private static final Map<String, PinotEnvironmentProvider> ENVIRONMENT_TO_ENVIRONMENT_PROVIDER_MAP = new HashMap<>(); Review comment: Why do we map here? Do we expect one instance to be a member of multiple env providers? -- 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: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org