From 4a0ae7d8d54f67a63e9289ca892b3faf214e3f68 Mon Sep 17 00:00:00 2001 From: Bingkun Guo Date: Fri, 26 Jun 2015 15:35:43 -0500 Subject: [PATCH] Fix inconsistent druid property names for "druid.metadata.storage.tables.xxx" between document and code --- docs/content/configuration/index.md | 6 +- .../MetadataStorageTablesConfigTest.java | 82 +++++++++++++++++++ .../test/resources/test.runtime.properties | 8 ++ .../realtime/DbSegmentPublisherConfig.java | 2 +- .../druid/cli/convert/ConvertProperties.java | 6 +- .../resources/convertProps/new.properties | 6 +- 6 files changed, 100 insertions(+), 10 deletions(-) create mode 100644 processing/src/test/java/io/druid/guice/MetadataStorageTablesConfigTest.java create mode 100644 processing/src/test/resources/test.runtime.properties diff --git a/docs/content/configuration/index.md b/docs/content/configuration/index.md index 6a4045930bc..9eca166effd 100644 --- a/docs/content/configuration/index.md +++ b/docs/content/configuration/index.md @@ -152,9 +152,9 @@ These properties specify the jdbc connection and other configuration around the |`druid.metadata.storage.connector.password`|The password to connect with.|none| |`druid.metadata.storage.connector.createTables`|If Druid requires a table and it doesn't exist, create it?|true| |`druid.metadata.storage.tables.base`|The base name for tables.|druid| -|`druid.metadata.storage.tables.segmentTable`|The table to use to look for segments.|druid_segments| -|`druid.metadata.storage.tables.ruleTable`|The table to use to look for segment load/drop rules.|druid_rules| -|`druid.metadata.storage.tables.configTable`|The table to use to look for configs.|druid_config| +|`druid.metadata.storage.tables.segments`|The table to use to look for segments.|druid_segments| +|`druid.metadata.storage.tables.rules`|The table to use to look for segment load/drop rules.|druid_rules| +|`druid.metadata.storage.tables.config`|The table to use to look for configs.|druid_config| |`druid.metadata.storage.tables.tasks`|Used by the indexing service to store tasks.|druid_tasks| |`druid.metadata.storage.tables.taskLog`|Used by the indexing service to store task logs.|druid_taskLog| |`druid.metadata.storage.tables.taskLock`|Used by the indexing service to store task locks.|druid_taskLock| diff --git a/processing/src/test/java/io/druid/guice/MetadataStorageTablesConfigTest.java b/processing/src/test/java/io/druid/guice/MetadataStorageTablesConfigTest.java new file mode 100644 index 00000000000..4710bd88665 --- /dev/null +++ b/processing/src/test/java/io/druid/guice/MetadataStorageTablesConfigTest.java @@ -0,0 +1,82 @@ +/* + * Licensed to Metamarkets Group Inc. (Metamarkets) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. Metamarkets licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package io.druid.guice; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.inject.Binder; +import com.google.inject.Guice; +import com.google.inject.Injector; +import com.google.inject.Module; +import com.google.inject.Provides; +import io.druid.jackson.DefaultObjectMapper; +import io.druid.metadata.MetadataStorageTablesConfig; +import org.junit.Assert; +import org.junit.Test; + +import java.util.Arrays; +import java.util.Properties; + +public class MetadataStorageTablesConfigTest +{ + @Test + public void testSerdeMetadataStorageTablesConfig() throws Exception + { + Injector injector = Guice.createInjector( + new Module() + { + @Override + public void configure(Binder binder) + { + binder.install(new PropertiesModule(Arrays.asList("test.runtime.properties"))); + binder.install(new ConfigModule()); + binder.install(new DruidGuiceExtensions()); + JsonConfigProvider.bind(binder, "druid.metadata.storage.tables", MetadataStorageTablesConfig.class); + } + + @Provides + @LazySingleton + public ObjectMapper jsonMapper() + { + return new DefaultObjectMapper(); + } + } + ); + + Properties props = injector.getInstance(Properties.class); + MetadataStorageTablesConfig config = injector.getInstance(MetadataStorageTablesConfig.class); + + Assert.assertEquals(props.getProperty("druid.metadata.storage.tables.base"), config.getBase()); + Assert.assertEquals(props.getProperty("druid.metadata.storage.tables.segments"), config.getSegmentsTable()); + Assert.assertEquals(props.getProperty("druid.metadata.storage.tables.rules"), config.getRulesTable()); + Assert.assertEquals(props.getProperty("druid.metadata.storage.tables.config"), config.getConfigTable()); + Assert.assertEquals( + props.getProperty("druid.metadata.storage.tables.tasks"), + config.getEntryTable(MetadataStorageTablesConfig.TASK_ENTRY_TYPE) + ); + Assert.assertEquals( + props.getProperty("druid.metadata.storage.tables.taskLog"), + config.getLogTable(MetadataStorageTablesConfig.TASK_ENTRY_TYPE) + ); + Assert.assertEquals( + props.getProperty("druid.metadata.storage.tables.taskLock"), + config.getLockTable(MetadataStorageTablesConfig.TASK_ENTRY_TYPE) + ); + } +} diff --git a/processing/src/test/resources/test.runtime.properties b/processing/src/test/resources/test.runtime.properties new file mode 100644 index 00000000000..c87aa9003cc --- /dev/null +++ b/processing/src/test/resources/test.runtime.properties @@ -0,0 +1,8 @@ +druid.metadata.storage.tables.base=druid +druid.metadata.storage.tables.segments=aaa_segments +druid.metadata.storage.tables.rules=bbb_rules +druid.metadata.storage.tables.config=ccc_config +druid.metadata.storage.tables.tasks=ddd_tasks +druid.metadata.storage.tables.taskLog=eee_tasklog +druid.metadata.storage.tables.taskLock=fff_tasklock +druid.metadata.storage.tables.audit=ggg_audit diff --git a/server/src/main/java/io/druid/segment/realtime/DbSegmentPublisherConfig.java b/server/src/main/java/io/druid/segment/realtime/DbSegmentPublisherConfig.java index 834fbb9eb46..b463982fdfd 100644 --- a/server/src/main/java/io/druid/segment/realtime/DbSegmentPublisherConfig.java +++ b/server/src/main/java/io/druid/segment/realtime/DbSegmentPublisherConfig.java @@ -21,6 +21,6 @@ import org.skife.config.Config; public abstract class DbSegmentPublisherConfig { - @Config("druid.metadata.storage.tables.segmentTable") + @Config("druid.metadata.storage.tables.segments") public abstract String getSegmentTable(); } diff --git a/services/src/main/java/io/druid/cli/convert/ConvertProperties.java b/services/src/main/java/io/druid/cli/convert/ConvertProperties.java index 97690e0aa12..5bfee723be2 100644 --- a/services/src/main/java/io/druid/cli/convert/ConvertProperties.java +++ b/services/src/main/java/io/druid/cli/convert/ConvertProperties.java @@ -72,9 +72,9 @@ public class ConvertProperties implements Runnable new Remove("druid.db.connector.useValidationQuery"), new Rename("druid.db.connector.createTables", "druid.metadata.storage.connector.createTables"), new Rename("druid.db.tables.base", "druid.metadata.storage.tables.base"), - new Rename("druid.db.tables.configTable", "druid.metadata.storage.tables.configTable"), - new Rename("druid.db.tables.segmentTable", "druid.metadata.storage.tables.segmentTable"), - new Rename("druid.db.tables.ruleTable", "druid.metadata.storage.tables.ruleTable"), + new Rename("druid.db.tables.configTable", "druid.metadata.storage.tables.config"), + new Rename("druid.db.tables.segmentTable", "druid.metadata.storage.tables.segments"), + new Rename("druid.db.tables.ruleTable", "druid.metadata.storage.tables.rules"), new Rename("druid.db.tables.taskLock", "druid.metadata.storage.tables.taskLock"), new Rename("druid.db.tables.tasks", "druid.metadata.storage.tables.tasks"), new Rename("druid.db.tables.taskLog", "druid.metadata.storage.tables.taskLog"), diff --git a/services/src/test/resources/convertProps/new.properties b/services/src/test/resources/convertProps/new.properties index 008bddd1a4e..cab63ffa502 100644 --- a/services/src/test/resources/convertProps/new.properties +++ b/services/src/test/resources/convertProps/new.properties @@ -5,9 +5,9 @@ druid.metadata.storage.connector.password=diurd druid.metadata.storage.connector.user=druid druid.metadata.storage.tables.base=druid -druid.metadata.storage.tables.segmentTable=druid_segments -druid.metadata.storage.tables.ruleTable=druid_rules -druid.metadata.storage.tables.configTable=druid_config +druid.metadata.storage.tables.segments=druid_segments +druid.metadata.storage.tables.rules=druid_rules +druid.metadata.storage.tables.config=druid_config druid.metadata.storage.tables.tasks=druid_tasks druid.metadata.storage.tables.taskLog=druid_taskLog druid.metadata.storage.tables.taskLock=druid_taskLock