You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2017/05/03 07:22:05 UTC

[27/50] [abbrv] ignite git commit: RESTORE snapshot test with modifications using DirectoryStream API

RESTORE snapshot test with modifications using DirectoryStream API


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/476e8f1e
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/476e8f1e
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/476e8f1e

Branch: refs/heads/ignite-gg-8.0.3.ea6-clients-test
Commit: 476e8f1e19dbaae426b1121a48d0d23043e1babb
Parents: 22b6a9a
Author: Alexandr Kuramshin <ak...@gridgain.com>
Authored: Thu Mar 16 00:34:14 2017 +0700
Committer: Alexandr Kuramshin <ak...@gridgain.com>
Committed: Thu Mar 16 00:34:14 2017 +0700

----------------------------------------------------------------------
 .../ignite/internal/util/lang/GridFunc.java     | 22 ++++++++++++++++++++
 1 file changed, 22 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/476e8f1e/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
old mode 100644
new mode 100755
index 5eb27d3..4ddf615
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
@@ -17,6 +17,10 @@
 
 package org.apache.ignite.internal.util.lang;
 
+import java.io.IOException;
+import java.nio.file.DirectoryStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -41,6 +45,7 @@ import java.util.concurrent.atomic.AtomicLong;
 import java.util.concurrent.atomic.AtomicReference;
 import javax.cache.Cache;
 import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteException;
 import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.compute.ComputeJobResult;
 import org.apache.ignite.internal.IgniteFutureTimeoutCheckedException;
@@ -2313,6 +2318,23 @@ public class GridFunc {
     }
 
     /**
+     * Tests if the given path is a directory and is not {@code null} or empty.
+     *
+     * @param dir Path to test.
+     * @return Whether or not the given path is a directory and is not {@code null} or empty.
+     */
+    public static boolean isEmptyDirectory(Path dir) {
+        if (dir == null || !Files.isDirectory(dir))
+            return false;
+        try (DirectoryStream<Path> files = Files.newDirectoryStream(dir)) {
+            return !files.iterator().hasNext();
+        }
+        catch (IOException e) {
+            throw new IgniteException(e);
+        }
+    }
+
+    /**
      * Converts collection of numbers to primitive {@code int[]} array.
      *
      * @param col Collection of numbers.