本文整理了Java中com.linecorp.armeria.server.Server.activePorts()
方法的一些代码示例,展示了Server.activePorts()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Server.activePorts()
方法的具体详情如下:
包路径:com.linecorp.armeria.server.Server
类名称:Server
方法名:activePorts
[英]Returns all ServerPorts that this Server is listening to.
[中]返回此服务器正在侦听的所有服务器端口。
代码示例来源:origin: line/armeria
private static boolean isStopped(@Nullable Server server) {
return server == null || server.activePorts().isEmpty();
}
代码示例来源: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 String toString() {
return MoreObjects.toStringHelper(this)
.add("config", config())
.add("activePorts", activePorts())
.add("state", startStop)
.toString();
}
代码示例来源:origin: line/armeria
private boolean hasSessionProtocol(SessionProtocol protocol) {
final Server server = this.server.get();
return server != null &&
server.activePorts().values().stream()
.anyMatch(port -> port.hasProtocol(protocol));
}
代码示例来源:origin: line/armeria
/**
* Returns the port number of the {@link Server} for the specified {@link SessionProtocol}.
*
* @throws IllegalStateException if the {@link Server} is not started or it did not open a port of the
* specified protocol.
*/
public int port(SessionProtocol protocol) {
return server().activePorts().values().stream()
.filter(p1 -> p1.hasProtocol(protocol)).findAny()
.flatMap(p -> Optional.of(p.localAddress().getPort()))
.orElseThrow(() -> new IllegalStateException(protocol + " port not open"));
}
代码示例来源:origin: line/armeria
@Override
public synchronized void start() {
try {
if (!isRunning) {
server.start().get();
if (port == 0) {
// Replace the specified port number with the primary port number.
// Server#activePort doesn't return the first added port, so we need to find that.
final Optional<ServerPort> port =
server.activePorts().values().stream()
.filter(p -> p.protocols().contains(protocol))
.filter(p -> address == null ||
Arrays.equals(address.getAddress(),
p.localAddress().getAddress().getAddress()))
.findFirst();
assert port.isPresent() : "the primary port doest not exist.";
this.port = port.get().localAddress().getPort();
}
isRunning = true;
}
} catch (Exception cause) {
throw new WebServerException("Failed to start " + ArmeriaWebServer.class.getSimpleName(),
Exceptions.peel(cause));
}
}
代码示例来源:origin: line/armeria
@Test
public void testPortConfiguration() throws Exception {
final Collection<ServerPort> ports = server.activePorts().values();
assertThat(ports.stream().filter(ServerPort::hasHttp)).hasSize(3);
assertThat(ports.stream().filter(p -> p.localAddress().getAddress().isAnyLocalAddress())).hasSize(2);
assertThat(ports.stream().filter(p -> p.localAddress().getAddress().isLoopbackAddress())).hasSize(1);
}
代码示例来源:origin: line/armeria
@BeforeClass
public static void init() throws Exception {
server.start().get();
httpPort = server.activePorts().values().stream()
.filter(ServerPort::hasHttp).findAny().get()
.localAddress().getPort();
httpsPort = server.activePorts().values().stream()
.filter(ServerPort::hasHttps).findAny().get()
.localAddress().getPort();
}
代码示例来源:origin: line/armeria
@Before
public void init() throws Exception {
httpPort = server.activePorts()
.values()
.stream()
.filter(ServerPort::hasHttp)
.findAny()
.get()
.localAddress()
.getPort();
}
代码示例来源:origin: line/armeria
logger.info("Armeria server started at ports: {}", s.activePorts());
return s;
代码示例来源:origin: line/armeria
server.start().get();
httpPort = server.activePorts().values().stream()
.filter(ServerPort::hasHttp).findAny().get().localAddress()
.getPort();
httpsPort = server.activePorts().values().stream()
.filter(ServerPort::hasHttps).findAny().get().localAddress()
.getPort();
代码示例来源:origin: com.linecorp.centraldogma/centraldogma-server-shaded
/**
* Returns the ports of the server.
*
* @return the {@link Map} which contains the pairs of local {@link InetSocketAddress} and
* {@link ServerPort} is the server is started. {@link Optional#empty()} otherwise.
*/
public Map<InetSocketAddress, ServerPort> activePorts() {
final Server server = this.server;
if (server != null) {
return server.activePorts();
} else {
return Collections.emptyMap();
}
}
代码示例来源:origin: line/centraldogma
/**
* Returns the ports of the server.
*
* @return the {@link Map} which contains the pairs of local {@link InetSocketAddress} and
* {@link ServerPort} is the server is started. {@link Optional#empty()} otherwise.
*/
public Map<InetSocketAddress, ServerPort> activePorts() {
final Server server = this.server;
if (server != null) {
return server.activePorts();
} else {
return Collections.emptyMap();
}
}
代码示例来源:origin: com.linecorp.centraldogma/centraldogma-server
/**
* Returns the ports of the server.
*
* @return the {@link Map} which contains the pairs of local {@link InetSocketAddress} and
* {@link ServerPort} is the server is started. {@link Optional#empty()} otherwise.
*/
public Map<InetSocketAddress, ServerPort> activePorts() {
final Server server = this.server;
if (server != null) {
return server.activePorts();
} else {
return Collections.emptyMap();
}
}
代码示例来源:origin: line/centraldogma
logger.info("Started the RPC server at: {}", server.activePorts());
logger.info("Started the Central Dogma successfully.");
success = true;
代码示例来源:origin: com.linecorp.centraldogma/centraldogma-server
logger.info("Started the RPC server at: {}", server.activePorts());
logger.info("Started the Central Dogma successfully.");
success = true;
代码示例来源:origin: com.linecorp.centraldogma/centraldogma-server-shaded
logger.info("Started the RPC server at: {}", server.activePorts());
logger.info("Started the Central Dogma successfully");
success = true;
代码示例来源:origin: com.linecorp.armeria/armeria-spring-boot2-autoconfigure
logger.info("Armeria server started at ports: {}", s.activePorts());
return s;
代码示例来源:origin: com.linecorp.armeria/armeria-spring-boot2-autoconfigure-shaded
logger.info("Armeria server started at ports: {}", s.activePorts());
return s;
代码示例来源:origin: com.linecorp.armeria/armeria-spring-boot1-autoconfigure-shaded
logger.info("Armeria server started at ports: {}", s.activePorts());
return s;
内容来源于网络,如有侵权,请联系作者删除!