@Override public final void run(T configuration, Environment environment) throws Exception { final PooledDataSourceFactory dbConfig = getDataSourceFactory(configuration); this.sessionFactory = requireNonNull(sessionFactoryFactory.build(this, environment, dbConfig, entities, name())); registerUnitOfWorkListenerIfAbsent(environment).registerSessionFactory(name(), sessionFactory); environment.healthChecks().register(name(), new SessionFactoryHealthCheck( environment.getHealthCheckExecutorService(), dbConfig.getValidationQueryTimeout().orElse(Duration.seconds(5)), sessionFactory, dbConfig.getValidationQuery())); }
@Override public void run(Configuration configuration, Environment environment) { final SimpleServerFactory serverConfig = new SimpleServerFactory(); configuration.setServerFactory(serverConfig); final HttpConnectorFactory connectorConfig = (HttpConnectorFactory) serverConfig.getConnector(); connectorConfig.setPort(0); environment.healthChecks().register("dummy", new DummyHealthCheck()); for (Object resource : resources) { if (resource instanceof Class<?>) { environment.jersey().register((Class<?>) resource); } else { environment.jersey().register(resource); } } } }
environment.healthChecks().register("docker", dockerHealthChecker); environment.healthChecks().register("zookeeper", zkHealthChecker); environment.healthChecks().register("dockerd", dockerDaemonHealthChecker); environment.healthChecks().getNames().forEach( name -> environment.metrics().register( "helios." + name + ".ok", new HealthCheckGauge(environment.healthChecks(), name))); new TotalHealthCheckGauge(environment.healthChecks()));
environment.healthChecks().register("graphhopper-storage", new GraphHopperStorageHealthCheck(graphHopperStorage));
environment.healthChecks().register(name, new JdbiHealthCheck( environment.getHealthCheckExecutorService(), configuration.getValidationQueryTimeout().orElseGet(() -> Duration.seconds(5)),
environment.getAdminContext(), environment.metrics(), environment.healthChecks());
@Override public Server build(Environment environment) { printBanner(environment.getName()); final ThreadPool threadPool = createThreadPool(environment.metrics()); final Server server = buildServer(environment.lifecycle(), threadPool); final Handler applicationHandler = createAppServlet(server, environment.jersey(), environment.getObjectMapper(), environment.getValidator(), environment.getApplicationContext(), environment.getJerseyServletContainer(), environment.metrics()); final Handler adminHandler = createAdminServlet(server, environment.getAdminContext(), environment.metrics(), environment.healthChecks()); final RoutingHandler routingHandler = buildRoutingHandler(environment.metrics(), server, applicationHandler, adminHandler); final Handler gzipHandler = buildGzipHandler(routingHandler); server.setHandler(addStatsHandler(addRequestLog(server, gzipHandler, environment.getName()))); return server; }
new ZooKeeperHealthChecker(zooKeeperClient); environment.healthChecks().register("zookeeper", zooKeeperHealthChecker); environment.healthChecks().getNames().forEach( name -> environment.metrics().register( "helios." + name + ".ok", new HealthCheckGauge(environment.healthChecks(), name)));
environment.healthChecks().register(name, new DBIHealthCheck( environment.getHealthCheckExecutorService(), configuration.getValidationQueryTimeout().orElseGet(() -> Duration.seconds(5)),
private void runRegularGraphHopper(CmdArgs configuration, Environment environment) { final GraphHopperManaged graphHopperManaged = new GraphHopperManaged(configuration, environment.getObjectMapper()); environment.lifecycle().manage(graphHopperManaged); environment.jersey().register(new AbstractBinder() { @Override protected void configure() { bind(configuration).to(CmdArgs.class); bind(graphHopperManaged).to(GraphHopperManaged.class); bind(graphHopperManaged.getGraphHopper()).to(GraphHopper.class); bind(graphHopperManaged.getGraphHopper()).to(GraphHopperAPI.class); bindFactory(HasElevation.class).to(Boolean.class).named("hasElevation"); bindFactory(LocationIndexFactory.class).to(LocationIndex.class); bindFactory(TranslationMapFactory.class).to(TranslationMap.class); bindFactory(EncodingManagerFactory.class).to(EncodingManager.class); bindFactory(GraphHopperStorageFactory.class).to(GraphHopperStorage.class); bindFactory(RasterHullBuilderFactory.class).to(DelaunayTriangulationIsolineBuilder.class); } }); if (configuration.getBool("web.change_graph.enabled", false)) { environment.jersey().register(ChangeGraphResource.class); } environment.jersey().register(NearestResource.class); environment.jersey().register(RouteResource.class); environment.jersey().register(IsochroneResource.class); environment.jersey().register(I18NResource.class); environment.jersey().register(InfoResource.class); environment.healthChecks().register("graphhopper", new GraphHopperHealthCheck(graphHopperManaged.getGraphHopper())); }
@Override public void run(HelloWorldConfiguration configuration, Environment environment) { final PersonDAO dao = new PersonDAO(hibernateBundle.getSessionFactory()); final Template template = configuration.buildTemplate(); environment.healthChecks().register("template", new TemplateHealthCheck(template)); environment.admin().addTask(new EchoTask()); environment.jersey().register(DateRequiredFeature.class); environment.jersey().register(new AuthDynamicFeature(new BasicCredentialAuthFilter.Builder<User>() .setAuthenticator(new ExampleAuthenticator()) .setAuthorizer(new ExampleAuthorizer()) .setRealm("SUPER SECRET STUFF") .buildAuthFilter())); environment.jersey().register(new AuthValueFactoryProvider.Binder<>(User.class)); environment.jersey().register(RolesAllowedDynamicFeature.class); environment.jersey().register(new HelloWorldResource(template)); environment.jersey().register(new ViewResource()); environment.jersey().register(new ProtectedResource()); environment.jersey().register(new PeopleResource(dao)); environment.jersey().register(new PersonResource(dao)); environment.jersey().register(new FilteredResource()); } }
environment.healthChecks().register("directory", new RedisHealthCheck(directoryClient)); environment.healthChecks().register("cache", new RedisHealthCheck(cacheClient));
environment.getAdminContext(), environment.metrics(), environment.healthChecks());
@Override public Server build(Environment environment) { printBanner(environment.getName()); final ThreadPool threadPool = createThreadPool(environment.metrics()); final Server server = buildServer(environment.lifecycle(), threadPool); final Handler applicationHandler = createAppServlet(server, environment.jersey(), environment.getObjectMapper(), environment.getValidator(), environment.getApplicationContext(), environment.getJerseyServletContainer(), environment.metrics()); final Handler adminHandler = createAdminServlet(server, environment.getAdminContext(), environment.metrics(), environment.healthChecks()); final RoutingHandler routingHandler = buildRoutingHandler(environment.metrics(), server, applicationHandler, adminHandler); final Handler gzipHandler = buildGzipHandler(routingHandler); server.setHandler(addStatsHandler(addRequestLog(server, gzipHandler, environment.getName()))); return server; }
@Override public void run(Configuration configuration, Environment environment) { final SimpleServerFactory serverConfig = new SimpleServerFactory(); configuration.setServerFactory(serverConfig); final HttpConnectorFactory connectorConfig = (HttpConnectorFactory) serverConfig.getConnector(); connectorConfig.setPort(0); environment.healthChecks().register("dummy", new DummyHealthCheck()); for (Object resource : resources) { if (resource instanceof Class<?>) { environment.jersey().register((Class<?>) resource); } else { environment.jersey().register(resource); } } } }
@Override public void run(MacroBaseConf configuration, Environment environment) throws Exception { configuration.loadSystemProperties(); environment.healthChecks().register("basic", new HealthCheck() { @Override protected Result check() throws Exception { return null; } }); } }
@Override public void unregister(ApplicationEntity appEntity) { if (environment == null) { LOG.warn("Environment is null, can not unregister"); return; } this.environment.healthChecks().unregister(appEntity.getAppId()); synchronized (lock) { appHealthChecks.remove(appEntity.getAppId()); } LOG.info("Successfully unregister health check for {}", appEntity.getAppId()); }
/** * Detect {@link HealthCheck} components. */ private void detectHealthChecks(final Environment environment) { for (BeanEntry<Named, HealthCheck> entry : locate(HealthCheck.class, Named.class)) { String name = entry.getKey().value(); HealthCheck component = entry.getValue(); environment.healthChecks().register(name, component); log.debug("Added health-check: {} -> {}", name, component); } }
@Override public void install(final Environment environment, final NamedHealthCheck instance) { environment.healthChecks().register(instance.getName(), instance); reporter.line("%-10s (%s)", instance.getName(), FeatureUtils.getInstanceClass(instance).getName()); }
public static ManagedAwsS3ClientStorage buildStorage(RequestLogUploadConfiguration uploadConfiguration, Environment environment, Map<String,String> propertyOverrides) { ManagedAwsS3ClientStorage storage = new ManagedAwsS3ClientStorage(uploadConfiguration.getAWSCredentialsProvider().getCredentials()); environment.lifecycle().manage(storage); environment.healthChecks().register("Amazon S3",storage.healthCheck()); return storage; }