Skip to content
Merged
Show file tree
Hide file tree
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 @@ -572,7 +572,10 @@ public NoopCachingTier(final AuthoritativeTier<K, V> authoritativeTier) {
@Override
public ValueHolder<V> getOrComputeIfAbsent(final K key, final Function<K, ValueHolder<V>> source) {
final ValueHolder<V> apply = source.apply(key);
authoritativeTier.flush(key, apply);
if (apply != null) {
//immediately flushes any entries faulted from authority as this tier has no capacity
authoritativeTier.flush(key, apply);
}
return apply;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,33 @@ public void CachingTierDoesNotSeeAnyOperationDuringClear() throws StoreAccessExc
ArgumentMatchers.any(), ArgumentMatchers.any());
}

@Test
public void AuthoritativeTierNullCheckDuringFlush() throws StoreAccessException, BrokenBarrierException, InterruptedException {
final TieredStore<String, String> tieredStore = new TieredStore<>(stringCachingTier, stringAuthoritativeTier);

final CyclicBarrier barrier = new CyclicBarrier(2);

doAnswer((Answer<Void>) invocation -> {
barrier.await();
barrier.await();
return null;
}).when(stringAuthoritativeTier).clear();
Thread t = new Thread(() -> {
try {
tieredStore.clear();
} catch (Exception e) {
throw new RuntimeException(e);
}
});

t.start();
barrier.await();
tieredStore.get("foo");
barrier.await();
t.join();
verify(stringAuthoritativeTier, never()).flush("foo", null);
}

@Test
@SuppressWarnings("unchecked")
public void testReleaseStoreFlushes() throws Exception {
Expand Down