org.eclipse.jetty.server.Server.setStopTimeout()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(6.7k)|赞(0)|评价(0)|浏览(289)

本文整理了Java中org.eclipse.jetty.server.Server.setStopTimeout()方法的一些代码示例,展示了Server.setStopTimeout()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Server.setStopTimeout()方法的具体详情如下:
包路径:org.eclipse.jetty.server.Server
类名称:Server
方法名:setStopTimeout

Server.setStopTimeout介绍

[英]Set a graceful stop time. The StatisticsHandler must be configured so that open connections can be tracked for a graceful shutdown.
[中]设定一个优雅的停车时间。必须对StatisticsHandler进行配置,以便跟踪打开的连接以实现正常关闭。

代码示例

代码示例来源:origin: loklak/loklak_server

public static void shutdown(int exitcode){
    DAO.severe("Shutting down installation now");
    server.setStopTimeout(0);
    System.exit(exitcode);
  }
}

代码示例来源:origin: scouter-project/scouter

private static void waitOnExit(Server server) throws Exception {
  File exit = new File(SysJMX.getProcessPID() + ".scouter");
  try {
    exit.createNewFile();
  } catch (Exception e) {
    String tmp = System.getProperty("user.home", "/tmp");
    exit = new File(tmp, SysJMX.getProcessPID() + ".scouter.run");
    try {
      exit.createNewFile();
    } catch (Exception k) {
      System.exit(1);
    }
  }
  exit.deleteOnExit();
  System.out.println("System JRE version : " + System.getProperty("java.version"));
  while (true) {
    if (exit.exists() == false) {
      server.setStopTimeout(3000);
      server.stop();
      System.exit(0);
    }
    ThreadUtil.sleep(1000);
  }
}

代码示例来源:origin: spring-projects/spring-framework

@Override
protected void resetInternal() {
  try {
    if (this.jettyServer.isRunning()) {
      this.jettyServer.setStopTimeout(5000);
      this.jettyServer.stop();
      this.jettyServer.destroy();
    }
  }
  catch (Exception ex) {
    throw new IllegalStateException(ex);
  }
  finally {
    this.jettyServer = null;
    this.contextHandler = null;
  }
}

代码示例来源:origin: spring-projects/spring-framework

@Override
public void stop() throws Exception {
  try {
    if (this.contextHandler.isRunning()) {
      this.contextHandler.stop();
    }
  }
  finally {
    if (this.jettyServer.isRunning()) {
      this.jettyServer.setStopTimeout(5000);
      this.jettyServer.stop();
    }
  }
}

代码示例来源:origin: dropwizard/dropwizard

protected Server buildServer(LifecycleEnvironment lifecycle,
               ThreadPool threadPool) {
  final Server server = new Server(threadPool);
  server.addLifeCycleListener(buildSetUIDListener());
  lifecycle.attach(server);
  final ErrorHandler errorHandler = new ErrorHandler();
  errorHandler.setServer(server);
  errorHandler.setShowStacks(false);
  server.addBean(errorHandler);
  server.setStopAtShutdown(true);
  server.setStopTimeout(shutdownGracePeriod.toMilliseconds());
  return server;
}

代码示例来源:origin: spring-projects/spring-framework

@Override
protected void stopInternal() throws Exception {
  try {
    if (this.contextHandler.isRunning()) {
      this.contextHandler.stop();
    }
  }
  finally {
    try {
      if (this.jettyServer.isRunning()) {
        this.jettyServer.setStopTimeout(5000);
        this.jettyServer.stop();
        this.jettyServer.destroy();
      }
    }
    catch (Exception ex) {
      // ignore
    }
  }
}

代码示例来源:origin: apache/incubator-druid

final long gracefulStop = config.getGracefulShutdownTimeout().toStandardDuration().getMillis();
if (gracefulStop > 0) {
 server.setStopTimeout(gracefulStop);

代码示例来源:origin: io.dropwizard/dropwizard-core

protected Server buildServer(LifecycleEnvironment lifecycle,
               ThreadPool threadPool) {
  final Server server = new Server(threadPool);
  server.addLifeCycleListener(buildSetUIDListener());
  lifecycle.attach(server);
  final ErrorHandler errorHandler = new ErrorHandler();
  errorHandler.setServer(server);
  errorHandler.setShowStacks(false);
  server.addBean(errorHandler);
  server.setStopAtShutdown(true);
  server.setStopTimeout(shutdownGracePeriod.toMilliseconds());
  return server;
}

代码示例来源:origin: com.teradata.airlift/http-server

@PreDestroy
public void stop()
    throws Exception
{
  server.setStopTimeout(0);
  server.stop();
}

代码示例来源:origin: Fanping/iveely.search

public void start() {
 try {
  Server server = new Server(this.port);
  WSHandler.setProcessor(eventProcessor);
  server.setHandler(new WSHandler());
  server.setStopTimeout(0);
  server.start();
  server.join();
 } catch (Exception ex) {
  logger.error(ex);
 }
}

代码示例来源:origin: stackoverflow.com

YourServletHandler servletHandler = new YourServletHandler();
StatisticsHandler statsHandler = new StatisticsHandler();
statsHandler.setHandler(servletHandler);

Server server = new Server(80);
server.setHandler(statsHandler);
server.setStopTimeout(3000L);

//...
server.start();

//...
server.stop();

代码示例来源:origin: com.github.tomakehurst/wiremock-jre8

protected void finalizeSetup(Options options) {
  if(!options.jettySettings().getStopTimeout().isPresent()) {
    jettyServer.setStopTimeout(0);
  }
}

代码示例来源:origin: org.apache.activemq/activemq-all

public Connector createConnector(Server server) throws Exception {
  ServerConnector connector = new ServerConnector(server);
  server.setStopTimeout(500);
  connector.setStopTimeout(500);
  if (transportOptions != null) {
    IntrospectionSupport.setProperties(connector, transportOptions, "");
  }
  return connector;
}

代码示例来源:origin: org.apache.activemq/activemq-osgi

public Connector createConnector(Server server) throws Exception {
  ServerConnector connector = new ServerConnector(server);
  server.setStopTimeout(500);
  connector.setStopTimeout(500);
  if (transportOptions != null) {
    IntrospectionSupport.setProperties(connector, transportOptions, "");
  }
  return connector;
}

代码示例来源:origin: org.apache.activemq/activemq-http

public Connector createConnector(Server server) throws Exception {
  ServerConnector connector = new ServerConnector(server);
  server.setStopTimeout(500);
  connector.setStopTimeout(500);
  if (transportOptions != null) {
    IntrospectionSupport.setProperties(connector, transportOptions, "");
  }
  return connector;
}

代码示例来源:origin: airlift/airlift

@AfterMethod(alwaysRun = true)
public void abstractTeardown()
    throws Exception
{
  if (server != null) {
    server.setStopTimeout(3000);
    server.stop();
  }
}

代码示例来源:origin: io.airlift/http-client

@AfterMethod(alwaysRun = true)
public void abstractTeardown()
    throws Exception
{
  if (server != null) {
    server.setStopTimeout(3000);
    server.stop();
  }
}

代码示例来源:origin: com.github.tomakehurst/wiremock-jre8

protected Server createServer(Options options) {
  final Server server = new Server(options.threadPoolFactory().buildThreadPool(options));
  final JettySettings jettySettings = options.jettySettings();
  final Optional<Long> stopTimeout = jettySettings.getStopTimeout();
  if(stopTimeout.isPresent()) {
    server.setStopTimeout(stopTimeout.get());
  }
  return server;
}

代码示例来源:origin: com.github.mjeanroy/junit-servers-jetty

private Server initServer() {
  Server server = new Server(configuration.getPort());
  server.setStopAtShutdown(configuration.isStopAtShutdown());
  server.setStopTimeout(configuration.getStopTimeout());
  return server;
}

代码示例来源:origin: org.secnod.shiro/shiro-jersey

public static Server start(int port) throws Exception {
  Server server = new Server(port);
  WebAppContext webapp = new WebAppContext();
  webapp.setContextPath("/");
  String resourcePath = JettyServer.class.getPackage().getName().replace('.', '/');
  webapp.setBaseResource(Resource.newClassPathResource(resourcePath));
  webapp.setParentLoaderPriority(true);
  server.setHandler(webapp);
  server.setStopTimeout(5000);
  server.start();
  return server;
}

相关文章