Michael Blow has uploaded a new change for review. https://asterix-gerrit.ics.uci.edu/1565
Change subject: Fix ERROR When Running Stop Sample Bat On Windows ...................................................................... Fix ERROR When Running Stop Sample Bat On Windows When running stop-sample-cluster.bat from a non-interactive shell on Windows, the following error has been observed: ERROR: Input redirection is not supported, exiting the process immediately Implemented a sleep function in client helper, to workaround the limitations of the Windows TIMEOUT command. Change-Id: Id2a68ec8217690a79b6c49fa670728cf67e81654 --- M asterixdb/asterix-client-helper/src/main/java/org/apache/asterix/clienthelper/AsterixHelperExecution.java M asterixdb/asterix-client-helper/src/main/java/org/apache/asterix/clienthelper/commands/ClientCommand.java A asterixdb/asterix-client-helper/src/main/java/org/apache/asterix/clienthelper/commands/SleepCommand.java M asterixdb/asterix-server/src/main/opt/local/bin/stop-sample-cluster.bat 4 files changed, 54 insertions(+), 2 deletions(-) git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb refs/changes/65/1565/1 diff --git a/asterixdb/asterix-client-helper/src/main/java/org/apache/asterix/clienthelper/AsterixHelperExecution.java b/asterixdb/asterix-client-helper/src/main/java/org/apache/asterix/clienthelper/AsterixHelperExecution.java index 424c1e3..dcb4d24 100644 --- a/asterixdb/asterix-client-helper/src/main/java/org/apache/asterix/clienthelper/AsterixHelperExecution.java +++ b/asterixdb/asterix-client-helper/src/main/java/org/apache/asterix/clienthelper/AsterixHelperExecution.java @@ -26,6 +26,7 @@ import org.apache.asterix.clienthelper.commands.GetClusterStateCommand; import org.apache.asterix.clienthelper.commands.ShutdownAllCommand; import org.apache.asterix.clienthelper.commands.ShutdownCommand; +import org.apache.asterix.clienthelper.commands.SleepCommand; import org.apache.asterix.clienthelper.commands.WaitForClusterCommand; import org.kohsuke.args4j.CmdLineException; import org.kohsuke.args4j.CmdLineParser; @@ -111,6 +112,8 @@ return new ShutdownCommand(args); case SHUTDOWN_CLUSTER_ALL: return new ShutdownAllCommand(args); + case SLEEP: + return new SleepCommand(args); default: throw new IllegalStateException("NYI: " + command); } diff --git a/asterixdb/asterix-client-helper/src/main/java/org/apache/asterix/clienthelper/commands/ClientCommand.java b/asterixdb/asterix-client-helper/src/main/java/org/apache/asterix/clienthelper/commands/ClientCommand.java index 979cd55..e02016c 100644 --- a/asterixdb/asterix-client-helper/src/main/java/org/apache/asterix/clienthelper/commands/ClientCommand.java +++ b/asterixdb/asterix-client-helper/src/main/java/org/apache/asterix/clienthelper/commands/ClientCommand.java @@ -31,7 +31,8 @@ GET_CLUSTER_STATE("Get state of cluster (errorcode 0 = ACTIVE, 1 = DOWN, 2 = UNUSABLE, 3 = OTHER)"), WAIT_FOR_CLUSTER("Wait for cluster to be ready (errorcode 0 = ACTIVE, non-zero = UNKNOWN)"), SHUTDOWN_CLUSTER("Instructs the cluster to shut down, leaving NCService processes intact"), - SHUTDOWN_CLUSTER_ALL("Instructs the cluster to shut down, including NCService processes"); + SHUTDOWN_CLUSTER_ALL("Instructs the cluster to shut down, including NCService processes"), + SLEEP("Sleep for specified -timeout seconds (-timeout must be set and greater than zero)"); private final String usage; private static final Map<String, Command> nameMap = new HashMap<>(); diff --git a/asterixdb/asterix-client-helper/src/main/java/org/apache/asterix/clienthelper/commands/SleepCommand.java b/asterixdb/asterix-client-helper/src/main/java/org/apache/asterix/clienthelper/commands/SleepCommand.java new file mode 100644 index 0000000..a32db7d --- /dev/null +++ b/asterixdb/asterix-client-helper/src/main/java/org/apache/asterix/clienthelper/commands/SleepCommand.java @@ -0,0 +1,48 @@ +/* + * 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.asterix.clienthelper.commands; + +import java.io.IOException; + +import org.apache.asterix.clienthelper.Args; + +public class SleepCommand extends ClientCommand { + + public SleepCommand(Args args) { + super(args); + + } + + @Override + public int execute() throws IOException { + final int timeoutSecs = args.getTimeoutSecs(); + if (timeoutSecs <= 0) { + throw new IllegalArgumentException("-timeout must be specified and greater than zero"); + } + log("sleeping for " + timeoutSecs + " seconds..."); + try { + Thread.sleep(timeoutSecs * 1000L); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new IOException("interrupted during sleep", e); + } + log("done!"); + return 0; + } +} diff --git a/asterixdb/asterix-server/src/main/opt/local/bin/stop-sample-cluster.bat b/asterixdb/asterix-server/src/main/opt/local/bin/stop-sample-cluster.bat index d71c3b4..2531565 100644 --- a/asterixdb/asterix-server/src/main/opt/local/bin/stop-sample-cluster.bat +++ b/asterixdb/asterix-server/src/main/opt/local/bin/stop-sample-cluster.bat @@ -86,7 +86,7 @@ set found= for /F "skip=1" %%P in ('type %tempfile%') DO set found=1 if "%found%" == "1" ( - timeout /T 1 /NOBREAK > nul + call "%INSTALLDIR%\bin\${HELPER_COMMAND}" sleep -timeout 1 -quiet goto :wait_loop ) goto :post_shutdown -- To view, visit https://asterix-gerrit.ics.uci.edu/1565 To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id2a68ec8217690a79b6c49fa670728cf67e81654 Gerrit-PatchSet: 1 Gerrit-Project: asterixdb Gerrit-Branch: master Gerrit-Owner: Michael Blow <mb...@apache.org>