Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,8 @@ public void testSequentialAccess() throws InterruptedException {
latch.await();
}

executorService.shutdownNow();

// Verify the final value of "foo" in Redis
String finalValue = control.get("foo");
assertEquals(threadCount * iterations, Integer.parseInt(finalValue));
Expand Down Expand Up @@ -368,6 +370,8 @@ public void testConcurrentAccessWithStats() throws InterruptedException {
latch.await();
}

executorService.shutdownNow();

CacheStats stats = testCache.getStats();
assertEquals(threadCount * iterations, stats.getMissCount() + stats.getHitCount());
assertEquals(stats.getMissCount(), stats.getLoadCount());
Expand All @@ -385,26 +389,28 @@ public void testMaxSize() throws InterruptedException {
// Create the shared mock instance of cache
TestCache testCache = new TestCache(maxSize, map, DefaultCacheable.INSTANCE);

// Submit multiple threads to perform concurrent operations
CountDownLatch latch = new CountDownLatch(threadCount);
for (int i = 0; i < threadCount; i++) {
executorService.submit(() -> {
try (JedisPooled jedis = new JedisPooled(endpoint.getHostAndPort(), clientConfig.get(), testCache)) {
for (int j = 0; j < iterations; j++) {
// Simulate continious get and update operations and consume invalidation events meanwhile
assertEquals("OK", jedis.set("foo" + j, "foo" + j));
jedis.get("foo" + j);
try (JedisPooled jedis = new JedisPooled(endpoint.getHostAndPort(), clientConfig.get(), testCache)) {
// Submit multiple threads to perform concurrent operations
CountDownLatch latch = new CountDownLatch(threadCount);
for (int i = 0; i < threadCount; i++) {
executorService.submit(() -> {
try {
for (int j = 0; j < iterations; j++) {
// Simulate continious get and update operations and consume invalidation events meanwhile
assertEquals("OK", jedis.set("foo" + j, "foo" + j));
jedis.get("foo" + j);
}
} finally {
latch.countDown();
}
} catch (Exception e) {
e.printStackTrace();
} finally {
latch.countDown();
}
});
});
}

// wait for all threads to complete
latch.await();
}

// wait for all threads to complete
latch.await();
executorService.shutdownNow();

CacheStats stats = testCache.getStats();

Expand Down