本文整理了Java中com.linecorp.armeria.server.Server.stop()
方法的一些代码示例,展示了Server.stop()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Server.stop()
方法的具体详情如下:
包路径:com.linecorp.armeria.server.Server
类名称:Server
方法名:stop
[英]Stops this Server to close all active ServerPorts. Note that the shutdown procedure is asynchronous and thus this method returns immediately. To wait until this Server is fully shut down, wait for the returned CompletableFuture:
Server server = ...;
[中]停止此服务器以关闭所有活动服务器端口。请注意,关闭过程是异步的,因此此方法会立即返回。要等待此服务器完全关闭,请等待返回的CompletableFuture:
Server server = ...;
代码示例来源:origin: line/armeria
/**
* Stops the {@link Server} asynchronously.
*
* @return the {@link CompletableFuture} that will complete when the {@link Server} is stopped.
*/
public CompletableFuture<Void> stop() {
final Server server = this.server.getAndSet(null);
if (server == null || server.activePorts().isEmpty()) {
return CompletableFuture.completedFuture(null);
}
return server.stop();
}
代码示例来源:origin: line/armeria
@Override
public synchronized void stop() {
try {
if (isRunning) {
server.stop().get();
isRunning = false;
}
} catch (Exception cause) {
throw new WebServerException("Failed to stop " + ArmeriaWebServer.class.getSimpleName(),
Exceptions.peel(cause));
}
}
代码示例来源:origin: line/armeria
@AfterClass
public static void destroy() throws Exception {
server.stop().get();
}
代码示例来源:origin: line/armeria
@After
public void stopServers() {
if (servers != null) {
servers.forEach(s -> s.stop().join());
}
}
代码示例来源:origin: line/armeria
public static void main(String[] args) throws Exception {
final SamlServiceProvider ssp = samlServiceProvider();
final Server server = new ServerBuilder()
.https(8443)
// You can add this certificate to your trust store in order to make your web browser happy.
.tls(new File(ClassLoader.getSystemResource("localhost.crt").toURI()),
new File(ClassLoader.getSystemResource("localhost.key").toURI()))
// Decorate you service with SAML decorator.
.annotatedService("/", new MyService(), ssp.newSamlDecorator())
// Add SAML service to your server which handles a SAML response and a metadata request.
.service(ssp.newSamlService())
.build();
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
server.stop().join();
logger.info("Server has been stopped.");
}));
server.start().join();
logger.info("Server has been started.");
}
}
代码示例来源:origin: line/armeria
@AfterClass
public static void afterClass() {
if (server != null) {
server.stop().join();
}
if (client != null) {
client.factory().close();
}
}
代码示例来源:origin: line/armeria
@Test(timeout = 20000)
public void testHardTimeout() throws Exception {
final long baselineNanos = baselineNanos();
final Server server = GracefulShutdownIntegrationTest.server.start();
// Keep sending a request after shutdown starts so that the hard limit is reached.
final SleepService.Iface client = newClient();
final CompletableFuture<Long> stopFuture = CompletableFuture.supplyAsync(() -> {
final long startTime = System.nanoTime();
server.stop().join();
final long stopTime = System.nanoTime();
return stopTime - startTime;
});
for (int i = 0; i < 50; i++) {
try {
client.sleep(100);
} catch (Exception e) {
// Server has been shut down
break;
}
}
// Should take 1 more second than the baseline, because the requests will extend the quiet period
// until the shutdown timeout is triggered.
assertThat(stopFuture.join()).isBetween(baselineNanos + MILLISECONDS.toNanos(600),
baselineNanos + MILLISECONDS.toNanos(1400));
}
代码示例来源:origin: line/armeria
@AfterClass
public static void destroy() throws Exception {
clientFactoryWithUseHttp2Preface.close();
clientFactoryWithoutUseHttp2Preface.close();
server.stop();
}
代码示例来源:origin: line/armeria
servers.get(0).stop().get();
servers.remove(0);
代码示例来源:origin: com.linecorp.centraldogma/centraldogma-server-shaded
if (server != null) {
logger.info("Stopping the RPC server ..");
server.stop().join();
logger.info("Stopped the RPC server");
代码示例来源:origin: com.linecorp.centraldogma/centraldogma-server
if (server != null) {
logger.info("Stopping the RPC server ..");
server.stop().join();
logger.info("Stopped the RPC server.");
代码示例来源:origin: line/centraldogma
if (server != null) {
logger.info("Stopping the RPC server ..");
server.stop().join();
logger.info("Stopped the RPC server.");
内容来源于网络,如有侵权,请联系作者删除!