You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by sh...@apache.org on 2015/06/19 11:59:38 UTC
incubator-kylin git commit: KYLIN-805 only drop the HTable that
created in this kylin instance
Repository: incubator-kylin
Updated Branches:
refs/heads/0.8 25bdf1676 -> 01b89861e
KYLIN-805 only drop the HTable that created in this kylin instance
Project: http://git-wip-us.apache.org/repos/asf/incubator-kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-kylin/commit/01b89861
Tree: http://git-wip-us.apache.org/repos/asf/incubator-kylin/tree/01b89861
Diff: http://git-wip-us.apache.org/repos/asf/incubator-kylin/diff/01b89861
Branch: refs/heads/0.8
Commit: 01b89861e7601e587276f2925cdf8048a4aac300
Parents: 25bdf16
Author: shaofengshi <sh...@apache.org>
Authored: Fri Jun 19 17:58:50 2015 +0800
Committer: shaofengshi <sh...@apache.org>
Committed: Fri Jun 19 17:58:50 2015 +0800
----------------------------------------------------------------------
.../kylin/job/cube/GarbageCollectionStep.java | 24 +++++++++++++++-----
1 file changed, 18 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/01b89861/job/src/main/java/org/apache/kylin/job/cube/GarbageCollectionStep.java
----------------------------------------------------------------------
diff --git a/job/src/main/java/org/apache/kylin/job/cube/GarbageCollectionStep.java b/job/src/main/java/org/apache/kylin/job/cube/GarbageCollectionStep.java
index eb7d1d3..828df7e 100644
--- a/job/src/main/java/org/apache/kylin/job/cube/GarbageCollectionStep.java
+++ b/job/src/main/java/org/apache/kylin/job/cube/GarbageCollectionStep.java
@@ -22,12 +22,17 @@ import com.google.common.collect.Lists;
import org.apache.commons.lang.StringUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
+import org.apache.hadoop.hbase.HTableDescriptor;
+import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.HBaseAdmin;
+import org.apache.kylin.common.KylinConfig;
+import org.apache.kylin.common.util.Bytes;
import org.apache.kylin.job.cmd.ShellCmdOutput;
import org.apache.kylin.job.exception.ExecuteException;
import org.apache.kylin.job.execution.AbstractExecutable;
import org.apache.kylin.job.execution.ExecutableContext;
import org.apache.kylin.job.execution.ExecuteResult;
+import org.apache.kylin.metadata.realization.IRealizationConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -74,20 +79,27 @@ public class GarbageCollectionStep extends AbstractExecutable {
List<String> oldTables = getOldHTables();
if (oldTables != null && oldTables.size() > 0) {
+ String metadataUrlPrefix = KylinConfig.getInstanceFromEnv().getMetadataUrlPrefix();
Configuration conf = HBaseConfiguration.create();
HBaseAdmin admin = null;
try {
admin = new HBaseAdmin(conf);
for (String table : oldTables) {
if (admin.tableExists(table)) {
- if (admin.isTableEnabled(table)) {
- admin.disableTable(table);
+ HTableDescriptor tableDescriptor = admin.getTableDescriptor(Bytes.toBytes(table));
+ String host = tableDescriptor.getValue(IRealizationConstants.HTableTag);
+ if (metadataUrlPrefix.equalsIgnoreCase(host)) {
+ if (admin.isTableEnabled(table)) {
+ admin.disableTable(table);
+ }
+ admin.deleteTable(table);
+ logger.debug("Dropped htable: " + table);
+ output.append("HBase table " + table + " is dropped. \n");
+ } else {
+ logger.debug("Skip htable: " + table);
+ output.append("Skip htable: " + table + ". \n");
}
-
- admin.deleteTable(table);
}
- logger.debug("Dropped htable: " + table);
- output.append("HBase table " + table + " is dropped. \n");
}
} catch (IOException e) {