File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -800,6 +800,7 @@ public ApiFuture<Empty> asyncClose() {
800800
public void close() {
801801
synchronized (lock) {
802802
numSessionsInUse--;
803+
numSessionsReleased++;
803804
}
804805
Exception = null;
805806
if (lastException != null && isSessionNotFound(lastException)) {
@@ -1462,6 +1463,7 @@ private PooledSession replaceSession(
14621463
if (!options.isFailIfSessionNotFound() && session.allowReplacing) {
14631464
synchronized (lock) {
14641465
numSessionsInUse--;
1466+
numSessionsReleased++;
14651467
}
14661468
session.Exception = null;
14671469
invalidateSession(session);
@@ -1482,6 +1484,7 @@ private void incrementNumSessionsInUse() {
14821484
if (maxSessionsInUse < ++numSessionsInUse) {
14831485
maxSessionsInUse = numSessionsInUse;
14841486
}
1487+
numSessionsAcquired++;
14851488
}
14861489
}
14871490

@@ -1523,7 +1526,6 @@ private void releaseSession(PooledSession session, Position position) {
15231526
if (closureFuture != null) {
15241527
return;
15251528
}
1526-
numSessionsReleased++;
15271529
if (readWaiters.size() == 0 && numSessionsBeingPrepared >= readWriteWaiters.size()) {
15281530
// No pending waiters
15291531
if (shouldPrepareSession()) {
Original file line numberDiff line numberDiff line change
@@ -1589,6 +1589,10 @@ public void testSessionMetrics() throws Exception {
15891589
assertThat(record.getMetrics()).containsEntry(MetricRegistryConstants.IN_USE_SESSIONS, 2L);
15901590
assertThat(record.getMetrics()).containsEntry(MetricRegistryConstants.MAX_IN_USE_SESSIONS, 2L);
15911591
assertThat(record.getMetrics()).containsEntry(MetricRegistryConstants.GET_SESSION_TIMEOUTS, 0L);
1592+
assertThat(record.getMetrics())
1593+
.containsEntry(MetricRegistryConstants.NUM_ACQUIRED_SESSIONS, 2L);
1594+
assertThat(record.getMetrics())
1595+
.containsEntry(MetricRegistryConstants.NUM_RELEASED_SESSIONS, 0L);
15921596
assertThat(record.getMetrics())
15931597
.containsEntry(
15941598
MetricRegistryConstants.MAX_ALLOWED_SESSIONS, (long) options.getMaxSessions());
@@ -1626,9 +1630,9 @@ public Void call() {
16261630
assertThat(record.getMetrics().get(MetricRegistryConstants.GET_SESSION_TIMEOUTS).longValue())
16271631
.isAtLeast(1L);
16281632
assertThat(record.getMetrics())
1629-
.containsEntry(MetricRegistryConstants.NUM_ACQUIRED_SESSIONS, 0L);
1633+
.containsEntry(MetricRegistryConstants.NUM_ACQUIRED_SESSIONS, 3L);
16301634
assertThat(record.getMetrics())
1631-
.containsEntry(MetricRegistryConstants.NUM_RELEASED_SESSIONS, 5L);
1635+
.containsEntry(MetricRegistryConstants.NUM_RELEASED_SESSIONS, 3L);
16321636
assertThat(record.getMetrics()).containsEntry(MetricRegistryConstants.IN_USE_SESSIONS, 0L);
16331637
assertThat(record.getMetrics()).containsEntry(MetricRegistryConstants.MAX_IN_USE_SESSIONS, 2L);
16341638
}

0 commit comments

Comments
 (0)