2 * Before starting the migration, please make sure to create a backup of sdctitan keyspace in cassandra
5 * 1. Download JanusGraph gremlin in-built package from below URL;
6 * https://github.com/JanusGraph/janusgraph/releases/download/v0.3.1/janusgraph-0.3.1-hadoop2.zip
7 * 2. Unzip it and navigate to bin folder.
8 * 3. Run below command.
9 * Command : ./gremlin.sh -l <LOG_LEVEL> -e <Path_To_This_Script_File> <Path_To_Properties_File>
10 * Example : ./gremlin.sh -l ERROR -e /data/scripts/TitanToJanusGraphMigration.groovy /data/scripts/titan.properties
12 * Note: Please make sure that the above provided property file have the below field present;
13 * graph.allow-upgrade=true
16 // Check for open database connections; should be only one
17 def Object checkAndCloseMultipleInstances(Object mgmt, Object graph, long sleepTime){
18 if(mgmt.getOpenInstances().size() > 1) {
19 for (String instanceId in mgmt.getOpenInstances())
20 if(!instanceId.contains("current"))
21 mgmt.forceCloseInstance(instanceId);
24 mgmt = graph.openManagement();
29 // Update the ID Store
30 def updateGraphIDStore(Object mgmt, long sleepTime){
31 mgmt.set('ids.store-name', 'titan_ids');
36 // Verify the ID Store
37 def verifyUpdatedGraphIDStore(String propertyPath){
38 graph = JanusGraphFactory.open(propertyPath);
39 mgmt = graph.openManagement();
40 if(!mgmt.get('ids.store-name').equals("titan_ids"))
41 throw new GroovyRuntimeException("FAILURE -> Error in setting up the ID Store to titan_ids; please contact system administrator... ");
43 println("SUCCESS -> Titan ID Store has also been set correctly... ");
47 graph = JanusGraphFactory.open(args[0]);
48 mgmt = graph.openManagement();
50 // Check if titan graph is upgraded to Janus Graph compatibility
51 if(mgmt.get('graph.titan-version').equals("1.0.0"))
52 throw new GroovyRuntimeException("FAILURE -> Titan graph is not upgraded to Janus. please make sure graph.allow-upgrade property is set to true in properties file and re-run the script.");
53 println("SUCCESS -> Titan Graph data is upgraded to Janus compatible Graph... ");
55 // Update the ID Store if required
56 if(mgmt.get('ids.store-name').equals("janusgraph_ids")){
57 mgmt = checkAndCloseMultipleInstances(mgmt, graph,2000l);
58 updateGraphIDStore(mgmt, 2000l);
59 verifyUpdatedGraphIDStore(args[0]);
61 println("SUCCESS -> Titan to Janus Graph upgrade process is now complete... ");
63 } catch(Exception ex){
64 println("FAILURE -> Titan to Janus Graph migration process has failed; please check the exception trace for more details.");