Package com.netflix.astyanax

Examples of com.netflix.astyanax.CassandraOperationTracer


        throw lastException;
  }

 
  private OperationResult<R> executeOp() throws ConnectionException {
    CassandraOperationTracer tracer = null;
   
    if (cf != null) {
      tracer = tracerFactory.newTracer(getOperationType(), cf);
    } else {
      tracer = tracerFactory.newTracer(getOperationType());
    }
   
    tracer.start();
    Statement query = getQuery();
   
    if (LOG.isDebugEnabled()) {
      LOG.debug("Query: " + query);
    }
   
        // Set the consistency level on the query
        query.setConsistencyLevel(clLevel);

        // Set the retry policy on the query
        if (retry instanceof JavaDriverBasedRetryPolicy) {
          JavaDriverBasedRetryPolicy jdRetryPolicy = (JavaDriverBasedRetryPolicy) retry;
          query.setRetryPolicy(jdRetryPolicy.getJDRetryPolicy());
        }

        ResultSet resultSet = session.execute(query);
        R result = parseResultSet(resultSet);
    OperationResult<R> opResult = new CqlOperationResultImpl<R>(resultSet, result);
    opResult.setAttemptsCount(retry.getAttemptCount());
    tracer.success();
    return opResult;
  }
View Full Code Here


    return opResult;
  }
 
  @Override
  public ListenableFuture<OperationResult<R>> executeAsync() throws ConnectionException {
    final CassandraOperationTracer tracer = tracerFactory.newTracer(getOperationType());
    tracer.start();
   
    Statement query = getQuery();
   
    if (LOG.isDebugEnabled()) {
      LOG.debug("Query: " + query);
    }
   
    ResultSetFuture rsFuture = session.executeAsync(query);
    return new AsyncOperationResult<R>(rsFuture) {
      @Override
      public OperationResult<R> getOperationResult(ResultSet resultSet) {
        R result = null;
        try {
          result = parseResultSet(resultSet);
        } catch (NotFoundException e) {
          e.printStackTrace();
        }
        tracer.success();
        OperationResult<R> opResult = new CqlOperationResultImpl<R>(resultSet, result);
        opResult.setAttemptsCount(retry.getAttemptCount());
        return opResult;
      }
    };
View Full Code Here

            operationCounter.incrementAndGet();

            // Set a new keyspace, if it changed
            lastException = null;
            if (op.getKeyspace() != null && (keyspaceName == null || !op.getKeyspace().equals(keyspaceName))) {
                CassandraOperationTracer tracer = tracerFactory.newTracer(CassandraOperationType.SET_KEYSPACE)
                        .start();
                try {
                    cassandraClient.set_keyspace(op.getKeyspace());
                    if (asConfig.getCqlVersion() != null)
                        cassandraClient.set_cql_version(asConfig.getCqlVersion());
                    keyspaceName = op.getKeyspace();
                    long now = System.nanoTime();
                    latency = now - startTime;
                    pool.addLatencySample(latency, now);
                    tracer.success();
                }
                catch (Exception e) {
                    long now = System.nanoTime();
                    latency = now - startTime;
                    lastException = ThriftConverter.ToConnectionPoolException(e).setLatency(latency);
                    if (e instanceof IsTimeoutException) {
                        pool.addLatencySample(TimeUnit.NANOSECONDS.convert(cpConfig.getSocketTimeout(), TimeUnit.MILLISECONDS), now);
                    }
                    tracer.failure(lastException);
                    throw lastException;
                }
                startTime = System.nanoTime(); // We don't want to include
                                               // the set_keyspace in our
                                               // latency calculation
View Full Code Here

TOP

Related Classes of com.netflix.astyanax.CassandraOperationTracer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.