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
4978a9be
Commit
4978a9be
authored
Jan 29, 2015
by
TJBChris
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed JSON output for search and relationshipwalk. Subobjects were not
broken out properly
parent
ebcb1392
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
23 additions
and
19 deletions
+23
-19
DiscoveryService.java
...rg/apache/hadoop/metadata/discovery/DiscoveryService.java
+3
-2
GraphBackedDiscoveryService.java
...adoop/metadata/discovery/GraphBackedDiscoveryService.java
+3
-2
MetadataRepository.java
...apache/hadoop/metadata/repository/MetadataRepository.java
+3
-2
GraphBackedMetadataRepository.java
...adata/repository/graph/GraphBackedMetadataRepository.java
+12
-11
MetadataDiscoveryResource.java
...oop/metadata/web/resources/MetadataDiscoveryResource.java
+2
-2
No files found.
repository/src/main/java/org/apache/hadoop/metadata/discovery/DiscoveryService.java
View file @
4978a9be
...
...
@@ -19,6 +19,7 @@
package
org
.
apache
.
hadoop
.
metadata
.
discovery
;
import
org.apache.hadoop.metadata.MetadataException
;
import
org.codehaus.jettison.json.JSONObject
;
import
java.util.HashMap
;
import
java.util.List
;
...
...
@@ -45,12 +46,12 @@ public interface DiscoveryService {
* @param searchText is plain text
* @param prop is the Vertex property to search.
*/
Map
<
String
,
HashMap
<
String
,
Map
<
String
,
String
>
>>
textSearch
(
String
searchText
,
int
depth
,
String
prop
);
Map
<
String
,
HashMap
<
String
,
JSONObject
>>
textSearch
(
String
searchText
,
int
depth
,
String
prop
);
/**
* Simple graph walker for search interface, which allows following of specific edges only.
* @param edgesToFollow is a comma-separated-list of edges to follow.
*/
Map
<
String
,
HashMap
<
String
,
Map
<
String
,
String
>
>>
relationshipWalk
(
String
guid
,
int
depth
,
String
edgesToFollow
);
Map
<
String
,
HashMap
<
String
,
JSONObject
>>
relationshipWalk
(
String
guid
,
int
depth
,
String
edgesToFollow
);
}
repository/src/main/java/org/apache/hadoop/metadata/discovery/GraphBackedDiscoveryService.java
View file @
4978a9be
...
...
@@ -22,6 +22,7 @@ import com.google.common.base.Preconditions;
import
org.apache.hadoop.metadata.MetadataException
;
import
org.apache.hadoop.metadata.repository.MetadataRepository
;
import
org.codehaus.jettison.json.JSONObject
;
import
javax.inject.Inject
;
...
...
@@ -60,7 +61,7 @@ public class GraphBackedDiscoveryService implements DiscoveryService {
* @param prop is the Vertex property to search.
*/
@Override
public
Map
<
String
,
HashMap
<
String
,
Map
<
String
,
String
>
>>
textSearch
(
String
searchText
,
int
depth
,
String
prop
)
{
public
Map
<
String
,
HashMap
<
String
,
JSONObject
>>
textSearch
(
String
searchText
,
int
depth
,
String
prop
)
{
Preconditions
.
checkNotNull
(
searchText
,
"Invalid argument: \"text\" cannot be null."
);
Preconditions
.
checkNotNull
(
prop
,
"Invalid argument: \"prop\" cannot be null."
);
...
...
@@ -72,7 +73,7 @@ public class GraphBackedDiscoveryService implements DiscoveryService {
* @param edgesToFollow is a comma-separated-list of edges to follow.
*/
@Override
public
Map
<
String
,
HashMap
<
String
,
Map
<
String
,
String
>
>>
relationshipWalk
(
String
guid
,
int
depth
,
String
edgesToFollow
)
{
public
Map
<
String
,
HashMap
<
String
,
JSONObject
>>
relationshipWalk
(
String
guid
,
int
depth
,
String
edgesToFollow
)
{
Preconditions
.
checkNotNull
(
guid
,
"Invalid argument: \"guid\" cannot be null."
);
Preconditions
.
checkNotNull
(
edgesToFollow
,
"Invalid argument: \"edgesToFollow\" cannot be null."
);
...
...
repository/src/main/java/org/apache/hadoop/metadata/repository/MetadataRepository.java
View file @
4978a9be
...
...
@@ -23,6 +23,7 @@ import org.apache.hadoop.metadata.ITypedReferenceableInstance;
import
org.apache.hadoop.metadata.MetadataException
;
import
org.apache.hadoop.metadata.service.Service
;
import
org.apache.hadoop.metadata.storage.RepositoryException
;
import
org.codehaus.jettison.json.JSONObject
;
import
java.util.HashMap
;
import
java.util.List
;
...
...
@@ -56,11 +57,11 @@ public interface MetadataRepository extends Service {
* @param searchText is plain text
* @param prop is the Vertex property to search.
*/
Map
<
String
,
HashMap
<
String
,
Map
<
String
,
String
>
>>
textSearch
(
String
searchText
,
int
depth
,
String
prop
);
Map
<
String
,
HashMap
<
String
,
JSONObject
>>
textSearch
(
String
searchText
,
int
depth
,
String
prop
);
/**
* Simple graph walker for search interface, which allows following of specific edges only.
* @param edgesToFollow is a comma-separated-list of edges to follow.
*/
Map
<
String
,
HashMap
<
String
,
Map
<
String
,
String
>
>>
relationshipWalk
(
String
guid
,
int
depth
,
String
edgesToFollow
);
Map
<
String
,
HashMap
<
String
,
JSONObject
>>
relationshipWalk
(
String
guid
,
int
depth
,
String
edgesToFollow
);
}
repository/src/main/java/org/apache/hadoop/metadata/repository/graph/GraphBackedMetadataRepository.java
View file @
4978a9be
...
...
@@ -47,6 +47,7 @@ import org.apache.hadoop.metadata.types.ObjectGraphWalker;
import
org.apache.hadoop.metadata.types.StructType
;
import
org.apache.hadoop.metadata.types.TraitType
;
import
org.apache.hadoop.metadata.types.TypeSystem
;
import
org.codehaus.jettison.json.JSONObject
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -184,7 +185,7 @@ public class GraphBackedMetadataRepository implements MetadataRepository {
return
entityList
;
}
private
static
void
searchWalker
(
Vertex
vtx
,
final
int
max
,
int
counter
,
HashMap
<
String
,
Map
<
String
,
String
>>
e
,
HashMap
<
String
,
Map
<
String
,
String
>
>
v
,
String
edgesToFollow
)
{
private
static
void
searchWalker
(
Vertex
vtx
,
final
int
max
,
int
counter
,
HashMap
<
String
,
JSONObject
>
e
,
HashMap
<
String
,
JSONObject
>
v
,
String
edgesToFollow
)
{
counter
++;
if
(
counter
<=
max
)
{
...
...
@@ -215,7 +216,7 @@ public class GraphBackedMetadataRepository implements MetadataRepository {
}
// Add to the Vertex map.
v
.
put
(
vtx
.
getId
().
toString
(),
jsonVertexMap
);
v
.
put
(
vtx
.
getId
().
toString
(),
new
JSONObject
(
jsonVertexMap
)
);
// Follow this Vertex's edges
while
(
edgeIterator
!=
null
&&
edgeIterator
.
hasNext
())
{
...
...
@@ -246,7 +247,7 @@ public class GraphBackedMetadataRepository implements MetadataRepository {
}
*/
e
.
put
(
edge
.
getId
().
toString
(),
jsonEdgeMap
);
e
.
put
(
edge
.
getId
().
toString
(),
new
JSONObject
(
jsonEdgeMap
)
);
searchWalker
(
edge
.
getVertex
(
d
),
max
,
counter
,
e
,
v
,
edgesToFollow
);
}
...
...
@@ -263,14 +264,14 @@ public class GraphBackedMetadataRepository implements MetadataRepository {
* @param prop is the Vertex property to search.
*/
@Override
public
Map
<
String
,
HashMap
<
String
,
Map
<
String
,
String
>
>>
textSearch
(
String
searchText
,
int
depth
,
String
prop
)
{
public
Map
<
String
,
HashMap
<
String
,
JSONObject
>>
textSearch
(
String
searchText
,
int
depth
,
String
prop
)
{
HashMap
<
String
,
HashMap
<
String
,
Map
<
String
,
String
>>>
result
=
new
HashMap
<
String
,
HashMap
<
String
,
Map
<
String
,
String
>
>>();
HashMap
<
String
,
HashMap
<
String
,
JSONObject
>>
result
=
new
HashMap
<
String
,
HashMap
<
String
,
JSONObject
>>();
// HashMaps, which contain sub JOSN Objects to be relayed back to the parent.
HashMap
<
String
,
Map
<
String
,
String
>>
vertices
=
new
HashMap
<
String
,
Map
<
String
,
String
>
>();
HashMap
<
String
,
Map
<
String
,
String
>>
edges
=
new
HashMap
<
String
,
Map
<
String
,
String
>
>();
HashMap
<
String
,
JSONObject
>
vertices
=
new
HashMap
<
String
,
JSONObject
>();
HashMap
<
String
,
JSONObject
>
edges
=
new
HashMap
<
String
,
JSONObject
>();
/* Later - when we allow search limitation by "type".
ArrayList<String> typesList = new ArrayList<String>();
...
...
@@ -306,13 +307,13 @@ public class GraphBackedMetadataRepository implements MetadataRepository {
* @param edgesToFollow is a comma-separated-list of edges to follow.
*/
@Override
public
Map
<
String
,
HashMap
<
String
,
Map
<
String
,
String
>
>>
relationshipWalk
(
String
guid
,
int
depth
,
String
edgesToFollow
)
{
public
Map
<
String
,
HashMap
<
String
,
JSONObject
>>
relationshipWalk
(
String
guid
,
int
depth
,
String
edgesToFollow
)
{
HashMap
<
String
,
HashMap
<
String
,
Map
<
String
,
String
>>>
result
=
new
HashMap
<
String
,
HashMap
<
String
,
Map
<
String
,
String
>
>>();
HashMap
<
String
,
HashMap
<
String
,
JSONObject
>>
result
=
new
HashMap
<
String
,
HashMap
<
String
,
JSONObject
>>();
// HashMaps, which contain sub JOSN Objects to be relayed back to the parent.
HashMap
<
String
,
Map
<
String
,
String
>>
vertices
=
new
HashMap
<
String
,
Map
<
String
,
String
>
>();
HashMap
<
String
,
Map
<
String
,
String
>>
edges
=
new
HashMap
<
String
,
Map
<
String
,
String
>
>();
HashMap
<
String
,
JSONObject
>
vertices
=
new
HashMap
<
String
,
JSONObject
>();
HashMap
<
String
,
JSONObject
>
edges
=
new
HashMap
<
String
,
JSONObject
>();
// Get the Vertex with the specified GUID.
Vertex
v
=
GraphHelper
.
findVertexByGUID
(
graphService
.
getBlueprintsGraph
(),
guid
);
...
...
webapp/src/main/java/org/apache/hadoop/metadata/web/resources/MetadataDiscoveryResource.java
View file @
4978a9be
...
...
@@ -135,10 +135,10 @@ public class MetadataDiscoveryResource {
try
{
response
.
put
(
"requestId"
,
Thread
.
currentThread
().
getName
());
if
(
resultMap
.
containsKey
(
"vertices"
))
{
response
.
put
(
"vertices"
,
resultMap
.
get
(
"vertices"
));
response
.
put
(
"vertices"
,
new
JSONObject
(
resultMap
.
get
(
"vertices"
)
));
}
if
(
resultMap
.
containsKey
(
"edges"
))
{
response
.
put
(
"edges"
,
resultMap
.
get
(
"edges"
));
response
.
put
(
"edges"
,
new
JSONObject
(
resultMap
.
get
(
"vertices"
)
));
}
}
catch
(
JSONException
e
)
{
throw
new
WebApplicationException
(
...
...
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