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
f4672292
Commit
f4672292
authored
4 years ago
by
Ashutosh Mestry
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-3775: Migration Import: Status display fix.
parent
de696534
master
No related merge requests found
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
31 deletions
+18
-31
DataMigrationStatusService.java
...tlas/repository/migration/DataMigrationStatusService.java
+16
-30
ZipFileMigrationImporter.java
.../atlas/repository/migration/ZipFileMigrationImporter.java
+2
-0
DataMigrationStatusServiceTest.java
...las/repository/impexp/DataMigrationStatusServiceTest.java
+0
-1
No files found.
repository/src/main/java/org/apache/atlas/repository/migration/DataMigrationStatusService.java
View file @
f4672292
...
...
@@ -22,15 +22,12 @@ import org.apache.atlas.model.migration.MigrationImportStatus;
import
org.apache.atlas.repository.Constants
;
import
org.apache.atlas.repository.graph.AtlasGraphProvider
;
import
org.apache.atlas.repository.graphdb.AtlasGraph
;
import
org.apache.atlas.repository.graphdb.AtlasIndexQuery
;
import
org.apache.atlas.repository.graphdb.AtlasVertex
;
import
org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2
;
import
org.apache.commons.lang.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.util.Date
;
import
java.util.Iterator
;
import
static
org
.
apache
.
atlas
.
repository
.
store
.
graph
.
v2
.
AtlasGraphUtilsV2
.
getEncodedProperty
;
import
static
org
.
apache
.
atlas
.
repository
.
store
.
graph
.
v2
.
AtlasGraphUtilsV2
.
setEncodedProperty
;
...
...
@@ -47,8 +44,8 @@ public class DataMigrationStatusService {
this
.
migrationStatusVertexManagement
=
new
MigrationStatusVertexManagement
(
AtlasGraphProvider
.
getGraphInstance
());
}
public
DataMigrationStatusService
(
AtlasGraph
atlasG
raph
)
{
this
.
migrationStatusVertexManagement
=
new
MigrationStatusVertexManagement
(
atlasG
raph
);
public
DataMigrationStatusService
(
AtlasGraph
g
raph
)
{
this
.
migrationStatusVertexManagement
=
new
MigrationStatusVertexManagement
(
g
raph
);
}
...
...
@@ -76,13 +73,11 @@ public class DataMigrationStatusService {
}
public
MigrationImportStatus
getStatus
()
{
if
(
this
.
status
!=
null
&&
StringUtils
.
isEmpty
(
this
.
status
.
getOperationStatus
())
&&
this
.
migrationStatusVertexManagement
.
exists
(
this
.
status
.
getName
()))
{
if
(
this
.
status
!=
null
&&
this
.
migrationStatusVertexManagement
.
exists
(
this
.
status
.
getName
()))
{
return
getCreate
(
this
.
status
);
}
else
{
return
this
.
status
;
}
return
this
.
status
;
}
public
MigrationImportStatus
getByName
(
String
name
)
{
...
...
@@ -115,18 +110,18 @@ public class DataMigrationStatusService {
public
static
final
String
PROPERTY_KEY_POSITION
=
encodePropertyKey
(
INTERNAL_PROPERTY_KEY_PREFIX
+
"migration.position"
);
public
static
final
String
PROPERTY_KEY_STATUS
=
encodePropertyKey
(
INTERNAL_PROPERTY_KEY_PREFIX
+
"migration.status"
);
private
AtlasGraph
atlasG
raph
;
private
AtlasGraph
g
raph
;
private
AtlasVertex
vertex
;
public
MigrationStatusVertexManagement
(
AtlasGraph
atlasG
raph
)
{
this
.
atlasGraph
=
atlasG
raph
;
public
MigrationStatusVertexManagement
(
AtlasGraph
g
raph
)
{
this
.
graph
=
g
raph
;
}
public
MigrationImportStatus
createOrUpdate
(
MigrationImportStatus
status
)
{
this
.
vertex
=
findByNameInternal
(
status
.
getName
());
if
(
this
.
vertex
==
null
)
{
this
.
vertex
=
atlasG
raph
.
addVertex
();
this
.
vertex
=
g
raph
.
addVertex
();
LOG
.
info
(
"MigrationStatusVertexManagement: Vertex created!"
);
updateVertex
(
this
.
vertex
,
status
);
}
...
...
@@ -156,29 +151,20 @@ public class DataMigrationStatusService {
public
void
delete
(
String
name
)
{
try
{
AtlasVertex
vertex
=
findByNameInternal
(
name
);
atlasG
raph
.
removeVertex
(
vertex
);
g
raph
.
removeVertex
(
vertex
);
this
.
vertex
=
null
;
}
finally
{
atlasG
raph
.
commit
();
g
raph
.
commit
();
}
}
private
AtlasVertex
findByNameInternal
(
String
name
)
{
try
{
String
idxQueryString
=
String
.
format
(
"%s\"%s\":\"%s\""
,
AtlasGraphUtilsV2
.
getIndexSearchPrefix
(),
Constants
.
GUID_PROPERTY_KEY
,
name
);
AtlasIndexQuery
idxQuery
=
atlasGraph
.
indexQuery
(
Constants
.
VERTEX_INDEX
,
idxQueryString
);
Iterator
<
AtlasIndexQuery
.
Result
<
Object
,
Object
>>
results
=
idxQuery
.
vertices
();
AtlasIndexQuery
.
Result
<?,
?>
qryResult
=
results
.
hasNext
()
?
results
.
next
()
:
null
;
if
(
qryResult
!=
null
)
{
return
qryResult
.
getVertex
();
}
else
{
return
null
;
}
return
AtlasGraphUtilsV2
.
findByGuid
(
graph
,
name
);
}
catch
(
Exception
e
)
{
LOG
.
error
(
"MigrationStatusVertexManagement.findByNameInternal: Failed!"
,
e
);
}
finally
{
atlasG
raph
.
commit
();
g
raph
.
commit
();
}
return
null
;
...
...
@@ -190,7 +176,7 @@ public class DataMigrationStatusService {
}
catch
(
Exception
e
)
{
LOG
.
warn
(
"Error updating status. Please rely on log messages."
,
e
);
}
finally
{
atlasG
raph
.
commit
();
g
raph
.
commit
();
}
}
...
...
@@ -200,7 +186,7 @@ public class DataMigrationStatusService {
}
catch
(
Exception
e
)
{
LOG
.
warn
(
"Error updating status. Please rely on log messages."
,
e
);
}
finally
{
atlasG
raph
.
commit
();
g
raph
.
commit
();
}
}
...
...
@@ -219,7 +205,7 @@ public class DataMigrationStatusService {
}
catch
(
Exception
ex
)
{
LOG
.
error
(
"Error updating MigrationImportStatus vertex. Status may not be persisted correctly."
,
ex
);
}
finally
{
atlasG
raph
.
commit
();
g
raph
.
commit
();
}
}
...
...
This diff is collapsed.
Click to expand it.
repository/src/main/java/org/apache/atlas/repository/migration/ZipFileMigrationImporter.java
View file @
f4672292
...
...
@@ -73,8 +73,10 @@ public class ZipFileMigrationImporter implements Runnable {
dataMigrationStatusService
.
setStatus
(
"DONE"
);
}
catch
(
IOException
e
)
{
LOG
.
error
(
"Migration Import: IO Error!"
,
e
);
dataMigrationStatusService
.
setStatus
(
"FAIL"
);
}
catch
(
AtlasBaseException
e
)
{
LOG
.
error
(
"Migration Import: Error!"
,
e
);
dataMigrationStatusService
.
setStatus
(
"FAIL"
);
}
}
...
...
This diff is collapsed.
Click to expand it.
repository/src/test/java/org/apache/atlas/repository/impexp/DataMigrationStatusServiceTest.java
View file @
f4672292
...
...
@@ -68,6 +68,5 @@ public class DataMigrationStatusServiceTest {
dataMigrationStatusService
.
delete
();
assertNull
(
dataMigrationStatusService
.
getStatus
());
assertNull
(
dataMigrationStatusService
.
getByName
(
ret
.
getName
()));
}
}
This diff is collapsed.
Click to expand it.
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