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


Java HealthCheck.Result方法代码示例

本文整理汇总了Java中com.codahale.metrics.health.HealthCheck.Result方法的典型用法代码示例。如果您正苦于以下问题:Java HealthCheck.Result方法的具体用法?Java HealthCheck.Result怎么用?Java HealthCheck.Result使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.codahale.metrics.health.HealthCheck的用法示例。


在下文中一共展示了HealthCheck.Result方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: check

import com.codahale.metrics.health.HealthCheck; //导入方法依赖的package包/类
/**
 Health check

 @return 204 if healthy otherwise 500
 */
@GET
@Produces(MediaType.APPLICATION_JSON + "; charset=UTF-8")
@Path("check")
public Response check()
{
	for (HealthStatus healthCheck : m_healthCheckService.getChecks())
	{
		HealthCheck.Result result = healthCheck.execute();
		if (!result.isHealthy())
		{
			return setHeaders(Response.status(Response.Status.INTERNAL_SERVER_ERROR)).build();
		}
	}

	return setHeaders(Response.status(m_healthyResponse)).build();
}
 
开发者ID:quqiangsheng,项目名称:abhot,代码行数:22,代码来源:HealthCheckResource.java

示例2: status

import com.codahale.metrics.health.HealthCheck; //导入方法依赖的package包/类
/**
 Returns the status of each health check.

 @return 200
 */
@GET
@Produces(MediaType.APPLICATION_JSON + "; charset=UTF-8")
@Path("status")
public Response status()
{
	List<String> messages = new ArrayList<String>();
	for (HealthStatus healthCheck : m_healthCheckService.getChecks())
	{
		HealthCheck.Result result = healthCheck.execute();
		if (result.isHealthy())
		{
			messages.add(healthCheck.getName() + ": OK");
		}
		else
		{
			messages.add(healthCheck.getName() + ": FAIL");
		}
	}

	GenericEntity<List<String>> entity = new GenericEntity<List<String>>(messages)
	{
	};
	return setHeaders(Response.ok(entity)).build();
}
 
开发者ID:quqiangsheng,项目名称:abhot,代码行数:30,代码来源:HealthCheckResource.java

示例3: healthCheckHandler

import com.codahale.metrics.health.HealthCheck; //导入方法依赖的package包/类
public static Handler healthCheckHandler(
    HealthCheckRegistry healthCheckRegistry, ObjectMapper mapper) {
  Preconditions.checkState(healthCheckRegistry != null);
  Preconditions.checkState(mapper != null);

  SortedMap<String, HealthCheck.Result> healthChecks = healthCheckRegistry.runHealthChecks();

  return xrpcRequest ->
      Recipes.newResponseOk(
          xrpcRequest
              .getAlloc()
              .directBuffer()
              .writeBytes(
                  mapper.writerWithDefaultPrettyPrinter().writeValueAsBytes(healthChecks)),
          Recipes.ContentType.Application_Json);
}
 
开发者ID:Nordstrom,项目名称:xrpc,代码行数:17,代码来源:AdminHandlers.java

示例4: getHealth

import com.codahale.metrics.health.HealthCheck; //导入方法依赖的package包/类
@Override
public HealthCheck.Result getHealth() {
    try {
        HBaseAdmin.checkHBaseAvailable(configuration);

        return HealthCheck.Result.builder()
                .healthy()
                .withMessage("HBase running on:")
                .withDetail("quorum", quorum)
                .withDetail("clientPort", clientPort)
                .withDetail("znodeParent", znodeParent)
                .build();
    } catch (Exception e) {
        return HealthCheck.Result.builder()
                .unhealthy(e)
                .build();
    }
}
 
开发者ID:gchq,项目名称:stroom-stats,代码行数:19,代码来源:HBaseConnection.java

示例5: getHealth

import com.codahale.metrics.health.HealthCheck; //导入方法依赖的package包/类
@Override
public HealthCheck.Result getHealth() {
    HealthCheck.ResultBuilder builder = HealthCheck.Result.builder();
    long nonRunningProcessorCount = processors.stream()
            .filter(processor -> !processor.getRunState().equals(RunState.RUNNING))
            .count();
    if (!runState.equals(RunState.RUNNING) || nonRunningProcessorCount > 0) {
        builder.unhealthy();
    } else {
        builder.healthy();
    }
    builder.withDetail("runState", runState.name());
    builder.withDetail("processorCount", processors.size());
    builder.withDetail("processors", processors.stream()
            .collect(HasHealthCheck.buildTreeMapCollector(
                    StatisticsAggregationProcessor::getName,
                    StatisticsAggregationProcessor::produceHealthCheckSummary)));

    return builder.build();
}
 
开发者ID:gchq,项目名称:stroom-stats,代码行数:21,代码来源:StatisticsAggregationService.java

示例6: getHealth

import com.codahale.metrics.health.HealthCheck; //导入方法依赖的package包/类
@Override
public HealthCheck.Result getHealth() {
    switch (runState) {
        case RUNNING:
            return HealthCheck.Result.builder()
                    .healthy()
                    .withMessage(runState.toString())
                    .withDetail("status", produceHealthCheckSummary())
                    .build();
        default:
            return HealthCheck.Result.builder()
                    .unhealthy()
                    .withMessage(runState.toString())
                    .withDetail("status", produceHealthCheckSummary())
                    .build();
    }
}
 
开发者ID:gchq,项目名称:stroom-stats,代码行数:18,代码来源:StatisticsAggregationProcessor.java

示例7: getHealth

import com.codahale.metrics.health.HealthCheck; //导入方法依赖的package包/类
@Override
public HealthCheck.Result getHealth() {
    HealthCheck.ResultBuilder builder = HealthCheck.Result.builder();
    long nonRunningProcessorCount = processors.stream()
            .filter(processor -> !processor.getRunState().equals(RunState.RUNNING))
            .count();
    if (!runState.equals(RunState.RUNNING) || nonRunningProcessorCount > 0) {
        builder.unhealthy();
    } else {
        builder.healthy();
    }
    builder.withDetail("runState", runState.name());
    builder.withDetail("processorCount", processors.size());
    builder.withDetail("processors", processors.stream()
            .collect(HasHealthCheck.buildTreeMapCollector(
                    StatisticsFlatMappingProcessor::getName,
                    StatisticsFlatMappingProcessor::produceHealthCheckSummary)));

    return builder.build();
}
 
开发者ID:gchq,项目名称:stroom-stats,代码行数:21,代码来源:StatisticsFlatMappingService.java

示例8: testZkHealth

import com.codahale.metrics.health.HealthCheck; //导入方法依赖的package包/类
@Test
public void testZkHealth() throws Exception {
    final CuratorFramework client = newClient(zk.getConnectString(), new RetryOneTime(100));
    client.start();
    client.blockUntilConnected();

    final HealthCheck check = new ZookeeperHealthCheck(client);
    final HealthCheck.Result res = check.execute();
    assertFalse(res.isHealthy());
    assertEquals("Zookeeper not properly initialized", res.getMessage());

    client.createContainers(ZNODE_COORDINATION);

    final HealthCheck.Result res2 = check.execute();
    assertTrue(res2.isHealthy());
}
 
开发者ID:trellis-ldp,项目名称:trellis-rosid,代码行数:17,代码来源:ZookeeperHealthCheckTest.java

示例9: getHealth

import com.codahale.metrics.health.HealthCheck; //导入方法依赖的package包/类
@Override
public HealthCheck.Result getHealth() {
    if (stroomPropertyService == null) {
        return HealthCheck.Result.unhealthy("stroomPropertyService has not been initialised");
    } else {

        try {
            //use a treeMap so the props are sorted on output
            return HealthCheck.Result.builder()
                    .withMessage("Available")
                    .withDetail("properties", new TreeMap<>(stroomPropertyService.getAllProperties()))
                    .build();

        } catch (Exception e) {
            return HealthCheck.Result.unhealthy(e);
        }
    }
}
 
开发者ID:gchq,项目名称:stroom-stats,代码行数:19,代码来源:StroomPropertyServiceHealthCheck.java

示例10: healthCheckCommand

import com.codahale.metrics.health.HealthCheck; //导入方法依赖的package包/类
private String healthCheckCommand(IMessage message, OptionSet optionSet) {
    StringBuilder response = new StringBuilder();
    if (healthCheckRegistry.getNames().isEmpty()) {
        return "No health checks registered";
    }
    Map<String, HealthCheck.Result> resultMap = healthCheckRegistry.runHealthChecks();
    response.append("*Health check results*\n");
    for (Map.Entry<String, HealthCheck.Result> entry : resultMap.entrySet()) {
        HealthCheck.Result result = entry.getValue();
        String msg = result.getMessage();
        Throwable t = result.getError();
        response.append(result.isHealthy() ? "[Healthy]" : "[Caution]")
            .append(" **").append(entry.getKey()).append("** ")
            .append(msg != null ? msg : "")
            .append(t != null ? " and exception: *" + t.getMessage() + "*" : "").append("\n");
    }
    return response.toString();
}
 
开发者ID:quanticc,项目名称:ugc-bot-redux,代码行数:19,代码来源:MetricsPresenter.java

示例11: testHealthCheck

import com.codahale.metrics.health.HealthCheck; //导入方法依赖的package包/类
@Test
public void testHealthCheck() throws Exception {
    ArgumentCaptor<HealthCheck> captor = ArgumentCaptor.forClass(HealthCheck.class);
    verify(_healthChecks, atLeastOnce()).addHealthCheck(Matchers.anyString(), captor.capture());
    List<HealthCheck> healthChecks = captor.getAllValues();

    int numCassandraHealthChecks = 0;
    for (HealthCheck healthCheck : healthChecks) {
        if (healthCheck instanceof CassandraHealthCheck) {
            HealthCheck.Result result = healthCheck.execute();
            assertTrue(result.isHealthy(), result.getMessage());
            numCassandraHealthChecks++;
        }
    }
    assertEquals(numCassandraHealthChecks, 3);  // app, ugc, databus
}
 
开发者ID:bazaarvoice,项目名称:emodb,代码行数:17,代码来源:CasDatabusTest.java

示例12: healthCheck

import com.codahale.metrics.health.HealthCheck; //导入方法依赖的package包/类
@GET
@Path(HEALTHCHECK)
@Produces(APPLICATION_JSON)
public Response healthCheck() throws JsonProcessingException {
    SortedMap<String, HealthCheck.Result> results = environment.healthChecks().runHealthChecks();

    Map<String, Map<String, Object>> response = getResponse(results);

    boolean healthy = results.size() == results.values()
            .stream()
            .filter(HealthCheck.Result::isHealthy)
            .count();

    if(healthy) {
        return Response.ok().entity(response).build();
    }
    return status(503).entity(response).build();
}
 
开发者ID:alphagov,项目名称:pay-adminusers,代码行数:19,代码来源:HealthCheckResource.java

示例13: check

import com.codahale.metrics.health.HealthCheck; //导入方法依赖的package包/类
@Override
protected HealthCheck.Result check() throws Exception {
    return timeBoundHealthCheck.check(() -> {
        final EntityManager entityManager = entityManagerFactory.createEntityManager();
        try {
            final EntityTransaction entityTransaction = entityManager.getTransaction();
            entityTransaction.begin();
            try {
                entityManager.createNativeQuery(validationQuery).getResultList();
                entityTransaction.commit();
            } catch (Exception e) {
                if (entityTransaction.isActive()) {
                    entityTransaction.rollback();
                }
                throw e;
            }
        } finally {
            entityManager.close();
        }
        return Result.healthy();
    });
}
 
开发者ID:scottescue,项目名称:dropwizard-entitymanager,代码行数:23,代码来源:EntityManagerFactoryHealthCheck.java

示例14: healthCheck

import com.codahale.metrics.health.HealthCheck; //导入方法依赖的package包/类
@GET
@Path("healthcheck")
@Produces(APPLICATION_JSON)
public Response healthCheck() throws JsonProcessingException {
    SortedMap<String, HealthCheck.Result> results = environment.healthChecks().runHealthChecks();

    Map<String, Map<String, Boolean>> response = getResponse(results);

    boolean healthy = results.size() == results.values()
            .stream()
            .filter(HealthCheck.Result::isHealthy)
            .count();

    if (healthy) {
        return Response.ok().entity(response).build();
    }
    return status(503).entity(response).build();
}
 
开发者ID:alphagov,项目名称:pay-publicauth,代码行数:19,代码来源:HealthCheckResource.java

示例15: health

import com.codahale.metrics.health.HealthCheck; //导入方法依赖的package包/类
@RequestMapping(value = "/health", method = RequestMethod.GET)
public ModelAndView health(@RequestParam(required = false) String format,
                           HttpServletRequest request) {
    final SortedMap<String, HealthCheck.Result> results = runHealthChecks();
    List<VistaAccount> vistaAccounts = vistaAccountDao.findAll();

    List<Map> items = new ArrayList<>(results.size());
    for (Map.Entry<String, HealthCheck.Result> entry : results.entrySet()) {
        String displayName = messageSource.getMessage(entry.getKey(), null, entry.getKey(), request.getLocale());

        Map item = new HashMap();
        item.put("name", displayName);
        item.put("health", entry.getValue());
        if (entry.getKey().startsWith(VistaAccountHealthCheckRegistrar.VISTA_CONNECTION_HEALTH_PREFIX)) {
            String vistaId = entry.getKey().substring(VistaAccountHealthCheckRegistrar.VISTA_CONNECTION_HEALTH_PREFIX.length());
            VistaAccount account = findOneByVistaId(vistaAccounts, vistaId);
            if (account != null) {
                item.put("vista", account);
            }
        }
        items.add(item);
    }
    return ModelAndViewFactory.contentNegotiatingModelAndView(JsonCCollection.create(request, items));
}
 
开发者ID:KRMAssociatesInc,项目名称:eHMP,代码行数:25,代码来源:HealthCheckController.java


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