[ https://issues.apache.org/jira/browse/AMBARI-24833?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16692251#comment-16692251 ]
ASF GitHub Bot commented on AMBARI-24833: ----------------------------------------- oleewere closed pull request #29: AMBARI-24833. Use clustername and hostname in cloud log archive dir URL: https://github.com/apache/ambari-logsearch/pull/29 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/ambari-logsearch-logfeeder/src/main/java/org/apache/ambari/logfeeder/output/cloud/CloudStorageLoggerFactory.java b/ambari-logsearch-logfeeder/src/main/java/org/apache/ambari/logfeeder/output/cloud/CloudStorageLoggerFactory.java index 0cfdbcc1e2..ea422b9c31 100644 --- a/ambari-logsearch-logfeeder/src/main/java/org/apache/ambari/logfeeder/output/cloud/CloudStorageLoggerFactory.java +++ b/ambari-logsearch-logfeeder/src/main/java/org/apache/ambari/logfeeder/output/cloud/CloudStorageLoggerFactory.java @@ -21,6 +21,7 @@ import org.apache.ambari.logfeeder.common.LogFeederConstants; import org.apache.ambari.logfeeder.conf.LogFeederProps; import org.apache.ambari.logfeeder.plugin.input.Input; +import org.apache.ambari.logfeeder.util.LogFeederUtil; import org.apache.logging.log4j.Level; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.core.LoggerContext; @@ -56,10 +57,11 @@ public static Logger createLogger(Input input, LoggerContext loggerContext, LogF String type = input.getLogType().replace(LogFeederConstants.CLOUD_PREFIX, ""); String uniqueThreadName = input.getThread().getName(); Configuration config = loggerContext.getConfiguration(); - String destination = logFeederProps.getCloudStorageDestination().getText(); String baseDir = logFeederProps.getRolloverConfig().getRolloverArchiveBaseDir(); - String activeLogDir = Paths.get(baseDir, destination, ACTIVE_FOLDER, type).toFile().getAbsolutePath(); - String archiveLogDir = Paths.get(baseDir, destination, ARCHIVED_FOLDER, type).toFile().getAbsolutePath(); + String destination = logFeederProps.getCloudStorageDestination().getText(); + String clusterHostnameBaseDir = Paths.get(baseDir, destination, logFeederProps.getClusterName(), LogFeederUtil.hostName).toFile().getAbsolutePath(); + String activeLogDir = Paths.get(clusterHostnameBaseDir, ACTIVE_FOLDER, type).toFile().getAbsolutePath(); + String archiveLogDir = Paths.get(clusterHostnameBaseDir, ARCHIVED_FOLDER, type).toFile().getAbsolutePath(); boolean useGzip = logFeederProps.getRolloverConfig().isUseGzip(); final String archiveFilePattern; diff --git a/ambari-logsearch-logfeeder/src/main/java/org/apache/ambari/logfeeder/output/cloud/CloudStorageUploader.java b/ambari-logsearch-logfeeder/src/main/java/org/apache/ambari/logfeeder/output/cloud/CloudStorageUploader.java index af9326aed4..22c7fc1c61 100644 --- a/ambari-logsearch-logfeeder/src/main/java/org/apache/ambari/logfeeder/output/cloud/CloudStorageUploader.java +++ b/ambari-logsearch-logfeeder/src/main/java/org/apache/ambari/logfeeder/output/cloud/CloudStorageUploader.java @@ -26,6 +26,7 @@ import org.apache.logging.log4j.Logger; import java.io.File; +import java.nio.file.Paths; import java.util.Collection; /** @@ -74,10 +75,11 @@ public void run() { */ void doUpload() { try { - final String archiveLogDir = String.join(File.separator, logFeederProps.getRolloverConfig().getRolloverArchiveBaseDir(), uploaderType, "archived"); - if (new File(archiveLogDir).exists()) { + final File archiveLogDir = Paths.get(logFeederProps.getRolloverConfig().getRolloverArchiveBaseDir(), + uploaderType, clusterName, hostName, "archived").toFile(); + if (archiveLogDir.exists()) { String[] extensions = {"log", "json", "gz"}; - Collection<File> filesToUpload = FileUtils.listFiles(new File(archiveLogDir), extensions, true); + Collection<File> filesToUpload = FileUtils.listFiles(archiveLogDir, extensions, true); if (filesToUpload.isEmpty()) { logger.debug("Not found any files to upload."); } else { ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Log Feeder: send logs to cloud storage (gcs/s3 etc.) > ---------------------------------------------------- > > Key: AMBARI-24833 > URL: https://issues.apache.org/jira/browse/AMBARI-24833 > Project: Ambari > Issue Type: Bug > Components: ambari-logsearch > Affects Versions: 2.7.0 > Reporter: Olivér Szabó > Assignee: Olivér Szabó > Priority: Major > Labels: pull-request-available > Fix For: 2.8.0 > > -- This message was sent by Atlassian JIRA (v7.6.3#76005)