asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mb...@apache.org
Subject asterixdb git commit: Fix ERROR When Running Stop Sample Bat On Windows
Date Fri, 10 Mar 2017 02:15:29 GMT
Repository: asterixdb
Updated Branches:
  refs/heads/master c0785b369 -> 1b288cacf


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
Reviewed-on: https://asterix-gerrit.ics.uci.edu/1565
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
BAD: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Ian Maxon <imaxon@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/asterixdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/asterixdb/commit/1b288cac
Tree: http://git-wip-us.apache.org/repos/asf/asterixdb/tree/1b288cac
Diff: http://git-wip-us.apache.org/repos/asf/asterixdb/diff/1b288cac

Branch: refs/heads/master
Commit: 1b288cacf693da3d67e87846bbecb720c97db01c
Parents: c0785b3
Author: Michael Blow <mblow@apache.org>
Authored: Thu Mar 9 18:58:58 2017 -0500
Committer: Michael Blow <mblow@apache.org>
Committed: Thu Mar 9 18:13:56 2017 -0800

----------------------------------------------------------------------
 .../clienthelper/AsterixHelperExecution.java    |  3 ++
 .../clienthelper/commands/ClientCommand.java    |  3 +-
 .../clienthelper/commands/SleepCommand.java     | 48 ++++++++++++++++++++
 .../main/opt/local/bin/stop-sample-cluster.bat  |  2 +-
 4 files changed, 54 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/asterixdb/blob/1b288cac/asterixdb/asterix-client-helper/src/main/java/org/apache/asterix/clienthelper/AsterixHelperExecution.java
----------------------------------------------------------------------
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.ClientCommand.Command;
 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 @@ public class AsterixHelperExecution {
                 return new ShutdownCommand(args);
             case SHUTDOWN_CLUSTER_ALL:
                 return new ShutdownAllCommand(args);
+            case SLEEP:
+                return new SleepCommand(args);
             default:
                 throw new IllegalStateException("NYI: " + command);
         }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/1b288cac/asterixdb/asterix-client-helper/src/main/java/org/apache/asterix/clienthelper/commands/ClientCommand.java
----------------------------------------------------------------------
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 @@ public abstract class ClientCommand {
         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<>();

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/1b288cac/asterixdb/asterix-client-helper/src/main/java/org/apache/asterix/clienthelper/commands/SleepCommand.java
----------------------------------------------------------------------
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;
+    }
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/1b288cac/asterixdb/asterix-server/src/main/opt/local/bin/stop-sample-cluster.bat
----------------------------------------------------------------------
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 @@ wmic process where ^
 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


Mime
View raw message