Skip to content

Commit

Permalink
Add submittedQueries counter to SqlQueryManager
Browse files Browse the repository at this point in the history
  • Loading branch information
prateek1306 authored and martint committed Nov 15, 2017
1 parent df79e1d commit 832aa77
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Expand Up @@ -30,6 +30,7 @@ public class SqlQueryManagerStats
{ {
private final AtomicInteger queuedQueries = new AtomicInteger(); private final AtomicInteger queuedQueries = new AtomicInteger();
private final AtomicInteger runningQueries = new AtomicInteger(); private final AtomicInteger runningQueries = new AtomicInteger();
private final CounterStat submittedQueries = new CounterStat();
private final CounterStat startedQueries = new CounterStat(); private final CounterStat startedQueries = new CounterStat();
private final CounterStat completedQueries = new CounterStat(); private final CounterStat completedQueries = new CounterStat();
private final CounterStat failedQueries = new CounterStat(); private final CounterStat failedQueries = new CounterStat();
Expand All @@ -49,6 +50,7 @@ public class SqlQueryManagerStats


public void queryQueued() public void queryQueued()
{ {
submittedQueries.update(1);
queuedQueries.incrementAndGet(); queuedQueries.incrementAndGet();
} }


Expand Down Expand Up @@ -132,6 +134,13 @@ public CounterStat getStartedQueries()
return startedQueries; return startedQueries;
} }


@Managed
@Nested
public CounterStat getSubmittedQueries()
{
return submittedQueries;
}

@Managed @Managed
@Nested @Nested
public CounterStat getCompletedQueries() public CounterStat getCompletedQueries()
Expand Down
Expand Up @@ -749,16 +749,18 @@ public void testQueryLoggingCount()
ImmutableList.of()), ImmutableList.of()),
new Duration(1, MINUTES)); new Duration(1, MINUTES));


long beforeQueryCount = queryManager.getStats().getCompletedQueries().getTotalCount(); long beforeCompletedQueriesCount = queryManager.getStats().getCompletedQueries().getTotalCount();
long beforeSubmittedQueriesCount = queryManager.getStats().getSubmittedQueries().getTotalCount();
assertUpdate("CREATE TABLE test_query_logging_count AS SELECT 1 foo_1, 2 foo_2_4", 1); assertUpdate("CREATE TABLE test_query_logging_count AS SELECT 1 foo_1, 2 foo_2_4", 1);
assertQuery("SELECT foo_1, foo_2_4 FROM test_query_logging_count", "SELECT 1, 2"); assertQuery("SELECT foo_1, foo_2_4 FROM test_query_logging_count", "SELECT 1, 2");
assertUpdate("DROP TABLE test_query_logging_count"); assertUpdate("DROP TABLE test_query_logging_count");
assertQueryFails("SELECT * FROM test_query_logging_count", ".*Table .* does not exist"); assertQueryFails("SELECT * FROM test_query_logging_count", ".*Table .* does not exist");


// TODO: Figure out a better way of synchronization // TODO: Figure out a better way of synchronization
assertUntilTimeout( assertUntilTimeout(
() -> assertEquals(queryManager.getStats().getCompletedQueries().getTotalCount() - beforeQueryCount, 4), () -> assertEquals(queryManager.getStats().getCompletedQueries().getTotalCount() - beforeCompletedQueriesCount, 4),
new Duration(1, MINUTES)); new Duration(1, MINUTES));
assertEquals(queryManager.getStats().getSubmittedQueries().getTotalCount() - beforeSubmittedQueriesCount, 4);
}); });
} }


Expand Down

0 comments on commit 832aa77

Please sign in to comment.