Skip to content

Commit e7901e1

Browse files
author
weixiang
committed
Wait to rebalanced cluster until server booted.
1 parent 3e9807d commit e7901e1

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/status/BootingStatus.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
package org.apache.skywalking.oap.server.core.status;
2020

21+
import java.util.concurrent.CountDownLatch;
2122
import lombok.AccessLevel;
2223
import lombok.Getter;
2324
import lombok.Setter;
@@ -28,6 +29,7 @@
2829
@Getter
2930
@Setter(AccessLevel.PACKAGE)
3031
public class BootingStatus {
32+
private final CountDownLatch bootingLatch = new CountDownLatch(1);
3133
/**
3234
* The status of OAP is fully booted successfully.
3335
*/
@@ -36,4 +38,13 @@ public class BootingStatus {
3638
* The uptime in milliseconds if {@link #isBooted} is true;
3739
*/
3840
private long uptime = 0;
41+
42+
public void setBooted(final boolean booted) {
43+
isBooted = booted;
44+
bootingLatch.countDown();
45+
}
46+
47+
public void waitUntilBooted() throws InterruptedException {
48+
bootingLatch.await();
49+
}
3950
}

oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/status/ServerStatusService.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,11 @@ public void bootedNow(List<ApplicationConfiguration.ModuleConfiguration> configu
6565

6666
public void rebalancedCluster(long rebalancedTime) {
6767
if (!bootingStatus.isBooted()) {
68-
return;
68+
try {
69+
bootingStatus.waitUntilBooted();
70+
} catch (InterruptedException e) {
71+
// ignore
72+
}
6973
}
7074

7175
clusterStatus.setRebalancedTime(rebalancedTime);

0 commit comments

Comments
 (0)