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
529ebcf8
Commit
529ebcf8
authored
May 23, 2015
by
Suma S
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #97 from hortonworks/master
Merging from master to DAL
parents
6e9dbbe8
c00f8de6
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
66 additions
and
18 deletions
+66
-18
MetadataServiceClient.java
...ava/org/apache/hadoop/metadata/MetadataServiceClient.java
+4
-0
pom.xml
pom.xml
+1
-1
DefaultGraphPersistenceStrategy.java
...data/discovery/graph/DefaultGraphPersistenceStrategy.java
+5
-1
GraphBackedDiscoveryService.java
...metadata/discovery/graph/GraphBackedDiscoveryService.java
+5
-2
Constants.java
...java/org/apache/hadoop/metadata/repository/Constants.java
+12
-9
MetadataRepository.java
...apache/hadoop/metadata/repository/MetadataRepository.java
+2
-1
GraphBackedMetadataRepository.java
...adata/repository/graph/GraphBackedMetadataRepository.java
+2
-2
GremlinQuery.scala
...scala/org/apache/hadoop/metadata/query/GremlinQuery.scala
+8
-2
GraphBackedMetadataRepositoryTest.java
...a/repository/graph/GraphBackedMetadataRepositoryTest.java
+27
-0
No files found.
client/src/main/java/org/apache/hadoop/metadata/MetadataServiceClient.java
View file @
529ebcf8
...
...
@@ -50,6 +50,9 @@ public class MetadataServiceClient {
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
MetadataServiceClient
.
class
);
public
static
final
String
NAME
=
"name"
;
public
static
final
String
GUID
=
"GUID"
;
public
static
final
String
TYPENAME
=
"typeName"
;
public
static
final
String
DEFINITION
=
"definition"
;
public
static
final
String
ERROR
=
"error"
;
public
static
final
String
REQUEST_ID
=
"requestId"
;
...
...
@@ -82,6 +85,7 @@ public class MetadataServiceClient {
}
catch
(
Exception
e
)
{
LOG
.
info
(
"Error processing client configuration."
,
e
);
}
URLConnectionClientHandler
handler
=
SecureClientUtils
.
getClientConnectionHandler
(
config
,
clientConfig
);
Client
client
=
new
Client
(
handler
,
config
);
...
...
pom.xml
View file @
529ebcf8
...
...
@@ -78,7 +78,7 @@
<slf4j.version>
1.7.7
</slf4j.version>
<jetty.version>
6.1.26
</jetty.version>
<jersey.version>
1.9
</jersey.version>
<tinkerpop.version>
2.
5
.0
</tinkerpop.version>
<tinkerpop.version>
2.
6
.0
</tinkerpop.version>
<titan.version>
0.5.4
</titan.version>
<hadoop.version>
2.6.0
</hadoop.version>
...
...
repository/src/main/java/org/apache/hadoop/metadata/discovery/graph/DefaultGraphPersistenceStrategy.java
View file @
529ebcf8
...
...
@@ -71,7 +71,11 @@ public class DefaultGraphPersistenceStrategy implements GraphPersistenceStrategi
@Override
public
String
fieldNameInVertex
(
IDataType
<?>
dataType
,
AttributeInfo
aInfo
)
{
return
metadataRepository
.
getFieldNameInVertex
(
dataType
,
aInfo
);
try
{
return
metadataRepository
.
getFieldNameInVertex
(
dataType
,
aInfo
);
}
catch
(
MetadataException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
@Override
...
...
repository/src/main/java/org/apache/hadoop/metadata/discovery/graph/GraphBackedDiscoveryService.java
View file @
529ebcf8
...
...
@@ -23,6 +23,7 @@ import com.thinkaurelius.titan.core.TitanIndexQuery;
import
com.thinkaurelius.titan.core.TitanProperty
;
import
com.thinkaurelius.titan.core.TitanVertex
;
import
com.tinkerpop.blueprints.Vertex
;
import
org.apache.hadoop.metadata.MetadataServiceClient
;
import
org.apache.hadoop.metadata.discovery.DiscoveryException
;
import
org.apache.hadoop.metadata.discovery.DiscoveryService
;
import
org.apache.hadoop.metadata.query.Expressions
;
...
...
@@ -66,6 +67,8 @@ public class GraphBackedDiscoveryService implements DiscoveryService {
private
final
TitanGraph
titanGraph
;
private
final
DefaultGraphPersistenceStrategy
graphPersistenceStrategy
;
public
final
static
String
SCORE
=
"score"
;
@Inject
GraphBackedDiscoveryService
(
GraphProvider
<
TitanGraph
>
graphProvider
,
MetadataRepository
metadataRepository
)
throws
DiscoveryException
{
...
...
@@ -93,8 +96,8 @@ public class GraphBackedDiscoveryService implements DiscoveryService {
if
(
guid
!=
null
)
{
//Filter non-class entities
try
{
row
.
put
(
"guid"
,
guid
);
row
.
put
(
"typeName"
,
vertex
.<
String
>
getProperty
(
Constants
.
ENTITY_TYPE_PROPERTY_KEY
));
row
.
put
(
"score"
,
result
.
getScore
());
row
.
put
(
MetadataServiceClient
.
TYPENAME
,
vertex
.<
String
>
getProperty
(
Constants
.
ENTITY_TYPE_PROPERTY_KEY
));
row
.
put
(
SCORE
,
result
.
getScore
());
}
catch
(
JSONException
e
)
{
LOG
.
error
(
"Unable to create response"
,
e
);
throw
new
DiscoveryException
(
"Unable to create response"
);
...
...
repository/src/main/java/org/apache/hadoop/metadata/repository/Constants.java
View file @
529ebcf8
...
...
@@ -23,41 +23,44 @@ public final class Constants {
/**
* Globally Unique identifier property key.
*/
public
static
final
String
GUID_PROPERTY_KEY
=
"guid"
;
public
static
final
String
INTERNAL_PROPERTY_KEY_PREFIX
=
"__"
;
public
static
final
String
GUID_PROPERTY_KEY
=
INTERNAL_PROPERTY_KEY_PREFIX
+
"guid"
;
public
static
final
String
GUID_INDEX
=
"guid_index"
;
/**
* Entity type name property key.
*/
public
static
final
String
ENTITY_TYPE_PROPERTY_KEY
=
"typeName"
;
public
static
final
String
ENTITY_TYPE_PROPERTY_KEY
=
INTERNAL_PROPERTY_KEY_PREFIX
+
"typeName"
;
public
static
final
String
ENTITY_TYPE_INDEX
=
"type_index"
;
/**
* Entity type's super types property key.
*/
public
static
final
String
SUPER_TYPES_PROPERTY_KEY
=
"superTypeNames"
;
public
static
final
String
SUPER_TYPES_PROPERTY_KEY
=
INTERNAL_PROPERTY_KEY_PREFIX
+
"superTypeNames"
;
public
static
final
String
SUPER_TYPES_INDEX
=
"super_types_index"
;
/**
* Full-text for the entity for enabling full-text search.
*/
//weird issue in TitanDB if __ added to this property key. Not adding it for now
public
static
final
String
ENTITY_TEXT_PROPERTY_KEY
=
"entityText"
;
/**
* Properties for type store graph
*/
public
static
final
String
TYPE_CATEGORY_PROPERTY_KEY
=
"type.category"
;
public
static
final
String
VERTEX_TYPE_PROPERTY_KEY
=
"type"
;
public
static
final
String
TYPENAME_PROPERTY_KEY
=
"type.name"
;
public
static
final
String
TYPE_CATEGORY_PROPERTY_KEY
=
INTERNAL_PROPERTY_KEY_PREFIX
+
"type.category"
;
public
static
final
String
VERTEX_TYPE_PROPERTY_KEY
=
INTERNAL_PROPERTY_KEY_PREFIX
+
"type"
;
public
static
final
String
TYPENAME_PROPERTY_KEY
=
INTERNAL_PROPERTY_KEY_PREFIX
+
"type.name"
;
/**
* Trait names property key and index name.
*/
public
static
final
String
TRAIT_NAMES_PROPERTY_KEY
=
"traitNames"
;
public
static
final
String
TRAIT_NAMES_PROPERTY_KEY
=
INTERNAL_PROPERTY_KEY_PREFIX
+
"traitNames"
;
public
static
final
String
TRAIT_NAMES_INDEX
=
"trait_names_index"
;
public
static
final
String
VERSION_PROPERTY_KEY
=
"version"
;
public
static
final
String
TIMESTAMP_PROPERTY_KEY
=
"timestamp"
;
public
static
final
String
VERSION_PROPERTY_KEY
=
INTERNAL_PROPERTY_KEY_PREFIX
+
"version"
;
public
static
final
String
TIMESTAMP_PROPERTY_KEY
=
INTERNAL_PROPERTY_KEY_PREFIX
+
"timestamp"
;
/**
* search backing index name.
...
...
repository/src/main/java/org/apache/hadoop/metadata/repository/MetadataRepository.java
View file @
529ebcf8
...
...
@@ -18,6 +18,7 @@
package
org
.
apache
.
hadoop
.
metadata
.
repository
;
import
org.apache.hadoop.metadata.MetadataException
;
import
org.apache.hadoop.metadata.typesystem.IReferenceableInstance
;
import
org.apache.hadoop.metadata.typesystem.ITypedReferenceableInstance
;
import
org.apache.hadoop.metadata.typesystem.ITypedStruct
;
...
...
@@ -61,7 +62,7 @@ public interface MetadataRepository {
* @param aInfo attribute info
* @return property key used to store a given attribute
*/
String
getFieldNameInVertex
(
IDataType
<?>
dataType
,
AttributeInfo
aInfo
);
String
getFieldNameInVertex
(
IDataType
<?>
dataType
,
AttributeInfo
aInfo
)
throws
MetadataException
;
/**
* Return the edge label for a given attribute in the repository.
...
...
repository/src/main/java/org/apache/hadoop/metadata/repository/graph/GraphBackedMetadataRepository.java
View file @
529ebcf8
...
...
@@ -122,8 +122,8 @@ public class GraphBackedMetadataRepository implements MetadataRepository {
}
@Override
public
String
getFieldNameInVertex
(
IDataType
<?>
dataType
,
AttributeInfo
aInfo
)
{
return
dataType
.
getName
()
+
"."
+
aInfo
.
name
;
public
String
getFieldNameInVertex
(
IDataType
<?>
dataType
,
AttributeInfo
aInfo
)
throws
MetadataException
{
return
getQualifiedName
(
dataType
,
aInfo
.
name
)
;
}
@Override
...
...
repository/src/main/scala/org/apache/hadoop/metadata/query/GremlinQuery.scala
View file @
529ebcf8
...
...
@@ -184,8 +184,14 @@ class GremlinTranslator(expr: Expression,
}
private
def
genQuery
(
expr
:
Expression
,
inSelect
:
Boolean
)
:
String
=
expr
match
{
case
ClassExpression
(
clsName
)
=>
s
"""has("${gPersistenceBehavior.typeAttributeName}","$clsName")"""
case
TraitExpression
(
clsName
)
=>
s
"""has("${gPersistenceBehavior.typeAttributeName}","$clsName")"""
case
ClassExpression
(
clsName
)
=>
val
typeName
=
gPersistenceBehavior
.
typeAttributeName
val
superTypeName
=
gPersistenceBehavior
.
superTypeAttributeName
s
"""filter{(it.$typeName == "$clsName") | (it.$superTypeName ? it.$superTypeName.contains("$clsName") : false)}"""
case
TraitExpression
(
clsName
)
=>
val
typeName
=
gPersistenceBehavior
.
typeAttributeName
val
superTypeName
=
gPersistenceBehavior
.
superTypeAttributeName
s
"""filter{(it.$typeName == "$clsName") | (it.$superTypeName ? it.$superTypeName.contains("$clsName") : false)}"""
case
fe
@FieldExpression
(
fieldName
,
fInfo
,
child
)
if
fe
.
dataType
.
getTypeCategory
==
TypeCategory
.
PRIMITIVE
=>
{
val
fN
=
"\""
+
gPersistenceBehavior
.
fieldNameInVertex
(
fInfo
.
dataType
,
fInfo
.
attrInfo
)
+
"\""
child
match
{
...
...
repository/src/test/java/org/apache/hadoop/metadata/repository/graph/GraphBackedMetadataRepositoryTest.java
View file @
529ebcf8
...
...
@@ -349,6 +349,33 @@ public class GraphBackedMetadataRepositoryTest {
}
}
@Test
(
dependsOnMethods
=
"testSubmitEntity"
)
public
void
testSearchByDSLWithInheritance
()
throws
Exception
{
String
dslQuery
=
"Person where name = 'Jane'"
;
System
.
out
.
println
(
"Executing dslQuery = "
+
dslQuery
);
String
jsonResults
=
discoveryService
.
searchByDSL
(
dslQuery
);
Assert
.
assertNotNull
(
jsonResults
);
JSONObject
results
=
new
JSONObject
(
jsonResults
);
Assert
.
assertEquals
(
results
.
length
(),
3
);
System
.
out
.
println
(
"results = "
+
results
);
Object
query
=
results
.
get
(
"query"
);
Assert
.
assertNotNull
(
query
);
JSONObject
dataType
=
results
.
getJSONObject
(
"dataType"
);
Assert
.
assertNotNull
(
dataType
);
String
typeName
=
dataType
.
getString
(
"typeName"
);
Assert
.
assertEquals
(
typeName
,
"Person"
);
JSONArray
rows
=
results
.
getJSONArray
(
"rows"
);
Assert
.
assertEquals
(
rows
.
length
(),
1
);
JSONObject
row
=
rows
.
getJSONObject
(
0
);
Assert
.
assertEquals
(
row
.
getString
(
"$typeName$"
),
"Manager"
);
Assert
.
assertEquals
(
row
.
getString
(
"name"
),
"Jane"
);
}
/**
* Full text search requires GraphBackedSearchIndexer, and GraphBackedSearchIndexer can't be enabled in
* GraphBackedDiscoveryServiceTest because of its test data. So, test for full text search is in
...
...
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