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
5becd8a5
Commit
5becd8a5
authored
May 19, 2015
by
Venkatesh Seetharam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Lineage Graph API
parent
dec21146
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
122 additions
and
3 deletions
+122
-3
HiveLineageService.java
.../apache/hadoop/metadata/discovery/HiveLineageService.java
+36
-1
LineageService.java
.../org/apache/hadoop/metadata/discovery/LineageService.java
+16
-0
HiveLineageResource.java
...he/hadoop/metadata/web/resources/HiveLineageResource.java
+70
-2
No files found.
repository/src/main/java/org/apache/hadoop/metadata/discovery/HiveLineageService.java
View file @
5becd8a5
...
...
@@ -19,7 +19,6 @@
package
org
.
apache
.
hadoop
.
metadata
.
discovery
;
import
com.thinkaurelius.titan.core.TitanGraph
;
import
org.apache.commons.configuration.ConfigurationException
;
import
org.apache.commons.configuration.PropertiesConfiguration
;
import
org.apache.hadoop.metadata.MetadataException
;
import
org.apache.hadoop.metadata.PropertiesUtil
;
...
...
@@ -116,6 +115,24 @@ public class HiveLineageService implements LineageService {
}
/**
* Return the lineage outputs graph for the given tableName.
*
* @param tableName tableName
* @return Outputs Graph as JSON
*/
@Override
public
String
getOutputsGraph
(
String
tableName
)
throws
DiscoveryException
{
LOG
.
info
(
"Fetching lineage outputs graph for tableName={}"
,
tableName
);
HiveWhereUsedQuery
outputsQuery
=
new
HiveWhereUsedQuery
(
HIVE_TABLE_TYPE_NAME
,
tableName
,
HIVE_PROCESS_TYPE_NAME
,
HIVE_PROCESS_INPUT_ATTRIBUTE_NAME
,
HIVE_PROCESS_OUTPUT_ATTRIBUTE_NAME
,
Option
.
empty
(),
SELECT_ATTRIBUTES
,
true
,
graphPersistenceStrategy
,
titanGraph
);
return
outputsQuery
.
graph
().
toInstanceJson
();
}
/**
* Return the lineage inputs for the given tableName.
*
* @param tableName tableName
...
...
@@ -141,6 +158,24 @@ public class HiveLineageService implements LineageService {
}
/**
* Return the lineage inputs graph for the given tableName.
*
* @param tableName tableName
* @return Inputs Graph as JSON
*/
@Override
public
String
getInputsGraph
(
String
tableName
)
throws
DiscoveryException
{
LOG
.
info
(
"Fetching lineage inputs graph for tableName={}"
,
tableName
);
HiveLineageQuery
inputsQuery
=
new
HiveLineageQuery
(
HIVE_TABLE_TYPE_NAME
,
tableName
,
HIVE_PROCESS_TYPE_NAME
,
HIVE_PROCESS_INPUT_ATTRIBUTE_NAME
,
HIVE_PROCESS_OUTPUT_ATTRIBUTE_NAME
,
Option
.
empty
(),
SELECT_ATTRIBUTES
,
true
,
graphPersistenceStrategy
,
titanGraph
);
return
inputsQuery
.
graph
().
toInstanceJson
();
}
/**
* Return the schema for the given tableName.
*
* @param tableName tableName
...
...
repository/src/main/java/org/apache/hadoop/metadata/discovery/LineageService.java
View file @
5becd8a5
...
...
@@ -32,6 +32,14 @@ public interface LineageService {
String
getOutputs
(
String
tableName
)
throws
DiscoveryException
;
/**
* Return the lineage outputs graph for the given tableName.
*
* @param tableName tableName
* @return Outputs Graph as JSON
*/
String
getOutputsGraph
(
String
tableName
)
throws
DiscoveryException
;
/**
* Return the lineage inputs for the given tableName.
*
* @param tableName tableName
...
...
@@ -40,6 +48,14 @@ public interface LineageService {
String
getInputs
(
String
tableName
)
throws
DiscoveryException
;
/**
* Return the lineage inputs graph for the given tableName.
*
* @param tableName tableName
* @return Inputs Graph as JSON
*/
String
getInputsGraph
(
String
tableName
)
throws
DiscoveryException
;
/**
* Return the schema for the given tableName.
*
* @param tableName tableName
...
...
webapp/src/main/java/org/apache/hadoop/metadata/web/resources/HiveLineageResource.java
View file @
5becd8a5
...
...
@@ -93,6 +93,40 @@ public class HiveLineageResource {
}
/**
* Returns the inputs graph for a given entity.
*
* @param tableName table name
*/
@GET
@Path
(
"table/{tableName}/inputs/graph"
)
@Consumes
(
MediaType
.
APPLICATION_JSON
)
@Produces
(
MediaType
.
APPLICATION_JSON
)
public
Response
inputsGraph
(
@Context
HttpServletRequest
request
,
@PathParam
(
"tableName"
)
String
tableName
)
{
Preconditions
.
checkNotNull
(
tableName
,
"table name cannot be null"
);
LOG
.
info
(
"Fetching lineage inputs graph for tableName={}"
,
tableName
);
try
{
final
String
jsonResult
=
lineageService
.
getInputsGraph
(
tableName
);
JSONObject
response
=
new
JSONObject
();
response
.
put
(
MetadataServiceClient
.
REQUEST_ID
,
Servlets
.
getRequestId
());
response
.
put
(
"tableName"
,
tableName
);
response
.
put
(
MetadataServiceClient
.
RESULTS
,
new
JSONObject
(
jsonResult
));
return
Response
.
ok
(
response
).
build
();
}
catch
(
DiscoveryException
e
)
{
LOG
.
error
(
"Unable to get lineage inputs graph for table {}"
,
tableName
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
BAD_REQUEST
));
}
catch
(
JSONException
e
)
{
LOG
.
error
(
"Unable to get lineage inputs graph for table {}"
,
tableName
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
}
}
/**
* Returns the outputs for a given entity.
*
* @param tableName table name
...
...
@@ -117,11 +151,45 @@ public class HiveLineageResource {
return
Response
.
ok
(
response
).
build
();
}
catch
(
DiscoveryException
e
)
{
LOG
.
error
(
"Unable to get lineage
in
puts for table {}"
,
tableName
,
e
);
LOG
.
error
(
"Unable to get lineage
out
puts for table {}"
,
tableName
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
BAD_REQUEST
));
}
catch
(
JSONException
e
)
{
LOG
.
error
(
"Unable to get lineage inputs for table {}"
,
tableName
,
e
);
LOG
.
error
(
"Unable to get lineage outputs for table {}"
,
tableName
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
}
}
/**
* Returns the outputs graph for a given entity.
*
* @param tableName table name
*/
@GET
@Path
(
"table/{tableName}/outputs/graph"
)
@Consumes
(
MediaType
.
APPLICATION_JSON
)
@Produces
(
MediaType
.
APPLICATION_JSON
)
public
Response
outputsGraph
(
@Context
HttpServletRequest
request
,
@PathParam
(
"tableName"
)
String
tableName
)
{
Preconditions
.
checkNotNull
(
tableName
,
"table name cannot be null"
);
LOG
.
info
(
"Fetching lineage outputs graph for tableName={}"
,
tableName
);
try
{
final
String
jsonResult
=
lineageService
.
getOutputs
(
tableName
);
JSONObject
response
=
new
JSONObject
();
response
.
put
(
MetadataServiceClient
.
REQUEST_ID
,
Servlets
.
getRequestId
());
response
.
put
(
"tableName"
,
tableName
);
response
.
put
(
MetadataServiceClient
.
RESULTS
,
new
JSONObject
(
jsonResult
));
return
Response
.
ok
(
response
).
build
();
}
catch
(
DiscoveryException
e
)
{
LOG
.
error
(
"Unable to get lineage outputs graph for table {}"
,
tableName
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
BAD_REQUEST
));
}
catch
(
JSONException
e
)
{
LOG
.
error
(
"Unable to get lineage outputs graph for table {}"
,
tableName
,
e
);
throw
new
WebApplicationException
(
Servlets
.
getErrorResponse
(
e
,
Response
.
Status
.
INTERNAL_SERVER_ERROR
));
}
...
...
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