You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@asterixdb.apache.org by mb...@apache.org on 2020/06/19 12:32:26 UTC

[asterixdb] 01/06: [NO ISSUE][MISC] HyracksException.getParams() type, += Throwing helpers

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

mblow pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/asterixdb.git

commit 8ef98896877ee33d0480a916ed070487634f29d7
Author: Michael Blow <mi...@couchbase.com>
AuthorDate: Tue Jun 9 16:48:11 2020 -0400

    [NO ISSUE][MISC] HyracksException.getParams() type, += Throwing helpers
    
    Change-Id: I0aa740452d40719da33bcb25ecec6c09e45c9dd1
    Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/6703
    Integration-Tests: Jenkins <je...@fulliautomatix.ics.uci.edu>
    Tested-by: Jenkins <je...@fulliautomatix.ics.uci.edu>
    Reviewed-by: Ali Alsuliman <al...@gmail.com>
---
 .../asterix/test/runtime/ExecutionTestUtil.java    | 17 +++++++++------
 .../hyracks/api/exceptions/HyracksException.java   |  2 +-
 .../org/apache/hyracks/util/ThrowingFunction.java  | 24 ++++++++++++++++++++++
 .../org/apache/hyracks/util/ThrowingSupplier.java  | 24 ++++++++++++++++++++++
 4 files changed, 60 insertions(+), 7 deletions(-)

diff --git a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/runtime/ExecutionTestUtil.java b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/runtime/ExecutionTestUtil.java
index 4ed36c6..30ebc1d 100644
--- a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/runtime/ExecutionTestUtil.java
+++ b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/runtime/ExecutionTestUtil.java
@@ -19,7 +19,6 @@
 package org.apache.asterix.test.runtime;
 
 import java.io.File;
-import java.nio.file.Paths;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -34,6 +33,7 @@ import org.apache.asterix.testframework.xml.TestSuite;
 import org.apache.commons.lang3.tuple.Pair;
 import org.apache.hyracks.api.config.IOption;
 import org.apache.hyracks.control.nc.NodeControllerService;
+import org.apache.hyracks.util.ThrowingSupplier;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 
@@ -123,8 +123,12 @@ public class ExecutionTestUtil {
             HDFSCluster.getInstance().cleanup();
         }
 
+        saveFailedXml(() -> File.createTempFile("failed", ".xml"));
+    }
+
+    public static void saveFailedXml(ThrowingSupplier<File> destFileSupplier) throws Exception {
         if (FailedGroup != null && FailedGroup.getTestCase().size() > 0) {
-            File temp = File.createTempFile("failed", ".xml");
+            File failedFile = destFileSupplier.get();
             javax.xml.bind.JAXBContext jaxbCtx = null;
             jaxbCtx = javax.xml.bind.JAXBContext.newInstance(TestSuite.class.getPackage().getName());
             javax.xml.bind.Marshaller marshaller = null;
@@ -133,11 +137,12 @@ public class ExecutionTestUtil {
             TestSuite failedSuite = new TestSuite();
             failedSuite.setResultOffsetPath("results");
             failedSuite.setQueryOffsetPath("queries");
+            failedSuite.setQueryFileExtension(".sqlpp");
             failedSuite.getTestGroup().add(FailedGroup);
-            marshaller.marshal(failedSuite, temp);
-            System.err.println("The failed.xml is written to :" + temp.getAbsolutePath()
-                    + ". You can copy it to only.xml by the following cmd:" + "\rcp " + temp.getAbsolutePath() + " "
-                    + Paths.get("./src/test/resources/runtimets/only.xml").toAbsolutePath());
+            marshaller.marshal(failedSuite, failedFile);
+            LOGGER.error("#####");
+            LOGGER.error("##### the failed.xml is written to {}", failedFile.getAbsolutePath());
+            LOGGER.error("#####");
         }
     }
 
diff --git a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/exceptions/HyracksException.java b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/exceptions/HyracksException.java
index 89e46de..46a9b66 100644
--- a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/exceptions/HyracksException.java
+++ b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/exceptions/HyracksException.java
@@ -130,7 +130,7 @@ public class HyracksException extends IOException implements IFormattedException
         return errorCode;
     }
 
-    public Object[] getParams() {
+    public Serializable[] getParams() {
         return params;
     }
 
diff --git a/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/ThrowingFunction.java b/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/ThrowingFunction.java
new file mode 100644
index 0000000..d18b41b
--- /dev/null
+++ b/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/ThrowingFunction.java
@@ -0,0 +1,24 @@
+/*
+ * 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.hyracks.util;
+
+@FunctionalInterface
+public interface ThrowingFunction<I, R> {
+    R process(I input) throws Exception;
+}
diff --git a/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/ThrowingSupplier.java b/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/ThrowingSupplier.java
new file mode 100644
index 0000000..28f5e29
--- /dev/null
+++ b/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/ThrowingSupplier.java
@@ -0,0 +1,24 @@
+/*
+ * 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.hyracks.util;
+
+@FunctionalInterface
+public interface ThrowingSupplier<T> {
+    T get() throws Exception;
+}