Skip to content

Commit

Permalink
Expose current cached session count
Browse files Browse the repository at this point in the history
Closes gh-26811
  • Loading branch information
jhoeller committed May 11, 2021
1 parent 90af2d5 commit 0865abe
Showing 1 changed file with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -179,6 +179,23 @@ public boolean isCacheConsumers() {
}


/**
* Return a current session count, indicating the number of sessions currently
* cached by this connection factory.
* @since 5.3.7
*/
public int getCachedSessionCount() {
int count = 0;
synchronized (this.cachedSessions) {
for (Deque<Session> sessionList : this.cachedSessions.values()) {
synchronized (sessionList) {
count += sessionList.size();
}
}
}
return count;
}

/**
* Resets the Session cache as well.
*/
Expand Down

0 comments on commit 0865abe

Please sign in to comment.