This is an automated email from the ASF dual-hosted git repository.
peeyush pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/asterixdb.git
The following commit(s) were added to refs/heads/master by this push:
new 97f8018c6a [NO ISSUE][OTH] Add counter to track total number of
requests
97f8018c6a is described below
commit 97f8018c6a0f227310529a45142c5dfe5997ddd0
Author: Peeyush Gupta <[email protected]>
AuthorDate: Fri Sep 22 10:45:34 2023 -0700
[NO ISSUE][OTH] Add counter to track total number of requests
- user model changes: no
- storage format changes: no
- interface changes: yes
Change-Id: I17347c7d03c536ecb1d3b59ccb483a2b01664747
Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/17799
Integration-Tests: Jenkins <[email protected]>
Tested-by: Jenkins <[email protected]>
Reviewed-by: Murtadha Hubail <[email protected]>
---
.../main/java/org/apache/asterix/common/api/IRequestTracker.java | 6 ++++++
.../java/org/apache/asterix/runtime/utils/RequestTracker.java | 8 ++++++++
2 files changed, 14 insertions(+)
diff --git
a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/api/IRequestTracker.java
b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/api/IRequestTracker.java
index a3ddb30ef0..0019015df8 100644
---
a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/api/IRequestTracker.java
+++
b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/api/IRequestTracker.java
@@ -75,4 +75,10 @@ public interface IRequestTracker {
* @return the recently completed requests
*/
Collection<IClientRequest> getCompletedRequests();
+
+ /**
+ *
+ * @return the total number of requests since cluster start/restart
+ */
+ long getTotalNumberOfRequests();
}
diff --git
a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/utils/RequestTracker.java
b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/utils/RequestTracker.java
index 333c709b61..c9425c6065 100644
---
a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/utils/RequestTracker.java
+++
b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/utils/RequestTracker.java
@@ -24,6 +24,7 @@ import java.util.Collections;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicLong;
import org.apache.asterix.common.api.IClientRequest;
import org.apache.asterix.common.api.IRequestTracker;
@@ -37,10 +38,12 @@ public class RequestTracker implements IRequestTracker {
private final Map<String, IClientRequest> clientIdRequests = new
ConcurrentHashMap<>();
private final CircularFifoQueue<IClientRequest> completedRequests;
private final ICcApplicationContext ccAppCtx;
+ private final AtomicLong numRequests;
public RequestTracker(ICcApplicationContext ccAppCtx) {
this.ccAppCtx = ccAppCtx;
completedRequests = new
CircularFifoQueue<>(ccAppCtx.getExternalProperties().getRequestsArchiveSize());
+ numRequests = new AtomicLong(0);
}
@Override
@@ -57,6 +60,7 @@ public class RequestTracker implements IRequestTracker {
@Override
public void track(IClientRequest request) {
runningRequests.put(request.getId(), request);
+ numRequests.incrementAndGet();
if (request.getClientContextId() != null) {
clientIdRequests.put(request.getClientContextId(), request);
}
@@ -112,4 +116,8 @@ public class RequestTracker implements IRequestTracker {
private synchronized void archive(IClientRequest request) {
completedRequests.add(request);
}
+
+ public long getTotalNumberOfRequests() {
+ return numRequests.get();
+ }
}