Package org.apache.hadoop.chukwa.datacollection.test

Examples of org.apache.hadoop.chukwa.datacollection.test.ConsoleOutConnector


      checkpointDir.mkdir();
      checkpointDir.deleteOnExit();
      conf.set("chukwaAgent.checkpoint.dir", checkpointDir.getAbsolutePath());

      ChukwaAgent agent = new ChukwaAgent(conf);
      ConsoleOutConnector conn = new ConsoleOutConnector(agent, true);
      conn.start();
      assertEquals(1, agent.adaptorCount());// check that we processed initial
                                            // adaptors
      assertNotNull(agent.getAdaptor("testAdaptor"));
      assertTrue(agent.getAdaptor("testAdaptor").getCurrentStatus().contains("foo"));

      System.out
          .println("---------------------done with first run, now stopping");
      agent.shutdown();
      Thread.sleep(2000);
      assertEquals(0, agent.adaptorCount());
      // at this point, there should be a checkpoint file with a tailer reading
      // foo.
      // we're going to rewrite initial adaptors to read bar; but after reboot
      // we should
      // still only be looking at foo.
      ps = new PrintStream(new FileOutputStream(initialAdaptors, false));// overwrite
      ps.println("add bar= org.apache.hadoop.chukwa.datacollection.adaptor.filetailer.CharFileTailingAdaptorUTF8  raw 0 "
              + bar.getAbsolutePath() + " 0  ");
      ps.close();

      System.out.println("---------------------restarting");
      agent = new ChukwaAgent(conf);
      conn = new ConsoleOutConnector(agent, true);
      conn.start();
      assertEquals(1, agent.adaptorCount());// check that we processed initial
                                            // adaptors
      assertNotNull(agent.getAdaptor("testAdaptor"));
      assertTrue(agent.getAdaptor("testAdaptor").getCurrentStatus().contains("foo"));
      agent.shutdown();
View Full Code Here


      }

      int uriArgNumber = 0;
      if (args.length > 0) {
        if (args[uriArgNumber].equals("local"))
          agent.connector = new ConsoleOutConnector(agent);
        else {
          if (!args[uriArgNumber].contains("://"))
            args[uriArgNumber] = "http://" + args[uriArgNumber];
          agent.connector = new HttpConnector(agent, args[uriArgNumber]);
        }
View Full Code Here

  public void testStopAndStart() {

    try {
      ChukwaAgent agent = new ChukwaAgent();
      ConsoleOutConnector conn = new ConsoleOutConnector(agent, true);
      conn.start();
     
      ChukwaConfiguration cc = new ChukwaConfiguration();
      int portno = cc.getInt("chukwaAgent.control.port", 9093);
      ChukwaAgentController cli = new ChukwaAgentController("localhost", portno);
     
      for(int i=1; i < 20; ++i) {
        cli.add("org.apache.hadoop.chukwa.util.ConstRateAdaptor", "raw" + i, "20000", 0);
        assertTrue(agent.adaptorCount() == 1);
        Thread.sleep(2000);  
        cli.removeAll();
        assertTrue(agent.adaptorCount() == 0);
      }
      agent.shutdown();
      conn.shutdown();
    } catch(Exception e) {
      e.printStackTrace();
      fail(e.toString());
    }
  }
View Full Code Here

 
  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) {
View Full Code Here

        if(args[0].equals("-restore")) {
          agent.DO_CHECKPOINT_RESTORE = true;
          uriArgNumber = 1;
        }
        if(args[uriArgNumber].equals("local"))
          connector = new ConsoleOutConnector(agent);
        else
        {
          if(!args[uriArgNumber].contains("://"))
            args[uriArgNumber] = "http://" + args[uriArgNumber];
          connector = new HttpConnector(agent, args[uriArgNumber]);
View Full Code Here

      checkpointDir.mkdir();
      checkpointDir.deleteOnExit();
      conf.set("chukwaAgent.checkpoint.dir", checkpointDir.getAbsolutePath());

      ChukwaAgent agent = new ChukwaAgent(conf);
      ConsoleOutConnector conn = new ConsoleOutConnector(agent, true);
      conn.start();
      assertEquals(1, agent.adaptorCount());// check that we processed initial
                                            // adaptors
      assertNotNull(agent.getAdaptor("testAdaptor"));
      assertTrue(agent.getAdaptor("testAdaptor").getCurrentStatus().contains("foo"));

      System.out
          .println("---------------------done with first run, now stopping");
      agent.shutdown();
      Thread.sleep(2000);
      assertEquals(0, agent.adaptorCount());
      // at this point, there should be a checkpoint file with a tailer reading
      // foo.
      // we're going to rewrite initial adaptors to read bar; but after reboot
      // we should
      // still only be looking at foo.
      ps = new PrintStream(new FileOutputStream(initialAdaptors, false));// overwrite
      ps.println("add bar= org.apache.hadoop.chukwa.datacollection.adaptor.filetailer.CharFileTailingAdaptorUTF8  raw 0 "
              + bar.getAbsolutePath() + " 0  ");
      ps.close();

      System.out.println("---------------------restarting");
      agent = new ChukwaAgent(conf);
      conn = new ConsoleOutConnector(agent, true);
      conn.start();
      assertEquals(1, agent.adaptorCount());// check that we processed initial
                                            // adaptors
      assertNotNull(agent.getAdaptor("testAdaptor"));
      assertTrue(agent.getAdaptor("testAdaptor").getCurrentStatus().contains("foo"));
      agent.shutdown();
View Full Code Here

  public void testAddCmdWithParam() {
    ChukwaAgent agent;
    try {
      agent = new ChukwaAgent();
      ConsoleOutConnector conn = new ConsoleOutConnector(agent, true);
      conn.start();
      long l = agent
          .processCommand("ADD org.apache.hadoop.chukwa.datacollection.adaptor.ChukwaTestAdaptor  chukwaTestAdaptorType 0 my param1 param2 /var/log/messages 114027");
      assertTrue(l != -1);
      Adaptor adaptor = agent.getAdaptorList().get(l);
      ChukwaTestAdaptor chukwaTestAdaptor = (ChukwaTestAdaptor) adaptor;
View Full Code Here

  public void testAddCmdWithoutParam1() {
    ChukwaAgent agent;
    try {
      agent = new ChukwaAgent();
      ConsoleOutConnector conn = new ConsoleOutConnector(agent, true);
      conn.start();
      long l = agent
          .processCommand("ADD org.apache.hadoop.chukwa.datacollection.adaptor.ChukwaTestAdaptor  chukwaTestAdaptorType 114027");
      assertTrue(l != -1);
      Adaptor adaptor = agent.getAdaptorList().get(l);
      ChukwaTestAdaptor chukwaTestAdaptor = (ChukwaTestAdaptor) adaptor;
View Full Code Here

  public void testAddCmdWithoutParam2() {
    ChukwaAgent agent;
    try {
      agent = new ChukwaAgent();
      ConsoleOutConnector conn = new ConsoleOutConnector(agent, true);
      conn.start();
      long l = agent
          .processCommand("ADD org.apache.hadoop.chukwa.datacollection.adaptor.ChukwaTestAdaptor"
              + "  chukwaTestAdaptorType 0  114027");
      assertTrue(l != -1);
      Adaptor adaptor = agent.getAdaptorList().get(l);
View Full Code Here

  public void testStopAndStart() {

    try {
      ChukwaAgent agent = new ChukwaAgent();
      ConsoleOutConnector conn = new ConsoleOutConnector(agent, true);
      conn.start();

      ChukwaConfiguration cc = new ChukwaConfiguration();
      int portno = cc.getInt("chukwaAgent.control.port", 9093);
      ChukwaAgentController cli = new ChukwaAgentController("localhost", portno);

      for (int i = 1; i < 20; ++i) {
        long adaptorId = cli.add(
            "org.apache.hadoop.chukwa.util.ConstRateAdaptor", "raw" + i, "2000"
                + i, 0);
        assertTrue(adaptorId != -1);
        Thread.sleep(2000);
        cli.removeAll();
      }
      agent.shutdown();
      conn.shutdown();
    } catch (Exception e) {
      e.printStackTrace();
      fail(e.toString());
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.chukwa.datacollection.test.ConsoleOutConnector

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.