HDDS-2224. Fix loadup cache for cache cleanup policy NEVER. (#1567)
This commit is contained in:
parent
169cef758d
commit
53ed78bcdb
|
@ -104,7 +104,7 @@ public class TypedTable<KEY, VALUE> implements Table<KEY, VALUE> {
|
|||
// We should build cache after OM restart when clean up policy is
|
||||
// NEVER. Setting epoch value -1, so that when it is marked for
|
||||
// delete, this will be considered for cleanup.
|
||||
cache.put(new CacheKey<>(kv.getKey()),
|
||||
cache.loadInitial(new CacheKey<>(kv.getKey()),
|
||||
new CacheValue<>(Optional.of(kv.getValue()), EPOCH_DEFAULT));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,6 +43,15 @@ public interface TableCache<CACHEKEY extends CacheKey,
|
|||
*/
|
||||
CACHEVALUE get(CACHEKEY cacheKey);
|
||||
|
||||
/**
|
||||
* This method should be called for tables with cache cleanup policy
|
||||
* {@link TableCacheImpl.CacheCleanupPolicy#NEVER} after system restart to
|
||||
* fill up the cache.
|
||||
* @param cacheKey
|
||||
* @param cacheValue
|
||||
*/
|
||||
void loadInitial(CACHEKEY cacheKey, CACHEVALUE cacheValue);
|
||||
|
||||
/**
|
||||
* Add an entry to the cache, if the key already exists it overrides.
|
||||
* @param cacheKey
|
||||
|
|
|
@ -70,6 +70,13 @@ public class TableCacheImpl<CACHEKEY extends CacheKey,
|
|||
return cache.get(cachekey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadInitial(CACHEKEY cacheKey, CACHEVALUE cacheValue) {
|
||||
// No need to add entry to epochEntries. Adding to cache is required during
|
||||
// normal put operation.
|
||||
cache.put(cacheKey, cacheValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void put(CACHEKEY cacheKey, CACHEVALUE value) {
|
||||
cache.put(cacheKey, value);
|
||||
|
|
Loading…
Reference in New Issue