World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
Java ai-catalogdata-catalogdatalakefederated-querylakehousemetadatametalakemodel-catalogopendatacatalogskycomputingstratosphere
[#2591] refactor: refactor garbage collector config and check its value validity (#2592)
YongXing2dc8c5458727
diff --git a/catalogs/catalog-hadoop/src/test/java/com/datastrato/gravitino/catalog/hadoop/TestHadoopCatalogOperations.java b/catalogs/catalog-hadoop/src/test/java/com/datastrato/gravitino/catalog/hadoop/TestHadoopCatalogOperations.javaindex e7d1f2b57e..1eca47aba4 100644--- a/catalogs/catalog-hadoop/src/test/java/com/datastrato/gravitino/catalog/hadoop/TestHadoopCatalogOperations.java+++ b/catalogs/catalog-hadoop/src/test/java/com/datastrato/gravitino/catalog/hadoop/TestHadoopCatalogOperations.java@@ -8,7 +8,7 @@ import static com.datastrato.gravitino.Configs.DEFAULT_ENTITY_KV_STORE;import static com.datastrato.gravitino.Configs.ENTITY_KV_STORE;import static com.datastrato.gravitino.Configs.ENTITY_STORE;import static com.datastrato.gravitino.Configs.ENTRY_KV_ROCKSDB_BACKEND_PATH;-import static com.datastrato.gravitino.Configs.KV_DELETE_AFTER_TIME;+import static com.datastrato.gravitino.Configs.STORE_DELETE_AFTER_TIME;import static com.datastrato.gravitino.Configs.STORE_TRANSACTION_MAX_SKEW_TIME;import static com.datastrato.gravitino.connector.BaseCatalog.CATALOG_BYPASS_PREFIX;@@ -78,7 +78,7 @@ public class TestHadoopCatalogOperations {Assertions.assertEquals(ROCKS_DB_STORE_PATH, config.get(ENTRY_KV_ROCKSDB_BACKEND_PATH));Mockito.when(config.get(STORE_TRANSACTION_MAX_SKEW_TIME)).thenReturn(1000L);- Mockito.when(config.get(KV_DELETE_AFTER_TIME)).thenReturn(20 * 60 * 1000L);+ Mockito.when(config.get(STORE_DELETE_AFTER_TIME)).thenReturn(20 * 60 * 1000L);store = EntityStoreFactory.createEntityStore(config);store.initialize(config);diff --git a/catalogs/catalog-messaging-kafka/src/test/java/com/datastrato/gravitino/catalog/kafka/TestKafkaCatalogOperations.java b/catalogs/catalog-messaging-kafka/src/test/java/com/datastrato/gravitino/catalog/kafka/TestKafkaCatalogOperations.javaindex 9dacdd1625..fe752a1b4f 100644--- a/catalogs/catalog-messaging-kafka/src/test/java/com/datastrato/gravitino/catalog/kafka/TestKafkaCatalogOperations.java+++ b/catalogs/catalog-messaging-kafka/src/test/java/com/datastrato/gravitino/catalog/kafka/TestKafkaCatalogOperations.java@@ -9,7 +9,7 @@ import static com.datastrato.gravitino.Configs.DEFAULT_ENTITY_KV_STORE;import static com.datastrato.gravitino.Configs.ENTITY_KV_STORE;import static com.datastrato.gravitino.Configs.ENTITY_STORE;import static com.datastrato.gravitino.Configs.ENTRY_KV_ROCKSDB_BACKEND_PATH;-import static com.datastrato.gravitino.Configs.KV_DELETE_AFTER_TIME;+import static com.datastrato.gravitino.Configs.STORE_DELETE_AFTER_TIME;import static com.datastrato.gravitino.Configs.STORE_TRANSACTION_MAX_SKEW_TIME;import static com.datastrato.gravitino.StringIdentifier.ID_KEY;import static com.datastrato.gravitino.catalog.kafka.KafkaCatalogOperations.CLIENT_ID_TEMPLATE;@@ -73,7 +73,7 @@ public class TestKafkaCatalogOperations extends KafkaClusterEmbedded {Assertions.assertEquals(ROCKS_DB_STORE_PATH, config.get(ENTRY_KV_ROCKSDB_BACKEND_PATH));Mockito.when(config.get(STORE_TRANSACTION_MAX_SKEW_TIME)).thenReturn(1000L);- Mockito.when(config.get(KV_DELETE_AFTER_TIME)).thenReturn(20 * 60 * 1000L);+ Mockito.when(config.get(STORE_DELETE_AFTER_TIME)).thenReturn(20 * 60 * 1000L);store = EntityStoreFactory.createEntityStore(config);store.initialize(config);diff --git a/common/src/main/java/com/datastrato/gravitino/Config.java b/common/src/main/java/com/datastrato/gravitino/Config.javaindex cc00c8c767..95b438d551 100644--- a/common/src/main/java/com/datastrato/gravitino/Config.java+++ b/common/src/main/java/com/datastrato/gravitino/Config.java@@ -33,13 +33,13 @@ public abstract class Config {private final ConcurrentMap<String, String> configMap;private final Map<String, DeprecatedConfig> deprecatedConfigMap;- // Constant Array to hold all deprecated configurations+ // Constant Array to hold all deprecated configuration keys, when a configuration is deprecated,+ // we should add it here.private final DeprecatedConfig[] deprecatedConfigs = {- // Example deprecated configuration- // new DeprecatedConfig(- // "gravitino.test.string",- // "1.0",- // "Please use gravitino.test.string1 instead."),+ new DeprecatedConfig(+ "gravitino.entity.store.kv.deleteAfterTimeMs",+ "0.5.0",+ "Please use gravitino.entity.store.deleteAfterTimeMs instead."),};/**diff --git a/common/src/test/java/com/datastrato/gravitino/config/TestConfigEntry.java b/common/src/test/java/com/datastrato/gravitino/config/TestConfigEntry.javaindex 4d8eb2ac6b..2eb40c418d 100644--- a/common/src/test/java/com/datastrato/gravitino/config/TestConfigEntry.java+++ b/common/src/test/java/com/datastrato/gravitino/config/TestConfigEntry.java@@ -91,7 +91,7 @@ public class TestConfigEntry {ConfigEntry<String> testConf =new ConfigBuilder("gravitino.test.string").alternatives(- Lists.newArrayList("gravitino.test.string.alt1", "gravitino.test.string.alt1"))+ Lists.newArrayList("gravitino.test.string.alt1", "gravitino.test.string.alt2")).stringConf().createWithDefault("test");@@ -101,7 +101,7 @@ public class TestConfigEntry {ConfigEntry<String> testConf1 =new ConfigBuilder("gravitino.test.string.no-exist").alternatives(- Lists.newArrayList("gravitino.test.string.alt1", "gravitino.test.string.alt1"))+ Lists.newArrayList("gravitino.test.string.alt1", "gravitino.test.string.alt2")).stringConf().createWithDefault("test");diff --git a/core/src/main/java/com/datastrato/gravitino/Configs.java b/core/src/main/java/com/datastrato/gravitino/Configs.javaindex 384f47628b..95f9780d72 100644--- a/core/src/main/java/com/datastrato/gravitino/Configs.java+++ b/core/src/main/java/com/datastrato/gravitino/Configs.java@@ -7,6 +7,7 @@ package com.datastrato.gravitino;import com.datastrato.gravitino.config.ConfigBuilder;import com.datastrato.gravitino.config.ConfigConstants;import com.datastrato.gravitino.config.ConfigEntry;+import com.google.common.collect.Lists;import java.io.File;import org.apache.commons.lang3.StringUtils;@@ -33,6 +34,24 @@ public interface Configs {Long DEFAULT_KV_DELETE_AFTER_TIME = 604800000L; // 7 daysString KV_DELETE_AFTER_TIME_KEY = "gravitino.entity.store.kv.deleteAfterTimeMs";+ // Config for data keep time after soft deletion, in milliseconds.+ String STORE_DELETE_AFTER_TIME_KEY = "gravitino.entity.store.deleteAfterTimeMs";+ // using the fallback default value+ Long DEFAULT_STORE_DELETE_AFTER_TIME = DEFAULT_KV_DELETE_AFTER_TIME;+ // The maximum allowed keep time for data deletion, in milliseconds. Equivalent to 30 days.+ Long MAX_DELETE_TIME_ALLOW = 1000 * 60 * 60 * 24 * 30L;+ // The minimum allowed keep time for data deletion, in milliseconds. Equivalent to 10 minutes.+ Long MIN_DELETE_TIME_ALLOW = 1000 * 60 * 10L;++ // Count of versions allowed to be retained, including the current version, used to delete old+ // versions data.+ String VERSION_RETENTION_COUNT_KEY = "gravitino.entity.store.versionRetentionCount";+ Long DEFAULT_VERSION_RETENTION_COUNT = 1L;+ // The maximum allowed count of versions to be retained+ Long MAX_VERSION_RETENTION_COUNT = 10L;+ // The minimum allowed count of versions to be retained+ Long MIN_VERSION_RETENTION_COUNT = 1L;+// Default path for RocksDB backend is "${GRAVITINO_HOME}/data/rocksdb"String DEFAULT_KV_ROCKSDB_BACKEND_PATH =String.join(File.separator, System.getenv("GRAVITINO_HOME"), "data", "rocksdb");@@ -146,11 +165,58 @@ public interface Configs {ConfigEntry<Long> KV_DELETE_AFTER_TIME =new ConfigBuilder(KV_DELETE_AFTER_TIME_KEY).doc(- "The maximum time in milliseconds that the deleted data and old version data is kept")- .version(ConfigConstants.VERSION_0_3_0)+ String.format(+ "The maximum time in milliseconds that the deleted data and old version data is kept, "+ + "max delete time allow is %s ms(30 days), "+ + "min delete time allow is %s ms(10 minutes)",+ MAX_DELETE_TIME_ALLOW, MIN_DELETE_TIME_ALLOW))+ .version(ConfigConstants.VERSION_0_5_0)+ .deprecated().longConf()+ .checkValue(+ v -> v >= MIN_DELETE_TIME_ALLOW && v <= MAX_DELETE_TIME_ALLOW,+ String.format(+ "The value of %s is out of range, which must be between %s and %s",+ KV_DELETE_AFTER_TIME_KEY, MIN_DELETE_TIME_ALLOW, MAX_DELETE_TIME_ALLOW)).createWithDefault(DEFAULT_KV_DELETE_AFTER_TIME);+ ConfigEntry<Long> STORE_DELETE_AFTER_TIME =+ new ConfigBuilder(STORE_DELETE_AFTER_TIME_KEY)+ .doc(+ String.format(+ "The maximum time in milliseconds that the deleted data and old version data is kept, "+ + "max delete time allow is %s ms(30 days), "+ + "min delete time allow is %s ms(10 minutes)",+ MAX_DELETE_TIME_ALLOW, MIN_DELETE_TIME_ALLOW))+ .version(ConfigConstants.VERSION_0_5_0)+ .alternatives(Lists.newArrayList(KV_DELETE_AFTER_TIME_KEY))+ .longConf()+ .checkValue(+ v -> v >= MIN_DELETE_TIME_ALLOW && v <= MAX_DELETE_TIME_ALLOW,+ String.format(+ "The value of %s is out of range, which must be between %s and %s",+ STORE_DELETE_AFTER_TIME_KEY, MIN_DELETE_TIME_ALLOW, MAX_DELETE_TIME_ALLOW))+ .createWithDefault(DEFAULT_STORE_DELETE_AFTER_TIME);++ ConfigEntry<Long> VERSION_RETENTION_COUNT =+ new ConfigBuilder(VERSION_RETENTION_COUNT_KEY)+ .doc(+ String.format(+ "The count of versions allowed to be retained, including the current version, "+ + "max version retention count is %s, "+ + "min version retention count is %s",+ MAX_VERSION_RETENTION_COUNT, MIN_VERSION_RETENTION_COUNT))+ .version(ConfigConstants.VERSION_0_5_0)+ .longConf()+ .checkValue(+ v -> v >= MIN_VERSION_RETENTION_COUNT && v <= MAX_VERSION_RETENTION_COUNT,+ String.format(+ "The value of %s is out of range, which must be between %s and %s",+ VERSION_RETENTION_COUNT_KEY,+ MIN_VERSION_RETENTION_COUNT,+ MAX_VERSION_RETENTION_COUNT))+ .createWithDefault(DEFAULT_VERSION_RETENTION_COUNT);+// The followings are configurations for tree lockConfigEntry<Long> TREE_LOCK_MAX_NODE_IN_MEMORY =diff --git a/core/src/main/java/com/datastrato/gravitino/storage/kv/KvGarbageCollector.java b/core/src/main/java/com/datastrato/gravitino/storage/kv/KvGarbageCollector.javaindex fc8fc5c7bf..a2f39c361d 100644--- a/core/src/main/java/com/datastrato/gravitino/storage/kv/KvGarbageCollector.java+++ b/core/src/main/java/com/datastrato/gravitino/storage/kv/KvGarbageCollector.java@@ -5,7 +5,7 @@package com.datastrato.gravitino.storage.kv;-import static com.datastrato.gravitino.Configs.KV_DELETE_AFTER_TIME;+import static com.datastrato.gravitino.Configs.STORE_DELETE_AFTER_TIME;import static com.datastrato.gravitino.storage.kv.KvNameMappingService.GENERAL_NAME_MAPPING_PREFIX;import static com.datastrato.gravitino.storage.kv.TransactionalKvBackendImpl.endOfTransactionId;import static com.datastrato.gravitino.storage.kv.TransactionalKvBackendImpl.generateCommitKey;@@ -44,9 +44,6 @@ public final class KvGarbageCollector implements Closeable {private final Config config;private final EntityKeyEncoder<byte[]> entityKeyEncoder;- private static final long MAX_DELETE_TIME_ALLOW = 1000 * 60 * 60 * 24 * 30L; // 30 days- private static final long MIN_DELETE_TIME_ALLOW = 1000 * 60 * 10L; // 10 minutes-private static final String TIME_STAMP_FORMAT = "yyyy-MM-dd HH:mm:ss.SSS";@VisibleForTesting@@ -65,21 +62,10 @@ public final class KvGarbageCollector implements Closeable {this.kvBackend = kvBackend;this.config = config;this.entityKeyEncoder = entityKeyEncoder;-- long deleteTimeLine = config.get(KV_DELETE_AFTER_TIME);- if (deleteTimeLine > MAX_DELETE_TIME_ALLOW || deleteTimeLine < MIN_DELETE_TIME_ALLOW) {- throw new IllegalArgumentException(- String.format(- "The delete time line is too long or too short, "- + "please check it. The delete time line is %s ms,"- + "max delete time allow is %s ms(30 days),"- + "min delete time allow is %s ms(10 minutes)",- deleteTimeLine, MAX_DELETE_TIME_ALLOW, MIN_DELETE_TIME_ALLOW));- }}public void start() {- long dateTimeLineMinute = config.get(KV_DELETE_AFTER_TIME) / 1000 / 60;+ long dateTimeLineMinute = config.get(STORE_DELETE_AFTER_TIME) / 1000 / 60;// We will collect garbage every 10 minutes at least. If the dateTimeLineMinute is larger than// 100 minutes, we would collect garbage every dateTimeLineMinute/10 minutes.@@ -133,7 +119,7 @@ public final class KvGarbageCollector implements Closeable {}private void collectAndRemoveOldVersionData() throws IOException {- long deleteTimeLine = System.currentTimeMillis() - config.get(KV_DELETE_AFTER_TIME);+ long deleteTimeLine = System.currentTimeMillis() - config.get(STORE_DELETE_AFTER_TIME);// Why should we leave shift 18 bits? please refer to TransactionIdGeneratorImpl#nextId// We can delete the data which is older than deleteTimeLine.(old data with transaction id that// is smaller than transactionIdToDelete)diff --git a/core/src/test/java/com/datastrato/gravitino/storage/TestEntityStorage.java b/core/src/test/java/com/datastrato/gravitino/storage/TestEntityStorage.javaindex 3aa0bef0da..6666cd0453 100644--- a/core/src/test/java/com/datastrato/gravitino/storage/TestEntityStorage.java+++ b/core/src/test/java/com/datastrato/gravitino/storage/TestEntityStorage.java@@ -15,8 +15,8 @@ import static com.datastrato.gravitino.Configs.ENTITY_RELATIONAL_JDBC_BACKEND_USimport static com.datastrato.gravitino.Configs.ENTITY_RELATIONAL_STORE;import static com.datastrato.gravitino.Configs.ENTITY_STORE;import static com.datastrato.gravitino.Configs.ENTRY_KV_ROCKSDB_BACKEND_PATH;-import static com.datastrato.gravitino.Configs.KV_DELETE_AFTER_TIME;import static com.datastrato.gravitino.Configs.RELATIONAL_ENTITY_STORE;+import static com.datastrato.gravitino.Configs.STORE_DELETE_AFTER_TIME;import static com.datastrato.gravitino.Configs.STORE_TRANSACTION_MAX_SKEW_TIME;import com.datastrato.gravitino.Catalog;@@ -92,7 +92,7 @@ public class TestEntityStorage {Assertions.assertEquals(KV_STORE_PATH, config.get(ENTRY_KV_ROCKSDB_BACKEND_PATH));Mockito.when(config.get(STORE_TRANSACTION_MAX_SKEW_TIME)).thenReturn(1000L);- Mockito.when(config.get(KV_DELETE_AFTER_TIME)).thenReturn(20 * 60 * 1000L);+ Mockito.when(config.get(STORE_DELETE_AFTER_TIME)).thenReturn(20 * 60 * 1000L);} else if (type.equals(Configs.RELATIONAL_ENTITY_STORE)) {File dir = new File(DB_DIR);if (dir.exists() || !dir.isDirectory()) {diff --git a/core/src/test/java/com/datastrato/gravitino/storage/kv/TestEntityKeyEncoding.java b/core/src/test/java/com/datastrato/gravitino/storage/kv/TestEntityKeyEncoding.javaindex 00504a5476..b23b8b88cb 100644--- a/core/src/test/java/com/datastrato/gravitino/storage/kv/TestEntityKeyEncoding.java+++ b/core/src/test/java/com/datastrato/gravitino/storage/kv/TestEntityKeyEncoding.java@@ -9,7 +9,7 @@ import static com.datastrato.gravitino.Configs.DEFAULT_ENTITY_KV_STORE;import static com.datastrato.gravitino.Configs.ENTITY_KV_STORE;import static com.datastrato.gravitino.Configs.ENTITY_STORE;import static com.datastrato.gravitino.Configs.ENTRY_KV_ROCKSDB_BACKEND_PATH;-import static com.datastrato.gravitino.Configs.KV_DELETE_AFTER_TIME;+import static com.datastrato.gravitino.Configs.STORE_DELETE_AFTER_TIME;import static com.datastrato.gravitino.Configs.STORE_TRANSACTION_MAX_SKEW_TIME;import static com.datastrato.gravitino.storage.kv.BinaryEntityKeyEncoder.BYTABLE_NAMESPACE_SEPARATOR;import static com.datastrato.gravitino.storage.kv.BinaryEntityKeyEncoder.WILD_CARD;@@ -52,7 +52,7 @@ public class TestEntityKeyEncoding {Mockito.when(config.get(STORE_TRANSACTION_MAX_SKEW_TIME)).thenReturn(3000L);Mockito.when(config.get(ENTITY_STORE)).thenReturn("kv");Mockito.when(config.get(ENTITY_KV_STORE)).thenReturn(DEFAULT_ENTITY_KV_STORE);- Mockito.when(config.get(KV_DELETE_AFTER_TIME)).thenReturn(20 * 60 * 1000L);+ Mockito.when(config.get(STORE_DELETE_AFTER_TIME)).thenReturn(20 * 60 * 1000L);return config;}diff --git a/core/src/test/java/com/datastrato/gravitino/storage/kv/TestKvEntityStorage.java b/core/src/test/java/com/datastrato/gravitino/storage/kv/TestKvEntityStorage.javaindex c937400a1c..df7c6953ac 100644--- a/core/src/test/java/com/datastrato/gravitino/storage/kv/TestKvEntityStorage.java+++ b/core/src/test/java/com/datastrato/gravitino/storage/kv/TestKvEntityStorage.java@@ -9,7 +9,7 @@ import static com.datastrato.gravitino.Configs.DEFAULT_ENTITY_KV_STORE;import static com.datastrato.gravitino.Configs.ENTITY_KV_STORE;import static com.datastrato.gravitino.Configs.ENTITY_STORE;import static com.datastrato.gravitino.Configs.ENTRY_KV_ROCKSDB_BACKEND_PATH;-import static com.datastrato.gravitino.Configs.KV_DELETE_AFTER_TIME;+import static com.datastrato.gravitino.Configs.STORE_DELETE_AFTER_TIME;import static com.datastrato.gravitino.Configs.STORE_TRANSACTION_MAX_SKEW_TIME;import com.datastrato.gravitino.Config;@@ -60,16 +60,20 @@ public class TestKvEntityStorage extends TestEntityStorage {}}- @Test- void testCreateKvEntityStore() throws IOException {+ public Config getConfig() throws IOException {Config config = Mockito.mock(Config.class);Mockito.when(config.get(ENTITY_STORE)).thenReturn("kv");Mockito.when(config.get(ENTITY_KV_STORE)).thenReturn(DEFAULT_ENTITY_KV_STORE);Mockito.when(config.get(Configs.ENTITY_SERDE)).thenReturn("proto");Mockito.when(config.get(ENTRY_KV_ROCKSDB_BACKEND_PATH)).thenReturn("/tmp/gravitino");Mockito.when(config.get(STORE_TRANSACTION_MAX_SKEW_TIME)).thenReturn(1000L);- Mockito.when(config.get(KV_DELETE_AFTER_TIME)).thenReturn(20 * 60 * 1000L);+ Mockito.when(config.get(STORE_DELETE_AFTER_TIME)).thenReturn(20 * 60 * 1000L);+ return config;+ }+ @Test+ void testCreateKvEntityStore() throws IOException {+ Config config = getConfig();FileUtils.deleteDirectory(FileUtils.getFile("/tmp/gravitino"));try (EntityStore store = EntityStoreFactory.createEntityStore(config)) {@@ -173,16 +177,11 @@ public class TestKvEntityStorage extends TestEntityStorage {@Test@Disabled("KvEntityStore is not thread safe after issue #780")void testConcurrentIssues() throws IOException, ExecutionException, InterruptedException {- Config config = Mockito.mock(Config.class);+ Config config = getConfig();File baseDir = new File(System.getProperty("java.io.tmpdir"));File file = Files.createTempDirectory(baseDir.toPath(), "test").toFile();file.deleteOnExit();- Mockito.when(config.get(ENTITY_STORE)).thenReturn("kv");- Mockito.when(config.get(ENTITY_KV_STORE)).thenReturn(DEFAULT_ENTITY_KV_STORE);- Mockito.when(config.get(Configs.ENTITY_SERDE)).thenReturn("proto");Mockito.when(config.get(ENTRY_KV_ROCKSDB_BACKEND_PATH)).thenReturn(file.getAbsolutePath());- Mockito.when(config.get(STORE_TRANSACTION_MAX_SKEW_TIME)).thenReturn(1000L);- Mockito.when(config.get(KV_DELETE_AFTER_TIME)).thenReturn(20 * 60 * 1000L);ThreadPoolExecutor threadPoolExecutor =new ThreadPoolExecutor(diff --git a/core/src/test/java/com/datastrato/gravitino/storage/kv/TestKvGarbageCollector.java b/core/src/test/java/com/datastrato/gravitino/storage/kv/TestKvGarbageCollector.javaindex fbc29af178..815dbfff3f 100644--- a/core/src/test/java/com/datastrato/gravitino/storage/kv/TestKvGarbageCollector.java+++ b/core/src/test/java/com/datastrato/gravitino/storage/kv/TestKvGarbageCollector.java@@ -9,7 +9,7 @@ import static com.datastrato.gravitino.Configs.DEFAULT_ENTITY_KV_STORE;import static com.datastrato.gravitino.Configs.ENTITY_KV_STORE;import static com.datastrato.gravitino.Configs.ENTITY_STORE;import static com.datastrato.gravitino.Configs.ENTRY_KV_ROCKSDB_BACKEND_PATH;-import static com.datastrato.gravitino.Configs.KV_DELETE_AFTER_TIME;+import static com.datastrato.gravitino.Configs.STORE_DELETE_AFTER_TIME;import static com.datastrato.gravitino.Configs.STORE_TRANSACTION_MAX_SKEW_TIME;import static com.datastrato.gravitino.storage.kv.TestKvEntityStorage.createBaseMakeLake;import static com.datastrato.gravitino.storage.kv.TestKvEntityStorage.createCatalog;@@ -56,7 +56,7 @@ class TestKvGarbageCollector {Mockito.when(config.get(Configs.ENTITY_SERDE)).thenReturn("proto");Mockito.when(config.get(ENTRY_KV_ROCKSDB_BACKEND_PATH)).thenReturn(file.getAbsolutePath());Mockito.when(config.get(STORE_TRANSACTION_MAX_SKEW_TIME)).thenReturn(3L);- Mockito.when(config.get(KV_DELETE_AFTER_TIME)).thenReturn(20 * 60 * 1000L);+ Mockito.when(config.get(STORE_DELETE_AFTER_TIME)).thenReturn(20 * 60 * 1000L);return config;}@@ -69,16 +69,17 @@ class TestKvGarbageCollector {@Testvoid testScheduler() throws IOException {Config config = getConfig();- Mockito.when(config.get(KV_DELETE_AFTER_TIME)).thenReturn(20 * 60 * 1000L); // 20 minutes- long dateTimeLineMinute = config.get(KV_DELETE_AFTER_TIME) / 1000 / 60;+ Mockito.when(config.get(STORE_DELETE_AFTER_TIME)).thenReturn(20 * 60 * 1000L); // 20 minutes+ long dateTimeLineMinute = config.get(STORE_DELETE_AFTER_TIME) / 1000 / 60;Assertions.assertEquals(10, Math.max(dateTimeLineMinute / 10, 10));- Mockito.when(config.get(KV_DELETE_AFTER_TIME)).thenReturn(2 * 60 * 60 * 1000L); // 2 hours- dateTimeLineMinute = config.get(KV_DELETE_AFTER_TIME) / 1000 / 60;+ Mockito.when(config.get(STORE_DELETE_AFTER_TIME)).thenReturn(2 * 60 * 60 * 1000L); // 2 hours+ dateTimeLineMinute = config.get(STORE_DELETE_AFTER_TIME) / 1000 / 60;Assertions.assertEquals(12, Math.max(dateTimeLineMinute / 10, 10));- Mockito.when(config.get(KV_DELETE_AFTER_TIME)).thenReturn(2 * 60 * 60 * 24 * 1000L); // 2 days- dateTimeLineMinute = config.get(KV_DELETE_AFTER_TIME) / 1000 / 60;+ Mockito.when(config.get(STORE_DELETE_AFTER_TIME))+ .thenReturn(2 * 60 * 60 * 24 * 1000L); // 2 days+ dateTimeLineMinute = config.get(STORE_DELETE_AFTER_TIME) / 1000 / 60;Assertions.assertEquals(288, Math.max(dateTimeLineMinute / 10, 10));}@@ -127,8 +128,9 @@ class TestKvGarbageCollector {// 0x1E, last_timestamp can be seen as they have not been stored to the backend.Assertions.assertEquals(7, allData.size());+ // Set the TTL to 2 seconds before the kvGarbageCollector is created+ Mockito.doReturn(2000L).when(config).get(STORE_DELETE_AFTER_TIME);KvGarbageCollector kvGarbageCollector = new KvGarbageCollector(kvBackend, config, null);- Mockito.doReturn(2000L).when(config).get(KV_DELETE_AFTER_TIME);// Wait TTL time to make sure the data is expired, please see ENTITY_KV_TTLThread.sleep(3000);@@ -153,16 +155,8 @@ class TestKvGarbageCollector {@Testvoid testRemoveWithGCCollector1() throws IOException, InterruptedException {- Config config = Mockito.mock(Config.class);- File baseDir = new File(System.getProperty("java.io.tmpdir"));- File file = Files.createTempDirectory(baseDir.toPath(), "test").toFile();- file.deleteOnExit();- Mockito.when(config.get(ENTITY_STORE)).thenReturn("kv");- Mockito.when(config.get(ENTITY_KV_STORE)).thenReturn(DEFAULT_ENTITY_KV_STORE);- Mockito.when(config.get(Configs.ENTITY_SERDE)).thenReturn("proto");- Mockito.when(config.get(ENTRY_KV_ROCKSDB_BACKEND_PATH)).thenReturn(file.getAbsolutePath());+ Config config = getConfig();Mockito.when(config.get(STORE_TRANSACTION_MAX_SKEW_TIME)).thenReturn(1000L);- Mockito.when(config.get(KV_DELETE_AFTER_TIME)).thenReturn(20 * 60 * 1000L);try (EntityStore store = EntityStoreFactory.createEntityStore(config)) {store.initialize(config);@@ -239,16 +233,8 @@ class TestKvGarbageCollector {@Testvoid testRemoveWithGCCollector2() throws IOException, InterruptedException {- Config config = Mockito.mock(Config.class);- File baseDir = new File(System.getProperty("java.io.tmpdir"));- File file = Files.createTempDirectory(baseDir.toPath(), "test").toFile();- file.deleteOnExit();- Mockito.when(config.get(ENTITY_STORE)).thenReturn("kv");- Mockito.when(config.get(ENTITY_KV_STORE)).thenReturn(DEFAULT_ENTITY_KV_STORE);- Mockito.when(config.get(Configs.ENTITY_SERDE)).thenReturn("proto");- Mockito.when(config.get(ENTRY_KV_ROCKSDB_BACKEND_PATH)).thenReturn(file.getAbsolutePath());+ Config config = getConfig();Mockito.when(config.get(STORE_TRANSACTION_MAX_SKEW_TIME)).thenReturn(1000L);- Mockito.when(config.get(KV_DELETE_AFTER_TIME)).thenReturn(20 * 60 * 1000L);try (EntityStore store = EntityStoreFactory.createEntityStore(config)) {store.initialize(config);@@ -278,7 +264,7 @@ class TestKvGarbageCollector {store.put(metalake2);store.put(metalake3);- Mockito.when(config.get(KV_DELETE_AFTER_TIME)).thenReturn(1000L);+ Mockito.when(config.get(STORE_DELETE_AFTER_TIME)).thenReturn(1000L);Thread.sleep(1500);kvEntityStore.kvGarbageCollector.collectAndClean();@@ -309,7 +295,7 @@ class TestKvGarbageCollector {store.put(catalog1);store.put(catalog2);- Mockito.when(config.get(KV_DELETE_AFTER_TIME)).thenReturn(1000L);+ Mockito.when(config.get(STORE_DELETE_AFTER_TIME)).thenReturn(1000L);Thread.sleep(1500);kvEntityStore.kvGarbageCollector.collectAndClean();@@ -342,7 +328,7 @@ class TestKvGarbageCollector {store.put(schema1);store.put(schema2);- Mockito.when(config.get(KV_DELETE_AFTER_TIME)).thenReturn(1000L);+ Mockito.when(config.get(STORE_DELETE_AFTER_TIME)).thenReturn(1000L);Thread.sleep(1500);kvEntityStore.kvGarbageCollector.collectAndClean();@@ -378,7 +364,7 @@ class TestKvGarbageCollector {store.put(table1);store.put(table2);- Mockito.when(config.get(KV_DELETE_AFTER_TIME)).thenReturn(1000L);+ Mockito.when(config.get(STORE_DELETE_AFTER_TIME)).thenReturn(1000L);Thread.sleep(1500);kvEntityStore.kvGarbageCollector.collectAndClean();diff --git a/core/src/test/java/com/datastrato/gravitino/storage/kv/TestKvNameMappingService.java b/core/src/test/java/com/datastrato/gravitino/storage/kv/TestKvNameMappingService.javaindex 0954726289..3b02aa95d4 100644--- a/core/src/test/java/com/datastrato/gravitino/storage/kv/TestKvNameMappingService.java+++ b/core/src/test/java/com/datastrato/gravitino/storage/kv/TestKvNameMappingService.java@@ -9,7 +9,7 @@ import static com.datastrato.gravitino.Configs.DEFAULT_ENTITY_KV_STORE;import static com.datastrato.gravitino.Configs.ENTITY_KV_STORE;import static com.datastrato.gravitino.Configs.ENTITY_STORE;import static com.datastrato.gravitino.Configs.ENTRY_KV_ROCKSDB_BACKEND_PATH;-import static com.datastrato.gravitino.Configs.KV_DELETE_AFTER_TIME;+import static com.datastrato.gravitino.Configs.STORE_DELETE_AFTER_TIME;import static com.datastrato.gravitino.Configs.STORE_TRANSACTION_MAX_SKEW_TIME;import com.datastrato.gravitino.Config;@@ -37,7 +37,7 @@ public class TestKvNameMappingService {Mockito.when(config.get(STORE_TRANSACTION_MAX_SKEW_TIME)).thenReturn(3000L);Mockito.when(config.get(ENTITY_STORE)).thenReturn("kv");Mockito.when(config.get(ENTITY_KV_STORE)).thenReturn(DEFAULT_ENTITY_KV_STORE);- Mockito.when(config.get(KV_DELETE_AFTER_TIME)).thenReturn(20 * 60 * 1000L);+ Mockito.when(config.get(STORE_DELETE_AFTER_TIME)).thenReturn(20 * 60 * 1000L);return config;}diff --git a/core/src/test/java/com/datastrato/gravitino/storage/kv/TestStorageVersion.java b/core/src/test/java/com/datastrato/gravitino/storage/kv/TestStorageVersion.javaindex 87a75ee77f..82348de0cc 100644--- a/core/src/test/java/com/datastrato/gravitino/storage/kv/TestStorageVersion.java+++ b/core/src/test/java/com/datastrato/gravitino/storage/kv/TestStorageVersion.java@@ -9,7 +9,7 @@ import static com.datastrato.gravitino.Configs.DEFAULT_ENTITY_KV_STORE;import static com.datastrato.gravitino.Configs.ENTITY_KV_STORE;import static com.datastrato.gravitino.Configs.ENTITY_STORE;import static com.datastrato.gravitino.Configs.ENTRY_KV_ROCKSDB_BACKEND_PATH;-import static com.datastrato.gravitino.Configs.KV_DELETE_AFTER_TIME;+import static com.datastrato.gravitino.Configs.STORE_DELETE_AFTER_TIME;import static com.datastrato.gravitino.Configs.STORE_TRANSACTION_MAX_SKEW_TIME;import com.datastrato.gravitino.Config;@@ -48,7 +48,7 @@ class TestStorageVersion {Mockito.when(config.get(Configs.ENTITY_SERDE)).thenReturn("proto");Mockito.when(config.get(ENTRY_KV_ROCKSDB_BACKEND_PATH)).thenReturn(file.getAbsolutePath());Mockito.when(config.get(STORE_TRANSACTION_MAX_SKEW_TIME)).thenReturn(1000L);- Mockito.when(config.get(KV_DELETE_AFTER_TIME)).thenReturn(20 * 60 * 1000L);+ Mockito.when(config.get(STORE_DELETE_AFTER_TIME)).thenReturn(20 * 60 * 1000L);// First time create entity store, the storage layout version should be DEFAULT_LAYOUT_VERSIONtry (EntityStore store = EntityStoreFactory.createEntityStore(config)) {diff --git a/docs/gravitino-server-config.md b/docs/gravitino-server-config.mdindex 7150c7fa8d..315d7844ee 100644--- a/docs/gravitino-server-config.md+++ b/docs/gravitino-server-config.md@@ -43,19 +43,20 @@ You can also specify filter parameters by setting configuration entries of the f### Storage configuration-| Configuration item | Description | Default value | Required | Since version |-|---------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------|----------------------------------|---------------|-| `gravitino.entity.store` | Which storage implementation to use. Key-value pair storage and relational storage are currently supported, the default value is `kv`, and the optional value is `relational`. | `kv` | No | 0.1.0 |-| `gravitino.entity.store.kv` | Detailed implementation of KV storage. `RocksDB` storage is currently supported, and the implementation is `RocksDBKvBackend`. | `RocksDBKvBackend` | No | 0.1.0 |-| `gravitino.entity.store.kv.rocksdbPath` | The storage path for RocksDB storage implementation. It supports both absolute and relative path, if the value is a relative path, the final path is `${GRAVITINO_HOME}/${PATH_YOU_HAVA_SET}`, default value is `${GRAVITINO_HOME}/data/rocksdb` | `${GRAVITINO_HOME}/data/rocksdb` | No | 0.1.0 |-| `graivitino.entity.serde` | The serialization/deserialization class used to support entity storage. `proto' is currently supported. | `proto` | No | 0.1.0 |-| `gravitino.entity.store.maxTransactionSkewTimeMs` | The maximum skew time of transactions in milliseconds. | `2000` | No | 0.3.0 |-| `gravitino.entity.store.kv.deleteAfterTimeMs` | The maximum time in milliseconds that deleted and old-version data is kept. Set to at least 10 minutes and no longer than 30 days. | `604800000`(7 days) | No | 0.3.0 |-| `gravitino.entity.store.relational` | Detailed implementation of Relational storage. `MySQL` is currently supported, and the implementation is `JDBCBackend`. | `JDBCBackend` | No | 0.5.0 |-| `gravitino.entity.store.relational.jdbcUrl` | The database url that the `JDBCBackend` needs to connect to. If you use `MySQL`, you should firstly initialize the database tables yourself by executing the file named `mysql_init.sql` in the `src/main/resources/mysql` directory of the `core` module. | (none) | Yes if you use `JdbcBackend` | 0.5.0 |-| `gravitino.entity.store.relational.jdbcDriver` | The jdbc driver name that the `JDBCBackend` needs to use. You should place the driver Jar package in the `${GRAVITINO_HOME}/libs/` directory. | (none) | Yes if you use `JdbcBackend` | 0.5.0 |-| `gravitino.entity.store.relational.jdbcUser` | The username that the `JDBCBackend` needs to use when connecting the database. It is required for `MySQL`. | (none) | Yes if you use `JdbcBackend` | 0.5.0 |-| `gravitino.entity.store.relational.jdbcPassword` | The password that the `JDBCBackend` needs to use when connecting the database. It is required for `MySQL`. | (none) | Yes if you use `JdbcBackend` | 0.5.0 |+| Configuration item | Description | Default value | Required | Since version |+|------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------|----------------------------------|---------------|+| `gravitino.entity.store` | Which storage implementation to use. Key-value pair storage and relational storage are currently supported, the default value is `kv`, and the optional value is `relational`. | `kv` | No | 0.1.0 |+| `gravitino.entity.store.kv` | Detailed implementation of KV storage. `RocksDB` storage is currently supported, and the implementation is `RocksDBKvBackend`. | `RocksDBKvBackend` | No | 0.1.0 |+| `gravitino.entity.store.kv.rocksdbPath` | The storage path for RocksDB storage implementation. It supports both absolute and relative path, if the value is a relative path, the final path is `${GRAVITINO_HOME}/${PATH_YOU_HAVA_SET}`, default value is `${GRAVITINO_HOME}/data/rocksdb` | `${GRAVITINO_HOME}/data/rocksdb` | No | 0.1.0 |+| `graivitino.entity.serde` | The serialization/deserialization class used to support entity storage. `proto' is currently supported. | `proto` | No | 0.1.0 |+| `gravitino.entity.store.maxTransactionSkewTimeMs` | The maximum skew time of transactions in milliseconds. | `2000` | No | 0.3.0 |+| `gravitino.entity.store.deleteAfterTimeMs` | The maximum time in milliseconds that deleted and old-version data is kept. Set to at least 10 minutes and no longer than 30 days. | `604800000`(7 days) | No | 0.5.0 |+| `gravitino.entity.store.versionRetentionCount` | The Count of versions allowed to be retained, including the current version, used to delete old versions data. Set to at least 1 and no greater than 10. | `1` | No | 0.5.0 |+| `gravitino.entity.store.relational` | Detailed implementation of Relational storage. `MySQL` is currently supported, and the implementation is `JDBCBackend`. | `JDBCBackend` | No | 0.5.0 |+| `gravitino.entity.store.relational.jdbcUrl` | The database url that the `JDBCBackend` needs to connect to. If you use `MySQL`, you should firstly initialize the database tables yourself by executing the file named `mysql_init.sql` in the `src/main/resources/mysql` directory of the `core` module. | (none) | Yes if you use `JdbcBackend` | 0.5.0 |+| `gravitino.entity.store.relational.jdbcDriver` | The jdbc driver name that the `JDBCBackend` needs to use. You should place the driver Jar package in the `${GRAVITINO_HOME}/libs/` directory. | (none) | Yes if you use `JdbcBackend` | 0.5.0 |+| `gravitino.entity.store.relational.jdbcUser` | The username that the `JDBCBackend` needs to use when connecting the database. It is required for `MySQL`. | (none) | Yes if you use `JdbcBackend` | 0.5.0 |+| `gravitino.entity.store.relational.jdbcPassword` | The password that the `JDBCBackend` needs to use when connecting the database. It is required for `MySQL`. | (none) | Yes if you use `JdbcBackend` | 0.5.0 |:::cautionWe strongly recommend that you change the default value of `gravitino.entity.store.kv.rocksdbPath`, as it's under the deployment directory and future version upgrades may remove it.