Skip to content

Commit 884e306

Browse files
committed
fix review
1 parent 3f7ad07 commit 884e306

File tree

11 files changed

+210
-102
lines changed

11 files changed

+210
-102
lines changed

fe/fe-common/src/main/java/org/apache/doris/common/Config.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3447,6 +3447,10 @@ public static int metaServiceRpcRetryTimes() {
34473447
+ "is the active tablet priority scheduling strategy enabled? (Default: Enabled)"})
34483448
public static boolean enable_cloud_active_tablet_priority_scheduling = true;
34493449

3450+
@ConfField(masterOnly = true, description = {"滑动窗口访问统计的时间窗口大小(秒),默认3600秒(1小时)",
3451+
"Time window size in seconds for sliding window access statistics, default 3600 seconds (1 hour)"})
3452+
public static long sliding_window_time_window_second = 3600L;
3453+
34503454
@ConfField(mutable = true, masterOnly = false)
34513455
public static String security_checker_class_name = "";
34523456

fe/fe-core/src/main/java/org/apache/doris/catalog/Tablet.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import org.apache.doris.common.FeConstants;
2525
import org.apache.doris.common.Pair;
2626
import org.apache.doris.common.UserException;
27-
import org.apache.doris.common.util.SlidingWindowAccessStats;
27+
import org.apache.doris.common.util.SlidingWindowAccessStatsFactory;
2828
import org.apache.doris.resource.Tag;
2929
import org.apache.doris.system.Backend;
3030
import org.apache.doris.system.SystemInfoService;
@@ -248,8 +248,7 @@ protected Multimap<Long, Long> getNormalReplicaBackendPathMapImpl(String beEndpo
248248
// for load plan.
249249
public Multimap<Long, Long> getNormalReplicaBackendPathMap() throws UserException {
250250
return getNormalReplicaBackendPathMapImpl(null, (rep, be) -> {
251-
// Use async version to avoid blocking getBackendIdImpl which is called frequently
252-
SlidingWindowAccessStats.getInstance().recordAccessAsync(getId());
251+
SlidingWindowAccessStatsFactory.recordTablet(getId());
253252
return rep.getBackendId();
254253
});
255254
}
@@ -265,8 +264,7 @@ public List<Replica> getQueryableReplicas(long visibleVersion, Map<Long, Set<Lon
265264
List<Replica> deadPathReplica = Lists.newArrayListWithCapacity(replicaNum);
266265
List<Replica> mayMissingVersionReplica = Lists.newArrayListWithCapacity(replicaNum);
267266
List<Replica> notCatchupReplica = Lists.newArrayListWithCapacity(replicaNum);
268-
// Use async version to avoid blocking getBackendIdImpl which is called frequently
269-
SlidingWindowAccessStats.getInstance().recordAccessAsync(getId());
267+
SlidingWindowAccessStatsFactory.recordTablet(getId());
270268

271269
for (Replica replica : replicas) {
272270
if (replica.isBad()) {

fe/fe-core/src/main/java/org/apache/doris/cloud/catalog/CloudReplica.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import org.apache.doris.common.DdlException;
3030
import org.apache.doris.common.Pair;
3131
import org.apache.doris.common.util.DebugPointUtil;
32-
import org.apache.doris.common.util.SlidingWindowAccessStats;
3332
import org.apache.doris.qe.ConnectContext;
3433
import org.apache.doris.system.Backend;
3534

@@ -303,8 +302,6 @@ private long getBackendIdImpl(String clusterId) throws ComputeGroupException {
303302
if (Strings.isNullOrEmpty(clusterId)) {
304303
return -1L;
305304
}
306-
// Use async version to avoid blocking getBackendIdImpl which is called frequently
307-
SlidingWindowAccessStats.getInstance().recordAccessAsync(getId());
308305

309306
if (isColocated()) {
310307
return getColocatedBeId(clusterId);

fe/fe-core/src/main/java/org/apache/doris/cloud/catalog/CloudTablet.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import org.apache.doris.catalog.Tablet;
2323
import org.apache.doris.common.InternalErrorCode;
2424
import org.apache.doris.common.UserException;
25-
import org.apache.doris.common.util.SlidingWindowAccessStats;
25+
import org.apache.doris.common.util.SlidingWindowAccessStatsFactory;
2626
import org.apache.doris.system.SystemInfoService;
2727

2828
import com.google.common.collect.Multimap;
@@ -61,17 +61,15 @@ private Multimap<Long, Long> backendPathMapReprocess(Multimap<Long, Long> pathMa
6161

6262
@Override
6363
public Multimap<Long, Long> getNormalReplicaBackendPathMap() throws UserException {
64-
// Use async version to avoid blocking getBackendIdImpl which is called frequently
65-
SlidingWindowAccessStats.getInstance().recordAccessAsync(getId());
64+
SlidingWindowAccessStatsFactory.recordTablet(getId());
6665
Multimap<Long, Long> pathMap = super.getNormalReplicaBackendPathMap();
6766
return backendPathMapReprocess(pathMap);
6867
}
6968

7069
public Multimap<Long, Long> getNormalReplicaBackendPathMap(String beEndpoint) throws UserException {
7170
Multimap<Long, Long> pathMap = super.getNormalReplicaBackendPathMapImpl(beEndpoint,
7271
(rep, be) -> {
73-
// Use async version to avoid blocking getBackendIdImpl which is called frequently
74-
SlidingWindowAccessStats.getInstance().recordAccessAsync(getId());
72+
SlidingWindowAccessStatsFactory.recordTablet(getId());
7573
return ((CloudReplica) rep).getBackendId(be);
7674
});
7775
return backendPathMapReprocess(pathMap);

fe/fe-core/src/main/java/org/apache/doris/cloud/catalog/CloudTabletRebalancer.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import org.apache.doris.common.util.DebugPointUtil;
4040
import org.apache.doris.common.util.MasterDaemon;
4141
import org.apache.doris.common.util.SlidingWindowAccessStats;
42+
import org.apache.doris.common.util.SlidingWindowAccessStatsFactory;
4243
import org.apache.doris.metric.MetricRepo;
4344
import org.apache.doris.rpc.RpcException;
4445
import org.apache.doris.service.FrontendOptions;
@@ -1709,7 +1710,7 @@ private Set<Long> getActiveTabletIds() {
17091710
try {
17101711
// get topN active tablets
17111712
List<SlidingWindowAccessStats.AccessStatsResult> active =
1712-
SlidingWindowAccessStats.getInstance().getTopNActiveTablets(10000);
1713+
SlidingWindowAccessStatsFactory.getTabletAccessStats().getTopNActive(10000);
17131714
if (active == null || active.isEmpty()) {
17141715
return Collections.emptySet();
17151716
}

fe/fe-core/src/main/java/org/apache/doris/common/proc/ReplicasProcNode.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.apache.doris.common.Config;
2929
import org.apache.doris.common.util.NetUtils;
3030
import org.apache.doris.common.util.SlidingWindowAccessStats;
31+
import org.apache.doris.common.util.SlidingWindowAccessStatsFactory;
3132
import org.apache.doris.common.util.TimeUtils;
3233
import org.apache.doris.statistics.query.QueryStatsUtil;
3334
import org.apache.doris.system.Backend;
@@ -92,8 +93,8 @@ public ProcResult fetchResult() throws AnalysisException {
9293
}
9394

9495
for (Replica replica : replicas) {
95-
SlidingWindowAccessStats.AccessStatsResult asr = SlidingWindowAccessStats.getInstance()
96-
.getTabletAccessInfo(tabletId);
96+
SlidingWindowAccessStats.AccessStatsResult asr = SlidingWindowAccessStatsFactory.getTabletAccessStats()
97+
.getAccessInfo(tabletId);
9798
long accessCount1H = 0;
9899
long lastAccessTime = 0;
99100
if (asr != null) {

fe/fe-core/src/main/java/org/apache/doris/common/proc/TabletsProcDir.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.apache.doris.common.util.ListComparator;
3131
import org.apache.doris.common.util.NetUtils;
3232
import org.apache.doris.common.util.SlidingWindowAccessStats;
33+
import org.apache.doris.common.util.SlidingWindowAccessStatsFactory;
3334
import org.apache.doris.common.util.TimeUtils;
3435
import org.apache.doris.statistics.query.QueryStatsUtil;
3536
import org.apache.doris.system.Backend;
@@ -144,8 +145,8 @@ public List<List<Comparable>> fetchComparableResult(long version, long backendId
144145

145146
tabletInfos.add(tabletInfo);
146147
} else {
147-
SlidingWindowAccessStats.AccessStatsResult asr = SlidingWindowAccessStats.getInstance()
148-
.getTabletAccessInfo(tabletId);
148+
SlidingWindowAccessStats.AccessStatsResult asr = SlidingWindowAccessStatsFactory
149+
.getTabletAccessStats().getAccessInfo(tabletId);
149150
long accessCount1H = 0;
150151
long lastAccessTime = 0;
151152
if (asr != null) {
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
package org.apache.doris.common.util;
19+
20+
/**
21+
* ID type for access statistics
22+
*/
23+
public enum AccessStatsIdType {
24+
TABLET, // Tablet ID statistics
25+
// Add more types as needed
26+
}

0 commit comments

Comments
 (0)