You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by db...@apache.org on 2016/03/21 15:34:59 UTC

ambari git commit: AMBARI-14084 : ViewRegistry now looks for file view.log4j.properties using the view archive classloader and loads all the log4j properties in it using PropertyConfigurator. Separate log4j configuraiton files added to all core views. (N

Repository: ambari
Updated Branches:
  refs/heads/branch-2.2 f189015a3 -> c663f7938


AMBARI-14084 : ViewRegistry now looks for file view.log4j.properties using the view archive classloader and loads all the log4j properties in it using PropertyConfigurator. Separate log4j configuraiton files added to all core views. (Nitiraj Rathore via dipayanb)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/c663f793
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/c663f793
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/c663f793

Branch: refs/heads/branch-2.2
Commit: c663f7938cec1cf6f5c8c73d81b9eb4c32e482d1
Parents: f189015
Author: Dipayan Bhowmick <di...@gmail.com>
Authored: Mon Mar 21 20:04:32 2016 +0530
Committer: Dipayan Bhowmick <di...@gmail.com>
Committed: Mon Mar 21 20:04:32 2016 +0530

----------------------------------------------------------------------
 .../org/apache/ambari/server/view/ViewRegistry.java    | 13 +++++++++++++
 contrib/views/capacity-scheduler/pom.xml               |  1 +
 .../src/main/resources/view.log4j.properties           |  9 +++++++++
 contrib/views/files/pom.xml                            |  1 +
 .../files/src/main/resources/view.log4j.properties     |  9 +++++++++
 contrib/views/hive/pom.xml                             |  1 +
 .../hive/src/main/resources/view.log4j.properties      |  9 +++++++++
 contrib/views/jobs/pom.xml                             |  1 +
 .../jobs/src/main/resources/view.log4j.properties      | 10 ++++++++++
 contrib/views/pig/pom.xml                              |  1 +
 .../views/pig/src/main/resources/view.log4j.properties |  9 +++++++++
 contrib/views/slider/pom.xml                           |  1 +
 .../slider/src/main/resources/view.log4j.properties    |  9 +++++++++
 .../storm/src/main/resources/view.log4j.properties     |  9 +++++++++
 contrib/views/tez/pom.xml                              |  1 +
 .../views/tez/src/main/resources/view.log4j.properties |  9 +++++++++
 16 files changed, 93 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/c663f793/ambari-server/src/main/java/org/apache/ambari/server/view/ViewRegistry.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/view/ViewRegistry.java b/ambari-server/src/main/java/org/apache/ambari/server/view/ViewRegistry.java
index 8b1f26e..6a01351 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/view/ViewRegistry.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/view/ViewRegistry.java
@@ -89,6 +89,7 @@ import org.apache.ambari.view.ViewDefinition;
 import org.apache.ambari.view.ViewResourceHandler;
 import org.apache.ambari.view.events.Event;
 import org.apache.ambari.view.events.Listener;
+import org.apache.log4j.PropertyConfigurator;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.security.core.GrantedAuthority;
@@ -99,6 +100,7 @@ import javax.inject.Singleton;
 
 import java.beans.IntrospectionException;
 import java.io.File;
+import java.net.URL;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
@@ -127,6 +129,7 @@ public class ViewRegistry {
   protected static final int DEFAULT_REQUEST_CONNECT_TIMEOUT = 5000;
   protected static final int DEFAULT_REQUEST_READ_TIMEOUT    = 10000;
   private static final String VIEW_AMBARI_VERSION_REGEXP = "^((\\d+\\.)?)*(\\*|\\d+)$";
+  private static final String VIEW_LOG_FILE = "view.log4j.properties";
 
   /**
    * Thread pool
@@ -1541,6 +1544,8 @@ public class ViewRegistry {
       // extract the archive and get the class loader
       ClassLoader cl = extractor.extractViewArchive(viewDefinition, archiveFile, extractedArchiveDirFile);
 
+      configureViewLogging(viewDefinition,cl);
+
       ViewConfig viewConfig = archiveUtility.getViewConfigFromExtractedArchive(extractedArchiveDirPath,
           configuration.isViewValidationEnabled());
 
@@ -1573,6 +1578,14 @@ public class ViewRegistry {
     }
   }
 
+  private void configureViewLogging(ViewEntity viewDefinition,ClassLoader cl) {
+    URL resourceURL = cl.getResource(VIEW_LOG_FILE);
+    if( null != resourceURL ){
+      LOG.debug("setting up logging for view {} as per property file {}",viewDefinition.getName(), resourceURL);
+      PropertyConfigurator.configure(resourceURL);
+    }
+  }
+
   private void addAutoInstanceDefinition(ViewEntity viewEntity) {
     ViewConfig viewConfig = viewEntity.getConfiguration();
     String viewName = viewEntity.getViewName();

http://git-wip-us.apache.org/repos/asf/ambari/blob/c663f793/contrib/views/capacity-scheduler/pom.xml
----------------------------------------------------------------------
diff --git a/contrib/views/capacity-scheduler/pom.xml b/contrib/views/capacity-scheduler/pom.xml
index 5569859..e523eb7 100644
--- a/contrib/views/capacity-scheduler/pom.xml
+++ b/contrib/views/capacity-scheduler/pom.xml
@@ -248,6 +248,7 @@
         <filtering>false</filtering>
         <includes>
             <include>view.xml</include>
+            <include>view.log4j.properties</include>
         </includes>
         </resource>
         <resource>

http://git-wip-us.apache.org/repos/asf/ambari/blob/c663f793/contrib/views/capacity-scheduler/src/main/resources/view.log4j.properties
----------------------------------------------------------------------
diff --git a/contrib/views/capacity-scheduler/src/main/resources/view.log4j.properties b/contrib/views/capacity-scheduler/src/main/resources/view.log4j.properties
new file mode 100644
index 0000000..1c51fb5
--- /dev/null
+++ b/contrib/views/capacity-scheduler/src/main/resources/view.log4j.properties
@@ -0,0 +1,9 @@
+log4j.appender.capshedView=org.apache.log4j.RollingFileAppender
+log4j.appender.capshedView.File=/var/log/ambari-server/capshed-view.log
+log4j.appender.capshedView.MaxFileSize=80MB
+log4j.appender.capshedView.MaxBackupIndex=60
+log4j.appender.capshedView.layout=org.apache.log4j.PatternLayout
+log4j.appender.capshedView.layout.ConversionPattern=%d{DATE} %5p [%t] %c{1}:%L - %m%n
+
+log4j.logger.org.apache.ambari.view.capacityscheduler=DEBUG,capshedView
+log4j.additivity.org.apache.ambari.view.capacityscheduler = false

http://git-wip-us.apache.org/repos/asf/ambari/blob/c663f793/contrib/views/files/pom.xml
----------------------------------------------------------------------
diff --git a/contrib/views/files/pom.xml b/contrib/views/files/pom.xml
index ccea5ab..c60ba9e 100644
--- a/contrib/views/files/pom.xml
+++ b/contrib/views/files/pom.xml
@@ -241,6 +241,7 @@
         <filtering>false</filtering>
         <includes>
           <include>view.xml</include>
+          <include>view.log4j.properties</include>
         </includes>
       </resource>
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/c663f793/contrib/views/files/src/main/resources/view.log4j.properties
----------------------------------------------------------------------
diff --git a/contrib/views/files/src/main/resources/view.log4j.properties b/contrib/views/files/src/main/resources/view.log4j.properties
new file mode 100644
index 0000000..4340341
--- /dev/null
+++ b/contrib/views/files/src/main/resources/view.log4j.properties
@@ -0,0 +1,9 @@
+log4j.appender.filesView=org.apache.log4j.RollingFileAppender
+log4j.appender.filesView.File=/var/log/ambari-server/files-view.log
+log4j.appender.filesView.MaxFileSize=80MB
+log4j.appender.filesView.MaxBackupIndex=60
+log4j.appender.filesView.layout=org.apache.log4j.PatternLayout
+log4j.appender.filesView.layout.ConversionPattern=%d{DATE} %5p [%t] %c{1}:%L - %m%n
+
+log4j.logger.org.apache.ambari.view.filebrowser=DEBUG,filesView
+log4j.additivity.org.apache.ambari.view.filebrowser= true

http://git-wip-us.apache.org/repos/asf/ambari/blob/c663f793/contrib/views/hive/pom.xml
----------------------------------------------------------------------
diff --git a/contrib/views/hive/pom.xml b/contrib/views/hive/pom.xml
index 1f150ff..fd6fcfe 100644
--- a/contrib/views/hive/pom.xml
+++ b/contrib/views/hive/pom.xml
@@ -336,6 +336,7 @@
         <includes>
           <include>META-INF/**/*</include>
           <include>view.xml</include>
+          <include>view.log4j.properties</include>
         </includes>
       </resource>
       <resource>

http://git-wip-us.apache.org/repos/asf/ambari/blob/c663f793/contrib/views/hive/src/main/resources/view.log4j.properties
----------------------------------------------------------------------
diff --git a/contrib/views/hive/src/main/resources/view.log4j.properties b/contrib/views/hive/src/main/resources/view.log4j.properties
new file mode 100644
index 0000000..77f8258
--- /dev/null
+++ b/contrib/views/hive/src/main/resources/view.log4j.properties
@@ -0,0 +1,9 @@
+log4j.appender.hiveView=org.apache.log4j.RollingFileAppender
+log4j.appender.hiveView.File=/var/log/ambari-server/hive-view.log
+log4j.appender.hiveView.MaxFileSize=80MB
+log4j.appender.hiveView.MaxBackupIndex=60
+log4j.appender.hiveView.layout=org.apache.log4j.PatternLayout
+log4j.appender.hiveView.layout.ConversionPattern=%d{DATE} %5p [%t] %c{1}:%L - %m%n
+
+log4j.logger.org.apache.ambari.view.hive=DEBUG,hiveView
+log4j.additivity.org.apache.ambari.view.hive = false

http://git-wip-us.apache.org/repos/asf/ambari/blob/c663f793/contrib/views/jobs/pom.xml
----------------------------------------------------------------------
diff --git a/contrib/views/jobs/pom.xml b/contrib/views/jobs/pom.xml
index d797ebd..045920f 100644
--- a/contrib/views/jobs/pom.xml
+++ b/contrib/views/jobs/pom.xml
@@ -156,6 +156,7 @@
                     <include>WEB-INF/web.xml</include>
                     <include>META-INF/**/*</include>
                     <include>view.xml</include>
+                    <include>view.log4j.properties</include>
                 </includes>
             </resource>
             <resource>

http://git-wip-us.apache.org/repos/asf/ambari/blob/c663f793/contrib/views/jobs/src/main/resources/view.log4j.properties
----------------------------------------------------------------------
diff --git a/contrib/views/jobs/src/main/resources/view.log4j.properties b/contrib/views/jobs/src/main/resources/view.log4j.properties
new file mode 100644
index 0000000..4007e0e
--- /dev/null
+++ b/contrib/views/jobs/src/main/resources/view.log4j.properties
@@ -0,0 +1,10 @@
+log4j.appender.jobsView=org.apache.log4j.RollingFileAppender
+log4j.appender.jobsView.File=/var/log/ambari-server/jobs-view.log
+log4j.appender.jobsView.MaxFileSize=80MB
+log4j.appender.jobsView.MaxBackupIndex=60
+log4j.appender.jobsView.layout=org.apache.log4j.PatternLayout
+log4j.appender.jobsView.layout.ConversionPattern=%d{DATE} %5p [%t] %c{1}:%L - %m%n
+
+
+log4j.logger.org.apache.ambari.view.jobs=DEBUG,jobsView
+log4j.additivity.org.apache.ambari.view.jobs=false
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/c663f793/contrib/views/pig/pom.xml
----------------------------------------------------------------------
diff --git a/contrib/views/pig/pom.xml b/contrib/views/pig/pom.xml
index 97160cc..c0beeb8 100644
--- a/contrib/views/pig/pom.xml
+++ b/contrib/views/pig/pom.xml
@@ -305,6 +305,7 @@
         <includes>
           <include>META-INF/**/*</include>
           <include>view.xml</include>
+          <include>view.log4j.properties</include>
         </includes>
       </resource>
       <resource>

http://git-wip-us.apache.org/repos/asf/ambari/blob/c663f793/contrib/views/pig/src/main/resources/view.log4j.properties
----------------------------------------------------------------------
diff --git a/contrib/views/pig/src/main/resources/view.log4j.properties b/contrib/views/pig/src/main/resources/view.log4j.properties
new file mode 100644
index 0000000..38eb5ee
--- /dev/null
+++ b/contrib/views/pig/src/main/resources/view.log4j.properties
@@ -0,0 +1,9 @@
+log4j.appender.pigView=org.apache.log4j.RollingFileAppender
+log4j.appender.pigView.File=/var/log/ambari-server/pig-view.log
+log4j.appender.pigView.MaxFileSize=80MB
+log4j.appender.pigView.MaxBackupIndex=60
+log4j.appender.pigView.layout=org.apache.log4j.PatternLayout
+log4j.appender.pigView.layout.ConversionPattern=%d{DATE} %5p [%t] %c{1}:%L - %m%n
+
+log4j.logger.org.apache.ambari.view.pig=DEBUG,pigView
+log4j.additivity.org.apache.ambari.view.pig=false
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/c663f793/contrib/views/slider/pom.xml
----------------------------------------------------------------------
diff --git a/contrib/views/slider/pom.xml b/contrib/views/slider/pom.xml
index 608988f..4188bb2 100644
--- a/contrib/views/slider/pom.xml
+++ b/contrib/views/slider/pom.xml
@@ -336,6 +336,7 @@
         <filtering>false</filtering>
         <includes>
           <include>view.xml</include>
+          <include>view.log4j.properties</include>
         </includes>
       </resource>
       <resource>

http://git-wip-us.apache.org/repos/asf/ambari/blob/c663f793/contrib/views/slider/src/main/resources/view.log4j.properties
----------------------------------------------------------------------
diff --git a/contrib/views/slider/src/main/resources/view.log4j.properties b/contrib/views/slider/src/main/resources/view.log4j.properties
new file mode 100644
index 0000000..2eed2ca
--- /dev/null
+++ b/contrib/views/slider/src/main/resources/view.log4j.properties
@@ -0,0 +1,9 @@
+log4j.appender.sliderView=org.apache.log4j.RollingFileAppender
+log4j.appender.sliderView.File=/var/log/ambari-server/slider-view.log
+log4j.appender.sliderView.MaxFileSize=80MB
+log4j.appender.sliderView.MaxBackupIndex=60
+log4j.appender.sliderView.layout=org.apache.log4j.PatternLayout
+log4j.appender.sliderView.layout.ConversionPattern=%d{DATE} %5p [%t] %c{1}:%L - %m%n
+
+log4j.logger.org.apache.ambari.view.slider=DEBUG,sliderView
+log4j.additivity.org.apache.ambari.view.slider=false
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/c663f793/contrib/views/storm/src/main/resources/view.log4j.properties
----------------------------------------------------------------------
diff --git a/contrib/views/storm/src/main/resources/view.log4j.properties b/contrib/views/storm/src/main/resources/view.log4j.properties
new file mode 100644
index 0000000..a51fb74
--- /dev/null
+++ b/contrib/views/storm/src/main/resources/view.log4j.properties
@@ -0,0 +1,9 @@
+log4j.appender.stormView=org.apache.log4j.RollingFileAppender
+log4j.appender.stormView.File=/var/log/ambari-server/storm-view.log
+log4j.appender.stormView.MaxFileSize=80MB
+log4j.appender.stormView.MaxBackupIndex=60
+log4j.appender.stormView.layout=org.apache.log4j.PatternLayout
+log4j.appender.stormView.layout.ConversionPattern=%d{DATE} %5p [%t] %c{1}:%L - %m%n
+
+log4j.logger.org.apache.ambari.storm=DEBUG,stormView
+log4j.additivity.org.apache.ambari.storm=false
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/c663f793/contrib/views/tez/pom.xml
----------------------------------------------------------------------
diff --git a/contrib/views/tez/pom.xml b/contrib/views/tez/pom.xml
index 8e82c5e..2daf7cc 100644
--- a/contrib/views/tez/pom.xml
+++ b/contrib/views/tez/pom.xml
@@ -145,6 +145,7 @@
           <include>WEB-INF/web.xml</include>
           <include>META-INF/**/*</include>
           <include>view.xml</include>
+          <include>view.log4j.properties</include>
         </includes>
       </resource>
       <resource>

http://git-wip-us.apache.org/repos/asf/ambari/blob/c663f793/contrib/views/tez/src/main/resources/view.log4j.properties
----------------------------------------------------------------------
diff --git a/contrib/views/tez/src/main/resources/view.log4j.properties b/contrib/views/tez/src/main/resources/view.log4j.properties
new file mode 100644
index 0000000..c7cf0be
--- /dev/null
+++ b/contrib/views/tez/src/main/resources/view.log4j.properties
@@ -0,0 +1,9 @@
+log4j.appender.tezView=org.apache.log4j.RollingFileAppender
+log4j.appender.tezView.File=/var/log/ambari-server/tez-view.log
+log4j.appender.tezView.MaxFileSize=80MB
+log4j.appender.tezView.MaxBackupIndex=60
+log4j.appender.tezView.layout=org.apache.log4j.PatternLayout
+log4j.appender.tezView.layout.ConversionPattern=%d{DATE} %5p [%t] %c{1}:%L - %m%n
+
+log4j.logger.org.apache.ambari.view.tez=DEBUG,tezView
+log4j.additivity.org.apache.ambari.view.tez=false
\ No newline at end of file