[ASTERIXDB-2819][IO] Make absolute & normalize IODevice paths

This improves the issue of not canonicalizing IOManager paths
by at least making them absolute and removing redundant ./ and ../
parts of the path.

Change-Id: Ib71fd775eb8e4b1df548350152a7331316abd5b5
Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/9444
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Michael Blow <mblow@apache.org>
diff --git a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/io/IODeviceHandle.java b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/io/IODeviceHandle.java
index a2d28e1..c826c2f 100644
--- a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/io/IODeviceHandle.java
+++ b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/io/IODeviceHandle.java
@@ -20,6 +20,7 @@
 
 import java.io.File;
 import java.io.Serializable;
+import java.nio.file.Paths;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -80,7 +81,7 @@
     public static List<IODeviceHandle> getDevices(String[] ioDevices) {
         List<IODeviceHandle> devices = new ArrayList<>();
         for (String ioDevice : ioDevices) {
-            String devPath = ioDevice.trim();
+            String devPath = Paths.get(ioDevice.trim()).toAbsolutePath().normalize().toString();
             devices.add(new IODeviceHandle(new File(devPath), "."));
         }
         return devices;
diff --git a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-nc/src/main/java/org/apache/hyracks/control/nc/io/IOManager.java b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-nc/src/main/java/org/apache/hyracks/control/nc/io/IOManager.java
index da78a0d..dee61a4 100644
--- a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-nc/src/main/java/org/apache/hyracks/control/nc/io/IOManager.java
+++ b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-nc/src/main/java/org/apache/hyracks/control/nc/io/IOManager.java
@@ -414,9 +414,9 @@
     }
 
     public IODeviceHandle getDevice(String fullPath) {
-        Path full = Paths.get(fullPath);
+        Path full = Paths.get(fullPath).normalize();
         for (IODeviceHandle d : ioDevices) {
-            if (full.startsWith(Paths.get(d.getMount().getAbsolutePath()))) {
+            if (full.startsWith(Paths.get(d.getMount().getAbsolutePath()).normalize())) {
                 return d;
             }
         }