private Result pingAll() { try { StringBuilder message = new StringBuilder(); OperationResult<CqlStatementResult> astyanaxResult = pingAstyanax(); message.append("Astyanax: ").append(astyanaxResult.getHost()).append(" ") .append(astyanaxResult.getLatency(TimeUnit.MICROSECONDS)).append("us"); if (astyanaxResult.getAttemptsCount() != 1) { message.append(", ").append(astyanaxResult.getAttemptsCount()).append(" attempts"); } Stopwatch cqlTimer = Stopwatch.createStarted(); ResultSet cqlResult = pingCql(); long queryDurationMicros = cqlTimer.elapsed(TimeUnit.MICROSECONDS); Host host = cqlResult.getExecutionInfo().getQueriedHost(); message.append(" | CQL: ").append(host).append(" ").append(queryDurationMicros).append("us"); return Result.healthy(message.toString()); } catch (Throwable t) { return Result.unhealthy(t); } }
private Result pingAll() { try { StringBuilder message = new StringBuilder(); OperationResult<CqlStatementResult> astyanaxResult = pingAstyanax(); message.append("Astyanax: ").append(astyanaxResult.getHost()).append(" ") .append(astyanaxResult.getLatency(TimeUnit.MICROSECONDS)).append("us"); if (astyanaxResult.getAttemptsCount() != 1) { message.append(", ").append(astyanaxResult.getAttemptsCount()).append(" attempts"); } Stopwatch cqlTimer = Stopwatch.createStarted(); ResultSet cqlResult = pingCql(); long queryDurationMicros = cqlTimer.elapsed(TimeUnit.MICROSECONDS); Host host = cqlResult.getExecutionInfo().getQueriedHost(); message.append(" | CQL: ").append(host).append(" ").append(queryDurationMicros).append("us"); return Result.healthy(message.toString()); } catch (Throwable t) { return Result.unhealthy(t); } }
private OperationResult createPositiveOperationResult(String hostName) { OperationResult operationResult = mock(OperationResult.class); com.netflix.astyanax.connectionpool.Host host = mock(com.netflix.astyanax.connectionpool.Host.class); when(host.toString()).thenReturn(hostName); when(operationResult.getHost()).thenReturn(host); when(operationResult.getAttemptsCount()).thenReturn(1); return operationResult; }