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
dec14a89
Commit
dec14a89
authored
Jan 27, 2015
by
TJBChris
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clenaed up direct vertex retrieval for relationships/lineage API. Added
some additional logging. Added a requestId element to the returned JSON.
parent
d8d9da29
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
17 deletions
+20
-17
MetadataDiscoveryResource.java
...oop/metadata/web/resources/MetadataDiscoveryResource.java
+14
-13
MetadataDiscoveryResourceIT.java
...p/metadata/web/resources/MetadataDiscoveryResourceIT.java
+6
-4
No files found.
webapp/src/main/java/org/apache/hadoop/metadata/web/resources/MetadataDiscoveryResource.java
View file @
dec14a89
...
...
@@ -29,6 +29,7 @@ import com.tinkerpop.blueprints.Vertex;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.hadoop.metadata.MetadataException
;
import
org.apache.hadoop.metadata.discovery.DiscoveryService
;
import
org.apache.hadoop.metadata.repository.graph.GraphHelper
;
import
org.apache.hadoop.metadata.repository.graph.GraphService
;
import
org.apache.hadoop.metadata.types.TypeSystem
;
import
org.apache.hadoop.metadata.web.util.Servlets
;
...
...
@@ -154,18 +155,23 @@ public class MetadataDiscoveryResource {
// Parent JSON Object
JSONObject
response
=
new
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
>>();
// Get the Vertex with the specified GUID.
for
(
Vertex
v:
getGraph
().
query
().
has
(
"guid"
,
guid
).
vertices
())
{
Vertex
v
=
GraphHelper
.
findVertexByGUID
(
getGraph
(),
guid
);
if
(
v
!=
null
)
{
searchWalker
(
v
,
depth
,
0
,
edges
,
vertices
,
edgesToFollow
);
LOG
.
debug
(
"Vertex {} found for guid {}"
,
v
,
guid
);
}
else
{
LOG
.
debug
(
"Vertex not found for guid {}"
,
guid
);
}
try
{
response
.
put
(
"requestId"
,
Thread
.
currentThread
().
getName
());
response
.
put
(
"vertices"
,
vertices
);
response
.
put
(
"edges"
,
edges
);
}
catch
(
JSONException
e
)
{
...
...
@@ -215,13 +221,18 @@ public class MetadataDiscoveryResource {
HashMap
<
String
,
Map
<
String
,
String
>>
vertices
=
new
HashMap
<
String
,
Map
<
String
,
String
>>();
HashMap
<
String
,
Map
<
String
,
String
>>
edges
=
new
HashMap
<
String
,
Map
<
String
,
String
>>();
int
resultCount
=
0
;
for
(
Vertex
v:
getGraph
().
query
().
has
(
prop
,
searchText
).
vertices
())
{
searchWalker
(
v
,
depth
,
0
,
edges
,
vertices
,
null
);
resultCount
++;
}
LOG
.
debug
(
"Search for {} returned {} results."
,
searchText
,
resultCount
);
try
{
response
.
put
(
"requestId"
,
Thread
.
currentThread
().
getName
());
response
.
put
(
"vertices"
,
vertices
);
response
.
put
(
"edges"
,
edges
);
}
catch
(
JSONException
e
)
{
...
...
@@ -305,15 +316,5 @@ public class MetadataDiscoveryResource {
}
private
static
void
validateInputs
(
String
errorMsg
,
String
...
inputs
)
{
for
(
String
input
:
inputs
)
{
if
(
StringUtils
.
isEmpty
(
input
))
{
throw
new
WebApplicationException
(
Response
.
status
(
Response
.
Status
.
BAD_REQUEST
)
.
entity
(
errorMsg
)
.
type
(
"text/plain"
)
.
build
());
}
}
}
}
webapp/src/test/java/org/apache/hadoop/metadata/web/resources/MetadataDiscoveryResourceIT.java
View file @
dec14a89
...
...
@@ -59,18 +59,20 @@ public class MetadataDiscoveryResourceIT extends BaseResourceIT {
}
@Test
(
dependsOnMethods
=
"testUriExists"
,
enabled
=
false
)
public
void
testSearchFor
NonExistent
Text
()
throws
Exception
{
@Test
(
dependsOnMethods
=
"test
FullText
UriExists"
,
enabled
=
false
)
public
void
testSearchForText
()
throws
Exception
{
WebResource
resource
=
service
.
path
(
"api/metadata/discovery/search/fulltext"
)
.
queryParam
(
"depth"
,
"
0"
).
queryParam
(
"text"
,
"foo"
).
queryParam
(
"property"
,
"N
ame"
);
.
queryParam
(
"depth"
,
"
3"
).
queryParam
(
"text"
,
"serde1"
).
queryParam
(
"property"
,
"n
ame"
);
ClientResponse
clientResponse
=
resource
.
accept
(
MediaType
.
APPLICATION_JSON
)
.
type
(
MediaType
.
APPLICATION_JSON
)
.
method
(
HttpMethod
.
GET
,
ClientResponse
.
class
);
System
.
out
.
println
(
clientResponse
.
toString
());
//TODO - Assure zero vertices and edges.
Assert
.
assert
Equals
(
true
,
true
);
Assert
.
assert
NotEquals
(
clientResponse
.
getStatus
(),
Response
.
Status
.
NOT_FOUND
.
getStatusCode
()
);
}
...
...
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