public AstyanaxResponseData(String response, int size, OperationResult<?> result, Object key, Map<?, ?> kv) { super(response, size, (result == null) ? "" : result.getHost().getHostName(), result != null ? result.getLatency(TimeUnit.MILLISECONDS) : 0, key, kv); } }
public DataStaxClientResponseData(String response, int size, OperationResult<?> result, Object key, Map<?, ?> kv) { super(response, size, (result == null) ? "" : result.getHost().getHostName(), result != null ? result.getLatency(TimeUnit.MILLISECONDS) : 0, key, kv); } }
public DataStaxClientResponseData(String response, int size, OperationResult<?> result, Object key, Object cn, Object value) { super(response, size, EXECUTED_ON + (result != null ? result.getHost().getHostName() : ""), (result != null ? result .getLatency(TimeUnit.MILLISECONDS) : 0), key, cn, value); }
public AstyanaxResponseData(String response, int size, OperationResult<?> result) { super(response, size, EXECUTED_ON + result != null ? result.getHost().getHostName() : "", result != null ? result.getLatency(TimeUnit.MILLISECONDS) : 0); }
public AstyanaxResponseData(String response, int size, OperationResult<?> result, Object key, Object cn, Object value) { super(response, size, EXECUTED_ON + (result != null ? result.getHost().getHostName() : ""), (result != null ? result.getLatency(TimeUnit.MILLISECONDS) : 0), key, cn, value); }
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); } }
/** * Attempt to execute the DDL operation on the same host * @param operation * @param retry * @return * @throws OperationException * @throws ConnectionException */ private synchronized <R> OperationResult<R> executeDdlOperation(AbstractOperationImpl<R> operation, RetryPolicy retry) throws OperationException, ConnectionException { ConnectionException lastException = null; for (int i = 0; i < 2; i++) { operation.setPinnedHost(ddlHost); try { OperationResult<R> result = connectionPool.executeWithFailover(operation, retry); ddlHost = result.getHost(); return result; } catch (ConnectionException e) { lastException = e; if (e instanceof IsDeadConnectionException) { ddlHost = null; } } } throw lastException; }
/** * Attempt to execute the DDL operation on the same host * @param operation * @param retry * @return * @throws OperationException * @throws ConnectionException */ private synchronized <R> OperationResult<R> executeDdlOperation(AbstractOperationImpl<R> operation, RetryPolicy retry) throws OperationException, ConnectionException { ConnectionException lastException = null; for (int i = 0; i < 2; i++) { operation.setPinnedHost(ddlHost); try { OperationResult<R> result = connectionPool.executeWithFailover(operation, retry); ddlHost = result.getHost(); return result; } catch (ConnectionException e) { lastException = e; if (e instanceof IsDeadConnectionException) { ddlHost = null; } } } throw lastException; }
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; }
return new OperationResultImpl<SchemaChangeResult>(opResult.getHost(), new SchemaChangeResponseImpl().setSchemaId("no-op"), opResult.getLatency());
return new OperationResultImpl<SchemaChangeResult>(opResult.getHost(), new SchemaChangeResponseImpl().setSchemaId("no-op"), opResult.getLatency());
latency = now - startTime; pool.addLatencySample(latency, now); return new OperationResultImpl<R>(result.getHost(), result.getResult(), latency); } catch (Exception e) { long now = System.nanoTime();
latency = now - startTime; pool.addLatencySample(latency, now); return new OperationResultImpl<R>(result.getHost(), result.getResult(), latency); } catch (Exception e) { long now = System.nanoTime();
/** * Read from a {@link CassandraNode} using the Astyanax API. * @throws ConnectionException */ public void readData(String keyspaceName) throws ConnectionException { // Create context AstyanaxContext<Keyspace> context = newAstyanaxContextForKeyspace(keyspaceName); try { Keyspace keyspace = context.getEntity(); // Query data OperationResult<ColumnList<String>> query = keyspace.prepareQuery(sampleColumnFamily) .getKey("one") .execute(); assertEquals(query.getHost().getHostName(), hostname); assertTrue(query.getLatency() > 0L); ColumnList<String> columns = query.getResult(); assertEquals(columns.size(), 2); // Lookup columns in response by name String name = columns.getColumnByName("name").getStringValue(); assertEquals(name, "Alice"); // Iterate through the columns for (Column<String> c : columns) { assertTrue(ImmutableList.of("name", "company").contains(c.getName())); } } finally { context.shutdown(); } }
assertEquals(insert.getHost().getHostName(), hostname); assertTrue(insert.getLatency() > 0L); } finally {