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
18981168
Commit
18981168
authored
Feb 02, 2015
by
TJBChris
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added API to return a list of indexed fields. Output is JSON.
parent
7aece73b
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
73 additions
and
0 deletions
+73
-0
DiscoveryService.java
...rg/apache/hadoop/metadata/discovery/DiscoveryService.java
+6
-0
GraphBackedDiscoveryService.java
...adoop/metadata/discovery/GraphBackedDiscoveryService.java
+10
-0
MetadataRepository.java
...apache/hadoop/metadata/repository/MetadataRepository.java
+7
-0
GraphBackedMetadataRepository.java
...adata/repository/graph/GraphBackedMetadataRepository.java
+10
-0
MetadataDiscoveryResource.java
...oop/metadata/web/resources/MetadataDiscoveryResource.java
+27
-0
MetadataDiscoveryResourceIT.java
...p/metadata/web/resources/MetadataDiscoveryResourceIT.java
+13
-0
No files found.
repository/src/main/java/org/apache/hadoop/metadata/discovery/DiscoveryService.java
View file @
18981168
...
...
@@ -24,6 +24,7 @@ import org.codehaus.jettison.json.JSONObject;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
/**
* Metadata discovery service.
...
...
@@ -54,4 +55,9 @@ public interface DiscoveryService {
*/
Map
<
String
,
HashMap
<
String
,
JSONObject
>>
relationshipWalk
(
String
guid
,
int
depth
,
String
edgesToFollow
);
/**
* Return a Set of indexed properties in the graph.
* No parameters.
*/
Set
<
String
>
getGraphIndexedFields
();
}
repository/src/main/java/org/apache/hadoop/metadata/discovery/GraphBackedDiscoveryService.java
View file @
18981168
...
...
@@ -29,6 +29,7 @@ import javax.inject.Inject;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
public
class
GraphBackedDiscoveryService
implements
DiscoveryService
{
...
...
@@ -81,5 +82,14 @@ public class GraphBackedDiscoveryService implements DiscoveryService {
}
/**
* Return a Set of indexed properties in the graph.
* No parameters.
*/
@Override
public
Set
<
String
>
getGraphIndexedFields
()
{
return
repository
.
getGraphIndexedFields
();
}
}
repository/src/main/java/org/apache/hadoop/metadata/repository/MetadataRepository.java
View file @
18981168
...
...
@@ -28,6 +28,7 @@ import org.codehaus.jettison.json.JSONObject;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
/**
* An interface for persisting metadata into a blueprints enabled graph db.
...
...
@@ -64,4 +65,10 @@ public interface MetadataRepository extends Service {
* @param edgesToFollow is a comma-separated-list of edges to follow.
*/
Map
<
String
,
HashMap
<
String
,
JSONObject
>>
relationshipWalk
(
String
guid
,
int
depth
,
String
edgesToFollow
);
/**
* Return a Set of indexed properties in the graph.
* No parameters.
*/
Set
<
String
>
getGraphIndexedFields
();
}
repository/src/main/java/org/apache/hadoop/metadata/repository/graph/GraphBackedMetadataRepository.java
View file @
18981168
...
...
@@ -65,6 +65,7 @@ import java.util.HashMap;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.concurrent.atomic.AtomicInteger
;
/**
...
...
@@ -141,6 +142,15 @@ public class GraphBackedMetadataRepository implements MetadataRepository {
throw
new
RepositoryException
(
e
);
}
}
/**
* Return a Set of indexed properties in the graph.
* No parameters.
*/
@Override
public
Set
<
String
>
getGraphIndexedFields
()
{
return
graphService
.
getIndexableGraph
().
getIndexedKeys
(
Vertex
.
class
);
}
@Override
public
ITypedReferenceableInstance
getEntityDefinition
(
String
guid
)
throws
RepositoryException
{
...
...
webapp/src/main/java/org/apache/hadoop/metadata/web/resources/MetadataDiscoveryResource.java
View file @
18981168
...
...
@@ -189,5 +189,32 @@ public class MetadataDiscoveryResource {
return
Response
.
ok
(
response
).
build
();
}
/**
* Return a list Vertices and Edges in the index.
*
* GET http://host/api/metadata/discovery/getIndexedFields
*
* No parameters taken.
*/
@GET
@Path
(
"/getIndexedFields"
)
@Produces
({
MediaType
.
APPLICATION_JSON
})
public
Response
getLineageResults
()
{
JSONObject
response
=
new
JSONObject
();
try
{
response
.
put
(
"indexed_fields:"
,
discoveryService
.
getGraphIndexedFields
());
}
catch
(
JSONException
e
)
{
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
"Search: Error building JSON result set."
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
}
LOG
.
debug
(
"JSON result:"
+
response
.
toString
());
return
Response
.
ok
(
response
).
build
();
}
}
webapp/src/test/java/org/apache/hadoop/metadata/web/resources/MetadataDiscoveryResourceIT.java
View file @
18981168
...
...
@@ -46,6 +46,19 @@ public class MetadataDiscoveryResourceIT extends BaseResourceIT {
}
@Test
public
void
testGetIndexedProperties
()
throws
Exception
{
WebResource
resource
=
service
.
path
(
"api/metadata/discovery/getIndexedFields"
);
ClientResponse
clientResponse
=
resource
.
accept
(
MediaType
.
APPLICATION_JSON
)
.
type
(
MediaType
.
APPLICATION_JSON
)
.
method
(
HttpMethod
.
GET
,
ClientResponse
.
class
);
Assert
.
assertNotEquals
(
clientResponse
.
getStatus
(),
Response
.
Status
.
NOT_FOUND
.
getStatusCode
());
}
@Test
public
void
testLineageUriExists
()
throws
Exception
{
WebResource
resource
=
service
.
path
(
"api/metadata/discovery/search/relationships/1"
)
...
...
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