Skip to content

Commit

Permalink
Minor rename in FakePoolMetrics
Browse files Browse the repository at this point in the history
  • Loading branch information
vietj committed Aug 10, 2024
1 parent 63a4697 commit b3690c7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class FakePoolMetrics implements PoolMetrics<Object, Object> {
private final AtomicInteger pending = new AtomicInteger();
private final AtomicInteger releaseCount = new AtomicInteger();
private final AtomicInteger enqueueCount = new AtomicInteger();
private final AtomicInteger acquired = new AtomicInteger();
private final AtomicInteger inUse = new AtomicInteger();
private final AtomicBoolean closed = new AtomicBoolean();

public FakePoolMetrics(String name, int maxSize) {
Expand All @@ -53,13 +53,13 @@ public void dequeue(Object queueMetric) {

@Override
public Object begin() {
acquired.incrementAndGet();
inUse.incrementAndGet();
return TASK_BEGIN;
}

public void end(Object t) {
assert t == TASK_BEGIN;
acquired.decrementAndGet();
inUse.decrementAndGet();
releaseCount.incrementAndGet();
}

Expand Down Expand Up @@ -99,17 +99,17 @@ public int pending() {
}

/**
* @return the number of elements currently borrowed from the pool
* @return the number of elements currently in use from the pool
*/
public int borrowed() {
return acquired.get();
public int inUse() {
return inUse.get();
}

/**
* @return the number of available elements currently in the pool
*/
public int available() {
return maxSize - acquired.get();
return maxSize - inUse.get();
}

/**
Expand Down
16 changes: 8 additions & 8 deletions vertx-core/src/test/java/io/vertx/tests/metrics/MetricsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -952,7 +952,7 @@ public void testThreadPoolMetricsWithExecuteBlocking() {
if (metrics.available() > 0) {
hadIdle.set(true);
}
if (metrics.borrowed() > 0) {
if (metrics.inUse() > 0) {
hadRunning.set(true);
}
}
Expand All @@ -966,7 +966,7 @@ public void testThreadPoolMetricsWithExecuteBlocking() {
assertTrue(hadRunning.get());

assertEquals(metrics.available(), getOptions().getWorkerPoolSize());
assertEquals(metrics.borrowed(), 0);
assertEquals(metrics.inUse(), 0);
assertEquals(metrics.pending(), 0);
}

Expand Down Expand Up @@ -997,7 +997,7 @@ public void testThreadPoolMetricsWithInternalExecuteBlocking() {
fail(e);
Thread.currentThread().interrupt();
}
if (metrics.borrowed() > 0) {
if (metrics.inUse() > 0) {
hadRunning.set(true);
}
if (metrics.pending() > 0) {
Expand All @@ -1018,7 +1018,7 @@ public void testThreadPoolMetricsWithInternalExecuteBlocking() {
assertTrue(hadRunning.get());

assertEquals(metrics.available(), getOptions().getWorkerPoolSize());
assertEquals(metrics.borrowed(), 0);
assertEquals(metrics.inUse(), 0);
assertEquals(metrics.pending(), 0);
}

Expand Down Expand Up @@ -1054,7 +1054,7 @@ public void testThreadPoolMetricsWithWorkerVerticle() throws Exception {
if (metrics.available() > 0) {
hadIdle.set(true);
}
if (metrics.borrowed() > 0) {
if (metrics.inUse() > 0) {
hadRunning.set(true);
}

Expand Down Expand Up @@ -1087,7 +1087,7 @@ public void testThreadPoolMetricsWithWorkerVerticle() throws Exception {
assertTrue("Had running tasks", hadRunning.get());

assertEquals(getOptions().getWorkerPoolSize(), metrics.available());
assertEquals(0, metrics.borrowed());
assertEquals(0, metrics.inUse());
assertEquals(0, metrics.pending());
}

Expand Down Expand Up @@ -1124,7 +1124,7 @@ public void testThreadPoolMetricsWithNamedExecuteBlocking() throws InterruptedEx
if (metrics.available() > 0) {
hadIdle.set(true);
}
if (metrics.borrowed() > 0) {
if (metrics.inUse() > 0) {
hadRunning.set(true);
}
});
Expand All @@ -1136,7 +1136,7 @@ public void testThreadPoolMetricsWithNamedExecuteBlocking() throws InterruptedEx
assertTrue(hadRunning.get());

assertEquals(metrics.available(), 10);
assertEquals(metrics.borrowed(), 0);
assertEquals(metrics.inUse(), 0);
assertEquals(metrics.pending(), 0);
}

Expand Down

0 comments on commit b3690c7

Please sign in to comment.