@Override protected Result check() throws Exception { final Set<String> threads = vm.deadlockedThreads(); if (threads.isEmpty()) { return Result.healthy(); } final StringBuilder builder = new StringBuilder("Deadlocked threads detected:\n"); for (String thread : threads) { builder.append(thread).append('\n'); } return Result.unhealthy(builder.toString()); } }
/** * Returns a healthy {@link Result} with a formatted message. * * Message formatting follows the same rules as * {@link String#format(String, Object...)}. * * @param message a message format * @param args the arguments apply to the message format * @return a healthy {@link Result} with an additional message * @see String#format(String, Object...) */ public static Result healthy(String message, Object... args) { return healthy(String.format(message, args)); }
@Test public void successfulCallReturnsHealthy() throws Exception { when(facade.getOrg("orgName")).thenReturn(new GHOrg("orgName", "http://a.b")); assertThat(healthCheck.check(), equalTo(HealthCheck.Result.healthy())); }
@Override public Result check() { Handle handle = null; try { handle = dbi.open(); final int test = handle.createQuery("select 1 as test").map(IntegerMapper.FIRST).first(); if (test == 1) { return Result.healthy(); } else { return Result.unhealthy(String.format("%s != 1", test)); } } catch (Throwable t) { return Result.unhealthy(t.toString()); } finally { if (handle != null) { handle.close(); } } }
@Override protected Result check() throws Exception { return Result.healthy(); } }
@Override protected Result check() throws Exception { // The service is always healthy, right? return Result.healthy(); } }
@Override protected Result check() throws Exception { return Result.healthy(); } }
@Override protected Result check() throws Exception { verifyConnection(); return Result.healthy(); }
@Override protected Result check() throws Exception { return Result.healthy(); } }
@Override protected Result check() throws Exception { mongo.getDatabaseNames(); return Result.healthy("MongoDB is running... :)"); }
@Override protected Result check() throws Exception { try { gitHubApi.getOrg(organization); return Result.healthy(); } catch (Exception e) { return Result.unhealthy(e); } } }