Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
gdliu3 committed Dec 25, 2023
1 parent f248f97 commit 20ed5df
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,6 @@ public class RestConstant {
"/hazelcast/rest/maps/system-monitoring-information";

public static final String STOP_JOB_URL = "/hazelcast/rest/maps/stop-job";

public static final String GET_LOG = "/hazelcast/rest/maps/log";
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@
import com.hazelcast.map.IMap;
import com.hazelcast.spi.impl.NodeEngine;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Comparator;
Expand All @@ -69,7 +73,7 @@
import static org.apache.seatunnel.engine.server.rest.RestConstant.RUNNING_JOBS_URL;
import static org.apache.seatunnel.engine.server.rest.RestConstant.RUNNING_JOB_URL;
import static org.apache.seatunnel.engine.server.rest.RestConstant.SYSTEM_MONITORING_INFORMATION;

import static org.apache.seatunnel.engine.server.rest.RestConstant.GET_LOG;
public class RestHttpGetCommandProcessor extends HttpCommandProcessor<HttpGetCommand> {

private final Log4j2HttpGetCommandProcessor original;
Expand Down Expand Up @@ -105,7 +109,9 @@ public void handle(HttpGetCommand httpGetCommand) {
handleJobInfoById(httpGetCommand, uri);
} else if (uri.startsWith(SYSTEM_MONITORING_INFORMATION)) {
getSystemMonitoringInformation(httpGetCommand);
} else {
} else if (uri.startsWith(GET_LOG)) {
handleLog(httpGetCommand);
}else {
original.handle(httpGetCommand);
}
} catch (IndexOutOfBoundsException e) {
Expand Down Expand Up @@ -159,6 +165,19 @@ private void getSystemMonitoringInformation(HttpGetCommand command) {
this.prepareResponse(command, jsonValues);
}

private void handleLog(HttpGetCommand command) throws IOException {

String logPath = System.getProperty("seatunnel.logs.path");
String logName = System.getProperty("seatunnel.logs.file_name")+".log";
Path path = Paths.get(logPath, logName);
if (!Files.exists(path)) {
this.prepareResponse(command, new JsonObject());
return;
}
byte[] logBytes = Files.readAllBytes(path);
this.prepareResponse(command, new String(logBytes));
}

private void handleRunningJobsInfo(HttpGetCommand command) {
IMap<Long, JobInfo> values =
this.textCommandService
Expand Down

0 comments on commit 20ed5df

Please sign in to comment.