Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature][ST-Engine] ST-Engine add print jobMetrics on job finished #3691

Merged
merged 1 commit into from
Dec 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public String toJsonString() {
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
try {
return objectMapper.writeValueAsString(this.metrics);
return objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(this.metrics);
} catch (JsonProcessingException e) {
ObjectNode objectNode = objectMapper.createObjectNode();
objectNode.put("err", "serialize JobMetrics err");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ public class ClientCommandArgs extends AbstractCommandArgs {
description = "Cancel job by JobId")
private String cancelJobId;

@Parameter(names = {"-m", "--metrics"},
description = "Get job metrics by JobId")
private String metricsJobId;

@Parameter(names = {"-l", "--list"},
description = "list job status")
private boolean listJob = false;
Expand Down Expand Up @@ -89,6 +93,10 @@ public String getCancelJobId() {
return cancelJobId;
}

public String getMetricsJobId() {
return metricsJobId;
}

public boolean isListJob(){
return listJob;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ public void execute() throws CommandExecuteException {
System.out.println(jobState);
} else if (null != clientCommandArgs.getCancelJobId()) {
engineClient.cancelJob(Long.parseLong(clientCommandArgs.getCancelJobId()));
} else if (null != clientCommandArgs.getMetricsJobId()) {
String jobMetrics = engineClient.getJobMetrics(Long.parseLong(clientCommandArgs.getMetricsJobId()));
System.out.println(jobMetrics);
} else {
Path configFile = FileUtils.getConfigPath(clientCommandArgs);
checkConfigExist(configFile);
Expand All @@ -87,6 +90,8 @@ public void execute() throws CommandExecuteException {

ClientJobProxy clientJobProxy = jobExecutionEnv.execute();
clientJobProxy.waitForJobComplete();
long jobId = clientJobProxy.getJobId();
System.out.println(engineClient.getJobMetrics(jobId));
}
} catch (ExecutionException | InterruptedException e) {
throw new CommandExecuteException("SeaTunnel job executed failed", e);
Expand Down