http://git-wip-us.apache.org/repos/asf/asterixdb/blob/4c7b5bfa/asterixdb/asterix-app/src/test/java/org/apache/asterix/app/bootstrap/TestNodeController.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/java/org/apache/asterix/app/bootstrap/TestNodeController.java b/asterixdb/asterix-app/src/test/java/org/apache/asterix/app/bootstrap/TestNodeController.java index cc12f36..2061cda 100644 --- a/asterixdb/asterix-app/src/test/java/org/apache/asterix/app/bootstrap/TestNodeController.java +++ b/asterixdb/asterix-app/src/test/java/org/apache/asterix/app/bootstrap/TestNodeController.java @@ -58,7 +58,6 @@ import org.apache.asterix.transaction.management.resource.LSMBTreeLocalResourceM import org.apache.asterix.transaction.management.resource.PersistentLocalResourceFactoryProvider; import org.apache.asterix.transaction.management.runtime.CommitRuntime; import org.apache.asterix.transaction.management.service.logging.LogReader; -import org.apache.commons.lang3.StringUtils; import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException; import org.apache.hyracks.algebricks.runtime.base.IPushRuntime; import org.apache.hyracks.algebricks.runtime.operators.std.EmptyTupleSourceRuntimeFactory; @@ -93,6 +92,7 @@ import org.apache.hyracks.storage.am.lsm.common.impls.NoMergePolicyFactory; import org.apache.hyracks.storage.common.file.ILocalResourceFactoryProvider; import org.apache.hyracks.storage.common.file.LocalResource; import org.apache.hyracks.test.support.TestUtils; +import org.apache.hyracks.util.file.FileUtil; import org.mockito.Mockito; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; @@ -101,8 +101,7 @@ public class TestNodeController { protected static final Logger LOGGER = Logger.getLogger(TestNodeController.class.getName()); protected static final String PATH_ACTUAL = "unittest" + File.separator; - protected static final String PATH_BASE = - StringUtils.join(new String[] { "src", "test", "resources", "nodetests" }, File.separator); + protected static final String PATH_BASE = FileUtil.joinPath("src", "test", "resources", "nodetests"); protected static final String TEST_CONFIG_FILE_NAME = "asterix-build-configuration.xml"; protected static TransactionProperties txnProperties;
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/4c7b5bfa/asterixdb/asterix-app/src/test/java/org/apache/asterix/common/config/ConfigUsageTest.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/java/org/apache/asterix/common/config/ConfigUsageTest.java b/asterixdb/asterix-app/src/test/java/org/apache/asterix/common/config/ConfigUsageTest.java new file mode 100644 index 0000000..b96b7fe --- /dev/null +++ b/asterixdb/asterix-app/src/test/java/org/apache/asterix/common/config/ConfigUsageTest.java @@ -0,0 +1,146 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF 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 org.apache.asterix.common.config; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.PrintStream; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; + +import org.apache.asterix.hyracks.bootstrap.CCApplicationEntryPoint; +import org.apache.hyracks.api.config.IOption; +import org.apache.hyracks.api.config.Section; +import org.apache.hyracks.control.common.config.ConfigManager; +import org.apache.hyracks.util.file.FileUtil; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +@RunWith(JUnit4.class) +public class ConfigUsageTest { + + private static final String CSV_FILE = FileUtil.joinPath("target", "surefire-reports", "config-options.csv"); + + @Test + public void generateUsage() { + generateUsage("| ", " | ", " |", true, System.err); + } + + @Test + public void generateUsageCSV() throws IOException { + new File(CSV_FILE).getParentFile().mkdirs(); + try (final PrintStream output = new PrintStream(new FileOutputStream(CSV_FILE))) { + generateUsage("\"", "\",\"", "\"", false, output); + // TODO(mblow): add some validation (in addition to just ensuring no exceptions...) + } + } + + public void generateUsage(String startDelim, String midDelim, String endDelim, boolean align, PrintStream output) { + ConfigManager configManager = new ConfigManager(); + CCApplicationEntryPoint aep = new CCApplicationEntryPoint(); + aep.registerConfig(configManager); + StringBuilder buf = new StringBuilder(); + int maxSectionWidth = 0; + int maxNameWidth = 0; + int maxDescriptionWidth = 0; + int maxDefaultWidth = 0; + if (align) { + for (Section section : configManager.getSections()) { + maxSectionWidth = Math.max(maxSectionWidth, section.sectionName().length()); + for (IOption option : configManager.getOptions(section)) { + if (option.hidden()) { + continue; + } + maxNameWidth = Math.max(maxNameWidth, option.ini().length()); + maxDescriptionWidth = Math.max(maxDescriptionWidth, + option.description() == null ? 0 : option.description().length()); + maxDefaultWidth = Math.max(maxDefaultWidth, configManager.defaultTextForUsage(option, IOption::ini) + .length()); + } + } + } + maxDescriptionWidth = Math.min(80, maxDescriptionWidth); + for (Section section : configManager.getSections()) { + List<IOption> options = new ArrayList<>(configManager.getOptions(section)); + options.sort(Comparator.comparing(IOption::ini)); + for (IOption option : options) { + if (option.hidden()) { + continue; + } + buf.append(startDelim); + center(buf, section.sectionName(), maxSectionWidth).append(midDelim); + pad(buf, option.ini(), maxNameWidth).append(midDelim); + String description = option.description() == null ? "" : option.description(); + String defaultText = configManager.defaultTextForUsage(option, IOption::ini); + boolean extra = false; + while (align && description.length() > maxDescriptionWidth) { + int cut = description.lastIndexOf(' ', maxDescriptionWidth); + pad(buf, description.substring(0, cut), maxDescriptionWidth).append(midDelim); + pad(buf, defaultText, maxDefaultWidth).append(endDelim).append('\n'); + defaultText = ""; + description = description.substring(cut + 1); + buf.append(startDelim); + pad(buf, "", maxSectionWidth).append(midDelim); + pad(buf, "", maxNameWidth).append(midDelim); + } + pad(buf, description, maxDescriptionWidth).append(midDelim); + pad(buf, defaultText, maxDefaultWidth).append(endDelim).append('\n'); + if (extra) { + buf.append(startDelim); + pad(buf, "", maxSectionWidth).append(midDelim); + pad(buf, "", maxNameWidth).append(midDelim); + pad(buf, "", maxDescriptionWidth).append(midDelim); + pad(buf, "", maxDefaultWidth).append(endDelim).append('\n'); + } + } + } + output.println(buf); + } + + private StringBuilder center(StringBuilder buf, String string, int width) { + if (string == null) { + string = ""; + } + int pad = width - string.length(); + int leftPad = pad / 2; + for (int i = leftPad; i > 0; i--) { + buf.append(' '); + } + buf.append(string); + for (int i = pad - leftPad; i > 0; i--) { + buf.append(' '); + } + return buf; + } + + private StringBuilder pad(StringBuilder buf, String string, int width) { + if (string == null) { + string = ""; + } + buf.append(string); + for (int i = width - string.length(); i > 0; i--) { + buf.append(' '); + } + return buf; + } + +} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/4c7b5bfa/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/TestExecutor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/TestExecutor.java b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/TestExecutor.java index ae40827..7765572 100644 --- a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/TestExecutor.java +++ b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/TestExecutor.java @@ -1113,13 +1113,13 @@ public class TestExecutor { private void deleteNCTxnLogs(String nodeId, CompilationUnit cUnit) throws Exception { OutputFormat fmt = OutputFormat.forCompilationUnit(cUnit); - String endpoint = "/admin/cluster"; + String endpoint = "/admin/cluster/node/" + nodeId + "/config"; InputStream executeJSONGet = executeJSONGet(fmt, new URI("http://" + host + ":" + port + endpoint)); StringWriter actual = new StringWriter(); IOUtils.copy(executeJSONGet, actual, StandardCharsets.UTF_8); String config = actual.toString(); ObjectMapper om = new ObjectMapper(); - String logDir = om.readTree(config).findPath("transaction.log.dirs").get(nodeId).asText(); + String logDir = om.readTree(config).findPath("txn.log.dir").asText(); FileUtils.deleteQuietly(new File(logDir)); } http://git-wip-us.apache.org/repos/asf/asterixdb/blob/4c7b5bfa/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/TestHelper.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/TestHelper.java b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/TestHelper.java index c1399fb..df9782a 100644 --- a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/TestHelper.java +++ b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/common/TestHelper.java @@ -38,7 +38,7 @@ import org.apache.asterix.common.configuration.AsterixConfiguration; import org.apache.asterix.common.exceptions.AsterixException; import org.apache.commons.compress.utils.IOUtils; import org.apache.commons.io.FileUtils; -import org.apache.commons.lang3.StringUtils; +import org.apache.hyracks.util.file.FileUtil; public final class TestHelper { @@ -54,10 +54,6 @@ public final class TestHelper { return false; } - public static String joinPath(String... pathElements) { - return StringUtils.join(pathElements, File.separatorChar); - } - public static void unzip(String sourceFile, String outputDir) throws IOException { if (System.getProperty("os.name").toLowerCase().startsWith("win")) { try (ZipFile zipFile = new ZipFile(sourceFile)) { @@ -117,7 +113,7 @@ public final class TestHelper { public static void deleteExistingInstanceFiles() { for (String dirName : TEST_DIRS) { - File f = new File(joinPath(TEST_DIR_BASE_PATH, dirName)); + File f = new File(FileUtil.joinPath(TEST_DIR_BASE_PATH, dirName)); if (FileUtils.deleteQuietly(f)) { System.out.println("Dir " + f.getName() + " deleted"); } http://git-wip-us.apache.org/repos/asf/asterixdb/blob/4c7b5bfa/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/logging/CheckpointingTest.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/logging/CheckpointingTest.java b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/logging/CheckpointingTest.java index 10e8658..34bb9cf 100644 --- a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/logging/CheckpointingTest.java +++ b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/logging/CheckpointingTest.java @@ -82,7 +82,7 @@ public class CheckpointingTest { private static final String DATASET_NAME = "TestDS"; private static final String DATA_TYPE_NAME = "DUMMY"; private static final String NODE_GROUP_NAME = "DEFAULT"; - private static final int TXN_LOG_PARTITION_SIZE = StorageUtil.getSizeInBytes(2, StorageUnit.MEGABYTE); + private static final int TXN_LOG_PARTITION_SIZE = StorageUtil.getIntSizeInBytes(2, StorageUnit.MEGABYTE); @Before public void setUp() throws Exception { http://git-wip-us.apache.org/repos/asf/asterixdb/blob/4c7b5bfa/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/runtime/ClusterStateDefaultParameterTest.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/runtime/ClusterStateDefaultParameterTest.java b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/runtime/ClusterStateDefaultParameterTest.java index 545b2a1..86a9639 100644 --- a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/runtime/ClusterStateDefaultParameterTest.java +++ b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/runtime/ClusterStateDefaultParameterTest.java @@ -65,7 +65,7 @@ public class ClusterStateDefaultParameterTest { @Test public void test() throws Exception { StringBuilder result = new StringBuilder(); - URL url = new URL("http://localhost:19002/admin/cluster"); + URL url = new URL("http://localhost:19002/admin/cluster/node/asterix_nc1/config"); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("GET"); BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream())); http://git-wip-us.apache.org/repos/asf/asterixdb/blob/4c7b5bfa/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/sqlpp/OptimizerParserTest.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/sqlpp/OptimizerParserTest.java b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/sqlpp/OptimizerParserTest.java index 31103a8..486a219 100644 --- a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/sqlpp/OptimizerParserTest.java +++ b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/sqlpp/OptimizerParserTest.java @@ -24,7 +24,7 @@ import java.util.Collection; import java.util.logging.Logger; import org.apache.asterix.test.base.AsterixTestHelper; -import org.apache.asterix.test.common.TestHelper; +import org.apache.hyracks.util.file.FileUtil; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; @@ -41,10 +41,10 @@ public class OptimizerParserTest { private static final String EXTENSION_RESULT = "ast"; private static final String FILENAME_IGNORE = "ignore.txt"; private static final String FILENAME_ONLY = "only.txt"; - private static final String PATH_BASE = TestHelper.joinPath("src", "test", "resources", "optimizerts"); - private static final String PATH_QUERIES = TestHelper.joinPath(PATH_BASE, "queries_sqlpp"); - private static final String PATH_EXPECTED = TestHelper.joinPath(PATH_BASE, "results_parser_sqlpp"); - private static final String PATH_ACTUAL = TestHelper.joinPath("target", "opt_parserts", "results_parser_sqlpp"); + private static final String PATH_BASE = FileUtil.joinPath("src", "test", "resources", "optimizerts"); + private static final String PATH_QUERIES = FileUtil.joinPath(PATH_BASE, "queries_sqlpp"); + private static final String PATH_EXPECTED = FileUtil.joinPath(PATH_BASE, "results_parser_sqlpp"); + private static final String PATH_ACTUAL = FileUtil.joinPath("target", "opt_parserts", "results_parser_sqlpp"); private static final ArrayList<String> ignore = AsterixTestHelper.readFile(FILENAME_IGNORE, PATH_BASE); private static final ArrayList<String> only = AsterixTestHelper.readFile(FILENAME_ONLY, PATH_BASE); http://git-wip-us.apache.org/repos/asf/asterixdb/blob/4c7b5bfa/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/sqlpp/ParserTestUtil.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/sqlpp/ParserTestUtil.java b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/sqlpp/ParserTestUtil.java index 891e463..9c3c393 100644 --- a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/sqlpp/ParserTestUtil.java +++ b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/sqlpp/ParserTestUtil.java @@ -25,6 +25,7 @@ import java.util.logging.Logger; import org.apache.asterix.test.base.AsterixTestHelper; import org.apache.asterix.test.common.TestHelper; +import org.apache.hyracks.util.file.FileUtil; import org.junit.Assume; import org.junit.internal.AssumptionViolatedException; @@ -34,15 +35,15 @@ class ParserTestUtil { String extensionQuery, String extensionResult, String pathExpected, String pathActual) { if (file.isDirectory() && !file.getName().startsWith(".")) { for (File innerfile : file.listFiles()) { - String subdir = innerfile.isDirectory() ? TestHelper.joinPath(path, innerfile.getName()) : path; + String subdir = innerfile.isDirectory() ? FileUtil.joinPath(path, innerfile.getName()) : path; suiteBuild(innerfile, testArgs, subdir, separator, extensionQuery, extensionResult, pathExpected, pathActual); } } if (file.isFile() && file.getName().endsWith(extensionQuery)) { String resultFileName = AsterixTestHelper.extToResExt(file.getName(), extensionResult); - File expectedFile = new File(TestHelper.joinPath(pathExpected, path, resultFileName)); - File actualFile = new File(TestHelper.joinPath(pathActual, path, resultFileName)); + File expectedFile = new File(FileUtil.joinPath(pathExpected, path, resultFileName)); + File actualFile = new File(FileUtil.joinPath(pathActual, path, resultFileName)); testArgs.add(new Object[] { file, expectedFile, actualFile }); } } http://git-wip-us.apache.org/repos/asf/asterixdb/blob/4c7b5bfa/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/sqlpp/SmokeParserTest.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/sqlpp/SmokeParserTest.java b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/sqlpp/SmokeParserTest.java index 8fe9370..3c856b5 100644 --- a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/sqlpp/SmokeParserTest.java +++ b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/sqlpp/SmokeParserTest.java @@ -24,7 +24,7 @@ import java.util.Collection; import java.util.logging.Logger; import org.apache.asterix.test.base.AsterixTestHelper; -import org.apache.asterix.test.common.TestHelper; +import org.apache.hyracks.util.file.FileUtil; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; @@ -41,10 +41,10 @@ public class SmokeParserTest { private static final String EXTENSION_RESULT = "ast"; private static final String FILENAME_IGNORE = "ignore.txt"; private static final String FILENAME_ONLY = "only.txt"; - private static final String PATH_BASE = TestHelper.joinPath("src", "test", "resources", "parserts"); - private static final String PATH_QUERIES = TestHelper.joinPath(PATH_BASE, "queries_sqlpp"); - private static final String PATH_EXPECTED = TestHelper.joinPath(PATH_BASE, "results_parser_sqlpp"); - private static final String PATH_ACTUAL = TestHelper.joinPath("target", "parserts"); + private static final String PATH_BASE = FileUtil.joinPath("src", "test", "resources", "parserts"); + private static final String PATH_QUERIES = FileUtil.joinPath(PATH_BASE, "queries_sqlpp"); + private static final String PATH_EXPECTED = FileUtil.joinPath(PATH_BASE, "results_parser_sqlpp"); + private static final String PATH_ACTUAL = FileUtil.joinPath("target", "parserts"); private static final ArrayList<String> ignore = AsterixTestHelper.readFile(FILENAME_IGNORE, PATH_BASE); private static final ArrayList<String> only = AsterixTestHelper.readFile(FILENAME_ONLY, PATH_BASE); http://git-wip-us.apache.org/repos/asf/asterixdb/blob/4c7b5bfa/asterixdb/asterix-app/src/test/resources/runtimets/api.xml ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/api.xml b/asterixdb/asterix-app/src/test/resources/runtimets/api.xml index 0fa83dd..372aa47 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/api.xml +++ b/asterixdb/asterix-app/src/test/resources/runtimets/api.xml @@ -66,11 +66,6 @@ </compilation-unit> </test-case> <test-case FilePath="api"> - <compilation-unit name="replication"> - <output-dir compare="Text">replication</output-dir> - </compilation-unit> - </test-case> - <test-case FilePath="api"> <compilation-unit name="query_status_1"> <output-dir compare="Text">query_status_1</output-dir> <expected-error>HTTP/1.1 404 Not Found</expected-error> http://git-wip-us.apache.org/repos/asf/asterixdb/blob/4c7b5bfa/asterixdb/asterix-app/src/test/resources/runtimets/queries/api/APIQueries.xml ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/api/APIQueries.xml b/asterixdb/asterix-app/src/test/resources/runtimets/queries/api/APIQueries.xml new file mode 100644 index 0000000..e69de29 http://git-wip-us.apache.org/repos/asf/asterixdb/blob/4c7b5bfa/asterixdb/asterix-app/src/test/resources/runtimets/queries/api/replication/replication.1.get.http ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/api/replication/replication.1.get.http b/asterixdb/asterix-app/src/test/resources/runtimets/queries/api/replication/replication.1.get.http deleted file mode 100644 index 5976b5d..0000000 --- a/asterixdb/asterix-app/src/test/resources/runtimets/queries/api/replication/replication.1.get.http +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF 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. - */ -/* - * Test case Name : replication - * Description : Replication - * Expected Result : Positive - * Date : 28th October 2016 - */ -/admin/cluster/replication http://git-wip-us.apache.org/repos/asf/asterixdb/blob/4c7b5bfa/asterixdb/asterix-app/src/test/resources/runtimets/results/api/cluster_state_1/cluster_state_1.1.adm ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/api/cluster_state_1/cluster_state_1.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/api/cluster_state_1/cluster_state_1.1.adm index 42fb7c3..03884bd 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/results/api/cluster_state_1/cluster_state_1.1.adm +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/api/cluster_state_1/cluster_state_1.1.adm @@ -5,110 +5,32 @@ "threadDumpUri" : "http://127.0.0.1:19002/admin/cluster/cc/threaddump" }, "config" : { - "api.port" : 19002, - "cluster.partitions" : { - "0" : { - "partitionId" : 0, - "nodeId" : "asterix_nc1", - "activeNodeId" : "asterix_nc1", - "active" : true, - "iodeviceNum" : 0 - }, - "1" : { - "partitionId" : 1, - "nodeId" : "asterix_nc1", - "activeNodeId" : "asterix_nc1", - "active" : true, - "iodeviceNum" : 1 - }, - "2" : { - "partitionId" : 2, - "nodeId" : "asterix_nc2", - "activeNodeId" : "asterix_nc2", - "active" : true, - "iodeviceNum" : 0 - }, - "3" : { - "partitionId" : 3, - "nodeId" : "asterix_nc2", - "activeNodeId" : "asterix_nc2", - "active" : true, - "iodeviceNum" : 1 - } - }, "compiler.framesize" : 32768, "compiler.groupmemory" : 163840, "compiler.joinmemory" : 262144, "compiler.parallelism" : 0, "compiler.pregelix.home" : "~/pregelix", "compiler.sortmemory" : 327680, - "core.dump.paths" : { }, "feed.central.manager.port" : 4500, "feed.max.threshold.period" : 5, "feed.memory.available.wait.timeout" : 10, "feed.memory.global.budget" : 67108864, "feed.pending.work.threshold" : 50, - "feed.port" : 19003, - "instance.name" : null, - "log.level" : "WARNING", + "instance.name" : "DEFAULT_INSTANCE", + "log.level" : "INFO", "max.wait.active.cluster" : 60, + "messaging.frame.count" : 512, + "messaging.frame.size" : 4096, "metadata.callback.port" : 0, + "metadata.listen.port" : 0, "metadata.node" : "asterix_nc1", - "metadata.partition" : { - "partitionId" : 0, - "nodeId" : "asterix_nc1", - "activeNodeId" : "asterix_nc1", - "active" : true, - "iodeviceNum" : 0 - }, - "metadata.port" : 0, "metadata.registration.timeout.secs" : 60, - "node.partitions" : { - "asterix_nc1" : [ { - "partitionId" : 0, - "nodeId" : "asterix_nc1", - "activeNodeId" : "asterix_nc1", - "active" : true, - "iodeviceNum" : 0 - }, { - "partitionId" : 1, - "nodeId" : "asterix_nc1", - "activeNodeId" : "asterix_nc1", - "active" : true, - "iodeviceNum" : 1 - } ], - "asterix_nc2" : [ { - "partitionId" : 2, - "nodeId" : "asterix_nc2", - "activeNodeId" : "asterix_nc2", - "active" : true, - "iodeviceNum" : 0 - }, { - "partitionId" : 3, - "nodeId" : "asterix_nc2", - "activeNodeId" : "asterix_nc2", - "active" : true, - "iodeviceNum" : 1 - } ] - }, - "node.stores" : { - "asterix_nc1" : [ "iodevice0", "iodevice1" ], - "asterix_nc2" : [ "iodevice0", "iodevice1" ] - }, "plot.activate" : false, - "storage.buffercache.maxopenfiles" : 2147483647, - "storage.buffercache.pagesize" : 32768, - "storage.buffercache.size" : 50331648, - "storage.lsm.bloomfilter.falsepositiverate" : 0.01, - "storage.memorycomponent.globalbudget" : 536870912, - "storage.memorycomponent.numcomponents" : 2, - "storage.memorycomponent.numpages" : 8, - "storage.memorycomponent.pagesize" : 131072, - "storage.metadata.memorycomponent.numpages" : 85, - "transaction.log.dirs" : { - "asterix_nc1" : "target/txnLogDir/asterix_nc1", - "asterix_nc2" : "target/txnLogDir/asterix_nc2" - }, + "replication.log.batchsize" : 4096, + "replication.log.buffer.numpages" : 8, + "replication.log.buffer.pagesize" : 131072, + "replication.max.remote.recovery.attempts" : 5, + "replication.timeout" : 30, "txn.commitprofiler.reportinterval" : 5, "txn.job.recovery.memorysize" : 67108864, "txn.lock.escalationthreshold" : 1000, @@ -120,10 +42,7 @@ "txn.log.checkpoint.history" : 0, "txn.log.checkpoint.lsnthreshold" : 67108864, "txn.log.checkpoint.pollfrequency" : 120, - "txn.log.partitionsize" : 268435456, - "web.port" : 19001, - "web.queryinterface.port" : 19006, - "web.secondary.port" : 19005 + "txn.log.partitionsize" : 268435456 }, "diagnosticsUri" : "http://127.0.0.1:19002/admin/diagnostics", "fullShutdownUri" : "http://127.0.0.1:19002/admin/shutdown?all=true", @@ -155,7 +74,6 @@ "statsUri" : "http://127.0.0.1:19002/admin/cluster/node/asterix_nc2/stats", "threadDumpUri" : "http://127.0.0.1:19002/admin/cluster/node/asterix_nc2/threaddump" } ], - "replicationUri" : "http://127.0.0.1:19002/admin/cluster/replication", "shutdownUri" : "http://127.0.0.1:19002/admin/shutdown", "state" : "ACTIVE", "versionUri" : "http://127.0.0.1:19002/admin/version" http://git-wip-us.apache.org/repos/asf/asterixdb/blob/4c7b5bfa/asterixdb/asterix-app/src/test/resources/runtimets/results/api/cluster_state_1_full/cluster_state_1_full.1.adm ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/api/cluster_state_1_full/cluster_state_1_full.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/api/cluster_state_1_full/cluster_state_1_full.1.adm index 75c4d3e..372ac00 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/results/api/cluster_state_1_full/cluster_state_1_full.1.adm +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/api/cluster_state_1_full/cluster_state_1_full.1.adm @@ -5,110 +5,32 @@ "threadDumpUri" : "http://127.0.0.1:19002/admin/cluster/cc/threaddump" }, "config" : { - "api.port" : 19002, - "cluster.partitions" : { - "0" : { - "partitionId" : 0, - "nodeId" : "asterix_nc1", - "activeNodeId" : "asterix_nc1", - "active" : true, - "iodeviceNum" : 0 - }, - "1" : { - "partitionId" : 1, - "nodeId" : "asterix_nc1", - "activeNodeId" : "asterix_nc1", - "active" : true, - "iodeviceNum" : 1 - }, - "2" : { - "partitionId" : 2, - "nodeId" : "asterix_nc2", - "activeNodeId" : "asterix_nc2", - "active" : true, - "iodeviceNum" : 0 - }, - "3" : { - "partitionId" : 3, - "nodeId" : "asterix_nc2", - "activeNodeId" : "asterix_nc2", - "active" : true, - "iodeviceNum" : 1 - } - }, "compiler.framesize" : 32768, "compiler.groupmemory" : 163840, "compiler.joinmemory" : 262144, "compiler.parallelism" : -1, "compiler.pregelix.home" : "~/pregelix", "compiler.sortmemory" : 327680, - "core.dump.paths" : { }, "feed.central.manager.port" : 4500, "feed.max.threshold.period" : 5, "feed.memory.available.wait.timeout" : 10, "feed.memory.global.budget" : 67108864, "feed.pending.work.threshold" : 50, - "feed.port" : 19003, - "instance.name" : null, + "instance.name" : "DEFAULT_INSTANCE", "log.level" : "WARNING", "max.wait.active.cluster" : 60, + "messaging.frame.count" : 512, + "messaging.frame.size" : 4096, "metadata.callback.port" : 0, + "metadata.listen.port" : 0, "metadata.node" : "asterix_nc1", - "metadata.partition" : { - "partitionId" : 0, - "nodeId" : "asterix_nc1", - "activeNodeId" : "asterix_nc1", - "active" : true, - "iodeviceNum" : 0 - }, - "metadata.port" : 0, "metadata.registration.timeout.secs" : 60, - "node.partitions" : { - "asterix_nc1" : [ { - "partitionId" : 0, - "nodeId" : "asterix_nc1", - "activeNodeId" : "asterix_nc1", - "active" : true, - "iodeviceNum" : 0 - }, { - "partitionId" : 1, - "nodeId" : "asterix_nc1", - "activeNodeId" : "asterix_nc1", - "active" : true, - "iodeviceNum" : 1 - } ], - "asterix_nc2" : [ { - "partitionId" : 2, - "nodeId" : "asterix_nc2", - "activeNodeId" : "asterix_nc2", - "active" : true, - "iodeviceNum" : 0 - }, { - "partitionId" : 3, - "nodeId" : "asterix_nc2", - "activeNodeId" : "asterix_nc2", - "active" : true, - "iodeviceNum" : 1 - } ] - }, - "node.stores" : { - "asterix_nc1" : [ "iodevice0", "iodevice1" ], - "asterix_nc2" : [ "iodevice0", "iodevice1" ] - }, "plot.activate" : false, - "storage.buffercache.maxopenfiles" : 2147483647, - "storage.buffercache.pagesize" : 32768, - "storage.buffercache.size" : 50331648, - "storage.lsm.bloomfilter.falsepositiverate" : 0.01, - "storage.memorycomponent.globalbudget" : 536870912, - "storage.memorycomponent.numcomponents" : 2, - "storage.memorycomponent.numpages" : 8, - "storage.memorycomponent.pagesize" : 131072, - "storage.metadata.memorycomponent.numpages" : 85, - "transaction.log.dirs" : { - "asterix_nc1" : "target/txnLogDir/asterix_nc1", - "asterix_nc2" : "target/txnLogDir/asterix_nc2" - }, + "replication.log.batchsize" : 4096, + "replication.log.buffer.numpages" : 8, + "replication.log.buffer.pagesize" : 131072, + "replication.max.remote.recovery.attempts" : 5, + "replication.timeout" : 30, "txn.commitprofiler.reportinterval" : 5, "txn.job.recovery.memorysize" : 67108864, "txn.lock.escalationthreshold" : 1000, @@ -120,10 +42,7 @@ "txn.log.checkpoint.history" : 0, "txn.log.checkpoint.lsnthreshold" : 67108864, "txn.log.checkpoint.pollfrequency" : 120, - "txn.log.partitionsize" : 268435456, - "web.port" : 19001, - "web.queryinterface.port" : 19006, - "web.secondary.port" : 19005 + "txn.log.partitionsize" : 268435456 }, "diagnosticsUri" : "http://127.0.0.1:19002/admin/diagnostics", "fullShutdownUri" : "http://127.0.0.1:19002/admin/shutdown?all=true", @@ -155,7 +74,6 @@ "statsUri" : "http://127.0.0.1:19002/admin/cluster/node/asterix_nc2/stats", "threadDumpUri" : "http://127.0.0.1:19002/admin/cluster/node/asterix_nc2/threaddump" } ], - "replicationUri" : "http://127.0.0.1:19002/admin/cluster/replication", "shutdownUri" : "http://127.0.0.1:19002/admin/shutdown", "state" : "ACTIVE", "versionUri" : "http://127.0.0.1:19002/admin/version" http://git-wip-us.apache.org/repos/asf/asterixdb/blob/4c7b5bfa/asterixdb/asterix-app/src/test/resources/runtimets/results/api/cluster_state_1_less/cluster_state_1_less.1.adm ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/api/cluster_state_1_less/cluster_state_1_less.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/api/cluster_state_1_less/cluster_state_1_less.1.adm index 76219aa..9d1ba6e 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/results/api/cluster_state_1_less/cluster_state_1_less.1.adm +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/api/cluster_state_1_less/cluster_state_1_less.1.adm @@ -5,110 +5,32 @@ "threadDumpUri" : "http://127.0.0.1:19002/admin/cluster/cc/threaddump" }, "config" : { - "api.port" : 19002, - "cluster.partitions" : { - "0" : { - "partitionId" : 0, - "nodeId" : "asterix_nc1", - "activeNodeId" : "asterix_nc1", - "active" : true, - "iodeviceNum" : 0 - }, - "1" : { - "partitionId" : 1, - "nodeId" : "asterix_nc1", - "activeNodeId" : "asterix_nc1", - "active" : true, - "iodeviceNum" : 1 - }, - "2" : { - "partitionId" : 2, - "nodeId" : "asterix_nc2", - "activeNodeId" : "asterix_nc2", - "active" : true, - "iodeviceNum" : 0 - }, - "3" : { - "partitionId" : 3, - "nodeId" : "asterix_nc2", - "activeNodeId" : "asterix_nc2", - "active" : true, - "iodeviceNum" : 1 - } - }, "compiler.framesize" : 32768, "compiler.groupmemory" : 163840, "compiler.joinmemory" : 262144, "compiler.parallelism" : 3, "compiler.pregelix.home" : "~/pregelix", "compiler.sortmemory" : 327680, - "core.dump.paths" : { }, "feed.central.manager.port" : 4500, "feed.max.threshold.period" : 5, "feed.memory.available.wait.timeout" : 10, "feed.memory.global.budget" : 67108864, "feed.pending.work.threshold" : 50, - "feed.port" : 19003, - "instance.name" : null, + "instance.name" : "DEFAULT_INSTANCE", "log.level" : "WARNING", "max.wait.active.cluster" : 60, + "messaging.frame.count" : 512, + "messaging.frame.size" : 4096, "metadata.callback.port" : 0, + "metadata.listen.port" : 0, "metadata.node" : "asterix_nc1", - "metadata.partition" : { - "partitionId" : 0, - "nodeId" : "asterix_nc1", - "activeNodeId" : "asterix_nc1", - "active" : true, - "iodeviceNum" : 0 - }, - "metadata.port" : 0, "metadata.registration.timeout.secs" : 60, - "node.partitions" : { - "asterix_nc1" : [ { - "partitionId" : 0, - "nodeId" : "asterix_nc1", - "activeNodeId" : "asterix_nc1", - "active" : true, - "iodeviceNum" : 0 - }, { - "partitionId" : 1, - "nodeId" : "asterix_nc1", - "activeNodeId" : "asterix_nc1", - "active" : true, - "iodeviceNum" : 1 - } ], - "asterix_nc2" : [ { - "partitionId" : 2, - "nodeId" : "asterix_nc2", - "activeNodeId" : "asterix_nc2", - "active" : true, - "iodeviceNum" : 0 - }, { - "partitionId" : 3, - "nodeId" : "asterix_nc2", - "activeNodeId" : "asterix_nc2", - "active" : true, - "iodeviceNum" : 1 - } ] - }, - "node.stores" : { - "asterix_nc1" : [ "iodevice0", "iodevice1" ], - "asterix_nc2" : [ "iodevice0", "iodevice1" ] - }, "plot.activate" : false, - "storage.buffercache.maxopenfiles" : 2147483647, - "storage.buffercache.pagesize" : 32768, - "storage.buffercache.size" : 50331648, - "storage.lsm.bloomfilter.falsepositiverate" : 0.01, - "storage.memorycomponent.globalbudget" : 536870912, - "storage.memorycomponent.numcomponents" : 2, - "storage.memorycomponent.numpages" : 8, - "storage.memorycomponent.pagesize" : 131072, - "storage.metadata.memorycomponent.numpages" : 85, - "transaction.log.dirs" : { - "asterix_nc1" : "target/txnLogDir/asterix_nc1", - "asterix_nc2" : "target/txnLogDir/asterix_nc2" - }, + "replication.log.batchsize" : 4096, + "replication.log.buffer.numpages" : 8, + "replication.log.buffer.pagesize" : 131072, + "replication.max.remote.recovery.attempts" : 5, + "replication.timeout" : 30, "txn.commitprofiler.reportinterval" : 5, "txn.job.recovery.memorysize" : 67108864, "txn.lock.escalationthreshold" : 1000, @@ -120,10 +42,7 @@ "txn.log.checkpoint.history" : 0, "txn.log.checkpoint.lsnthreshold" : 67108864, "txn.log.checkpoint.pollfrequency" : 120, - "txn.log.partitionsize" : 268435456, - "web.port" : 19001, - "web.queryinterface.port" : 19006, - "web.secondary.port" : 19005 + "txn.log.partitionsize" : 268435456 }, "diagnosticsUri" : "http://127.0.0.1:19002/admin/diagnostics", "fullShutdownUri" : "http://127.0.0.1:19002/admin/shutdown?all=true", @@ -155,7 +74,6 @@ "statsUri" : "http://127.0.0.1:19002/admin/cluster/node/asterix_nc2/stats", "threadDumpUri" : "http://127.0.0.1:19002/admin/cluster/node/asterix_nc2/threaddump" } ], - "replicationUri" : "http://127.0.0.1:19002/admin/cluster/replication", "shutdownUri" : "http://127.0.0.1:19002/admin/shutdown", "state" : "ACTIVE", "versionUri" : "http://127.0.0.1:19002/admin/version" http://git-wip-us.apache.org/repos/asf/asterixdb/blob/4c7b5bfa/asterixdb/asterix-app/src/test/resources/runtimets/results/api/replication/replication.1.adm ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/api/replication/replication.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/api/replication/replication.1.adm deleted file mode 100644 index a614faa..0000000 --- a/asterixdb/asterix-app/src/test/resources/runtimets/results/api/replication/replication.1.adm +++ /dev/null @@ -1,9 +0,0 @@ -{ - "config" : { - "log.batchsize" : 4096, - "log.buffer.numpages" : 8, - "log.buffer.pagesize" : 131072, - "max.remote.recovery.attempts" : 5, - "timeout" : 30 - } -} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/4c7b5bfa/asterixdb/asterix-client-helper/pom.xml ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-client-helper/pom.xml b/asterixdb/asterix-client-helper/pom.xml index 726e8fa..bf8a51e 100644 --- a/asterixdb/asterix-client-helper/pom.xml +++ b/asterixdb/asterix-client-helper/pom.xml @@ -118,7 +118,7 @@ <artifactId>maven-dependency-plugin</artifactId> <version>2.10</version> <configuration> - <usedDependencies> + <usedDependencies combine.children="append"> <usedDependency>org.codehaus.mojo.appassembler:appassembler-booter</usedDependency> </usedDependencies> </configuration> http://git-wip-us.apache.org/repos/asf/asterixdb/blob/4c7b5bfa/asterixdb/asterix-common/pom.xml ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-common/pom.xml b/asterixdb/asterix-common/pom.xml index 65e82a2..60f2af0 100644 --- a/asterixdb/asterix-common/pom.xml +++ b/asterixdb/asterix-common/pom.xml @@ -273,6 +273,10 @@ <artifactId>hyracks-http</artifactId> </dependency> <dependency> + <groupId>org.apache.hyracks</groupId> + <artifactId>hyracks-control-common</artifactId> + </dependency> + <dependency> <groupId>io.netty</groupId> <artifactId>netty-all</artifactId> </dependency> @@ -288,5 +292,9 @@ <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-annotations</artifactId> </dependency> + <dependency> + <groupId>args4j</groupId> + <artifactId>args4j</artifactId> + </dependency> </dependencies> </project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/asterixdb/blob/4c7b5bfa/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/cluster/IClusterStateManager.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/cluster/IClusterStateManager.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/cluster/IClusterStateManager.java index d971f48..bf03d54 100644 --- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/cluster/IClusterStateManager.java +++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/cluster/IClusterStateManager.java @@ -21,6 +21,7 @@ package org.apache.asterix.common.cluster; import java.util.Map; import org.apache.asterix.common.api.IClusterManagementWork.ClusterState; +import org.apache.hyracks.api.config.IOption; import org.apache.hyracks.api.exceptions.HyracksDataException; public interface IClusterStateManager { @@ -65,7 +66,7 @@ public interface IClusterStateManager { /** * @return a map of nodeId and NC Configuration for active nodes. */ - Map<String, Map<String, String>> getActiveNcConfiguration(); + Map<String, Map<IOption, Object>> getActiveNcConfiguration(); /** * @return The current metadata node Id. http://git-wip-us.apache.org/repos/asf/asterixdb/blob/4c7b5bfa/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/AbstractProperties.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/AbstractProperties.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/AbstractProperties.java index eccbff2..a5bb945 100644 --- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/AbstractProperties.java +++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/AbstractProperties.java @@ -18,63 +18,11 @@ */ package org.apache.asterix.common.config; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.function.UnaryOperator; -import java.util.logging.Level; -import java.util.logging.Logger; - public abstract class AbstractProperties { - private static final Logger LOGGER = Logger.getLogger(AbstractProperties.class.getName()); - private static final List<AbstractProperties> IMPLS = Collections.synchronizedList(new ArrayList<>()); protected final PropertiesAccessor accessor; public AbstractProperties(PropertiesAccessor accessor) { this.accessor = accessor; - IMPLS.add(this); - } - - public Map<String, Object> getProperties() { - return getProperties(UnaryOperator.identity()); - } - - public Map<String, Object> getProperties(UnaryOperator<String> keyTransformer) { - Map<String, Object> properties = new HashMap<>(); - for (Method m : getClass().getMethods()) { - PropertyKey key = m.getAnnotation(PropertyKey.class); - Stringify stringify = m.getAnnotation(Stringify.class); - if (key != null) { - try { - if (stringify != null) { - properties.put(keyTransformer.apply(key.value()), String.valueOf(m.invoke(this))); - } else { - properties.put(keyTransformer.apply(key.value()), m.invoke(this)); - } - } catch (Exception e) { - LOGGER.log(Level.INFO, "Error accessing property: " + key.value(), e); - } - } - } - return properties; - } - - @Retention(RetentionPolicy.RUNTIME) - public @interface PropertyKey { - String value(); - } - - @Retention(RetentionPolicy.RUNTIME) - public @interface Stringify { - } - - public static List<AbstractProperties> getImplementations() { - return Collections.unmodifiableList(IMPLS); } } http://git-wip-us.apache.org/repos/asf/asterixdb/blob/4c7b5bfa/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/AsterixProperties.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/AsterixProperties.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/AsterixProperties.java index 3ae2bd9..5f3a1aa 100644 --- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/AsterixProperties.java +++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/AsterixProperties.java @@ -18,37 +18,40 @@ */ package org.apache.asterix.common.config; -import java.io.File; +import org.apache.asterix.common.exceptions.AsterixException; +import org.apache.hyracks.api.config.IConfigManager; +import org.apache.hyracks.api.exceptions.HyracksDataException; public class AsterixProperties { - //---------------------------- Directories ---------------------------// - private static final String VAR = File.separator + "var"; - private static final String LIB = VAR + File.separator + "lib"; - private static final String ASTERIXDB = LIB + File.separator + "asterixdb"; - //----------------------------- Sections -----------------------------// - public static final String SECTION_ASTERIX = "asterix"; + public static final String SECTION_PREFIX_EXTENSION = "extension/"; - public static final String SECTION_CC = "cc"; - public static final String SECTION_PREFIX_NC = "nc/"; - //---------------------------- Properties ---=------------------------// - public static final String PROPERTY_CLUSTER_ADDRESS = "cluster.address"; - public static final String PROPERTY_INSTANCE_NAME = "instance"; - public static final String DEFAULT_INSTANCE_NAME = "DEFAULT_INSTANCE"; - public static final String PROPERTY_METADATA_NODE = "metadata.node"; - public static final String PROPERTY_COREDUMP_DIR = "coredumpdir"; - public static final String DEFAULT_COREDUMP_DIR = String.join(File.separator, ASTERIXDB, "coredump"); - public static final String PROPERTY_TXN_LOG_DIR = "txnlogdir"; - public static final String DEFAULT_TXN_LOG_DIR = String.join(File.separator, ASTERIXDB, "txn-log"); - public static final String PROPERTY_IO_DEV = "iodevices"; - public static final String DEFAULT_IO_DEV = String.join(File.separator, ASTERIXDB, "iodevice"); - public static final String PROPERTY_STORAGE_DIR = "storagedir"; - public static final String DEFAULT_STORAGE_DIR = "storage"; - public static final String PROPERTY_CLASS = "class"; private AsterixProperties() { } - public static final String getSectionId(String prefix, String section) { + public static String getSectionId(String prefix, String section) { return section.substring(prefix.length()); } + + public static void registerConfigOptions(IConfigManager configManager) { + configManager.register( + NodeProperties.Option.class, + CompilerProperties.Option.class, + MetadataProperties.Option.class, + ExternalProperties.Option.class, + FeedProperties.Option.class, + MessagingProperties.Option.class, + ReplicationProperties.Option.class, + StorageProperties.Option.class, + TransactionProperties.Option.class); + + // we need to process the old-style asterix config before we apply defaults! + configManager.addConfigurator(IConfigManager.APPLY_DEFAULTS_METRIC - 1, () -> { + try { + PropertiesAccessor.getInstance(configManager.getAppConfig()); + } catch (AsterixException e) { + throw new HyracksDataException(e); + } + }); + } } http://git-wip-us.apache.org/repos/asf/asterixdb/blob/4c7b5bfa/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/BuildProperties.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/BuildProperties.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/BuildProperties.java index a1d4703..7a36dbe 100644 --- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/BuildProperties.java +++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/BuildProperties.java @@ -27,89 +27,6 @@ public class BuildProperties extends AbstractProperties { super(accessor); } - public String getUserEmail() { - return accessor.getProperty("git.build.user.email", "", PropertyInterpreters.getStringPropertyInterpreter()); - } - - public String getBuildHost() { - return accessor.getProperty("git.build.host", "", PropertyInterpreters.getStringPropertyInterpreter()); - } - - public String getDirty() { - return accessor.getProperty("git.dirty", "", PropertyInterpreters.getStringPropertyInterpreter()); - } - - public String getRemoteOriginUrl() { - return accessor.getProperty("git.remote.origin.url", "", PropertyInterpreters.getStringPropertyInterpreter()); - } - - public String getClosestTagName() { - return accessor.getProperty("git.closest.tag.name", "", PropertyInterpreters.getStringPropertyInterpreter()); - } - - public String getCommitIdDescribeShort() { - return accessor.getProperty("git.commit.id.describe-short", "", - PropertyInterpreters.getStringPropertyInterpreter()); - } - - public String getCommitUserEmail() { - return accessor.getProperty("git.commit.user.email", "", PropertyInterpreters.getStringPropertyInterpreter()); - } - - public String getCommitTime() { - return accessor.getProperty("git.commit.time", "", PropertyInterpreters.getStringPropertyInterpreter()); - } - - public String getCommitMessage() { - return accessor.getProperty("git.commit.message.full", "", PropertyInterpreters.getStringPropertyInterpreter()); - } - - public String getBuildVersion() { - return accessor.getProperty("git.build.version", "", PropertyInterpreters.getStringPropertyInterpreter()); - } - - public String getCommitMessageShort() { - return accessor.getProperty("git.commit.message.short", "", - PropertyInterpreters.getStringPropertyInterpreter()); - } - - public String getShortCommitId() { - return accessor.getProperty("git.commit.id.abbrev", "", PropertyInterpreters.getStringPropertyInterpreter()); - } - - public String getBranch() { - return accessor.getProperty("git.branch", "", PropertyInterpreters.getStringPropertyInterpreter()); - } - - public String getBuildUserName() { - return accessor.getProperty("git.build.user.name", "", PropertyInterpreters.getStringPropertyInterpreter()); - } - - public String getClosestTagCommitCount() { - return accessor.getProperty("git.closest.tag.commit.count", "", - PropertyInterpreters.getStringPropertyInterpreter()); - } - - public String getCommitIdDescribe() { - return accessor.getProperty("git.commit.id.describe", "", PropertyInterpreters.getStringPropertyInterpreter()); - } - - public String getCommitId() { - return accessor.getProperty("git.commit.id", "", PropertyInterpreters.getStringPropertyInterpreter()); - } - - public String getTags() { - return accessor.getProperty("git.tags", "", PropertyInterpreters.getStringPropertyInterpreter()); - } - - public String getBuildTime() { - return accessor.getProperty("git.build.time", "", PropertyInterpreters.getStringPropertyInterpreter()); - } - - public String getCommitUserName() { - return accessor.getProperty("git.commit.user.name", "", PropertyInterpreters.getStringPropertyInterpreter()); - } - public Map<String, String> getAllProps() { return accessor.getBuildProperties(); } http://git-wip-us.apache.org/repos/asf/asterixdb/blob/4c7b5bfa/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/CompilerProperties.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/CompilerProperties.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/CompilerProperties.java index 3710e54..f97c5a5 100644 --- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/CompilerProperties.java +++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/CompilerProperties.java @@ -18,68 +18,91 @@ */ package org.apache.asterix.common.config; +import static org.apache.hyracks.control.common.config.OptionTypes.INTEGER; +import static org.apache.hyracks.control.common.config.OptionTypes.INTEGER_BYTE_UNIT; +import static org.apache.hyracks.control.common.config.OptionTypes.LONG_BYTE_UNIT; +import static org.apache.hyracks.control.common.config.OptionTypes.STRING; import static org.apache.hyracks.util.StorageUtil.StorageUnit.KILOBYTE; import static org.apache.hyracks.util.StorageUtil.StorageUnit.MEGABYTE; +import org.apache.hyracks.api.config.IOption; +import org.apache.hyracks.api.config.IOptionType; +import org.apache.hyracks.api.config.Section; import org.apache.hyracks.util.StorageUtil; public class CompilerProperties extends AbstractProperties { - public static final String COMPILER_SORTMEMORY_KEY = "compiler.sortmemory"; - private static final long COMPILER_SORTMEMORY_DEFAULT = StorageUtil.getSizeInBytes(32, MEGABYTE); + public enum Option implements IOption { + COMPILER_SORTMEMORY(LONG_BYTE_UNIT, StorageUtil.getLongSizeInBytes(32L, MEGABYTE)), + COMPILER_JOINMEMORY(LONG_BYTE_UNIT, StorageUtil.getLongSizeInBytes(32L, MEGABYTE)), + COMPILER_GROUPMEMORY(LONG_BYTE_UNIT, StorageUtil.getLongSizeInBytes(32L, MEGABYTE)), + COMPILER_FRAMESIZE(INTEGER_BYTE_UNIT, StorageUtil.getIntSizeInBytes(32, KILOBYTE)), + COMPILER_PARALLELISM(INTEGER, COMPILER_PARALLELISM_AS_STORAGE), + COMPILER_PREGELIX_HOME(STRING, "~/pregelix"); + + private final IOptionType type; + private final Object defaultValue; + + Option(IOptionType type, Object defaultValue) { + this.type = type; + this.defaultValue = defaultValue; + } + + @Override + public Section section() { + return Section.COMMON; + } + + @Override + public String description() { + return ""; + } + + @Override + public IOptionType type() { + return type; + } + + @Override + public Object defaultValue() { + return defaultValue; + } + } + public static final String COMPILER_SORTMEMORY_KEY = Option.COMPILER_SORTMEMORY.ini(); - public static final String COMPILER_GROUPMEMORY_KEY = "compiler.groupmemory"; - private static final long COMPILER_GROUPMEMORY_DEFAULT = StorageUtil.getSizeInBytes(32, MEGABYTE); + public static final String COMPILER_GROUPMEMORY_KEY = Option.COMPILER_GROUPMEMORY.ini(); - public static final String COMPILER_JOINMEMORY_KEY = "compiler.joinmemory"; - private static final long COMPILER_JOINMEMORY_DEFAULT = StorageUtil.getSizeInBytes(32, MEGABYTE); + public static final String COMPILER_JOINMEMORY_KEY = Option.COMPILER_JOINMEMORY.ini(); - private static final String COMPILER_FRAMESIZE_KEY = "compiler.framesize"; - private static final int COMPILER_FRAMESIZE_DEFAULT = StorageUtil.getSizeInBytes(32, KILOBYTE); + public static final String COMPILER_PARALLELISM_KEY = Option.COMPILER_PARALLELISM.ini(); - public static final String COMPILER_PARALLELISM_KEY = "compiler.parallelism"; public static final int COMPILER_PARALLELISM_AS_STORAGE = 0; - private static final String COMPILER_PREGELIX_HOME = "compiler.pregelix.home"; - private static final String COMPILER_PREGELIX_HOME_DEFAULT = "~/pregelix"; - public CompilerProperties(PropertiesAccessor accessor) { super(accessor); } - @PropertyKey(COMPILER_SORTMEMORY_KEY) public long getSortMemorySize() { - return accessor.getProperty(COMPILER_SORTMEMORY_KEY, COMPILER_SORTMEMORY_DEFAULT, - PropertyInterpreters.getLongBytePropertyInterpreter()); + return accessor.getLong(Option.COMPILER_SORTMEMORY); } - @PropertyKey(COMPILER_JOINMEMORY_KEY) public long getJoinMemorySize() { - return accessor.getProperty(COMPILER_JOINMEMORY_KEY, COMPILER_JOINMEMORY_DEFAULT, - PropertyInterpreters.getLongBytePropertyInterpreter()); + return accessor.getLong(Option.COMPILER_JOINMEMORY); } - @PropertyKey(COMPILER_GROUPMEMORY_KEY) public long getGroupMemorySize() { - return accessor.getProperty(COMPILER_GROUPMEMORY_KEY, COMPILER_GROUPMEMORY_DEFAULT, - PropertyInterpreters.getLongBytePropertyInterpreter()); + return accessor.getLong(Option.COMPILER_GROUPMEMORY); } - @PropertyKey(COMPILER_FRAMESIZE_KEY) public int getFrameSize() { - return accessor.getProperty(COMPILER_FRAMESIZE_KEY, COMPILER_FRAMESIZE_DEFAULT, - PropertyInterpreters.getIntegerBytePropertyInterpreter()); + return accessor.getInt(Option.COMPILER_FRAMESIZE); } - @PropertyKey(COMPILER_PARALLELISM_KEY) public int getParallelism() { - return accessor.getProperty(COMPILER_PARALLELISM_KEY, COMPILER_PARALLELISM_AS_STORAGE, - PropertyInterpreters.getIntegerPropertyInterpreter()); + return accessor.getInt(Option.COMPILER_PARALLELISM); } - @PropertyKey(COMPILER_PREGELIX_HOME) public String getPregelixHome() { - return accessor.getProperty(COMPILER_PREGELIX_HOME, COMPILER_PREGELIX_HOME_DEFAULT, - PropertyInterpreters.getStringPropertyInterpreter()); + return accessor.getString(Option.COMPILER_PREGELIX_HOME); } } http://git-wip-us.apache.org/repos/asf/asterixdb/blob/4c7b5bfa/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/ExternalProperties.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/ExternalProperties.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/ExternalProperties.java index eb6bda5..2f85221 100644 --- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/ExternalProperties.java +++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/ExternalProperties.java @@ -18,101 +18,107 @@ */ package org.apache.asterix.common.config; -import java.util.logging.Level; +import static org.apache.hyracks.control.common.config.OptionTypes.*; -public class ExternalProperties extends AbstractProperties { - - public static final String EXTERNAL_WEBPORT_KEY = "web.port"; - public static final int EXTERNAL_WEBPORT_DEFAULT = 19001; - - public static final String EXTERNAL_SECONDARY_WEBPORT_KEY = "web.secondary.port"; - public static final int EXTERNAL_SECONDARY_WEBPORT_DEFAULT = 19005; - - public static final String QUERY_WEBPORT_KEY = "web.queryinterface.port"; - public static final int QUERY_WEBPORT_DEFAULT = 19006; - - public static final String EXTERNAL_LOGLEVEL_KEY = "log.level"; - public static final Level EXTERNAL_LOGLEVEL_DEFAULT = Level.WARNING; +import org.apache.hyracks.api.config.IOption; +import org.apache.hyracks.api.config.IOptionType; +import org.apache.hyracks.api.config.Section; - public static final String EXTERNAL_APISERVER_KEY = "api.port"; - public static final int EXTERNAL_APISERVER_DEFAULT = 19002; - - public static final String EXTERNAL_FEEDSERVER_KEY = "feed.port"; - public static final int EXTERNAL_FEEDSERVER_DEFAULT = 19003; - - public static final String EXTERNAL_CC_JAVA_OPTS_KEY = "cc.java.opts"; - public static final String EXTERNAL_CC_JAVA_OPTS_DEFAULT = "-Xmx1024m"; - - public static final String EXTERNAL_NC_JAVA_OPTS_KEY = "nc.java.opts"; - public static final String EXTERNAL_NC_JAVA_OPTS_DEFAULT = "-Xmx1024m"; - - public static final String EXTERNAL_MAX_WAIT_FOR_ACTIVE_CLUSTER = "max.wait.active.cluster"; - public static final int EXTERNAL_MAX_WAIT_FOR_ACTIVE_CLUSTER_DEFAULT = 60; +public class ExternalProperties extends AbstractProperties { - public static final String EXTERNAL_PLOT_ACTIVATE = "plot.activate"; - public static final boolean EXTERNAL_PLOT_ACTIVATE_DEFAULT = false; + public enum Option implements IOption { + WEB_PORT(INTEGER, 19001), + WEB_QUERYINTERFACE_PORT(INTEGER, 19006), + API_PORT(INTEGER, 19002), + FEED_PORT(INTEGER, 19003), + LOG_LEVEL(LEVEL, java.util.logging.Level.WARNING), + MAX_WAIT_ACTIVE_CLUSTER(INTEGER, 60), + PLOT_ACTIVATE(BOOLEAN, false), + CC_JAVA_OPTS(STRING, "-Xmx1024m"), + NC_JAVA_OPTS(STRING, "-Xmx1024m"); + + private final IOptionType type; + private final Object defaultValue; + + Option(IOptionType type, Object defaultValue) { + this.type = type; + this.defaultValue = defaultValue; + } + + @Override + public Section section() { + switch (this) { + case WEB_PORT: + case WEB_QUERYINTERFACE_PORT: + case API_PORT: + case FEED_PORT: + return Section.CC; + case LOG_LEVEL: + case MAX_WAIT_ACTIVE_CLUSTER: + case PLOT_ACTIVATE: + return Section.COMMON; + case CC_JAVA_OPTS: + case NC_JAVA_OPTS: + return Section.VIRTUAL; + default: + throw new IllegalStateException("NYI: " + this); + } + } + + @Override + public String description() { + // TODO(mblow): add descriptions + return null; + } + + @Override + public IOptionType type() { + return type; + } + + @Override + public Object defaultValue() { + return defaultValue; + } + } public ExternalProperties(PropertiesAccessor accessor) { super(accessor); } - @PropertyKey(EXTERNAL_WEBPORT_KEY) public int getWebInterfacePort() { - return accessor.getProperty(EXTERNAL_WEBPORT_KEY, EXTERNAL_WEBPORT_DEFAULT, - PropertyInterpreters.getIntegerPropertyInterpreter()); - } - - @PropertyKey(EXTERNAL_SECONDARY_WEBPORT_KEY) - public int getSecondaryWebInterfacePort() { - return accessor.getProperty(EXTERNAL_SECONDARY_WEBPORT_KEY, EXTERNAL_SECONDARY_WEBPORT_DEFAULT, - PropertyInterpreters.getIntegerPropertyInterpreter()); + return accessor.getInt(Option.WEB_PORT); } - @PropertyKey(QUERY_WEBPORT_KEY) public int getQueryWebInterfacePort() { - return accessor.getProperty(QUERY_WEBPORT_KEY, QUERY_WEBPORT_DEFAULT, - PropertyInterpreters.getIntegerPropertyInterpreter()); + return accessor.getInt(Option.WEB_QUERYINTERFACE_PORT); } - @PropertyKey(EXTERNAL_APISERVER_KEY) public int getAPIServerPort() { - return accessor.getProperty(EXTERNAL_APISERVER_KEY, EXTERNAL_APISERVER_DEFAULT, - PropertyInterpreters.getIntegerPropertyInterpreter()); + return accessor.getInt(Option.API_PORT); } - @PropertyKey(EXTERNAL_FEEDSERVER_KEY) public int getFeedServerPort() { - return accessor.getProperty(EXTERNAL_FEEDSERVER_KEY, EXTERNAL_FEEDSERVER_DEFAULT, - PropertyInterpreters.getIntegerPropertyInterpreter()); + return accessor.getInt(Option.FEED_PORT); } - @PropertyKey(EXTERNAL_LOGLEVEL_KEY) - @Stringify - public Level getLogLevel() { - return accessor.getProperty(EXTERNAL_LOGLEVEL_KEY, EXTERNAL_LOGLEVEL_DEFAULT, - PropertyInterpreters.getLevelPropertyInterpreter()); + public java.util.logging.Level getLogLevel() { + return accessor.getLoggingLevel(Option.LOG_LEVEL); } - public String getNCJavaParams() { - return accessor.getProperty(EXTERNAL_NC_JAVA_OPTS_KEY, EXTERNAL_NC_JAVA_OPTS_DEFAULT, - PropertyInterpreters.getStringPropertyInterpreter()); + public int getMaxWaitClusterActive() { + return accessor.getInt(Option.MAX_WAIT_ACTIVE_CLUSTER); } - public String getCCJavaParams() { - return accessor.getProperty(EXTERNAL_CC_JAVA_OPTS_KEY, EXTERNAL_CC_JAVA_OPTS_DEFAULT, - PropertyInterpreters.getStringPropertyInterpreter()); + public boolean getIsPlottingEnabled() { + return accessor.getBoolean(Option.PLOT_ACTIVATE); } - @PropertyKey(EXTERNAL_MAX_WAIT_FOR_ACTIVE_CLUSTER) - public int getMaxWaitClusterActive() { - return accessor.getProperty(EXTERNAL_MAX_WAIT_FOR_ACTIVE_CLUSTER, EXTERNAL_MAX_WAIT_FOR_ACTIVE_CLUSTER_DEFAULT, - PropertyInterpreters.getIntegerPropertyInterpreter()); + public String getNCJavaParams() { + return accessor.getString(Option.NC_JAVA_OPTS); } - @PropertyKey(EXTERNAL_PLOT_ACTIVATE) - public Boolean getIsPlottingEnabled() { - return accessor.getProperty(EXTERNAL_PLOT_ACTIVATE, EXTERNAL_PLOT_ACTIVATE_DEFAULT, - PropertyInterpreters.getBooleanPropertyInterpreter()); + public String getCCJavaParams() { + return accessor.getString(Option.CC_JAVA_OPTS); } - } http://git-wip-us.apache.org/repos/asf/asterixdb/blob/4c7b5bfa/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/FeedProperties.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/FeedProperties.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/FeedProperties.java index 0afbbd3..a96d746 100644 --- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/FeedProperties.java +++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/FeedProperties.java @@ -18,65 +18,84 @@ */ package org.apache.asterix.common.config; -import org.apache.hyracks.util.StorageUtil; - +import static org.apache.hyracks.control.common.config.OptionTypes.INTEGER; +import static org.apache.hyracks.control.common.config.OptionTypes.LONG; +import static org.apache.hyracks.control.common.config.OptionTypes.LONG_BYTE_UNIT; import static org.apache.hyracks.util.StorageUtil.StorageUnit.MEGABYTE; +import org.apache.hyracks.api.config.IOption; +import org.apache.hyracks.api.config.IOptionType; +import org.apache.hyracks.api.config.Section; +import org.apache.hyracks.util.StorageUtil; + public class FeedProperties extends AbstractProperties { - private static final String FEED_CENTRAL_MANAGER_PORT_KEY = "feed.central.manager.port"; - private static final int FEED_CENTRAL_MANAGER_PORT_DEFAULT = 4500; + public enum Option implements IOption { + FEED_PENDING_WORK_THRESHOLD(INTEGER, 50), + FEED_MEMORY_GLOBAL_BUDGET(LONG_BYTE_UNIT, StorageUtil.getLongSizeInBytes(64L, MEGABYTE)), + FEED_MEMORY_AVAILABLE_WAIT_TIMEOUT(LONG, 10L), + FEED_CENTRAL_MANAGER_PORT(INTEGER, 4500), + FEED_MAX_THRESHOLD_PERIOD(INTEGER, 5); - private static final String FEED_MEMORY_GLOBALBUDGET_KEY = "feed.memory.global.budget"; - private static final long FEED_MEMORY_GLOBALBUDGET_DEFAULT = StorageUtil.getSizeInBytes(64, MEGABYTE); - // i.e. 2048 frames (assuming 32768 as frame size) + private final IOptionType type; + private final Object defaultValue; - private static final String FEED_MEMORY_AVAILABLE_WAIT_TIMEOUT_KEY = "feed.memory.available.wait.timeout"; - private static final long FEED_MEMORY_AVAILABLE_WAIT_TIMEOUT_DEFAULT = 10; // 10 seconds + Option(IOptionType type, Object defaultValue) { + this.type = type; + this.defaultValue = defaultValue; + } - private static final String FEED_PENDING_WORK_THRESHOLD_KEY = "feed.pending.work.threshold"; - private static final int FEED_PENDING_WORK_THRESHOLD_DEFAULT = 50; + @Override + public Section section() { + return Section.COMMON; + } - private static final String FEED_MAX_SUCCESSIVE_THRESHOLD_PERIOD_KEY = "feed.max.threshold.period"; - private static final int FEED_MAX_SUCCESSIVE_THRESHOLD_PERIOD_DEFAULT = 5; + @Override + public String description() { + // TODO(mblow): add missing descriptions + switch (this) { + case FEED_CENTRAL_MANAGER_PORT: + return "port at which the Central Feed Manager listens for control messages from local Feed " + + "Managers"; + case FEED_MAX_THRESHOLD_PERIOD: + return "maximum length of input queue before triggering corrective action"; + default: + return null; + } + } + + @Override + public IOptionType type() { + return type; + } + + @Override + public Object defaultValue() { + return defaultValue; + } + } public FeedProperties(PropertiesAccessor accessor) { super(accessor); } - @PropertyKey(FEED_MEMORY_GLOBALBUDGET_KEY) + public int getPendingWorkThreshold() { + return accessor.getInt(Option.FEED_PENDING_WORK_THRESHOLD); + } + public long getMemoryComponentGlobalBudget() { - return accessor.getProperty(FEED_MEMORY_GLOBALBUDGET_KEY, FEED_MEMORY_GLOBALBUDGET_DEFAULT, - PropertyInterpreters.getLongBytePropertyInterpreter()); + return accessor.getLong(Option.FEED_MEMORY_GLOBAL_BUDGET); } - @PropertyKey(FEED_MEMORY_AVAILABLE_WAIT_TIMEOUT_KEY) public long getMemoryAvailableWaitTimeout() { - return accessor.getProperty(FEED_MEMORY_AVAILABLE_WAIT_TIMEOUT_KEY, FEED_MEMORY_AVAILABLE_WAIT_TIMEOUT_DEFAULT, - PropertyInterpreters.getLongPropertyInterpreter()); + return accessor.getLong(Option.FEED_MEMORY_AVAILABLE_WAIT_TIMEOUT); } - /** - * @return port at which the Central Feed Manager listens for control messages from local Feed Managers - */ - @PropertyKey(FEED_CENTRAL_MANAGER_PORT_KEY) public int getFeedCentralManagerPort() { - return accessor.getProperty(FEED_CENTRAL_MANAGER_PORT_KEY, FEED_CENTRAL_MANAGER_PORT_DEFAULT, - PropertyInterpreters.getIntegerPropertyInterpreter()); - } - - /** - * @return maximum length of input queue before triggering corrective action - */ - @PropertyKey(FEED_PENDING_WORK_THRESHOLD_KEY) - public int getPendingWorkThreshold() { - return accessor.getProperty(FEED_PENDING_WORK_THRESHOLD_KEY, FEED_PENDING_WORK_THRESHOLD_DEFAULT, - PropertyInterpreters.getIntegerPropertyInterpreter()); + return accessor.getInt(Option.FEED_CENTRAL_MANAGER_PORT); } - @PropertyKey(FEED_MAX_SUCCESSIVE_THRESHOLD_PERIOD_KEY) public int getMaxSuccessiveThresholdPeriod() { - return accessor.getProperty(FEED_MAX_SUCCESSIVE_THRESHOLD_PERIOD_KEY, - FEED_MAX_SUCCESSIVE_THRESHOLD_PERIOD_DEFAULT, PropertyInterpreters.getIntegerPropertyInterpreter()); + return accessor.getInt(Option.FEED_MAX_THRESHOLD_PERIOD); } } http://git-wip-us.apache.org/repos/asf/asterixdb/blob/4c7b5bfa/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/IPropertiesProvider.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/IPropertiesProvider.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/IPropertiesProvider.java index 1de1523..4637437 100644 --- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/IPropertiesProvider.java +++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/IPropertiesProvider.java @@ -19,21 +19,23 @@ package org.apache.asterix.common.config; public interface IPropertiesProvider { - public StorageProperties getStorageProperties(); + StorageProperties getStorageProperties(); - public TransactionProperties getTransactionProperties(); + TransactionProperties getTransactionProperties(); - public CompilerProperties getCompilerProperties(); + CompilerProperties getCompilerProperties(); - public MetadataProperties getMetadataProperties(); + MetadataProperties getMetadataProperties(); - public ExternalProperties getExternalProperties(); + ExternalProperties getExternalProperties(); - public FeedProperties getFeedProperties(); + FeedProperties getFeedProperties(); BuildProperties getBuildProperties(); - public ReplicationProperties getReplicationProperties(); + ReplicationProperties getReplicationProperties(); - public MessagingProperties getMessagingProperties(); + MessagingProperties getMessagingProperties(); + + NodeProperties getNodeProperties(); } http://git-wip-us.apache.org/repos/asf/asterixdb/blob/4c7b5bfa/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/IPropertyInterpreter.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/IPropertyInterpreter.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/IPropertyInterpreter.java deleted file mode 100644 index 36f5716..0000000 --- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/IPropertyInterpreter.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF 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 org.apache.asterix.common.config; - -public interface IPropertyInterpreter<T> { - public T interpret(String s) throws IllegalArgumentException; -} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/4c7b5bfa/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/MessagingProperties.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/MessagingProperties.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/MessagingProperties.java index 2e98e1e..8097b5f 100644 --- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/MessagingProperties.java +++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/MessagingProperties.java @@ -18,28 +18,60 @@ */ package org.apache.asterix.common.config; +import static org.apache.hyracks.control.common.config.OptionTypes.INTEGER; +import static org.apache.hyracks.control.common.config.OptionTypes.INTEGER_BYTE_UNIT; +import static org.apache.hyracks.util.StorageUtil.StorageUnit.KILOBYTE; + +import org.apache.hyracks.api.config.IOption; +import org.apache.hyracks.api.config.IOptionType; +import org.apache.hyracks.api.config.Section; import org.apache.hyracks.util.StorageUtil; -import org.apache.hyracks.util.StorageUtil.StorageUnit; public class MessagingProperties extends AbstractProperties { - private static final String MESSAGING_FRAME_SIZE_KEY = "messaging.frame.size"; - private static final int MESSAGING_FRAME_SIZE_DEFAULT = StorageUtil.getSizeInBytes(4, StorageUnit.KILOBYTE); + public enum Option implements IOption { + MESSAGING_FRAME_SIZE(INTEGER_BYTE_UNIT, StorageUtil.getIntSizeInBytes(4, KILOBYTE)), + MESSAGING_FRAME_COUNT(INTEGER, 512); + + private final IOptionType type; + private final Object defaultValue; + + Option(IOptionType type, Object defaultValue) { + this.type = type; + this.defaultValue = defaultValue; + } + + @Override + public Section section() { + return Section.COMMON; + } - private static final String MESSAGING_FRAME_COUNT_KEY = "messaging.frame.count"; - private static final int MESSAGING_BUFFER_COUNTE_DEFAULT = 512; + @Override + public String description() { + // TODO(mblow): add missing descriptions + return null; + } + + @Override + public IOptionType type() { + return type; + } + + @Override + public Object defaultValue() { + return defaultValue; + } + } public MessagingProperties(PropertiesAccessor accessor) { super(accessor); } public int getFrameSize() { - return accessor.getProperty(MESSAGING_FRAME_SIZE_KEY, MESSAGING_FRAME_SIZE_DEFAULT, - PropertyInterpreters.getIntegerPropertyInterpreter()); + return accessor.getInt(Option.MESSAGING_FRAME_SIZE); } public int getFrameCount() { - return accessor.getProperty(MESSAGING_FRAME_COUNT_KEY, MESSAGING_BUFFER_COUNTE_DEFAULT, - PropertyInterpreters.getIntegerPropertyInterpreter()); + return accessor.getInt(Option.MESSAGING_FRAME_COUNT); } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/asterixdb/blob/4c7b5bfa/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/MetadataProperties.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/MetadataProperties.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/MetadataProperties.java index ab65b71..948bdad 100644 --- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/MetadataProperties.java +++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/MetadataProperties.java @@ -18,90 +18,135 @@ */ package org.apache.asterix.common.config; +import static org.apache.hyracks.control.common.config.OptionTypes.INTEGER; +import static org.apache.hyracks.control.common.config.OptionTypes.STRING; + import java.util.List; import java.util.Map; import java.util.SortedMap; import org.apache.asterix.common.cluster.ClusterPartition; +import org.apache.hyracks.api.config.IApplicationConfig; +import org.apache.hyracks.api.config.IOption; +import org.apache.hyracks.api.config.IOptionType; +import org.apache.hyracks.api.config.Section; public class MetadataProperties extends AbstractProperties { - private static final String METADATA_REGISTRATION_TIMEOUT_KEY = "metadata.registration.timeout.secs"; - private static final long METADATA_REGISTRATION_TIMEOUT_DEFAULT = 60; - - private static final String METADATA_PORT_KEY = "metadata.port"; - private static final int METADATA_PORT_DEFAULT = 0; + public enum Option implements IOption { + INSTANCE_NAME(STRING, "DEFAULT_INSTANCE"), + METADATA_NODE(STRING, null), + METADATA_REGISTRATION_TIMEOUT_SECS(INTEGER, 60), + METADATA_LISTEN_PORT(INTEGER, 0), + METADATA_CALLBACK_PORT(INTEGER, 0); + + private final IOptionType type; + private final Object defaultValue; + + <T> Option(IOptionType<T> type, T defaultValue) { + this.type = type; + this.defaultValue = defaultValue; + } + + @Override + public Section section() { + return Section.COMMON; + } + + @Override + public String description() { + switch (this) { + case INSTANCE_NAME: + return "The name of this cluster instance"; + case METADATA_NODE: + return "the node which should serve as the metadata node"; + case METADATA_REGISTRATION_TIMEOUT_SECS: + return "how long in seconds to wait for the metadata node to register with the CC"; + case METADATA_LISTEN_PORT: + return "IP port to bind metadata listener (0 = random port)"; + case METADATA_CALLBACK_PORT: + return "IP port to bind metadata callback listener (0 = random port)"; + default: + throw new IllegalStateException("NYI: " + this); + } + } + + @Override + public IOptionType type() { + return type; + } + + @Override + public Object defaultValue() { + return defaultValue; + } + + @Override + public Object get(IApplicationConfig cfg) { + if (this == METADATA_NODE) { + Object value = cfg.getStatic(this); + return value != null ? value : cfg.getNCNames().isEmpty() ? null : cfg.getNCNames().get(0); + } else { + return cfg.getStatic(this); + } + } - private static final String METADATA_CALLBACK_PORT_KEY = "metadata.callback.port"; - private static final int METADATA_CALLBACK_PORT_DEFAULT = 0; + } public MetadataProperties(PropertiesAccessor accessor) { super(accessor); } - @PropertyKey("instance.name") public String getInstanceName() { - return accessor.getInstanceName(); + return accessor.getString(Option.INSTANCE_NAME); } - @PropertyKey("metadata.node") public String getMetadataNodeName() { - return accessor.getMetadataNodeName(); + return accessor.getString(Option.METADATA_NODE); } - @PropertyKey("metadata.partition") public ClusterPartition getMetadataPartition() { - return accessor.getMetadataPartition(); + // metadata partition is always the first partition on the metadata node + return accessor.getNodePartitions().get(getMetadataNodeName())[0]; } - @PropertyKey("node.stores") public Map<String, String[]> getStores() { return accessor.getStores(); } public List<String> getNodeNames() { - return accessor.getNodeNames(); + return accessor.getNCNames(); } public String getCoredumpPath(String nodeId) { return accessor.getCoredumpPath(nodeId); } - @PropertyKey("core.dump.paths") public Map<String, String> getCoredumpPaths() { return accessor.getCoredumpConfig(); } - @PropertyKey("node.partitions") public Map<String, ClusterPartition[]> getNodePartitions() { return accessor.getNodePartitions(); } - @PropertyKey("cluster.partitions") public SortedMap<Integer, ClusterPartition> getClusterPartitions() { return accessor.getClusterPartitions(); } - @PropertyKey("transaction.log.dirs") public Map<String, String> getTransactionLogDirs() { return accessor.getTransactionLogDirs(); } - @PropertyKey(METADATA_REGISTRATION_TIMEOUT_KEY) - public long getRegistrationTimeoutSecs() { - return accessor.getProperty(METADATA_REGISTRATION_TIMEOUT_KEY, METADATA_REGISTRATION_TIMEOUT_DEFAULT, - PropertyInterpreters.getLongPropertyInterpreter()); + public int getRegistrationTimeoutSecs() { + return accessor.getInt(Option.METADATA_REGISTRATION_TIMEOUT_SECS); } - @PropertyKey(METADATA_PORT_KEY) public int getMetadataPort() { - return accessor.getProperty(METADATA_PORT_KEY, METADATA_PORT_DEFAULT, - PropertyInterpreters.getIntegerPropertyInterpreter()); + return accessor.getInt(Option.METADATA_LISTEN_PORT); } - @PropertyKey(METADATA_CALLBACK_PORT_KEY) public int getMetadataCallbackPort() { - return accessor.getProperty(METADATA_CALLBACK_PORT_KEY, METADATA_CALLBACK_PORT_DEFAULT, - PropertyInterpreters.getIntegerPropertyInterpreter()); + return accessor.getInt(Option.METADATA_CALLBACK_PORT); } }
