Search in sources :

Example 1 with StartupConfigHandler

use of com.hotels.styx.admin.handlers.StartupConfigHandler in project styx by ExpediaGroup.

the class AdminServerBuilder method adminEndpoints.

private HttpHandler adminEndpoints(StyxConfig styxConfig, StartupConfig startupConfig) {
    Optional<Duration> metricsCacheExpiration = styxConfig.adminServerConfig().metricsCacheExpiration();
    AdminHttpRouter httpRouter = new AdminHttpRouter();
    httpRouter.aggregate("/", new IndexHandler(indexLinkPaths(styxConfig)));
    httpRouter.aggregate("/version.txt", new VersionTextHandler(styxConfig.versionFiles(startupConfig)));
    httpRouter.aggregate("/admin", new IndexHandler(indexLinkPaths(styxConfig)));
    httpRouter.aggregate("/admin/uptime", new UptimeHandler(environment.meterRegistry()));
    httpRouter.aggregate("/admin/ping", new PingHandler());
    httpRouter.aggregate("/admin/threads", new ThreadsHandler());
    httpRouter.aggregate("/admin/current_requests", new CurrentRequestsHandler(CurrentRequestTracker.INSTANCE));
    MetricsHandler metricsHandler = new MetricsHandler(environment.metricRegistry(), metricsCacheExpiration);
    httpRouter.aggregate("/admin/metrics", metricsHandler);
    httpRouter.aggregate("/admin/metrics/", metricsHandler);
    httpRouter.aggregate("/admin/configuration", new StyxConfigurationHandler(configuration));
    httpRouter.aggregate("/admin/jvm", new JVMMetricsHandler(environment.metricRegistry(), metricsCacheExpiration));
    httpRouter.aggregate("/admin/configuration/logging", new LoggingConfigurationHandler(startupConfig.logConfigLocation()));
    httpRouter.aggregate("/admin/configuration/startup", new StartupConfigHandler(startupConfig));
    RoutingObjectHandler routingObjectHandler = new RoutingObjectHandler(routeDatabase, routingObjectFactoryContext);
    httpRouter.aggregate("/admin/routing", routingObjectHandler);
    httpRouter.aggregate("/admin/routing/", routingObjectHandler);
    ServiceProviderHandler serviceProvideHandler = new ServiceProviderHandler(providerDatabase);
    httpRouter.aggregate("/admin/service/providers", serviceProvideHandler);
    httpRouter.aggregate("/admin/service/provider/", serviceProvideHandler);
    if (configVersion(styxConfig) == ROUTING_CONFIG_V1) {
        httpRouter.aggregate("/admin/dashboard/data.json", dashboardDataHandler(styxConfig));
        httpRouter.aggregate("/admin/dashboard/", new ClassPathResourceHandler("/admin/dashboard/"));
    }
    // Replace them in the backwards compatibility mode only.
    // Remove altogether when Routing Engine is enabled:
    httpRouter.aggregate("/admin/origins/status", new OriginsInventoryHandler(environment.eventBus()));
    httpRouter.aggregate("/admin/configuration/origins", new OriginsHandler(backendServicesRegistry));
    httpRouter.aggregate("/admin/tasks/origins/reload", new HttpMethodFilteringHandler(POST, new OriginsReloadCommandHandler(backendServicesRegistry)));
    httpRouter.aggregate("/admin/tasks/origins", new HttpMethodFilteringHandler(POST, new OriginsCommandHandler(environment.eventBus())));
    httpRouter.aggregate("/admin/tasks/plugin/", new PluginToggleHandler(environment.plugins()));
    // Plugins Handler
    environment.plugins().forEach(namedPlugin -> {
        extensionEndpoints("plugins", namedPlugin.name(), namedPlugin.adminInterfaceHandlers()).forEach(route -> httpRouter.stream(route.path(), route.handler()));
    });
    httpRouter.aggregate("/admin/plugins", new PluginListHandler(environment.plugins()));
    ProviderRoutingHandler providerHandler = new ProviderRoutingHandler("/admin/providers", providerDatabase);
    httpRouter.aggregate("/admin/providers", providerHandler);
    httpRouter.aggregate("/admin/providers/", providerHandler);
    ProviderRoutingHandler serverHandler = new ProviderRoutingHandler("/admin/servers", serverDatabase);
    httpRouter.aggregate("/admin/servers", serverHandler);
    httpRouter.aggregate("/admin/servers/", serverHandler);
    Optional<PrometheusMeterRegistry> optPrometheus = Optional.ofNullable(findRegistry(environment.meterRegistry().micrometerRegistry(), PrometheusMeterRegistry.class));
    if (optPrometheus.isPresent()) {
        httpRouter.aggregate("/metrics", new PrometheusHandler(optPrometheus.get()));
    } else {
        LOG.warn("No PrometheusMeterRegistry present, so we cannot publish to prometheus.");
    }
    return httpRouter;
}
Also used : OriginsInventoryHandler(com.hotels.styx.admin.handlers.OriginsInventoryHandler) OriginsHandler(com.hotels.styx.admin.handlers.OriginsHandler) PrometheusHandler(com.hotels.styx.admin.handlers.PrometheusHandler) PingHandler(com.hotels.styx.admin.handlers.PingHandler) StartupConfigHandler(com.hotels.styx.admin.handlers.StartupConfigHandler) VersionTextHandler(com.hotels.styx.admin.handlers.VersionTextHandler) ProviderRoutingHandler(com.hotels.styx.admin.handlers.ProviderRoutingHandler) HttpMethodFilteringHandler(com.hotels.styx.common.http.handler.HttpMethodFilteringHandler) ThreadsHandler(com.hotels.styx.admin.handlers.ThreadsHandler) IndexHandler(com.hotels.styx.admin.handlers.IndexHandler) UptimeHandler(com.hotels.styx.admin.handlers.UptimeHandler) OriginsReloadCommandHandler(com.hotels.styx.admin.tasks.OriginsReloadCommandHandler) RoutingObjectHandler(com.hotels.styx.admin.handlers.RoutingObjectHandler) MetricsHandler(com.hotels.styx.admin.handlers.MetricsHandler) JVMMetricsHandler(com.hotels.styx.admin.handlers.JVMMetricsHandler) OriginsCommandHandler(com.hotels.styx.admin.tasks.OriginsCommandHandler) ClassPathResourceHandler(com.hotels.styx.server.handlers.ClassPathResourceHandler) PrometheusMeterRegistry(io.micrometer.prometheus.PrometheusMeterRegistry) Duration(java.time.Duration) JVMMetricsHandler(com.hotels.styx.admin.handlers.JVMMetricsHandler) AdminHttpRouter(com.hotels.styx.server.AdminHttpRouter) LoggingConfigurationHandler(com.hotels.styx.admin.handlers.LoggingConfigurationHandler) ServiceProviderHandler(com.hotels.styx.admin.handlers.ServiceProviderHandler) PluginToggleHandler(com.hotels.styx.admin.handlers.PluginToggleHandler) PluginListHandler(com.hotels.styx.admin.handlers.PluginListHandler) StyxConfigurationHandler(com.hotels.styx.admin.handlers.StyxConfigurationHandler) CurrentRequestsHandler(com.hotels.styx.admin.handlers.CurrentRequestsHandler)

Aggregations

CurrentRequestsHandler (com.hotels.styx.admin.handlers.CurrentRequestsHandler)1 IndexHandler (com.hotels.styx.admin.handlers.IndexHandler)1 JVMMetricsHandler (com.hotels.styx.admin.handlers.JVMMetricsHandler)1 LoggingConfigurationHandler (com.hotels.styx.admin.handlers.LoggingConfigurationHandler)1 MetricsHandler (com.hotels.styx.admin.handlers.MetricsHandler)1 OriginsHandler (com.hotels.styx.admin.handlers.OriginsHandler)1 OriginsInventoryHandler (com.hotels.styx.admin.handlers.OriginsInventoryHandler)1 PingHandler (com.hotels.styx.admin.handlers.PingHandler)1 PluginListHandler (com.hotels.styx.admin.handlers.PluginListHandler)1 PluginToggleHandler (com.hotels.styx.admin.handlers.PluginToggleHandler)1 PrometheusHandler (com.hotels.styx.admin.handlers.PrometheusHandler)1 ProviderRoutingHandler (com.hotels.styx.admin.handlers.ProviderRoutingHandler)1 RoutingObjectHandler (com.hotels.styx.admin.handlers.RoutingObjectHandler)1 ServiceProviderHandler (com.hotels.styx.admin.handlers.ServiceProviderHandler)1 StartupConfigHandler (com.hotels.styx.admin.handlers.StartupConfigHandler)1 StyxConfigurationHandler (com.hotels.styx.admin.handlers.StyxConfigurationHandler)1 ThreadsHandler (com.hotels.styx.admin.handlers.ThreadsHandler)1 UptimeHandler (com.hotels.styx.admin.handlers.UptimeHandler)1 VersionTextHandler (com.hotels.styx.admin.handlers.VersionTextHandler)1 OriginsCommandHandler (com.hotels.styx.admin.tasks.OriginsCommandHandler)1