This commit is contained in:
Stephane Nicoll 2017-12-14 17:06:46 +01:00
parent 132467787c
commit 27922ae325
3 changed files with 17 additions and 25 deletions

View File

@ -48,21 +48,16 @@ public class CassandraHealthIndicator extends AbstractHealthIndicator {
@Override
protected void doHealthCheck(Health.Builder builder) throws Exception {
try {
Select select = QueryBuilder.select("release_version").from("system",
"local");
ResultSet results = this.cassandraOperations.getCqlOperations()
.queryForResultSet(select);
if (results.isExhausted()) {
builder.up();
return;
}
String version = results.one().getString(0);
builder.up().withDetail("version", version);
}
catch (Exception ex) {
builder.down(ex);
Select select = QueryBuilder.select("release_version").from("system",
"local");
ResultSet results = this.cassandraOperations.getCqlOperations()
.queryForResultSet(select);
if (results.isExhausted()) {
builder.up();
return;
}
String version = results.one().getString(0);
builder.up().withDetail("version", version);
}
}

View File

@ -108,16 +108,11 @@ public class DataSourceHealthIndicator extends AbstractHealthIndicator
builder.up().withDetail("database", product);
String validationQuery = getValidationQuery(product);
if (StringUtils.hasText(validationQuery)) {
try {
// Avoid calling getObject as it breaks MySQL on Java 7
List<Object> results = this.jdbcTemplate.query(validationQuery,
new SingleColumnRowMapper());
Object result = DataAccessUtils.requiredSingleResult(results);
builder.withDetail("hello", result);
}
catch (Exception ex) {
builder.down(ex);
}
// Avoid calling getObject as it breaks MySQL on Java 7
List<Object> results = this.jdbcTemplate.query(validationQuery,
new SingleColumnRowMapper());
Object result = DataAccessUtils.requiredSingleResult(results);
builder.withDetail("hello", result);
}
}

View File

@ -63,8 +63,10 @@ public class Neo4jHealthIndicator extends AbstractHealthIndicator {
* {@link Health.Builder Builder}.
* @param session the session to use to execute a cypher statement
* @param builder the builder to add details to
* @throws Exception if getting health details failed
*/
protected void extractResult(Session session, Health.Builder builder) {
protected void extractResult(Session session, Health.Builder builder)
throws Exception {
Result result = session.query(CYPHER, Collections.emptyMap());
builder.up().withDetail("nodes",
result.queryResults().iterator().next().get("nodes"));