chukwa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From asrab...@apache.org
Subject svn commit: r759838 - in /hadoop/chukwa/trunk: CHANGES.txt src/java/org/apache/hadoop/chukwa/inputtools/log4j/ChukwaDailyRollingFileAppender.java
Date Mon, 30 Mar 2009 04:32:42 GMT
Author: asrabkin
Date: Mon Mar 30 04:32:41 2009
New Revision: 759838

URL: http://svn.apache.org/viewvc?rev=759838&view=rev
Log:
CHUKWA-43.  ChukwaLog4jAppender should send the current file offset instead of sending 0.
 Contributed by Jerome Boulon.

Modified:
    hadoop/chukwa/trunk/CHANGES.txt
    hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/inputtools/log4j/ChukwaDailyRollingFileAppender.java

Modified: hadoop/chukwa/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/CHANGES.txt?rev=759838&r1=759837&r2=759838&view=diff
==============================================================================
--- hadoop/chukwa/trunk/CHANGES.txt (original)
+++ hadoop/chukwa/trunk/CHANGES.txt Mon Mar 30 04:32:41 2009
@@ -35,6 +35,8 @@
 
   BUG FIXES
 
+    CHUKWA-43.  ChukwaLog4jAppender should send the current file offset instead of sending
0.  (Jerome Boulon via asrabkin)
+
     CHUKWA-41.  ChukwaLog4jAppender does not escape \n for exception.  (Jerome Boulon via
asrabkin)
 
     CHUKWA-28.  Late initalization of log4j adaptor.  (Jerome Boulon via asrabkin)

Modified: hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/inputtools/log4j/ChukwaDailyRollingFileAppender.java
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/inputtools/log4j/ChukwaDailyRollingFileAppender.java?rev=759838&r1=759837&r2=759838&view=diff
==============================================================================
--- hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/inputtools/log4j/ChukwaDailyRollingFileAppender.java
(original)
+++ hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/inputtools/log4j/ChukwaDailyRollingFileAppender.java
Mon Mar 30 04:32:41 2009
@@ -21,6 +21,7 @@
 import java.util.Locale;
 import java.util.TimeZone;
 import java.util.regex.Pattern;
+
 import org.apache.hadoop.chukwa.datacollection.controller.ChukwaAgentController;
 import org.apache.hadoop.chukwa.util.RecordConstants;
 import org.apache.log4j.FileAppender;
@@ -520,6 +521,20 @@
       // and use the boolean to avoid the first level locking
       if (chukwaClientIsNull) {
         synchronized (chukwaLock) {
+
+          String log4jFileName = getFile(); 
+          String recordType = getRecordType();
+
+          long currentLength = 0L;
+          try {
+            File fooLog = new File(log4jFileName);
+            log4jFileName = fooLog.getAbsolutePath();
+            currentLength = fooLog.length();
+          } catch (Throwable e) {
+            log.warn("Exception while trying to get current file size for " + log4jFileName);
+            currentLength = 0L;
+          }
+
           if (chukwaClient == null) {
             if (getChukwaClientHostname() != null
                 && getChukwaClientPortNum() != 0) {
@@ -531,7 +546,7 @@
             } else {
               chukwaClient = new ChukwaAgentController();
               log
-                  .debug("setup adaptor with no args, which means it used its defaults");
+              .debug("setup adaptor with no args, which means it used its defaults");
             }
 
             chukwaClientIsNull = false;
@@ -556,9 +571,10 @@
             if (numRetries == 0) {
               numRetries = 48;
             }
-            String log4jFileName = getFile();
-            String recordType = getRecordType();
-            long adaptorID = chukwaClient.addFile(recordType, log4jFileName,
+
+
+            long adaptorID = chukwaClient.add(ChukwaAgentController.CharFileTailUTF8NewLineEscaped,
+                recordType,currentLength + " " + log4jFileName, currentLength,
                 numRetries, retryInterval);
 
             // Setup a shutdownHook for the controller
@@ -568,10 +584,13 @@
 
             if (adaptorID > 0) {
               log.debug("Added file tailing adaptor to chukwa agent for file "
-                  + log4jFileName + "using this recordType :" + recordType);
+                  + log4jFileName + ", adaptorId:" + adaptorID 
+                  + " using this recordType :" + recordType 
+                  + ", starting at offset:" + currentLength);
             } else {
               log.debug("Chukwa adaptor not added, addFile(" + log4jFileName
-                  + ") returned " + adaptorID);
+                  + ") returned " + adaptorID 
+                  + ", current offset:" + currentLength);
             }
 
           }



Mime
View raw message