You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@asterixdb.apache.org by ti...@apache.org on 2016/04/06 07:29:14 UTC

incubator-asterixdb git commit: ASTERIXDB-1356: report file not found

Repository: incubator-asterixdb
Updated Branches:
  refs/heads/master a858684f5 -> 6452d6757


ASTERIXDB-1356: report file not found

Change-Id: Ia12bf84adfd8442103567df42ac22e5750e1360f
Reviewed-on: https://asterix-gerrit.ics.uci.edu/771
Tested-by: Jenkins <je...@fulliautomatix.ics.uci.edu>
Reviewed-by: Murtadha Hubail <hu...@gmail.com>


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

Branch: refs/heads/master
Commit: 6452d67571f1c8eafc3f29b915d0482098903a44
Parents: a858684
Author: Till Westmann <ti...@apache.org>
Authored: Tue Apr 5 21:50:44 2016 -0700
Committer: Till Westmann <ti...@apache.org>
Committed: Tue Apr 5 22:23:31 2016 -0700

----------------------------------------------------------------------
 .../file-not-found/file-not-found.1.ddl.aql     | 29 +++++++++++++++++++
 .../file-not-found/file-not-found.2.update.aql  | 30 ++++++++++++++++++++
 .../src/test/resources/runtimets/testsuite.xml  |  6 ++++
 .../input/stream/LocalFSInputStream.java        |  2 +-
 .../factory/LocalFSInputStreamFactory.java      |  7 +----
 .../external/util/FileSystemWatcher.java        |  4 +++
 .../external/util/LocalFileSystemUtils.java     | 15 +++++-----
 7 files changed, 79 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/6452d675/asterix-app/src/test/resources/runtimets/queries/load/file-not-found/file-not-found.1.ddl.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/queries/load/file-not-found/file-not-found.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/load/file-not-found/file-not-found.1.ddl.aql
new file mode 100644
index 0000000..37a8f14
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/load/file-not-found/file-not-found.1.ddl.aql
@@ -0,0 +1,29 @@
+/*
+ * 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.
+ */
+/**
+ * Test loading from a file that does not exist.
+ * Expected result: fail - File not found.
+ */
+
+drop dataverse broken if exists;
+create dataverse broken;
+use dataverse broken;
+
+create type xtype as closed { id: int32 };
+create dataset X(xtype) primary key id;

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/6452d675/asterix-app/src/test/resources/runtimets/queries/load/file-not-found/file-not-found.2.update.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/queries/load/file-not-found/file-not-found.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/load/file-not-found/file-not-found.2.update.aql
new file mode 100644
index 0000000..c26ffd5
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/load/file-not-found/file-not-found.2.update.aql
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+/**
+ * Test loading from a file that does not exist.
+ * Expected result: fail - File not found.
+ */
+
+use dataverse broken;
+
+load dataset X using localfs(
+  ("path"="asterix_nc1://bla"),
+  ("format"="delimited-text"),
+  ("delimiter"="|")
+);

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/6452d675/asterix-app/src/test/resources/runtimets/testsuite.xml
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/runtimets/testsuite.xml b/asterix-app/src/test/resources/runtimets/testsuite.xml
index e4e12f3..0ce4103 100644
--- a/asterix-app/src/test/resources/runtimets/testsuite.xml
+++ b/asterix-app/src/test/resources/runtimets/testsuite.xml
@@ -6343,6 +6343,12 @@
                 <!-- <expected-error>org.apache.hyracks.api.exceptions.HyracksException</expected-error> -->
             </compilation-unit>
         </test-case>
+        <test-case FilePath="load">
+            <compilation-unit name="file-not-found">
+              <output-dir compare="Text">none</output-dir>
+              <expected-error>org.apache.hyracks.api.exceptions.HyracksDataException: bla: path not found</expected-error>
+            </compilation-unit>
+        </test-case>
         <test-case FilePath="user-defined-functions">
             <compilation-unit name="query-issue244">
                 <output-dir compare="Text">query-issue244</output-dir>

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/6452d675/asterix-external-data/src/main/java/org/apache/asterix/external/input/stream/LocalFSInputStream.java
----------------------------------------------------------------------
diff --git a/asterix-external-data/src/main/java/org/apache/asterix/external/input/stream/LocalFSInputStream.java b/asterix-external-data/src/main/java/org/apache/asterix/external/input/stream/LocalFSInputStream.java
index 2519177..3c3b8fb 100644
--- a/asterix-external-data/src/main/java/org/apache/asterix/external/input/stream/LocalFSInputStream.java
+++ b/asterix-external-data/src/main/java/org/apache/asterix/external/input/stream/LocalFSInputStream.java
@@ -38,7 +38,7 @@ public class LocalFSInputStream extends AsterixInputStream {
     private byte lastByte;
     private File currentFile;
 
-    public LocalFSInputStream(FileSystemWatcher watcher) throws IOException {
+    public LocalFSInputStream(FileSystemWatcher watcher) {
         this.watcher = watcher;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/6452d675/asterix-external-data/src/main/java/org/apache/asterix/external/input/stream/factory/LocalFSInputStreamFactory.java
----------------------------------------------------------------------
diff --git a/asterix-external-data/src/main/java/org/apache/asterix/external/input/stream/factory/LocalFSInputStreamFactory.java b/asterix-external-data/src/main/java/org/apache/asterix/external/input/stream/factory/LocalFSInputStreamFactory.java
index 712ffbe..ae012f3 100644
--- a/asterix-external-data/src/main/java/org/apache/asterix/external/input/stream/factory/LocalFSInputStreamFactory.java
+++ b/asterix-external-data/src/main/java/org/apache/asterix/external/input/stream/factory/LocalFSInputStreamFactory.java
@@ -19,7 +19,6 @@
 package org.apache.asterix.external.input.stream.factory;
 
 import java.io.File;
-import java.io.IOException;
 import java.nio.file.Path;
 import java.util.ArrayList;
 import java.util.Map;
@@ -72,11 +71,7 @@ public class LocalFSInputStreamFactory implements IInputStreamFactory {
             }
             watcher = new FileSystemWatcher(inputResources, expression, isFeed);
         }
-        try {
-            return new LocalFSInputStream(watcher);
-        } catch (IOException e) {
-            throw new HyracksDataException(e);
-        }
+        return new LocalFSInputStream(watcher);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/6452d675/asterix-external-data/src/main/java/org/apache/asterix/external/util/FileSystemWatcher.java
----------------------------------------------------------------------
diff --git a/asterix-external-data/src/main/java/org/apache/asterix/external/util/FileSystemWatcher.java b/asterix-external-data/src/main/java/org/apache/asterix/external/util/FileSystemWatcher.java
index b15d097..ea5cc8f 100644
--- a/asterix-external-data/src/main/java/org/apache/asterix/external/util/FileSystemWatcher.java
+++ b/asterix-external-data/src/main/java/org/apache/asterix/external/util/FileSystemWatcher.java
@@ -93,6 +93,10 @@ public class FileSystemWatcher {
                         register(dirPath);
                     }
                     resume();
+                } else {
+                    if (files.isEmpty()) {
+                        throw new HyracksDataException(path + ": no files found");
+                    }
                 }
             }
         } catch (IOException e) {

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/6452d675/asterix-external-data/src/main/java/org/apache/asterix/external/util/LocalFileSystemUtils.java
----------------------------------------------------------------------
diff --git a/asterix-external-data/src/main/java/org/apache/asterix/external/util/LocalFileSystemUtils.java b/asterix-external-data/src/main/java/org/apache/asterix/external/util/LocalFileSystemUtils.java
index d6e9463..16dd1e9 100644
--- a/asterix-external-data/src/main/java/org/apache/asterix/external/util/LocalFileSystemUtils.java
+++ b/asterix-external-data/src/main/java/org/apache/asterix/external/util/LocalFileSystemUtils.java
@@ -29,19 +29,20 @@ import java.nio.file.attribute.BasicFileAttributes;
 import java.util.LinkedList;
 import java.util.regex.Pattern;
 
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+
 public class LocalFileSystemUtils {
 
-    //TODO: replace this method by FileUtils.iterateFilesAndDirs(.)
     public static void traverse(final LinkedList<File> files, File root, final String expression,
             final LinkedList<Path> dirs) throws IOException {
-        if (!Files.exists(root.toPath())) {
-            return;
+        final Path path = root.toPath();
+        if (!Files.exists(path)) {
+            throw new HyracksDataException(path + ": path not found");
         }
-        if (!Files.isDirectory(root.toPath())) {
-            validateAndAdd(root.toPath(), expression, files);
+        if (!Files.isDirectory(path)) {
+            validateAndAdd(path, expression, files);
         }
-        //FileUtils.iterateFilesAndDirs(directory, fileFilter, dirFilter)
-        Files.walkFileTree(root.toPath(), new SimpleFileVisitor<Path>() {
+        Files.walkFileTree(path, new SimpleFileVisitor<Path>() {
             @Override
             public FileVisitResult preVisitDirectory(Path path, BasicFileAttributes attrs) throws IOException {
                 if (!Files.exists(path, LinkOption.NOFOLLOW_LINKS)) {