chukwa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From asrab...@apache.org
Subject svn commit: r895473 - in /hadoop/chukwa/trunk/src: java/org/apache/hadoop/chukwa/datacollection/adaptor/ java/org/apache/hadoop/chukwa/datacollection/adaptor/filetailer/ java/org/apache/hadoop/chukwa/datacollection/agent/ test/org/apache/hadoop/chukwa/...
Date Sun, 03 Jan 2010 20:34:04 GMT
Author: asrabkin
Date: Sun Jan  3 20:34:04 2010
New Revision: 895473

URL: http://svn.apache.org/viewvc?rev=895473&view=rev
Log:
CHUKWA-420. More refactoring

Modified:
    hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/datacollection/adaptor/AbstractAdaptor.java
    hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/datacollection/adaptor/AdaptorShutdownPolicy.java
    hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/datacollection/adaptor/ExecAdaptor.java
    hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/datacollection/adaptor/FileAdaptor.java
    hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/datacollection/adaptor/filetailer/FileTailingAdaptor.java
    hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/datacollection/adaptor/filetailer/LWFTAdaptor.java
    hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/datacollection/adaptor/filetailer/RCheckFTAdaptor.java
    hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/datacollection/agent/AdaptorManager.java
    hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/datacollection/agent/AgentControlSocketListener.java
    hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/datacollection/agent/ChukwaAgent.java
    hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/datacollection/adaptor/TestExecAdaptor.java

Modified: hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/datacollection/adaptor/AbstractAdaptor.java
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/datacollection/adaptor/AbstractAdaptor.java?rev=895473&r1=895472&r2=895473&view=diff
==============================================================================
--- hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/datacollection/adaptor/AbstractAdaptor.java
(original)
+++ hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/datacollection/adaptor/AbstractAdaptor.java
Sun Jan  3 20:34:04 2010
@@ -45,8 +45,8 @@
   public abstract void start(long offset) throws AdaptorException;
   public abstract String parseArgs(String s);
 
-  public void deregisterAndStop(boolean gracefully) {
-    control.stopAdaptor(adaptorID, gracefully);
+  public void deregisterAndStop() {
+    control.stopAdaptor(adaptorID, AdaptorShutdownPolicy.HARD_STOP);
   }
   
   public String parseArgs(String d, String s, AdaptorManager c) {

Modified: hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/datacollection/adaptor/AdaptorShutdownPolicy.java
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/datacollection/adaptor/AdaptorShutdownPolicy.java?rev=895473&r1=895472&r2=895473&view=diff
==============================================================================
--- hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/datacollection/adaptor/AdaptorShutdownPolicy.java
(original)
+++ hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/datacollection/adaptor/AdaptorShutdownPolicy.java
Sun Jan  3 20:34:04 2010
@@ -19,4 +19,15 @@
 
 public enum AdaptorShutdownPolicy {
   HARD_STOP,GRACEFULLY,WAIT_TILL_FINISHED;
+  
+  public String toString() {
+    if(this.equals(GRACEFULLY))
+      return "Gracefully";
+    else if(this.equals(HARD_STOP))
+      return "Abruptly";
+    else if(this.equals(WAIT_TILL_FINISHED))
+      return "Once finished";
+    else
+        return "unknown mode";
+  }
 }

Modified: hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/datacollection/adaptor/ExecAdaptor.java
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/datacollection/adaptor/ExecAdaptor.java?rev=895473&r1=895472&r2=895473&view=diff
==============================================================================
--- hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/datacollection/adaptor/ExecAdaptor.java
(original)
+++ hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/datacollection/adaptor/ExecAdaptor.java
Sun Jan  3 20:34:04 2010
@@ -67,7 +67,7 @@
       try {
 
         if (o.getInt("status") == exec.statusKO) {
-          deregisterAndStop(false);
+          deregisterAndStop();
           return;
         }
 

Modified: hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/datacollection/adaptor/FileAdaptor.java
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/datacollection/adaptor/FileAdaptor.java?rev=895473&r1=895472&r2=895473&view=diff
==============================================================================
--- hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/datacollection/adaptor/FileAdaptor.java
(original)
+++ hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/datacollection/adaptor/FileAdaptor.java
Sun Jan  3 20:34:04 2010
@@ -172,7 +172,7 @@
          int bytesUsed = extractRecords(dest, 0, buf, fileTime);
          this.fileReadOffset = bytesUsed;
          finished = true;
-         deregisterAndStop(false);
+         deregisterAndStop();
          cleanUp();
        } catch(Exception e) {
          log.warn("Exception while trying to read: " + toWatch.getAbsolutePath(),e);
@@ -191,7 +191,7 @@
       if (now > timeOut) {
         finished = true;
         log.warn("Couldn't read this file: " + toWatch.getAbsolutePath());
-        deregisterAndStop(false);
+        deregisterAndStop();
         cleanUp() ;
       }
     }

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=895473&r1=895472&r2=895473&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
Sun Jan  3 20:34:04 2010
@@ -148,7 +148,7 @@
           return false;
         }
 
-        deregisterAndStop(false);
+        deregisterAndStop();
         return false;
       } else if (!toWatch.exists() || !toWatch.canRead()) {
         if (adaptorInError == false) {

Modified: hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/datacollection/adaptor/filetailer/LWFTAdaptor.java
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/datacollection/adaptor/filetailer/LWFTAdaptor.java?rev=895473&r1=895472&r2=895473&view=diff
==============================================================================
--- hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/datacollection/adaptor/filetailer/LWFTAdaptor.java
(original)
+++ hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/datacollection/adaptor/filetailer/LWFTAdaptor.java
Sun Jan  3 20:34:04 2010
@@ -215,7 +215,7 @@
       }
     } catch(IOException e) {
       log.warn("IOException in tailer", e);
-      deregisterAndStop(false);
+      deregisterAndStop();
     }
     
     return hasMoreData;

Modified: hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/datacollection/adaptor/filetailer/RCheckFTAdaptor.java
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/datacollection/adaptor/filetailer/RCheckFTAdaptor.java?rev=895473&r1=895472&r2=895473&view=diff
==============================================================================
--- hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/datacollection/adaptor/filetailer/RCheckFTAdaptor.java
(original)
+++ hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/datacollection/adaptor/filetailer/RCheckFTAdaptor.java
Sun Jan  3 20:34:04 2010
@@ -177,7 +177,7 @@
         
     } catch(IOException e) {
       log.warn("IOException in "+adaptorID, e);
-      deregisterAndStop(false);
+      deregisterAndStop();
     }
     
     return hasMoreData;

Modified: hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/datacollection/agent/AdaptorManager.java
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/datacollection/agent/AdaptorManager.java?rev=895473&r1=895472&r2=895473&view=diff
==============================================================================
--- hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/datacollection/agent/AdaptorManager.java
(original)
+++ hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/datacollection/agent/AdaptorManager.java
Sun Jan  3 20:34:04 2010
@@ -21,6 +21,7 @@
 import java.util.Map;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.chukwa.datacollection.adaptor.Adaptor;
+import org.apache.hadoop.chukwa.datacollection.adaptor.AdaptorShutdownPolicy;
 
 /**
  * The interface to the agent that is exposed to adaptors.
@@ -31,7 +32,11 @@
 
   Configuration getConfiguration();
   int adaptorCount();
+  @Deprecated
   long stopAdaptor(String id, boolean gracefully);
+  
+
+  long stopAdaptor(String id, AdaptorShutdownPolicy mode);
   Adaptor getAdaptor(String id);
   String processAddCommand(String cmd);
   Map<String, String> getAdaptorList();
@@ -76,10 +81,14 @@
       return "";
     }
 
-    @Override
     public long stopAdaptor(String id, boolean gracefully) {
       return 0;
     }
+
+    @Override
+    public long stopAdaptor(String id, AdaptorShutdownPolicy mode) {
+      return 0;
+    }
     
     @Override
     public String reportCommit(Adaptor a, long l) {

Modified: hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/datacollection/agent/AgentControlSocketListener.java
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/datacollection/agent/AgentControlSocketListener.java?rev=895473&r1=895472&r2=895473&view=diff
==============================================================================
--- hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/datacollection/agent/AgentControlSocketListener.java
(original)
+++ hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/datacollection/agent/AgentControlSocketListener.java
Sun Jan  3 20:34:04 2010
@@ -29,6 +29,7 @@
 import java.util.Map;
 import org.apache.hadoop.chukwa.datacollection.adaptor.Adaptor;
 import org.apache.hadoop.chukwa.datacollection.adaptor.AdaptorException;
+import org.apache.hadoop.chukwa.datacollection.adaptor.AdaptorShutdownPolicy;
 import org.apache.log4j.Logger;
 
 /**
@@ -130,7 +131,7 @@
           out.println("need to specify an adaptor to shut down, by number");
         } else {
           sanitizeAdaptorName(out, words);
-          long offset = agent.stopAdaptor(words[1], true);
+          long offset = agent.stopAdaptor(words[1], AdaptorShutdownPolicy.GRACEFULLY);
           if (offset != -1)
             out.println("OK adaptor " + words[1] + " stopping gracefully at "
                 + offset);
@@ -142,7 +143,7 @@
           out.println("need to specify an adaptor to shut down, by number");
         } else {
           sanitizeAdaptorName(out, words);
-          agent.stopAdaptor(words[1], false);
+          agent.stopAdaptor(words[1], AdaptorShutdownPolicy.HARD_STOP);
           out.println("OK adaptor " + words[1] + " stopped");
         }
       } else if (words[0].equalsIgnoreCase("reloadCollectors")) {

Modified: hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/datacollection/agent/ChukwaAgent.java
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/datacollection/agent/ChukwaAgent.java?rev=895473&r1=895472&r2=895473&view=diff
==============================================================================
--- hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/datacollection/agent/ChukwaAgent.java
(original)
+++ hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/datacollection/agent/ChukwaAgent.java
Sun Jan  3 20:34:04 2010
@@ -522,6 +522,14 @@
     }
     return adaptors;
   }
+  
+
+  public long stopAdaptor(String name, boolean gracefully) {
+    if (gracefully) 
+      return stopAdaptor(name, AdaptorShutdownPolicy.GRACEFULLY);
+    else
+      return stopAdaptor(name, AdaptorShutdownPolicy.HARD_STOP);
+  }
 
   /**
    * Stop the adaptor with given ID number. Takes a parameter to indicate
@@ -535,7 +543,7 @@
    * @param gracefully if true, shutdown, if false, hardStop
    * @return the number of bytes synched at stop. -1 on error
    */
-  public long stopAdaptor(String name, boolean gracefully) {
+  public long stopAdaptor(String name, AdaptorShutdownPolicy shutdownMode) {
     Adaptor toStop;
     long offset = -1;
 
@@ -546,7 +554,7 @@
       toStop = adaptorsByName.remove(name);
     }
     if (toStop == null) {
-      log.warn("trying to stop adaptor " + name + " that isn't running");
+      log.warn("trying to stop " + name + " that isn't running");
       return offset;
     } else {
       adaptorPositions.remove(toStop);
@@ -555,15 +563,9 @@
     ChukwaAgent.agentMetrics.removedAdaptor.inc();
     
     try {
-      if (gracefully) {
-        offset = toStop.shutdown(AdaptorShutdownPolicy.GRACEFULLY);
-        log.info("shutdown on adaptor: " + name + ", "
-            + toStop.getCurrentStatus());
-      } else {
-        toStop.shutdown(AdaptorShutdownPolicy.HARD_STOP);
-        log.info("hardStop on adaptorId: " + name + ", "
-            + toStop.getCurrentStatus());
-      }
+      offset = toStop.shutdown(shutdownMode);
+      log.info("shutdown ["+ shutdownMode + "] on " + name + ", "
+          + toStop.getCurrentStatus());
     } catch (AdaptorException e) {
       log.error("adaptor failed to stop cleanly", e);
     } finally {

Modified: hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/datacollection/adaptor/TestExecAdaptor.java
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/datacollection/adaptor/TestExecAdaptor.java?rev=895473&r1=895472&r2=895473&view=diff
==============================================================================
--- hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/datacollection/adaptor/TestExecAdaptor.java
(original)
+++ hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/datacollection/adaptor/TestExecAdaptor.java
Sun Jan  3 20:34:04 2010
@@ -51,7 +51,7 @@
    */
   public void testForLeaks()  throws ChukwaAgent.AlreadyRunningException, InterruptedException
{
     Configuration conf = new Configuration();
-//    conf.set("chukwaAgent.control.port", "0");
+    conf.set("chukwaAgent.control.port", "0");
     conf.setBoolean("chukwaAgent.checkpoint.enabled", false);
     ChukwaAgent agent = new ChukwaAgent(conf);
 



Mime
View raw message