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
78cfd718
Commit
78cfd718
authored
Jun 28, 2018
by
Sarath Subramanian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-2769: Atlas start just after the upgrade fails with…
ATLAS-2769: Atlas start just after the upgrade fails with 'TableNotFoundException: atlas_janus' exception
parent
bae32755
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
65 additions
and
1 deletion
+65
-1
AtlasGraphProvider.java
...org/apache/atlas/repository/graph/AtlasGraphProvider.java
+65
-1
No files found.
repository/src/main/java/org/apache/atlas/repository/graph/AtlasGraphProvider.java
View file @
78cfd718
...
...
@@ -19,10 +19,14 @@
package
org
.
apache
.
atlas
.
repository
.
graph
;
import
com.google.common.annotations.VisibleForTesting
;
import
org.apache.atlas.ApplicationProperties
;
import
org.apache.atlas.AtlasException
;
import
org.apache.atlas.repository.RepositoryException
;
import
org.apache.atlas.repository.graphdb.AtlasGraph
;
import
org.apache.atlas.repository.graphdb.GraphDatabase
;
import
org.apache.atlas.util.AtlasRepositoryConfiguration
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
...
...
@@ -35,6 +39,14 @@ public class AtlasGraphProvider implements IAtlasGraphProvider {
private
static
volatile
GraphDatabase
<?,?>
graphDb_
;
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
AtlasGraphProvider
.
class
);
private
static
final
Integer
MAX_RETRY_COUNT
=
getMaxRetryCount
();
private
static
final
Long
RETRY_SLEEP_TIME_MS
=
getRetrySleepTime
();
private
static
final
String
GRAPH_REPOSITORY_MAX_RETRIES
=
"atlas.graph.repository.max.retries"
;
private
static
final
String
GRAPH_REPOSITORY_RETRY_SLEEPTIME
=
"atlas.graph.repository.retry.sleeptime.ms"
;
private
static
org
.
apache
.
commons
.
configuration
.
Configuration
APPLICATION_PROPERTIES
=
null
;
public
static
<
V
,
E
>
AtlasGraph
<
V
,
E
>
getGraphInstance
()
{
GraphDatabase
<?,?>
db
=
getGraphDatabase
();
AtlasGraph
<?,
?>
graph
=
db
.
getGraph
();
...
...
@@ -67,7 +79,59 @@ public class AtlasGraphProvider implements IAtlasGraphProvider {
@Override
@Bean
(
destroyMethod
=
""
)
public
AtlasGraph
get
()
throws
RepositoryException
{
public
AtlasGraph
get
()
throws
RepositoryException
{
try
{
return
getGraphInstance
();
}
catch
(
Exception
ex
)
{
LOG
.
info
(
"Failed to obtain graph instance, retrying "
+
MAX_RETRY_COUNT
+
" times, error: "
+
ex
);
return
retry
();
}
}
private
AtlasGraph
retry
()
throws
RepositoryException
{
int
retryCounter
=
0
;
while
(
retryCounter
<
MAX_RETRY_COUNT
)
{
try
{
// Retry after 30 sec to get graph instance
Thread
.
sleep
(
RETRY_SLEEP_TIME_MS
);
return
getGraphInstance
();
}
catch
(
Exception
ex
)
{
retryCounter
++;
LOG
.
info
(
"Failed to obtain graph instance on retry "
+
retryCounter
+
" of "
+
MAX_RETRY_COUNT
+
" error: "
+
ex
);
if
(
retryCounter
>=
MAX_RETRY_COUNT
)
{
LOG
.
info
(
"Max retries exceeded."
);
break
;
}
}
}
throw
new
RepositoryException
(
"Max retries exceeded. Failed to obtain graph instance after "
+
MAX_RETRY_COUNT
+
" retries"
);
}
private
static
Integer
getMaxRetryCount
()
{
initApplicationProperties
();
return
(
APPLICATION_PROPERTIES
==
null
)
?
3
:
APPLICATION_PROPERTIES
.
getInt
(
GRAPH_REPOSITORY_MAX_RETRIES
,
3
);
}
private
static
Long
getRetrySleepTime
()
{
initApplicationProperties
();
return
(
APPLICATION_PROPERTIES
==
null
)
?
30000
:
APPLICATION_PROPERTIES
.
getLong
(
GRAPH_REPOSITORY_RETRY_SLEEPTIME
,
30000
);
}
private
static
void
initApplicationProperties
()
{
if
(
APPLICATION_PROPERTIES
==
null
)
{
try
{
APPLICATION_PROPERTIES
=
ApplicationProperties
.
get
();
}
catch
(
AtlasException
ex
)
{
// ignore
}
}
}
}
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