Source:
private boolean timedQuery(long iterationNumber) throws Exception { boolean isSelectCountStatement = query.getStatement().toUpperCase().trim().contains("COUNT(") ? true : false; Connection conn = null; PreparedStatement statement = null; ResultSet rs = null; Long start = EnvironmentEdgeManager.currentTimeMillis(); Date startDate = Calendar.getInstance().getTime(); String exception = null; Long resultRowCount = 0L; String queryIteration = threadName + ":" + iterationNumber; Boolean timedOut = false; try { conn = pUtil.getConnection(query.getTenantId(), scenario.getPhoenixProperties()); conn.setAutoCommit(true); final String statementString = query.getDynamicStatement(ruleApplier, scenario); statement = conn.prepareStatement(statementString); LOGGER.info("Executing " + queryIteration + ": " + statementString); if (scenario.getWriteParams() != null) { Workload writes = new WriteWorkload(PhoenixUtil.create(), parser, scenario, GeneratePhoenixStats.NO); workloadExecutor.add(writes); } boolean isQuery = statement.execute(); if (isQuery) { rs = statement.getResultSet(); Pair<Long, Boolean> r = getResults(rs, queryIteration, isSelectCountStatement); resultRowCount = r.getKey(); timedOut = r.getValue(); } else { conn.commit(); } } catch (Exception e) { LOGGER.error("Exception while executing query " + queryIteration, e); exception = e.getMessage(); throw e; } finally { getThreadTime().getRunTimesInMs().add(new RunTime(exception, startDate, resultRowCount, (int) (EnvironmentEdgeManager.currentTimeMillis() - start), timedOut)); if (rs != null) rs.close(); if (statement != null) statement.close(); if (conn != null) conn.close(); } return true; }

Target:
private boolean timedQuery(long iterationNumber) throws Exception { boolean isSelectCountStatement = query.getStatement().toUpperCase().trim().contains("COUNT(") ? true : false; Connection conn = null; PreparedStatement statement = null; ResultSet rs = null; Long queryStartTime = EnvironmentEdgeManager.currentTimeMillis(); Date startDate = Calendar.getInstance().getTime(); String exception = null; Long resultRowCount = 0L; String queryIteration = threadName + ":" + iterationNumber; Long queryElapsedTime = 0L; try { conn = pUtil.getConnection(query.getTenantId(), scenario.getPhoenixProperties()); conn.setAutoCommit(true); final String statementString = query.getDynamicStatement(ruleApplier, scenario); statement = conn.prepareStatement(statementString); LOGGER.info("Executing iteration: " + queryIteration + ": " + statementString); if (scenario.getWriteParams() != null) { Workload writes = new WriteWorkload(PhoenixUtil.create(), parser, scenario, GeneratePhoenixStats.NO); workloadExecutor.add(writes); } boolean isQuery = statement.execute(); if (isQuery) { rs = statement.getResultSet(); Pair<Long, Long> r = getResults(rs, queryIteration, isSelectCountStatement, queryStartTime); resultRowCount = r.getFirst(); queryElapsedTime = r.getSecond(); } else { conn.commit(); } } catch (Exception e) { LOGGER.error("Exception while executing query iteration " + queryIteration, e); exception = e.getMessage(); throw e; } finally { getThreadTime().getRunTimesInMs().add(new RunTime(exception, startDate, resultRowCount, queryElapsedTime, queryElapsedTime > query.getTimeoutDuration())); if (rs != null) rs.close(); if (statement != null) statement.close(); if (conn != null) conn.close(); } return true; }