Skip to content

Commit

Permalink
optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
zyxxoo committed Sep 29, 2024
1 parent 4274b72 commit ad1e003
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ public void increaseLoad(int delta) {
this.updated = true;
}

public long expireTime() {
return this.updateTime.getTime() + EXPIRED_INTERVAL;

Check warning on line 118 in hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/task/HugeServerInfo.java

View check run for this annotation

Codecov / codecov/patch

hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/task/HugeServerInfo.java#L118

Added line #L118 was not covered by tests
}

public Date updateTime() {
return this.updateTime;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,18 @@ public synchronized void initServerInfo(GlobalMasterInfo nodeInfo) {

Id serverId = nodeInfo.nodeId();
HugeServerInfo existed = this.serverInfo(serverId);
if (existed != null && existed.alive()) {
if (existed.expireTime() > DateUtil.now().getTime() + 30 * 1000) {
LOG.info("the node time maybe skew very much: {}", existed);
throw new HugeException("The server with name '%s' maybe skew very much", serverId);

Check warning on line 113 in hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/task/ServerInfoManager.java

View check run for this annotation

Codecov / codecov/patch

hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/task/ServerInfoManager.java#L112-L113

Added lines #L112 - L113 were not covered by tests
}
try {
Thread.sleep(existed.expireTime());
} catch (InterruptedException e) {
throw new HugeException("Interrupted when waiting for server " +

Check warning on line 118 in hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/task/ServerInfoManager.java

View check run for this annotation

Codecov / codecov/patch

hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/task/ServerInfoManager.java#L116-L118

Added lines #L116 - L118 were not covered by tests
"info expired", e);
}

Check warning on line 120 in hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/task/ServerInfoManager.java

View check run for this annotation

Codecov / codecov/patch

hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/task/ServerInfoManager.java#L120

Added line #L120 was not covered by tests
}
E.checkArgument(existed == null || !existed.alive(),
"The server with name '%s' already in cluster",
serverId);
Expand Down

0 comments on commit ad1e003

Please sign in to comment.