Skip to content

Commit

Permalink
fix: atomic refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
fengjiachun committed Sep 25, 2024
1 parent 8b498bb commit bc1ddeb
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions ingester-protocol/src/main/java/io/greptime/RouterClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,24 +78,26 @@ public boolean init(RouterOptions opts) {
return;
}

// I don't want to worry about the overflow issue with long anymore,
// because assuming one increment per second, it will take 292 years
// to overflow. I think that's sufficient.
if (thisOrder < order.get()) {
LOG.warn("Skip outdated health check result, order: {}", thisOrder);
return;
}
synchronized (this) {
// I don't want to worry about the overflow issue with long anymore,
// because assuming one increment per second, it will take 292 years
// to overflow. I think that's sufficient.
if (thisOrder < order.get()) {
LOG.warn("Skip outdated health check result, order: {}", thisOrder);
return;
}

List<Endpoint> activities = new ArrayList<>();
List<Endpoint> inactivities = new ArrayList<>();
for (Map.Entry<Endpoint, Boolean> entry : r.entrySet()) {
if (entry.getValue()) {
activities.add(entry.getKey());
} else {
inactivities.add(entry.getKey());
List<Endpoint> activities = new ArrayList<>();
List<Endpoint> inactivities = new ArrayList<>();
for (Map.Entry<Endpoint, Boolean> entry : r.entrySet()) {
if (entry.getValue()) {
activities.add(entry.getKey());
} else {
inactivities.add(entry.getKey());
}
}
this.router.onRefresh(activities, inactivities);
}
this.router.onRefresh(activities, inactivities);
});
},
Util.randomInitialDelay(180),
Expand Down

0 comments on commit bc1ddeb

Please sign in to comment.