You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ol...@apache.org on 2018/11/19 20:49:46 UTC
[ambari-logsearch] branch master updated: AMBARI-24833. Use
clustername and hostname in cloud log archive dir (#29)
This is an automated email from the ASF dual-hosted git repository.
oleewere pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ambari-logsearch.git
The following commit(s) were added to refs/heads/master by this push:
new 1af5b0b AMBARI-24833. Use clustername and hostname in cloud log archive dir (#29)
1af5b0b is described below
commit 1af5b0b50442df0bb292151554a169e64372289a
Author: Olivér Szabó <ol...@gmail.com>
AuthorDate: Mon Nov 19 21:49:42 2018 +0100
AMBARI-24833. Use clustername and hostname in cloud log archive dir (#29)
* AMBARI-24833. Use clustername and hostname in cloud log archive dir
* AMBARI-24833. Check the right folders on upload and use Paths.get
---
.../ambari/logfeeder/output/cloud/CloudStorageLoggerFactory.java | 8 +++++---
.../ambari/logfeeder/output/cloud/CloudStorageUploader.java | 8 +++++---
2 files changed, 10 insertions(+), 6 deletions(-)
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 0cfdbcc..ea422b9 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 @@ package org.apache.ambari.logfeeder.output.cloud;
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 class CloudStorageLoggerFactory {
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 af9326a..22c7fc1 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.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.File;
+import java.nio.file.Paths;
import java.util.Collection;
/**
@@ -74,10 +75,11 @@ public class CloudStorageUploader extends Thread {
*/
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 {