chukwa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From asrab...@apache.org
Subject svn commit: r901414 - in /hadoop/chukwa/trunk: ./ src/java/org/apache/hadoop/chukwa/datacollection/adaptor/ src/java/org/apache/hadoop/chukwa/datacollection/agent/ src/java/org/apache/hadoop/chukwa/inputtools/plugin/
Date Wed, 20 Jan 2010 22:47:00 GMT
Author: asrabkin
Date: Wed Jan 20 22:47:00 2010
New Revision: 901414

URL: http://svn.apache.org/viewvc?rev=901414&view=rev
Log:
CHUKWA-359. Report detailed error on adaptor start failure.

Modified:
    hadoop/chukwa/trunk/CHANGES.txt
    hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/datacollection/adaptor/ExecAdaptor.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/java/org/apache/hadoop/chukwa/inputtools/plugin/ExecPlugin.java

Modified: hadoop/chukwa/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/CHANGES.txt?rev=901414&r1=901413&r2=901414&view=diff
==============================================================================
--- hadoop/chukwa/trunk/CHANGES.txt (original)
+++ hadoop/chukwa/trunk/CHANGES.txt Wed Jan 20 22:47:00 2010
@@ -24,6 +24,8 @@
  
    IMPROVEMENTS
 
+    CHUKWA-359. Report detailed error on adaptor start failure. (asrabkin)
+
     CHUKWA-420. Clean up adaptor stop methods. (asrabkin)
 
     CHUKWA-437. Clean up widget category labels. (Eric Yang)

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=901414&r1=901413&r2=901414&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
Wed Jan 20 22:47:00 2010
@@ -41,6 +41,8 @@
  */
 public class ExecAdaptor extends AbstractAdaptor {
   
+  public static final boolean FULL_PATHS = false;
+  
   static class EmbeddedExec extends ExecPlugin {
 
     String cmd;
@@ -154,10 +156,9 @@
 
   @Override
   public void start(long offset) throws AdaptorException {
-
-
+    if(FULL_PATHS && !(new java.io.File(cmd)).exists())
+      throw new AdaptorException("Can't start ExecAdaptor. No command " + cmd);
     this.sendOffset = offset;
-
     this.exec = new EmbeddedExec(cmd);
     TimerTask execTimer = new RunToolTask();
     timer.schedule(execTimer, 0L, period);

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=901414&r1=901413&r2=901414&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
Wed Jan 20 22:47:00 2010
@@ -49,7 +49,7 @@
   protected int portno;
   protected ServerSocket s = null;
   volatile boolean closing = false;
-  static final String VERSION = "0.2.0-dev";
+  static final String VERSION = "0.4.0-dev";
   public boolean ALLOW_REMOTE = true;
   public static final String REMOTE_ACCESS_OPT = "chukwaAgent.control.remote";
 
@@ -121,11 +121,15 @@
       } else if (words[0].equalsIgnoreCase("close")) {
         connection.close();
       } else if (words[0].equalsIgnoreCase("add")) {
-        String newID = agent.processAddCommand(cmd);
-        if (newID != null)
-          out.println("OK add completed; new ID is " + newID);
-        else
-          out.println("failed to start adaptor...check logs for details");
+        try {
+          String newID = agent.processAddCommandE(cmd);
+          if (newID != null)
+            out.println("OK add completed; new ID is " + newID);
+          else
+            out.println("failed to start adaptor...check logs for details");
+        } catch(AdaptorException e) {
+          out.println(e);
+        }
       } else if (words[0].equalsIgnoreCase("shutdown")) {
         if (words.length < 2) {
           out.println("need to specify an adaptor to shut down, by number");

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=901414&r1=901413&r2=901414&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
Wed Jan 20 22:47:00 2010
@@ -307,6 +307,15 @@
    * 
    */
   public String processAddCommand(String cmd) {
+    try {
+      return processAddCommandE(cmd);
+    } catch(AdaptorException e) {
+      return null;
+    }
+  }
+  
+
+  public String processAddCommandE(String cmd) throws AdaptorException {
     Matcher m = addCmdPattern.matcher(cmd);
     if (m.matches()) {
       long offset; // check for obvious errors first
@@ -314,10 +323,9 @@
         offset = Long.parseLong(m.group(5));
       } catch (NumberFormatException e) {
         log.warn("malformed line " + cmd);
-        return null;
+        throw new AdaptorException("bad input syntax");
       }
 
-       
       String adaptorID = m.group(1);
       String adaptorClassName = m.group(2);
       String dataType = m.group(3);
@@ -328,12 +336,12 @@
       Adaptor adaptor = AdaptorFactory.createAdaptor(adaptorClassName);
       if (adaptor == null) {
         log.warn("Error creating adaptor of class " + adaptorClassName);
-        return null;
+        throw new AdaptorException("Can't load class " + adaptorClassName);
       }
       String coreParams = adaptor.parseArgs(dataType,params,this);
       if(coreParams == null) {
-        log.warn("invalid params for adaptor: " + params);
-        return null;
+        log.warn("invalid params for adaptor: " + params);       
+        throw new AdaptorException("invalid params for adaptor: " + params);
       }
       
       if(adaptorID == null) { //user didn't specify, so synthesize
@@ -362,8 +370,11 @@
           return adaptorID;
 
         } catch (Exception e) {
+          Adaptor failed = adaptorsByName.remove(adaptorID);
+          adaptorPositions.remove(failed);
           log.warn("failed to start adaptor", e);
-          // FIXME: don't we need to clean up the adaptor maps here?
+          if(e instanceof AdaptorException)
+            throw (AdaptorException)e;
         }
       }
     } else if (cmd.length() > 0)

Modified: hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/inputtools/plugin/ExecPlugin.java
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/inputtools/plugin/ExecPlugin.java?rev=901414&r1=901413&r2=901414&view=diff
==============================================================================
--- hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/inputtools/plugin/ExecPlugin.java
(original)
+++ hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/inputtools/plugin/ExecPlugin.java
Wed Jan 20 22:47:00 2010
@@ -36,14 +36,15 @@
   public final int statusOK = 100;
   public final int statusKO = -100;
 
-  Process process;
+  Process process = null;
 
   public ExecPlugin() {
 
   }
 
   public void stop() {
-    process.destroy();
+    if(process != null)
+      process.destroy();
   }
 
   public int waitFor() throws InterruptedException {



Mime
View raw message