KYLIN-2676 Add UUID into excludes list
Project: http://git-wip-us.apache.org/repos/asf/kylin/repo Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/66dc5418 Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/66dc5418 Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/66dc5418 Branch: refs/heads/master Commit: 66dc5418ce9860103a67398256ee11a7e428d4a0 Parents: ea06950 Author: auphyroc99 <[email protected]> Authored: Fri Jun 16 15:32:33 2017 +0800 Committer: Hongbin Ma <[email protected]> Committed: Mon Jun 19 13:23:47 2017 +0800 ---------------------------------------------------------------------- .../kylin/common/persistence/ResourceTool.java | 40 +++++++++++++++----- 1 file changed, 31 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/kylin/blob/66dc5418/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 6ba68ae..6a73e12 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 @@ -37,6 +37,8 @@ public class ResourceTool { private static String[] excludes = null; private static final Logger logger = LoggerFactory.getLogger(ResourceTool.class); + private static final String[] IMMUTABLE_PREFIX = { "/UUID" }; + public static void main(String[] args) throws IOException { args = StringUtil.filterSystemArgs(args); @@ -52,13 +54,15 @@ public class ResourceTool { String include = System.getProperty("include"); if (include != null) { - setIncludes(include.split("\\s*,\\s*")); + addIncludes(include.split("\\s*,\\s*")); } String exclude = System.getProperty("exclude"); if (exclude != null) { - setExcludes(exclude.split("\\s*,\\s*")); + addExcludes(exclude.split("\\s*,\\s*")); } + addExcludes(IMMUTABLE_PREFIX); + String cmd = args[0]; switch (cmd) { case "reset": @@ -91,16 +95,34 @@ public class ResourceTool { return includes; } - public static void setIncludes(String[] arg) { - includes = arg; + public static void addIncludes(String[] arg) { + if (arg != null) { + if (includes != null) { + String[] nIncludes = new String[includes.length + arg.length]; + System.arraycopy(includes, 0, nIncludes, 0, includes.length); + System.arraycopy(arg, 0, nIncludes, includes.length, arg.length); + includes = nIncludes; + } else { + includes = arg; + } + } } public static String[] getExcludes() { return excludes; } - public static void setExcludes(String[] arg) { - excludes = arg; + public static void addExcludes(String[] arg) { + if (arg != null) { + if (excludes != null) { + String[] nExcludes = new String[excludes.length + arg.length]; + System.arraycopy(excludes, 0, nExcludes, 0, excludes.length); + System.arraycopy(arg, 0, nExcludes, excludes.length, arg.length); + excludes = nExcludes; + } else { + excludes = arg; + } + } } public static String cat(KylinConfig config, String path) throws IOException { @@ -134,16 +156,16 @@ public class ResourceTool { ResourceStore dst = ResourceStore.getStore(dstConfig); logger.info("Copy from {} to {}", src, dst); - + copyR(src, dst, path); } public static void copy(KylinConfig srcConfig, KylinConfig dstConfig, List<String> paths) throws IOException { ResourceStore src = ResourceStore.getStore(srcConfig); ResourceStore dst = ResourceStore.getStore(dstConfig); - + logger.info("Copy from {} to {}", src, dst); - + for (String path : paths) { copyR(src, dst, path); }
