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
f73dab3e
Commit
f73dab3e
authored
May 14, 2015
by
Shwetha GS
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
get entity definition to retun referenceable json
parent
4543c837
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
15 additions
and
12 deletions
+15
-12
HiveMetaStoreBridge.java
...ache/hadoop/metadata/hive/bridge/HiveMetaStoreBridge.java
+4
-9
MetadataServiceClient.java
...ava/org/apache/hadoop/metadata/MetadataServiceClient.java
+4
-2
DefaultMetadataService.java
...ache/hadoop/metadata/services/DefaultMetadataService.java
+1
-1
BaseResourceIT.java
.../apache/hadoop/metadata/web/resources/BaseResourceIT.java
+5
-0
EntityJerseyResourceIT.java
...hadoop/metadata/web/resources/EntityJerseyResourceIT.java
+1
-0
No files found.
addons/hive-bridge/src/main/java/org/apache/hadoop/metadata/hive/bridge/HiveMetaStoreBridge.java
View file @
f73dab3e
...
@@ -119,8 +119,8 @@ public class HiveMetaStoreBridge {
...
@@ -119,8 +119,8 @@ public class HiveMetaStoreBridge {
if
(
results
.
length
()
==
0
)
{
if
(
results
.
length
()
==
0
)
{
return
null
;
return
null
;
}
else
{
}
else
{
ITypedReferenceableInstance
reference
=
Serialization
.
fromJson
(
results
.
get
(
0
).
toString
()
);
String
guid
=
results
.
getJSONObject
(
0
).
getJSONObject
(
"$id$"
).
getString
(
"id"
);
return
new
Referenceable
(
reference
.
getId
().
id
,
typeName
,
null
);
return
new
Referenceable
(
gu
id
,
typeName
,
null
);
}
}
}
}
...
@@ -198,8 +198,7 @@ public class HiveMetaStoreBridge {
...
@@ -198,8 +198,7 @@ public class HiveMetaStoreBridge {
return
null
;
return
null
;
}
else
{
}
else
{
//There should be just one instance with the given name
//There should be just one instance with the given name
ITypedReferenceableInstance
reference
=
Serialization
.
fromJson
(
results
.
get
(
0
).
toString
());
String
guid
=
results
.
getJSONObject
(
0
).
getJSONObject
(
"$id$"
).
getString
(
"id"
);
String
guid
=
reference
.
getId
().
id
;
LOG
.
debug
(
"Got reference for table {}.{} = {}"
,
dbRef
,
tableName
,
guid
);
LOG
.
debug
(
"Got reference for table {}.{} = {}"
,
dbRef
,
tableName
,
guid
);
return
new
Referenceable
(
guid
,
typeName
,
null
);
return
new
Referenceable
(
guid
,
typeName
,
null
);
}
}
...
@@ -212,7 +211,7 @@ public class HiveMetaStoreBridge {
...
@@ -212,7 +211,7 @@ public class HiveMetaStoreBridge {
}
}
MetadataServiceClient
dgiClient
=
getMetadataServiceClient
();
MetadataServiceClient
dgiClient
=
getMetadataServiceClient
();
ITypedReferenceableInstanc
e
tableInstance
=
dgiClient
.
getEntity
(
tableRef
.
getId
().
id
);
Referenceabl
e
tableInstance
=
dgiClient
.
getEntity
(
tableRef
.
getId
().
id
);
Id
sdId
=
(
Id
)
tableInstance
.
get
(
"sd"
);
Id
sdId
=
(
Id
)
tableInstance
.
get
(
"sd"
);
return
new
Referenceable
(
sdId
.
id
,
sdId
.
getTypeName
(),
null
);
return
new
Referenceable
(
sdId
.
id
,
sdId
.
getTypeName
(),
null
);
}
}
...
@@ -454,10 +453,6 @@ public class HiveMetaStoreBridge {
...
@@ -454,10 +453,6 @@ public class HiveMetaStoreBridge {
}
else
{
}
else
{
LOG
.
info
(
"Hive data model is already registered!"
);
LOG
.
info
(
"Hive data model is already registered!"
);
}
}
//todo remove when fromJson(entityJson) is supported on client
dataModelGenerator
.
createDataModel
();
TypeSystem
.
getInstance
().
defineTypes
(
dataModelGenerator
.
getTypesDef
());
}
}
public
static
void
main
(
String
[]
argv
)
throws
Exception
{
public
static
void
main
(
String
[]
argv
)
throws
Exception
{
...
...
client/src/main/java/org/apache/hadoop/metadata/MetadataServiceClient.java
View file @
f73dab3e
...
@@ -26,6 +26,8 @@ import com.sun.jersey.client.urlconnection.URLConnectionClientHandler;
...
@@ -26,6 +26,8 @@ import com.sun.jersey.client.urlconnection.URLConnectionClientHandler;
import
org.apache.commons.configuration.PropertiesConfiguration
;
import
org.apache.commons.configuration.PropertiesConfiguration
;
import
org.apache.hadoop.metadata.security.SecureClientUtils
;
import
org.apache.hadoop.metadata.security.SecureClientUtils
;
import
org.apache.hadoop.metadata.typesystem.ITypedReferenceableInstance
;
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.hadoop.metadata.typesystem.json.Serialization
;
import
org.codehaus.jettison.json.JSONArray
;
import
org.codehaus.jettison.json.JSONArray
;
import
org.codehaus.jettison.json.JSONException
;
import
org.codehaus.jettison.json.JSONException
;
...
@@ -176,11 +178,11 @@ public class MetadataServiceClient {
...
@@ -176,11 +178,11 @@ public class MetadataServiceClient {
* @return result json object
* @return result json object
* @throws MetadataServiceException
* @throws MetadataServiceException
*/
*/
public
ITypedReferenceableInstanc
e
getEntity
(
String
guid
)
throws
MetadataServiceException
{
public
Referenceabl
e
getEntity
(
String
guid
)
throws
MetadataServiceException
{
JSONObject
jsonResponse
=
callAPI
(
API
.
GET_ENTITY
,
null
,
guid
);
JSONObject
jsonResponse
=
callAPI
(
API
.
GET_ENTITY
,
null
,
guid
);
try
{
try
{
String
entityInstanceDefinition
=
jsonResponse
.
getString
(
MetadataServiceClient
.
RESULTS
);
String
entityInstanceDefinition
=
jsonResponse
.
getString
(
MetadataServiceClient
.
RESULTS
);
return
Serialization
.
fromJson
(
entityInstanceDefinition
);
return
InstanceSerialization
.
fromJsonReferenceable
(
entityInstanceDefinition
,
true
);
}
catch
(
JSONException
e
)
{
}
catch
(
JSONException
e
)
{
throw
new
MetadataServiceException
(
e
);
throw
new
MetadataServiceException
(
e
);
}
}
...
...
repository/src/main/java/org/apache/hadoop/metadata/services/DefaultMetadataService.java
View file @
f73dab3e
...
@@ -195,7 +195,7 @@ public class DefaultMetadataService implements MetadataService {
...
@@ -195,7 +195,7 @@ public class DefaultMetadataService implements MetadataService {
Preconditions
.
checkNotNull
(
guid
,
"guid cannot be null"
);
Preconditions
.
checkNotNull
(
guid
,
"guid cannot be null"
);
final
ITypedReferenceableInstance
instance
=
repository
.
getEntityDefinition
(
guid
);
final
ITypedReferenceableInstance
instance
=
repository
.
getEntityDefinition
(
guid
);
return
Serialization
$
.
MODULE
$
.
toJson
(
instanc
e
);
return
InstanceSerialization
.
toJson
(
instance
,
tru
e
);
}
}
/**
/**
...
...
webapp/src/test/java/org/apache/hadoop/metadata/web/resources/BaseResourceIT.java
View file @
f73dab3e
...
@@ -28,6 +28,8 @@ import org.apache.hadoop.metadata.typesystem.TypesDef;
...
@@ -28,6 +28,8 @@ import org.apache.hadoop.metadata.typesystem.TypesDef;
import
org.apache.hadoop.metadata.typesystem.json.InstanceSerialization
;
import
org.apache.hadoop.metadata.typesystem.json.InstanceSerialization
;
import
org.apache.hadoop.metadata.typesystem.json.TypesSerialization
;
import
org.apache.hadoop.metadata.typesystem.json.TypesSerialization
;
import
org.apache.hadoop.metadata.typesystem.persistence.Id
;
import
org.apache.hadoop.metadata.typesystem.persistence.Id
;
import
org.apache.hadoop.metadata.typesystem.types.ClassType
;
import
org.apache.hadoop.metadata.typesystem.types.HierarchicalTypeDefinition
;
import
org.codehaus.jettison.json.JSONObject
;
import
org.codehaus.jettison.json.JSONObject
;
import
org.testng.Assert
;
import
org.testng.Assert
;
import
org.testng.annotations.BeforeClass
;
import
org.testng.annotations.BeforeClass
;
...
@@ -59,9 +61,12 @@ public abstract class BaseResourceIT {
...
@@ -59,9 +61,12 @@ public abstract class BaseResourceIT {
}
}
protected
void
createType
(
TypesDef
typesDef
)
throws
Exception
{
protected
void
createType
(
TypesDef
typesDef
)
throws
Exception
{
HierarchicalTypeDefinition
<
ClassType
>
sampleType
=
typesDef
.
classTypesAsJavaList
().
get
(
0
);
if
(
serviceClient
.
getType
(
sampleType
.
typeName
)
==
null
)
{
String
typesAsJSON
=
TypesSerialization
.
toJson
(
typesDef
);
String
typesAsJSON
=
TypesSerialization
.
toJson
(
typesDef
);
createType
(
typesAsJSON
);
createType
(
typesAsJSON
);
}
}
}
protected
void
createType
(
String
typesAsJSON
)
throws
Exception
{
protected
void
createType
(
String
typesAsJSON
)
throws
Exception
{
WebResource
resource
=
service
WebResource
resource
=
service
...
...
webapp/src/test/java/org/apache/hadoop/metadata/web/resources/EntityJerseyResourceIT.java
View file @
f73dab3e
...
@@ -148,6 +148,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
...
@@ -148,6 +148,7 @@ public class EntityJerseyResourceIT extends BaseResourceIT {
final
String
definition
=
response
.
getString
(
MetadataServiceClient
.
RESULTS
);
final
String
definition
=
response
.
getString
(
MetadataServiceClient
.
RESULTS
);
Assert
.
assertNotNull
(
definition
);
Assert
.
assertNotNull
(
definition
);
LOG
.
debug
(
"tableInstanceAfterGet = "
+
definition
);
LOG
.
debug
(
"tableInstanceAfterGet = "
+
definition
);
InstanceSerialization
.
fromJsonReferenceable
(
definition
,
true
);
}
}
private
ClientResponse
addProperty
(
String
guid
,
String
property
,
String
value
)
{
private
ClientResponse
addProperty
(
String
guid
,
String
property
,
String
value
)
{
...
...
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