diff --git a/minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloClusterImpl.java b/minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloClusterImpl.java index 36939b5ac71..adda1c65be2 100644 --- a/minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloClusterImpl.java +++ b/minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloClusterImpl.java @@ -138,6 +138,10 @@ public class MiniAccumuloClusterImpl implements AccumuloCluster { private final AtomicReference miniDFS = new AtomicReference<>(); private final List cleanup = new ArrayList<>(); private final MiniAccumuloClusterControl clusterControl; + private final Set defaultJvmOpts = + Set.of("-XX:+PerfDisableSharedMem", "-XX:+AlwaysPreTouch"); + private final Map defaultSystemProps = + Map.of("apple.awt.UIElement", "true", "java.net.preferIPv4Stack", "true"); private boolean initialized = false; private ExecutorService executor; @@ -348,8 +352,13 @@ private ProcessInfo _exec(Class clazz, List extraJvmOpts, String... a String javaBin = javaHome + File.separator + "bin" + File.separator + "java"; var basicArgs = Stream.of(javaBin, "-Dproc=" + clazz.getSimpleName()); - var jvmOptions = Stream.concat(config.getJvmOptions().stream(), extraJvmOpts.stream()); - var systemProps = config.getSystemProperties().entrySet().stream() + + var jvmOptions = + Stream.concat(Stream.concat(defaultJvmOpts.stream(), config.getJvmOptions().stream()), + extraJvmOpts.stream()); + var systemProps = Stream + .concat(defaultSystemProps.entrySet().stream(), + config.getSystemProperties().entrySet().stream()) .map(e -> String.format("-D%s=%s", e.getKey(), e.getValue())); var classArgs = Stream.of(Main.class.getName(), clazz.getName()); diff --git a/minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloConfigImpl.java b/minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloConfigImpl.java index dbbbf5aecd5..8e81809563b 100644 --- a/minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloConfigImpl.java +++ b/minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloConfigImpl.java @@ -88,7 +88,7 @@ public class MiniAccumuloConfigImpl { MONITOR, Monitor.class, ZOOKEEPER, ZooKeeperServerMain.class, TABLET_SERVER, TabletServer.class, SCAN_SERVER, ScanServer.class, COMPACTOR, Compactor.class)); private boolean jdwpEnabled = false; - private final Map systemProperties = new HashMap<>(); + private Map systemProperties = new HashMap<>(); private final Set jvmOptions = new HashSet<>(); private String instanceName = "miniInstance"; @@ -134,11 +134,6 @@ public class MiniAccumuloConfigImpl { public MiniAccumuloConfigImpl(File dir, String rootPassword) { this.dir = dir; this.rootPassword = rootPassword; - // Set default options - this.jvmOptions.add("-XX:+PerfDisableSharedMem"); - this.jvmOptions.add("-XX:+AlwaysPreTouch"); - this.systemProperties.put("-Dapple.awt.UIElement", "true"); - this.systemProperties.put("-Djava.net.preferIPv4Stack", "true"); } /** @@ -677,7 +672,7 @@ public File getClientPropsFile() { * @since 1.6.0 */ public void setSystemProperties(Map systemProperties) { - this.systemProperties.putAll(systemProperties); + this.systemProperties = new HashMap<>(systemProperties); } /** @@ -690,36 +685,13 @@ public Map getSystemProperties() { } /** - * Add a JVM option to the spawned JVM processes. The default set of JVM options contains - * '-XX:+PerfDisableSharedMem' and '-XX:+AlwaysPreTouch' - * - * @param option JVM option - * @since 2.1.5 - */ - public void addJvmOption(String option) { - this.jvmOptions.add(option); - } - - /** - * Remove an option from the set of JVM options. Only options that match the {@code option} - * exactly will be removed. - * - * @param option JVM option - * @return true if removed, false if not removed - * @since 2.1.5 - */ - public boolean removeJvmOption(String option) { - return this.jvmOptions.remove(option); - } - - /** - * Get the set of JVM options + * Get the set of JVM options. Changes to this set will affect the Configuration * * @return set of options * @since 2.1.5 */ public Set getJvmOptions() { - return new HashSet<>(jvmOptions); + return jvmOptions; } /** diff --git a/test/src/main/java/org/apache/accumulo/test/tracing/ScanTracingIT.java b/test/src/main/java/org/apache/accumulo/test/tracing/ScanTracingIT.java index 898915999d7..1bdcd6a1fd5 100644 --- a/test/src/main/java/org/apache/accumulo/test/tracing/ScanTracingIT.java +++ b/test/src/main/java/org/apache/accumulo/test/tracing/ScanTracingIT.java @@ -74,7 +74,7 @@ private static List getJvmArgs() { @Override protected void configure(MiniAccumuloConfigImpl cfg, Configuration hadoopCoreSite) { - getJvmArgs().forEach(cfg::addJvmOption); + cfg.getJvmOptions().addAll(getJvmArgs()); // sized such that full table scans will not fit in the cache cfg.setProperty(Property.TSERV_DATACACHE_SIZE.getKey(), "8M"); cfg.setProperty(Property.TSERV_SCAN_EXECUTORS_PREFIX.getKey() + "pool1.threads", "8");