hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bha...@apache.org
Subject [hadoop] branch trunk updated: HDDS-2224. Fix loadup cache for cache cleanup policy NEVER. (#1567)
Date Wed, 02 Oct 2019 22:18:50 GMT
This is an automated email from the ASF dual-hosted git repository.

bharat pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/hadoop.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 53ed78b  HDDS-2224. Fix loadup cache for cache cleanup policy NEVER. (#1567)
53ed78b is described below

commit 53ed78bcdb716d0351a934ac18661ef9fa6a03d4
Author: Bharat Viswanadham <bharat@apache.org>
AuthorDate: Wed Oct 2 15:18:43 2019 -0700

    HDDS-2224. Fix loadup cache for cache cleanup policy NEVER. (#1567)
---
 .../main/java/org/apache/hadoop/hdds/utils/db/TypedTable.java    | 2 +-
 .../java/org/apache/hadoop/hdds/utils/db/cache/TableCache.java   | 9 +++++++++
 .../org/apache/hadoop/hdds/utils/db/cache/TableCacheImpl.java    | 7 +++++++
 3 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/utils/db/TypedTable.java
b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/utils/db/TypedTable.java
index c5f23bb..597eff1 100644
--- a/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/utils/db/TypedTable.java
+++ b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/utils/db/TypedTable.java
@@ -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));
         }
       }
diff --git a/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/utils/db/cache/TableCache.java
b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/utils/db/cache/TableCache.java
index 1f16969..de5a079 100644
--- a/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/utils/db/cache/TableCache.java
+++ b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/utils/db/cache/TableCache.java
@@ -44,6 +44,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
    * @param value
diff --git a/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/utils/db/cache/TableCacheImpl.java
b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/utils/db/cache/TableCacheImpl.java
index f33136b..c3215c4 100644
--- a/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/utils/db/cache/TableCacheImpl.java
+++ b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/utils/db/cache/TableCacheImpl.java
@@ -71,6 +71,13 @@ public class TableCacheImpl<CACHEKEY extends 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);
     epochEntries.add(new EpochEntry<>(value.getEpoch(), cacheKey));


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org


Mime
View raw message