From d7ba778ce54adc66391256fba9899bc27ee6733a Mon Sep 17 00:00:00 2001 From: Prabhu Joseph Date: Tue, 22 Jan 2019 11:19:26 +0530 Subject: [PATCH] YARN-9027 --- .../yarn/server/timeline/LevelDBCacheTimelineStore.java | 8 ++++++++ .../yarn/server/timeline/TestLevelDBCacheTimelineStore.java | 13 +++++++++++++ 2 files changed, 21 insertions(+) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timeline-pluginstorage/src/main/java/org/apache/hadoop/yarn/server/timeline/LevelDBCacheTimelineStore.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timeline-pluginstorage/src/main/java/org/apache/hadoop/yarn/server/timeline/LevelDBCacheTimelineStore.java index 9b1ffdc..0478bc1 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timeline-pluginstorage/src/main/java/org/apache/hadoop/yarn/server/timeline/LevelDBCacheTimelineStore.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timeline-pluginstorage/src/main/java/org/apache/hadoop/yarn/server/timeline/LevelDBCacheTimelineStore.java @@ -38,6 +38,7 @@ import java.io.File; import java.io.IOException; import java.util.Map; +import java.util.concurrent.atomic.AtomicInteger; /** * LevelDB implementation of {@link KeyValueBasedTimelineStore}. This @@ -63,6 +64,8 @@ private String dbId; private DB entityDb; private Configuration configuration; + private static final AtomicInteger DB_CNTR = new AtomicInteger(0); + private static final String CACHED_LDB_FILENAME = "db"; public LevelDBCacheTimelineStore(String id, String name) { super(name); @@ -76,6 +79,11 @@ public LevelDBCacheTimelineStore(String id) { this(id, LevelDBCacheTimelineStore.class.getName()); } + public LevelDBCacheTimelineStore() { + this(CACHED_LDB_FILENAME + String.valueOf(DB_CNTR.getAndIncrement()), + LevelDBCacheTimelineStore.class.getName()); + } + @Override protected synchronized void serviceInit(Configuration conf) throws Exception { configuration = conf; diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timeline-pluginstorage/src/test/java/org/apache/hadoop/yarn/server/timeline/TestLevelDBCacheTimelineStore.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timeline-pluginstorage/src/test/java/org/apache/hadoop/yarn/server/timeline/TestLevelDBCacheTimelineStore.java index 66da1e0..25c8095 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timeline-pluginstorage/src/test/java/org/apache/hadoop/yarn/server/timeline/TestLevelDBCacheTimelineStore.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timeline-pluginstorage/src/test/java/org/apache/hadoop/yarn/server/timeline/TestLevelDBCacheTimelineStore.java @@ -19,9 +19,11 @@ package org.apache.hadoop.yarn.server.timeline; import org.apache.hadoop.yarn.conf.YarnConfiguration; +import org.apache.hadoop.util.ReflectionUtils; import org.junit.After; import org.junit.Before; import org.junit.Test; +import static org.junit.Assert.assertNotNull; import java.io.IOException; @@ -47,6 +49,17 @@ public TimelineStore getTimelineStore() { } @Test + public void testDefaultConstructor() { + TimelineStore store = null; + try { + store = ReflectionUtils.newInstance(LevelDBCacheTimelineStore.class, + new YarnConfiguration()); + } finally { + assertNotNull(store); + } + } + + @Test public void testGetSingleEntity() throws IOException { super.testGetSingleEntity(); } -- 2.7.4 (Apple Git-66)