Jackie-Jiang commented on code in PR #20202:
URL: https://github.com/apache/pinot/pull/20202#discussion_r4530675198


##########
pinot-tools/src/main/java/org/apache/pinot/tools/admin/command/QuickstartServerProcess.java:
##########
@@ -0,0 +1,279 @@
+/**
+ * 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.pinot.tools.admin.command;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.RandomAccessFile;
+import java.lang.management.ManagementFactory;
+import java.net.HttpURLConnection;
+import java.net.URI;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.time.Duration;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+import org.apache.commons.configuration2.PropertiesConfiguration;
+import org.apache.commons.configuration2.convert.LegacyListDelimiterHandler;
+import org.apache.commons.configuration2.io.FileHandler;
+import org.apache.pinot.spi.utils.CommonConstants;
+import org.apache.pinot.tools.admin.PinotAdministrator;
+
+
+/// Owns one quickstart server JVM, its configuration, and its startup log. 
Startup waits for the server's readiness
+/// endpoint. The child exits when its parent's stdin pipe closes, including 
when the parent is killed abruptly.
+/// [#stop] is synchronized and can be called repeatedly or concurrently with 
waiting for readiness.
+final class QuickstartServerProcess {
+  static final String STARTED_FILE_NAME = "server.started";
+  private static final Duration STARTUP_TIMEOUT = Duration.ofMinutes(2);
+  private static final long SHUTDOWN_TIMEOUT_SECONDS = 30;
+  private static final long FORCED_SHUTDOWN_TIMEOUT_SECONDS = 10;
+
+  private final Process _process;
+  private final File _logFile;
+  private final File _startedFile;
+  private final int _port;
+
+  private QuickstartServerProcess(Process process, File logFile, File 
startedFile, int port) {
+    _process = process;
+    _logFile = logFile;
+    _startedFile = startedFile;
+    _port = port;
+  }
+
+  static QuickstartServerProcess launch(Map<String, Object> effectiveConfig, 
File processDir)
+      throws Exception {
+    Files.createDirectories(processDir.toPath());
+    Files.createDirectories(new File(processDir, "tmp").toPath());
+    File configFile = new File(processDir, "server.properties");
+    writeConfig(effectiveConfig, configFile);
+    int port = 
Integer.parseInt(effectiveConfig.get(CommonConstants.Server.CONFIG_OF_ADMIN_API_PORT).toString());
+    return launch(buildCommand(configFile, processDir), processDir, port);
+  }
+
+  static void writeConfig(Map<String, Object> effectiveConfig, File configFile)
+      throws Exception {
+    PropertiesConfiguration configuration = new PropertiesConfiguration();
+    configuration.setListDelimiterHandler(new LegacyListDelimiterHandler(','));
+    configuration.getLayout().setForceSingleLine(true);
+    effectiveConfig.forEach(configuration::setProperty);
+    new FileHandler(configuration).save(configFile);
+  }
+
+  static List<String> buildCommand(File configFile, File processDir) {
+    List<String> command = new ArrayList<>();
+    File javaExecutable = new File(System.getProperty("java.home"), 
"bin/java");
+    command.add(javaExecutable.getAbsolutePath());
+    command.add("-Xms128m");
+    command.add("-Xmx1g");

Review Comment:
   Updated in `911b8a43ba` to match the usual equal-heap convention. 
`pinot.quickstart.server.xmx` defaults to `1g`, and 
`pinot.quickstart.server.xms` inherits the configured maximum unless explicitly 
set. Defaults are therefore `-Xms1g -Xmx1g`; setting only `xmx=512m` produces 
`512m/512m`, while an explicit smaller `xms` remains supported.
   
   The [Docker QuickStart 
documentation](https://github.com/apache/pinot/blob/911b8a43ba8873a8bf959d615e0c5f4e4c98b2c5/docker/images/pinot/README.md#heap-sizes-for-forked-quickstarts)
 covers configuration and the unchanged 6 GiB / 8 GiB aggregate maximum heap 
budgets plus native-memory headroom. Tests launch actual JVMs for all three 
cases. The live two-server check also verified both servers' `-Xms1g -Xmx1g` 
arguments.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to