chukwa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ey...@apache.org
Subject svn commit: r766189 - in /hadoop/chukwa: branches/chukwa-0.1/src/java/org/apache/hadoop/chukwa/datacollection/adaptor/filetailer/FileTailingAdaptor.java trunk/src/java/org/apache/hadoop/chukwa/datacollection/adaptor/filetailer/FileTailingAdaptor.java
Date Sat, 18 Apr 2009 00:51:01 GMT
Author: eyang
Date: Sat Apr 18 00:51:01 2009
New Revision: 766189

URL: http://svn.apache.org/viewvc?rev=766189&view=rev
Log:
CHUKWA-154. Handle adaptor exception, close file pointers on failure condition.  (Jerome Boulon
via Eric Yang)

Modified:
    hadoop/chukwa/branches/chukwa-0.1/src/java/org/apache/hadoop/chukwa/datacollection/adaptor/filetailer/FileTailingAdaptor.java
    hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/datacollection/adaptor/filetailer/FileTailingAdaptor.java

Modified: hadoop/chukwa/branches/chukwa-0.1/src/java/org/apache/hadoop/chukwa/datacollection/adaptor/filetailer/FileTailingAdaptor.java
URL: http://svn.apache.org/viewvc/hadoop/chukwa/branches/chukwa-0.1/src/java/org/apache/hadoop/chukwa/datacollection/adaptor/filetailer/FileTailingAdaptor.java?rev=766189&r1=766188&r2=766189&view=diff
==============================================================================
--- hadoop/chukwa/branches/chukwa-0.1/src/java/org/apache/hadoop/chukwa/datacollection/adaptor/filetailer/FileTailingAdaptor.java
(original)
+++ hadoop/chukwa/branches/chukwa-0.1/src/java/org/apache/hadoop/chukwa/datacollection/adaptor/filetailer/FileTailingAdaptor.java
Sat Apr 18 00:51:01 2009
@@ -135,8 +135,12 @@
   public void hardStop() throws AdaptorException {
     tailer.stopWatchingFile(this);
     try {
-    reader.close();
-    } catch(IOException e) {
+      if (reader != null) {
+        reader.close();
+      }
+      reader = null;
+    } catch(Throwable e) {
+      // do nothing
     }
   }
 
@@ -225,7 +229,10 @@
         len = reader.length();
         long newLength = newReader.length();
         if (newLength < len && fileReadOffset >= len) {
-          reader.close();
+          if (reader != null) {
+            reader.close();
+          }
+          
           reader = newReader;
           fileReadOffset = 0L;
           log.debug("Adaptor|" + adaptorID
@@ -233,8 +240,11 @@
               + toWatch.getAbsolutePath());
         } else {
           try {
-            newReader.close();
-          } catch (IOException e) {
+            if (newReader != null) {
+              newReader.close();
+            }
+            newReader =null;
+          } catch (Throwable e) {
             // do nothing.
           }
         }
@@ -316,7 +326,10 @@
 
       } else {
         // file has rotated and no detection
-        reader.close();
+        if (reader != null) {
+          reader.close();
+        }
+        
         reader = null;
         fileReadOffset = 0L;
         offsetOfFirstByte = 0L;

Modified: hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/datacollection/adaptor/filetailer/FileTailingAdaptor.java
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/datacollection/adaptor/filetailer/FileTailingAdaptor.java?rev=766189&r1=766188&r2=766189&view=diff
==============================================================================
--- hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/datacollection/adaptor/filetailer/FileTailingAdaptor.java
(original)
+++ hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/datacollection/adaptor/filetailer/FileTailingAdaptor.java
Sat Apr 18 00:51:01 2009
@@ -135,8 +135,12 @@
   public void hardStop() throws AdaptorException {
     tailer.stopWatchingFile(this);
     try {
-    reader.close();
-    } catch(IOException e) {
+      if (reader != null) {
+        reader.close();
+      }
+      reader = null;
+    } catch(Throwable e) {
+      // do nothing
     }
   }
 
@@ -225,7 +229,10 @@
         len = reader.length();
         long newLength = newReader.length();
         if (newLength < len && fileReadOffset >= len) {
-          reader.close();
+          if (reader != null) {
+            reader.close();
+          }
+          
           reader = newReader;
           fileReadOffset = 0L;
           log.debug("Adaptor|" + adaptorID
@@ -233,8 +240,11 @@
               + toWatch.getAbsolutePath());
         } else {
           try {
-            newReader.close();
-          } catch (IOException e) {
+            if (newReader != null) {
+              newReader.close();
+            }
+            newReader =null;
+          } catch (Throwable e) {
             // do nothing.
           }
         }
@@ -316,7 +326,10 @@
 
       } else {
         // file has rotated and no detection
-        reader.close();
+        if (reader != null) {
+          reader.close();
+        }
+        
         reader = null;
         fileReadOffset = 0L;
         offsetOfFirstByte = 0L;



Mime
View raw message