本文整理了Java中com.linecorp.armeria.server.Server.config()
方法的一些代码示例,展示了Server.config()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Server.config()
方法的具体详情如下:
包路径:com.linecorp.armeria.server.Server
类名称:Server
方法名:config
[英]Returns the configuration of this Server.
[中]返回此服务器的配置。
代码示例来源:origin: line/armeria
/**
* Returns the {@link MeterRegistry} that collects various stats.
*/
public MeterRegistry meterRegistry() {
return config().meterRegistry();
}
代码示例来源:origin: line/armeria
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("config", config())
.add("activePorts", activePorts())
.add("state", startStop)
.toString();
}
代码示例来源:origin: line/armeria
@Override
public void serviceAdded(ServiceConfig cfg) {
if (maxInboundMessageSizeBytes == NO_MAX_INBOUND_MESSAGE_SIZE) {
maxInboundMessageSizeBytes = (int) Math.min(cfg.server().config().defaultMaxRequestLength(),
Integer.MAX_VALUE);
}
}
代码示例来源:origin: line/armeria
/**
* Returns the hostname of the default {@link VirtualHost}, which is the hostname of the machine unless
* configured explicitly via {@link ServerBuilder#defaultVirtualHost(VirtualHost)}.
*/
public String defaultHostname() {
return config().defaultVirtualHost().defaultHostname();
}
代码示例来源:origin: line/armeria
/**
* Returns a {@link EventLoop} from the worker group. This can be used for, e.g., scheduling background
* tasks for the lifetime of the {@link Server} using
* {@link EventLoop#scheduleAtFixedRate(Runnable, long, long, TimeUnit)}. It is very important that these
* tasks do not block as this would block all requests in the server on that {@link EventLoop}.
*/
public EventLoop nextEventLoop() {
return config().workerGroup().next();
}
代码示例来源:origin: line/armeria
void start() throws Exception {
boolean success = false;
try {
assert armeriaServer != null;
server = serverFactory.apply(armeriaServer.config().blockingTaskExecutor());
connector = new ArmeriaConnector(server);
server.addConnector(connector);
if (!server.isStarted()) {
logger.info("Starting an embedded Jetty: {}", server);
server.start();
startedServer = true;
} else {
startedServer = false;
}
success = true;
} finally {
if (!success) {
server = null;
connector = null;
}
}
}
代码示例来源:origin: line/armeria
private static ServiceConfig findServiceConfig(Server server, String path, Service<?, ?> service) {
for (ServiceConfig cfg : server.config().defaultVirtualHost().serviceConfigs()) {
final Optional<String> exactPath = cfg.pathMapping().exactPath();
if (!exactPath.isPresent()) {
continue;
}
if (!path.equals(exactPath.get())) {
continue;
}
if (cfg.service().as(service.getClass()).isPresent()) {
return cfg;
}
}
throw new Error(); // Never reaches here.
}
}
代码示例来源:origin: line/armeria
@Override
public void serverStarting(Server server) throws Exception {
final ServerConfig config = server.config();
final List<VirtualHost> virtualHosts = config.findVirtualHosts(DocService.this);
final List<ServiceConfig> services =
config.serviceConfigs().stream()
.filter(se -> virtualHosts.contains(se.virtualHost()))
.collect(toImmutableList());
ServiceSpecification spec = generate(services);
spec = addDocStrings(spec, services);
spec = addExamples(spec);
vfs(SPECIFICATION_INDEX).setContent(jsonMapper.writerWithDefaultPrettyPrinter()
.writeValueAsBytes(spec));
}
});
代码示例来源:origin: line/armeria
@Override
public ExecutorService blockingTaskExecutor() {
if (blockingTaskExecutor != null) {
return blockingTaskExecutor;
}
return blockingTaskExecutor = makeContextAware(server().config().blockingTaskExecutor());
}
代码示例来源:origin: line/armeria
private void setupServerMetrics() {
final MeterRegistry meterRegistry = config().meterRegistry();
final GracefulShutdownSupport gracefulShutdownSupport = this.gracefulShutdownSupport;
assert gracefulShutdownSupport != null;
meterRegistry.gauge("armeria.server.pendingResponses", gracefulShutdownSupport,
GracefulShutdownSupport::pendingResponses);
meterRegistry.gauge("armeria.server.connections", connectionLimitingHandler,
ConnectionLimitingHandler::numConnections);
}
代码示例来源:origin: line/armeria
@Override
protected CompletionStage<Void> doStart() {
if (config().gracefulShutdownQuietPeriod().isZero()) {
gracefulShutdownSupport = GracefulShutdownSupport.createDisabled();
} else {
gracefulShutdownSupport =
GracefulShutdownSupport.create(config().gracefulShutdownQuietPeriod(),
config().blockingTaskExecutor());
final List<ServerPort> ports = config().ports();
代码示例来源:origin: line/armeria
private RequestContextAwareLogger newLogger(ServiceConfig cfg) {
String loggerName = cfg.loggerName().orElse(null);
if (loggerName == null) {
loggerName = cfg.pathMapping().loggerName();
}
return new RequestContextAwareLogger(this, LoggerFactory.getLogger(
cfg.server().config().serviceLoggerPrefix() + '.' + loggerName));
}
代码示例来源:origin: line/armeria
final ServerConfig serverCfg = cfg.server().config();
requestTimeoutMillis = serverCfg.defaultRequestTimeoutMillis();
maxRequestLength = serverCfg.defaultMaxRequestLength();
代码示例来源:origin: line/armeria
private static Service<?, ?> service(ServerBuilder sb) {
final Server server = sb.build();
return server.config().defaultVirtualHost().serviceConfigs().get(0).service();
}
代码示例来源:origin: line/armeria
if (cause != null) {
final HttpResponse errorRes;
if (ctx.server().config().verboseResponses()) {
errorRes = HttpResponse.of(HttpStatus.INTERNAL_SERVER_ERROR,
MediaType.PLAIN_TEXT_UTF_8,
代码示例来源:origin: line/armeria
static HttpHeaders statusToTrailers(ServiceRequestContext ctx, Status status, boolean headersSent) {
final HttpHeaders trailers;
if (headersSent) {
// Normal trailers.
trailers = new DefaultHttpHeaders();
} else {
// Trailers only response
trailers = new DefaultHttpHeaders(true, 3, true)
.status(HttpStatus.OK)
.set(HttpHeaderNames.CONTENT_TYPE, "application/grpc+proto");
}
trailers.add(GrpcHeaderNames.GRPC_STATUS, Integer.toString(status.getCode().value()));
if (status.getDescription() != null) {
trailers.add(GrpcHeaderNames.GRPC_MESSAGE, StatusMessageEscaper.escape(status.getDescription()));
}
if (ctx.server().config().verboseResponses() && status.getCause() != null) {
final ThrowableProto proto = GrpcStatus.serializeThrowable(status.getCause());
trailers.add(GrpcHeaderNames.ARMERIA_GRPC_THROWABLEPROTO_BIN,
Base64.getEncoder().encodeToString(proto.toByteArray()));
}
return trailers;
}
代码示例来源:origin: line/armeria
appException = (TApplicationException) cause;
} else {
if (ctx.server().config().verboseResponses()) {
appException = new TApplicationException(
TApplicationException.INTERNAL_ERROR,
代码示例来源:origin: line/armeria
if (ctx.server().config().verboseResponses()) {
errorRes = HttpResponse.of(HttpStatus.BAD_REQUEST, MediaType.PLAIN_TEXT_UTF_8,
"Failed to decode a %s header: %s", serializationFormat,
代码示例来源:origin: line/armeria
server.config().defaultVirtualHost(),
localAddress().getHostString(),
path(),
代码示例来源:origin: com.linecorp.armeria/armeria-grpc
@Override
public void serviceAdded(ServiceConfig cfg) throws Exception {
if (maxInboundMessageSizeBytes == NO_MAX_INBOUND_MESSAGE_SIZE) {
maxInboundMessageSizeBytes = (int) cfg.server().config().defaultMaxRequestLength();
}
}
内容来源于网络,如有侵权,请联系作者删除!