gortiz commented on code in PR #17576: URL: https://github.com/apache/pinot/pull/17576#discussion_r2792483759
########## pinot-server/src/main/java/org/apache/pinot/server/starter/helix/KeepPipelineBreakerStatsPredicate.java: ########## @@ -0,0 +1,78 @@ +/** + * 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.server.starter.helix; + +import java.util.Locale; +import java.util.Map; +import java.util.Set; +import org.apache.pinot.spi.config.provider.PinotClusterConfigChangeListener; +import org.apache.pinot.spi.env.PinotConfiguration; +import org.apache.pinot.spi.utils.CommonConstants; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +public class KeepPipelineBreakerStatsPredicate implements PinotClusterConfigChangeListener { + private static final Logger LOGGER = LoggerFactory.getLogger(KeepPipelineBreakerStatsPredicate.class); + + private volatile boolean _skip; + + public KeepPipelineBreakerStatsPredicate(boolean skip) { + _skip = skip; + } + + // NOTE: When this method is called, the helix manager is not yet connected. + public static KeepPipelineBreakerStatsPredicate create(PinotConfiguration serverConf) { + boolean skip = serverConf.getProperty( + CommonConstants.MultiStageQueryRunner.KEY_OF_SKIP_PIPELINE_BREAKER_STATS, + CommonConstants.MultiStageQueryRunner.DEFAULT_SKIP_PIPELINE_BREAKER_STATS); + LOGGER.info("Initialized {} with value: {}", + CommonConstants.MultiStageQueryRunner.KEY_OF_SKIP_PIPELINE_BREAKER_STATS, skip); + return new KeepPipelineBreakerStatsPredicate(skip); + } + + public boolean isEnabled() { + return !_skip; + } + + @Override + public void onChange(Set<String> changedConfigs, Map<String, String> clusterConfigs) { + String key = CommonConstants.MultiStageQueryRunner.KEY_OF_SKIP_PIPELINE_BREAKER_STATS; + if (!changedConfigs.contains(key)) { + LOGGER.debug("No change for key: {}, keeping its value as {}", key, _skip); + return; + } + String value = clusterConfigs.get(key); + if (value == null || value.isEmpty()) { + LOGGER.info("Empty or null value for key: {}, reset to default: {}", + key, + CommonConstants.MultiStageQueryRunner.DEFAULT_SKIP_PIPELINE_BREAKER_STATS); + _skip = CommonConstants.MultiStageQueryRunner.DEFAULT_SKIP_PIPELINE_BREAKER_STATS; + } else { + boolean oldEnabled = _skip; Review Comment: Originally the code was using enabled everywhere, but I changed that to skip as suggested by Jackie and I forgot to rename this attribute. I think in this case the logic is not affected, but I'm going to rename it for clarity -- 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
