@Test public void checkTest() { when(session.execute(any(Statement.class))).thenReturn(null); assertThat(defaultCassandraHealthCheck.check(), is(HealthCheck.Result.healthy())); doThrow(new NoHostAvailableException(new HashMap())) .when(session).execute(eq(DefaultCassandraHealthCheck.SELECT_NOW_FROM_SYSTEM_LOCAL)); assertThat(defaultCassandraHealthCheck.check(), is(HealthCheck.Result.unhealthy("All host(s) tried for query failed (no host was tried)"))); }
@Override public Result check() { boolean res = false; String msg = ""; try { this.session.execute(SELECT_NOW_FROM_SYSTEM_LOCAL); res = true; } catch (NoHostAvailableException ex) { LOGGER.error("No hosts available", ex); msg = ex.getMessage(); } return res ? Result.healthy() : Result.unhealthy(msg); }
DefaultCassandraHealthCheck extends HealthCheck { @Override public Result check() { boolean res = false; String msg = ""; try { this.session.execute(SELECT_NOW_FROM_SYSTEM_LOCAL); res = true; } catch (NoHostAvailableException ex) { LOGGER.error("No hosts available", ex); msg = ex.getMessage(); } return res ? Result.healthy() : Result.unhealthy(msg); } }
DefaultCassandraHealthCheck extends HealthCheck { @Override public Result check() { boolean res = false; String msg = ""; try { this.session.execute(SELECT_NOW_FROM_SYSTEM_LOCAL); res = true; } catch (NoHostAvailableException ex) { LOGGER.error("No hosts available", ex); msg = ex.getMessage(); } return res ? Result.healthy() : Result.unhealthy(msg); } DefaultCassandraHealthCheck(Session session); }
DefaultCassandraHealthCheck extends HealthCheck { @Override public Result check() { boolean res = false; String msg = ""; try { this.session.execute(SELECT_NOW_FROM_SYSTEM_LOCAL); res = true; } catch (NoHostAvailableException ex) { LOGGER.error("No hosts available", ex); msg = ex.getMessage(); } return res ? Result.healthy() : Result.unhealthy(msg); } DefaultCassandraHealthCheck(Session session); @Override Result check(); }
DefaultCassandraHealthCheck extends HealthCheck { @Override public Result check() { boolean res = false; String msg = ""; try { this.session.execute(SELECT_NOW_FROM_SYSTEM_LOCAL); res = true; } catch (NoHostAvailableException ex) { LOGGER.error("No hosts available", ex); msg = ex.getMessage(); } return res ? Result.healthy() : Result.unhealthy(msg); } DefaultCassandraHealthCheck(Session session); @Override Result check(); static final String SELECT_NOW_FROM_SYSTEM_LOCAL; }