本文整理汇总了Java中com.yammer.dropwizard.config.Environment.addHealthCheck方法的典型用法代码示例。如果您正苦于以下问题:Java Environment.addHealthCheck方法的具体用法?Java Environment.addHealthCheck怎么用?Java Environment.addHealthCheck使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.yammer.dropwizard.config.Environment
的用法示例。
在下文中一共展示了Environment.addHealthCheck方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import com.yammer.dropwizard.config.Environment; //导入方法依赖的package包/类
@Override
public void run(ServiceConfiguration configuration, Environment environment) throws Exception {
try {
ZooKeeperConfiguration zkConfig = configuration.getZooKeeperConfiguration();
String zkHost = zkConfig.getHost();
String zkPort = zkConfig.getPort();
String zkHostPort = String.format("%s:%s", zkHost, zkPort);
LOG.info("Connecting to ZooKeeper " + zkHostPort);
zookeeper = new ZooKeeper(zkHostPort, 3000, new ZooKeeperMonitor());
} catch (IOException e) {
LOG.error(e.getMessage(), e);
}
environment.addHealthCheck(new ZooPeekerHealthCheck());
environment.addResource(new NodeResource(zookeeper));
}
示例2: run
import com.yammer.dropwizard.config.Environment; //导入方法依赖的package包/类
@Override
public void run(T configuration, Environment environment) throws Exception {
JedisConfiguration conf = getJedisConfiguration(configuration);
jedisPoolConfig = conf.poolConfig;
jedisPool = new JedisPool(jedisPoolConfig, conf.getHost(), conf.getPort());
environment.addHealthCheck(new JedisPoolHealthCheck("jedis-pool", jedisPool));
environment.manage(new Managed() {
@Override
public void start() throws Exception {
}
@Override
public void stop() throws Exception {
jedisPool.destroy();
}
});
environment.addProvider(new JedisPoolProvider(jedisPool));
}
示例3: run
import com.yammer.dropwizard.config.Environment; //导入方法依赖的package包/类
@Override
public void run(KayVeeConfiguration configuration, Environment environment) throws Exception {
// create the local store
LocalStore localStore = new LocalStore();
// create and setup the distributed store
RaftConfiguration raftConfiguration = createRaftConfiguration(configuration);
DistributedStore distributedStore = new DistributedStore(localStore);
RaftAgent raftAgent = RaftAgent.fromConfigurationObject(raftConfiguration, distributedStore); // create the agent
raftAgent.setupJacksonAnnotatedCommandSerializationAndDeserialization(KayVeeCommand.class); // setup the agent to deal with our Command subclasses
distributedStore.setRaftAgent(raftAgent);
distributedStore.initialize();
environment.manage(distributedStore);
// setup our health checks
environment.addHealthCheck(new DistributedStoreCheck(distributedStore));
// setup the resources by which kayvee is accessed
environment.addResource(new KeysResource(configuration.getClusterConfiguration().getMembers(), distributedStore));
// setup our exception mappers
environment.addProvider(IllegalArgumentExceptionMapper.class);
environment.addProvider(KayVeeExceptionMapper.class);
}
示例4: run
import com.yammer.dropwizard.config.Environment; //导入方法依赖的package包/类
@Override
public void run(final T configuration, final Environment environment)
{
final Iterable<Module> configedModules = configureModules(configuration, modules);
final DropwizardModule<T> dwModule = new DropwizardModule<T>(configuration, environment);
final Injector injector = parentInjector.or(Guice.createInjector())
.createChildInjector(Iterables.concat(of(dwModule), configedModules));
environment.addFilter(injector.getInstance(GuiceFilter.class), "*");
// Support Module definition of health checks
if (!injector.findBindingsByType(healthChecksKey.getTypeLiteral()).isEmpty()) {
final Set<HealthCheck> healthChecks = injector.getInstance(healthChecksKey);
for (HealthCheck hc : healthChecks) {
environment.addHealthCheck(hc);
}
}
}
示例5: run
import com.yammer.dropwizard.config.Environment; //导入方法依赖的package包/类
/**
* Establishes an environment and configures resources need to
* execute service. Optional service health checks.
*/
@Override
public void run(DataConfiguration configuration, Environment environment) {
final LensEndpoint restResource = new LensEndpoint();
environment.addResource(restResource);
/*final JsonLensEndpoint jsonResource = new JsonLensEndpoint();
environment.addResource(jsonResource);*/
// Application complains if health check not included. Can add more robust
// service tests later for more complete code base.
environment.addHealthCheck(new ServiceHealthCheck());
}
示例6: run
import com.yammer.dropwizard.config.Environment; //导入方法依赖的package包/类
@Override
public void run(SampleConfiguration configuration, Environment environment) {
overrideLogging();
Injector injector = Guice.createInjector();
environment.addResource(injector.getInstance(GadgetResource.class));
environment.addResource(injector.getInstance(StaticTypesResource.class));
environment.addResource(injector.getInstance(CustomHeadersResource.class));
environment.addResource(injector.getInstance(MultipartResource.class));
environment.addResource(injector.getInstance(BinaryStreamResource.class));
environment.addHealthCheck(injector.getInstance(SampleHealthCheck.class));
}
示例7: run
import com.yammer.dropwizard.config.Environment; //导入方法依赖的package包/类
@Override
public void run(final Config configuration, final Environment environment) {
environment.addHealthCheck(new Health());
BookResource br = new BookResource(hibernate.getSessionFactory());
environment.addResource(br);
}
示例8: run
import com.yammer.dropwizard.config.Environment; //导入方法依赖的package包/类
@Override
public void run(GreenfieldConfiguration configuration,
Environment environment) {
String template = configuration.getTemplate();
String defaultName = configuration.getDefaultName();
environment.addResource(new GreenfieldResource(template, defaultName));
environment.addHealthCheck(new GreenfieldHealthCheck(template));
}
示例9: run
import com.yammer.dropwizard.config.Environment; //导入方法依赖的package包/类
@Override
public void run(AppConfiguration configuration, Environment environment) throws Exception {
AXLPort axl = initAxlService(configuration.getCucm());
environment.manage(new CucmAxlService(axl));
environment.addProvider(new BasicAuthProvider<User>(new AppAuthenticator(configuration.getApiauth()), "PROTECTED"));
environment.addHealthCheck(new CucmAxlServiceHealthCheck(axl));
environment.addResource(new PhoneResource(axl));
environment.addResource(new SpeeddialsResource(axl));
}
示例10: run
import com.yammer.dropwizard.config.Environment; //导入方法依赖的package包/类
@Override
public void run(HelloWorldConfiguration configuration,
Environment environment) {
final String template = configuration.getTemplate();
final String defaultName = configuration.getDefaultName();
environment.addResource(new HelloWorldResource(template, defaultName));
environment.addHealthCheck(new TemplateHealthCheck(template));
}
示例11: run
import com.yammer.dropwizard.config.Environment; //导入方法依赖的package包/类
@Override public void run(Configuration config, Environment environment) {
// Suppress the "THIS SERVICE HAS NO HEALTHCHECKS" warning.
// A real service would have proper health checks.
environment.addHealthCheck(new FakeHealthCheck());
// Suppress the "ResourceConfig instance does not contain any root resource classes" error.
// A real service would probably provide a Jersey resource or two.
environment.addResource(EmptyResource.class);
// Here's the interesting part:
// Mount the Rack application defined in the config.ru file on the classpath at /rack.
environment.addServlet(createRackServlet(), "/rack/*");
}
示例12: run
import com.yammer.dropwizard.config.Environment; //导入方法依赖的package包/类
@Override
public void run(Configuration configuration, Environment environment) throws Exception {
environment.addResource(new PizzaResource());
environment.addHealthCheck(new PizzaHealthCheck());
environment.addProvider(new HmacAuthProvider<>(new DefaultRequestHandler<>(new PizzaAuthenticator())));
}
示例13: run
import com.yammer.dropwizard.config.Environment; //导入方法依赖的package包/类
@Override
public void run(LocateApiConfiguration configuration, Environment environment) throws Exception {
/**
* Mongo set up
*/
MongoClient mongoClient = configureMongoClient(environment, configuration.getMongoConfiguration());
DB locateDb = setUpDb(configuration.getMongoConfiguration().getLocateDatabase(), configuration.getMongoConfiguration(), mongoClient);
DB credentialsDb = setUpDb(configuration.getMongoConfiguration().getCredentialsDatabase(), configuration.getMongoConfiguration(), mongoClient);
/**
* Dao layer
*/
final AuthorizationTokenDao authorizationTokenDao = configureAuthorizationTokenDao(credentialsDb);
final UsageDao usageDao = configureRateMeterDao(credentialsDb);
final AddressDao addressDao = configureAddressDao(locateDb);
final PostcodeToAuthorityDao postcodeToAuthorityDao = configurePostcodeToAuthorityDao(locateDb);
/**
* Enable cors support
*/
environment.addFilter(CrossOriginFilter.class, "*")
.setInitParam("allowedOrigins", configuration.getAllowedOrigins())
.setInitParam("allowedHeaders", "X-Requested-With,Content-Type,Accept,Origin,Authorization")
.setInitParam("allowedMethods", "OPTIONS,GET");
/**
* Resources
*/
environment.addResource(new AddressResource(addressDao, configuration));
environment.addResource(new PostcodeToAuthorityResource(postcodeToAuthorityDao));
/**
* Healthchecks
*/
environment.addHealthCheck(new MongoHealthCheck(mongoClient));
/**
* Exception mapper
*/
environment.addProvider(new LocateExceptionMapper());
/**
* Authentication
*/
environment.addProvider(new BearerTokenAuthProvider(configuration, usageDao, new BearerTokenAuthenticator(authorizationTokenDao)));
/**
* Better exception mappings
*/
removeDefaultExceptionMappers(environment);
/**
* Date serialisation
*/
environment.getObjectMapperFactory().setDateFormat(internalDateFormatter);
/**
* Tasks
*/
environment.addTask(new MongoIndexTask(authorizationTokenDao, usageDao));
}
示例14: addMySQLHealthCheck
import com.yammer.dropwizard.config.Environment; //导入方法依赖的package包/类
private void addMySQLHealthCheck(Environment environment, Connection dbConnection) {
String healthCheckName = "mysql";
environment.addHealthCheck(new MySQLHealthCheck(healthCheckName, dbConnection));
}
示例15: addRedisHealthCheck
import com.yammer.dropwizard.config.Environment; //导入方法依赖的package包/类
private void addRedisHealthCheck(Environment environment, Jedis redisClient) {
String healthCheckName = "redis";
environment.addHealthCheck(new RedisHealthCheck(healthCheckName, redisClient));
}