kasakrisz commented on a change in pull request #19: AMBARI-24833. Re-implement 
S3/HDFS outputs as global cloud outputs
URL: https://github.com/apache/ambari-logsearch/pull/19#discussion_r232542736
 
 

 ##########
 File path: 
ambari-logsearch-logfeeder/src/main/java/org/apache/ambari/logfeeder/output/cloud/CloudStorageLoggerFactory.java
 ##########
 @@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+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.logging.log4j.Level;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.core.LoggerContext;
+import org.apache.logging.log4j.core.appender.RollingFileAppender;
+import 
org.apache.logging.log4j.core.appender.rolling.CompositeTriggeringPolicy;
+import 
org.apache.logging.log4j.core.appender.rolling.OnStartupTriggeringPolicy;
+import 
org.apache.logging.log4j.core.appender.rolling.SizeBasedTriggeringPolicy;
+import org.apache.logging.log4j.core.config.AppenderRef;
+import org.apache.logging.log4j.core.config.Configuration;
+import org.apache.logging.log4j.core.config.LoggerConfig;
+import org.apache.logging.log4j.core.layout.PatternLayout;
+
+import java.io.File;
+
+/**
+ * Create a custom logger that will be used to ship inputs into specific files
+ * and rollover those files to an archive folder that will be monitored by a
+ * thread which will upload archived files to a cloud storage
+ */
+public class CloudStorageLoggerFactory {
+
+  private static final String ACTIVE_FOLDER = "active";
+  private static final String ARCHIVED_FOLDER = "archived";
+  private static final String DATE_PATTERN_SUFFIX_GZ = 
"-%d{yyyy-MM-dd-hh-mm-ss-SSS}.log.gz";
+  private static final String DATE_PATTERN_SUFFIX = 
"-%d{yyyy-MM-dd-hh-mm-ss-SSS}.log";
+
+  public static Logger createLogger(Input input, LoggerContext loggerContext, 
LogFeederProps logFeederProps) {
+    String type = input.getLogType().replace(LogFeederConstants.CLOUD_PREFIX, 
"");
+    String uniqueThreadName = input.getThread().getName();
+    Configuration config = loggerContext.getConfiguration();
+    String destination = logFeederProps.getCloudStorageDestination().getText();
+    String activeLogDir = String.join(File.separator, 
logFeederProps.getTmpDir(), destination, ACTIVE_FOLDER, type);
 
 Review comment:
   Paths.get() can be used too for joining path fragments:
   ```Paths.get(logFeederProps.getTmpDir(), destination, ACTIVE_FOLDER, type)```
   
   but joining strings is also good

----------------------------------------------------------------
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


With regards,
Apache Git Services

Reply via email to