Package org.apache.hadoop.chukwa.datacollection.agent

Examples of org.apache.hadoop.chukwa.datacollection.agent.ChukwaAgent$StatsCollectorTask


  }
 
  public void testMultiStopAndStart() {

    try {
      ChukwaAgent agent = new ChukwaAgent();
      ConsoleOutConnector conn = new ConsoleOutConnector(agent, true);
      conn.start();
     
      for(int trial=0; trial < 20; ++trial) {
        ArrayList<Long> runningAdaptors = new ArrayList<Long>();
      
        for(int i = 1; i < 7; ++i) {
          long l = agent.processCommand("add org.apache.hadoop.chukwa.util.ConstRateAdaptor raw"+i+ " 20000 0");
          assertTrue(agent.adaptorCount() == i);
          assertTrue(l != -1);
          runningAdaptors.add(l);
        }
        Thread.sleep(1000);  
        for(Long l: runningAdaptors)
          agent.stopAdaptor(l, true);
        assertTrue(agent.adaptorCount() == 0);
      }
      agent.shutdown();
    } catch(Exception e) {
      e.printStackTrace();
      fail(e.toString());
    }
  }
View Full Code Here


public class TestChukwaAppender extends TestCase {
 
  public void testChukwaAppender() {
    try {
   
    ChukwaAgent agent = new ChukwaAgent();
    ChunkCatcherConnector chunks = new ChunkCatcherConnector();
    chunks.start();
    Logger myLogger = Logger.getLogger(TestChukwaAppender.class);
    File out = new File("/tmp/chukwa_test_out");
    out.delete();
    ChukwaDailyRollingFileAppender app = new ChukwaDailyRollingFileAppender(
        new SimpleLayout(), out.getAbsolutePath(), "yyyy-MM-dd");
    app.append(new LoggingEvent("foo", myLogger,  System.currentTimeMillis(),Priority.INFO, "foo", null));
    assertEquals(1, agent.adaptorCount());
    Chunk c = chunks.waitForAChunk();
    System.out.println("read a chunk OK");
    String logLine = new String(c.getData());
    assertTrue(logLine.equals("INFO - foo\n"));
    System.out.println(new String(c.getData()));
View Full Code Here

  Connector httpConnector;
  //consoleConnector = new ConsoleOutConnector(agent);
 
  protected void setUp() throws ChukwaAgent.AlreadyRunningException {
    config = new ChukwaConfiguration();
    agent = new ChukwaAgent();
    c = new ChukwaAgentController();
    httpConnector = new HttpConnector(agent); //use default source for list of collectors (i.e. conf/connectors)

    httpConnector.start();
View Full Code Here

public class TestFailedCollector extends TestCase {
 
  public void testFailedCollector()
  {
    try {
      ChukwaAgent agent = new ChukwaAgent();
      boolean failed=false;
      HttpConnector connector = new HttpConnector(agent, "http://localhost:1234/chukwa");
      connector.start();
     
      ChukwaConfiguration cc = new ChukwaConfiguration();
      int portno = cc.getInt("chukwaAgent.control.port", 9093);
      ChukwaAgentController cli = new ChukwaAgentController("localhost", portno);
     
      File tmpOutput = TempFileUtil.makeBinary(2000);
     
      cli.addFile("unknown", tmpOutput.getAbsolutePath());
      System.out.println("have " + agent.adaptorCount() + " running adaptors");
      cli.removeFile("unknown", tmpOutput.getAbsolutePath());
   
     
      tmpOutput.delete();
      assertFalse(failed);
      System.out.println("done");
      agent.shutdown();
      connector.shutdown();
    } catch(Exception e) {
      e.printStackTrace();
    }
  }
View Full Code Here

    chunks.start();
  }
 
  public void testWithPs() throws ChukwaAgent.AlreadyRunningException {
    try {
      ChukwaAgent  agent = new ChukwaAgent();
      agent.processCommand("add org.apache.hadoop.chukwa.datacollection.adaptor.ExecAdaptor ps ps aux 0");
 
      Chunk c = chunks.waitForAChunk();
      System.out.println(new String(c.getData()));
    } catch(InterruptedException e) {
     
View Full Code Here

      root.addServlet(new ServletHolder(new ServletCollector()), "/*");
      server.start();
      server.setStopAtShutdown(false);
 
      Thread.sleep(1000);
      ChukwaAgent agent = new ChukwaAgent();
      HttpConnector connector = new HttpConnector(agent, "http://localhost:9990/chukwa");
      connector.start();
     
      ChukwaConfiguration cc = new ChukwaConfiguration();
      int portno = cc.getInt("chukwaAgent.control.port", 9093);
View Full Code Here

    chunks = new ChunkCatcherConnector();
    chunks.start();
  }
 
  public void testRawAdaptor() throws IOException, InterruptedException, ChukwaAgent.AlreadyRunningException {
    ChukwaAgent  agent = new ChukwaAgent();
   
    File testFile = makeTestFile("/tmp/chukwaTest");
    agent.processCommand("add org.apache.hadoop.chukwa.datacollection.adaptor.filetailer.FileTailingAdaptor" +
        " raw " + testFile + " 0");
    assertTrue(agent.adaptorCount() == 1);
    Chunk c = chunks.waitForAChunk();
    assertTrue(c.getDataType().equals("raw"));
    assertTrue(c.getRecordOffsets().length == 1);
    assertTrue(c.getSeqID() == testFile.length());    
    agent.shutdown();
  }
View Full Code Here

    agent.shutdown();
  }


  public void testCrSepAdaptor() throws IOException, InterruptedException, ChukwaAgent.AlreadyRunningException {
    ChukwaAgent  agent = new ChukwaAgent();
    File testFile = makeTestFile("/tmp/chukwaTest");
    agent.processCommand("add org.apache.hadoop.chukwa.datacollection.adaptor.filetailer.CharFileTailingAdaptorUTF8" +
        " lines " + testFile + " 0");
    assertTrue(agent.adaptorCount() == 1);
    System.out.println("getting a chunk...");
    Chunk c = chunks.waitForAChunk();
    System.out.println("got chunk");
    assertTrue(c.getSeqID() == testFile.length());   
   
    assertTrue(c.getRecordOffsets().length == 80);
    int recStart = 0;
    for(int rec = 0 ; rec < c.getRecordOffsets().length; ++rec) {
      String record = new String(c.getData(), recStart, c.getRecordOffsets()[rec] - recStart+1);
      System.out.println("record "+ rec+ " was: " + record);
      assertTrue(record.equals(rec + " abcdefghijklmnopqrstuvwxyz\n"));
      recStart = c.getRecordOffsets()[rec] +1;
    }
    assertTrue(c.getDataType().equals("lines"));   
    agent.shutdown();
  }
View Full Code Here

    chunks = new ChunkCatcherConnector();
    chunks.start();
  }
 
  public void testStartAtOffset() throws IOException, InterruptedException, ChukwaAgent.AlreadyRunningException {
    ChukwaAgent  agent = new ChukwaAgent();
    File testFile = makeTestFile();
    int startOffset = 50;
    agent.processCommand("add org.apache.hadoop.chukwa.datacollection.adaptor.filetailer.CharFileTailingAdaptorUTF8 " +
         "lines "+ startOffset+ " " + testFile + " " + startOffset);
    assertTrue(agent.adaptorCount() == 1);
    System.out.println("getting a chunk...");
    Chunk c = chunks.waitForAChunk();
    System.out.println("got chunk");
    assertTrue(c.getSeqID() == testFile.length() + startOffset);   
   
    assertTrue(c.getRecordOffsets().length == 80);//80 lines in test file
    int recStart = 0;
    for(int rec = 0 ; rec < c.getRecordOffsets().length; ++rec) {
      String record = new String(c.getData(), recStart, c.getRecordOffsets()[rec] - recStart+1);
      System.out.println("record "+ rec+ " was: " + record);
      assertTrue(record.equals(rec + " abcdefghijklmnopqrstuvwxyz\n"));
      recStart = c.getRecordOffsets()[rec] +1;
    }
    assertTrue(c.getDataType().equals("lines"));   
    agent.shutdown();
  }
View Full Code Here

    assertTrue(c.getDataType().equals("lines"));   
    agent.shutdown();
  }
 
  public void testStartAfterOffset() throws IOException, InterruptedException, ChukwaAgent.AlreadyRunningException {
    ChukwaAgent  agent = new ChukwaAgent();
    File testFile = makeTestFile();
    int startOffset = 50;
    agent.processCommand("add org.apache.hadoop.chukwa.datacollection.adaptor.filetailer.CharFileTailingAdaptorUTF8 " +
         "lines "+ startOffset+ " " + testFile + " " + (startOffset + 29) );
    assertTrue(agent.adaptorCount() == 1);
    System.out.println("getting a chunk...");
    Chunk c = chunks.waitForAChunk();
    System.out.println("got chunk");
    assertTrue(c.getSeqID() == testFile.length() + startOffset);   
   
    assertTrue(c.getRecordOffsets().length == 79);//80 lines in test file, minus the one we skipped
    int recStart = 0;
    for(int rec = 0 ; rec < c.getRecordOffsets().length; ++rec) {
      String record = new String(c.getData(), recStart, c.getRecordOffsets()[rec] - recStart+1);
      System.out.println("record "+ rec+ " was: " + record);
      assertTrue(record.equals((rec+1) + " abcdefghijklmnopqrstuvwxyz\n"));
      recStart = c.getRecordOffsets()[rec] +1;
    }
    assertTrue(c.getDataType().equals("lines"));   
    agent.shutdown();
  }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.chukwa.datacollection.agent.ChukwaAgent$StatsCollectorTask

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.