This is an automated email from the ASF dual-hosted git repository.

mpochatkin pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/ignite-3.git


The following commit(s) were added to refs/heads/main by this push:
     new 8a1a15a0d7 IGNITE-22364 Remove daemon mode in zip distribution (#3940)
8a1a15a0d7 is described below

commit 8a1a15a0d77bc3dffd7c1f81eae0a9dc4fd826ff
Author: Maksim Myskov <[email protected]>
AuthorDate: Fri Jun 28 15:05:12 2024 +0300

    IGNITE-22364 Remove daemon mode in zip distribution (#3940)
---
 .../internal/rest/ItRestAddressReportTest.java     |  98 ----------------
 .../org/apache/ignite/internal/app/IgniteImpl.java |   7 --
 .../internal/component/RestAddressReporter.java    |  83 --------------
 .../component/RestAddressReporterTest.java         | 125 ---------------------
 packaging/db/zip/linux/ignite3db                   |  61 +---------
 5 files changed, 2 insertions(+), 372 deletions(-)

diff --git 
a/modules/rest/src/integrationTest/java/org/apache/ignite/internal/rest/ItRestAddressReportTest.java
 
b/modules/rest/src/integrationTest/java/org/apache/ignite/internal/rest/ItRestAddressReportTest.java
deleted file mode 100644
index c717b61be5..0000000000
--- 
a/modules/rest/src/integrationTest/java/org/apache/ignite/internal/rest/ItRestAddressReportTest.java
+++ /dev/null
@@ -1,98 +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.ignite.internal.rest;
-
-import static 
org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willCompleteSuccessfully;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.is;
-
-import java.net.InetAddress;
-import java.net.URL;
-import java.net.UnknownHostException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import org.apache.ignite.IgniteServer;
-import org.apache.ignite.InitParameters;
-import org.apache.ignite.internal.app.IgniteRunner;
-import org.apache.ignite.internal.testframework.BaseIgniteAbstractTest;
-import org.apache.ignite.internal.testframework.TestIgnitionManager;
-import org.apache.ignite.internal.testframework.WorkDirectory;
-import org.apache.ignite.internal.testframework.WorkDirectoryExtension;
-import org.junit.jupiter.api.DisplayName;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
-
-/**
- * Test that after Ignite is started there is a file with REST server address 
in working directory.
- */
-@ExtendWith(WorkDirectoryExtension.class)
-public class ItRestAddressReportTest extends BaseIgniteAbstractTest {
-    private static final String NODE_NAME = "node";
-
-    @WorkDirectory
-    private Path workDir;
-
-    @Test
-    @DisplayName("Should report rest port to the file after RestComponent 
started")
-    void restPortReportedToFile() throws Exception {
-        // Given configuration with rest port configured rest.port=10333
-        Path configPath = 
Path.of(ItRestAddressReportTest.class.getResource("/ignite-config-rest-port-not-default.json").toURI());
-
-        // When start node
-        IgniteServer node = IgniteRunner.start(
-                "--config-path", configPath.toAbsolutePath().toString(),
-                "--work-dir", 
workDir.resolve(NODE_NAME).toAbsolutePath().toString(),
-                "--node-name", NODE_NAME
-        );
-
-        // And init cluster
-        InitParameters initParameters = InitParameters.builder()
-                .metaStorageNodes(node)
-                .clusterName("cluster")
-                .build();
-
-        TestIgnitionManager.init(node, initParameters);
-
-        // Then node is started
-        assertThat(node.waitForInitAsync(), willCompleteSuccessfully());
-
-        // And there is a file in work dir with the rest address
-        Path reportFile = workDir.resolve(NODE_NAME).resolve("rest-address");
-        assertThat(Files.exists(reportFile), is(true));
-
-        // And the file contains valid rest server network address
-        URL restUri = new URL(Files.readString(reportFile));
-        assertThat(restUri.getHost(), is(equalTo(getHostName())));
-        assertThat(restUri.getPort(), is(equalTo(10333)));
-
-        // When stop node
-        node.shutdown();
-
-        // Then the file is removed
-        assertThat(Files.exists(reportFile), is(false));
-    }
-
-    private static String getHostName() {
-        try {
-            return InetAddress.getLocalHost().getHostName();
-        } catch (UnknownHostException e) {
-            return "localhost";
-        }
-    }
-}
diff --git 
a/modules/runner/src/main/java/org/apache/ignite/internal/app/IgniteImpl.java 
b/modules/runner/src/main/java/org/apache/ignite/internal/app/IgniteImpl.java
index 13751fe0cc..adfdac3464 100644
--- 
a/modules/runner/src/main/java/org/apache/ignite/internal/app/IgniteImpl.java
+++ 
b/modules/runner/src/main/java/org/apache/ignite/internal/app/IgniteImpl.java
@@ -79,7 +79,6 @@ import 
org.apache.ignite.internal.cluster.management.topology.api.LogicalNode;
 import 
org.apache.ignite.internal.cluster.management.topology.api.LogicalTopologyEventListener;
 import 
org.apache.ignite.internal.cluster.management.topology.api.LogicalTopologyService;
 import 
org.apache.ignite.internal.cluster.management.topology.api.LogicalTopologySnapshot;
-import org.apache.ignite.internal.component.RestAddressReporter;
 import org.apache.ignite.internal.components.LogSyncer;
 import org.apache.ignite.internal.components.LongJvmPauseDetector;
 import org.apache.ignite.internal.compute.AntiHijackIgniteCompute;
@@ -383,8 +382,6 @@ public class IgniteImpl implements Ignite {
 
     private final OutgoingSnapshotsManager outgoingSnapshotsManager;
 
-    private final RestAddressReporter restAddressReporter;
-
     private final CatalogManager catalogManager;
 
     private final AuthenticationManager authenticationManager;
@@ -668,8 +665,6 @@ public class IgniteImpl implements Ignite {
 
         
metricManager.configure(clusterConfigRegistry.getConfiguration(MetricConfiguration.KEY));
 
-        restAddressReporter = new RestAddressReporter(workDir);
-
         DataStorageModules dataStorageModules = new DataStorageModules(
                 ServiceLoader.load(DataStorageModule.class, 
serviceProviderClassLoader)
         );
@@ -1085,7 +1080,6 @@ public class IgniteImpl implements Ignite {
                     clusterSvc.updateMetadata(
                             new NodeMetadata(restComponent.hostName(), 
restComponent.httpPort(), restComponent.httpsPort()));
 
-                    restAddressReporter.writeReport(restHttpAddress(), 
restHttpsAddress());
                 } catch (Throwable e) {
                     startupExecutor.shutdownNow();
 
@@ -1278,7 +1272,6 @@ public class IgniteImpl implements Ignite {
 
         // TODO https://issues.apache.org/jira/browse/IGNITE-22570
         return lifecycleManager.stopNode(new 
ComponentContext(lifecycleExecutor))
-                .whenCompleteAsync((unused, throwable) -> 
restAddressReporter.removeReport())
                 // Moving to the common pool on purpose to close the stop pool 
and proceed user's code in the common pool.
                 .whenCompleteAsync((res, ex) -> 
lifecycleExecutor.shutdownNow());
     }
diff --git 
a/modules/runner/src/main/java/org/apache/ignite/internal/component/RestAddressReporter.java
 
b/modules/runner/src/main/java/org/apache/ignite/internal/component/RestAddressReporter.java
deleted file mode 100644
index 884fe2ed18..0000000000
--- 
a/modules/runner/src/main/java/org/apache/ignite/internal/component/RestAddressReporter.java
+++ /dev/null
@@ -1,83 +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.ignite.internal.component;
-
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.Objects;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-import org.apache.ignite.internal.logger.IgniteLogger;
-import org.apache.ignite.internal.logger.Loggers;
-import org.apache.ignite.lang.ErrorGroups.Common;
-import org.apache.ignite.lang.IgniteException;
-import org.apache.ignite.network.NetworkAddress;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Can write network address to file that could be used by other systems to 
know on what port Ignite 3 REST server is started.
- */
-public class RestAddressReporter {
-
-    private static final IgniteLogger LOG = 
Loggers.forClass(RestAddressReporter.class);
-
-    private static final String REPORT_FILE_NAME = "rest-address";
-
-    private final Path workDir;
-
-    /** Main constructor that accept the root directory where report file will 
be written. */
-    public RestAddressReporter(Path workDir) {
-        this.workDir = workDir;
-    }
-
-    /** Write network address to file. */
-    public void writeReport(@Nullable NetworkAddress httpAddress, @Nullable 
NetworkAddress httpsAddress) {
-        try {
-            Files.writeString(workDir.resolve(REPORT_FILE_NAME), 
report(httpAddress, httpsAddress));
-        } catch (IOException e) {
-            String message = "Unexpected error when trying to write REST 
server network address to file";
-            throw new IgniteException(Common.INTERNAL_ERR, message, e);
-        }
-    }
-
-    private String report(@Nullable NetworkAddress httpAddress, @Nullable 
NetworkAddress httpsAddress) {
-        return Stream.of(report("http", httpAddress), report("https", 
httpsAddress))
-                .filter(Objects::nonNull)
-                .collect(Collectors.joining(", "));
-    }
-
-    @Nullable
-    private String report(String protocol, @Nullable NetworkAddress 
httpAddress) {
-        if (httpAddress == null) {
-            return null;
-        } else {
-            return protocol + "://" + httpAddress.host() + ":" + 
httpAddress.port();
-        }
-    }
-
-    /** Remove report file. The method is expected to be called on node stop. 
*/
-    public void removeReport() {
-        try {
-            Files.delete(workDir.resolve(REPORT_FILE_NAME));
-        } catch (IOException e) {
-            String message = "Unexpected error when trying to remove REST 
server network address file";
-            LOG.error(message, new IgniteException(Common.INTERNAL_ERR, 
message, e));
-        }
-    }
-}
diff --git 
a/modules/runner/src/test/java/org/apache/ignite/internal/component/RestAddressReporterTest.java
 
b/modules/runner/src/test/java/org/apache/ignite/internal/component/RestAddressReporterTest.java
deleted file mode 100644
index b69badbbee..0000000000
--- 
a/modules/runner/src/test/java/org/apache/ignite/internal/component/RestAddressReporterTest.java
+++ /dev/null
@@ -1,125 +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.ignite.internal.component;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.is;
-import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
-
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import org.apache.ignite.network.NetworkAddress;
-import org.junit.jupiter.api.DisplayName;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.io.TempDir;
-
-/** Test for {@link RestAddressReporter}. */
-class RestAddressReporterTest {
-
-    private static final String REST_ADDRESS_FILENAME = "rest-address";
-
-    @Test
-    @DisplayName("REST server network addresses is reported to file")
-    void httpAndHttpsAddressesReported(@TempDir Path tmpDir) throws 
IOException {
-        // Given
-        RestAddressReporter reporter = new RestAddressReporter(tmpDir);
-
-        // When
-        reporter.writeReport(new NetworkAddress("localhost", 9999), new 
NetworkAddress("localhost", 8443));
-
-        // Then there is a report
-        String restAddress = 
Files.readString(tmpDir.resolve(REST_ADDRESS_FILENAME));
-        assertThat(restAddress, equalTo("http://localhost:9999, 
https://localhost:8443";));
-    }
-
-    @Test
-    @DisplayName("REST server HTTP address is reported to file")
-    void httpAddressReported(@TempDir Path tmpDir) throws IOException {
-        // Given
-        RestAddressReporter reporter = new RestAddressReporter(tmpDir);
-
-        // When
-        reporter.writeReport(new NetworkAddress("localhost", 9999), null);
-
-        // Then there is a report
-        String restAddress = 
Files.readString(tmpDir.resolve(REST_ADDRESS_FILENAME));
-        assertThat(restAddress, equalTo("http://localhost:9999";));
-    }
-
-    @Test
-    @DisplayName("REST server HTTPS address is reported to file")
-    void httpsAddressReported(@TempDir Path tmpDir) throws IOException {
-        // Given
-        RestAddressReporter reporter = new RestAddressReporter(tmpDir);
-
-        // When
-        reporter.writeReport(null, new NetworkAddress("localhost", 8443));
-
-        // Then there is a report
-        String restAddress = 
Files.readString(tmpDir.resolve(REST_ADDRESS_FILENAME));
-        assertThat(restAddress, equalTo("https://localhost:8443";));
-    }
-
-    @Test
-    @DisplayName("File with network address is removed")
-    void reportDeleted(@TempDir Path tmpDir) throws IOException {
-        // Given reported address
-        RestAddressReporter reporter = new RestAddressReporter(tmpDir);
-        reporter.writeReport(new NetworkAddress("localhost", 9999), new 
NetworkAddress("localhost", 8443));
-        // And file exists
-        assertThat(Files.exists(tmpDir.resolve(REST_ADDRESS_FILENAME)), 
is(true));
-
-        // When
-        reporter.removeReport();
-
-        // Then file is removed
-        assertThat(Files.exists(tmpDir.resolve(REST_ADDRESS_FILENAME)), 
is(false));
-    }
-
-    @Test
-    @DisplayName("If there is no report file for some reason then throw an 
exception")
-    void doesNotThrowExceptionWhenThereIsNoFile(@TempDir Path tmpDir) {
-        // Given
-        Path path = tmpDir.resolve("nosuchpath");
-        RestAddressReporter reporter = new RestAddressReporter(path);
-
-        // When try to removeReport
-        // Then nothing is thrown
-        assertDoesNotThrow(reporter::removeReport);
-    }
-
-    @Test
-    @DisplayName("If there is a file with report then it should be rewritten")
-    void rewritesAlreadyExistingFile(@TempDir Path tmpDir) throws IOException {
-        // Given reported address to file
-        Files.writeString(
-                tmpDir.resolve(REST_ADDRESS_FILENAME),
-                new NetworkAddress("localhost", 9999).toString()
-        );
-
-        // When try to write it again but with another port
-        RestAddressReporter reporter = new RestAddressReporter(tmpDir);
-        reporter.writeReport(new NetworkAddress("localhost", 4444), new 
NetworkAddress("localhost", 8443));
-
-        // Then file rewritten
-        String restAddress = 
Files.readString(tmpDir.resolve(REST_ADDRESS_FILENAME));
-        assertThat(restAddress, equalTo("http://localhost:4444, 
https://localhost:8443";));
-    }
-}
diff --git a/packaging/db/zip/linux/ignite3db b/packaging/db/zip/linux/ignite3db
index ba4f26fa23..f23d4d24be 100644
--- a/packaging/db/zip/linux/ignite3db
+++ b/packaging/db/zip/linux/ignite3db
@@ -27,70 +27,13 @@ cd .. # now SCRIPT_DIR points at parent dir for bin
 # if IGNITE_HOME is not set than it will be parent directory for bin
 if [ -z ${IGNITE_HOME+x} ]; then IGNITE_HOME=$(pwd); fi
 
-
 . @CONF_DIR@/@VARS_FILE_NAME@
 . @LIB_DIR@/@BOOTSTRAP_FILE_NAME@
 
 cd ${IGNITE_HOME} || exit
 
-start() {
-  echo "Starting Ignite 3..."
-
-  STARTUP_LOG_FILE="${LOG_DIR}/ignite3db-startup.log"
-
-  CMD="${JAVA_CMD_WITH_ARGS} ${APPLICATION_ARGS}"
-  $CMD >>"${STARTUP_LOG_FILE}" 2>&1 </dev/null & echo $! >${IGNITE_HOME}/pid
-
-  rest_address_file=${WORK_DIR}/rest-address
-  max_attempts=30
-  count=0
-  while [ ! -f "$rest_address_file" ] && [ "$count" -lt "$max_attempts" ]; do
-    sleep 1
-    count=$((count + 1))
-  done
-
- if [ ! -f "$rest_address_file" ]; then
-     echo "Failure: Application did not start within the expected time frame. 
Check out ${STARTUP_LOG_FILE}" >&2
-     exit 1
- else
-     rest_address=$(cat "$rest_address_file")
-     echo "Node named ${NODE_NAME} started successfully. REST addresses are 
[$rest_address]"
- fi
-}
-
-stop() {
-  ignite_pid="$(cat ${IGNITE_HOME}/pid)"
-  kill "$ignite_pid"
-
-  max_attempts=10
-  count=0
-  while ps -p "$ignite_pid" > /dev/null && [ "$count" -lt "$max_attempts" ]; do
-    sleep 10
-    count=$((count + 1))
-  done
-
-  if ps -p "$ignite_pid" > /dev/null; then
-    kill -9 "$ignite_pid"
-  fi
-
-  rm ${WORK_DIR}/rest-address
-}
+CMD="${JAVA_CMD_WITH_ARGS} ${APPLICATION_ARGS}"
+$CMD
 
-case $1 in
-start)
-  start
-  ;;
-stop)
-  stop
-  ;;
-restart)
-  stop
-  start
-  ;;
-*)
-  echo "Unknown command '$1', available commands: start, stop, restart"
-  exit 1
-  ;;
-esac
 
 

Reply via email to