You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by li...@apache.org on 2016/11/06 09:30:59 UTC
[23/49] kylin git commit: KYLIN-2141: Add program-friendly interfaces
for ResourceTool
KYLIN-2141: Add program-friendly interfaces for ResourceTool
Signed-off-by: Yang Li <li...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/e8d1e345
Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/e8d1e345
Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/e8d1e345
Branch: refs/heads/KYLIN-1971
Commit: e8d1e345b9ca6715f28451dc00c356224e4864c2
Parents: f8d3f14
Author: Yiming Liu <li...@gmail.com>
Authored: Mon Oct 31 17:45:09 2016 +0800
Committer: Yang Li <li...@apache.org>
Committed: Wed Nov 2 22:04:42 2016 +0800
----------------------------------------------------------------------
.../kylin/common/persistence/ResourceTool.java | 28 +++++++++++++++++---
1 file changed, 24 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/kylin/blob/e8d1e345/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 2f16eb7..2c8bc83 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
@@ -49,11 +49,11 @@ public class ResourceTool {
String include = System.getProperty("include");
if (include != null) {
- includes = include.split("\\s*,\\s*");
+ setIncludes(include.split("\\s*,\\s*"));
}
String exclude = System.getProperty("exclude");
if (exclude != null) {
- excludes = exclude.split("\\s*,\\s*");
+ setExcludes(exclude.split("\\s*,\\s*"));
}
String cmd = args[0];
@@ -84,26 +84,46 @@ public class ResourceTool {
}
}
- public static void cat(KylinConfig config, String path) throws IOException {
+ public static String[] getIncludes() {
+ return includes;
+ }
+
+ public static void setIncludes(String[] arg) {
+ includes = arg;
+ }
+
+ public static String[] getExcludes() {
+ return excludes;
+ }
+
+ public static void setExcludes(String[] arg) {
+ excludes = arg;
+ }
+
+ public static String cat(KylinConfig config, String path) throws IOException {
ResourceStore store = ResourceStore.getStore(config);
InputStream is = store.getResource(path).inputStream;
BufferedReader br = null;
+ StringBuffer sb = new StringBuffer();
String line;
try {
br = new BufferedReader(new InputStreamReader(is));
while ((line = br.readLine()) != null) {
System.out.println(line);
+ sb.append(line).append('\n');
}
} finally {
IOUtils.closeQuietly(is);
IOUtils.closeQuietly(br);
}
+ return sb.toString();
}
- public static void list(KylinConfig config, String path) throws IOException {
+ public static NavigableSet<String> list(KylinConfig config, String path) throws IOException {
ResourceStore store = ResourceStore.getStore(config);
NavigableSet<String> result = store.listResources(path);
System.out.println("" + result);
+ return result;
}
public static void copy(KylinConfig srcConfig, KylinConfig dstConfig, String path) throws IOException {