Skip to content

Commit

Permalink
commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
s7monk committed Jun 17, 2024
1 parent 007b5bf commit b0f8d98
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

package org.apache.paimon.web.server.context.logtool;

import org.apache.paimon.web.server.util.LocalDateTimeUtil;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -115,7 +117,9 @@ public void finish(String str) {
}
steps.get(stepIndex - 1).setEndTime(LocalDateTime.now());
String message =
String.format("\n[%s] %s INFO: %s", type.getValue(), LocalDateTime.now(), str);
String.format(
"\n[%s] INFO: %s",
LocalDateTimeUtil.getFormattedDateTime(LocalDateTime.now()), str);
steps.get(stepIndex - 1).appendInfo(message);
setStatus(LogStatus.FINISHED);
setEndTime(LocalDateTime.now());
Expand All @@ -128,7 +132,9 @@ public void config(String str) {
return;
}
String message =
String.format("\n[%s] %s CONFIG: %s", type.getValue(), LocalDateTime.now(), str);
String.format(
"\n[%s] CONFIG: %s",
LocalDateTimeUtil.getFormattedDateTime(LocalDateTime.now()), str);
steps.get(stepIndex - 1).appendInfo(message);
LogReadPool.write(message, userId);
}
Expand All @@ -138,7 +144,9 @@ public void info(String str) {
return;
}
String message =
String.format("\n[%s] %s INFO: %s", type.getValue(), LocalDateTime.now(), str);
String.format(
"\n[%s] INFO: %s",
LocalDateTimeUtil.getFormattedDateTime(LocalDateTime.now()), str);
steps.get(stepIndex - 1).appendInfo(message);
LogReadPool.write(message, userId);
}
Expand All @@ -164,7 +172,9 @@ public void error(String str) {
return;
}
String message =
String.format("\n[%s] %s ERROR: %s", type.getValue(), LocalDateTime.now(), str);
String.format(
"\n[%s] ERROR: %s",
LocalDateTimeUtil.getFormattedDateTime(LocalDateTime.now()), str);
steps.get(stepIndex - 1).appendInfo(message);
steps.get(stepIndex - 1).appendError(message);
LogReadPool.write(message, userId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,11 @@ public interface JobService extends IService<JobInfo> {
*/
void refreshJobStatus(String taskType);

public String getLogsByUserId(String userId);
/**
* Fetches log entries for a given user ID.
*
* @param userId the user's ID
* @return log entries as a string
*/
String getLogsByUserId(String userId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,18 @@ public JobVO submitJob(JobSubmitDTO jobSubmitDTO) {

try {
logWriter.start();
logWriter.info(
String.format(
"Starting to submit %s %s job...",
jobSubmitDTO.getTaskType(), executeMode));
ExecutionResult executionResult = executor.executeSql(jobSubmitDTO.getStatements());
if (StringUtils.isNotBlank(executionResult.getJobId())) {
JobInfo jobInfo = buildJobInfo(executionResult, jobSubmitDTO);
this.save(jobInfo);
}
logWriter.finish(String.format("Execute %s job finished.", jobSubmitDTO.getTaskType()));
logWriter.finish(
String.format(
"Execution successful [Job ID: %s].", executionResult.getJobId()));
historyService.saveHistory(
History.builder()
.name(LocalDateTimeUtil.getFormattedDateTime(LocalDateTime.now()))
Expand Down Expand Up @@ -249,8 +255,7 @@ public void stop(StopJobDTO stopJobDTO) {
LogContextHolder.registerProcess(
LogEntity.init(LogType.UNKNOWN, getLoginIdAsString()));
try {
logWriter.info(
String.format("Initializing %s job config...", stopJobDTO.getTaskType()));
logWriter.info(String.format("Starting to stop %s job...", stopJobDTO.getTaskType()));
Executor executor = getExecutor(stopJobDTO.getClusterId(), stopJobDTO.getTaskType());
if (executor == null) {
logWriter.error("No executor available for job stopping.");
Expand All @@ -271,6 +276,10 @@ public void stop(StopJobDTO stopJobDTO) {
log.error(
"Failed to update job status in the database for jobId: {}",
stopJobDTO.getJobId());
} else {
logWriter.info(
String.format(
"Successfully stopped job [Job ID: %s].", stopJobDTO.getJobId()));
}
logWriter.finish();
} catch (Exception e) {
Expand Down

0 comments on commit b0f8d98

Please sign in to comment.