Skip to content

Commit 27fce57

Browse files
committed
fix tablet and replica
1 parent c7121fd commit 27fce57

File tree

6 files changed

+50
-15
lines changed

6 files changed

+50
-15
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ public class LocalReplica extends Replica {
3434
@SerializedName(value = "rds", alternate = {"remoteDataSize"})
3535
private volatile long remoteDataSize = 0;
3636
@SerializedName(value = "ris", alternate = {"remoteInvertedIndexSize"})
37-
private Long remoteInvertedIndexSize = 0L;
37+
private long remoteInvertedIndexSize = 0L;
3838
@SerializedName(value = "rss", alternate = {"remoteSegmentSize"})
39-
private Long remoteSegmentSize = 0L;
39+
private long remoteSegmentSize = 0L;
4040

4141
// the last load failed version
4242
@SerializedName(value = "lfv", alternate = {"lastFailedVersion"})
@@ -207,7 +207,7 @@ public void setRemoteDataSize(long remoteDataSize) {
207207
}
208208

209209
@Override
210-
public Long getRemoteInvertedIndexSize() {
210+
public long getRemoteInvertedIndexSize() {
211211
return remoteInvertedIndexSize;
212212
}
213213

@@ -217,7 +217,7 @@ public void setRemoteInvertedIndexSize(long remoteInvertedIndexSize) {
217217
}
218218

219219
@Override
220-
public Long getRemoteSegmentSize() {
220+
public long getRemoteSegmentSize() {
221221
return remoteSegmentSize;
222222
}
223223

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
public class LocalTablet extends Tablet {
2929
private static final Logger LOG = LogManager.getLogger(LocalTablet.class);
3030

31+
@SerializedName(value = "lastCheckTime")
32+
private long lastCheckTime;
33+
3134
// cooldown conf
3235
@SerializedName(value = "cri", alternate = {"cooldownReplicaId"})
3336
private long cooldownReplicaId = -1;
@@ -148,4 +151,14 @@ protected long getLastTimeNoPathForNewReplica() {
148151
public void setLastTimeNoPathForNewReplica(long lastTimeNoPathForNewReplica) {
149152
this.lastTimeNoPathForNewReplica = lastTimeNoPathForNewReplica;
150153
}
154+
155+
@Override
156+
public long getLastCheckTime() {
157+
return lastCheckTime;
158+
}
159+
160+
@Override
161+
public void setLastCheckTime(long lastCheckTime) {
162+
this.lastCheckTime = lastCheckTime;
163+
}
151164
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,11 @@ public static class ReplicaContext {
9999
@Setter
100100
@Getter
101101
@SerializedName(value = "lis", alternate = {"localInvertedIndexSize"})
102-
private Long localInvertedIndexSize = 0L;
102+
private long localInvertedIndexSize = 0L;
103103
@Setter
104104
@Getter
105105
@SerializedName(value = "lss", alternate = {"localSegmentSize"})
106-
private Long localSegmentSize = 0L;
106+
private long localSegmentSize = 0L;
107107

108108
public Replica() {
109109
}
@@ -199,7 +199,7 @@ public void setRemoteDataSize(long remoteDataSize) {
199199
}
200200
}
201201

202-
public Long getRemoteInvertedIndexSize() {
202+
public long getRemoteInvertedIndexSize() {
203203
return 0L;
204204
}
205205

@@ -209,7 +209,7 @@ public void setRemoteInvertedIndexSize(long remoteInvertedIndexSize) {
209209
}
210210
}
211211

212-
public Long getRemoteSegmentSize() {
212+
public long getRemoteSegmentSize() {
213213
return 0L;
214214
}
215215

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
/**
5252
* This class represents the olap tablet related metadata.
5353
*/
54-
public class Tablet extends MetaObject {
54+
public class Tablet {
5555
private static final Logger LOG = LogManager.getLogger(Tablet.class);
5656
// if current version count of replica is mor than
5757
// QUERYABLE_TIMES_OF_MIN_VERSION_COUNT times the minimum version count,
@@ -889,4 +889,12 @@ public void setLastTimeNoPathForNewReplica(long lastTimeNoPathForNewReplica) {
889889
throw new UnsupportedOperationException("setLastTimeNoPathForNewReplica is not supported in Tablet");
890890
}
891891
}
892+
893+
public long getLastCheckTime() {
894+
return -1;
895+
}
896+
897+
public void setLastCheckTime(long lastCheckTime) {
898+
throw new UnsupportedOperationException("setLastCheckTime is not supported in Tablet");
899+
}
892900
}

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public class CloudReplica extends Replica {
7272

7373
private static final Random rand = new Random();
7474

75-
private Map<String, List<Long>> memClusterToBackends = new ConcurrentHashMap<String, List<Long>>();
75+
private Map<String, List<Long>> memClusterToBackends = null;
7676

7777
// clusterId, secondaryBe, changeTimestamp
7878
private Map<String, Pair<Long, Long>> secondaryClusterToBackends
@@ -311,6 +311,7 @@ private long getBackendIdImpl(String clusterId) throws ComputeGroupException {
311311
int indexRand = rand.nextInt(Config.cloud_replica_num);
312312
int coldReadRand = rand.nextInt(100);
313313
boolean allowColdRead = coldReadRand < Config.cloud_cold_read_percent;
314+
initMemClusterToBackends();
314315
boolean replicaEnough = memClusterToBackends.get(clusterId) != null
315316
&& memClusterToBackends.get(clusterId).size() > indexRand;
316317

@@ -470,7 +471,18 @@ private long getIndexByBeNum(long hashValue, int beNum) {
470471
return (hashValue % beNum + beNum) % beNum;
471472
}
472473

473-
public List<Long> hashReplicaToBes(String clusterId, boolean isBackGround, int replicaNum)
474+
private void initMemClusterToBackends() {
475+
// the enable_cloud_multi_replica is not used now
476+
if (memClusterToBackends == null) {
477+
synchronized (this) {
478+
if (memClusterToBackends == null) {
479+
memClusterToBackends = new ConcurrentHashMap<>();
480+
}
481+
}
482+
}
483+
}
484+
485+
private List<Long> hashReplicaToBes(String clusterId, boolean isBackGround, int replicaNum)
474486
throws ComputeGroupException {
475487
// TODO(luwei) list should be sorted
476488
List<Backend> clusterBes = ((CloudSystemInfoService) Env.getCurrentSystemInfo())

fe/fe-core/src/main/java/org/apache/doris/consistency/ConsistencyChecker.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ public class ConsistencyChecker extends MasterDaemon {
5656

5757
private static final Comparator<MetaObject> COMPARATOR =
5858
(first, second) -> Long.signum(first.getLastCheckTime() - second.getLastCheckTime());
59+
private static final Comparator<Tablet> TABLET_COMPARATOR =
60+
(first, second) -> Long.signum(first.getLastCheckTime() - second.getLastCheckTime());
5961

6062
// tabletId -> job
6163
private Map<Long, CheckConsistencyJob> jobs;
@@ -315,12 +317,12 @@ private List<Long> chooseTablets() {
315317
MaterializedIndex index = (MaterializedIndex) chosenOne;
316318

317319
// sort tablets
318-
Queue<MetaObject> tabletQueue
319-
= new PriorityQueue<>(Math.max(index.getTablets().size(), 1), COMPARATOR);
320+
Queue<Tablet> tabletQueue = new PriorityQueue<>(Math.max(index.getTablets().size(), 1),
321+
TABLET_COMPARATOR);
320322
tabletQueue.addAll(index.getTablets());
323+
Tablet tablet = null;
321324

322-
while ((chosenOne = tabletQueue.poll()) != null) {
323-
Tablet tablet = (Tablet) chosenOne;
325+
while ((tablet = tabletQueue.poll()) != null) {
324326
long chosenTabletId = tablet.getId();
325327

326328
if (this.jobs.containsKey(chosenTabletId)) {

0 commit comments

Comments
 (0)