当前位置: 首页>>代码示例>>Java>>正文


Java HealthCheck类代码示例

本文整理汇总了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());
}
 
开发者ID:Flipkart,项目名称:foxtrot,代码行数:17,代码来源:ClusterManager.java

示例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);
    }
}
 
开发者ID:Flipkart,项目名称:foxtrot,代码行数:20,代码来源:ClusterManager.java

示例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" +
                "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
        );
    }


}
 
开发者ID:twilio,项目名称:wiztowar,代码行数:28,代码来源:DWAdapter.java

示例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));
  }
}
 
开发者ID:kijiproject,项目名称:kiji-rest,代码行数:26,代码来源:ManagedKijiClient.java

示例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);
        }
    }

}
 
开发者ID:fizmo,项目名称:dropwizard-bundle-guice,代码行数:21,代码来源:GuiceBundle.java

示例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");
}
 
开发者ID:Flipkart,项目名称:foxtrot,代码行数:14,代码来源:ElasticSearchHealthCheck.java

示例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);
}
 
开发者ID:fizmo,项目名称:dropwizard-bundle-guice,代码行数:15,代码来源:TestGuiceBundle.java

示例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;
}
 
开发者ID:Flipkart,项目名称:foxtrot,代码行数:6,代码来源:ClusterManager.java

示例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, "/*");
}
 
开发者ID:Flipkart,项目名称:foxtrot,代码行数:58,代码来源:FoxtrotServer.java

示例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;
        }
 
开发者ID:Berico-Technologies,项目名称:Nagios-Dropwizard,代码行数:21,代码来源:TestService.java

示例11: getHealthChecks

import com.yammer.metrics.core.HealthCheck; //导入依赖的package包/类
@Override
public ImmutableSet<HealthCheck> getHealthChecks() {
    return super.getHealthChecks();
}
 
开发者ID:twilio,项目名称:wiztowar,代码行数:5,代码来源:ExtendedEnvironment.java

示例12: getHealthChecks

import com.yammer.metrics.core.HealthCheck; //导入依赖的package包/类
public Set<HealthCheck> getHealthChecks() {
    return environment.getHealthChecks();
}
 
开发者ID:yammer,项目名称:dropwizard-testing-integration,代码行数:4,代码来源:EnvironmentFriend.java

示例13: unRegisterHealthChecks

import com.yammer.metrics.core.HealthCheck; //导入依赖的package包/类
private void unRegisterHealthChecks() {
    for (HealthCheck healthCheck : startUpEnvironment.getHealthChecks()) {
        HealthChecks.defaultRegistry().unregister(healthCheck);
    }
}
 
开发者ID:yammer,项目名称:dropwizard-testing-integration,代码行数:6,代码来源:LifecycleServerCommand.java

示例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);
}
 
开发者ID:fizmo,项目名称:dropwizard-bundle-guice,代码行数:6,代码来源:TestGuiceBundle.java

示例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);
}
 
开发者ID:fizmo,项目名称:dropwizard-bundle-guice,代码行数:7,代码来源:GuiceBundleModule.java


注:本文中的com.yammer.metrics.core.HealthCheck类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。