chukwa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From asrab...@apache.org
Subject svn commit: r832432 - in /hadoop/chukwa/trunk: CHANGES.txt src/java/org/apache/hadoop/chukwa/datacollection/agent/AgentControlSocketListener.java src/test/org/apache/hadoop/chukwa/datacollection/agent/TestCmd.java
Date Tue, 03 Nov 2009 14:36:07 GMT
Author: asrabkin
Date: Tue Nov  3 14:36:07 2009
New Revision: 832432

URL: http://svn.apache.org/viewvc?rev=832432&view=rev
Log:
CHUKWA-405. Add a stopall command

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

Modified: hadoop/chukwa/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/CHANGES.txt?rev=832432&r1=832431&r2=832432&view=diff
==============================================================================
--- hadoop/chukwa/trunk/CHANGES.txt (original)
+++ hadoop/chukwa/trunk/CHANGES.txt Tue Nov  3 14:36:07 2009
@@ -4,9 +4,11 @@
 
   NEW FEATURES
 
-  IMPROVEMENTS
+    CHUKWA-405  Add a "stop all" command. (asrabkin)
+ 
+   IMPROVEMENTS
 
-    CHUKWA-407. Make SocketTeeWriter work in single-stage pipeline. (Thushara Wijeratna via
asrabkin)
+    CHUKWA-409. Make SocketTeeWriter work in single-stage pipeline. (Thushara Wijeratna via
asrabkin)
 
     CHUKWA-408. Add optional metadata to real-time feed. (asrabkin)
 

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=832432&r1=832431&r2=832432&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 Nov  3 14:36:07 2009
@@ -115,6 +115,7 @@
         out.println("list -- list running adaptors");
         out.println("close -- close this connection");
         out.println("stopagent -- stop the whole agent process");
+        out.println("stopall -- stop all adaptors");
         out.println("reloadCollectors -- reload the list of collectors");
         out.println("help -- print this message");
         out.println("\t Command names are case-blind.");
@@ -166,11 +167,18 @@
         out.println("stopping agent process.");
         connection.close();
         agent.shutdown(true);
+      } else if(words[0].equalsIgnoreCase("stopall")) {
+        int stopped = 0;
+        for(String id: agent.getAdaptorList().keySet()) {
+          agent.stopAdaptor(id, false);
+          stopped++;
+         }
+        out.println("stopped " + stopped + " adaptors");
       } else if (words[0].equals("")) {
         out.println(getStatusLine());
       } else {
         log.warn("unknown command " + words[0]);
-        out.println("unknown command" + words[0]);
+        out.println("unknown command " + words[0]);
         out.println("say 'help' for a list of legal commands");
       }
       out.flush();

Modified: hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/datacollection/agent/TestCmd.java
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/datacollection/agent/TestCmd.java?rev=832432&r1=832431&r2=832432&view=diff
==============================================================================
--- hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/datacollection/agent/TestCmd.java
(original)
+++ hadoop/chukwa/trunk/src/test/org/apache/hadoop/chukwa/datacollection/agent/TestCmd.java
Tue Nov  3 14:36:07 2009
@@ -22,9 +22,12 @@
 import org.apache.hadoop.chukwa.datacollection.adaptor.Adaptor;
 import org.apache.hadoop.chukwa.datacollection.adaptor.ChukwaTestAdaptor;
 import org.apache.hadoop.chukwa.datacollection.agent.ChukwaAgent.AlreadyRunningException;
+import org.apache.hadoop.chukwa.datacollection.connector.ChunkCatcherConnector;
 import org.apache.hadoop.chukwa.datacollection.test.ConsoleOutConnector;
 import org.apache.hadoop.conf.Configuration;
 import junit.framework.TestCase;
+import java.net.*;
+import java.io.*;
 
 public class TestCmd extends TestCase {
 
@@ -122,4 +125,29 @@
       fail(e.toString());
     }
   }
+  
+  public void testStopAll() throws Exception{
+    Configuration conf = new Configuration();
+    conf.set("chukwaAgent.control.port", "0");
+    ChukwaAgent agent = new ChukwaAgent(conf);
+    ChunkCatcherConnector chunks = new ChunkCatcherConnector();
+    chunks.start();
+    agent.processAddCommand(
+        "ADD adaptor1 = org.apache.hadoop.chukwa.datacollection.adaptor.ChukwaTestAdaptor"
+        + "  chukwaTestAdaptorType 0");
+
+    agent.processAddCommand(
+    "ADD adaptor2 = org.apache.hadoop.chukwa.datacollection.adaptor.ChukwaTestAdaptor"
+    + "  chukwaTestAdaptorType 0");
+    assertEquals(2, agent.adaptorCount());
+
+    Socket s = new Socket("localhost", agent.getControllerPort());
+    PrintWriter bw = new PrintWriter(new OutputStreamWriter(s.getOutputStream()));
+    bw.println("stopAll");
+    bw.flush();
+    InputStreamReader in = new InputStreamReader(s.getInputStream());
+    in.read();
+    assertEquals(0, agent.adaptorCount());
+    agent.shutdown();
+  }
 }



Mime
View raw message