Repository: kylin
Updated Branches:
  refs/heads/2.0-rc 183b31a66 -> 22e439272


minor, ResourceTool support -Dinclude option


Project: http://git-wip-us.apache.org/repos/asf/kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/22e43927
Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/22e43927
Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/22e43927

Branch: refs/heads/2.0-rc
Commit: 22e439272970640ae3554561928a95f1ada3cc30
Parents: 183b31a
Author: Li, Yang <yang...@ebay.com>
Authored: Mon Dec 14 17:49:26 2015 +0800
Committer: Li, Yang <yang...@ebay.com>
Committed: Mon Dec 14 17:49:26 2015 +0800

----------------------------------------------------------------------
 .../kylin/common/persistence/ResourceTool.java  | 31 ++++++++++++++------
 1 file changed, 22 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/22e43927/core-common/src/main/java/org/apache/kylin/common/persistence/ResourceTool.java
----------------------------------------------------------------------
diff --git 
a/core-common/src/main/java/org/apache/kylin/common/persistence/ResourceTool.java
 
b/core-common/src/main/java/org/apache/kylin/common/persistence/ResourceTool.java
index 0efea6d..d2801ff 100644
--- 
a/core-common/src/main/java/org/apache/kylin/common/persistence/ResourceTool.java
+++ 
b/core-common/src/main/java/org/apache/kylin/common/persistence/ResourceTool.java
@@ -26,6 +26,7 @@ import org.apache.kylin.common.util.StringUtil;
 
 public class ResourceTool {
 
+    private static String[] includes = null;
     private static String[] excludes = null;
 
     public static void main(String[] args) throws IOException {
@@ -38,6 +39,10 @@ public class ResourceTool {
             return;
         }
 
+        String include = System.getProperty("include");
+        if (include != null) {
+            includes = include.split("\\s*,\\s*");
+        }
         String exclude = System.getProperty("exclude");
         if (exclude != null) {
             excludes = exclude.split("\\s*,\\s*");
@@ -83,7 +88,7 @@ public class ResourceTool {
 
         // case of resource (not a folder)
         if (children == null) {
-            if (matchExclude(path) == false) {
+            if (matchFilter(path)) {
                 RawResource res = src.getResource(path);
                 if (res != null) {
                     dst.putResource(path, res.inputStream, res.timestamp);
@@ -100,14 +105,22 @@ public class ResourceTool {
         }
     }
 
-    private static boolean matchExclude(String path) {
-        if (excludes == null)
-            return false;
-        for (String exclude : excludes) {
-            if (path.startsWith(exclude))
-                return true;
+    private static boolean matchFilter(String path) {
+        if (includes != null) {
+            boolean in = false;
+            for (String include : includes) {
+                in = in || path.startsWith(include);
+            }
+            if (!in)
+                return false;
+        }
+        if (excludes != null) {
+            for (String exclude : excludes) {
+                if (path.startsWith(exclude))
+                    return false;
+            }
         }
-        return false;
+        return true;
     }
 
     public static void reset(KylinConfig config) throws IOException {
@@ -118,7 +131,7 @@ public class ResourceTool {
     private static void resetR(ResourceStore store, String path) throws 
IOException {
         ArrayList<String> children = store.listResources(path);
         if (children == null) { // path is a resource (not a folder)
-            if (matchExclude(path) == false) {
+            if (matchFilter(path) == false) {
                 store.deleteResource(path);
             }
         } else {

Reply via email to