Skip to content

Commit

Permalink
Merge pull request #3 from TongchengOpenSource/optimize_getserver
Browse files Browse the repository at this point in the history
Optimize the logic of RestHttpGetCommandProcessor#getSeaTunnelServer()
  • Loading branch information
xiaochen-zhou authored Mar 31, 2024
2 parents a067aa3 + f26afe6 commit eac76d0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -254,13 +254,15 @@ public boolean taskIsEnded(@NonNull TaskGroupLocation taskGroupLocation) {
public boolean isMasterNode() {
// must retry until the cluster have master node
try {
return RetryUtils.retryWithException(
() -> nodeEngine.getThisAddress().equals(nodeEngine.getMasterAddress()),
new RetryUtils.RetryMaterial(
Constant.OPERATION_RETRY_TIME,
true,
exception -> exception instanceof NullPointerException && isRunning,
Constant.OPERATION_RETRY_SLEEP));
return Boolean.TRUE.equals(
RetryUtils.retryWithException(
() -> nodeEngine.getThisAddress().equals(nodeEngine.getMasterAddress()),
new RetryUtils.RetryMaterial(
Constant.OPERATION_RETRY_TIME,
true,
exception ->
exception instanceof NullPointerException && isRunning,
Constant.OPERATION_RETRY_SLEEP)));
} catch (InterruptedException e) {
LOGGER.info("master node check interrupted");
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ private JsonObject convertToJson(JobInfo jobInfo, long jobId) {
SeaTunnelServer seaTunnelServer = getSeaTunnelServer(true);
String jobMetrics;
JobStatus jobStatus;
ClassLoaderService classLoaderService;
if (seaTunnelServer == null) {
jobMetrics =
(String)
Expand All @@ -390,15 +391,14 @@ private JsonObject convertToJson(JobInfo jobInfo, long jobId) {
getNode().nodeEngine,
new GetJobStatusOperation(jobId))
.join()];
seaTunnelServer = getSeaTunnelServer(false);
classLoaderService = getSeaTunnelServer(false).getClassLoaderService();

} else {
jobMetrics =
seaTunnelServer.getCoordinatorService().getJobMetrics(jobId).toJsonString();
jobStatus = seaTunnelServer.getCoordinatorService().getJobStatus(jobId);
classLoaderService = seaTunnelServer.getClassLoaderService();
}

ClassLoaderService classLoaderService = seaTunnelServer.getClassLoaderService();
ClassLoader classLoader =
classLoaderService.getClassLoader(
jobId, jobImmutableInformation.getPluginJarsUrls());
Expand Down

0 comments on commit eac76d0

Please sign in to comment.