com.linecorp.armeria.server.Server.config()方法的使用及代码示例

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

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

Server.config介绍

[英]Returns the configuration of this Server.
[中]返回此服务器的配置。

代码示例

代码示例来源:origin: line/armeria

  1. /**
  2. * Returns the {@link MeterRegistry} that collects various stats.
  3. */
  4. public MeterRegistry meterRegistry() {
  5. return config().meterRegistry();
  6. }

代码示例来源:origin: line/armeria

  1. @Override
  2. public String toString() {
  3. return MoreObjects.toStringHelper(this)
  4. .add("config", config())
  5. .add("activePorts", activePorts())
  6. .add("state", startStop)
  7. .toString();
  8. }

代码示例来源:origin: line/armeria

  1. @Override
  2. public void serviceAdded(ServiceConfig cfg) {
  3. if (maxInboundMessageSizeBytes == NO_MAX_INBOUND_MESSAGE_SIZE) {
  4. maxInboundMessageSizeBytes = (int) Math.min(cfg.server().config().defaultMaxRequestLength(),
  5. Integer.MAX_VALUE);
  6. }
  7. }

代码示例来源:origin: line/armeria

  1. /**
  2. * Returns the hostname of the default {@link VirtualHost}, which is the hostname of the machine unless
  3. * configured explicitly via {@link ServerBuilder#defaultVirtualHost(VirtualHost)}.
  4. */
  5. public String defaultHostname() {
  6. return config().defaultVirtualHost().defaultHostname();
  7. }

代码示例来源:origin: line/armeria

  1. /**
  2. * Returns a {@link EventLoop} from the worker group. This can be used for, e.g., scheduling background
  3. * tasks for the lifetime of the {@link Server} using
  4. * {@link EventLoop#scheduleAtFixedRate(Runnable, long, long, TimeUnit)}. It is very important that these
  5. * tasks do not block as this would block all requests in the server on that {@link EventLoop}.
  6. */
  7. public EventLoop nextEventLoop() {
  8. return config().workerGroup().next();
  9. }

代码示例来源:origin: line/armeria

  1. void start() throws Exception {
  2. boolean success = false;
  3. try {
  4. assert armeriaServer != null;
  5. server = serverFactory.apply(armeriaServer.config().blockingTaskExecutor());
  6. connector = new ArmeriaConnector(server);
  7. server.addConnector(connector);
  8. if (!server.isStarted()) {
  9. logger.info("Starting an embedded Jetty: {}", server);
  10. server.start();
  11. startedServer = true;
  12. } else {
  13. startedServer = false;
  14. }
  15. success = true;
  16. } finally {
  17. if (!success) {
  18. server = null;
  19. connector = null;
  20. }
  21. }
  22. }

代码示例来源:origin: line/armeria

  1. private static ServiceConfig findServiceConfig(Server server, String path, Service<?, ?> service) {
  2. for (ServiceConfig cfg : server.config().defaultVirtualHost().serviceConfigs()) {
  3. final Optional<String> exactPath = cfg.pathMapping().exactPath();
  4. if (!exactPath.isPresent()) {
  5. continue;
  6. }
  7. if (!path.equals(exactPath.get())) {
  8. continue;
  9. }
  10. if (cfg.service().as(service.getClass()).isPresent()) {
  11. return cfg;
  12. }
  13. }
  14. throw new Error(); // Never reaches here.
  15. }
  16. }

代码示例来源:origin: line/armeria

  1. @Override
  2. public void serverStarting(Server server) throws Exception {
  3. final ServerConfig config = server.config();
  4. final List<VirtualHost> virtualHosts = config.findVirtualHosts(DocService.this);
  5. final List<ServiceConfig> services =
  6. config.serviceConfigs().stream()
  7. .filter(se -> virtualHosts.contains(se.virtualHost()))
  8. .collect(toImmutableList());
  9. ServiceSpecification spec = generate(services);
  10. spec = addDocStrings(spec, services);
  11. spec = addExamples(spec);
  12. vfs(SPECIFICATION_INDEX).setContent(jsonMapper.writerWithDefaultPrettyPrinter()
  13. .writeValueAsBytes(spec));
  14. }
  15. });

代码示例来源:origin: line/armeria

  1. @Override
  2. public ExecutorService blockingTaskExecutor() {
  3. if (blockingTaskExecutor != null) {
  4. return blockingTaskExecutor;
  5. }
  6. return blockingTaskExecutor = makeContextAware(server().config().blockingTaskExecutor());
  7. }

代码示例来源:origin: line/armeria

  1. private void setupServerMetrics() {
  2. final MeterRegistry meterRegistry = config().meterRegistry();
  3. final GracefulShutdownSupport gracefulShutdownSupport = this.gracefulShutdownSupport;
  4. assert gracefulShutdownSupport != null;
  5. meterRegistry.gauge("armeria.server.pendingResponses", gracefulShutdownSupport,
  6. GracefulShutdownSupport::pendingResponses);
  7. meterRegistry.gauge("armeria.server.connections", connectionLimitingHandler,
  8. ConnectionLimitingHandler::numConnections);
  9. }

代码示例来源:origin: line/armeria

  1. @Override
  2. protected CompletionStage<Void> doStart() {
  3. if (config().gracefulShutdownQuietPeriod().isZero()) {
  4. gracefulShutdownSupport = GracefulShutdownSupport.createDisabled();
  5. } else {
  6. gracefulShutdownSupport =
  7. GracefulShutdownSupport.create(config().gracefulShutdownQuietPeriod(),
  8. config().blockingTaskExecutor());
  9. final List<ServerPort> ports = config().ports();

代码示例来源:origin: line/armeria

  1. private RequestContextAwareLogger newLogger(ServiceConfig cfg) {
  2. String loggerName = cfg.loggerName().orElse(null);
  3. if (loggerName == null) {
  4. loggerName = cfg.pathMapping().loggerName();
  5. }
  6. return new RequestContextAwareLogger(this, LoggerFactory.getLogger(
  7. cfg.server().config().serviceLoggerPrefix() + '.' + loggerName));
  8. }

代码示例来源:origin: line/armeria

  1. final ServerConfig serverCfg = cfg.server().config();
  2. requestTimeoutMillis = serverCfg.defaultRequestTimeoutMillis();
  3. maxRequestLength = serverCfg.defaultMaxRequestLength();

代码示例来源:origin: line/armeria

  1. private static Service<?, ?> service(ServerBuilder sb) {
  2. final Server server = sb.build();
  3. return server.config().defaultVirtualHost().serviceConfigs().get(0).service();
  4. }

代码示例来源:origin: line/armeria

  1. if (cause != null) {
  2. final HttpResponse errorRes;
  3. if (ctx.server().config().verboseResponses()) {
  4. errorRes = HttpResponse.of(HttpStatus.INTERNAL_SERVER_ERROR,
  5. MediaType.PLAIN_TEXT_UTF_8,

代码示例来源:origin: line/armeria

  1. static HttpHeaders statusToTrailers(ServiceRequestContext ctx, Status status, boolean headersSent) {
  2. final HttpHeaders trailers;
  3. if (headersSent) {
  4. // Normal trailers.
  5. trailers = new DefaultHttpHeaders();
  6. } else {
  7. // Trailers only response
  8. trailers = new DefaultHttpHeaders(true, 3, true)
  9. .status(HttpStatus.OK)
  10. .set(HttpHeaderNames.CONTENT_TYPE, "application/grpc+proto");
  11. }
  12. trailers.add(GrpcHeaderNames.GRPC_STATUS, Integer.toString(status.getCode().value()));
  13. if (status.getDescription() != null) {
  14. trailers.add(GrpcHeaderNames.GRPC_MESSAGE, StatusMessageEscaper.escape(status.getDescription()));
  15. }
  16. if (ctx.server().config().verboseResponses() && status.getCause() != null) {
  17. final ThrowableProto proto = GrpcStatus.serializeThrowable(status.getCause());
  18. trailers.add(GrpcHeaderNames.ARMERIA_GRPC_THROWABLEPROTO_BIN,
  19. Base64.getEncoder().encodeToString(proto.toByteArray()));
  20. }
  21. return trailers;
  22. }

代码示例来源:origin: line/armeria

  1. appException = (TApplicationException) cause;
  2. } else {
  3. if (ctx.server().config().verboseResponses()) {
  4. appException = new TApplicationException(
  5. TApplicationException.INTERNAL_ERROR,

代码示例来源:origin: line/armeria

  1. if (ctx.server().config().verboseResponses()) {
  2. errorRes = HttpResponse.of(HttpStatus.BAD_REQUEST, MediaType.PLAIN_TEXT_UTF_8,
  3. "Failed to decode a %s header: %s", serializationFormat,

代码示例来源:origin: line/armeria

  1. server.config().defaultVirtualHost(),
  2. localAddress().getHostString(),
  3. path(),

代码示例来源:origin: com.linecorp.armeria/armeria-grpc

  1. @Override
  2. public void serviceAdded(ServiceConfig cfg) throws Exception {
  3. if (maxInboundMessageSizeBytes == NO_MAX_INBOUND_MESSAGE_SIZE) {
  4. maxInboundMessageSizeBytes = (int) cfg.server().config().defaultMaxRequestLength();
  5. }
  6. }

相关文章