HDDS-2224. Fix loadup cache for cache cleanup policy NEVER. (#1567)

This commit is contained in:
Bharat Viswanadham 2019-10-02 15:18:43 -07:00 committed by GitHub
parent 169cef758d
commit 53ed78bcdb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 1 deletions

View File

@ -104,7 +104,7 @@ public TypedTable(
// 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));
}
}

View File

@ -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

View File

@ -70,6 +70,13 @@ public CACHEVALUE get(CACHEKEY 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);