當前位置: 首頁>>代碼示例>>Java>>正文


Java QueuedThreadPool.setDaemon方法代碼示例

本文整理匯總了Java中org.eclipse.jetty.util.thread.QueuedThreadPool.setDaemon方法的典型用法代碼示例。如果您正苦於以下問題:Java QueuedThreadPool.setDaemon方法的具體用法?Java QueuedThreadPool.setDaemon怎麽用?Java QueuedThreadPool.setDaemon使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.jetty.util.thread.QueuedThreadPool的用法示例。


在下文中一共展示了QueuedThreadPool.setDaemon方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createRedirectorServer

import org.eclipse.jetty.util.thread.QueuedThreadPool; //導入方法依賴的package包/類
private Server createRedirectorServer() {
  int unsecurePort = conf.get(HTTP_PORT_KEY, HTTP_PORT_DEFAULT);
  String hostname = conf.get(HTTP_BIND_HOST, HTTP_BIND_HOST_DEFAULT);

  QueuedThreadPool qtp = new QueuedThreadPool(25);
  qtp.setName(serverName + "Redirector");
  qtp.setDaemon(true);
  Server server = new Server(qtp);
  InetSocketAddress addr = new InetSocketAddress(hostname, unsecurePort);
  ServerConnector connector = new ServerConnector(server);
  connector.setHost(addr.getHostName());
  connector.setPort(addr.getPort());
  server.setConnectors(new Connector[]{connector});

  ServletContextHandler context = new ServletContextHandler();
  context.addServlet(new ServletHolder(new RedirectorServlet()), "/*");
  context.setContextPath("/");
  server.setHandler(context);
  return server;
}
 
開發者ID:streamsets,項目名稱:datacollector,代碼行數:21,代碼來源:WebServerTask.java

示例2: startServer

import org.eclipse.jetty.util.thread.QueuedThreadPool; //導入方法依賴的package包/類
public static void startServer() throws ServletException {
    QueuedThreadPool threadPool = new QueuedThreadPool(10);
    threadPool.setDaemon(true);
    threadPool.setMaxThreads(10);
    Server server = new Server(threadPool);
    server.addBean(new ScheduledExecutorScheduler("JettyScheduler", true), true);
    ServerConnector http = new ServerConnector(server, new HttpConnectionFactory());
    http.setPort(2992);
    server.addConnector(http);

    ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
    context.setContextPath("/");
    context.setBaseResource(Resource.newClassPathResource("/org/lwjglx/debug/static"));
    context.setWelcomeFiles(new String[] { "index.html" });
    server.setHandler(context);

    WebSocketUpgradeFilter wsfilter = WebSocketUpgradeFilter.configureContext(context);
    // wsfilter.getFactory().getPolicy().setIdleTimeout(5000);
    wsfilter.addMapping(new ServletPathSpec("/ws"), new ProfilingConnectionCreator());

    ServletHolder holderDefault = new ServletHolder("default", DefaultServlet.class);
    holderDefault.setInitParameter("dirAllowed", "true");
    context.addServlet(holderDefault, "/");

    try {
        server.start();
    } catch (Exception e) {
        throw new AssertionError("Could not start profiling server", e);
    }
}
 
開發者ID:LWJGLX,項目名稱:debug,代碼行數:31,代碼來源:Profiling.java

示例3: start

import org.eclipse.jetty.util.thread.QueuedThreadPool; //導入方法依賴的package包/類
@Override
public void start() {
    if (isStarted()) {
        return;
    }
    jettyServer = new org.eclipse.jetty.server.Server();
    int port = serverConfig.getPort();
    DispatcherServlet.addHttpHandler(port, new WebServiceHandler());

    int threads = serverConfig.getServerBusinessPoolSize();
    QueuedThreadPool threadPool = new QueuedThreadPool();
    threadPool.setName("JSF-WS-BZ");
    threadPool.setDaemon(true);
    threadPool.setMaxThreads(threads);
    threadPool.setMinThreads(threads);
    jettyServer.setThreadPool(threadPool);

    SelectChannelConnector connector = new SelectChannelConnector();
    connector.setHost(serverConfig.getHost());
    connector.setPort(serverConfig.getPort());
    jettyServer.addConnector(connector);

    ServletHandler servletHandler = new ServletHandler();
    ServletHolder servletHolder = servletHandler.addServletWithMapping(DispatcherServlet.class, "/*");
    servletHolder.setInitOrder(2);

    jettyServer.setHandler(servletHandler);

    try {
        jettyServer.start();
    } catch (Exception e) {
        throw new InitErrorException("Failed to start jetty server at port " + port
                + ", cause: " + e.getMessage(), e);
    }
}
 
開發者ID:tiglabs,項目名稱:jsf-sdk,代碼行數:36,代碼來源:HttpWsServer.java

示例4: init

import org.eclipse.jetty.util.thread.QueuedThreadPool; //導入方法依賴的package包/類
public static void init() {
    QueuedThreadPool queuedThreadPool = new QueuedThreadPool();
    queuedThreadPool.setDaemon(true);
    jetty = new Server(queuedThreadPool);

    HandlerCollection handlerCollection = new HandlerCollection(true);
    handlerCollection.addHandler(new JettyHandler(RESPONSE_STRING, PATH_RESPONSE_STRING));
    jetty.setHandler(handlerCollection);
}
 
開發者ID:apache,項目名稱:nifi-minifi,代碼行數:10,代碼來源:PullHttpChangeIngestorCommonTest.java

示例5: doStart

import org.eclipse.jetty.util.thread.QueuedThreadPool; //導入方法依賴的package包/類
@Override
protected void doStart() throws Exception {
    if (!hasThreadPool()) {
        // if there is no thread pool then create a default thread pool using daemon threads
        QueuedThreadPool qtp = new QueuedThreadPool();
        // 16 max threads is the default in the http client
        qtp.setMaxThreads(16);
        qtp.setDaemon(true);
        // let the thread names indicate they are from the client
        qtp.setName("CamelJettyClient(" + ObjectHelper.getIdentityHashCode(this) + ")");
        setThreadPoolOrExecutor(qtp);
    }
    super.doStart();
}
 
開發者ID:nkasvosve,項目名稱:beyondj,代碼行數:15,代碼來源:CamelHttpClient.java

示例6: createServer

import org.eclipse.jetty.util.thread.QueuedThreadPool; //導入方法依賴的package包/類
private Server createServer() {
  port = isSSLEnabled() ?
    conf.get(HTTPS_PORT_KEY, HTTPS_PORT_DEFAULT) :
    conf.get(HTTP_PORT_KEY, HTTP_PORT_DEFAULT);

  String hostname = conf.get(HTTP_BIND_HOST, HTTP_BIND_HOST_DEFAULT);

  QueuedThreadPool qtp = new QueuedThreadPool(conf.get(HTTP_MAX_THREADS, HTTP_MAX_THREADS_DEFAULT));
  qtp.setName(serverName);
  qtp.setDaemon(true);
  Server server = new Server(qtp);

  httpConf = configureForwardRequestCustomizer(httpConf);

  if (!isSSLEnabled()) {
    InetSocketAddress addr = new InetSocketAddress(hostname, port);
    ServerConnector connector = new ServerConnector(server, new HttpConnectionFactory(httpConf));
    connector.setHost(addr.getHostName());
    connector.setPort(addr.getPort());
    server.setConnectors(new Connector[]{connector});
  } else {
    //Create a connector for HTTPS
    httpConf.addCustomizer(new SecureRequestCustomizer());

    SslContextFactory sslContextFactory = createSslContextFactory();
    ServerConnector httpsConnector = new ServerConnector(server,
                                                         new SslConnectionFactory(sslContextFactory, "http/1.1"),
                                                         new HttpConnectionFactory(httpConf));
    httpsConnector.setPort(port);
    httpsConnector.setHost(hostname);
    server.setConnectors(new Connector[]{httpsConnector});
  }
  return server;
}
 
開發者ID:streamsets,項目名稱:datacollector,代碼行數:35,代碼來源:WebServerTask.java

示例7: JettyHttpServer

import org.eclipse.jetty.util.thread.QueuedThreadPool; //導入方法依賴的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);

    server = new Server(threadPool);

    // HTTP connector
    ServerConnector connector = new ServerConnector(server);
    if (!url.isAnyHost() && NetUtils.isValidLocalHost(url.getHost())) {
        connector.setHost(url.getHost());
    }
    connector.setPort(url.getPort());
    // connector.setIdleTimeout(30000);
    server.addConnector(connector);

    ServletHandler servletHandler = new ServletHandler();
    ServletHolder servletHolder = servletHandler.addServletWithMapping(DispatcherServlet.class, "/*");
    servletHolder.setInitOrder(2);

    server.insertHandler(servletHandler);

    try {
        server.start();
    } catch (Exception e) {
        throw new IllegalStateException("Failed to start jetty server on " + url.getAddress() + ", cause: "
                + e.getMessage(), e);
    }
}
 
開發者ID:dubbo,項目名稱:dubbo-rpc-jsonrpc,代碼行數:35,代碼來源:JettyHttpServer.java

示例8: start

import org.eclipse.jetty.util.thread.QueuedThreadPool; //導入方法依賴的package包/類
void start() {
  if (server != null) {
    throw new RuntimeException("Server is already started");
  } else {
    QueuedThreadPool threadPool = new QueuedThreadPool();
    threadPool.setDaemon(true);
    server = new Server(threadPool);
    server.manage(threadPool);

    final ServerConnector connector = new ServerConnector(server);
    connector.setIdleTimeout(60 * 1000);
    connector.setSoLingerTime(-1);
    connector.setPort(0);
    server.setConnectors(new Connector[] { connector });

    final ResourceHandler resHandler = new ResourceHandler();
    resHandler.setResourceBase(resourceBase.getAbsolutePath());

    final HandlerList handlerList = new HandlerList();
    handlerList.setHandlers(new Handler[] {resHandler, new DefaultHandler()});
    server.setHandler(handlerList);
    try {
      server.start();
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
    port = connector.getLocalPort();
  }
}
 
開發者ID:apache,項目名稱:calcite,代碼行數:30,代碼來源:HttpServer.java

示例9: RestChangeIngestor

import org.eclipse.jetty.util.thread.QueuedThreadPool; //導入方法依賴的package包/類
public RestChangeIngestor() {
    QueuedThreadPool queuedThreadPool = new QueuedThreadPool();
    queuedThreadPool.setDaemon(true);
    jetty = new Server(queuedThreadPool);
}
 
開發者ID:apache,項目名稱:nifi-minifi,代碼行數:6,代碼來源:RestChangeIngestor.java

示例10: init

import org.eclipse.jetty.util.thread.QueuedThreadPool; //導入方法依賴的package包/類
public List<Stage.ConfigIssue> init(Stage.Context context) {
  List<Stage.ConfigIssue> issues = new ArrayList<>();
  try {
    int maxThreads = getJettyServerMaxThreads();
    int minThreads = getJettyServerMinThreads();
    QueuedThreadPool threadPool =
        new QueuedThreadPool(maxThreads, minThreads, 60000, new ArrayBlockingQueue<Runnable>(maxThreads));
    threadPool.setName("http-receiver-server:" + context.getPipelineInfo().get(0).getInstanceName());
    threadPool.setDaemon(true);
    Server server = new Server(threadPool);

    ServerConnector connector;
    if (configs.isTlsEnabled()) {
      LOG.debug("Configuring HTTPS");
      HttpConfiguration httpsConf = new HttpConfiguration();
      httpsConf.addCustomizer(new SecureRequestCustomizer());
      SslContextFactory sslContextFactory = new SslContextFactory();

      TlsConfigBean tlsConfig = configs.getTlsConfigBean();
      sslContextFactory.setKeyStorePath(tlsConfig.keyStoreFilePath);
      sslContextFactory.setKeyStoreType(tlsConfig.keyStoreType.getJavaValue());
      sslContextFactory.setKeyStorePassword(tlsConfig.keyStorePassword.get());
      sslContextFactory.setKeyManagerPassword(tlsConfig.keyStorePassword.get());
      sslContextFactory.setIncludeProtocols(tlsConfig.getFinalProtocols());
      sslContextFactory.setIncludeCipherSuites(tlsConfig.getFinalCipherSuites());

      connector = new ServerConnector(server,
          new SslConnectionFactory(sslContextFactory, "http/1.1"),
          new HttpConnectionFactory(httpsConf)
      );
    } else {
      LOG.debug("Configuring HTTP");
      connector = new ServerConnector(server);
    }
    connector.setPort(configs.getPort());
    server.setConnectors(new Connector[]{connector});

    ServletContextHandler contextHandler = new ServletContextHandler();
    // CORS Handling
    FilterHolder crossOriginFilter = new FilterHolder(CrossOriginFilter.class);
    Map<String, String> params = new HashMap<>();
    params.put(CrossOriginFilter.ALLOWED_ORIGINS_PARAM, "*");
    params.put(CrossOriginFilter.ALLOWED_HEADERS_PARAM, "*");
    crossOriginFilter.setInitParameters(params);
    contextHandler.addFilter(crossOriginFilter, "/*", EnumSet.of(DispatcherType.REQUEST));

    addReceiverServlet(context, contextHandler);

    contextHandler.setContextPath("/");
    server.setHandler(contextHandler);
    server.start();

    LOG.debug("Running, port '{}', TLS '{}'", configs.getPort(), configs.isTlsEnabled());

    httpServer = server;
  } catch (Exception ex) {
    issues.add(context.createConfigIssue("HTTP", "", HttpServerErrors.HTTP_SERVER_ORIG_20, ex.toString()));
  }
  return issues;
}
 
開發者ID:streamsets,項目名稱:datacollector,代碼行數:61,代碼來源:AbstractHttpReceiverServer.java

示例11: start

import org.eclipse.jetty.util.thread.QueuedThreadPool; //導入方法依賴的package包/類
public void start() throws Exception {
  int numberOfThreads = getJettyServerMinimumThreads();
  QueuedThreadPool threadPool = new QueuedThreadPool(numberOfThreads, numberOfThreads, 60000,
                                                     new ArrayBlockingQueue<Runnable>(20));
  threadPool.setName("sdcipc-server");
  threadPool.setDaemon(true);
  Server server = new Server(threadPool);

  ServerConnector connector;
  if (configs.tlsConfigBean.isEnabled()) {
    LOG.debug("Configuring over HTTPS");
    HttpConfiguration httpsConf = new HttpConfiguration();
    httpsConf.addCustomizer(new SecureRequestCustomizer());
    SslContextFactory sslContextFactory = new SslContextFactory();
    final TlsConfigBean tlsConfig = configs.getTlsConfigBean();

    sslContextFactory.setKeyStore(tlsConfig.getKeyStore());
    sslContextFactory.setKeyStorePassword(tlsConfig.keyStorePassword.get());
    sslContextFactory.setKeyManagerPassword(tlsConfig.keyStorePassword.get());
    sslContextFactory.setSslContext(tlsConfig.getSslContext());
    sslContextFactory.setIncludeProtocols(tlsConfig.getFinalProtocols());
    sslContextFactory.setIncludeCipherSuites(tlsConfig.getFinalCipherSuites());

    connector = new ServerConnector(server, new SslConnectionFactory(sslContextFactory, "http/1.1"),
                                    new HttpConnectionFactory(httpsConf));
  } else {
    LOG.debug("Configuring over HTTP");
    connector = new ServerConnector(server);
  }
  connector.setPort(configs.port);
  server.setConnectors(new Connector[]{connector});

  servlet = new IpcServlet(context, configs, queue);
  ServletContextHandler contextHandler = new ServletContextHandler();
  contextHandler.addFilter(DisableTraceFilter.class, "/*", EnumSet.allOf(DispatcherType.class));
  contextHandler.addServlet(new ServletHolder(new PingServlet()), Constants.PING_PATH);
  contextHandler.addServlet(new ServletHolder(servlet), Constants.IPC_PATH);
  contextHandler.setContextPath("/");
  server.setHandler(contextHandler);

  server.start();

  LOG.info("Running, port '{}', TLS '{}'", configs.port, configs.tlsConfigBean.isEnabled());

  httpServer = server;
}
 
開發者ID:streamsets,項目名稱:datacollector,代碼行數:47,代碼來源:IpcServer.java


注:本文中的org.eclipse.jetty.util.thread.QueuedThreadPool.setDaemon方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。