Repository: atlas
Updated Branches:
  refs/heads/branch-1.0 3e89e9b48 -> 641323dba


ATLAS-2817: Handle auto upgrade from janus 0.2.0 to janus 0.3.0

(cherry picked from commit 27e8b2a40c718314aa0d8f114f5f7170e6c2a2dc)


Project: http://git-wip-us.apache.org/repos/asf/atlas/repo
Commit: http://git-wip-us.apache.org/repos/asf/atlas/commit/641323db
Tree: http://git-wip-us.apache.org/repos/asf/atlas/tree/641323db
Diff: http://git-wip-us.apache.org/repos/asf/atlas/diff/641323db

Branch: refs/heads/branch-1.0
Commit: 641323dbab4902f4f883df4144704488d794049e
Parents: 3e89e9b
Author: apoorvnaik <[email protected]>
Authored: Tue Jul 31 07:06:17 2018 -0700
Committer: apoorvnaik <[email protected]>
Committed: Mon Aug 20 16:45:51 2018 -0700

----------------------------------------------------------------------
 .../graphdb/janus/AtlasJanusGraphDatabase.java         | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/atlas/blob/641323db/graphdb/janus/src/main/java/org/apache/atlas/repository/graphdb/janus/AtlasJanusGraphDatabase.java
----------------------------------------------------------------------
diff --git 
a/graphdb/janus/src/main/java/org/apache/atlas/repository/graphdb/janus/AtlasJanusGraphDatabase.java
 
b/graphdb/janus/src/main/java/org/apache/atlas/repository/graphdb/janus/AtlasJanusGraphDatabase.java
index 6b9ad83..47e561b 100644
--- 
a/graphdb/janus/src/main/java/org/apache/atlas/repository/graphdb/janus/AtlasJanusGraphDatabase.java
+++ 
b/graphdb/janus/src/main/java/org/apache/atlas/repository/graphdb/janus/AtlasJanusGraphDatabase.java
@@ -30,6 +30,7 @@ import 
org.apache.atlas.typesystem.types.DataTypes.TypeCategory;
 import org.apache.atlas.utils.AtlasPerfTracer;
 import org.apache.commons.configuration.Configuration;
 import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONMapper;
+import org.janusgraph.core.JanusGraphException;
 import 
org.janusgraph.graphdb.database.serialize.attribute.SerializableSerializer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -50,6 +51,7 @@ public class AtlasJanusGraphDatabase implements 
GraphDatabase<AtlasJanusVertex,
     private static final Logger LOG      = 
LoggerFactory.getLogger(AtlasJanusGraphDatabase.class);
     private static final Logger PERF_LOG = 
AtlasPerfTracer.getPerfLogger("AtlasJanusGraphDatabase");
 
+    private static final String OLDER_STORAGE_EXCEPTION = "Storage version is 
incompatible with current client";
 
     /**
      * Constant for the configuration property that indicates the prefix.
@@ -102,7 +104,16 @@ public class AtlasJanusGraphDatabase implements 
GraphDatabase<AtlasJanusVertex,
                         throw new RuntimeException(e);
                     }
 
-                    graphInstance = JanusGraphFactory.open(config);
+                    try {
+                        graphInstance = JanusGraphFactory.open(config);
+                    } catch (JanusGraphException e) {
+                        LOG.warn("JanusGraphException: {}", e.getMessage());
+                        if 
(e.getMessage().startsWith(OLDER_STORAGE_EXCEPTION)) {
+                            LOG.info("Newer client is being used with older 
janus storage version. Setting allow-upgrade=true and reattempting connection");
+                            config.addProperty("graph.allow-upgrade", true);
+                            graphInstance = JanusGraphFactory.open(config);
+                        }
+                    }
                     atlasGraphInstance = new AtlasJanusGraph();
                     validateIndexBackend(config);
                 }

Reply via email to