forked from datahub-project/datahub
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(data-platforms): adding rest resource for /dataPlatforms and mid…
…-tier support (datahub-project#1817) * feat(data-platforms): Adding rest resource for /dataPlatforms and mid-tier support * Removed data platforms which are Linkedin internal
- Loading branch information
1 parent
3ed7289
commit 30d2b4b
Showing
14 changed files
with
483 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
datahub-dao/src/main/java/com/linkedin/datahub/dao/table/DataPlatformsDao.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.linkedin.datahub.dao.table; | ||
|
||
import com.linkedin.dataplatform.DataPlatformInfo; | ||
import com.linkedin.dataplatform.client.DataPlatforms; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.stream.Collectors; | ||
import javax.annotation.Nonnull; | ||
|
||
|
||
public class DataPlatformsDao { | ||
|
||
private final DataPlatforms _dataPlatforms; | ||
|
||
public DataPlatformsDao(@Nonnull DataPlatforms dataPlatforms) { | ||
_dataPlatforms = dataPlatforms; | ||
} | ||
|
||
/** | ||
* Get all data platforms | ||
*/ | ||
public List<Map<String, Object>> getAllPlatforms() throws Exception { | ||
return _dataPlatforms.getAllPlatforms().stream().map(DataPlatformInfo::data).collect(Collectors.toList()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
gms/api/src/main/idl/com.linkedin.dataplatform.dataPlatforms.restspec.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"name" : "dataPlatforms", | ||
"namespace" : "com.linkedin.dataplatform", | ||
"path" : "/dataPlatforms", | ||
"schema" : "com.linkedin.dataplatform.DataPlatformInfo", | ||
"doc" : "Resource provides information about various data platforms.\n\ngenerated from: com.linkedin.metadata.resources.dataplatform.DataPlatforms", | ||
"collection" : { | ||
"identifier" : { | ||
"name" : "platformName", | ||
"type" : "string" | ||
}, | ||
"supports" : [ "get", "get_all" ], | ||
"methods" : [ { | ||
"method" : "get" | ||
}, { | ||
"method" : "get_all", | ||
"pagingSupported" : true | ||
} ], | ||
"entity" : { | ||
"path" : "/dataPlatforms/{platformName}" | ||
} | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
gms/api/src/main/snapshot/com.linkedin.dataplatform.dataPlatforms.snapshot.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
{ | ||
"models" : [ { | ||
"type" : "record", | ||
"name" : "DataPlatformInfo", | ||
"namespace" : "com.linkedin.dataplatform", | ||
"doc" : "Information about a data platform", | ||
"fields" : [ { | ||
"name" : "name", | ||
"type" : "string", | ||
"doc" : "Name of the data platform", | ||
"validate" : { | ||
"strlen" : { | ||
"max" : 15 | ||
} | ||
} | ||
}, { | ||
"name" : "type", | ||
"type" : { | ||
"type" : "enum", | ||
"name" : "PlatformType", | ||
"doc" : "Platform types available at LinkedIn", | ||
"symbols" : [ "FILE_SYSTEM", "KEY_VALUE_STORE", "MESSAGE_BROKER", "OBJECT_STORE", "OLAP_DATASTORE", "OTHERS", "QUERY_ENGINE", "RELATIONAL_DB", "SEARCH_ENGINE" ], | ||
"symbolDocs" : { | ||
"FILE_SYSTEM" : "Value for a file system, e.g. hdfs", | ||
"KEY_VALUE_STORE" : "Value for a key value store, e.g. espresso, voldemort", | ||
"MESSAGE_BROKER" : "Value for a message broker, e.g. kafka", | ||
"OBJECT_STORE" : "Value for an object store, e.g. ambry", | ||
"OLAP_DATASTORE" : "Value for an OLAP datastore, e.g. pinot", | ||
"OTHERS" : "Value for other platforms, e.g salesforce, dovetail", | ||
"QUERY_ENGINE" : "Value for a query engine, e.g. presto", | ||
"RELATIONAL_DB" : "Value for a relational database, e.g. oracle, mysql", | ||
"SEARCH_ENGINE" : "Value for a search engine, e.g seas" | ||
} | ||
}, | ||
"doc" : "Platform type this data platform describes" | ||
}, { | ||
"name" : "datasetNameDelimiter", | ||
"type" : "string", | ||
"doc" : "The delimiter in the dataset names on the data platform, e.g. '/' for HDFS and '.' for Oracle" | ||
} ] | ||
}, "com.linkedin.dataplatform.PlatformType" ], | ||
"schema" : { | ||
"name" : "dataPlatforms", | ||
"namespace" : "com.linkedin.dataplatform", | ||
"path" : "/dataPlatforms", | ||
"schema" : "com.linkedin.dataplatform.DataPlatformInfo", | ||
"doc" : "Resource provides information about various data platforms.\n\ngenerated from: com.linkedin.metadata.resources.dataplatform.DataPlatforms", | ||
"collection" : { | ||
"identifier" : { | ||
"name" : "platformName", | ||
"type" : "string" | ||
}, | ||
"supports" : [ "get", "get_all" ], | ||
"methods" : [ { | ||
"method" : "get" | ||
}, { | ||
"method" : "get_all", | ||
"pagingSupported" : true | ||
} ], | ||
"entity" : { | ||
"path" : "/dataPlatforms/{platformName}" | ||
} | ||
} | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
gms/client/src/main/java/com/linkedin/dataplatform/client/DataPlatforms.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.linkedin.dataplatform.client; | ||
|
||
import com.linkedin.metadata.restli.BaseClient; | ||
import com.linkedin.dataplatform.DataPlatformInfo; | ||
import com.linkedin.dataplatform.DataPlatformsRequestBuilders; | ||
import com.linkedin.r2.RemoteInvocationException; | ||
import com.linkedin.restli.client.Client; | ||
import com.linkedin.restli.client.GetAllRequest; | ||
import com.linkedin.restli.client.Request; | ||
import java.util.List; | ||
import javax.annotation.Nonnull; | ||
|
||
|
||
public class DataPlatforms extends BaseClient { | ||
|
||
private static final DataPlatformsRequestBuilders PLATFORMS_REQUEST_BUILDERS = new DataPlatformsRequestBuilders(); | ||
|
||
public DataPlatforms(@Nonnull Client restliClient) { | ||
super(restliClient); | ||
} | ||
|
||
/** | ||
* Get data platform details by name | ||
* @param platformName String | ||
* @return DataPlatformInfo | ||
* @throws RemoteInvocationException | ||
*/ | ||
@Nonnull | ||
public DataPlatformInfo getPlatformByName(@Nonnull String platformName) throws RemoteInvocationException { | ||
Request<DataPlatformInfo> req = PLATFORMS_REQUEST_BUILDERS.get().id(platformName).build(); | ||
return _client.sendRequest(req).getResponse().getEntity(); | ||
} | ||
|
||
/** | ||
* Get all data platforms | ||
* @return List<DataPlatformInfo> | ||
* @throws RemoteInvocationException | ||
*/ | ||
@Nonnull | ||
public List<DataPlatformInfo> getAllPlatforms() throws RemoteInvocationException { | ||
GetAllRequest<DataPlatformInfo> req = PLATFORMS_REQUEST_BUILDERS.getAll().build(); | ||
return _client.sendRequest(req).getResponse().getEntity().getElements(); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...actories/src/main/java/com/linkedin/dataplatform/factory/DataPlatformLocalDaoFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.linkedin.dataplatform.factory; | ||
|
||
import com.linkedin.metadata.aspect.DataPlatformAspect; | ||
import com.linkedin.metadata.dao.ImmutableLocalDAO; | ||
import com.linkedin.metadata.resources.dataplatform.utils.DataPlatformsUtil; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.context.ApplicationContext; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
|
||
@Configuration | ||
public class DataPlatformLocalDaoFactory { | ||
@Autowired | ||
ApplicationContext applicationContext; | ||
|
||
@Bean(name = "dataPlatformLocalDAO") | ||
protected ImmutableLocalDAO createInstance() { | ||
return new ImmutableLocalDAO<>(DataPlatformAspect.class, DataPlatformsUtil.getDataPlatformInfoMap()); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
gms/impl/src/main/java/com/linkedin/metadata/resources/dataplatform/DataPlatforms.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.linkedin.metadata.resources.dataplatform; | ||
|
||
import com.linkedin.common.urn.DataPlatformUrn; | ||
import com.linkedin.dataplatform.DataPlatformInfo; | ||
import com.linkedin.metadata.aspect.DataPlatformAspect; | ||
import com.linkedin.metadata.dao.ImmutableLocalDAO; | ||
import com.linkedin.metadata.restli.RestliUtils; | ||
import com.linkedin.parseq.Task; | ||
import com.linkedin.restli.server.PagingContext; | ||
import com.linkedin.restli.server.annotations.PagingContextParam; | ||
import com.linkedin.restli.server.annotations.RestLiCollection; | ||
import com.linkedin.restli.server.annotations.RestMethod; | ||
import com.linkedin.restli.server.resources.CollectionResourceAsyncTemplate; | ||
import java.util.List; | ||
import javax.annotation.Nonnull; | ||
import javax.inject.Inject; | ||
import javax.inject.Named; | ||
|
||
|
||
/** | ||
* Resource provides information about various data platforms. | ||
*/ | ||
@RestLiCollection(name = "dataPlatforms", namespace = "com.linkedin.dataplatform", keyName = "platformName") | ||
public class DataPlatforms extends CollectionResourceAsyncTemplate<String, DataPlatformInfo> { | ||
|
||
@Inject | ||
@Named("dataPlatformLocalDAO") | ||
private ImmutableLocalDAO<DataPlatformAspect, DataPlatformUrn> _localDAO; | ||
|
||
@RestMethod.Get | ||
public Task<DataPlatformInfo> get(@Nonnull final String name) { | ||
return RestliUtils.toTaskFromOptional(() -> _localDAO.get(DataPlatformInfo.class, new DataPlatformUrn(name))); | ||
} | ||
|
||
@RestMethod.GetAll | ||
public Task<List<DataPlatformInfo>> getAll(@Nonnull @PagingContextParam(defaultCount = 100) PagingContext pagingContext) { | ||
return Task.value(_localDAO.list(DataPlatformInfo.class, pagingContext.getStart(), pagingContext.getCount()).getValues()); | ||
} | ||
} | ||
|
Oops, something went wrong.