deardeng commented on code in PR #64167: URL: https://github.com/apache/doris/pull/64167#discussion_r3498387246
########## fe/fe-core/src/main/java/org/apache/doris/clone/TenantLevelColocateTableCheckerAndBalancer.java: ########## @@ -0,0 +1,469 @@ +// 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 org.apache.doris.catalog.Database; +import org.apache.doris.catalog.Env; +import org.apache.doris.catalog.MaterializedIndex; +import org.apache.doris.catalog.MaterializedIndex.IndexExtState; +import org.apache.doris.catalog.OlapTable; +import org.apache.doris.catalog.Partition; +import org.apache.doris.catalog.ReplicaAllocation; +import org.apache.doris.catalog.Tablet; +import org.apache.doris.catalog.Tablet.TabletHealth; +import org.apache.doris.catalog.Tablet.TabletStatus; +import org.apache.doris.catalog.TenantLevelColocateGroupSchema; +import org.apache.doris.catalog.TenantLevelColocateTableIndex; +import org.apache.doris.clone.TabletChecker.CheckerCounter; +import org.apache.doris.clone.TabletSchedCtx.Priority; +import org.apache.doris.clone.TabletScheduler.AddResult; +import org.apache.doris.common.Config; +import org.apache.doris.common.DdlException; +import org.apache.doris.common.Reference; +import org.apache.doris.persist.ModifyTenantLevelColocateMapInfo; +import org.apache.doris.resource.Tag; +import org.apache.doris.system.SystemInfoService; + +import com.google.common.base.Preconditions; +import com.google.common.base.Strings; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * TenantLevelColocateTableCheckerAndBalancer is responsible for tablets' repair and balance of colocated tables. + */ +public class TenantLevelColocateTableCheckerAndBalancer extends ColocateTableCheckerAndBalancer { Review Comment: TenantLevelColocateTableCheckerAndBalancer is not identical to ColocateTableCheckerAndBalancer because tenant-level colocate has a different group model, single-tag group schema, master/slave roles, slave bucket mapping, and separate master/slave stable states. So merging both into one class with conditionals may hurt readability. However, the high-level workflow is almost duplicated: runAfterCatalogReady -> relocate/balance groups -> match groups -> iterate table/partition/index/tablet -> create TabletSchedCtx -> mark stable/unstable. Could we extract a shared abstract/template layer or strategy interface for the common traversal and scheduling flow, and keep only the schema/index-specific operations in the two implementations? The current subclass reuses the low-level balance algorithm, but still duplicates too much control flow. -- 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]
