Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
atlas
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
dataplatform
atlas
Commits
8188a96e
Commit
8188a96e
authored
Jul 08, 2019
by
Ashutosh Mestry
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-3315: Database initialization exception handling.
parent
5c002517
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
11 deletions
+51
-11
AtlasJanusGraphDatabase.java
...las/repository/graphdb/janus/AtlasJanusGraphDatabase.java
+16
-10
AtlasJanusDatabaseTest.java
...tlas/repository/graphdb/janus/AtlasJanusDatabaseTest.java
+35
-1
No files found.
graphdb/janus/src/main/java/org/apache/atlas/repository/graphdb/janus/AtlasJanusGraphDatabase.java
View file @
8188a96e
...
...
@@ -18,6 +18,7 @@
package
org
.
apache
.
atlas
.
repository
.
graphdb
.
janus
;
import
com.google.common.annotations.VisibleForTesting
;
import
com.google.common.collect.ImmutableMap
;
import
org.apache.atlas.ApplicationProperties
;
import
org.apache.atlas.AtlasException
;
...
...
@@ -165,25 +166,30 @@ public class AtlasJanusGraphDatabase implements GraphDatabase<AtlasJanusVertex,
throw
new
RuntimeException
(
e
);
}
graphInstance
=
initJanusGraph
(
config
);
atlasGraphInstance
=
new
AtlasJanusGraph
();
validateIndexBackend
(
config
);
}
}
}
return
graphInstance
;
}
@VisibleForTesting
static
JanusGraph
initJanusGraph
(
Configuration
config
)
{
try
{
graphInstance
=
JanusGraphFactory
.
open
(
config
);
return
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
);
}
else
{
return
JanusGraphFactory
.
open
(
config
);
}
else
{
throw
new
RuntimeException
(
e
);
}
}
atlasGraphInstance
=
new
AtlasJanusGraph
();
validateIndexBackend
(
config
);
}
}
}
return
graphInstance
;
}
public
static
JanusGraph
getBulkLoadingGraphInstance
()
{
...
...
graphdb/janus/src/test/java/org/apache/atlas/repository/graphdb/janus/AtlasJanusDatabaseTest.java
View file @
8188a96e
...
...
@@ -31,6 +31,7 @@ import org.apache.atlas.repository.graphdb.AtlasGraphQuery.ComparisionOperator;
import
org.apache.atlas.repository.graphdb.AtlasPropertyKey
;
import
org.apache.atlas.repository.graphdb.AtlasVertex
;
import
org.apache.atlas.typesystem.types.DataTypes.TypeCategory
;
import
org.apache.commons.configuration.Configuration
;
import
org.testng.annotations.AfterClass
;
import
org.testng.annotations.Test
;
...
...
@@ -39,9 +40,18 @@ import java.math.BigInteger;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.Map
;
import
static
org
.
testng
.
Assert
.*;
import
static
org
.
apache
.
atlas
.
repository
.
graphdb
.
janus
.
AtlasJanusGraphDatabase
.
initJanusGraph
;
import
static
org
.
testng
.
Assert
.
assertEquals
;
import
static
org
.
testng
.
Assert
.
assertFalse
;
import
static
org
.
testng
.
Assert
.
assertNotNull
;
import
static
org
.
testng
.
Assert
.
assertNull
;
import
static
org
.
testng
.
Assert
.
assertTrue
;
import
static
org
.
testng
.
Assert
.
fail
;
/**
* Sanity test of basic graph operations using the Janus graphdb
...
...
@@ -81,6 +91,30 @@ public class AtlasJanusDatabaseTest {
}
@Test
public
void
initializationFailureShouldThrowRuntimeException
()
throws
AtlasException
{
Configuration
cfg
=
AtlasJanusGraphDatabase
.
getConfiguration
();
Map
<
String
,
Object
>
cfgBackup
=
new
HashMap
<>();
Iterator
<
String
>
keys
=
cfg
.
getKeys
();
while
(
keys
.
hasNext
())
{
String
key
=
keys
.
next
();
cfgBackup
.
put
(
key
,
cfg
.
getProperty
(
key
));
}
try
{
cfg
.
clear
();
initJanusGraph
(
cfg
);
fail
(
"Should have thrown an exception!"
);
}
catch
(
RuntimeException
ex
)
{
assertTrue
(
true
);
for
(
Map
.
Entry
<
String
,
Object
>
entry
:
cfgBackup
.
entrySet
())
{
cfg
.
setProperty
(
entry
.
getKey
(),
entry
.
getValue
());
}
}
}
@Test
public
<
V
,
E
>
void
testPropertyDataTypes
()
{
// primitives
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment