com.datastax.driver.core.ExecutionInfo Java Examples

The following examples show how to use com.datastax.driver.core.ExecutionInfo. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AdaptiveResultSet.java    From emodb with Apache License 2.0 5 votes vote down vote up
/**
 * Reduces the fetch size and retries the query.  Returns true if the query succeeded, false if the root cause
 * of the exception does not indicate a frame size issue, if the frame size cannot be adjusted down any further,
 * or if the retried query fails for an unrelated reason.
 */
private boolean reduceFetchSize(Throwable reason) {
    if (!isAdaptiveException(reason) || --_remainingAdaptations == 0) {
        return false;
    }

    ExecutionInfo executionInfo = _delegate.getExecutionInfo();
    Statement statement = executionInfo.getStatement();
    PagingState pagingState = executionInfo.getPagingState();
    int fetchSize = statement.getFetchSize();

    while (fetchSize > MIN_FETCH_SIZE) {
        fetchSize = Math.max(fetchSize / 2, MIN_FETCH_SIZE);
        _log.debug("Retrying query at next page with fetch size {} due to {}", fetchSize, reason.getMessage());
        statement.setFetchSize(fetchSize);
        statement.setPagingState(pagingState);
        try {
            _delegate = _session.execute(statement);
            return true;
        } catch (Throwable t) {
            // Exit the adaptation loop if the exception isn't one where adapting further may help
            if (!isAdaptiveException(t) || --_remainingAdaptations == 0) {
                return false;
            }
        }
    }

    return false;
}
 
Example #2
Source File: TestCassandraHealthCheck.java    From emodb with Apache License 2.0 5 votes vote down vote up
private ResultSet createPositiveResultSet(String hostName) {
    ExecutionInfo executionInfo = mock(ExecutionInfo.class);
    Host host = mock(Host.class);
    when(host.toString()).thenReturn(hostName);
    when(executionInfo.getQueriedHost()).thenReturn(host);
    ResultSet resultSet = mock(ResultSet.class);
    when(resultSet.getExecutionInfo()).thenReturn(executionInfo);
    return resultSet;
}
 
Example #3
Source File: DatastaxBackend.java    From heroic with Apache License 2.0 5 votes vote down vote up
private AsyncFuture<QueryTrace> buildTrace(
    final Connection c, final QueryTrace.Identifier what, final long elapsed,
    List<ExecutionInfo> info
) {
    final ImmutableList.Builder<AsyncFuture<QueryTrace>> traces = ImmutableList.builder();

    for (final ExecutionInfo i : info) {
        com.datastax.driver.core.QueryTrace qt = i.getQueryTrace();

        if (qt == null) {
            log.warn("Query trace requested, but is not available");
            continue;
        }

        traces.add(getEvents(c, qt.getTraceId()).directTransform(events -> {
            final ImmutableList.Builder<QueryTrace> children = ImmutableList.builder();

            for (final Event e : events) {
                final long eventElapsed =
                    TimeUnit.NANOSECONDS.convert(e.getSourceElapsed(), TimeUnit.MICROSECONDS);
                children.add(QueryTrace.of(QueryTrace.identifier(e.getName()), eventElapsed));
            }

            final QueryTrace.Identifier segment = QueryTrace.identifier(
                i.getQueriedHost().toString() + "[" + qt.getTraceId().toString() + "]");

            final long segmentElapsed =
                TimeUnit.NANOSECONDS.convert(qt.getDurationMicros(), TimeUnit.MICROSECONDS);

            return QueryTrace.of(segment, segmentElapsed, children.build());
        }));
    }

    return async
        .collect(traces.build())
        .directTransform(t -> QueryTrace.of(what, elapsed, ImmutableList.copyOf(t)));
}
 
Example #4
Source File: AdaptiveResultSet.java    From emodb with Apache License 2.0 4 votes vote down vote up
@Override
public ExecutionInfo getExecutionInfo() {
    return _delegate.getExecutionInfo();
}
 
Example #5
Source File: AdaptiveResultSet.java    From emodb with Apache License 2.0 4 votes vote down vote up
@Override
public List<ExecutionInfo> getAllExecutionInfo() {
    return _delegate.getAllExecutionInfo();
}
 
Example #6
Source File: MetadataResultSet.java    From cassandra-jdbc-wrapper with Apache License 2.0 4 votes vote down vote up
public ExecutionInfo getExecutionInfo() {
	// TODO Auto-generated method stub
	return null;
}
 
Example #7
Source File: MetadataResultSet.java    From cassandra-jdbc-wrapper with Apache License 2.0 4 votes vote down vote up
public List<ExecutionInfo> getAllExecutionInfo() {
	// TODO Auto-generated method stub
	return null;
}
 
Example #8
Source File: MockResultSet.java    From hawkular-metrics with Apache License 2.0 4 votes vote down vote up
@Override
public ExecutionInfo getExecutionInfo() {
    throw new UnsupportedOperationException();
}
 
Example #9
Source File: MockResultSet.java    From hawkular-metrics with Apache License 2.0 4 votes vote down vote up
@Override
public List<ExecutionInfo> getAllExecutionInfo() {
    throw new UnsupportedOperationException();
}