Source:
public void replay() { while (queryIterator.hasNext()) { List<FQLQuery> queries = queryIterator.next(); for (FQLQuery query : queries) { if (filters.stream().anyMatch(f -> !f.test(query))) continue; try (Timer.Context ctx = metrics.timer("queries").time()) { List<ListenableFuture<ResultHandler.ComparableResultSet>> results = new ArrayList<>(sessions.size()); for (Session session : sessions) { try { if (query.keyspace != null && !query.keyspace.equals(session.getLoggedKeyspace())) { if (debug) { out.println(String.format("Switching keyspace from %s to %s", session.getLoggedKeyspace(), query.keyspace)); } session.execute("USE " + query.keyspace); } } catch (Throwable t) { out.println("USE "+query.keyspace+" failed: "+t.getMessage()); } if (debug) { out.println("Executing query:"); out.println(query); } results.add(query.execute(session)); } ListenableFuture<List<ResultHandler.ComparableResultSet>> resultList = Futures.allAsList(results); Futures.addCallback(resultList, new FutureCallback<List<ResultHandler.ComparableResultSet>>() { public void onSuccess(@Nullable List<ResultHandler.ComparableResultSet> resultSets) { resultHandler.handleResults(query, resultSets); } public void onFailure(Throwable throwable) { throw new AssertionError("Errors should be handled in FQLQuery.execute", throwable); } }, es); FBUtilities.waitOnFuture(resultList); } catch (Throwable t) { out.println("QUERY " + query +" got exception: "+t.getMessage()); } Timer timer = metrics.timer("queries"); if (timer.getCount() % 5000 == 0) out.printf("%d queries, rate = %.2f%n", timer.getCount(), timer.getOneMinuteRate()); } } }

Target:
public void replay() { while (queryIterator.hasNext()) { List<FQLQuery> queries = queryIterator.next(); for (FQLQuery query : queries) { if (filters.stream().anyMatch(f -> !f.test(query))) continue; try (Timer.Context ctx = metrics.timer("queries").time()) { List<ListenableFuture<ResultHandler.ComparableResultSet>> results = new ArrayList<>(sessions.size()); Statement statement = query.toStatement(); for (Session session : sessions) { try { if (query.keyspace != null && !query.keyspace.equals(session.getLoggedKeyspace())) { if (debug) out.printf("Switching keyspace from %s to %s%n", session.getLoggedKeyspace(), query.keyspace); session.execute("USE " + query.keyspace); } } catch (Throwable t) { out.printf("USE %s failed: %s%n", query.keyspace, t.getMessage()); } if (debug) { out.println("Executing query:"); out.println(query); } ListenableFuture<ResultSet> future = session.executeAsync(statement); results.add(handleErrors(future)); } ListenableFuture<List<ResultHandler.ComparableResultSet>> resultList = Futures.allAsList(results); Futures.addCallback(resultList, new FutureCallback<List<ResultHandler.ComparableResultSet>>() { public void onSuccess(@Nullable List<ResultHandler.ComparableResultSet> resultSets) { resultHandler.handleResults(query, resultSets); } public void onFailure(Throwable throwable) { throw new AssertionError("Errors should be handled in FQLQuery.execute", throwable); } }, es); FBUtilities.waitOnFuture(resultList); } catch (Throwable t) { out.printf("QUERY %s got exception: %s", query, t.getMessage()); } Timer timer = metrics.timer("queries"); if (timer.getCount() % PRINT_RATE == 0) out.printf("%d queries, rate = %.2f%n", timer.getCount(), timer.getOneMinuteRate()); } } }