private ContainerLogsRequest getMatchedLogOptions( ContainerLogsRequest request, LogCLIHelpers logCliHelper, boolean useRegex, boolean ignoreSizeLimit) throws IOException { ContainerLogsRequest newOptions = new ContainerLogsRequest(request); Set<ContainerLogFileInfo> files = logCliHelper.listContainerLogs( request); Set<String> matchedFiles = getMatchedLogFiles(request, files, useRegex, ignoreSizeLimit); if (matchedFiles.isEmpty()) { return null; } else { newOptions.setLogTypes(matchedFiles); return newOptions; } }
@Private @VisibleForTesting public ContainerLogsRequest getMatchedOptionForRunningApp( ContainerLogsRequest container, boolean useRegex, boolean ignoreSizeLimit) throws IOException { String containerIdStr = container.getContainerId().toString(); String nodeHttpAddress = container.getNodeHttpAddress(); if (nodeHttpAddress == null || nodeHttpAddress.isEmpty()) { System.err.println("Can not get the logs for the container: " + containerIdStr); System.err.println("The node http address is required to get container " + "logs for the Running application."); return null; } Set<String> matchedFiles = getMatchedContainerLogFiles(container, useRegex, ignoreSizeLimit); if (matchedFiles.isEmpty()) { System.err.println("Can not find any log file matching the pattern: " + container.getLogTypes() + " for the container: " + containerIdStr + " within the application: " + container.getAppId()); return null; } container.setLogTypes(matchedFiles); return container; }
Set<String> logTypes = new HashSet<>(); logTypes.add(outputFileName); logRequest.setLogTypes(logTypes); factory.getFileControllerForRead(appId, appOwner) .readAggregatedLogs(logRequest, os);
@Private @VisibleForTesting public int dumpAContainersLogs(String appId, String containerId, String nodeId, String jobOwner) throws IOException { ContainerLogsRequest options = new ContainerLogsRequest(); options.setAppId(ApplicationId.fromString(appId)); options.setContainerId(containerId); options.setNodeId(nodeId); options.setAppOwner(jobOwner); Set<String> logs = new HashSet<String>(); options.setLogTypes(logs); options.setBytes(Long.MAX_VALUE); return dumpAContainerLogsForLogType(options, false); }
public ContainerLogsRequest(ApplicationId applicationId, boolean isAppFinished, String owner, String address, String httpAddress, String container, String localDir, Set<String> logs, long bytes, ContainerState containerState) { this.setAppId(applicationId); this.setAppFinished(isAppFinished); this.setAppOwner(owner); this.setNodeId(address); this.setNodeHttpAddress(httpAddress); this.setContainerId(container); this.setOutputLocalDir(localDir); this.setLogTypes(logs); this.setBytes(bytes); this.setContainerState(containerState); }
public ContainerLogsRequest(ContainerLogsRequest request) { this.setAppId(request.getAppId()); this.setAppFinished(request.isAppFinished()); this.setAppOwner(request.getAppOwner()); this.setNodeId(request.getNodeId()); this.setNodeHttpAddress(request.getNodeHttpAddress()); this.setContainerId(request.getContainerId()); this.setOutputLocalDir(request.getOutputLocalDir()); this.setLogTypes(request.getLogTypes()); this.setBytes(request.getBytes()); this.setContainerState(request.getContainerState()); }