YARN-9027. Fixed LevelDBCacheTimelineStore initialization.
Contributed by Prabhu Joseph
This commit is contained in:
parent
1ae062c818
commit
4cb559ea7b
|
@ -38,6 +38,7 @@ import org.slf4j.LoggerFactory;
|
|||
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 @@ public class LevelDBCacheTimelineStore extends KeyValueBasedTimelineStore {
|
|||
private String dbId;
|
||||
private DB entityDb;
|
||||
private Configuration configuration;
|
||||
private static final AtomicInteger DB_COUNTER = new AtomicInteger(0);
|
||||
private static final String CACHED_LDB_FILENAME = "db";
|
||||
|
||||
public LevelDBCacheTimelineStore(String id, String name) {
|
||||
super(name);
|
||||
|
@ -76,6 +79,11 @@ public class LevelDBCacheTimelineStore extends KeyValueBasedTimelineStore {
|
|||
this(id, LevelDBCacheTimelineStore.class.getName());
|
||||
}
|
||||
|
||||
public LevelDBCacheTimelineStore() {
|
||||
this(CACHED_LDB_FILENAME + String.valueOf(DB_COUNTER.getAndIncrement()),
|
||||
LevelDBCacheTimelineStore.class.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected synchronized void serviceInit(Configuration conf) throws Exception {
|
||||
configuration = conf;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
@ -46,6 +48,17 @@ public class TestLevelDBCacheTimelineStore extends TimelineStoreTestUtils {
|
|||
return store;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefaultConstructor() {
|
||||
TimelineStore store = null;
|
||||
try {
|
||||
store = ReflectionUtils.newInstance(LevelDBCacheTimelineStore.class,
|
||||
new YarnConfiguration());
|
||||
} finally {
|
||||
assertNotNull("LevelDBCacheTimelineStore failed to instantiate", store);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSingleEntity() throws IOException {
|
||||
super.testGetSingleEntity();
|
||||
|
|
Loading…
Reference in New Issue