yiguolei commented on code in PR #41170: URL: https://github.com/apache/doris/pull/41170#discussion_r1776206563
########## fe/fe-core/src/main/java/org/apache/doris/qe/SimpleScheduler.java: ########## @@ -19,37 +19,169 @@ import org.apache.doris.catalog.Env; import org.apache.doris.common.Config; -import org.apache.doris.common.Pair; import org.apache.doris.common.Reference; import org.apache.doris.common.UserException; import org.apache.doris.system.Backend; import org.apache.doris.system.SystemInfoService; import org.apache.doris.thrift.TNetworkAddress; import org.apache.doris.thrift.TScanRangeLocation; +import com.google.common.base.Strings; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import org.apache.commons.collections.CollectionUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import java.time.Instant; +import java.time.LocalDateTime; +import java.time.ZoneId; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.concurrent.atomic.AtomicLong; +import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReentrantLock; import java.util.stream.Collectors; public class SimpleScheduler { private static final Logger LOG = LogManager.getLogger(SimpleScheduler.class); + public static final long RecordBlackListThreshold = 10; + + public static class BlackListInfo { + public BlackListInfo() {} + + private Lock lock = new ReentrantLock(); + private String reasonForBlackList = ""; + private Long firstRecordBlackTimestampMs = 0L; + private Long lastRecordBlackTimestampMs = 0L; + private Long lastBlackTimestampMs = 0L; + private Long recordBlackListCount = 0L; + private Long backendID = 0L; + + public void tryAddBlackList(String reason) { + lock.lock(); + try { + recordAddBlackList(reason); + if (shuoldBeBlackListed()) { + doAddBlackList(); + LOG.info("Backend is added to black list.\n{}", getDebugInfo()); + } + } finally { + lock.unlock(); + } + } + + private void recordAddBlackList(String reason) { + if (firstRecordBlackTimestampMs <= 0) { + firstRecordBlackTimestampMs = System.currentTimeMillis(); + } + + lastRecordBlackTimestampMs = System.currentTimeMillis(); + recordBlackListCount++; Review Comment: 如果当前时间- 之前的last 时间超过了 1min,那么就应该把count 变为0,然后把first 变成当前的时间。 -- 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: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org