Michael Blow has uploaded a new change for review.
https://asterix-gerrit.ics.uci.edu/1751
Change subject: Make Default Dir a Command Line Option
......................................................................
Make Default Dir a Command Line Option
Avoid using static field to hold default directory, in favor of an
option.
Change-Id: I7855c8f344eea9c9b6a394d85413a062a3ddb609
---
M
asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/ApplicationConfigurator.java
M
asterixdb/asterix-app/src/test/java/org/apache/asterix/common/config/ConfigUsageTest.java
M
asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/NodeProperties.java
M
hyracks-fullstack/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/controllers/CCConfig.java
M
hyracks-fullstack/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/controllers/ControllerConfig.java
M
hyracks-fullstack/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/controllers/NCConfig.java
6 files changed, 104 insertions(+), 56 deletions(-)
git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb
refs/changes/51/1751/1
diff --git
a/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/ApplicationConfigurator.java
b/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/ApplicationConfigurator.java
index 466203c..05ee648 100644
---
a/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/ApplicationConfigurator.java
+++
b/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/ApplicationConfigurator.java
@@ -36,9 +36,9 @@
static void registerConfigOptions(IConfigManager configManager) {
AsterixProperties.registerConfigOptions(configManager);
- ControllerConfig.defaultDir =
FileUtil.joinPath(System.getProperty("java.io.tmpdir"), "asterixdb");
- NCConfig.defaultAppClass = NCApplication.class.getName();
- CCConfig.defaultAppClass = CCApplication.class.getName();
+
ControllerConfig.Option.DEFAULT_DIR.setDefaultValue(FileUtil.joinPath(System.getProperty("java.io.tmpdir"),
"asterixdb"));
+
NCConfig.Option.APP_CLASS.setDefaultValue(NCApplication.class.getName());
+
CCConfig.Option.APP_CLASS.setDefaultValue(CCApplication.class.getName());
try {
InputStream propertyStream =
ApplicationConfigurator.class.getClassLoader()
.getResourceAsStream("git.properties");
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
index acd4540..e656790 100644
---
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
@@ -85,8 +85,8 @@
ConfigManager configManager = new ConfigManager();
CCApplication application = new CCApplication();
application.registerConfig(configManager);
- ControllerConfig.defaultDir =
ControllerConfig.defaultDir.replace(System.getProperty("java.io.tmpdir"),
- "${java.io.tmpdir}/");
+
ControllerConfig.Option.DEFAULT_DIR.setDefaultValue(((String)ControllerConfig.Option.DEFAULT_DIR.defaultValue()).replace(System.getProperty("java.io.tmpdir"),
+ "${java.io.tmpdir}/"));
return configManager;
}
diff --git
a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/NodeProperties.java
b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/NodeProperties.java
index e3a5fb9..1d09fff 100644
---
a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/NodeProperties.java
+++
b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/NodeProperties.java
@@ -18,12 +18,14 @@
*/
package org.apache.asterix.common.config;
-import java.util.function.Supplier;
+import java.util.function.Function;
+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;
import org.apache.hyracks.control.common.config.OptionTypes;
+import org.apache.hyracks.control.common.controllers.ControllerConfig;
import org.apache.hyracks.control.common.controllers.NCConfig;
import org.apache.hyracks.util.file.FileUtil;
@@ -33,29 +35,34 @@
INITIAL_RUN(OptionTypes.BOOLEAN, false, "A flag indicating if it's the
first time the NC is started"),
CORE_DUMP_DIR(
OptionTypes.STRING,
- (Supplier<String>) () ->
FileUtil.joinPath(NCConfig.defaultDir, "coredump"),
- "The directory where node core dumps should be written"),
+ appConfig ->
FileUtil.joinPath(appConfig.getString(ControllerConfig.Option.DEFAULT_DIR),
"coredump"),
+ "The directory where node core dumps should be written",
+ "<value of " + ControllerConfig.Option.DEFAULT_DIR.cmdline() +
">/coredump"),
TXN_LOG_DIR(
OptionTypes.STRING,
- (Supplier<String>) () ->
FileUtil.joinPath(NCConfig.defaultDir, "txn-log"),
- "The directory where transaction logs should be stored"),
- STORAGE_SUBDIR(OptionTypes.STRING, "storage", "The subdirectory name
under each iodevice used for storage"),
- ;
+ appConfig ->
FileUtil.joinPath(appConfig.getString(ControllerConfig.Option.DEFAULT_DIR),
"txn-log"),
+ "The directory where transaction logs should be stored",
+ "<value of " + ControllerConfig.Option.DEFAULT_DIR.cmdline() +
">/txn-log"),
+ STORAGE_SUBDIR(OptionTypes.STRING, "storage", "The subdirectory name
under each iodevice used for storage"),;
private final IOptionType type;
private final Object defaultValue;
private final String description;
+ private final String defaultValueDescription;
<T> Option(IOptionType<T> type, T defaultValue, String description) {
this.type = type;
this.defaultValue = defaultValue;
this.description = description;
+ this.defaultValueDescription = null;
}
- <T> Option(IOptionType<T> type, Supplier<T> defaultValue, String
description) {
+ <T> Option(IOptionType<T> type, Function<IApplicationConfig, T>
defaultValue, String description,
+ String defaultValueDescription) {
this.type = type;
this.defaultValue = defaultValue;
this.description = description;
+ this.defaultValueDescription = defaultValueDescription;
}
@Override
@@ -79,9 +86,15 @@
}
@Override
+ public String usageDefaultOverride(IApplicationConfig accessor,
Function<IOption, String> optionPrinter) {
+ return defaultValueDescription;
+ }
+
+ @Override
public boolean hidden() {
return this == INITIAL_RUN;
}
+
}
public NodeProperties(PropertiesAccessor accessor) {
diff --git
a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/controllers/CCConfig.java
b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/controllers/CCConfig.java
index 51451ce..f83df3a 100644
---
a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/controllers/CCConfig.java
+++
b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/controllers/CCConfig.java
@@ -26,8 +26,9 @@
import java.net.InetAddress;
import java.util.ArrayList;
import java.util.List;
-import java.util.function.Supplier;
+import java.util.function.Function;
+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;
@@ -38,10 +39,8 @@
@SuppressWarnings("SameParameterValue")
public class CCConfig extends ControllerConfig {
- public static String defaultAppClass;
-
public enum Option implements IOption {
- APP_CLASS(STRING, (Supplier<String>)() -> defaultAppClass),
+ APP_CLASS(STRING, (String) null),
ADDRESS(STRING, InetAddress.getLoopbackAddress().getHostAddress()),
CLUSTER_LISTEN_ADDRESS(STRING, ADDRESS),
CLUSTER_LISTEN_PORT(INTEGER, 1099),
@@ -58,32 +57,40 @@
RESULT_TTL(LONG, 86400000L), // TODO(mblow): add time unit
RESULT_SWEEP_THRESHOLD(LONG, 60000L), // TODO(mblow): add time unit
@SuppressWarnings("RedundantCast") // not redundant- false positive
from IDEA
- ROOT_DIR(STRING, (Supplier<String>)() -> FileUtil.joinPath(defaultDir,
"ClusterControllerService")),
+ ROOT_DIR(STRING, (Function<IApplicationConfig, String>) appConfig ->
+
FileUtil.joinPath(appConfig.getString(ControllerConfig.Option.DEFAULT_DIR),
+ "ClusterControllerService"), "<value of " +
ControllerConfig.Option.DEFAULT_DIR.cmdline() +
+ ">/ClusterControllerService"),
CLUSTER_TOPOLOGY(STRING),
JOB_QUEUE_CLASS(STRING,
"org.apache.hyracks.control.cc.scheduler.FIFOJobQueue"),
JOB_QUEUE_CAPACITY(INTEGER, 4096),
JOB_MANAGER_CLASS(STRING,
"org.apache.hyracks.control.cc.job.JobManager");
private final IOptionType parser;
- private final Object defaultValue;
+ private Object defaultValue;
+ private final String defaultValueDescription;
<T> Option(IOptionType<T> parser) {
- this(parser, (T)null);
+ this(parser, (T) null);
}
<T> Option(IOptionType<T> parser, Option defaultOption) {
this.parser = parser;
this.defaultValue = defaultOption;
+ defaultValueDescription = null;
}
<T> Option(IOptionType<T> parser, T defaultValue) {
this.parser = parser;
this.defaultValue = defaultValue;
+ defaultValueDescription = null;
}
- <T> Option(IOptionType<T> parser, Supplier<T> defaultValue) {
+ <T> Option(IOptionType<T> parser, Function<IApplicationConfig, T>
defaultValue,
+ String defaultValueDescription) {
this.parser = parser;
this.defaultValue = defaultValue;
+ this.defaultValueDescription = defaultValueDescription;
}
@Override
@@ -129,16 +136,16 @@
case HEARTBEAT_MAX_MISSES:
return "Sets the maximum number of missed heartbeats
before a node is marked as dead";
case PROFILE_DUMP_PERIOD:
- return "Sets the time duration between two profile dumps
from each node controller in " +
- "milliseconds; 0 to disable";
+ return "Sets the time duration between two profile dumps
from each node controller in "
+ + "milliseconds; 0 to disable";
case JOB_HISTORY_SIZE:
return "Limits the number of historical jobs remembered by
the system to the specified value";
case RESULT_TTL:
- return "Limits the amount of time results for asynchronous
jobs should be retained by the system " +
- "in milliseconds";
+ return "Limits the amount of time results for asynchronous
jobs should be retained by the system "
+ + "in milliseconds";
case RESULT_SWEEP_THRESHOLD:
- return "The duration within which an instance of the
result cleanup should be invoked in " +
- "milliseconds";
+ return "The duration within which an instance of the
result cleanup should be invoked in "
+ + "milliseconds";
case ROOT_DIR:
return "Sets the root folder used for file operations";
case CLUSTER_TOPOLOGY:
@@ -153,6 +160,15 @@
throw new IllegalStateException("NYI: " + this);
}
}
+
+ public void setDefaultValue(Object defaultValue) {
+ this.defaultValue = defaultValue;
+ }
+
+ @Override
+ public String usageDefaultOverride(IApplicationConfig accessor,
Function<IOption, String> optionPrinter) {
+ return defaultValueDescription;
+ }
}
private final ConfigManager configManager;
diff --git
a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/controllers/ControllerConfig.java
b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/controllers/ControllerConfig.java
index 05f7854..a9b3f97 100644
---
a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/controllers/ControllerConfig.java
+++
b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/controllers/ControllerConfig.java
@@ -31,19 +31,21 @@
public class ControllerConfig implements Serializable {
- public static String defaultDir =
FileUtil.joinPath(System.getProperty("java.io.tmpdir"), "hyracks");
-
public enum Option implements IOption {
- CONFIG_FILE(OptionTypes.STRING, "Specify path to master configuration
file"),
- CONFIG_FILE_URL(OptionTypes.URL, "Specify URL to master configuration
file");
+ CONFIG_FILE(OptionTypes.STRING, "Specify path to master configuration
file", null),
+ CONFIG_FILE_URL(OptionTypes.URL, "Specify URL to master configuration
file", null),
+ DEFAULT_DIR(OptionTypes.STRING, "Directory where files are written to
by default",
+ FileUtil.joinPath(System.getProperty("java.io.tmpdir"),
"hyracks")),
+ ;
private final IOptionType type;
private final String description;
+ private String defaultValue;
-
- Option(IOptionType type, String description) {
+ Option(IOptionType type, String description, String defaultValue) {
this.type = type;
this.description = description;
+ this.defaultValue = defaultValue;
}
@Override
@@ -63,7 +65,11 @@
@Override
public Object defaultValue() {
- return null;
+ return defaultValue;
+ }
+
+ public void setDefaultValue(String defaultValue) {
+ this.defaultValue = defaultValue;
}
}
diff --git
a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/controllers/NCConfig.java
b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/controllers/NCConfig.java
index 9cf4da3..86cc19e 100644
---
a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/controllers/NCConfig.java
+++
b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/controllers/NCConfig.java
@@ -28,7 +28,7 @@
import java.net.InetAddress;
import java.util.ArrayList;
import java.util.List;
-import java.util.function.Supplier;
+import java.util.function.Function;
import org.apache.hyracks.api.config.IApplicationConfig;
import org.apache.hyracks.api.config.IOption;
@@ -40,8 +40,6 @@
public class NCConfig extends ControllerConfig {
private static final long serialVersionUID = 3L;
- public static String defaultAppClass;
-
public enum Option implements IOption {
ADDRESS(STRING, InetAddress.getLoopbackAddress().getHostAddress()),
PUBLIC_ADDRESS(STRING, ADDRESS),
@@ -49,11 +47,11 @@
CLUSTER_LISTEN_PORT(INTEGER, 0),
NCSERVICE_ADDRESS(STRING, PUBLIC_ADDRESS),
NCSERVICE_PORT(INTEGER, 9090),
- CLUSTER_ADDRESS(STRING, (String)null),
+ CLUSTER_ADDRESS(STRING, (String) null),
CLUSTER_PORT(INTEGER, 1099),
CLUSTER_PUBLIC_ADDRESS(STRING, PUBLIC_ADDRESS),
CLUSTER_PUBLIC_PORT(INTEGER, CLUSTER_LISTEN_PORT),
- NODE_ID(STRING, (String)null),
+ NODE_ID(STRING, (String) null),
DATA_LISTEN_ADDRESS(STRING, ADDRESS),
DATA_LISTEN_PORT(INTEGER, 0),
DATA_PUBLIC_ADDRESS(STRING, PUBLIC_ADDRESS),
@@ -67,36 +65,42 @@
MESSAGING_PUBLIC_ADDRESS(STRING, PUBLIC_ADDRESS),
MESSAGING_PUBLIC_PORT(INTEGER, MESSAGING_LISTEN_PORT),
CLUSTER_CONNECT_RETRIES(INTEGER, 5),
- @SuppressWarnings("RedundantCast") // not redundant- false positive
from IDEA
- IODEVICES(STRING_ARRAY, (Supplier<String []>)() -> new String [] {
FileUtil.joinPath(defaultDir, "iodevice") }),
+ IODEVICES(STRING_ARRAY, appConfig -> new String[] {
+
FileUtil.joinPath(appConfig.getString(ControllerConfig.Option.DEFAULT_DIR),
"iodevice") },
+ "<value of " + ControllerConfig.Option.DEFAULT_DIR.cmdline() +
">/iodevice"),
NET_THREAD_COUNT(INTEGER, 1),
NET_BUFFER_COUNT(INTEGER, 1),
RESULT_TTL(LONG, 86400000L),
RESULT_SWEEP_THRESHOLD(LONG, 60000L),
RESULT_MANAGER_MEMORY(INTEGER_BYTE_UNIT, -1),
@SuppressWarnings("RedundantCast") // not redundant- false positive
from IDEA
- APP_CLASS(STRING, (Supplier<String>)() -> defaultAppClass),
+ APP_CLASS(STRING, (String) null),
NCSERVICE_PID(INTEGER, -1),
COMMAND(STRING, "hyracksnc"),
- JVM_ARGS(STRING, (String)null),
+ JVM_ARGS(STRING, (String) null),
VIRTUAL_NC(BOOLEAN, false);
private final IOptionType parser;
- private final Object defaultValue;
+ private final String defaultValueDescription;
+ private Object defaultValue;
<T> Option(IOptionType<T> parser, Option defaultOption) {
this.parser = parser;
this.defaultValue = defaultOption;
+ defaultValueDescription = null;
}
<T> Option(IOptionType<T> parser, T defaultValue) {
this.parser = parser;
this.defaultValue = defaultValue;
+ defaultValueDescription = null;
}
- <T> Option(IOptionType<T> parser, Supplier<T> defaultValue) {
+ <T> Option(IOptionType<T> parser, Function<IApplicationConfig, T>
defaultValue,
+ String defaultValueDescription) {
this.parser = parser;
this.defaultValue = defaultValue;
+ this.defaultValueDescription = defaultValueDescription;
}
@Override
@@ -113,13 +117,13 @@
public String description() {
switch (this) {
case ADDRESS:
- return "Default IP Address to bind listeners on this NC.
All services will bind on this address " +
- "unless a service-specific listen address is
supplied.";
+ return "Default IP Address to bind listeners on this NC.
All services will bind on this address "
+ + "unless a service-specific listen address is
supplied.";
case CLUSTER_LISTEN_ADDRESS:
return "IP Address to bind cluster listener on this NC";
case PUBLIC_ADDRESS:
- return "Default public address that other processes should
use to contact this NC. All services " +
- "will advertise this address unless a
service-specific public address is supplied.";
+ return "Default public address that other processes should
use to contact this NC. All services "
+ + "will advertise this address unless a
service-specific public address is supplied.";
case NCSERVICE_ADDRESS:
return "Address the CC should use to contact the NCService
associated with this NC";
case NCSERVICE_PORT:
@@ -135,8 +139,8 @@
case CLUSTER_PUBLIC_PORT:
return "Public IP port to announce cluster listener";
case NODE_ID:
- return "Logical name of node controller unique within the
cluster (required unless specified in " +
- "config file)";
+ return "Logical name of node controller unique within the
cluster (required unless specified in "
+ + "config file)";
case DATA_LISTEN_ADDRESS:
return "IP Address to bind data listener";
case DATA_LISTEN_PORT:
@@ -170,11 +174,11 @@
case NET_BUFFER_COUNT:
return "Number of network buffers per input/output
channel";
case RESULT_TTL:
- return "Limits the amount of time results for asynchronous
jobs should be retained by the system " +
- "in milliseconds";
+ return "Limits the amount of time results for asynchronous
jobs should be retained by the system "
+ + "in milliseconds";
case RESULT_SWEEP_THRESHOLD:
- return "The duration within which an instance of the
result cleanup should be invoked in " +
- "milliseconds";
+ return "The duration within which an instance of the
result cleanup should be invoked in "
+ + "milliseconds";
case RESULT_MANAGER_MEMORY:
return "Memory usable for result caching at this Node
Controller in bytes";
case APP_CLASS:
@@ -192,7 +196,6 @@
}
}
-
@Override
public IOptionType type() {
return parser;
@@ -203,10 +206,20 @@
return defaultValue;
}
+ public void setDefaultValue(Object defaultValue) {
+ this.defaultValue = defaultValue;
+ }
+
@Override
public boolean hidden() {
return this == VIRTUAL_NC;
}
+
+ @Override
+ public String usageDefaultOverride(IApplicationConfig accessor,
Function<IOption, String> optionPrinter) {
+ return defaultValueDescription;
+ }
+
}
private List<String> appArgs = new ArrayList<>();
--
To view, visit https://asterix-gerrit.ics.uci.edu/1751
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I7855c8f344eea9c9b6a394d85413a062a3ddb609
Gerrit-PatchSet: 1
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Michael Blow <[email protected]>