本文整理汇总了Java中org.mortbay.jetty.nio.SelectChannelConnector类的典型用法代码示例。如果您正苦于以下问题:Java SelectChannelConnector类的具体用法?Java SelectChannelConnector怎么用?Java SelectChannelConnector使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SelectChannelConnector类属于org.mortbay.jetty.nio包,在下文中一共展示了SelectChannelConnector类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startup
import org.mortbay.jetty.nio.SelectChannelConnector; //导入依赖的package包/类
public void startup() {
if (adminPort > 0) {
Connector httpConnector = new SelectChannelConnector();
httpConnector.setHost(adminHost);
httpConnector.setPort(adminPort);
adminServer.addConnector(httpConnector);
}
if (adminServer.getConnectors() == null
|| adminServer.getConnectors().length == 0) {
adminServer = null;
log.warn("Admin console not started due to configuration error.");
return;
}
adminServer
.setHandlers(new Handler[] { contexts, new DefaultHandler() });
try {
adminServer.start();
httpStarted = true;
log.debug("Admin console started.");
} catch (Exception e) {
log.error("Could not start admin conosle server", e);
}
}
示例2: createDefaultChannelConnector
import org.mortbay.jetty.nio.SelectChannelConnector; //导入依赖的package包/类
@InterfaceAudience.Private
public static Connector createDefaultChannelConnector() {
SelectChannelConnector ret = new SelectChannelConnector();
ret.setLowResourceMaxIdleTime(10000);
ret.setAcceptQueueSize(128);
ret.setResolveNames(false);
ret.setUseDirectBuffers(false);
if(Shell.WINDOWS) {
// result of setting the SO_REUSEADDR flag is different on Windows
// http://msdn.microsoft.com/en-us/library/ms740621(v=vs.85).aspx
// without this 2 NN's can start on the same machine and listen on
// the same port with indeterminate routing of incoming requests to them
ret.setReuseAddress(false);
}
ret.setHeaderBufferSize(1024*64);
return ret;
}
示例3: createDefaultChannelConnector
import org.mortbay.jetty.nio.SelectChannelConnector; //导入依赖的package包/类
@InterfaceAudience.Private
public static Connector createDefaultChannelConnector() {
SelectChannelConnector ret = new SelectChannelConnector();
ret.setLowResourceMaxIdleTime(10000);
ret.setAcceptQueueSize(128);
ret.setResolveNames(false);
ret.setUseDirectBuffers(false);
if(Shell.WINDOWS) {
// result of setting the SO_REUSEADDR flag is different on Windows
// http://msdn.microsoft.com/en-us/library/ms740621(v=vs.85).aspx
// without this 2 NN's can start on the same machine and listen on
// the same port with indeterminate routing of incoming requests to them
ret.setReuseAddress(false);
}
ret.setHeaderBufferSize(1024*64);
return ret;
}
示例4: start
import org.mortbay.jetty.nio.SelectChannelConnector; //导入依赖的package包/类
@Override
public void start() {
jettyServer = new Server();
//We can use Contexts etc if we have many urls to handle. For one url,
//specifying a handler directly is the most efficient.
SelectChannelConnector connector = new SelectChannelConnector();
connector.setReuseAddress(true);
connector.setPort(port);
jettyServer.setConnectors(new Connector[] {connector});
jettyServer.setHandler(new HTTPMetricsHandler());
try {
jettyServer.start();
while (!jettyServer.isStarted()) {
Thread.sleep(500);
}
} catch (Exception ex) {
LOG.error("Error starting Jetty. JSON Metrics may not be available.", ex);
}
}
示例5: createDefaultChannelConnector
import org.mortbay.jetty.nio.SelectChannelConnector; //导入依赖的package包/类
@InterfaceAudience.Private
public static Connector createDefaultChannelConnector() {
SelectChannelConnector ret = new SelectChannelConnectorWithSafeStartup();
ret.setLowResourceMaxIdleTime(10000);
ret.setAcceptQueueSize(128);
ret.setResolveNames(false);
ret.setUseDirectBuffers(false);
if(Shell.WINDOWS) {
// result of setting the SO_REUSEADDR flag is different on Windows
// http://msdn.microsoft.com/en-us/library/ms740621(v=vs.85).aspx
// without this 2 NN's can start on the same machine and listen on
// the same port with indeterminate routing of incoming requests to them
ret.setReuseAddress(false);
}
ret.setHeaderBufferSize(1024*64);
return ret;
}
示例6: createDefaultChannelConnector
import org.mortbay.jetty.nio.SelectChannelConnector; //导入依赖的package包/类
@InterfaceAudience.Private
public static Connector createDefaultChannelConnector() {
SelectChannelConnector ret = new SelectChannelConnectorWithSafeStartup();
ret.setLowResourceMaxIdleTime(10000);
ret.setAcceptQueueSize(128);
ret.setResolveNames(false);
ret.setUseDirectBuffers(false);
if(Shell.WINDOWS) {
// result of setting the SO_REUSEADDR flag is different on Windows
// http://msdn.microsoft.com/en-us/library/ms740621(v=vs.85).aspx
// without this 2 NN's can start on the same machine and listen on
// the same port with indeterminate routing of incoming requests to them
ret.setReuseAddress(false);
}
ret.setHeaderBufferSize(1024*64);
return ret;
}
示例7: isJettySelectorThread
import org.mortbay.jetty.nio.SelectChannelConnector; //导入依赖的package包/类
/**
* @return true if the given thread ID appears to be a Jetty selector thread
* based on its stack trace
*/
private static boolean isJettySelectorThread(long tid) {
ThreadInfo info = threadBean.getThreadInfo(tid, 20);
for (StackTraceElement stack : info.getStackTrace()) {
// compare class names instead of classses, since
// jetty uses a different classloader
if (SelectChannelConnector.class.getName().equals(
stack.getClassName())) {
LOG.debug("Thread #" + tid + " (" + info.getThreadName() + ") " +
"is a Jetty selector thread.");
return true;
}
}
LOG.debug("Thread #" + tid + " (" + info.getThreadName() + ") " +
"is not a jetty thread");
return false;
}
示例8: putUpJettyServer
import org.mortbay.jetty.nio.SelectChannelConnector; //导入依赖的package包/类
private void putUpJettyServer() throws IOException {
if (!conf.getBoolean("hbase.master.infoserver.redirect", true)) {
return;
}
int infoPort = conf.getInt("hbase.master.info.port.orig",
HConstants.DEFAULT_MASTER_INFOPORT);
// -1 is for disabling info server, so no redirecting
if (infoPort < 0 || infoServer == null) {
return;
}
RedirectServlet.regionServerInfoPort = infoServer.getPort();
masterJettyServer = new org.mortbay.jetty.Server();
Connector connector = new SelectChannelConnector();
connector.setHost(conf.get("hbase.master.info.bindAddress", "0.0.0.0"));
connector.setPort(infoPort);
masterJettyServer.addConnector(connector);
masterJettyServer.setStopAtShutdown(true);
Context context = new Context(masterJettyServer, "/", Context.NO_SESSIONS);
context.addServlet(RedirectServlet.class, "/*");
try {
masterJettyServer.start();
} catch (Exception e) {
throw new IOException("Failed to start redirecting jetty server", e);
}
}
示例9: startHttpServer
import org.mortbay.jetty.nio.SelectChannelConnector; //导入依赖的package包/类
private void startHttpServer() throws Exception {
server = new Server();
SelectChannelConnector selectChannelConnector = new SelectChannelConnector();
selectChannelConnector.setPort(11060);
server.setConnectors(new Connector[]{selectChannelConnector});
PackagesResourceConfig packagesResourceConfig = new PackagesResourceConfig("com/ngdata/hbaseindexer/rest");
ServletHolder servletHolder = new ServletHolder(new ServletContainer(packagesResourceConfig));
servletHolder.setName("HBase-Indexer");
Context context = new Context(server, "/", Context.NO_SESSIONS);
context.addServlet(servletHolder, "/*");
context.setContextPath("/");
context.setAttribute("indexerModel", indexerModel);
context.setAttribute("indexerSupervisor", indexerSupervisor);
server.setHandler(context);
server.start();
}
示例10: main
import org.mortbay.jetty.nio.SelectChannelConnector; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
Server server = new Server();
SelectChannelConnector connector = new SelectChannelConnector();
connector.setPort(PORT);
server.addConnector(connector);
server.setStopAtShutdown(true);
// the orders of handlers is very important!
ContextHandler contextHandler = new ContextHandler();
contextHandler.setContextPath("/reports");
contextHandler.setResourceBase("./reports/");
contextHandler.addHandler(new ResourceHandler());
server.addHandler(contextHandler);
server.addHandler(new WebAppContext("webapp", "/nextreports-server"));
long t = System.currentTimeMillis();
server.start();
t = System.currentTimeMillis() - t;
String version = server.getClass().getPackage().getImplementationVersion();
System.out.println("Started Jetty Server " + version + " on port " + PORT + " in " + t / 1000 + "s");
server.join();
}
示例11: createDefaultConnector
import org.mortbay.jetty.nio.SelectChannelConnector; //导入依赖的package包/类
public Object createDefaultConnector(int port) throws Exception {
SelectChannelConnector connector = new SelectChannelConnector();
connector.setPort(port);
connector.setMaxIdleTime(DEFAULT_MAX_IDLE_TIME);
return connector;
}
示例12: JettyHttpServer
import org.mortbay.jetty.nio.SelectChannelConnector; //导入依赖的package包/类
public JettyHttpServer(URL url, final HttpHandler handler){
super(url, handler);
DispatcherServlet.addHttpHandler(url.getPort(), handler);
int threads = url.getParameter(Constants.THREADS_KEY, Constants.DEFAULT_THREADS);
QueuedThreadPool threadPool = new QueuedThreadPool();
threadPool.setDaemon(true);
threadPool.setMaxThreads(threads);
threadPool.setMinThreads(threads);
SelectChannelConnector connector = new SelectChannelConnector();
if (! url.isAnyHost() && NetUtils.isValidLocalHost(url.getHost())) {
connector.setHost(url.getHost());
}
connector.setPort(url.getPort());
server = new Server();
server.setThreadPool(threadPool);
server.addConnector(connector);
ServletHandler servletHandler = new ServletHandler();
ServletHolder servletHolder = servletHandler.addServletWithMapping(DispatcherServlet.class, "/*");
servletHolder.setInitOrder(2);
server.addHandler(servletHandler);
try {
server.start();
} catch (Exception e) {
throw new IllegalStateException("Failed to start jetty server on " + url.getAddress() + ", cause: "
+ e.getMessage(), e);
}
}
示例13: start
import org.mortbay.jetty.nio.SelectChannelConnector; //导入依赖的package包/类
public void start() {
String serverPort = ConfigUtils.getProperty(JETTY_PORT);
int port;
if (serverPort == null || serverPort.length() == 0) {
port = DEFAULT_JETTY_PORT;
} else {
port = Integer.parseInt(serverPort);
}
connector = new SelectChannelConnector();
connector.setPort(port);
ServletHandler handler = new ServletHandler();
String resources = ConfigUtils.getProperty(JETTY_DIRECTORY);
if (resources != null && resources.length() > 0) {
FilterHolder resourceHolder = handler.addFilterWithMapping(ResourceFilter.class, "/*", Handler.DEFAULT);
resourceHolder.setInitParameter("resources", resources);
}
ServletHolder pageHolder = handler.addServletWithMapping(PageServlet.class, "/*");
pageHolder.setInitParameter("pages", ConfigUtils.getProperty(JETTY_PAGES));
pageHolder.setInitOrder(2);
Server server = new Server();
server.addConnector(connector);
server.addHandler(handler);
try {
server.start();
} catch (Exception e) {
throw new IllegalStateException("Failed to start jetty server on " + NetUtils.getLocalHost() + ":" + port + ", cause: " + e.getMessage(), e);
}
}
示例14: main
import org.mortbay.jetty.nio.SelectChannelConnector; //导入依赖的package包/类
/**
* Sets up and runs server.
* @param args
*/
public static void main(String[] args)
{
final Server server = new Server();
SelectChannelConnector connector = new SelectChannelConnector();
connector.setPort(8080);
server.addConnector(connector);
Context htmlContext = new Context(server, "/", Context.SESSIONS);
ResourceHandler htmlHandler = new ResourceHandler();
htmlHandler.setResourceBase("web");
htmlContext.setHandler(htmlHandler);
Context servletContext = new Context(server, "/", Context.SESSIONS);
GenericWebApplicationContext springContext = new GenericWebApplicationContext();
springContext.setParent(new ClassPathXmlApplicationContext("org/getahead/dwrdemo/cli/spring.xml"));
servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, springContext);
ServletHolder holder = new ServletHolder(new DwrSpringServlet());
holder.setInitParameter("pollAndCometEnabled", "true");
holder.setInitParameter("debug", "true");
servletContext.addServlet(holder, "/dwr/*");
try
{
JettyShutdown.addShutdownHook(server);
server.start();
server.join();
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
示例15: main
import org.mortbay.jetty.nio.SelectChannelConnector; //导入依赖的package包/类
/**
* Sets up and runs server.
* @param args
*/
public static void main(String[] args)
{
Server server = new Server();
SelectChannelConnector connector = new SelectChannelConnector();
connector.setPort(8080);
server.addConnector(connector);
Context htmlContext = new Context(server, "/", Context.SESSIONS);
ResourceHandler htmlHandler = new ResourceHandler();
htmlHandler.setResourceBase("web");
htmlContext.setHandler(htmlHandler);
Context servletContext = new Context(server, "/", Context.SESSIONS);
ServletHolder holder = new ServletHolder(new DwrServlet());
holder.setInitParameter("activeReverseAjaxEnabled", "true");
holder.setInitParameter("debug", "true");
servletContext.addServlet(holder, "/dwr/*");
servletContext.setResourceBase("web");
try
{
JettyShutdown.addShutdownHook(server);
server.start();
server.join();
}
catch (Exception ex)
{
ex.printStackTrace();
}
}