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
ab95c1a7
Commit
ab95c1a7
authored
Aug 16, 2016
by
Shwetha GS
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-1119 Add retries for edge label creation (sumasai via shwethags)
parent
bed2a70d
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
225 additions
and
49 deletions
+225
-49
release-log.txt
release-log.txt
+1
-0
DeleteHandler.java
...java/org/apache/atlas/repository/graph/DeleteHandler.java
+4
-4
GraphBackedMetadataRepository.java
...atlas/repository/graph/GraphBackedMetadataRepository.java
+1
-1
GraphHelper.java
...n/java/org/apache/atlas/repository/graph/GraphHelper.java
+89
-35
GraphToTypedInstanceMapper.java
...he/atlas/repository/graph/GraphToTypedInstanceMapper.java
+3
-3
TypedInstanceToGraphMapper.java
...he/atlas/repository/graph/TypedInstanceToGraphMapper.java
+2
-2
GraphBackedTypeStore.java
...ache/atlas/repository/typestore/GraphBackedTypeStore.java
+1
-1
GraphHelperMockTest.java
...rg/apache/atlas/repository/graph/GraphHelperMockTest.java
+121
-0
GraphHelperTest.java
...va/org/apache/atlas/repository/graph/GraphHelperTest.java
+2
-2
GraphBackedTypeStoreTest.java
.../atlas/repository/typestore/GraphBackedTypeStoreTest.java
+1
-1
No files found.
release-log.txt
View file @
ab95c1a7
...
@@ -6,6 +6,7 @@ INCOMPATIBLE CHANGES:
...
@@ -6,6 +6,7 @@ INCOMPATIBLE CHANGES:
ATLAS-1060 Add composite indexes for exact match performance improvements for all attributes (sumasai via shwethags)
ATLAS-1060 Add composite indexes for exact match performance improvements for all attributes (sumasai via shwethags)
ALL CHANGES:
ALL CHANGES:
ATLAS-1119 Add retries for edge label creation (sumasai via shwethags)
ATLAS-1111 Data loss is observed when atlas is restarted while hive_table metadata ingestion into kafka topic is in-progress(shwethags via sumasai)
ATLAS-1111 Data loss is observed when atlas is restarted while hive_table metadata ingestion into kafka topic is in-progress(shwethags via sumasai)
ATLAS-1115 Show Tag / Taxonomy Listing in sorted order (Kalyanikashikar via sumasai)
ATLAS-1115 Show Tag / Taxonomy Listing in sorted order (Kalyanikashikar via sumasai)
ATLAS-1117 Atlas start fails on trunk (jnhagelb via dkantor)
ATLAS-1117 Atlas start fails on trunk (jnhagelb via dkantor)
...
...
repository/src/main/java/org/apache/atlas/repository/graph/DeleteHandler.java
View file @
ab95c1a7
...
@@ -85,7 +85,7 @@ public abstract class DeleteHandler {
...
@@ -85,7 +85,7 @@ public abstract class DeleteHandler {
}
}
// Get GUIDs and vertices for all deletion candidates.
// Get GUIDs and vertices for all deletion candidates.
Set
<
VertexInfo
>
compositeVertices
=
G
raphHelper
.
getCompositeVertices
(
instanceVertex
);
Set
<
VertexInfo
>
compositeVertices
=
g
raphHelper
.
getCompositeVertices
(
instanceVertex
);
// Record all deletion candidate GUIDs in RequestContext
// Record all deletion candidate GUIDs in RequestContext
// and gather deletion candidate vertices.
// and gather deletion candidate vertices.
...
@@ -158,7 +158,7 @@ public abstract class DeleteHandler {
...
@@ -158,7 +158,7 @@ public abstract class DeleteHandler {
DataTypes
.
TypeCategory
elementTypeCategory
=
elementType
.
getTypeCategory
();
DataTypes
.
TypeCategory
elementTypeCategory
=
elementType
.
getTypeCategory
();
if
(
elementTypeCategory
==
DataTypes
.
TypeCategory
.
STRUCT
||
if
(
elementTypeCategory
==
DataTypes
.
TypeCategory
.
STRUCT
||
elementTypeCategory
==
DataTypes
.
TypeCategory
.
CLASS
)
{
elementTypeCategory
==
DataTypes
.
TypeCategory
.
CLASS
)
{
Iterator
<
Edge
>
edges
=
G
raphHelper
.
getOutGoingEdgesByLabel
(
instanceVertex
,
edgeLabel
);
Iterator
<
Edge
>
edges
=
g
raphHelper
.
getOutGoingEdgesByLabel
(
instanceVertex
,
edgeLabel
);
if
(
edges
!=
null
)
{
if
(
edges
!=
null
)
{
while
(
edges
.
hasNext
())
{
while
(
edges
.
hasNext
())
{
Edge
edge
=
edges
.
next
();
Edge
edge
=
edges
.
next
();
...
@@ -228,7 +228,7 @@ public abstract class DeleteHandler {
...
@@ -228,7 +228,7 @@ public abstract class DeleteHandler {
public
void
deleteEdgeReference
(
Vertex
outVertex
,
String
edgeLabel
,
DataTypes
.
TypeCategory
typeCategory
,
public
void
deleteEdgeReference
(
Vertex
outVertex
,
String
edgeLabel
,
DataTypes
.
TypeCategory
typeCategory
,
boolean
isComposite
)
throws
AtlasException
{
boolean
isComposite
)
throws
AtlasException
{
Edge
edge
=
G
raphHelper
.
getEdgeForLabel
(
outVertex
,
edgeLabel
);
Edge
edge
=
g
raphHelper
.
getEdgeForLabel
(
outVertex
,
edgeLabel
);
if
(
edge
!=
null
)
{
if
(
edge
!=
null
)
{
deleteEdgeReference
(
edge
,
typeCategory
,
isComposite
,
false
);
deleteEdgeReference
(
edge
,
typeCategory
,
isComposite
,
false
);
}
}
...
@@ -295,7 +295,7 @@ public abstract class DeleteHandler {
...
@@ -295,7 +295,7 @@ public abstract class DeleteHandler {
case
CLASS:
case
CLASS:
//If its class attribute, its the only edge between two vertices
//If its class attribute, its the only edge between two vertices
if
(
attributeInfo
.
multiplicity
.
nullAllowed
())
{
if
(
attributeInfo
.
multiplicity
.
nullAllowed
())
{
edge
=
G
raphHelper
.
getEdgeForLabel
(
outVertex
,
edgeLabel
);
edge
=
g
raphHelper
.
getEdgeForLabel
(
outVertex
,
edgeLabel
);
if
(
shouldUpdateReverseAttribute
)
{
if
(
shouldUpdateReverseAttribute
)
{
GraphHelper
.
setProperty
(
outVertex
,
propertyName
,
null
);
GraphHelper
.
setProperty
(
outVertex
,
propertyName
,
null
);
}
}
...
...
repository/src/main/java/org/apache/atlas/repository/graph/GraphBackedMetadataRepository.java
View file @
ab95c1a7
...
@@ -267,7 +267,7 @@ public class GraphBackedMetadataRepository implements MetadataRepository {
...
@@ -267,7 +267,7 @@ public class GraphBackedMetadataRepository implements MetadataRepository {
try
{
try
{
final
String
entityTypeName
=
GraphHelper
.
getTypeName
(
instanceVertex
);
final
String
entityTypeName
=
GraphHelper
.
getTypeName
(
instanceVertex
);
String
relationshipLabel
=
GraphHelper
.
getTraitLabel
(
entityTypeName
,
traitNameToBeDeleted
);
String
relationshipLabel
=
GraphHelper
.
getTraitLabel
(
entityTypeName
,
traitNameToBeDeleted
);
Edge
edge
=
G
raphHelper
.
getEdgeForLabel
(
instanceVertex
,
relationshipLabel
);
Edge
edge
=
g
raphHelper
.
getEdgeForLabel
(
instanceVertex
,
relationshipLabel
);
if
(
edge
!=
null
)
{
if
(
edge
!=
null
)
{
deleteHandler
.
deleteEdgeReference
(
edge
,
DataTypes
.
TypeCategory
.
TRAIT
,
false
,
true
);
deleteHandler
.
deleteEdgeReference
(
edge
,
DataTypes
.
TypeCategory
.
TRAIT
,
false
,
true
);
...
...
repository/src/main/java/org/apache/atlas/repository/graph/GraphHelper.java
View file @
ab95c1a7
This diff is collapsed.
Click to expand it.
repository/src/main/java/org/apache/atlas/repository/graph/GraphToTypedInstanceMapper.java
View file @
ab95c1a7
...
@@ -163,7 +163,7 @@ public final class GraphToTypedInstanceMapper {
...
@@ -163,7 +163,7 @@ public final class GraphToTypedInstanceMapper {
Edge
edge
;
Edge
edge
;
if
(
edgeId
==
null
)
{
if
(
edgeId
==
null
)
{
edge
=
G
raphHelper
.
getEdgeForLabel
(
instanceVertex
,
relationshipLabel
);
edge
=
g
raphHelper
.
getEdgeForLabel
(
instanceVertex
,
relationshipLabel
);
}
else
{
}
else
{
edge
=
graphHelper
.
getEdgeByEdgeId
(
instanceVertex
,
relationshipLabel
,
edgeId
);
edge
=
graphHelper
.
getEdgeByEdgeId
(
instanceVertex
,
relationshipLabel
,
edgeId
);
}
}
...
@@ -269,7 +269,7 @@ public final class GraphToTypedInstanceMapper {
...
@@ -269,7 +269,7 @@ public final class GraphToTypedInstanceMapper {
Edge
edge
;
Edge
edge
;
if
(
edgeId
==
null
)
{
if
(
edgeId
==
null
)
{
edge
=
G
raphHelper
.
getEdgeForLabel
(
instanceVertex
,
relationshipLabel
);
edge
=
g
raphHelper
.
getEdgeForLabel
(
instanceVertex
,
relationshipLabel
);
}
else
{
}
else
{
edge
=
graphHelper
.
getEdgeByEdgeId
(
instanceVertex
,
relationshipLabel
,
edgeId
);
edge
=
graphHelper
.
getEdgeByEdgeId
(
instanceVertex
,
relationshipLabel
,
edgeId
);
}
}
...
@@ -296,7 +296,7 @@ public final class GraphToTypedInstanceMapper {
...
@@ -296,7 +296,7 @@ public final class GraphToTypedInstanceMapper {
TraitType
traitType
,
ITypedStruct
traitInstance
)
throws
AtlasException
{
TraitType
traitType
,
ITypedStruct
traitInstance
)
throws
AtlasException
{
String
relationshipLabel
=
GraphHelper
.
getTraitLabel
(
typedInstanceTypeName
,
traitName
);
String
relationshipLabel
=
GraphHelper
.
getTraitLabel
(
typedInstanceTypeName
,
traitName
);
LOG
.
debug
(
"Finding edge for {} -> label {} "
,
instanceVertex
,
relationshipLabel
);
LOG
.
debug
(
"Finding edge for {} -> label {} "
,
instanceVertex
,
relationshipLabel
);
Iterator
<
Edge
>
edgeIterator
=
G
raphHelper
.
getOutGoingEdgesByLabel
(
instanceVertex
,
relationshipLabel
);
Iterator
<
Edge
>
edgeIterator
=
g
raphHelper
.
getOutGoingEdgesByLabel
(
instanceVertex
,
relationshipLabel
);
while
(
edgeIterator
.
hasNext
())
{
while
(
edgeIterator
.
hasNext
())
{
Edge
edge
=
edgeIterator
.
next
();
Edge
edge
=
edgeIterator
.
next
();
final
Vertex
traitInstanceVertex
=
edge
.
getVertex
(
Direction
.
IN
);
final
Vertex
traitInstanceVertex
=
edge
.
getVertex
(
Direction
.
IN
);
...
...
repository/src/main/java/org/apache/atlas/repository/graph/TypedInstanceToGraphMapper.java
View file @
ab95c1a7
...
@@ -211,9 +211,9 @@ public final class TypedInstanceToGraphMapper {
...
@@ -211,9 +211,9 @@ public final class TypedInstanceToGraphMapper {
case
STRUCT:
case
STRUCT:
case
CLASS:
case
CLASS:
String
edgeLabel
=
G
raphHelper
.
getEdgeLabel
(
typedInstance
,
attributeInfo
);
String
edgeLabel
=
g
raphHelper
.
getEdgeLabel
(
typedInstance
,
attributeInfo
);
Edge
currentEdge
=
G
raphHelper
.
getEdgeForLabel
(
instanceVertex
,
edgeLabel
);
Edge
currentEdge
=
g
raphHelper
.
getEdgeForLabel
(
instanceVertex
,
edgeLabel
);
String
newEdgeId
=
addOrUpdateReference
(
instanceVertex
,
attributeInfo
,
attributeInfo
.
dataType
(),
String
newEdgeId
=
addOrUpdateReference
(
instanceVertex
,
attributeInfo
,
attributeInfo
.
dataType
(),
attrValue
,
currentEdge
,
edgeLabel
,
operation
);
attrValue
,
currentEdge
,
edgeLabel
,
operation
);
...
...
repository/src/main/java/org/apache/atlas/repository/typestore/GraphBackedTypeStore.java
View file @
ab95c1a7
...
@@ -282,7 +282,7 @@ public class GraphBackedTypeStore implements ITypeStore {
...
@@ -282,7 +282,7 @@ public class GraphBackedTypeStore implements ITypeStore {
private
ImmutableSet
<
String
>
getSuperTypes
(
Vertex
vertex
)
{
private
ImmutableSet
<
String
>
getSuperTypes
(
Vertex
vertex
)
{
Set
<
String
>
superTypes
=
new
HashSet
<>();
Set
<
String
>
superTypes
=
new
HashSet
<>();
Iterator
<
Edge
>
edges
=
G
raphHelper
.
getOutGoingEdgesByLabel
(
vertex
,
SUPERTYPE_EDGE_LABEL
);
Iterator
<
Edge
>
edges
=
g
raphHelper
.
getOutGoingEdgesByLabel
(
vertex
,
SUPERTYPE_EDGE_LABEL
);
while
(
edges
.
hasNext
())
{
while
(
edges
.
hasNext
())
{
Edge
edge
=
edges
.
next
();
Edge
edge
=
edges
.
next
();
superTypes
.
add
((
String
)
edge
.
getVertex
(
Direction
.
IN
).
getProperty
(
Constants
.
TYPENAME_PROPERTY_KEY
));
superTypes
.
add
((
String
)
edge
.
getVertex
(
Direction
.
IN
).
getProperty
(
Constants
.
TYPENAME_PROPERTY_KEY
));
...
...
repository/src/test/java/org/apache/atlas/repository/graph/GraphHelperMockTest.java
0 → 100644
View file @
ab95c1a7
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
apache
.
atlas
.
repository
.
graph
;
import
com.thinkaurelius.titan.core.TitanGraph
;
import
com.thinkaurelius.titan.core.TitanVertex
;
import
com.tinkerpop.blueprints.Direction
;
import
com.tinkerpop.blueprints.Edge
;
import
org.apache.atlas.repository.RepositoryException
;
import
org.mockito.MockitoAnnotations
;
import
org.testng.annotations.BeforeClass
;
import
org.testng.annotations.Test
;
import
java.util.Iterator
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
when
;
import
static
org
.
testng
.
Assert
.
assertEquals
;
public
class
GraphHelperMockTest
{
private
GraphHelper
graphHelperInstance
;
private
TitanGraph
graph
;
@BeforeClass
public
void
setup
()
{
MockitoAnnotations
.
initMocks
(
this
);
graph
=
mock
(
TitanGraph
.
class
);
graphHelperInstance
=
GraphHelper
.
getInstance
(
graph
);
}
@Test
(
expectedExceptions
=
RepositoryException
.
class
)
public
void
testGetOrCreateEdgeLabelWithMaxRetries
()
throws
Exception
{
final
String
edgeLabel
=
"testLabel"
;
TitanVertex
v1
=
mock
(
TitanVertex
.
class
);
TitanVertex
v2
=
mock
(
TitanVertex
.
class
);
Iterable
noEdgesIterable
=
new
Iterable
<
Edge
>()
{
@Override
public
Iterator
<
Edge
>
iterator
()
{
return
new
Iterator
<
Edge
>()
{
@Override
public
boolean
hasNext
()
{
return
false
;
}
@Override
public
Edge
next
()
{
return
null
;
}
@Override
public
void
remove
()
{
}
};
}
};
when
(
v2
.
getEdges
(
Direction
.
IN
)).
thenReturn
(
noEdgesIterable
);
when
(
v1
.
getEdges
(
Direction
.
OUT
)).
thenReturn
(
noEdgesIterable
);
when
(
v1
.
getId
()).
thenReturn
(
new
String
(
"1234"
));
when
(
v2
.
getId
()).
thenReturn
(
new
String
(
"5678"
));
when
(
graph
.
addEdge
(
null
,
v1
,
v2
,
edgeLabel
)).
thenThrow
(
new
RuntimeException
(
"Unique property constraint violated"
));
graphHelperInstance
.
getOrCreateEdge
(
v1
,
v2
,
edgeLabel
);
}
@Test
public
void
testGetOrCreateEdgeLabelWithRetries
()
throws
Exception
{
final
String
edgeLabel
=
"testLabel"
;
TitanVertex
v1
=
mock
(
TitanVertex
.
class
);
TitanVertex
v2
=
mock
(
TitanVertex
.
class
);
Edge
edge
=
mock
(
Edge
.
class
);
Iterable
noEdgesIterable
=
new
Iterable
<
Edge
>()
{
@Override
public
Iterator
<
Edge
>
iterator
()
{
return
new
Iterator
<
Edge
>()
{
@Override
public
boolean
hasNext
()
{
return
false
;
}
@Override
public
Edge
next
()
{
return
null
;
}
@Override
public
void
remove
()
{
}
};
}
};
when
(
v2
.
getEdges
(
Direction
.
IN
)).
thenReturn
(
noEdgesIterable
);
when
(
v1
.
getEdges
(
Direction
.
OUT
)).
thenReturn
(
noEdgesIterable
);
when
(
v1
.
getId
()).
thenReturn
(
new
String
(
"v1"
));
when
(
v2
.
getId
()).
thenReturn
(
new
String
(
"v2"
));
when
(
edge
.
getId
()).
thenReturn
(
new
String
(
"edge"
));
when
(
graph
.
addEdge
(
null
,
v1
,
v2
,
edgeLabel
))
.
thenThrow
(
new
RuntimeException
(
"Unique property constraint violated"
)).
thenReturn
(
edge
);
Edge
redge
=
graphHelperInstance
.
getOrCreateEdge
(
v1
,
v2
,
edgeLabel
);
assertEquals
(
edge
,
redge
);
}
}
repository/src/test/java/org/apache/atlas/repository/graph/GraphHelperTest.java
View file @
ab95c1a7
...
@@ -117,7 +117,7 @@ public class GraphHelperTest {
...
@@ -117,7 +117,7 @@ public class GraphHelperTest {
}
}
}
}
Vertex
deptVertex
=
GraphHelper
.
getInstance
().
getVertexForGUID
(
deptGuid
);
Vertex
deptVertex
=
GraphHelper
.
getInstance
().
getVertexForGUID
(
deptGuid
);
Set
<
VertexInfo
>
compositeVertices
=
GraphHelper
.
getCompositeVertices
(
deptVertex
);
Set
<
VertexInfo
>
compositeVertices
=
GraphHelper
.
get
Instance
().
get
CompositeVertices
(
deptVertex
);
HashMap
<
String
,
VertexInfo
>
verticesByGuid
=
new
HashMap
<>();
HashMap
<
String
,
VertexInfo
>
verticesByGuid
=
new
HashMap
<>();
for
(
VertexInfo
vertexInfo:
compositeVertices
)
{
for
(
VertexInfo
vertexInfo:
compositeVertices
)
{
verticesByGuid
.
put
(
vertexInfo
.
getGuid
(),
vertexInfo
);
verticesByGuid
.
put
(
vertexInfo
.
getGuid
(),
vertexInfo
);
...
@@ -148,7 +148,7 @@ public class GraphHelperTest {
...
@@ -148,7 +148,7 @@ public class GraphHelperTest {
v1
.
addEdge
(
"l1"
,
v2
);
v1
.
addEdge
(
"l1"
,
v2
);
v1
.
addEdge
(
"l2"
,
v2
);
v1
.
addEdge
(
"l2"
,
v2
);
Iterator
<
Edge
>
iterator
=
GraphHelper
.
getOutGoingEdgesByLabel
(
v1
,
"l1"
);
Iterator
<
Edge
>
iterator
=
GraphHelper
.
get
Instance
().
get
OutGoingEdgesByLabel
(
v1
,
"l1"
);
assertTrue
(
iterator
.
hasNext
());
assertTrue
(
iterator
.
hasNext
());
assertTrue
(
iterator
.
hasNext
());
assertTrue
(
iterator
.
hasNext
());
assertNotNull
(
iterator
.
next
());
assertNotNull
(
iterator
.
next
());
...
...
repository/src/test/java/org/apache/atlas/repository/typestore/GraphBackedTypeStoreTest.java
View file @
ab95c1a7
...
@@ -223,7 +223,7 @@ public class GraphBackedTypeStoreTest {
...
@@ -223,7 +223,7 @@ public class GraphBackedTypeStoreTest {
private
int
countOutgoingEdges
(
Vertex
typeVertex
,
String
edgeLabel
)
{
private
int
countOutgoingEdges
(
Vertex
typeVertex
,
String
edgeLabel
)
{
Iterator
<
Edge
>
outGoingEdgesByLabel
=
GraphHelper
.
getOutGoingEdgesByLabel
(
typeVertex
,
edgeLabel
);
Iterator
<
Edge
>
outGoingEdgesByLabel
=
GraphHelper
.
get
Instance
().
get
OutGoingEdgesByLabel
(
typeVertex
,
edgeLabel
);
int
edgeCount
=
0
;
int
edgeCount
=
0
;
for
(
Iterator
<
Edge
>
iterator
=
outGoingEdgesByLabel
;
iterator
.
hasNext
();)
{
for
(
Iterator
<
Edge
>
iterator
=
outGoingEdgesByLabel
;
iterator
.
hasNext
();)
{
iterator
.
next
();
iterator
.
next
();
...
...
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