Search in sources :

Example 1 with ThriftServletCollector

use of org.honu.datacollection.collector.servlet.ThriftServletCollector in project Honu by jboulon.

the class ThriftJettyCollector method main.

public static void main(String[] args) throws Exception {
    Configuration conf = HonuConfigurationFactory.getInstance().getCollectorConfiguration();
    THREADS = conf.getInt("chukwaCollector.http.threads", THREADS);
    // Set up jetty connector
    int portNum = conf.getInt("chukwaCollector.http.port", 9999);
    SelectChannelConnector jettyConnector = new SelectChannelConnector();
    jettyConnector.setLowResourcesConnections(THREADS - 10);
    jettyConnector.setLowResourceMaxIdleTime(1500);
    jettyConnector.setPort(portNum);
    int sslPortNum = conf.getInt("chukwaCollector.https.port", 9998);
    SslSocketConnector sslConnector = new SslSocketConnector();
    sslConnector.setPort(sslPortNum);
    sslConnector.setMaxIdleTime(1500);
    sslConnector.setKeystore(conf.get("chukwaCollector.keystore"));
    sslConnector.setTruststore(conf.get("chukwaCollector.truststore"));
    sslConnector.setPassword(conf.get("chukwaCollector.password"));
    sslConnector.setKeyPassword(conf.get("chukwaCollector.keyPassword"));
    sslConnector.setTrustPassword(conf.get("chukwaCollector.trustPassword"));
    // Set up jetty server proper, using connector
    jettyServer = new Server(portNum);
    jettyServer.setConnectors(new Connector[] { jettyConnector, sslConnector });
    org.mortbay.thread.BoundedThreadPool pool = new org.mortbay.thread.BoundedThreadPool();
    pool.setMaxThreads(THREADS);
    jettyServer.setThreadPool(pool);
    // Add the collector servlet to server
    Context root = new Context(jettyServer, "/", Context.SESSIONS);
    root.addServlet(new ServletHolder(new ThriftServletCollector()), "/*");
    jettyServer.start();
    jettyServer.setStopAtShutdown(true);
}
Also used : SslSocketConnector(org.mortbay.jetty.security.SslSocketConnector) Configuration(org.apache.hadoop.conf.Configuration) Server(org.mortbay.jetty.Server) SelectChannelConnector(org.mortbay.jetty.nio.SelectChannelConnector) ThriftServletCollector(org.honu.datacollection.collector.servlet.ThriftServletCollector)

Aggregations

Configuration (org.apache.hadoop.conf.Configuration)1 ThriftServletCollector (org.honu.datacollection.collector.servlet.ThriftServletCollector)1 Server (org.mortbay.jetty.Server)1 SelectChannelConnector (org.mortbay.jetty.nio.SelectChannelConnector)1 SslSocketConnector (org.mortbay.jetty.security.SslSocketConnector)1