Skip to content

Commit

Permalink
[feature](merge-cloud) Optimize TabletStatMgr initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
SWJTU-ZhangLei committed Mar 21, 2024
1 parent ac2bd43 commit 56f39f1
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@
import org.apache.logging.log4j.Logger;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ForkJoinPool;
import java.util.Map;


/*
* CloudTabletStatMgr is for collecting tablet(replica) statistics from backends.
Expand All @@ -46,10 +47,8 @@
public class CloudTabletStatMgr extends MasterDaemon {
private static final Logger LOG = LogManager.getLogger(CloudTabletStatMgr.class);

private ForkJoinPool taskPool = new ForkJoinPool(Runtime.getRuntime().availableProcessors());

// <(dbId, tableId) -> CloudTableStats>
private ConcurrentHashMap<Pair<Long, Long>, CloudTableStats> cloudTableStatsMap = new ConcurrentHashMap<>();
private volatile Map<Pair<Long, Long>, CloudTableStats> cloudTableStatsMap = new HashMap<>();

public CloudTabletStatMgr() {
super("cloud tablet stat mgr", Config.tablet_stat_update_interval_second * 1000);
Expand Down Expand Up @@ -136,7 +135,7 @@ protected void runAfterCatalogReady() {

// after update replica in all backends, update index row num
start = System.currentTimeMillis();
ConcurrentHashMap<Pair<Long, Long>, CloudTableStats> newCloudTableStatsMap = new ConcurrentHashMap<>();
Map<Pair<Long, Long>, CloudTableStats> newCloudTableStatsMap = new HashMap<>();
for (Long dbId : dbIds) {
Database db = Env.getCurrentInternalCatalog().getDbNullable(dbId);
if (db == null) {
Expand Down Expand Up @@ -241,7 +240,7 @@ private GetTabletStatsResponse getTabletStats(GetTabletStatsRequest request)
return response;
}

public ConcurrentHashMap<Pair<Long, Long>, CloudTableStats> getCloudTableStatsMap() {
public Map<Pair<Long, Long>, CloudTableStats> getCloudTableStatsMap() {
return this.cloudTableStatsMap;
}

Expand Down
14 changes: 4 additions & 10 deletions fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java
Original file line number Diff line number Diff line change
Expand Up @@ -446,9 +446,7 @@ public class Env {

private DeployManager deployManager;

private TabletStatMgr tabletStatMgr;

private CloudTabletStatMgr cloudTabletStatMgr;
private MasterDaemon tabletStatMgr;

private Auth auth;
private AccessControllerManager accessManager;
Expand Down Expand Up @@ -694,8 +692,7 @@ public Env(boolean isCheckpointCatalog) {

this.globalTransactionMgr = EnvFactory.getInstance().createGlobalTransactionMgr(this);

this.tabletStatMgr = new TabletStatMgr();
this.cloudTabletStatMgr = new CloudTabletStatMgr();
this.tabletStatMgr = EnvFactory.getInstance().createTabletStatMgr();

this.auth = new Auth();
this.accessManager = new AccessControllerManager(auth);
Expand Down Expand Up @@ -1678,11 +1675,8 @@ protected void startMasterOnlyDaemonThreads() {
private void startNonMasterDaemonThreads() {
// start load manager thread
loadManager.start();
if (Config.isNotCloudMode()) {
tabletStatMgr.start();
} else {
cloudTabletStatMgr.start();
}
tabletStatMgr.start();

// load and export job label cleaner thread
labelCleaner.start();
// es repository
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.apache.doris.common.Config;
import org.apache.doris.common.MetaNotFoundException;
import org.apache.doris.common.UserException;
import org.apache.doris.common.util.MasterDaemon;
import org.apache.doris.common.util.PropertyAnalyzer;
import org.apache.doris.datasource.InternalCatalog;
import org.apache.doris.load.loadv2.BrokerLoadJob;
Expand Down Expand Up @@ -154,4 +155,8 @@ public RoutineLoadManager createRoutineLoadManager() {
public LoadManager createLoadManager(LoadJobScheduler loadJobScheduler) {
return new LoadManager(loadJobScheduler);
}

public MasterDaemon createTabletStatMgr() {
return new TabletStatMgr();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.apache.doris.analysis.BrokerDesc;
import org.apache.doris.analysis.DescriptorTable;
import org.apache.doris.analysis.UserIdentity;
import org.apache.doris.catalog.CloudTabletStatMgr;
import org.apache.doris.catalog.Database;
import org.apache.doris.catalog.DynamicPartitionProperty;
import org.apache.doris.catalog.Env;
Expand All @@ -41,6 +42,7 @@
import org.apache.doris.cloud.transaction.CloudGlobalTransactionMgr;
import org.apache.doris.common.MetaNotFoundException;
import org.apache.doris.common.UserException;
import org.apache.doris.common.util.MasterDaemon;
import org.apache.doris.common.util.PropertyAnalyzer;
import org.apache.doris.datasource.InternalCatalog;
import org.apache.doris.load.loadv2.BrokerLoadJob;
Expand Down Expand Up @@ -179,4 +181,8 @@ public RoutineLoadManager createRoutineLoadManager() {
public LoadManager createLoadManager(LoadJobScheduler loadJobScheduler) {
return new CloudLoadManager(loadJobScheduler);
}

public MasterDaemon createTabletStatMgr() {
return new CloudTabletStatMgr();
}
}

0 comments on commit 56f39f1

Please sign in to comment.