logger.error("Unable to load HTML templates from jar for admin pages.", e);
throw e;
}
// NOW START SocketConnector and create Jetty server but dont start.
SocketConnector connector = null;
try {
// The socket channel connector seems to be faster for our use
//SelectChannelConnector connector = new SelectChannelConnector();
connector = new SocketConnector();
if (intf != null && intf.length() > 0) {
connector.setHost(intf);
}
connector.setPort(port);
connector.statsReset();
connector.setName("VoltDB-HTTPD");
//open the connector here so we know if port is available and Init work can retry with next port.
connector.open();
m_server.addConnector(connector);
//"/"
ContextHandler dbMonitorHandler = new ContextHandler("/");
dbMonitorHandler.setHandler(new DBMonitorHandler());
///api/1.0/
ContextHandler apiRequestHandler = new ContextHandler("/api/1.0");
apiRequestHandler.setHandler(new APIRequestHandler());
///catalog
ContextHandler catalogRequestHandler = new ContextHandler("/catalog");
catalogRequestHandler.setHandler(new CatalogRequestHandler());
///catalog
ContextHandler ddlRequestHandler = new ContextHandler("/ddl");
ddlRequestHandler.setHandler(new DDLRequestHandler());
ContextHandlerCollection handlers = new ContextHandlerCollection();
handlers.setHandlers(new Handler[] {
apiRequestHandler,
catalogRequestHandler,
ddlRequestHandler,
dbMonitorHandler
});
m_server.setHandler(handlers);
/*
* Don't force us to look at a huge pile of threads
*/
final QueuedThreadPool qtp = new QueuedThreadPool();
qtp.setMaxIdleTimeMs(15000);
qtp.setMinThreads(1);
m_server.setThreadPool(qtp);
m_jsonEnabled = jsonEnabled;
} catch (Exception e) {
// double try to make sure the port doesn't get eaten
try { connector.close(); } catch (Exception e2) {}
try { m_server.destroy(); } catch (Exception e2) {}
throw new Exception(e);
}
}