You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vk...@apache.org on 2020/12/31 05:11:13 UTC
[ignite-3] 01/03: IGNITE-13936 - Fixed node startup on Windows
This is an automated email from the ASF dual-hosted git repository.
vkulichenko pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/ignite-3.git
commit fbd8740bc3937493ea0c15c5c5154c56071a4df2
Author: Valentin Kulichenko <va...@gmail.com>
AuthorDate: Wed Dec 30 21:08:09 2020 -0800
IGNITE-13936 - Fixed node startup on Windows
---
.../ignite/cli/builtins/node/NodeManager.java | 44 ++++++++--------------
1 file changed, 16 insertions(+), 28 deletions(-)
diff --git a/modules/cli/src/main/java/org/apache/ignite/cli/builtins/node/NodeManager.java b/modules/cli/src/main/java/org/apache/ignite/cli/builtins/node/NodeManager.java
index 3a00310..9c0934d 100644
--- a/modules/cli/src/main/java/org/apache/ignite/cli/builtins/node/NodeManager.java
+++ b/modules/cli/src/main/java/org/apache/ignite/cli/builtins/node/NodeManager.java
@@ -19,18 +19,13 @@ package org.apache.ignite.cli.builtins.node;
import java.io.FileWriter;
import java.io.IOException;
-import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
-import java.nio.file.StandardWatchEventKinds;
-import java.nio.file.WatchEvent;
-import java.nio.file.WatchService;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
-import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.inject.Inject;
@@ -44,7 +39,7 @@ public class NodeManager {
private static final String MAIN_CLASS = "org.apache.ignite.app.IgniteRunner";
private static final Duration NODE_START_TIMEOUT = Duration.ofSeconds(30);
- private static final Duration LOG_FILE_POLL_INTERVAL = Duration.ofMillis(50);
+ private static final Duration LOG_FILE_POLL_INTERVAL = Duration.ofMillis(500);
private final ModuleStorage moduleStorage;
@@ -109,34 +104,27 @@ public class NodeManager {
// TODO: We need more robust way of checking if node successfully run
private static boolean waitForStart(String started, Path file, Duration timeout) throws IOException, InterruptedException {
- try(WatchService watchService = FileSystems.getDefault().newWatchService()) {
- file.getParent().register(watchService, StandardWatchEventKinds.ENTRY_MODIFY);
- var beginTime = System.currentTimeMillis();
- while ((System.currentTimeMillis() - beginTime) < timeout.toMillis()) {
- var key = watchService.poll(LOG_FILE_POLL_INTERVAL.toMillis(), TimeUnit.MILLISECONDS);
- if (key != null) {
- for (WatchEvent<?> event : key.pollEvents()) {
- if (event.kind().equals(StandardWatchEventKinds.ENTRY_MODIFY) &&
- (((WatchEvent<Path>)event).context().getFileName()).equals(file.getFileName())) {
- var content = Files.readString(file);
- if (content.contains(started))
- return true;
- else if (content.contains("Exception"))
- throw new IgniteCLIException("Can't start the node. Read logs for details: " + file);
- }
- }
- key.reset();
- }
- }
- return false;
- }
+ var start = System.currentTimeMillis();
+
+ while ((System.currentTimeMillis() - start) < timeout.toMillis()) {
+ Thread.sleep(LOG_FILE_POLL_INTERVAL.toMillis());
+
+ var content = Files.readString(file);
+
+ if (content.contains(started))
+ return true;
+ else if (content.contains("Exception"))
+ throw new IgniteCLIException("Can't start the node. Read logs for details: " + file);
+ }
+
+ return false;
}
public String classpath() throws IOException {
return moduleStorage.listInstalled().modules.stream()
.flatMap(m -> m.artifacts.stream())
.map(m -> m.toAbsolutePath().toString())
- .collect(Collectors.joining(":"));
+ .collect(Collectors.joining(System.getProperty("path.separator")));
}
public List<String> classpathItems() throws IOException {