Package org.mortbay.jetty

Examples of org.mortbay.jetty.Server


          .getCanonicalName());
      ChukwaHttpSender sender = new ChukwaHttpSender(conf);
      ArrayList<String> collectorList = new ArrayList<String>();
      collectorList.add("http://localhost:9990/chukwa");
      sender.setCollectors(new RetryListOfCollectors(collectorList, conf));
      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,
          "testing -- this should appear once".getBytes(), null);
      ArrayList<Chunk> toSend = new ArrayList<Chunk>();
View Full Code Here


        + "," + 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);
    HttpConnector conn = new HttpConnector(agent);
    RetryListOfCollectors clist = new RetryListOfCollectors(conf);
    clist.add("http://localhost:"+(PORTNO+1)+"/");
    clist.add("http://localhost:"+(PORTNO+2)+"/");
    conn.setCollectors(clist);
    conn.start();
    //FIXME: somehow need to clue in commit checker which paths to check.
    //       Somehow need

    String resp = agent.processAddCommand("add adaptor_constSend = " + ConstRateAdaptor.class.getCanonicalName() +
        " testData "+ TestDelayedAcks.SEND_RATE + " 12345 0");
    assertTrue("adaptor_constSend".equals(resp));
    Thread.sleep(10 * 1000);
    collector1_s.stop();
    Thread.sleep(10 * 1000);
    SeqFileWriter.ENABLE_ROTATION_ON_CLOSE = true;

    String[] stat = agent.getAdaptorList().get("adaptor_constSend").split(" ");
    long bytesCommitted = Long.valueOf(stat[stat.length -1]);
    assertTrue(bytesCommitted > 0);
    agent.shutdown();
    conn.shutdown();
    Thread.sleep(2000); //for collectors to shut down
    collector2_s.stop();
    Thread.sleep(2000); //for collectors to shut down
   
    checkDirs(conf, conf.get(CommitCheckServlet.SCANPATHS_OPT));
   
    TestDirTailingAdaptor.nukeDirContents(new File(outputDirectory));
View Full Code Here

      keys = new ArrayList<String>();
      keys.add("timestamp");
      testTables.put("system_metrics", keys);
      URL serverConf = TestDatabaseWebJson.class
        .getResource("/WEB-INF/jetty.xml");
      server = new Server();
      XmlConfiguration configuration;
      try {
        configuration = new XmlConfiguration(serverConf);
        configuration.configure(server);
        server.start();
View Full Code Here

      jettyConnector.setLowResourcesConnections(THREADS-1);
      jettyConnector.setLowResourceMaxIdleTime(1500);
      jettyConnector.setPort(collectorPort);
     
      // Set up jetty server proper, using connector
      jettyCollector = new Server(collectorPort);
      Context root = new Context(jettyCollector, "/", Context.SESSIONS);
      root.addServlet(new ServletHolder(new ServletCollector(conf)), "/*");
      jettyCollector.start();
      jettyCollector.setStopAtShutdown(true);
      Thread.sleep(10000);
View Full Code Here

    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+"/");
    conn.start();
    String resp = agent.processAddCommand("add constSend = " + ConstRateAdaptor.class.getCanonicalName() +
        " testData "+ SEND_RATE + " 0");
    assertTrue("adaptor_constSend".equals(resp));
    Thread.sleep(TEST_DURATION_SECS * 1000);
   
    AsyncAckSender sender = (AsyncAckSender)conn.getSender();
    int resets = sender.adaptorReset.getResetCount();
    System.out.println(resets + " resets");
    assertTrue(resets > 0);
   
    agent.shutdown();
    collectorServ.stop();
    conn.shutdown();
    Thread.sleep(5000); //for collector to shut down
   
    long dups = TestFailedCollectorAck.checkDirs(conf, conf.get(SeqFileWriter.OUTPUT_DIR_OPT));
    assertTrue(dups > 0);
View Full Code Here

    RetryListOfCollectors clist = new RetryListOfCollectors(conf);
    clist.add("http://localhost:"+PORTNO+"/chukwa");
    HttpConnector conn = new HttpConnector(agent);
    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 adaptor_constSend = " + ConstRateAdaptor.class.getCanonicalName() +
        " testData "+ SEND_RATE + " 0");
    assertNotNull(agent.getAdaptor("adaptor_constSend"));
    Thread.sleep(TEST_DURATION_SECS * 1000);
 
View Full Code Here

  }
 

  public static Server startCollectorOnPort(Configuration conf, int port,
      ServletCollector collector) throws Exception {
    Server server = new Server(port);
   
    Context root = new Context(server, "/", Context.SESSIONS);
    root.addServlet(new ServletHolder(collector), "/*");
    root.addServlet(new ServletHolder(new CommitCheckServlet(conf)), "/"+CommitCheckServlet.DEFAULT_PATH);

    server.start();
    server.setStopAtShutdown(false);
    return server;
  }
View Full Code Here

    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("adaptor_constSend".equals(resp));
      Thread.sleep(END2END_TEST_SECS * 1000);

      //do the shutdown directly, here, so that acks are still processed.
      assertNotNull(agent.getAdaptor("adaptor_constSend"));
      long bytesOutput = agent.getAdaptor("adaptor_constSend").shutdown(AdaptorShutdownPolicy.GRACEFULLY);
      Thread.sleep(CLIENT_SCANPERIOD + SERVER_SCANPERIOD + ROTATEPERIOD + 3000);
     
      String[] stat = agent.getAdaptorList().get("adaptor_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);
      //We need a little imprecision here, since the send rate is a bit bursty,
      //and since some acks got lost after the adaptor was stopped.
      assertTrue(bytesPerSec > 9 * SEND_RATE/ 1000 / 10);
      AsyncAckSender sender = (AsyncAckSender)conn.getSender();
      assertEquals(0, sender.adaptorReset.getResetCount());
     
      agent.shutdown();
      collectorServ.stop();
      conn.shutdown();
      Thread.sleep(5000); //for collector to shut down
      TestDirTailingAdaptor.nukeDirContents(new File(outputDirectory));
     
    } catch (Exception e) {
View Full Code Here

  /**
   * @param args
   */
  public static void main(String[] args) {
    try {
      Server server = new Server(9990);
      Context root = new Context(server, "/", Context.SESSIONS);

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

      Thread.sleep(1000);
      ChukwaAgent agent = new ChukwaAgent();
      HttpConnector connector = new HttpConnector(agent,
          "http://localhost:9990/chukwa");
View Full Code Here

            "com.sun.jersey.api.core.PackagesResourceConfig");
    servletHolder.setInitParameter("com.sun.jersey.config.property.packages",
            "org.apache.hadoop.chukwa.datacollection.agent.rest");
    servletHolder.setServletHandler(new ServletHandler());

    jettyServer = new Server();

    Context root = new Context(jettyServer, "/foo/bar", Context.SESSIONS);
    root.setAttribute("ChukwaAgent", agent);
    root.addServlet(servletHolder, "/*");

 
View Full Code Here

TOP

Related Classes of org.mortbay.jetty.Server

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.