Package org.apache.hadoop.chukwa.datacollection.collector.servlet

Examples of org.apache.hadoop.chukwa.datacollection.collector.servlet.ServletCollector


  public void testEndToEnd() {
    try {
      Configuration conf = new Configuration();

      String outputDirectory = buildConf(conf);
      ServletCollector collector = new ServletCollector(conf);
      Server collectorServ = startCollectorOnPort(conf, PORTNO, collector);
      Thread.sleep(1000);
     
      ChukwaAgent agent = new ChukwaAgent(conf);
      HttpConnector conn = new HttpConnector(agent, "http://localhost:"+PORTNO+"/");
      conn.start();
      String resp = agent.processAddCommand("add constSend = " + ConstRateAdaptor.class.getCanonicalName() +
          " testData "+ SEND_RATE + " 0");
      assertTrue("constSend".equals(resp));
      Thread.sleep(END2END_TEST_SECS * 1000);

      //do the shutdown directly, here, so that acks are still processed.
      assertNotNull(agent.getAdaptor("constSend"));
      long bytesOutput = agent.getAdaptor("constSend").shutdown();
      Thread.sleep(CLIENT_SCANPERIOD + SERVER_SCANPERIOD + ROTATEPERIOD + 3000);
     
      String[] stat = agent.getAdaptorList().get("constSend").split(" ");
      long bytesCommitted = Long.valueOf(stat[stat.length -1]);
     
      long bytesPerSec = bytesOutput / (1000 * END2END_TEST_SECS);
      System.out.println("data rate was " + bytesPerSec + " kb /second");
  
      //all data should be committed
      System.out.println(bytesCommitted + " bytes committed");
      System.out.println(bytesOutput + " bytes output");
      System.out.println("difference is " + (bytesOutput - bytesCommitted));
      ChukwaWriter w = collector.getWriter();
      long bytesWritten = ((SeqFileWriter)w).getBytesWritten();
      System.out.println("collector wrote " + bytesWritten);

      assertEquals(bytesCommitted, bytesOutput);
      assertEquals(bytesWritten, bytesCommitted);
View Full Code Here


      THREADS = conf.getInt("chukwaCollector.http.threads", THREADS);

      // pick a writer.
      ChukwaWriter w = null;
      Map<String, HttpServlet> servletsToAdd = new TreeMap<String, HttpServlet>();
      ServletCollector servletCollector = new ServletCollector(conf);
      for(String arg: args) {
        if(arg.startsWith("writer=")) {       //custom writer class
          String writerCmd = arg.substring("writer=".length());
          if (writerCmd.equals("pretend") || writerCmd.equals("pretend-quietly")) {
            boolean verbose = !writerCmd.equals("pretend-quietly");
            w = new ConsoleWriter(verbose);
            w.init(conf);
            servletCollector.setWriter(w);
          } else
            conf.set("chukwaCollector.writerClass", writerCmd);
        } else if(arg.startsWith("servlet=")) {     //adding custom servlet
           String servletCmd = arg.substring("servlet=".length());
           String[] halves = servletCmd.split("@");
View Full Code Here

      server.setConnectors(new Connector[]{ jettyConnector});
      org.mortbay.thread.BoundedThreadPool pool = new  org.mortbay.thread.BoundedThreadPool();
      pool.setMaxThreads(30);
      server.setThreadPool(pool);
      Context root = new Context(server,"/",Context.SESSIONS);
      root.addServlet(new ServletHolder(new ServletCollector()), "/*");
      server.start();
      server.setStopAtShutdown(false);
    
      System.out.println("started http collector on port number " + portNum);

View Full Code Here

    try{
      Server server = new Server(9990);
      Context root = new Context(server,"/",Context.SESSIONS);
 
      ServletCollector.setWriter(new ConsoleWriter(true));
      root.addServlet(new ServletHolder(new ServletCollector()), "/*");
      server.start();
      server.setStopAtShutdown(false);
 
      Thread.sleep(1000);
      ChukwaAgent agent = new ChukwaAgent();
View Full Code Here

    File sinkB = new File(outputDirectory, "chukwa_sink_B");
    sinkB.mkdir();
    conf.set(CommitCheckServlet.SCANPATHS_OPT, sinkA.getCanonicalPath()
        + "," + sinkB.getCanonicalPath());
    conf.set(SeqFileWriter.OUTPUT_DIR_OPT, sinkA.getCanonicalPath() );
    ServletCollector collector1 = new ServletCollector(new Configuration(conf));
    conf.set(SeqFileWriter.OUTPUT_DIR_OPT,sinkB.getCanonicalPath() );
    ServletCollector collector2 = new ServletCollector(conf);
    Server collector1_s = TestDelayedAcks.startCollectorOnPort(conf, PORTNO+1, collector1);
    Server collector2_s = TestDelayedAcks.startCollectorOnPort(conf, PORTNO+2, collector2);
    Thread.sleep(2000); //for collectors to start
   
    ChukwaAgent agent = new ChukwaAgent(conf);
View Full Code Here

  public void testAdaptorTimeout() throws Exception {
    Configuration conf = new Configuration();

    String outputDirectory = TestDelayedAcks.buildConf(conf);
    conf.setInt(AdaptorResetThread.TIMEOUT_OPT, 1000);
    ServletCollector collector = new ServletCollector(conf);
    Server collectorServ = TestDelayedAcks.startCollectorOnPort(conf, PORTNO, collector);
    Thread.sleep(1000);
   
    ChukwaAgent agent = new ChukwaAgent(conf);
    HttpConnector conn = new HttpConnector(agent, "http://localhost:"+PORTNO+"/");
View Full Code Here

    conn.setCollectors(clist);
    conn.start();
    Server server = new Server(PORTNO);
    Context root = new Context(server, "/", Context.SESSIONS);

    root.addServlet(new ServletHolder(new ServletCollector(conf)), "/*");
    server.start();
    server.setStopAtShutdown(false);
    Thread.sleep(1000);
    agent.processAddCommand("add constSend = " + ConstRateAdaptor.class.getCanonicalName() +
        " testData "+ SEND_RATE + " 0");
View Full Code Here

    try {
      Server server = new Server(9990);
      Context root = new Context(server, "/", Context.SESSIONS);

      ServletCollector.setWriter(new ConsoleWriter(true));
      root.addServlet(new ServletHolder(new ServletCollector(
          new ChukwaConfiguration(true))), "/*");
      server.start();
      server.setStopAtShutdown(false);

      Thread.sleep(1000);
View Full Code Here

      org.mortbay.thread.BoundedThreadPool pool = new org.mortbay.thread.BoundedThreadPool();
      pool.setMaxThreads(THREADS);
      jettyServer.setThreadPool(pool);
      // and add the servlet to it
      Context root = new Context(jettyServer, "/", Context.SESSIONS);
      root.addServlet(new ServletHolder(new ServletCollector(conf)), "/*");
      jettyServer.start();
      jettyServer.setStopAtShutdown(false);

      System.out.println("started http collector on port number " + portNum);

View Full Code Here

      collectorList.add("http://localhost:9990/chukwa");
      sender.setCollectors(new RetryListOfCollectors(collectorList, 50));
      Server server = new Server(9990);
      Context root = new Context(server, "/", Context.SESSIONS);

      root.addServlet(new ServletHolder(new ServletCollector(conf)), "/*");
      server.start();
      server.setStopAtShutdown(false);
      Thread.sleep(1000);

      Chunk c = new ChunkImpl("data", "stream", 0,
View Full Code Here

TOP

Related Classes of org.apache.hadoop.chukwa.datacollection.collector.servlet.ServletCollector

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.