You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@kylin.apache.org by GitBox <gi...@apache.org> on 2021/03/16 03:24:32 UTC

[GitHub] [kylin] zhengshengjun opened a new pull request #1611: KYLIN-4923 CubeMigration Tools support migrate meta from 2.x/3.x cluster to 4.0 cluster

zhengshengjun opened a new pull request #1611:
URL: https://github.com/apache/kylin/pull/1611


   …ter to 4.0 cluster
   
   ## Proposed changes
   
   Describe the big picture of your changes here to communicate to the maintainers why we should accept this pull request. If it fixes a bug or resolves a feature request, be sure to link to that issue.
   
   ## Types of changes
   
   What types of changes does your code introduce to Kylin?
   _Put an `x` in the boxes that apply_
   
   - [ ] Bugfix (non-breaking change which fixes an issue)
   - [x] New feature (non-breaking change which adds functionality)
   - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
   - [ ] Documentation Update (if none of the other choices apply)
   
   ## Checklist
   
   _Put an `x` in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code._
   
   - [x] I have create an issue on [Kylin's jira](https://issues.apache.org/jira/browse/KYLIN), and have described the bug/feature there in detail
   - [x] Commit messages in my PR start with the related jira ID, like "KYLIN-0000 Make Kylin project open-source"
   - [x] Compiling and unit tests pass locally with my changes
   - [ ] I have added tests that prove my fix is effective or that my feature works
   - [x] If this change need a document change, I will prepare another pr against the `document` branch
   - [x] Any dependent changes have been merged
   
   ## Further comments
   
   If this is a relatively large or complex change, kick off the discussion at user@kylin or dev@kylin by explaining why you chose the solution you did and what alternatives you considered, etc...
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kylin] zhangayqian commented on pull request #1611: KYLIN-4923 CubeMigration Tools support migrate meta from 2.x/3.x cluster to 4.0 cluster

Posted by GitBox <gi...@apache.org>.
zhangayqian commented on pull request #1611:
URL: https://github.com/apache/kylin/pull/1611#issuecomment-818395907


   LGTM and test passed.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kylin] hit-lacus commented on a change in pull request #1611: KYLIN-4923 CubeMigration Tools support migrate meta from 2.x/3.x cluster to 4.0 cluster

Posted by GitBox <gi...@apache.org>.
hit-lacus commented on a change in pull request #1611:
URL: https://github.com/apache/kylin/pull/1611#discussion_r596003733



##########
File path: build/bin/kylin.sh
##########
@@ -143,9 +143,9 @@ function retrieveDependency() {
 
     # compose hadoop_dependencies
     hadoop_dependencies=${hadoop_dependencies}:`hadoop classpath`
-#    if [ -n "${hbase_dependency}" ]; then
-#        hadoop_dependencies=${hadoop_dependencies}:${hbase_dependency}
-#    fi
+    if [ -n "${hbase_dependency}" ]; then

Review comment:
       From my side, I would like to remove HBase related jars in the future. So, I find it will break the this CubeMigrationTool .




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kylin] zhengshengjun commented on pull request #1611: KYLIN-4923 CubeMigration Tools support migrate meta from 2.x/3.x cluster to 4.0 cluster

Posted by GitBox <gi...@apache.org>.
zhengshengjun commented on pull request #1611:
URL: https://github.com/apache/kylin/pull/1611#issuecomment-813784359


   I have removed HBase dependency. We can migrate meta from 2.x/3.x to 4.x by two steps:
   1. use  "metastore.sh backup"  to export 2.x/3.x metadata to local dir
   2. then use "CubeMigration -srcConfig ${exported_meta_dir} -dstConfig v4/kylin.properties ... " to migrate exported metadata to new cluster


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kylin] lgtm-com[bot] commented on pull request #1611: KYLIN-4923 CubeMigration Tools support migrate meta from 2.x/3.x cluster to 4.0 cluster

Posted by GitBox <gi...@apache.org>.
lgtm-com[bot] commented on pull request #1611:
URL: https://github.com/apache/kylin/pull/1611#issuecomment-818399497


   This pull request **introduces 3 alerts** when merging dd6d796a036bea0fe8eb2825deacecece2c31283 into 6153889ce1b1fad2c409364e77ec471166654551 - [view on LGTM.com](https://lgtm.com/projects/g/apache/kylin/rev/pr-79984c1a2c7bb2ce6fd52e695ac0943e68e14530)
   
   **new alerts:**
   
   * 3 for Dereferenced variable may be null


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kylin] zhengshengjun commented on pull request #1611: KYLIN-4923 CubeMigration Tools support migrate meta from 2.x/3.x cluster to 4.0 cluster

Posted by GitBox <gi...@apache.org>.
zhengshengjun commented on pull request #1611:
URL: https://github.com/apache/kylin/pull/1611#issuecomment-824102590


   Added document in: https://cwiki.apache.org/confluence/display/KYLIN/How+to+migrate+metadata+to+Kylin+4


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kylin] zhengshengjun commented on a change in pull request #1611: KYLIN-4923 CubeMigration Tools support migrate meta from 2.x/3.x cluster to 4.0 cluster

Posted by GitBox <gi...@apache.org>.
zhengshengjun commented on a change in pull request #1611:
URL: https://github.com/apache/kylin/pull/1611#discussion_r610687020



##########
File path: tool/src/main/java/org/apache/kylin/tool/CubeMigrationCLI.java
##########
@@ -86,82 +98,113 @@
     protected String dstProject;
     protected String srcHdfsWorkDir;
     protected String dstHdfsWorkDir;
+    private boolean migrateSegment;
+    private boolean realExecute;
+    private boolean purgeAndDisable;
+    private OptionsHelper optHelper;
 
     private static final String ACL_PREFIX = "/acl/";
     private static final String GLOBAL_DICT_PREFIX = "/dict/global_dict/";
 
-    public static void main(String[] args) throws IOException, InterruptedException {
+    private static final Option OPTION_SRC_CONFIG = OptionBuilder.isRequired(true).hasArg().withDescription("The KylinConfig of the cube’s source").create("srcConfig");
+    private static final Option OPTION_DST_CONFIG = OptionBuilder.isRequired(true).hasArg().withDescription("The KylinConfig of the cube’s new home").create("dstConfig");
+    private static final Option OPTION_ALL_CUBES = OptionBuilder.isRequired(false).withDescription("migrate all cubes meta from source cluster").create("allCubes");
+    private static final Option OPTION_CUBE = OptionBuilder.isRequired(false).hasArg().withDescription("Cube name to migrate").create("cube");
+    private static final Option OPTION_DST_PROJECT = OptionBuilder.isRequired(false).hasArg().withDescription("cube's new project home, if not set, keep the same as source cluster").create("dstProject");
+    private static final Option OPTION_SRC_PROJECT = OptionBuilder.isRequired(false).hasArg().withDescription("source project to migrate").create("srcProject");
+    private static final Option OPTION_COPY_ACL = OptionBuilder.isRequired(false).hasArg().withDescription("copy ACL").create("copyAcl");
+    private static final Option OPTION_PURGE_AND_DISABLE = OptionBuilder.isRequired(false).withDescription("purge source cluster data").create("purgeAndDisable");
+    private static final Option OPTION_OVERWRITE = OptionBuilder.isRequired(false).withDescription("overwrite target cluster's meta if exists").create("overwriteIfExists");
+    private static final Option OPTION_EXECUTE = OptionBuilder.isRequired(false).withDescription("execute migration").create("execute");
+    private static final Option OPTION_MIGRATE_SEGMENTS = OptionBuilder.isRequired(false).withDescription("migrate segment data").create("migrateSegment");

Review comment:
       It would be nice if we add this validation for users. By the way, what about deciding automatically by comparing cube's major version and system's major version before "doMigrateSegment"?

##########
File path: tool/src/main/java/org/apache/kylin/tool/CubeMigrationCLI.java
##########
@@ -86,82 +98,113 @@
     protected String dstProject;
     protected String srcHdfsWorkDir;
     protected String dstHdfsWorkDir;
+    private boolean migrateSegment;
+    private boolean realExecute;
+    private boolean purgeAndDisable;
+    private OptionsHelper optHelper;
 
     private static final String ACL_PREFIX = "/acl/";
     private static final String GLOBAL_DICT_PREFIX = "/dict/global_dict/";
 
-    public static void main(String[] args) throws IOException, InterruptedException {
+    private static final Option OPTION_SRC_CONFIG = OptionBuilder.isRequired(true).hasArg().withDescription("The KylinConfig of the cube’s source").create("srcConfig");
+    private static final Option OPTION_DST_CONFIG = OptionBuilder.isRequired(true).hasArg().withDescription("The KylinConfig of the cube’s new home").create("dstConfig");
+    private static final Option OPTION_ALL_CUBES = OptionBuilder.isRequired(false).withDescription("migrate all cubes meta from source cluster").create("allCubes");
+    private static final Option OPTION_CUBE = OptionBuilder.isRequired(false).hasArg().withDescription("Cube name to migrate").create("cube");
+    private static final Option OPTION_DST_PROJECT = OptionBuilder.isRequired(false).hasArg().withDescription("cube's new project home, if not set, keep the same as source cluster").create("dstProject");
+    private static final Option OPTION_SRC_PROJECT = OptionBuilder.isRequired(false).hasArg().withDescription("source project to migrate").create("srcProject");
+    private static final Option OPTION_COPY_ACL = OptionBuilder.isRequired(false).hasArg().withDescription("copy ACL").create("copyAcl");
+    private static final Option OPTION_PURGE_AND_DISABLE = OptionBuilder.isRequired(false).withDescription("purge source cluster data").create("purgeAndDisable");
+    private static final Option OPTION_OVERWRITE = OptionBuilder.isRequired(false).withDescription("overwrite target cluster's meta if exists").create("overwriteIfExists");
+    private static final Option OPTION_EXECUTE = OptionBuilder.isRequired(false).withDescription("execute migration").create("execute");

Review comment:
       good suggestion !

##########
File path: tool/src/main/java/org/apache/kylin/tool/CubeMigrationCLI.java
##########
@@ -86,82 +98,113 @@
     protected String dstProject;
     protected String srcHdfsWorkDir;
     protected String dstHdfsWorkDir;
+    private boolean migrateSegment;
+    private boolean realExecute;
+    private boolean purgeAndDisable;
+    private OptionsHelper optHelper;
 
     private static final String ACL_PREFIX = "/acl/";
     private static final String GLOBAL_DICT_PREFIX = "/dict/global_dict/";
 
-    public static void main(String[] args) throws IOException, InterruptedException {
+    private static final Option OPTION_SRC_CONFIG = OptionBuilder.isRequired(true).hasArg().withDescription("The KylinConfig of the cube’s source").create("srcConfig");
+    private static final Option OPTION_DST_CONFIG = OptionBuilder.isRequired(true).hasArg().withDescription("The KylinConfig of the cube’s new home").create("dstConfig");
+    private static final Option OPTION_ALL_CUBES = OptionBuilder.isRequired(false).withDescription("migrate all cubes meta from source cluster").create("allCubes");
+    private static final Option OPTION_CUBE = OptionBuilder.isRequired(false).hasArg().withDescription("Cube name to migrate").create("cube");
+    private static final Option OPTION_DST_PROJECT = OptionBuilder.isRequired(false).hasArg().withDescription("cube's new project home, if not set, keep the same as source cluster").create("dstProject");
+    private static final Option OPTION_SRC_PROJECT = OptionBuilder.isRequired(false).hasArg().withDescription("source project to migrate").create("srcProject");
+    private static final Option OPTION_COPY_ACL = OptionBuilder.isRequired(false).hasArg().withDescription("copy ACL").create("copyAcl");
+    private static final Option OPTION_PURGE_AND_DISABLE = OptionBuilder.isRequired(false).withDescription("purge source cluster data").create("purgeAndDisable");
+    private static final Option OPTION_OVERWRITE = OptionBuilder.isRequired(false).withDescription("overwrite target cluster's meta if exists").create("overwriteIfExists");
+    private static final Option OPTION_EXECUTE = OptionBuilder.isRequired(false).withDescription("execute migration").create("execute");
+    private static final Option OPTION_MIGRATE_SEGMENTS = OptionBuilder.isRequired(false).withDescription("migrate segment data").create("migrateSegment");
+
+    public static void main(String[] args) throws Exception {
+        CubeMigrationCLI cli = new CubeMigrationCLI();
+        cli.init(args);
+        cli.moveCube();
+    }
 
+    public void init(String[] args) {
+        optHelper = new OptionsHelper();
         CubeMigrationCLI cli = new CubeMigrationCLI();
-        if (args.length != 8 && args.length != 9) {
-            cli.usage();
+        try {
+            optHelper.parseOptions(cli.getOptions(), args);
+        } catch (Exception e) {
+            logger.error("failed to parse arguments", e);
+            optHelper.printUsage("CubeMigrationCLI", cli.getOptions());
             System.exit(1);
         }
-        if (args.length == 8) {
-            cli.moveCube(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]);
-        } else if (args.length == 9) {
-            cli.moveCube(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8]);
-        }
+        doAclCopy = optHelper.hasOption(OPTION_COPY_ACL);
+        doOverwrite = optHelper.hasOption(OPTION_OVERWRITE);
+        doMigrateSegment = optHelper.hasOption(OPTION_MIGRATE_SEGMENTS);
+        purgeAndDisable = optHelper.hasOption(OPTION_PURGE_AND_DISABLE);
+        srcConfig = KylinConfig.createInstanceFromUri(optHelper.getOptionValue(OPTION_SRC_CONFIG));
+        srcStore = ResourceStore.getStore(srcConfig);
+        dstConfig = KylinConfig.createInstanceFromUri(optHelper.getOptionValue(OPTION_DST_CONFIG));
+        dstStore = ResourceStore.getStore(dstConfig);
+        migrateSegment = optHelper.hasOption(OPTION_MIGRATE_SEGMENTS);

Review comment:
       it's redundant, thank you for finding it out




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kylin] zhangayqian commented on a change in pull request #1611: KYLIN-4923 CubeMigration Tools support migrate meta from 2.x/3.x cluster to 4.0 cluster

Posted by GitBox <gi...@apache.org>.
zhangayqian commented on a change in pull request #1611:
URL: https://github.com/apache/kylin/pull/1611#discussion_r610474387



##########
File path: tool/src/main/java/org/apache/kylin/tool/CubeMigrationCLI.java
##########
@@ -86,82 +98,113 @@
     protected String dstProject;
     protected String srcHdfsWorkDir;
     protected String dstHdfsWorkDir;
+    private boolean migrateSegment;
+    private boolean realExecute;
+    private boolean purgeAndDisable;
+    private OptionsHelper optHelper;
 
     private static final String ACL_PREFIX = "/acl/";
     private static final String GLOBAL_DICT_PREFIX = "/dict/global_dict/";
 
-    public static void main(String[] args) throws IOException, InterruptedException {
+    private static final Option OPTION_SRC_CONFIG = OptionBuilder.isRequired(true).hasArg().withDescription("The KylinConfig of the cube’s source").create("srcConfig");
+    private static final Option OPTION_DST_CONFIG = OptionBuilder.isRequired(true).hasArg().withDescription("The KylinConfig of the cube’s new home").create("dstConfig");
+    private static final Option OPTION_ALL_CUBES = OptionBuilder.isRequired(false).withDescription("migrate all cubes meta from source cluster").create("allCubes");
+    private static final Option OPTION_CUBE = OptionBuilder.isRequired(false).hasArg().withDescription("Cube name to migrate").create("cube");
+    private static final Option OPTION_DST_PROJECT = OptionBuilder.isRequired(false).hasArg().withDescription("cube's new project home, if not set, keep the same as source cluster").create("dstProject");
+    private static final Option OPTION_SRC_PROJECT = OptionBuilder.isRequired(false).hasArg().withDescription("source project to migrate").create("srcProject");
+    private static final Option OPTION_COPY_ACL = OptionBuilder.isRequired(false).hasArg().withDescription("copy ACL").create("copyAcl");
+    private static final Option OPTION_PURGE_AND_DISABLE = OptionBuilder.isRequired(false).withDescription("purge source cluster data").create("purgeAndDisable");
+    private static final Option OPTION_OVERWRITE = OptionBuilder.isRequired(false).withDescription("overwrite target cluster's meta if exists").create("overwriteIfExists");
+    private static final Option OPTION_EXECUTE = OptionBuilder.isRequired(false).withDescription("execute migration").create("execute");

Review comment:
       Maybe the parameter `execute ` should be called `realMigrate`, so that users can better to  understand the meaning of this parameter. And its default value can be set to `true`.

##########
File path: tool/src/main/java/org/apache/kylin/tool/CubeMigrationCLI.java
##########
@@ -86,82 +98,113 @@
     protected String dstProject;
     protected String srcHdfsWorkDir;
     protected String dstHdfsWorkDir;
+    private boolean migrateSegment;
+    private boolean realExecute;
+    private boolean purgeAndDisable;
+    private OptionsHelper optHelper;
 
     private static final String ACL_PREFIX = "/acl/";
     private static final String GLOBAL_DICT_PREFIX = "/dict/global_dict/";
 
-    public static void main(String[] args) throws IOException, InterruptedException {
+    private static final Option OPTION_SRC_CONFIG = OptionBuilder.isRequired(true).hasArg().withDescription("The KylinConfig of the cube’s source").create("srcConfig");
+    private static final Option OPTION_DST_CONFIG = OptionBuilder.isRequired(true).hasArg().withDescription("The KylinConfig of the cube’s new home").create("dstConfig");
+    private static final Option OPTION_ALL_CUBES = OptionBuilder.isRequired(false).withDescription("migrate all cubes meta from source cluster").create("allCubes");
+    private static final Option OPTION_CUBE = OptionBuilder.isRequired(false).hasArg().withDescription("Cube name to migrate").create("cube");
+    private static final Option OPTION_DST_PROJECT = OptionBuilder.isRequired(false).hasArg().withDescription("cube's new project home, if not set, keep the same as source cluster").create("dstProject");
+    private static final Option OPTION_SRC_PROJECT = OptionBuilder.isRequired(false).hasArg().withDescription("source project to migrate").create("srcProject");
+    private static final Option OPTION_COPY_ACL = OptionBuilder.isRequired(false).hasArg().withDescription("copy ACL").create("copyAcl");
+    private static final Option OPTION_PURGE_AND_DISABLE = OptionBuilder.isRequired(false).withDescription("purge source cluster data").create("purgeAndDisable");
+    private static final Option OPTION_OVERWRITE = OptionBuilder.isRequired(false).withDescription("overwrite target cluster's meta if exists").create("overwriteIfExists");
+    private static final Option OPTION_EXECUTE = OptionBuilder.isRequired(false).withDescription("execute migration").create("execute");
+    private static final Option OPTION_MIGRATE_SEGMENTS = OptionBuilder.isRequired(false).withDescription("migrate segment data").create("migrateSegment");
+
+    public static void main(String[] args) throws Exception {
+        CubeMigrationCLI cli = new CubeMigrationCLI();
+        cli.init(args);
+        cli.moveCube();
+    }
 
+    public void init(String[] args) {
+        optHelper = new OptionsHelper();
         CubeMigrationCLI cli = new CubeMigrationCLI();
-        if (args.length != 8 && args.length != 9) {
-            cli.usage();
+        try {
+            optHelper.parseOptions(cli.getOptions(), args);
+        } catch (Exception e) {
+            logger.error("failed to parse arguments", e);
+            optHelper.printUsage("CubeMigrationCLI", cli.getOptions());
             System.exit(1);
         }
-        if (args.length == 8) {
-            cli.moveCube(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]);
-        } else if (args.length == 9) {
-            cli.moveCube(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8]);
-        }
+        doAclCopy = optHelper.hasOption(OPTION_COPY_ACL);
+        doOverwrite = optHelper.hasOption(OPTION_OVERWRITE);
+        doMigrateSegment = optHelper.hasOption(OPTION_MIGRATE_SEGMENTS);
+        purgeAndDisable = optHelper.hasOption(OPTION_PURGE_AND_DISABLE);
+        srcConfig = KylinConfig.createInstanceFromUri(optHelper.getOptionValue(OPTION_SRC_CONFIG));
+        srcStore = ResourceStore.getStore(srcConfig);
+        dstConfig = KylinConfig.createInstanceFromUri(optHelper.getOptionValue(OPTION_DST_CONFIG));
+        dstStore = ResourceStore.getStore(dstConfig);
+        migrateSegment = optHelper.hasOption(OPTION_MIGRATE_SEGMENTS);

Review comment:
       What is the difference between `migrateSegment ` and `doMigrateSegment `?

##########
File path: tool/src/main/java/org/apache/kylin/tool/CubeMigrationCLI.java
##########
@@ -86,82 +98,113 @@
     protected String dstProject;
     protected String srcHdfsWorkDir;
     protected String dstHdfsWorkDir;
+    private boolean migrateSegment;
+    private boolean realExecute;
+    private boolean purgeAndDisable;
+    private OptionsHelper optHelper;
 
     private static final String ACL_PREFIX = "/acl/";
     private static final String GLOBAL_DICT_PREFIX = "/dict/global_dict/";
 
-    public static void main(String[] args) throws IOException, InterruptedException {
+    private static final Option OPTION_SRC_CONFIG = OptionBuilder.isRequired(true).hasArg().withDescription("The KylinConfig of the cube’s source").create("srcConfig");
+    private static final Option OPTION_DST_CONFIG = OptionBuilder.isRequired(true).hasArg().withDescription("The KylinConfig of the cube’s new home").create("dstConfig");
+    private static final Option OPTION_ALL_CUBES = OptionBuilder.isRequired(false).withDescription("migrate all cubes meta from source cluster").create("allCubes");
+    private static final Option OPTION_CUBE = OptionBuilder.isRequired(false).hasArg().withDescription("Cube name to migrate").create("cube");
+    private static final Option OPTION_DST_PROJECT = OptionBuilder.isRequired(false).hasArg().withDescription("cube's new project home, if not set, keep the same as source cluster").create("dstProject");
+    private static final Option OPTION_SRC_PROJECT = OptionBuilder.isRequired(false).hasArg().withDescription("source project to migrate").create("srcProject");
+    private static final Option OPTION_COPY_ACL = OptionBuilder.isRequired(false).hasArg().withDescription("copy ACL").create("copyAcl");
+    private static final Option OPTION_PURGE_AND_DISABLE = OptionBuilder.isRequired(false).withDescription("purge source cluster data").create("purgeAndDisable");
+    private static final Option OPTION_OVERWRITE = OptionBuilder.isRequired(false).withDescription("overwrite target cluster's meta if exists").create("overwriteIfExists");
+    private static final Option OPTION_EXECUTE = OptionBuilder.isRequired(false).withDescription("execute migration").create("execute");
+    private static final Option OPTION_MIGRATE_SEGMENTS = OptionBuilder.isRequired(false).withDescription("migrate segment data").create("migrateSegment");

Review comment:
       In addition to being used as a metadata upgrade tool,  CubeMigrationCLI may also be used for metadata migration between different clusters of the same version. 
   Therefore, a parameter should be added to determine whether the user is upgrading kylin 2/3 metadata to kylin 4.0.  It can be called `upgradeMeta`. When `upgradeMeta` is set to `true`, then parameter `doMigrateSegment` cannot be set to `true`.

##########
File path: tool/src/main/java/org/apache/kylin/tool/CubeMigrationCLI.java
##########
@@ -86,82 +98,113 @@
     protected String dstProject;
     protected String srcHdfsWorkDir;
     protected String dstHdfsWorkDir;
+    private boolean migrateSegment;
+    private boolean realExecute;
+    private boolean purgeAndDisable;
+    private OptionsHelper optHelper;
 
     private static final String ACL_PREFIX = "/acl/";
     private static final String GLOBAL_DICT_PREFIX = "/dict/global_dict/";
 
-    public static void main(String[] args) throws IOException, InterruptedException {
+    private static final Option OPTION_SRC_CONFIG = OptionBuilder.isRequired(true).hasArg().withDescription("The KylinConfig of the cube’s source").create("srcConfig");
+    private static final Option OPTION_DST_CONFIG = OptionBuilder.isRequired(true).hasArg().withDescription("The KylinConfig of the cube’s new home").create("dstConfig");
+    private static final Option OPTION_ALL_CUBES = OptionBuilder.isRequired(false).withDescription("migrate all cubes meta from source cluster").create("allCubes");
+    private static final Option OPTION_CUBE = OptionBuilder.isRequired(false).hasArg().withDescription("Cube name to migrate").create("cube");
+    private static final Option OPTION_DST_PROJECT = OptionBuilder.isRequired(false).hasArg().withDescription("cube's new project home, if not set, keep the same as source cluster").create("dstProject");
+    private static final Option OPTION_SRC_PROJECT = OptionBuilder.isRequired(false).hasArg().withDescription("source project to migrate").create("srcProject");
+    private static final Option OPTION_COPY_ACL = OptionBuilder.isRequired(false).hasArg().withDescription("copy ACL").create("copyAcl");
+    private static final Option OPTION_PURGE_AND_DISABLE = OptionBuilder.isRequired(false).withDescription("purge source cluster data").create("purgeAndDisable");
+    private static final Option OPTION_OVERWRITE = OptionBuilder.isRequired(false).withDescription("overwrite target cluster's meta if exists").create("overwriteIfExists");
+    private static final Option OPTION_EXECUTE = OptionBuilder.isRequired(false).withDescription("execute migration").create("execute");
+    private static final Option OPTION_MIGRATE_SEGMENTS = OptionBuilder.isRequired(false).withDescription("migrate segment data").create("migrateSegment");
+
+    public static void main(String[] args) throws Exception {
+        CubeMigrationCLI cli = new CubeMigrationCLI();
+        cli.init(args);
+        cli.moveCube();
+    }
 
+    public void init(String[] args) {
+        optHelper = new OptionsHelper();
         CubeMigrationCLI cli = new CubeMigrationCLI();
-        if (args.length != 8 && args.length != 9) {
-            cli.usage();
+        try {
+            optHelper.parseOptions(cli.getOptions(), args);
+        } catch (Exception e) {
+            logger.error("failed to parse arguments", e);
+            optHelper.printUsage("CubeMigrationCLI", cli.getOptions());
             System.exit(1);
         }
-        if (args.length == 8) {
-            cli.moveCube(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]);
-        } else if (args.length == 9) {
-            cli.moveCube(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8]);
-        }
+        doAclCopy = optHelper.hasOption(OPTION_COPY_ACL);
+        doOverwrite = optHelper.hasOption(OPTION_OVERWRITE);
+        doMigrateSegment = optHelper.hasOption(OPTION_MIGRATE_SEGMENTS);
+        purgeAndDisable = optHelper.hasOption(OPTION_PURGE_AND_DISABLE);
+        srcConfig = KylinConfig.createInstanceFromUri(optHelper.getOptionValue(OPTION_SRC_CONFIG));
+        srcStore = ResourceStore.getStore(srcConfig);
+        dstConfig = KylinConfig.createInstanceFromUri(optHelper.getOptionValue(OPTION_DST_CONFIG));
+        dstStore = ResourceStore.getStore(dstConfig);
+        migrateSegment = optHelper.hasOption(OPTION_MIGRATE_SEGMENTS);
+        realExecute = optHelper.hasOption(OPTION_EXECUTE);
+        dstProject = optHelper.getOptionValue(OPTION_DST_PROJECT);
+        conf = HadoopUtil.getCurrentConfiguration();
     }
 
-    protected void usage() {
-        System.out.println(
-                "Usage: CubeMigrationCLI srcKylinConfigUri dstKylinConfigUri cubeName projectName copyAclOrNot purgeOrNot overwriteIfExists realExecute migrateSegmentOrNot");
-        System.out.println("srcKylinConfigUri: The KylinConfig of the cube’s source \n"
-                + "dstKylinConfigUri: The KylinConfig of the cube’s new home \n"
-                + "cubeName: the name of cube to be migrated. \n"
-                + "projectName: The target project in the target environment.(Make sure it exist) \n"
-                + "copyAclOrNot: true or false: whether copy cube ACL to target environment. \n"
-                + "purgeOrNot: true or false: whether purge the cube from src server after the migration. \n"
-                + "overwriteIfExists: overwrite cube if it already exists in the target environment. \n"
-                + "realExecute: if false, just print the operations to take, if true, do the real migration. \n"
-                + "migrateSegmentOrNot:(optional) true or false: whether copy segment data to target environment. \n");
-
-    }
+    public void moveCube() throws Exception {
+        conf = HadoopUtil.getCurrentConfiguration();
 
-    public void moveCube(String srcCfgUri, String dstCfgUri, String cubeName, String projectName, String copyAcl,
-                         String purgeAndDisable, String overwriteIfExists, String realExecute)
-            throws IOException, InterruptedException {
+        if (optHelper.hasOption(OPTION_CUBE)) {
+            CubeManager cubeManager = CubeManager.getInstance(srcConfig);
+            moveSingleCube(optHelper.getOptionValue(OPTION_CUBE), dstProject, cubeManager);

Review comment:
       `dstProject ` here may be`null` and may not have been created in dstKylin.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kylin] zhengshengjun commented on a change in pull request #1611: KYLIN-4923 CubeMigration Tools support migrate meta from 2.x/3.x cluster to 4.0 cluster

Posted by GitBox <gi...@apache.org>.
zhengshengjun commented on a change in pull request #1611:
URL: https://github.com/apache/kylin/pull/1611#discussion_r610686888



##########
File path: tool/src/main/java/org/apache/kylin/tool/CubeMigrationCLI.java
##########
@@ -86,82 +98,113 @@
     protected String dstProject;
     protected String srcHdfsWorkDir;
     protected String dstHdfsWorkDir;
+    private boolean migrateSegment;
+    private boolean realExecute;
+    private boolean purgeAndDisable;
+    private OptionsHelper optHelper;
 
     private static final String ACL_PREFIX = "/acl/";
     private static final String GLOBAL_DICT_PREFIX = "/dict/global_dict/";
 
-    public static void main(String[] args) throws IOException, InterruptedException {
+    private static final Option OPTION_SRC_CONFIG = OptionBuilder.isRequired(true).hasArg().withDescription("The KylinConfig of the cube’s source").create("srcConfig");
+    private static final Option OPTION_DST_CONFIG = OptionBuilder.isRequired(true).hasArg().withDescription("The KylinConfig of the cube’s new home").create("dstConfig");
+    private static final Option OPTION_ALL_CUBES = OptionBuilder.isRequired(false).withDescription("migrate all cubes meta from source cluster").create("allCubes");
+    private static final Option OPTION_CUBE = OptionBuilder.isRequired(false).hasArg().withDescription("Cube name to migrate").create("cube");
+    private static final Option OPTION_DST_PROJECT = OptionBuilder.isRequired(false).hasArg().withDescription("cube's new project home, if not set, keep the same as source cluster").create("dstProject");
+    private static final Option OPTION_SRC_PROJECT = OptionBuilder.isRequired(false).hasArg().withDescription("source project to migrate").create("srcProject");
+    private static final Option OPTION_COPY_ACL = OptionBuilder.isRequired(false).hasArg().withDescription("copy ACL").create("copyAcl");
+    private static final Option OPTION_PURGE_AND_DISABLE = OptionBuilder.isRequired(false).withDescription("purge source cluster data").create("purgeAndDisable");
+    private static final Option OPTION_OVERWRITE = OptionBuilder.isRequired(false).withDescription("overwrite target cluster's meta if exists").create("overwriteIfExists");
+    private static final Option OPTION_EXECUTE = OptionBuilder.isRequired(false).withDescription("execute migration").create("execute");
+    private static final Option OPTION_MIGRATE_SEGMENTS = OptionBuilder.isRequired(false).withDescription("migrate segment data").create("migrateSegment");
+
+    public static void main(String[] args) throws Exception {
+        CubeMigrationCLI cli = new CubeMigrationCLI();
+        cli.init(args);
+        cli.moveCube();
+    }
 
+    public void init(String[] args) {
+        optHelper = new OptionsHelper();
         CubeMigrationCLI cli = new CubeMigrationCLI();
-        if (args.length != 8 && args.length != 9) {
-            cli.usage();
+        try {
+            optHelper.parseOptions(cli.getOptions(), args);
+        } catch (Exception e) {
+            logger.error("failed to parse arguments", e);
+            optHelper.printUsage("CubeMigrationCLI", cli.getOptions());
             System.exit(1);
         }
-        if (args.length == 8) {
-            cli.moveCube(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]);
-        } else if (args.length == 9) {
-            cli.moveCube(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8]);
-        }
+        doAclCopy = optHelper.hasOption(OPTION_COPY_ACL);
+        doOverwrite = optHelper.hasOption(OPTION_OVERWRITE);
+        doMigrateSegment = optHelper.hasOption(OPTION_MIGRATE_SEGMENTS);
+        purgeAndDisable = optHelper.hasOption(OPTION_PURGE_AND_DISABLE);
+        srcConfig = KylinConfig.createInstanceFromUri(optHelper.getOptionValue(OPTION_SRC_CONFIG));
+        srcStore = ResourceStore.getStore(srcConfig);
+        dstConfig = KylinConfig.createInstanceFromUri(optHelper.getOptionValue(OPTION_DST_CONFIG));
+        dstStore = ResourceStore.getStore(dstConfig);
+        migrateSegment = optHelper.hasOption(OPTION_MIGRATE_SEGMENTS);
+        realExecute = optHelper.hasOption(OPTION_EXECUTE);
+        dstProject = optHelper.getOptionValue(OPTION_DST_PROJECT);
+        conf = HadoopUtil.getCurrentConfiguration();
     }
 
-    protected void usage() {
-        System.out.println(
-                "Usage: CubeMigrationCLI srcKylinConfigUri dstKylinConfigUri cubeName projectName copyAclOrNot purgeOrNot overwriteIfExists realExecute migrateSegmentOrNot");
-        System.out.println("srcKylinConfigUri: The KylinConfig of the cube’s source \n"
-                + "dstKylinConfigUri: The KylinConfig of the cube’s new home \n"
-                + "cubeName: the name of cube to be migrated. \n"
-                + "projectName: The target project in the target environment.(Make sure it exist) \n"
-                + "copyAclOrNot: true or false: whether copy cube ACL to target environment. \n"
-                + "purgeOrNot: true or false: whether purge the cube from src server after the migration. \n"
-                + "overwriteIfExists: overwrite cube if it already exists in the target environment. \n"
-                + "realExecute: if false, just print the operations to take, if true, do the real migration. \n"
-                + "migrateSegmentOrNot:(optional) true or false: whether copy segment data to target environment. \n");
-
-    }
+    public void moveCube() throws Exception {
+        conf = HadoopUtil.getCurrentConfiguration();
 
-    public void moveCube(String srcCfgUri, String dstCfgUri, String cubeName, String projectName, String copyAcl,
-                         String purgeAndDisable, String overwriteIfExists, String realExecute)
-            throws IOException, InterruptedException {
+        if (optHelper.hasOption(OPTION_CUBE)) {
+            CubeManager cubeManager = CubeManager.getInstance(srcConfig);
+            moveSingleCube(optHelper.getOptionValue(OPTION_CUBE), dstProject, cubeManager);

Review comment:
       You are right. Maybe try to create it automatically?
       If the specified destProject exists in source cluster, the project's owner keep unchanged. 
       If the specified destProject does not exists in source cluster, set the to be created project's owner to ADMIN ? 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kylin] zhengshengjun commented on pull request #1611: KYLIN-4923 CubeMigration Tools support migrate meta from 2.x/3.x cluster to 4.0 cluster

Posted by GitBox <gi...@apache.org>.
zhengshengjun commented on pull request #1611:
URL: https://github.com/apache/kylin/pull/1611#issuecomment-801159674


   > Could you please add some **How to use** or document about you code change? I see you add a lot of "Option".
   > 
   > Please take the doc I wrote before as a example.
   
   Sure, I'll create a new PR about optimizing existing CubeMigration Tools.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kylin] zhangayqian commented on a change in pull request #1611: KYLIN-4923 CubeMigration Tools support migrate meta from 2.x/3.x cluster to 4.0 cluster

Posted by GitBox <gi...@apache.org>.
zhangayqian commented on a change in pull request #1611:
URL: https://github.com/apache/kylin/pull/1611#discussion_r611283652



##########
File path: tool/src/main/java/org/apache/kylin/tool/CubeMigrationCLI.java
##########
@@ -86,82 +98,113 @@
     protected String dstProject;
     protected String srcHdfsWorkDir;
     protected String dstHdfsWorkDir;
+    private boolean migrateSegment;
+    private boolean realExecute;
+    private boolean purgeAndDisable;
+    private OptionsHelper optHelper;
 
     private static final String ACL_PREFIX = "/acl/";
     private static final String GLOBAL_DICT_PREFIX = "/dict/global_dict/";
 
-    public static void main(String[] args) throws IOException, InterruptedException {
+    private static final Option OPTION_SRC_CONFIG = OptionBuilder.isRequired(true).hasArg().withDescription("The KylinConfig of the cube’s source").create("srcConfig");
+    private static final Option OPTION_DST_CONFIG = OptionBuilder.isRequired(true).hasArg().withDescription("The KylinConfig of the cube’s new home").create("dstConfig");
+    private static final Option OPTION_ALL_CUBES = OptionBuilder.isRequired(false).withDescription("migrate all cubes meta from source cluster").create("allCubes");
+    private static final Option OPTION_CUBE = OptionBuilder.isRequired(false).hasArg().withDescription("Cube name to migrate").create("cube");
+    private static final Option OPTION_DST_PROJECT = OptionBuilder.isRequired(false).hasArg().withDescription("cube's new project home, if not set, keep the same as source cluster").create("dstProject");
+    private static final Option OPTION_SRC_PROJECT = OptionBuilder.isRequired(false).hasArg().withDescription("source project to migrate").create("srcProject");
+    private static final Option OPTION_COPY_ACL = OptionBuilder.isRequired(false).hasArg().withDescription("copy ACL").create("copyAcl");
+    private static final Option OPTION_PURGE_AND_DISABLE = OptionBuilder.isRequired(false).withDescription("purge source cluster data").create("purgeAndDisable");
+    private static final Option OPTION_OVERWRITE = OptionBuilder.isRequired(false).withDescription("overwrite target cluster's meta if exists").create("overwriteIfExists");
+    private static final Option OPTION_EXECUTE = OptionBuilder.isRequired(false).withDescription("execute migration").create("execute");
+    private static final Option OPTION_MIGRATE_SEGMENTS = OptionBuilder.isRequired(false).withDescription("migrate segment data").create("migrateSegment");

Review comment:
       > It would be nice if we add this validation for users. By the way, what about deciding automatically by comparing cube's major version and system's major version before "doMigrateSegment"?
   
   Good idea!




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kylin] zhengshengjun commented on a change in pull request #1611: KYLIN-4923 CubeMigration Tools support migrate meta from 2.x/3.x cluster to 4.0 cluster

Posted by GitBox <gi...@apache.org>.
zhengshengjun commented on a change in pull request #1611:
URL: https://github.com/apache/kylin/pull/1611#discussion_r610686888



##########
File path: tool/src/main/java/org/apache/kylin/tool/CubeMigrationCLI.java
##########
@@ -86,82 +98,113 @@
     protected String dstProject;
     protected String srcHdfsWorkDir;
     protected String dstHdfsWorkDir;
+    private boolean migrateSegment;
+    private boolean realExecute;
+    private boolean purgeAndDisable;
+    private OptionsHelper optHelper;
 
     private static final String ACL_PREFIX = "/acl/";
     private static final String GLOBAL_DICT_PREFIX = "/dict/global_dict/";
 
-    public static void main(String[] args) throws IOException, InterruptedException {
+    private static final Option OPTION_SRC_CONFIG = OptionBuilder.isRequired(true).hasArg().withDescription("The KylinConfig of the cube’s source").create("srcConfig");
+    private static final Option OPTION_DST_CONFIG = OptionBuilder.isRequired(true).hasArg().withDescription("The KylinConfig of the cube’s new home").create("dstConfig");
+    private static final Option OPTION_ALL_CUBES = OptionBuilder.isRequired(false).withDescription("migrate all cubes meta from source cluster").create("allCubes");
+    private static final Option OPTION_CUBE = OptionBuilder.isRequired(false).hasArg().withDescription("Cube name to migrate").create("cube");
+    private static final Option OPTION_DST_PROJECT = OptionBuilder.isRequired(false).hasArg().withDescription("cube's new project home, if not set, keep the same as source cluster").create("dstProject");
+    private static final Option OPTION_SRC_PROJECT = OptionBuilder.isRequired(false).hasArg().withDescription("source project to migrate").create("srcProject");
+    private static final Option OPTION_COPY_ACL = OptionBuilder.isRequired(false).hasArg().withDescription("copy ACL").create("copyAcl");
+    private static final Option OPTION_PURGE_AND_DISABLE = OptionBuilder.isRequired(false).withDescription("purge source cluster data").create("purgeAndDisable");
+    private static final Option OPTION_OVERWRITE = OptionBuilder.isRequired(false).withDescription("overwrite target cluster's meta if exists").create("overwriteIfExists");
+    private static final Option OPTION_EXECUTE = OptionBuilder.isRequired(false).withDescription("execute migration").create("execute");
+    private static final Option OPTION_MIGRATE_SEGMENTS = OptionBuilder.isRequired(false).withDescription("migrate segment data").create("migrateSegment");
+
+    public static void main(String[] args) throws Exception {
+        CubeMigrationCLI cli = new CubeMigrationCLI();
+        cli.init(args);
+        cli.moveCube();
+    }
 
+    public void init(String[] args) {
+        optHelper = new OptionsHelper();
         CubeMigrationCLI cli = new CubeMigrationCLI();
-        if (args.length != 8 && args.length != 9) {
-            cli.usage();
+        try {
+            optHelper.parseOptions(cli.getOptions(), args);
+        } catch (Exception e) {
+            logger.error("failed to parse arguments", e);
+            optHelper.printUsage("CubeMigrationCLI", cli.getOptions());
             System.exit(1);
         }
-        if (args.length == 8) {
-            cli.moveCube(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]);
-        } else if (args.length == 9) {
-            cli.moveCube(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8]);
-        }
+        doAclCopy = optHelper.hasOption(OPTION_COPY_ACL);
+        doOverwrite = optHelper.hasOption(OPTION_OVERWRITE);
+        doMigrateSegment = optHelper.hasOption(OPTION_MIGRATE_SEGMENTS);
+        purgeAndDisable = optHelper.hasOption(OPTION_PURGE_AND_DISABLE);
+        srcConfig = KylinConfig.createInstanceFromUri(optHelper.getOptionValue(OPTION_SRC_CONFIG));
+        srcStore = ResourceStore.getStore(srcConfig);
+        dstConfig = KylinConfig.createInstanceFromUri(optHelper.getOptionValue(OPTION_DST_CONFIG));
+        dstStore = ResourceStore.getStore(dstConfig);
+        migrateSegment = optHelper.hasOption(OPTION_MIGRATE_SEGMENTS);
+        realExecute = optHelper.hasOption(OPTION_EXECUTE);
+        dstProject = optHelper.getOptionValue(OPTION_DST_PROJECT);
+        conf = HadoopUtil.getCurrentConfiguration();
     }
 
-    protected void usage() {
-        System.out.println(
-                "Usage: CubeMigrationCLI srcKylinConfigUri dstKylinConfigUri cubeName projectName copyAclOrNot purgeOrNot overwriteIfExists realExecute migrateSegmentOrNot");
-        System.out.println("srcKylinConfigUri: The KylinConfig of the cube’s source \n"
-                + "dstKylinConfigUri: The KylinConfig of the cube’s new home \n"
-                + "cubeName: the name of cube to be migrated. \n"
-                + "projectName: The target project in the target environment.(Make sure it exist) \n"
-                + "copyAclOrNot: true or false: whether copy cube ACL to target environment. \n"
-                + "purgeOrNot: true or false: whether purge the cube from src server after the migration. \n"
-                + "overwriteIfExists: overwrite cube if it already exists in the target environment. \n"
-                + "realExecute: if false, just print the operations to take, if true, do the real migration. \n"
-                + "migrateSegmentOrNot:(optional) true or false: whether copy segment data to target environment. \n");
-
-    }
+    public void moveCube() throws Exception {
+        conf = HadoopUtil.getCurrentConfiguration();
 
-    public void moveCube(String srcCfgUri, String dstCfgUri, String cubeName, String projectName, String copyAcl,
-                         String purgeAndDisable, String overwriteIfExists, String realExecute)
-            throws IOException, InterruptedException {
+        if (optHelper.hasOption(OPTION_CUBE)) {
+            CubeManager cubeManager = CubeManager.getInstance(srcConfig);
+            moveSingleCube(optHelper.getOptionValue(OPTION_CUBE), dstProject, cubeManager);

Review comment:
       You are right. Maybe try to create it automatically?
       Whether the specified destProject exists in source cluster or not, the cube's owner keep unchanged. 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kylin] zhengshengjun commented on a change in pull request #1611: KYLIN-4923 CubeMigration Tools support migrate meta from 2.x/3.x cluster to 4.0 cluster

Posted by GitBox <gi...@apache.org>.
zhengshengjun commented on a change in pull request #1611:
URL: https://github.com/apache/kylin/pull/1611#discussion_r596072430



##########
File path: build/bin/kylin.sh
##########
@@ -143,9 +143,9 @@ function retrieveDependency() {
 
     # compose hadoop_dependencies
     hadoop_dependencies=${hadoop_dependencies}:`hadoop classpath`
-#    if [ -n "${hbase_dependency}" ]; then
-#        hadoop_dependencies=${hadoop_dependencies}:${hbase_dependency}
-#    fi
+    if [ -n "${hbase_dependency}" ]; then

Review comment:
       Agreed ! It breaks the long term goal.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kylin] hit-lacus commented on pull request #1611: KYLIN-4923 CubeMigration Tools support migrate meta from 2.x/3.x cluster to 4.0 cluster

Posted by GitBox <gi...@apache.org>.
hit-lacus commented on pull request #1611:
URL: https://github.com/apache/kylin/pull/1611#issuecomment-824555862


   > Added document in: https://cwiki.apache.org/confluence/display/KYLIN/How+to+migrate+metadata+to+Kylin+4
   
   That's great! Thx! 👍 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kylin] lgtm-com[bot] commented on pull request #1611: KYLIN-4923 CubeMigration Tools support migrate meta from 2.x/3.x cluster to 4.0 cluster

Posted by GitBox <gi...@apache.org>.
lgtm-com[bot] commented on pull request #1611:
URL: https://github.com/apache/kylin/pull/1611#issuecomment-817235442


   This pull request **introduces 4 alerts** when merging 31e00c9e6be5e4995d0b5f558452746ab1af0299 into dfd012f45b9740ae0598041d7f1326e3a58c0da7 - [view on LGTM.com](https://lgtm.com/projects/g/apache/kylin/rev/pr-bf41ec36312e165d5129b6691037df3c5d86017d)
   
   **new alerts:**
   
   * 3 for Dereferenced variable may be null
   * 1 for Missing format argument


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kylin] zhangayqian commented on pull request #1611: KYLIN-4923 CubeMigration Tools support migrate meta from 2.x/3.x cluster to 4.0 cluster

Posted by GitBox <gi...@apache.org>.
zhangayqian commented on pull request #1611:
URL: https://github.com/apache/kylin/pull/1611#issuecomment-816348127


   > I have removed HBase dependency. We can migrate meta from 2.x/3.x to 4.x by two steps:
   > 
   > 1. use  "metastore.sh backup"  to export 2.x/3.x metadata to local dir
   > 2. then use "CubeMigration -srcConfig ${exported_meta_dir} -dstConfig v4/kylin.properties ... " to migrate exported metadata to new cluster
   
   @zhengshengjun Thanks! I will test and review this PR.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kylin] zhangayqian commented on a change in pull request #1611: KYLIN-4923 CubeMigration Tools support migrate meta from 2.x/3.x cluster to 4.0 cluster

Posted by GitBox <gi...@apache.org>.
zhangayqian commented on a change in pull request #1611:
URL: https://github.com/apache/kylin/pull/1611#discussion_r611283240



##########
File path: tool/src/main/java/org/apache/kylin/tool/CubeMigrationCLI.java
##########
@@ -86,82 +98,113 @@
     protected String dstProject;
     protected String srcHdfsWorkDir;
     protected String dstHdfsWorkDir;
+    private boolean migrateSegment;
+    private boolean realExecute;
+    private boolean purgeAndDisable;
+    private OptionsHelper optHelper;
 
     private static final String ACL_PREFIX = "/acl/";
     private static final String GLOBAL_DICT_PREFIX = "/dict/global_dict/";
 
-    public static void main(String[] args) throws IOException, InterruptedException {
+    private static final Option OPTION_SRC_CONFIG = OptionBuilder.isRequired(true).hasArg().withDescription("The KylinConfig of the cube’s source").create("srcConfig");
+    private static final Option OPTION_DST_CONFIG = OptionBuilder.isRequired(true).hasArg().withDescription("The KylinConfig of the cube’s new home").create("dstConfig");
+    private static final Option OPTION_ALL_CUBES = OptionBuilder.isRequired(false).withDescription("migrate all cubes meta from source cluster").create("allCubes");
+    private static final Option OPTION_CUBE = OptionBuilder.isRequired(false).hasArg().withDescription("Cube name to migrate").create("cube");
+    private static final Option OPTION_DST_PROJECT = OptionBuilder.isRequired(false).hasArg().withDescription("cube's new project home, if not set, keep the same as source cluster").create("dstProject");
+    private static final Option OPTION_SRC_PROJECT = OptionBuilder.isRequired(false).hasArg().withDescription("source project to migrate").create("srcProject");
+    private static final Option OPTION_COPY_ACL = OptionBuilder.isRequired(false).hasArg().withDescription("copy ACL").create("copyAcl");
+    private static final Option OPTION_PURGE_AND_DISABLE = OptionBuilder.isRequired(false).withDescription("purge source cluster data").create("purgeAndDisable");
+    private static final Option OPTION_OVERWRITE = OptionBuilder.isRequired(false).withDescription("overwrite target cluster's meta if exists").create("overwriteIfExists");
+    private static final Option OPTION_EXECUTE = OptionBuilder.isRequired(false).withDescription("execute migration").create("execute");
+    private static final Option OPTION_MIGRATE_SEGMENTS = OptionBuilder.isRequired(false).withDescription("migrate segment data").create("migrateSegment");
+
+    public static void main(String[] args) throws Exception {
+        CubeMigrationCLI cli = new CubeMigrationCLI();
+        cli.init(args);
+        cli.moveCube();
+    }
 
+    public void init(String[] args) {
+        optHelper = new OptionsHelper();
         CubeMigrationCLI cli = new CubeMigrationCLI();
-        if (args.length != 8 && args.length != 9) {
-            cli.usage();
+        try {
+            optHelper.parseOptions(cli.getOptions(), args);
+        } catch (Exception e) {
+            logger.error("failed to parse arguments", e);
+            optHelper.printUsage("CubeMigrationCLI", cli.getOptions());
             System.exit(1);
         }
-        if (args.length == 8) {
-            cli.moveCube(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]);
-        } else if (args.length == 9) {
-            cli.moveCube(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8]);
-        }
+        doAclCopy = optHelper.hasOption(OPTION_COPY_ACL);
+        doOverwrite = optHelper.hasOption(OPTION_OVERWRITE);
+        doMigrateSegment = optHelper.hasOption(OPTION_MIGRATE_SEGMENTS);
+        purgeAndDisable = optHelper.hasOption(OPTION_PURGE_AND_DISABLE);
+        srcConfig = KylinConfig.createInstanceFromUri(optHelper.getOptionValue(OPTION_SRC_CONFIG));
+        srcStore = ResourceStore.getStore(srcConfig);
+        dstConfig = KylinConfig.createInstanceFromUri(optHelper.getOptionValue(OPTION_DST_CONFIG));
+        dstStore = ResourceStore.getStore(dstConfig);
+        migrateSegment = optHelper.hasOption(OPTION_MIGRATE_SEGMENTS);
+        realExecute = optHelper.hasOption(OPTION_EXECUTE);
+        dstProject = optHelper.getOptionValue(OPTION_DST_PROJECT);
+        conf = HadoopUtil.getCurrentConfiguration();
     }
 
-    protected void usage() {
-        System.out.println(
-                "Usage: CubeMigrationCLI srcKylinConfigUri dstKylinConfigUri cubeName projectName copyAclOrNot purgeOrNot overwriteIfExists realExecute migrateSegmentOrNot");
-        System.out.println("srcKylinConfigUri: The KylinConfig of the cube’s source \n"
-                + "dstKylinConfigUri: The KylinConfig of the cube’s new home \n"
-                + "cubeName: the name of cube to be migrated. \n"
-                + "projectName: The target project in the target environment.(Make sure it exist) \n"
-                + "copyAclOrNot: true or false: whether copy cube ACL to target environment. \n"
-                + "purgeOrNot: true or false: whether purge the cube from src server after the migration. \n"
-                + "overwriteIfExists: overwrite cube if it already exists in the target environment. \n"
-                + "realExecute: if false, just print the operations to take, if true, do the real migration. \n"
-                + "migrateSegmentOrNot:(optional) true or false: whether copy segment data to target environment. \n");
-
-    }
+    public void moveCube() throws Exception {
+        conf = HadoopUtil.getCurrentConfiguration();
 
-    public void moveCube(String srcCfgUri, String dstCfgUri, String cubeName, String projectName, String copyAcl,
-                         String purgeAndDisable, String overwriteIfExists, String realExecute)
-            throws IOException, InterruptedException {
+        if (optHelper.hasOption(OPTION_CUBE)) {
+            CubeManager cubeManager = CubeManager.getInstance(srcConfig);
+            moveSingleCube(optHelper.getOptionValue(OPTION_CUBE), dstProject, cubeManager);

Review comment:
       > You are right. Maybe try to create it automatically?
   > Whether the specified destProject exists in source cluster or not, the cube's owner keep unchanged.
   
   Nice. I agree.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kylin] hit-lacus commented on pull request #1611: KYLIN-4923 CubeMigration Tools support migrate meta from 2.x/3.x cluster to 4.0 cluster

Posted by GitBox <gi...@apache.org>.
hit-lacus commented on pull request #1611:
URL: https://github.com/apache/kylin/pull/1611#issuecomment-801558727


   OK, following is a example.
   
   https://cwiki.apache.org/confluence/display/KYLIN/DiagnosisTool


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kylin] zhengshengjun removed a comment on pull request #1611: KYLIN-4923 CubeMigration Tools support migrate meta from 2.x/3.x cluster to 4.0 cluster

Posted by GitBox <gi...@apache.org>.
zhengshengjun removed a comment on pull request #1611:
URL: https://github.com/apache/kylin/pull/1611#issuecomment-801159674


   > Could you please add some **How to use** or document about you code change? I see you add a lot of "Option".
   > 
   > Please take the doc I wrote before as a example.
   
   Sure, I'll create a new PR about optimizing existing CubeMigration Tools.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kylin] hit-lacus merged pull request #1611: KYLIN-4923 CubeMigration Tools support migrate meta from 2.x/3.x cluster to 4.0 cluster

Posted by GitBox <gi...@apache.org>.
hit-lacus merged pull request #1611:
URL: https://github.com/apache/kylin/pull/1611


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kylin] hit-lacus commented on pull request #1611: KYLIN-4923 CubeMigration Tools support migrate meta from 2.x/3.x cluster to 4.0 cluster

Posted by GitBox <gi...@apache.org>.
hit-lacus commented on pull request #1611:
URL: https://github.com/apache/kylin/pull/1611#issuecomment-801077980


   Could you please add some **How to use** or document about you code change? I see you add a lot of "Option".
   
   Please take the doc I wrote before as a example.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kylin] codecov-io commented on pull request #1611: KYLIN-4923 CubeMigration Tools support migrate meta from 2.x/3.x cluster to 4.0 cluster

Posted by GitBox <gi...@apache.org>.
codecov-io commented on pull request #1611:
URL: https://github.com/apache/kylin/pull/1611#issuecomment-813792124


   # [Codecov](https://codecov.io/gh/apache/kylin/pull/1611?src=pr&el=h1) Report
   > :exclamation: No coverage uploaded for pull request base (`kylin-on-parquet-v2@d7ca7a5`). [Click here to learn what that means](https://docs.codecov.io/docs/error-reference#section-missing-base-commit).
   > The diff coverage is `n/a`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/kylin/pull/1611/graphs/tree.svg?width=650&height=150&src=pr&token=JawVgbgsVo)](https://codecov.io/gh/apache/kylin/pull/1611?src=pr&el=tree)
   
   ```diff
   @@                  Coverage Diff                   @@
   ##             kylin-on-parquet-v2    #1611   +/-   ##
   ======================================================
     Coverage                       ?   24.31%           
     Complexity                     ?     4647           
   ======================================================
     Files                          ?     1145           
     Lines                          ?    65463           
     Branches                       ?     9612           
   ======================================================
     Hits                           ?    15916           
     Misses                         ?    47878           
     Partials                       ?     1669           
   ```
   
   
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/kylin/pull/1611?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/kylin/pull/1611?src=pr&el=footer). Last update [d7ca7a5...7a1b56c](https://codecov.io/gh/apache/kylin/pull/1611?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org