kangkaisen commented on a change in pull request #5010: URL: https://github.com/apache/incubator-doris/pull/5010#discussion_r548531872
########## File path: fe/fe-core/src/main/java/org/apache/doris/clone/MovesInProgressCache.java ########## @@ -0,0 +1,87 @@ +// 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.doris.clone; + +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; +import com.google.common.collect.Maps; +import org.apache.doris.common.Pair; +import org.apache.doris.thrift.TStorageMedium; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.StringJoiner; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; + +public class MovesInProgressCache { + // cluster -> medium -> moves in progress + private final Map<String, Map<TStorageMedium, Cell>> movesInProgressMap = Maps.newHashMap(); + + // TabletId -> Pair<Move, ToDeleteReplicaId>, 'ToDeleteReplicaId == -1' means this move haven't been scheduled successfully. + public static class Cell { + Cache<Long, Pair<PartitionRebalancer.ReplicaMove, Long>> cache; + + Cell(long duration, TimeUnit unit) { + cache = CacheBuilder.newBuilder().expireAfterAccess(duration, unit).build(); + } + + public Cache<Long, Pair<PartitionRebalancer.ReplicaMove, Long>> get() { + return cache; + } + } + + public void updateCatalog(Map<String, ClusterLoadStatistic> statisticMap, long expireAfterAccessSecond) { + updateCatalog(statisticMap, expireAfterAccessSecond, TimeUnit.SECONDS); + } + + public void updateCatalog(Map<String, ClusterLoadStatistic> statisticMap, long duration, TimeUnit unit) { Review comment: 这个方法不是在 update cache 吗? 你的类名是MovesInProgressCache, 而且有getCache。 所以updateCache 是不是更好理解? ---------------------------------------------------------------- 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...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org