private Map<String, ContainerLogsRequest> getMatchedLogTypesForFinishedApp( List<ContainerLogsRequest> containerLogRequests, LogCLIHelpers logCliHelper, boolean useRegex, boolean ignoreSizeLimit) { Map<String, ContainerLogsRequest> containerMatchedLog = new HashMap<>(); for (ContainerLogsRequest container : containerLogRequests) { try { ContainerLogsRequest request = getMatchedLogOptions(container, logCliHelper, useRegex, ignoreSizeLimit); if (request == null) { System.err.println("Can not find any log file matching the pattern: " + container.getLogTypes() + " for the container: " + container.getContainerId() + " within the application: " + container.getAppId()); continue; } containerMatchedLog.put(container.getContainerId(), request); } catch (IOException ex) { System.err.println(ex); continue; } } return containerMatchedLog; } }
@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; }
boolean ignoreSizeLimit) throws IOException { Set<String> matchedFiles = new HashSet<String>(); Set<String> filePattern = options.getLogTypes(); long size = options.getBytes(); boolean getAll = options.getLogTypes().contains("ALL"); Iterator<ContainerLogFileInfo> iterator = candidate.iterator(); while(iterator.hasNext()) {
String nodeId = logRequest.getNodeId(); List<String> logTypes = new ArrayList<>(); if (logRequest.getLogTypes() != null && !logRequest .getLogTypes().isEmpty()) { logTypes.addAll(logRequest.getLogTypes());
boolean foundAnyLogs = false; byte[] buffer = new byte[65536]; for (String logFile : request.getLogTypes()) { InputStream is = null; try {
if (newOptions == null) { System.err.println("Can not find any log file matching the pattern: " + options.getLogTypes() + " for the application: " + options.getAppId()); } else {
: LogAggregationUtils.getNodeString(nodeId); List<String> logTypes = new ArrayList<>(); if (logRequest.getLogTypes() != null && !logRequest .getLogTypes().isEmpty()) { logTypes.addAll(logRequest.getLogTypes());
if (newOptions == null) { System.err.println("Can not find any log file matching the pattern: " + request.getLogTypes() + " for the container: " + request.getContainerId() + " within the application: " + request.getAppId()); if (newOptions == null) { System.err.println("Can not find any log file matching the pattern: " + request.getLogTypes() + " for the container: " + request.getContainerId() + " within the application: " + request.getAppId());
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()); }