[ 
https://issues.apache.org/jira/browse/KYLIN-1605?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15261626#comment-15261626
 ] 

Richard Calaba commented on KYLIN-1605:
---------------------------------------

I did additional testing of the metastore.sh backup / restore and the 
org.apache.kylin.storage.hbase.util.CubeMigrationCLI and here is brief summary:

(cannot report some of the issues as bugs as that would require proper setup - 
so this is just summary of current functionality - tested on 1.5.1)

1) I have succeeded to manually clone one Cube from tables in schemaA to the 
same named tables in schemaB (schema - aka. database). The steps involved are:

    a) metastore.sh backup

    b) modify the json files (replace schemaA with schemaB in tables / project 
/ cube definition / model ; rename cube name and cube model ; create new unique 
uuids) ; rename files so they correspond to the new cube / model / table / 
project names

    c) metastore.sh restore <path_to_modified_json_files_dir_tree> 

    d) Reload Metadata (System) in Kylin UI -> now I have exact clone of my 
cube on new SchemaB tables (including all necessary objects)

    e) I did this with EMPTY (DISABLED) cube

2) I also tried for curiosity the same as above - but not specifying new uuids 
- the metastore.sh restore also worked and the rest of the functionality also 
(cube build, querying). Probably because the operations rely on unique Cube 
Name in whole Kylin system. Which is fine - but there was technical 
inconsistency because 2 cubes (and other objects) were existing with same uuid 
! This technical inconsistency showed itself when I was trying to use  
org.apache.kylin.storage.hbase.util.CubeMigrationCL and specifying that the 
source cube should be purged after the migration succeeds. What happened is 
that migration successfully migrated CubeA but deleted CubeB (including it's 
project !!) - I am guessing here that the reason was the fact that both CubeA 
and CubeB had same uuid. So make sure that you replace the uuids with new 
unique values if modyfing backed-up metadata. Can we have REST srevice for new 
unique UUID generation ?? So we can automate this ... or can the metastore.sh 
restore replace the UUIDs during imprt with new ones ???

3) As stated above - if Cube is not in READY status it cannot be migrated by  
org.apache.kylin.storage.hbase.util.CubeMigrationCL ... so what I did is I used 
metastore.sh backup technique, then modified JSON attribute status (from 
DISABLED to READY) of the Cube Meta (not the Cube Descriptor ! - there are 2 
JSON files per Cube). Then I had successfully imported the Cube back - using 
metastore.sh restore - and voila - the Cube was in READY status even it had no 
loaded data segment (no READY segment). Then I tsted querying and Build Job 
Scheduling - and all seemed to work fine ! Cannot prove the Build as running 
into MapR specific issues not related to this. 

   So seems Cube with 0 loaded segments can be queried, migrated (see below). 
Unfortunatelly once you disable Cube with 0 segments - you cannot enable it 
again. That might be reported as bug - if all works - we should allow 
opeartions on cubes with 0 segments loaded ...

4) Using the trick above in point 3) - I made my empty Cube READY and used  
org.apache.kylin.storage.hbase.util.CubeMigrationCL to migrate it from one 
system to another, here few observations:

         - I used same host running 2 instances of Kylin (one on port 7070 and 
2nd on 9090; I had to adjust kylin properties file to use another table name 
for metadata storage and also had to change ports of the tomcat packed with 
Kylin so I can have 2 tomcats running on different ports (server.xml file in 
tomact/conf directory).

    After doing this I SUCCESSFULLY migrated my EMPTY Cube (manually set to 
READY - see above) - from one Kylin Server to another.
    All seemed working fine - but no intensive data tests done/

    ONE WEIRD thing was that even Cube Querying and job scheduling worked fine 
- the Hive Tables were not "loaded" in the Kylin UI (Model -> Datasource was 
not showing any table; seems loading of the Hive DB tables is needed only for 
design time ... goood ... for runtime it seems using the copied Hive DB 
metadata and assumes they correspond in connected Hive DB ... also good 
assumption :) - so maybe this weird thing "works as designed" 

5) As I was tetsing those hardocre scenarios I also tried migrating Cube from 
one project to another on same server - that didin't work - obviously part of 
the problem is that cube migration doesn't support renaming of the migrated 
cube and cube name is system unique ...

6) Testing once - I got some exception while trying to migrate my empty ACL ... 
maybe something to check ...


> Functionality to Export/Import Hive/Model/Cube Metadata - API
> -------------------------------------------------------------
>
>                 Key: KYLIN-1605
>                 URL: https://issues.apache.org/jira/browse/KYLIN-1605
>             Project: Kylin
>          Issue Type: New Feature
>          Components: General
>    Affects Versions: Future
>            Reporter: Richard Calaba
>            Priority: Critical
>
> Hello,
> I wonder what is the official way to copy a Kylin Cube definition from one 
> system to another ??? I didn't find any official docu for that in Kylin. I 
> also checked REST API and didn't find all building blocks which would be 
> needed to achieve this.
> The scenario is to transfer Cube definition from one system to another system 
> (like DEV to QAS / QAS to PRD, ...). So it can be rebuild there from that 
> actual system's data.
> I imagine the functionality to be split into:
> 1) Export Hive Table Metadata (REST API) to JSON
> 2) Import Hive Table Metadata (REST API) from JSON - checks whether the Hive 
> DB table meta in JSON is consistent with actual Hive DB table
> 3) Export Cube Model Metadata (REST API) to JSON
> 4) Import Cube Model Metadata (REST API) from JSON - checks whether the 
> underlying Hive DB tables exists and are consistent with Model; returns new 
> unique ID of the imported model
> 5) Export Cube Descriptor (metadata) (REST API) to JSON
> 6) Import Cube Descriptor (metadata) (REST API) from JSON. Check that  Cube 
> metadata is consistent (i.e. that the referred Model is existing in the 
> system). Returns new unique ID of the imported Cube so it can be used for 
> example to call Build Cube REST API after successful import.
> Optionally the Export/Import functions can be then connected to UI.
> Because of the Dependencies (Hive DB table Meta -> Cube Model -> Cube 
> Descriptor) and because of the reusability of the building blocks (several 
> Models referring same Hive DB Tables/Views; several Cubes referring same 
> Model) we should have independent Export/Import REST APIs for each level 
> separately (Hive DB meta / Model / Cube Descriptor).



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to