本文整理汇总了Java中org.eclipse.jetty.util.thread.ScheduledExecutorScheduler类的典型用法代码示例。如果您正苦于以下问题:Java ScheduledExecutorScheduler类的具体用法?Java ScheduledExecutorScheduler怎么用?Java ScheduledExecutorScheduler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ScheduledExecutorScheduler类属于org.eclipse.jetty.util.thread包,在下文中一共展示了ScheduledExecutorScheduler类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ArmeriaConnector
import org.eclipse.jetty.util.thread.ScheduledExecutorScheduler; //导入依赖的package包/类
ArmeriaConnector(Server server) {
this.server = server;
executor = server.getThreadPool();
final HttpConfiguration httpConfig = server.getBean(HttpConfiguration.class);
this.httpConfig = httpConfig != null ? httpConfig : new HttpConfiguration();
final Scheduler scheduler = server.getBean(Scheduler.class);
this.scheduler = scheduler != null ? scheduler : new ScheduledExecutorScheduler();
final ByteBufferPool byteBufferPool = server.getBean(ByteBufferPool.class);
this.byteBufferPool = byteBufferPool != null ? byteBufferPool : new ArrayByteBufferPool();
addBean(server, false);
addBean(executor);
unmanage(executor);
addBean(this.httpConfig);
addBean(this.scheduler);
addBean(this.byteBufferPool);
connectionFactory = new ArmeriaConnectionFactory();
connectionFactories = Collections.singleton(connectionFactory);
}
示例2: createServer
import org.eclipse.jetty.util.thread.ScheduledExecutorScheduler; //导入依赖的package包/类
private Server createServer() {
final QueuedThreadPool threadPool = new QueuedThreadPool();
threadPool.setMaxThreads(500);
final Server server = new Server(threadPool);
server.addBean(new ScheduledExecutorScheduler());
final ServerConnector http = createHttpServerConnector(server);
server.addConnector(http);
server.setHandler(createServletContextHandler());
server.setDumpAfterStart(false);
server.setDumpBeforeStop(false);
server.setStopAtShutdown(true);
return server;
}
示例3: createServer
import org.eclipse.jetty.util.thread.ScheduledExecutorScheduler; //导入依赖的package包/类
protected Server createServer() {
final QueuedThreadPool threadPool = new QueuedThreadPool();
threadPool.setMaxThreads(500);
final Server server = new Server(threadPool);
server.addBean(new ScheduledExecutorScheduler());
final HttpConfiguration http_config = createHttpConfigurationForHTTP();
// ServerConnector http = new ServerConnector(server, new HttpConnectionFactory(http_config));
// http.setPort(8080);
// http.setIdleTimeout(30000);
// server.addConnector(http);
server.setHandler(createServletContextHandler());
server.setDumpAfterStart(false);
server.setDumpBeforeStop(false);
server.setStopAtShutdown(true);
final HttpConfiguration https_config = createHttpConfigurationForHTTPS(http_config);
server.addConnector(createServerConnectorForHTTPS(server, https_config));
return server;
}
示例4: startServer
import org.eclipse.jetty.util.thread.ScheduledExecutorScheduler; //导入依赖的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);
}
}
示例5: createConnector
import org.eclipse.jetty.util.thread.ScheduledExecutorScheduler; //导入依赖的package包/类
public ServerConnector createConnector(Server server) {
// a few things are hardcoded for now... if needed we can turn these
// into properties
HttpConfiguration httpConfig = buildHttpConfiguration();
ConnectionFactory[] connectionFactories = buildHttpConnectionFactories(httpConfig);
Scheduler scheduler = new ScheduledExecutorScheduler();
ByteBufferPool bufferPool = buildBufferPool();
// "-1" is Jetty default for acceptor and selector threads that triggers default init algorithm based on
// the number of machine cores
int acceptorThreads = this.acceptorThreads > 0 ? this.acceptorThreads : -1;
int selectorThreads = this.selectorThreads > 0 ? this.selectorThreads : -1;
ThreadPool threadPool = Objects.requireNonNull(server.getThreadPool());
ServerConnector connector = new ServerConnector(
server,
threadPool,
scheduler,
bufferPool,
acceptorThreads,
selectorThreads,
connectionFactories);
connector.setPort(getPort());
connector.setIdleTimeout(30 * 1000);
connector.setHost(getHost());
return connector;
}
示例6: prepare
import org.eclipse.jetty.util.thread.ScheduledExecutorScheduler; //导入依赖的package包/类
/**
* A fully configured Jetty Server instance
*/
public void prepare() throws Exception {
// === jetty.xml ===
// Setup Threadpool
QueuedThreadPool threadPool = new QueuedThreadPool();
threadPool.setMinThreads(MIN_THREADS);
threadPool.setMaxThreads(MAX_THREADS);
// Server
server = new Server(threadPool);
// Scheduler
server.addBean(new ScheduledExecutorScheduler());
// HTTP Configuration
HttpConfiguration httpConfig = new HttpConfiguration();
httpConfig.setSecureScheme(HttpScheme.HTTPS.asString());
httpConfig.setSecurePort(CONFIG.getJetty().getHttpsPort());
httpConfig.setOutputBufferSize(32768);
httpConfig.setRequestHeaderSize(8192);
httpConfig.setResponseHeaderSize(8192);
httpConfig.setSendServerVersion(false);
httpConfig.setSendDateHeader(false);
httpConfig.setSendXPoweredBy(false);
// Extra options
server.setDumpAfterStart(false);
server.setDumpBeforeStop(false);
server.setStopAtShutdown(true);
server.setStopTimeout(STOP_TIMEOUT);
if (CONFIG.getJetty().isHttpEnabled()) {
server.addConnector(httpConnector(httpConfig));
}
if (CONFIG.getJetty().isHttpsEnabled()) {
server.addConnector(httpsConnector(httpConfig));
}
SteveAppContext steveAppContext = new SteveAppContext();
server.setHandler(steveAppContext.getHandlers());
}
示例7: MesosSchedulerServerImpl
import org.eclipse.jetty.util.thread.ScheduledExecutorScheduler; //导入依赖的package包/类
MesosSchedulerServerImpl(MesosSchedulerServerBuilder builder, Scheduler scheduler, MesosMasterClient master, FrameworkInfo frameworkInfo) {
this.credential = requireNonNull(builder.getCredential());
this.serverExecutor = requireNonNull(builder.getServerExecutor());
this.serverPort = builder.getServerPort();
this.scheduler = requireNonNull(scheduler);
this.master = requireNonNull(master);
this.frameworkInfo = requireNonNull(frameworkInfo);
Server schedulerProcessServer = new Server(new ExecutorThreadPool(builder.getServerExecutor()));
org.eclipse.jetty.util.thread.Scheduler taskScheduler =
new ScheduledExecutorScheduler("Jetty-Scheduler", true);
// This is necessary for the session manager and connection timeout logic to use non-daemon
// threads.
schedulerProcessServer.addBean(taskScheduler);
ServerConnector connector = new ServerConnector(schedulerProcessServer);
connector.setHost(requireNonNull(builder.getServerHostAddress()));
connector.setPort(serverPort);
schedulerProcessServer.addConnector(connector);
ServletContextHandler context = new ServletContextHandler();
context.setContextPath("/");
context.addServlet(new ServletHolder(
new SchedulerServlet(scheduler, serverExecutor, master)),
"/scheduler(1)/*");
authenticateeServlet = new AuthenticateeServlet(
PID.fromString("[email protected]:8080"),
credential,
new LibprocessClientBuilder()
.setFromPort(8080)
.setFromId("authenticatee")
.build());
context.addServlet(new ServletHolder(authenticateeServlet), "/authenticatee/*");
schedulerProcessServer.setHandler(context);
this.masterServer = schedulerProcessServer;
}
示例8: newServer
import org.eclipse.jetty.util.thread.ScheduledExecutorScheduler; //导入依赖的package包/类
@SuppressWarnings({"resource", "boxing"})
public static Server newServer(int jettyPort, String jettyWebAppDir, JettyServiceSetting jettyServiceSetting) throws Exception {
if (jettyPort == 0 || jettyWebAppDir == null) {
throw new IllegalArgumentException("Jetty port and resource dir may not be empty");
}
// server setup
Server server = new Server();
server.addBean(new ScheduledExecutorScheduler());
server.setDumpAfterStart(false);
server.setDumpBeforeStop(false);
server.setStopAtShutdown(true);
// http://www.eclipse.org/jetty/documentation/current/embedding-jetty.html#d0e19050
// Setup JMX
MBeanContainer mbContainer = new MBeanContainer(ManagementFactory.getPlatformMBeanServer());
server.addBean(mbContainer);
//setup handlers according to the jetty settings
HandlerCollection handlerCollection = new HandlerCollection();
if (jettyServiceSetting == JettyServiceSetting.ARTIFACTORY || jettyServiceSetting == JettyServiceSetting.BOTH) {
// The WebAppContext is the entity that controls the environment in
// which a web application lives and breathes. In this example the
// context path is being set to "/" so it is suitable for serving root
// context requests and then we see it setting the location of the war.
// A whole host of other configurations are available, ranging from
// configuring to support annotation scanning in the webapp (through
// PlusConfiguration) to choosing where the webapp will unpack itself.
WebAppContext webapp = new WebAppContext();
File warFile = new File(jettyWebAppDir + File.separator + "artifactory.war");
webapp.setContextPath("/artifactory");
webapp.setWar(warFile.getAbsolutePath());
// A WebAppContext is a ContextHandler as well so it needs to be set to
// the server so it is aware of where to send the appropriate requests.
handlerCollection.addHandler(webapp);
}
if (jettyServiceSetting == JettyServiceSetting.VIP || jettyServiceSetting == JettyServiceSetting.BOTH) {
// Serve resource files which reside in the jettyWebAppDir
ResourceHandler resourceHandler = new ResourceHandler();
resourceHandler.setDirectoriesListed(false);
resourceHandler.setResourceBase(jettyWebAppDir);
handlerCollection.addHandler(resourceHandler);
}
server.setHandler(handlerCollection);
// http configuration
HttpConfiguration http_config = new HttpConfiguration();
http_config.setSendServerVersion(true);
// HTTP connector
ServerConnector http = new ServerConnector(server, new HttpConnectionFactory(http_config));
http.setPort(jettyPort);
server.addConnector(http);
// start server
server.start();
LOG.info("Started jetty server on port: {}, resource dir: {} ", jettyPort, jettyWebAppDir);
return server;
}
示例9: start
import org.eclipse.jetty.util.thread.ScheduledExecutorScheduler; //导入依赖的package包/类
@Override
public void start() throws Exception {
// Thread pool
final QueuedThreadPool threadPool = new QueuedThreadPool();
threadPool.setMinThreads(10);
threadPool.setMaxThreads(500);
// Jetty Server
server = new Server(threadPool);
// Setup Scheduler
server.addBean(new ScheduledExecutorScheduler());
// Setup JMX
final MBeanContainer mbeanContainer = new MBeanContainer(ManagementFactory.getPlatformMBeanServer());
server.addBean(mbeanContainer);
// HTTP config
final HttpConfiguration httpConfig = new HttpConfiguration();
httpConfig.addCustomizer( new ForwardedRequestCustomizer() );
httpConfig.setSecureScheme("https");
httpConfig.setSecurePort(httpsPort);
httpConfig.setOutputBufferSize(32768);
httpConfig.setRequestHeaderSize(8192);
httpConfig.setResponseHeaderSize(8192);
httpConfig.setSendServerVersion(false);
httpConfig.setSendDateHeader(false);
// HTTP Connector
final ServerConnector httpConnector = new ServerConnector(server, new HttpConnectionFactory(httpConfig));
httpConnector.setPort(httpPort);
httpConnector.setHost(bindInterface);
httpConnector.setIdleTimeout(30000);
server.addConnector(httpConnector);
// Setup handlers
server.setHandler(createHandlers());
// Extra config options
server.setStopAtShutdown(true);
// Configure SSL
if (httpsEnable && !Strings.isNullOrEmpty(keystoreFile) && new File(keystoreFile).exists()) {
// SSL Context
final SslContextFactory sslContextFactory = new SslContextFactory();
// Define keystore path and passwords
sslContextFactory.setKeyStorePath(keystoreFile);
sslContextFactory.setKeyStorePassword(keystorePassword);
sslContextFactory.setKeyManagerPassword(keystorePassword);
// HTTPS config
final HttpConfiguration httpsConfig = new HttpConfiguration(httpConfig);
httpsConfig.addCustomizer(new SecureRequestCustomizer());
// HTTPS connector
final ServerConnector sslConnector = new ServerConnector(server,
new SslConnectionFactory(sslContextFactory, "http/1.1"),
new HttpConnectionFactory(httpsConfig));
sslConnector.setPort(httpsPort);
sslConnector.setHost(bindInterface);
server.addConnector(sslConnector);
}
server.start();
server.join();
}