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
d1109efe
Commit
d1109efe
authored
Aug 16, 2019
by
Sarath Subramanian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-3377: Update AtlasPatchRegistry to use graph query instead of index query
parent
2223c82c
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
26 deletions
+24
-26
AtlasPatchRegistry.java
...g/apache/atlas/repository/patches/AtlasPatchRegistry.java
+24
-26
No files found.
repository/src/main/java/org/apache/atlas/repository/patches/AtlasPatchRegistry.java
View file @
d1109efe
...
...
@@ -22,7 +22,9 @@ import org.apache.atlas.RequestContext;
import
org.apache.atlas.model.patches.AtlasPatch
;
import
org.apache.atlas.model.patches.AtlasPatch.AtlasPatches
;
import
org.apache.atlas.model.patches.AtlasPatch.PatchStatus
;
import
org.apache.atlas.repository.Constants
;
import
org.apache.atlas.repository.graphdb.AtlasGraph
;
import
org.apache.atlas.repository.graphdb.AtlasGraphQuery
;
import
org.apache.atlas.repository.graphdb.AtlasIndexQuery
;
import
org.apache.atlas.repository.graphdb.AtlasIndexQuery.Result
;
import
org.apache.atlas.repository.graphdb.AtlasVertex
;
...
...
@@ -45,8 +47,6 @@ import java.util.Map;
import
static
org
.
apache
.
atlas
.
model
.
patches
.
AtlasPatch
.
PatchStatus
.
FAILED
;
import
static
org
.
apache
.
atlas
.
model
.
patches
.
AtlasPatch
.
PatchStatus
.
UNKNOWN
;
import
static
org
.
apache
.
atlas
.
repository
.
Constants
.*;
import
static
org
.
apache
.
atlas
.
repository
.
graph
.
AtlasGraphProvider
.
getGraphInstance
;
import
static
org
.
apache
.
atlas
.
repository
.
store
.
bootstrap
.
AtlasTypeDefStoreInitializer
.
TYPEDEF_PATCH_TYPE
;
import
static
org
.
apache
.
atlas
.
repository
.
store
.
graph
.
v2
.
AtlasGraphUtilsV2
.
getEncodedProperty
;
import
static
org
.
apache
.
atlas
.
repository
.
store
.
graph
.
v2
.
AtlasGraphUtilsV2
.
getIndexSearchPrefix
;
import
static
org
.
apache
.
atlas
.
repository
.
store
.
graph
.
v2
.
AtlasGraphUtilsV2
.
setEncodedProperty
;
...
...
@@ -96,20 +96,20 @@ public class AtlasPatchRegistry {
}
public
void
updateStatus
(
String
patchId
,
PatchStatus
patchStatus
)
{
try
{
AtlasVertex
patchVertex
=
findByPatchId
(
patchId
);
if
(
patchVertex
==
null
)
{
return
;
}
if
(
patchVertex
!=
null
)
{
setEncodedProperty
(
patchVertex
,
PATCH_STATE_PROPERTY_KEY
,
patchStatus
.
toString
());
setEncodedProperty
(
patchVertex
,
MODIFICATION_TIMESTAMP_PROPERTY_KEY
,
RequestContext
.
get
().
getRequestTime
());
setEncodedProperty
(
patchVertex
,
MODIFIED_BY_KEY
,
getCurrentUser
());
setEncodedProperty
(
patchVertex
,
PATCH_STATE_PROPERTY_KEY
,
patchStatus
.
toString
());
}
}
finally
{
graph
.
commit
();
patchNameStatusMap
.
put
(
patchId
,
patchStatus
);
graph
.
commit
();
}
}
private
static
String
getId
(
String
incomingId
,
String
patchFile
,
int
index
)
{
...
...
@@ -128,8 +128,12 @@ public class AtlasPatchRegistry {
private
void
createOrUpdatePatchVertex
(
AtlasGraph
graph
,
String
patchId
,
String
description
,
String
patchType
,
String
action
,
PatchStatus
patchStatus
)
{
boolean
isPatchRegistered
=
MapUtils
.
isNotEmpty
(
patchNameStatusMap
)
&&
patchNameStatusMap
.
containsKey
(
patchId
);
AtlasVertex
patchVertex
=
isPatchRegistered
?
findByPatchId
(
patchId
)
:
graph
.
addVertex
();
try
{
AtlasVertex
patchVertex
=
findByPatchId
(
patchId
);
if
(
patchVertex
==
null
)
{
patchVertex
=
graph
.
addVertex
();
}
setEncodedProperty
(
patchVertex
,
PATCH_ID_PROPERTY_KEY
,
patchId
);
setEncodedProperty
(
patchVertex
,
PATCH_DESCRIPTION_PROPERTY_KEY
,
description
);
...
...
@@ -140,8 +144,11 @@ public class AtlasPatchRegistry {
setEncodedProperty
(
patchVertex
,
MODIFICATION_TIMESTAMP_PROPERTY_KEY
,
RequestContext
.
get
().
getRequestTime
());
setEncodedProperty
(
patchVertex
,
CREATED_BY_KEY
,
AtlasTypeDefGraphStoreV2
.
getCurrentUser
());
setEncodedProperty
(
patchVertex
,
MODIFIED_BY_KEY
,
AtlasTypeDefGraphStoreV2
.
getCurrentUser
());
}
finally
{
graph
.
commit
();
patchNameStatusMap
.
put
(
patchId
,
patchStatus
);
}
}
private
static
Map
<
String
,
PatchStatus
>
getPatchNameStatusForAllRegistered
(
AtlasGraph
graph
)
{
...
...
@@ -180,9 +187,9 @@ public class AtlasPatchRegistry {
}
}
catch
(
Throwable
t
)
{
LOG
.
warn
(
"getAllPatches(): Returned empty result!"
);
}
}
finally
{
graph
.
commit
();
}
return
new
AtlasPatches
(
ret
);
}
...
...
@@ -204,20 +211,11 @@ public class AtlasPatchRegistry {
return
ret
;
}
private
static
AtlasVertex
findByPatchId
(
String
patchId
)
{
AtlasVertex
ret
=
null
;
String
indexQuery
=
getIndexSearchPrefix
()
+
"\""
+
PATCH_ID_PROPERTY_KEY
+
"\" : ("
+
patchId
+
")"
;
Iterator
<
Result
<
Object
,
Object
>>
results
=
getGraphInstance
().
indexQuery
(
VERTEX_INDEX
,
indexQuery
).
vertices
();
public
AtlasVertex
findByPatchId
(
String
patchId
)
{
AtlasGraphQuery
query
=
graph
.
query
().
has
(
Constants
.
PATCH_ID_PROPERTY_KEY
,
patchId
);
Iterator
<
AtlasVertex
>
results
=
query
.
vertices
().
iterator
();
while
(
results
!=
null
&&
results
.
hasNext
())
{
ret
=
results
.
next
().
getVertex
();
if
(
ret
!=
null
)
{
break
;
}
}
return
ret
;
return
results
.
hasNext
()
?
results
.
next
()
:
null
;
}
private
static
PatchStatus
getPatchStatus
(
AtlasVertex
vertex
)
{
...
...
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