Search in sources :

Example 1 with LogListInfo

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));
}
Also used : LogListInfo(org.apache.flink.runtime.rest.messages.LogListInfo) Arrays(java.util.Arrays) GatewayRetriever(org.apache.flink.runtime.webmonitor.retriever.GatewayRetriever) RestfulGateway(org.apache.flink.runtime.webmonitor.RestfulGateway) IOException(java.io.IOException) CompletableFuture(java.util.concurrent.CompletableFuture) LogInfo(org.apache.flink.runtime.rest.messages.LogInfo) MessageHeaders(org.apache.flink.runtime.rest.messages.MessageHeaders) Collectors(java.util.stream.Collectors) File(java.io.File) RestHandlerException(org.apache.flink.runtime.rest.handler.RestHandlerException) EmptyMessageParameters(org.apache.flink.runtime.rest.messages.EmptyMessageParameters) EmptyRequestBody(org.apache.flink.runtime.rest.messages.EmptyRequestBody) List(java.util.List) FutureUtils(org.apache.flink.util.concurrent.FutureUtils) Map(java.util.Map) LogListInfo(org.apache.flink.runtime.rest.messages.LogListInfo) HandlerRequest(org.apache.flink.runtime.rest.handler.HandlerRequest) Nonnull(javax.annotation.Nonnull) Collections(java.util.Collections) Time(org.apache.flink.api.common.time.Time) AbstractRestHandler(org.apache.flink.runtime.rest.handler.AbstractRestHandler) Nullable(javax.annotation.Nullable) LogInfo(org.apache.flink.runtime.rest.messages.LogInfo) IOException(java.io.IOException) File(java.io.File)

Example 2 with LogListInfo

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])));
}
Also used : LogListInfo(org.apache.flink.runtime.rest.messages.LogListInfo) LogInfo(org.apache.flink.runtime.rest.messages.LogInfo) File(java.io.File) Test(org.junit.Test)

Example 3 with LogListInfo

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()));
}
Also used : LogListInfo(org.apache.flink.runtime.rest.messages.LogListInfo) Test(org.junit.Test)

Example 4 with LogListInfo

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()));
}
Also used : LogListInfo(org.apache.flink.runtime.rest.messages.LogListInfo) LogInfo(org.apache.flink.runtime.rest.messages.LogInfo) Test(org.junit.Test)

Aggregations

LogListInfo (org.apache.flink.runtime.rest.messages.LogListInfo)4 LogInfo (org.apache.flink.runtime.rest.messages.LogInfo)3 Test (org.junit.Test)3 File (java.io.File)2 IOException (java.io.IOException)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 List (java.util.List)1 Map (java.util.Map)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 Collectors (java.util.stream.Collectors)1 Nonnull (javax.annotation.Nonnull)1 Nullable (javax.annotation.Nullable)1 Time (org.apache.flink.api.common.time.Time)1 AbstractRestHandler (org.apache.flink.runtime.rest.handler.AbstractRestHandler)1 HandlerRequest (org.apache.flink.runtime.rest.handler.HandlerRequest)1 RestHandlerException (org.apache.flink.runtime.rest.handler.RestHandlerException)1 EmptyMessageParameters (org.apache.flink.runtime.rest.messages.EmptyMessageParameters)1 EmptyRequestBody (org.apache.flink.runtime.rest.messages.EmptyRequestBody)1 MessageHeaders (org.apache.flink.runtime.rest.messages.MessageHeaders)1