use of org.apache.flink.runtime.rest.messages.LogListInfo in project flink by apache.
the class JobManagerLogListHandler method handleRequest.
@Override
protected CompletableFuture<LogListInfo> handleRequest(@Nonnull HandlerRequest<EmptyRequestBody> request, @Nonnull RestfulGateway gateway) throws RestHandlerException {
if (logDir == null) {
return CompletableFuture.completedFuture(new LogListInfo(Collections.emptyList()));
}
final File[] logFiles = logDir.listFiles();
if (logFiles == null) {
return FutureUtils.completedExceptionally(new IOException("Could not list files in " + logDir));
}
final List<LogInfo> logs = Arrays.stream(logFiles).filter(File::isFile).map(logFile -> new LogInfo(logFile.getName(), logFile.length(), logFile.lastModified())).collect(Collectors.toList());
return CompletableFuture.completedFuture(new LogListInfo(logs));
}
use of org.apache.flink.runtime.rest.messages.LogListInfo in project flink by apache.
the class JobManagerLogListHandlerTest method testGetJobManagerLogsList.
@Test
public void testGetJobManagerLogsList() throws Exception {
File logRoot = temporaryFolder.getRoot();
List<LogInfo> expectedLogInfo = Arrays.asList(new LogInfo("jobmanager.log", 5, 1632844800000L), new LogInfo("jobmanager.out", 7, 1632844800000L), new LogInfo("test.log", 13, 1632844800000L));
createLogFiles(logRoot, expectedLogInfo);
JobManagerLogListHandler jobManagerLogListHandler = createHandler(logRoot);
LogListInfo logListInfo = jobManagerLogListHandler.handleRequest(testRequest, dispatcherGateway).get();
assertThat(logListInfo.getLogInfos(), containsInAnyOrder(expectedLogInfo.toArray(new LogInfo[0])));
}
use of org.apache.flink.runtime.rest.messages.LogListInfo in project flink by apache.
the class JobManagerLogListHandlerTest method testGetJobManagerLogsListWhenLogDirIsNull.
@Test
public void testGetJobManagerLogsListWhenLogDirIsNull() throws Exception {
JobManagerLogListHandler jobManagerLogListHandler = createHandler(null);
LogListInfo logListInfo = jobManagerLogListHandler.handleRequest(testRequest, dispatcherGateway).get();
assertThat(logListInfo.getLogInfos(), is(empty()));
}
use of org.apache.flink.runtime.rest.messages.LogListInfo in project flink by apache.
the class TaskManagerLogListHandlerTest method testGetTaskManagerLogsList.
@Test
public void testGetTaskManagerLogsList() throws Exception {
List<LogInfo> logsList = Arrays.asList(new LogInfo("taskmanager.log", 1024L, 1632844800000L), new LogInfo("taskmanager.out", 1024L, 1632844800000L), new LogInfo("taskmanager-2.out", 1024L, 1632844800000L));
resourceManagerGateway.setRequestTaskManagerLogListFunction(EXPECTED_TASK_MANAGER_ID -> CompletableFuture.completedFuture(logsList));
LogListInfo logListInfo = taskManagerLogListHandler.handleRequest(handlerRequest, resourceManagerGateway).get();
assertThat(logListInfo.getLogInfos(), hasSize(logsList.size()));
}
Aggregations