chukwa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From asrab...@apache.org
Subject svn commit: r781204 - in /hadoop/chukwa/trunk: CHANGES.txt src/java/org/apache/hadoop/chukwa/datacollection/agent/AgentControlSocketListener.java
Date Tue, 02 Jun 2009 23:02:57 GMT
Author: asrabkin
Date: Tue Jun  2 23:02:57 2009
New Revision: 781204

URL: http://svn.apache.org/viewvc?rev=781204&view=rev
Log:
CHUKWA-71. Status/version command for chukwa agent

Modified:
    hadoop/chukwa/trunk/CHANGES.txt
    hadoop/chukwa/trunk/src/java/org/apache/hadoop/chukwa/datacollection/agent/AgentControlSocketListener.java

Modified: hadoop/chukwa/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/CHANGES.txt?rev=781204&r1=781203&r2=781204&view=diff
==============================================================================
--- hadoop/chukwa/trunk/CHANGES.txt (original)
+++ hadoop/chukwa/trunk/CHANGES.txt Tue Jun  2 23:02:57 2009
@@ -4,6 +4,8 @@
 
   NEW FEATURES
 
+    CHUKWA-71. Status/version command for chukwa agent. (asrabkin)
+
     CHUKWA-271. Added SQL client to HICC for SQL data exploration. (Eric Yang)
 
     CHUKWA-210. Add new job conf metrics as database columns. (Cheng Zhang via Eric Yang)

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=781204&r1=781203&r2=781204&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
Tue Jun  2 23:02:57 2009
@@ -25,9 +25,11 @@
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.PrintStream;
+import java.net.InetAddress;
 import java.net.ServerSocket;
 import java.net.Socket;
 import java.net.SocketException;
+import java.net.UnknownHostException;
 import java.util.Map;
 import org.apache.hadoop.chukwa.datacollection.adaptor.Adaptor;
 import org.apache.hadoop.chukwa.datacollection.adaptor.AdaptorException;
@@ -50,6 +52,7 @@
   protected int portno;
   protected ServerSocket s = null;
   volatile boolean closing = false;
+  static final String VERSION = "0.2.0-dev";
 
   private class ListenThread extends Thread {
     Socket connection;
@@ -101,8 +104,7 @@
       }
 
       if (words[0].equalsIgnoreCase("help")) {
-        out
-            .println("you're talking to the Chukwa agent.  Commands available: ");
+        out.println("you're talking to the Chukwa agent.  Commands available: ");
         out.println("add [adaptorname] [args] [offset] -- start an adaptor");
         out.println("shutdown [adaptornumber]  -- graceful stop");
         out.println("stop [adaptornumber]  -- abrupt stop");
@@ -167,6 +169,8 @@
         out.println("stopping agent process.");
         connection.close();
         agent.shutdown(true);
+      } else if (words[0].equals("")) {
+        out.println(getStatusLine());
       } else {
         log.warn("unknown command " + words[0]);
         out.println("unknown command" + words[0]);
@@ -260,4 +264,21 @@
       return portno;
     }
   }
+  
+  //FIXME: we also do this in ChunkImpl; should really do it only once
+  //and make it visible everywhere?
+  private static String localHostAddr;
+  static {
+    try {
+      localHostAddr = InetAddress.getLocalHost().getHostName();
+    } catch (UnknownHostException e) {
+      localHostAddr = "localhost";
+    }
+  }
+  
+  public String getStatusLine() {
+    int adaptorCount = agent.adaptorCount();
+    
+    return localHostAddr + ": Chukwa Agent running, version " + VERSION + ", with " + adaptorCount
+ " adaptors";
+  }
 }



Mime
View raw message