Search in sources :

Example 1 with TimingState

use of com.palantir.util.jmx.OperationTimer.TimingState in project atlasdb by palantir.

the class DbKvsGetRanges method getFirstPages.

private Map<RangeRequest, TokenBackedBasicResultsPage<RowResult<Value>, byte[]>> getFirstPages(TableReference tableRef, List<RangeRequest> requests, long timestamp) {
    List<String> subQueries = Lists.newArrayList();
    List<Object> argsList = Lists.newArrayList();
    for (int i = 0; i < requests.size(); i++) {
        RangeRequest request = requests.get(i);
        Pair<String, List<Object>> queryAndArgs = getRangeQueryAndArgs(tableRef, request.getStartInclusive(), request.getEndExclusive(), request.isReverse(), request.getBatchHint() == null ? 1 : request.getBatchHint(), i);
        subQueries.add(queryAndArgs.lhSide);
        argsList.addAll(queryAndArgs.rhSide);
    }
    String query = Joiner.on(") UNION ALL (").appendTo(new StringBuilder("("), subQueries).append(")").toString();
    Object[] args = argsList.toArray();
    TimingState timer = logTimer.begin("Table: " + tableRef.getQualifiedName() + " get_page");
    try {
        return getFirstPagesFromDb(tableRef, requests, timestamp, query, args);
    } finally {
        timer.end();
    }
}
Also used : RangeRequest(com.palantir.atlasdb.keyvalue.api.RangeRequest) TimingState(com.palantir.util.jmx.OperationTimer.TimingState) List(java.util.List)

Example 2 with TimingState

use of com.palantir.util.jmx.OperationTimer.TimingState in project atlasdb by palantir.

the class SqlStatsSqlTimer method start.

@Override
public Handle start(String module, final String sqlKey, final String rawSql) {
    final TimingState timingState;
    if (LoggerFactory.getLogger("com.palantir.nexus.db.SQL").isTraceEnabled()) {
        String sql = rawSql.replaceAll("[\n]+", "");
        String msg = System.currentTimeMillis() + "\tSQL\t" + module + "\t" + sql;
        timingState = timer.begin(msg);
    } else {
        timingState = null;
    }
    return () -> {
        if (timingState != null && logger.isTraceEnabled()) {
            timingState.end();
        }
    };
}
Also used : TimingState(com.palantir.util.jmx.OperationTimer.TimingState)

Aggregations

TimingState (com.palantir.util.jmx.OperationTimer.TimingState)2 RangeRequest (com.palantir.atlasdb.keyvalue.api.RangeRequest)1 List (java.util.List)1