本文整理汇总了Java中com.yammer.metrics.core.HealthCheck类的典型用法代码示例。如果您正苦于以下问题:Java HealthCheck类的具体用法?Java HealthCheck怎么用?Java HealthCheck使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
HealthCheck类属于com.yammer.metrics.core包,在下文中一共展示了HealthCheck类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ClusterManager
import com.yammer.metrics.core.HealthCheck; //导入依赖的package包/类
public ClusterManager(HazelcastConnection connection,
List<HealthCheck> healthChecks,
HttpConfiguration httpConfiguration) throws Exception {
this.hazelcastConnection = connection;
this.healthChecks = healthChecks;
MapConfig mapConfig = new MapConfig(MAP_NAME);
mapConfig.setTimeToLiveSeconds(MAP_REFRESH_TIME + 2); //Reduce jitter
mapConfig.setBackupCount(1);
mapConfig.setAsyncBackupCount(2);
mapConfig.setEvictionPolicy(EvictionPolicy.NONE);
hazelcastConnection.getHazelcastConfig().getMapConfigs().put(MAP_NAME, mapConfig);
String hostname = Inet4Address.getLocalHost().getCanonicalHostName();
executor = Executors.newScheduledThreadPool(1);
clusterMember = new ClusterMember(hostname, httpConfiguration.getPort());
}
示例2: run
import com.yammer.metrics.core.HealthCheck; //导入依赖的package包/类
@Override
public void run() {
if (null == members) {
logger.error("Map not yet initialized.");
return;
}
try {
boolean isHealthy = true;
for (HealthCheck healthCheck : healthChecks) {
isHealthy &= healthCheck.execute().isHealthy();
}
if (isHealthy) {
members.put(clusterMember.toString(), clusterMember);
logger.debug("Service is healthy. Registering to map.");
}
} catch (Exception e) {
logger.error("Error updating value in map: ", e);
}
}
示例3: addHealthChecks
import com.yammer.metrics.core.HealthCheck; //导入依赖的package包/类
/**
* This method is adapted from ServerFactory.buildServer.
*
* @param env the {@link ExtendedEnvironment} to get {@link HealthCheck}s from.
*/
private void addHealthChecks(ExtendedEnvironment env) {
HealthChecks.defaultRegistry().register(new DeadlockHealthCheck());
for (HealthCheck healthCheck : env.getHealthChecks()) {
HealthChecks.defaultRegistry().register(healthCheck);
}
if (env.getHealthChecks().isEmpty()) {
logger.warn('\n' +
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" +
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" +
"! THIS SERVICE HAS NO HEALTHCHECKS. THIS MEANS YOU WILL NEVER KNOW IF IT !\n" +
"! DIES IN PRODUCTION, WHICH MEANS YOU WILL NEVER KNOW IF YOU'RE LETTING !\n" +
"! YOUR USERS DOWN. YOU SHOULD ADD A HEALTHCHECK FOR EACH DEPENDENCY OF !\n" +
"! YOUR SERVICE WHICH FULLY (BUT LIGHTLY) TESTS YOUR SERVICE'S ABILITY TO !\n" +
"! USE THAT SERVICE. THINK OF IT AS A CONTINUOUS INTEGRATION TEST. !\n" +
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" +
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
);
}
}
示例4: checkHealth
import com.yammer.metrics.core.HealthCheck; //导入依赖的package包/类
/**
* Check whether this KijiClient is healthy.
*
* @return health status of the KijiClient.
*/
public HealthCheck.Result checkHealth() {
final State state = mState.get();
Preconditions.checkState(state == State.STARTED,
"Can not check health while in state %s.", state);
List<String> issues = Lists.newArrayList();
if (mZKFramework.getState() != CuratorFrameworkState.STARTED) {
issues.add(String.format("ZooKeeper connection in unhealthy state %s.",
mZKFramework.getState()));
}
for (KijiInstanceCache instanceCache : mInstanceCaches.asMap().values()) {
issues.addAll(instanceCache.checkHealth());
}
if (issues.isEmpty()) {
return HealthCheck.Result.healthy();
} else {
return HealthCheck.Result.unhealthy(Joiner.on('\n').join(issues));
}
}
示例5: run
import com.yammer.metrics.core.HealthCheck; //导入依赖的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);
}
}
}
示例6: check
import com.yammer.metrics.core.HealthCheck; //导入依赖的package包/类
@Override
protected HealthCheck.Result check() throws Exception {
ClusterHealthResponse response = elasticsearchConnection
.getClient()
.admin()
.cluster()
.prepareHealth()
.execute()
.actionGet();
return (response.getStatus().name().equalsIgnoreCase("GREEN")
|| response.getStatus().name().equalsIgnoreCase("YELLOW"))
? HealthCheck.Result.healthy() : HealthCheck.Result.unhealthy("Cluster unhealthy");
}
示例7: TestHealthChecks
import com.yammer.metrics.core.HealthCheck; //导入依赖的package包/类
@Test
public void TestHealthChecks() throws Exception {
ConfiguredBundle<TestConfig> bundle = new GuiceBundle.Builder()
.withModules(new RootResourceModule(), new HealthCheckModule()).build();
Environment environment = mock(Environment.class);
runContainer(bundle, environment);
ArgumentCaptor<HealthCheck> captor = ArgumentCaptor.forClass(HealthCheck.class);
verify(environment).addHealthCheck(captor.capture());
assertTrue(captor.getValue() instanceof TestHealthCheck);
}
示例8: NodeDataUpdater
import com.yammer.metrics.core.HealthCheck; //导入依赖的package包/类
private NodeDataUpdater(List<HealthCheck> healthChecks, IMap<String, ClusterMember> members, ClusterMember clusterMember) {
this.healthChecks = ImmutableList.copyOf(healthChecks);
this.members = members;
this.clusterMember = clusterMember;
}
示例9: run
import com.yammer.metrics.core.HealthCheck; //导入依赖的package包/类
@Override
public void run(FoxtrotServerConfiguration configuration, Environment environment) throws Exception {
configuration.getHttpConfiguration().setRootPath("/foxtrot/*");
configureObjectMapper(environment);
ObjectMapper objectMapper = environment.getObjectMapperFactory().build();
ExecutorService executorService = environment.managedExecutorService("query-executor-%s", 20, 40, 30, TimeUnit.SECONDS);
HbaseTableConnection HBaseTableConnection = new HbaseTableConnection(configuration.getHbase());
ElasticsearchConnection elasticsearchConnection = new ElasticsearchConnection(configuration.getElasticsearch());
HazelcastConnection hazelcastConnection = new HazelcastConnection(configuration.getCluster());
ElasticsearchUtils.setTableNamePrefix(configuration.getElasticsearch());
TableMetadataManager tableMetadataManager = new DistributedTableMetadataManager(hazelcastConnection, elasticsearchConnection);
DataStore dataStore = new HBaseDataStore(HBaseTableConnection,
objectMapper, new DocumentTranslator(configuration.getHbase()));
QueryStore queryStore = new ElasticsearchQueryStore(tableMetadataManager, elasticsearchConnection, dataStore, objectMapper);
FoxtrotTableManager tableManager = new FoxtrotTableManager(tableMetadataManager, queryStore, dataStore);
CacheManager cacheManager = new CacheManager(new DistributedCacheFactory(hazelcastConnection, objectMapper));
AnalyticsLoader analyticsLoader = new AnalyticsLoader(tableMetadataManager, dataStore, queryStore, elasticsearchConnection, cacheManager, objectMapper);
QueryExecutor executor = new QueryExecutor(analyticsLoader, executorService);
DataDeletionManagerConfig dataDeletionManagerConfig = configuration.getTableDataManagerConfig();
DataDeletionManager dataDeletionManager = new DataDeletionManager(dataDeletionManagerConfig, queryStore);
List<HealthCheck> healthChecks = new ArrayList<>();
healthChecks.add(new ElasticSearchHealthCheck("ES Health Check", elasticsearchConnection));
ClusterManager clusterManager = new ClusterManager(hazelcastConnection, healthChecks, configuration.getHttpConfiguration());
environment.manage(HBaseTableConnection);
environment.manage(elasticsearchConnection);
environment.manage(hazelcastConnection);
environment.manage(tableMetadataManager);
environment.manage(analyticsLoader);
environment.manage(dataDeletionManager);
environment.manage(clusterManager);
environment.addResource(new DocumentResource(queryStore));
environment.addResource(new AsyncResource(cacheManager));
environment.addResource(new AnalyticsResource(executor));
environment.addResource(new TableManagerResource(tableManager));
environment.addResource(new TableFieldMappingResource(queryStore));
environment.addResource(new ConsoleResource(
new ElasticsearchConsolePersistence(elasticsearchConnection, objectMapper)));
FqlEngine fqlEngine = new FqlEngine(tableMetadataManager, queryStore, executor, objectMapper);
environment.addResource(new FqlResource(fqlEngine));
environment.addResource(new ClusterInfoResource(clusterManager));
environment.addResource(new UtilResource(configuration));
environment.addResource(new ClusterHealthResource(queryStore));
healthChecks.forEach(environment::addHealthCheck);
environment.addProvider(new FoxtrotExceptionMapper());
environment.addProvider(new FlatResponseTextProvider());
environment.addProvider(new FlatResponseCsvProvider());
environment.addProvider(new FlatResponseErrorTextProvider());
environment.addFilter(CrossOriginFilter.class, "/*");
}
示例10: getWrappedCheckTasks
import com.yammer.metrics.core.HealthCheck; //导入依赖的package包/类
public List<HealthCheck> getWrappedCheckTasks(){
List<HealthCheck> tasks = Lists.newArrayList();
for (String clazz : wrappedCheckTasks){
try {
NagiosCheckTask task = (NagiosCheckTask) Class.forName(clazz).newInstance();
tasks.add(new HealthCheckWrapper(task));
} catch (Exception e) {
e.printStackTrace();
}
}
return tasks;
}
示例11: getHealthChecks
import com.yammer.metrics.core.HealthCheck; //导入依赖的package包/类
@Override
public ImmutableSet<HealthCheck> getHealthChecks() {
return super.getHealthChecks();
}
示例12: getHealthChecks
import com.yammer.metrics.core.HealthCheck; //导入依赖的package包/类
public Set<HealthCheck> getHealthChecks() {
return environment.getHealthChecks();
}
示例13: unRegisterHealthChecks
import com.yammer.metrics.core.HealthCheck; //导入依赖的package包/类
private void unRegisterHealthChecks() {
for (HealthCheck healthCheck : startUpEnvironment.getHealthChecks()) {
HealthChecks.defaultRegistry().unregister(healthCheck);
}
}
示例14: configure
import com.yammer.metrics.core.HealthCheck; //导入依赖的package包/类
@Override
protected void configure() {
final Multibinder<HealthCheck> multibinder = Multibinder.newSetBinder(binder(), HealthCheck.class);
multibinder.addBinding().to(TestHealthCheck.class);
}
示例15: configure
import com.yammer.metrics.core.HealthCheck; //导入依赖的package包/类
@Override
protected void configure() {
bind(GuiceBundleResource.class);
final Multibinder<HealthCheck> multibinder = Multibinder.newSetBinder(binder(), HealthCheck.class);
multibinder.addBinding().to(GuiceBundleHealthCheck.class);
}