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
e013e656
Commit
e013e656
authored
May 20, 2015
by
Suma Shivaprasad
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed all review comments
parent
1a536c2a
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
17 deletions
+16
-17
MetadataServiceClient.java
...ava/org/apache/hadoop/metadata/MetadataServiceClient.java
+13
-10
DefaultMetadataService.java
...ache/hadoop/metadata/services/DefaultMetadataService.java
+2
-1
EntityResource.java
.../apache/hadoop/metadata/web/resources/EntityResource.java
+1
-5
TypesResource.java
...g/apache/hadoop/metadata/web/resources/TypesResource.java
+0
-1
No files found.
client/src/main/java/org/apache/hadoop/metadata/MetadataServiceClient.java
View file @
e013e656
...
...
@@ -29,6 +29,7 @@ import org.apache.hadoop.metadata.typesystem.ITypedReferenceableInstance;
import
org.apache.hadoop.metadata.typesystem.Referenceable
;
import
org.apache.hadoop.metadata.typesystem.json.InstanceSerialization
;
import
org.apache.hadoop.metadata.typesystem.json.Serialization
;
import
org.apache.http.protocol.HTTP
;
import
org.codehaus.jettison.json.JSONArray
;
import
org.codehaus.jettison.json.JSONException
;
import
org.codehaus.jettison.json.JSONObject
;
...
...
@@ -36,6 +37,7 @@ import org.slf4j.Logger;
import
org.slf4j.LoggerFactory
;
import
javax.ws.rs.HttpMethod
;
import
javax.ws.rs.POST
;
import
javax.ws.rs.core.MediaType
;
import
javax.ws.rs.core.Response
;
import
javax.ws.rs.core.UriBuilder
;
...
...
@@ -50,7 +52,6 @@ import static org.apache.hadoop.metadata.security.SecurityProperties.TLS_ENABLED
public
class
MetadataServiceClient
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
MetadataServiceClient
.
class
);
public
static
final
String
NAME
=
"name"
;
public
static
final
String
URI
=
"id"
;
public
static
final
String
GUID
=
"GUID"
;
public
static
final
String
DEFINITION
=
"definition"
;
public
static
final
String
ERROR
=
"error"
;
...
...
@@ -61,7 +62,7 @@ public class MetadataServiceClient {
public
static
final
String
URI_TYPES
=
"types"
;
public
static
final
String
URI_ENTITIES
=
"entities"
;
public
static
final
String
URI_TRAITS
=
"traits"
;
p
rivate
static
final
String
URI_SEARCH
=
"discovery/search"
;
p
ublic
static
final
String
URI_SEARCH
=
"discovery/search"
;
private
WebResource
service
;
...
...
@@ -169,7 +170,7 @@ public class MetadataServiceClient {
* @throws MetadataServiceException
*/
public
JSONObject
createType
(
String
typeAsJson
)
throws
MetadataServiceException
{
return
callAPI
(
API
.
CREATE_TYPE
,
typeAsJson
,
Response
.
Status
.
CREATED
);
return
callAPI
(
API
.
CREATE_TYPE
,
typeAsJson
);
}
/**
...
...
@@ -179,7 +180,7 @@ public class MetadataServiceClient {
* @throws MetadataServiceException
*/
public
JSONObject
createEntity
(
String
entityAsJson
)
throws
MetadataServiceException
{
return
callAPI
(
API
.
CREATE_ENTITY
,
entityAsJson
,
Response
.
Status
.
CREATED
);
return
callAPI
(
API
.
CREATE_ENTITY
,
entityAsJson
);
}
/**
...
...
@@ -189,7 +190,7 @@ public class MetadataServiceClient {
* @throws MetadataServiceException
*/
public
Referenceable
getEntity
(
String
guid
)
throws
MetadataServiceException
{
JSONObject
jsonResponse
=
callAPI
(
API
.
GET_ENTITY
,
null
,
Response
.
Status
.
OK
,
guid
);
JSONObject
jsonResponse
=
callAPI
(
API
.
GET_ENTITY
,
null
,
guid
);
try
{
String
entityInstanceDefinition
=
jsonResponse
.
getString
(
MetadataServiceClient
.
GUID
);
return
InstanceSerialization
.
fromJsonReferenceable
(
entityInstanceDefinition
,
true
);
...
...
@@ -281,17 +282,19 @@ public class MetadataServiceClient {
return
resource
;
}
private
JSONObject
callAPIWithResource
(
API
api
,
WebResource
resource
,
Response
.
Status
expectedStatus
)
throws
MetadataServiceException
{
return
callAPIWithResource
(
api
,
resource
,
null
,
expectedStatus
);
private
JSONObject
callAPIWithResource
(
API
api
,
WebResource
resource
)
throws
MetadataServiceException
{
return
callAPIWithResource
(
api
,
resource
,
null
);
}
private
JSONObject
callAPIWithResource
(
API
api
,
WebResource
resource
,
Object
requestObject
,
Response
.
Status
expectedStatus
)
private
JSONObject
callAPIWithResource
(
API
api
,
WebResource
resource
,
Object
requestObject
)
throws
MetadataServiceException
{
ClientResponse
clientResponse
=
resource
.
accept
(
MediaType
.
APPLICATION_JSON
)
.
type
(
MediaType
.
APPLICATION_JSON
)
.
method
(
api
.
getMethod
(),
ClientResponse
.
class
,
requestObject
);
Response
.
Status
expectedStatus
=
(
api
.
getMethod
()
==
HttpMethod
.
POST
)
?
Response
.
Status
.
CREATED
:
Response
.
Status
.
OK
;
if
(
clientResponse
.
getStatus
()
==
expectedStatus
.
getStatusCode
())
{
String
responseAsString
=
clientResponse
.
getEntity
(
String
.
class
);
System
.
out
.
println
(
"response : "
+
responseAsString
);
...
...
@@ -306,8 +309,8 @@ public class MetadataServiceClient {
}
private
JSONObject
callAPI
(
API
api
,
Object
requestObject
,
Response
.
Status
expectedStatus
,
String
...
pathParams
)
throws
MetadataServiceException
{
String
...
pathParams
)
throws
MetadataServiceException
{
WebResource
resource
=
getResource
(
api
,
pathParams
);
return
callAPIWithResource
(
api
,
resource
,
requestObject
,
expectedStatus
);
return
callAPIWithResource
(
api
,
resource
,
requestObject
);
}
}
repository/src/main/java/org/apache/hadoop/metadata/services/DefaultMetadataService.java
View file @
e013e656
...
...
@@ -21,6 +21,7 @@ package org.apache.hadoop.metadata.services;
import
com.google.common.base.Preconditions
;
import
com.google.common.collect.ImmutableList
;
import
org.apache.hadoop.metadata.MetadataException
;
import
org.apache.hadoop.metadata.MetadataServiceClient
;
import
org.apache.hadoop.metadata.discovery.SearchIndexer
;
import
org.apache.hadoop.metadata.listener.EntityChangeListener
;
import
org.apache.hadoop.metadata.listener.TypesChangeListener
;
...
...
@@ -100,7 +101,7 @@ public class DefaultMetadataService implements MetadataService {
onTypesAddedToRepo
(
typesAdded
);
JSONObject
response
=
new
JSONObject
()
{{
put
(
"types"
,
typesAdded
.
keySet
());
put
(
MetadataServiceClient
.
URI_TYPES
,
typesAdded
.
keySet
());
}};
return
response
;
}
catch
(
JSONException
e
)
{
...
...
webapp/src/main/java/org/apache/hadoop/metadata/web/resources/EntityResource.java
View file @
e013e656
...
...
@@ -36,10 +36,8 @@ import javax.ws.rs.*;
import
javax.ws.rs.core.*
;
import
java.io.IOException
;
import
java.net.URI
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
* Entity management operations as REST API.
...
...
@@ -89,7 +87,6 @@ public class EntityResource {
JSONObject
response
=
new
JSONObject
();
response
.
put
(
MetadataServiceClient
.
REQUEST_ID
,
Servlets
.
getRequestId
());
response
.
put
(
MetadataServiceClient
.
GUID
,
guid
);
response
.
put
(
MetadataServiceClient
.
URI
,
locationURI
.
toURL
().
toExternalForm
());
response
.
put
(
MetadataServiceClient
.
DEFINITION
,
entity
);
return
Response
.
created
(
locationURI
).
entity
(
response
).
build
();
...
...
@@ -268,7 +265,6 @@ public class EntityResource {
JSONObject
response
=
new
JSONObject
();
response
.
put
(
MetadataServiceClient
.
REQUEST_ID
,
Servlets
.
getRequestId
());
response
.
put
(
MetadataServiceClient
.
GUID
,
guid
);
response
.
put
(
MetadataServiceClient
.
URI
,
locationURI
.
toURL
().
toExternalForm
());
response
.
put
(
MetadataServiceClient
.
DEFINITION
,
traitDefinition
);
return
Response
.
created
(
locationURI
).
entity
(
response
).
build
();
...
...
webapp/src/main/java/org/apache/hadoop/metadata/web/resources/TypesResource.java
View file @
e013e656
...
...
@@ -95,7 +95,6 @@ public class TypesResource {
typesAddedList
.
add
(
new
HashMap
<
String
,
String
>()
{{
put
(
MetadataServiceClient
.
NAME
,
name
);
put
(
MetadataServiceClient
.
URI
,
locationUri
.
toURL
().
toExternalForm
());
}});
}
...
...
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