[Breaking] Update to GMA 0.2.0 and fix Urn definitions. (#1977)

Urn definitions needed to be updated since 0.2.0 changed the base Urn class. 

I also added some more urn coercers that were missing.
This commit is contained in:
John Plaisted 2020-11-11 16:06:29 -08:00 committed by GitHub
parent 70ddb09d29
commit 60e43061d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 448 additions and 223 deletions

View File

@ -1,6 +1,6 @@
buildscript {
ext.pegasusVersion = '28.3.7'
ext.gmaVersion = '0.1.0'
ext.gmaVersion = '0.2.0'
apply from: './repositories.gradle'
buildscript.repositories.addAll(project.repositories)

View File

@ -43,7 +43,7 @@ public class OwnerViewDao {
datasetOwnership.setDatasetUrn(datasetUrn);
datasetOwnership.setFromUpstream(false);
datasetOwnership.setOwners(fillDatasetOwner(ownership, owners));
datasetOwnership.setActor(ownership.getLastModified().getActor().getContent());
datasetOwnership.setActor(ownership.getLastModified().getActor().getId());
datasetOwnership.setLastModified(ownership.getLastModified().getTime());
return datasetOwnership;
}

View File

@ -45,7 +45,7 @@ public class DatasetUtil {
*/
public static DatasetView toDatasetView(Dataset dataset) {
DatasetView view = new DatasetView();
view.setPlatform(dataset.getPlatform().getContent());
view.setPlatform(dataset.getPlatform().getPlatformNameEntity());
view.setNativeName(dataset.getName());
view.setFabric(dataset.getOrigin().name());
view.setDescription(dataset.getDescription());

View File

@ -16,7 +16,7 @@ public class DataProcessesClient extends BaseClient {
return new DataProcessKey()
.setName(urn.getNameEntity())
.setOrigin(urn.getOriginEntity())
.setOrchestrator(urn.getOrchestrator());
.setOrchestrator(urn.getOrchestratorEntity());
}
@Nonnull

View File

@ -95,7 +95,7 @@ public class DataProcesses extends BaseSearchableEntityResource<
protected ComplexResourceKey<DataProcessKey, EmptyRecord> toKey(@Nonnull DataProcessUrn urn) {
return new ComplexResourceKey<>(
new DataProcessKey()
.setOrchestrator(urn.getOrchestrator())
.setOrchestrator(urn.getOrchestratorEntity())
.setName(urn.getNameEntity())
.setOrigin(urn.getOriginEntity()),
new EmptyRecord());
@ -105,7 +105,7 @@ public class DataProcesses extends BaseSearchableEntityResource<
@Override
protected DataProcess toValue(@Nonnull DataProcessSnapshot processSnapshot) {
final DataProcess value = new DataProcess()
.setOrchestrator(processSnapshot.getUrn().getOrchestrator())
.setOrchestrator(processSnapshot.getUrn().getOrchestratorEntity())
.setName(processSnapshot.getUrn().getNameEntity())
.setOrigin(processSnapshot.getUrn().getOriginEntity());
ModelUtils.getAspectsFromSnapshot(processSnapshot).forEach(aspect -> {

View File

@ -10,37 +10,51 @@ public final class AzkabanFlowUrn extends Urn {
public static final String ENTITY_TYPE = "azkabanFlow";
private static final String CONTENT_FORMAT = "(%s,%s,%s)";
private final String clusterEntity;
private final String projectEntity;
private final String flowIdEntity;
private final String _cluster;
private final String _project;
private final String _flowId;
public AzkabanFlowUrn(String cluster, String project, String flowId) {
super(ENTITY_TYPE, String.format(CONTENT_FORMAT, cluster, project, flowId));
this.clusterEntity = cluster;
this.projectEntity = project;
this.flowIdEntity = flowId;
super(ENTITY_TYPE, TupleKey.create(cluster, project, flowId));
this._cluster = cluster;
this._project = project;
this._flowId = flowId;
}
public String getClusterEntity() {
return clusterEntity;
return _cluster;
}
public String getProjectEntity() {
return projectEntity;
return _project;
}
public String getFlowIdEntity() {
return flowIdEntity;
return _flowId;
}
public static AzkabanFlowUrn createFromString(String rawUrn) throws URISyntaxException {
String content = new Urn(rawUrn).getContent();
String[] parts = content.substring(1, content.length() - 1).split(",");
return new AzkabanFlowUrn(parts[0], parts[1], parts[2]);
return createFromUrn(Urn.createFromString(rawUrn));
}
public static AzkabanFlowUrn createFromUrn(Urn urn) throws URISyntaxException {
if (!"li".equals(urn.getNamespace())) {
throw new URISyntaxException(urn.toString(), "Urn namespace type should be 'li'.");
} else if (!ENTITY_TYPE.equals(urn.getEntityType())) {
throw new URISyntaxException(urn.toString(), "Urn entity type should be 'azkabanFlow'.");
} else {
TupleKey key = urn.getEntityKey();
if (key.size() != 3) {
throw new URISyntaxException(urn.toString(), "Invalid number of keys.");
} else {
try {
return new AzkabanFlowUrn((String) key.getAs(0, String.class), (String) key.getAs(1, String.class),
(String) key.getAs(2, String.class));
} catch (Exception e) {
throw new URISyntaxException(urn.toString(), "Invalid URN Parameter: '" + e.getMessage());
}
}
}
}
public static AzkabanFlowUrn deserialize(String rawUrn) throws URISyntaxException {

View File

@ -10,31 +10,45 @@ public final class AzkabanJobUrn extends Urn {
public static final String ENTITY_TYPE = "azkabanJob";
private static final String CONTENT_FORMAT = "(%s,%s)";
private final AzkabanFlowUrn flowEntity;
private final String jobIdEntity;
private final AzkabanFlowUrn _flow;
private final String _jobId;
public AzkabanJobUrn(AzkabanFlowUrn flow, String jobId) {
super(ENTITY_TYPE, String.format(CONTENT_FORMAT, flow.toString(), jobId));
this.flowEntity = flow;
this.jobIdEntity = jobId;
super(ENTITY_TYPE, TupleKey.create(flow, jobId));
this._flow = flow;
this._jobId = jobId;
}
public AzkabanFlowUrn getFlowEntity() {
return flowEntity;
return _flow;
}
public String getJobIdEntity() {
return jobIdEntity;
return _jobId;
}
public static AzkabanJobUrn createFromString(String rawUrn) throws URISyntaxException {
String content = new Urn(rawUrn).getContent();
String flowParts = content.substring(1, content.lastIndexOf(",") + 1);
String[] parts = content.substring(1, content.length() - 1).split(",");
return new AzkabanJobUrn(AzkabanFlowUrn.createFromString(flowParts), parts[3]);
return createFromUrn(Urn.createFromString(rawUrn));
}
public static AzkabanJobUrn createFromUrn(Urn urn) throws URISyntaxException {
if (!"li".equals(urn.getNamespace())) {
throw new URISyntaxException(urn.toString(), "Urn namespace type should be 'li'.");
} else if (!ENTITY_TYPE.equals(urn.getEntityType())) {
throw new URISyntaxException(urn.toString(), "Urn entity type should be 'azkabanJob'.");
} else {
TupleKey key = urn.getEntityKey();
if (key.size() != 2) {
throw new URISyntaxException(urn.toString(), "Invalid number of keys.");
} else {
try {
return new AzkabanJobUrn((AzkabanFlowUrn) key.getAs(0, AzkabanFlowUrn.class),
(String) key.getAs(1, String.class));
} catch (Exception e) {
throw new URISyntaxException(urn.toString(), "Invalid URN Parameter: '" + e.getMessage());
}
}
}
}
public static AzkabanJobUrn deserialize(String rawUrn) throws URISyntaxException {
@ -42,6 +56,7 @@ public final class AzkabanJobUrn extends Urn {
}
static {
Custom.initializeCustomClass(AzkabanFlowUrn.class);
Custom.registerCoercer(new DirectCoercer<AzkabanJobUrn>() {
public Object coerceInput(AzkabanJobUrn object) throws ClassCastException {
return object.toString();

View File

@ -10,31 +10,45 @@ public final class ChartUrn extends Urn {
public static final String ENTITY_TYPE = "chart";
private static final String CONTENT_FORMAT = "(%s,%s)";
private final String _dashboardTool;
private final String dashboardToolEntity;
private final String chartIdEntity;
private final String _chartId;
public ChartUrn(String dashboardTool, String chartId) {
super(ENTITY_TYPE, String.format(CONTENT_FORMAT, dashboardTool, chartId));
this.dashboardToolEntity = dashboardTool;
this.chartIdEntity = chartId;
super(ENTITY_TYPE, TupleKey.create(dashboardTool, chartId));
this._dashboardTool = dashboardTool;
this._chartId = chartId;
}
public String getDashboardToolEntity() {
return dashboardToolEntity;
return _dashboardTool;
}
public String getChartIdEntity() {
return chartIdEntity;
return _chartId;
}
public static ChartUrn createFromString(String rawUrn) throws URISyntaxException {
Urn urn = new Urn(rawUrn);
validateUrn(urn, ENTITY_TYPE);
String[] urnParts = urn.getContent().split(",");
return new ChartUrn(urnParts[0], urnParts[1]);
return createFromUrn(Urn.createFromString(rawUrn));
}
public static ChartUrn createFromUrn(Urn urn) throws URISyntaxException {
if (!"li".equals(urn.getNamespace())) {
throw new URISyntaxException(urn.toString(), "Urn namespace type should be 'li'.");
} else if (!ENTITY_TYPE.equals(urn.getEntityType())) {
throw new URISyntaxException(urn.toString(), "Urn entity type should be 'chart'.");
} else {
TupleKey key = urn.getEntityKey();
if (key.size() != 2) {
throw new URISyntaxException(urn.toString(), "Invalid number of keys.");
} else {
try {
return new ChartUrn((String)key.getAs(0, String.class), (String)key.getAs(1, String.class));
} catch (Exception e) {
throw new URISyntaxException(urn.toString(), "Invalid URN Parameter: '" + e.getMessage());
}
}
}
}
public static ChartUrn deserialize(String rawUrn) throws URISyntaxException {

View File

@ -4,41 +4,52 @@ import com.linkedin.data.template.Custom;
import com.linkedin.data.template.DirectCoercer;
import com.linkedin.data.template.TemplateOutputCastException;
import java.net.URISyntaxException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public final class CorpGroupUrn extends Urn {
public static final String ENTITY_TYPE = "corpGroup";
private static final Pattern URN_PATTERN = Pattern.compile("^" + URN_PREFIX + ENTITY_TYPE + ":([\\-\\w]+)$");
private final String groupNameEntity;
private final String _groupName;
public CorpGroupUrn(String groupName) {
super(ENTITY_TYPE, groupName);
this.groupNameEntity = groupName;
super(ENTITY_TYPE, TupleKey.createWithOneKeyPart(groupName));
this._groupName = groupName;
}
private CorpGroupUrn(TupleKey entityKey, String groupName) {
super("li", "corpGroup", entityKey);
this._groupName = groupName;
}
public String getGroupNameEntity() {
return groupNameEntity;
return _groupName;
}
public static CorpGroupUrn createFromString(String rawUrn) throws URISyntaxException {
String groupName = new Urn(rawUrn).getContent();
return new CorpGroupUrn(groupName);
return createFromUrn(Urn.createFromString(rawUrn));
}
private static CorpGroupUrn decodeUrn(String groupName) throws Exception {
return new CorpGroupUrn(TupleKey.create(new Object[]{groupName}), groupName);
}
public static CorpGroupUrn createFromUrn(Urn urn) throws URISyntaxException {
if (!ENTITY_TYPE.equals(urn.getEntityType())) {
throw new URISyntaxException(urn.toString(), "Can't cast URN to CorpGroupUrn, not same ENTITY");
}
Matcher matcher = URN_PATTERN.matcher(urn.toString());
if (matcher.find()) {
return new CorpGroupUrn(matcher.group(1));
if (!"li".equals(urn.getNamespace())) {
throw new URISyntaxException(urn.toString(), "Urn namespace type should be 'li'.");
} else if (!ENTITY_TYPE.equals(urn.getEntityType())) {
throw new URISyntaxException(urn.toString(), "Urn entity type should be 'corpGroup'.");
} else {
throw new URISyntaxException(urn.toString(), "CorpGroupUrn syntax error");
TupleKey key = urn.getEntityKey();
if (key.size() != 1) {
throw new URISyntaxException(urn.toString(), "Invalid number of keys.");
} else {
try {
return decodeUrn((String)key.getAs(0, String.class));
} catch (Exception var3) {
throw new URISyntaxException(urn.toString(), "Invalid URN Parameter: '" + var3.getMessage());
}
}
}
}

View File

@ -1,10 +1,10 @@
package com.linkedin.common.urn;
import com.linkedin.common.FabricType;
import com.linkedin.data.template.Custom;
import com.linkedin.data.template.DirectCoercer;
import com.linkedin.data.template.TemplateOutputCastException;
import java.net.URISyntaxException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -12,34 +12,37 @@ public final class CorpuserUrn extends Urn {
public static final String ENTITY_TYPE = "corpuser";
private static final Pattern URN_PATTERN = Pattern.compile("^" + URN_PREFIX + ENTITY_TYPE + ":([\\-\\w]+)$");
private final String usernameEntity;
private final String _username;
public CorpuserUrn(String username) {
super(ENTITY_TYPE, username);
this.usernameEntity = username;
super(ENTITY_TYPE, TupleKey.create(username));
this._username = username;
}
public String getUsernameEntity() {
return usernameEntity;
return _username;
}
public static CorpuserUrn createFromString(String rawUrn) throws URISyntaxException {
String username = new Urn(rawUrn).getContent();
return new CorpuserUrn(username);
return createFromUrn(Urn.createFromString(rawUrn));
}
public static CorpuserUrn createFromUrn(Urn urn) throws URISyntaxException {
if (!ENTITY_TYPE.equals(urn.getEntityType())) {
throw new URISyntaxException(urn.toString(), "Can't cast URN to CorpuserUrn, not same ENTITY");
}
Matcher matcher = URN_PATTERN.matcher(urn.toString());
if (matcher.find()) {
return new CorpuserUrn(matcher.group(1));
if (!"li".equals(urn.getNamespace())) {
throw new URISyntaxException(urn.toString(), "Urn namespace type should be 'li'.");
} else if (!ENTITY_TYPE.equals(urn.getEntityType())) {
throw new URISyntaxException(urn.toString(), "Urn entity type should be 'corpuser'.");
} else {
throw new URISyntaxException(urn.toString(), "CorpuserUrn syntax error");
TupleKey key = urn.getEntityKey();
if (key.size() != 1) {
throw new URISyntaxException(urn.toString(), "Invalid number of keys.");
} else {
try {
return new CorpuserUrn((String) key.getAs(0, String.class));
} catch (Exception var3) {
throw new URISyntaxException(urn.toString(), "Invalid URN Parameter: '" + var3.getMessage());
}
}
}
}

View File

@ -10,31 +10,44 @@ public final class DashboardUrn extends Urn {
public static final String ENTITY_TYPE = "dashboard";
private static final String CONTENT_FORMAT = "(%s,%s)";
private final String dashboardToolEntity;
private final String dashboardIdEntity;
private final String _dashboardTool;
private final String _dashboardId;
public DashboardUrn(String dashboardTool, String dashboardId) {
super(ENTITY_TYPE, String.format(CONTENT_FORMAT, dashboardTool, dashboardId));
this.dashboardToolEntity = dashboardTool;
this.dashboardIdEntity = dashboardId;
super(ENTITY_TYPE, TupleKey.create(dashboardId, dashboardId));
this._dashboardTool = dashboardTool;
this._dashboardId = dashboardId;
}
public String getDashboardToolEntity() {
return dashboardToolEntity;
return _dashboardTool;
}
public String getDashboardIdEntity() {
return dashboardIdEntity;
return _dashboardId;
}
public static DashboardUrn createFromString(String rawUrn) throws URISyntaxException {
Urn urn = new Urn(rawUrn);
validateUrn(urn, ENTITY_TYPE);
String[] urnParts = urn.getContent().split(",");
return new DashboardUrn(urnParts[0], urnParts[1]);
return createFromUrn(Urn.createFromString(rawUrn));
}
public static DashboardUrn createFromUrn(Urn urn) throws URISyntaxException {
if (!"li".equals(urn.getNamespace())) {
throw new URISyntaxException(urn.toString(), "Urn namespace type should be 'li'.");
} else if (!ENTITY_TYPE.equals(urn.getEntityType())) {
throw new URISyntaxException(urn.toString(), "Urn entity type should be 'dashboard'.");
} else {
TupleKey key = urn.getEntityKey();
if (key.size() != 2) {
throw new URISyntaxException(urn.toString(), "Invalid number of keys.");
} else {
try {
return new DashboardUrn((String) key.getAs(0, String.class), (String) key.getAs(1, String.class));
} catch (Exception e) {
throw new URISyntaxException(urn.toString(), "Invalid URN Parameter: '" + e.getMessage());
}
}
}
}
public static DashboardUrn deserialize(String rawUrn) throws URISyntaxException {

View File

@ -11,20 +11,38 @@ public final class DataPlatformUrn extends Urn {
public static final String ENTITY_TYPE = "dataPlatform";
private final String platformNameEntity;
private final String _platformName;
public DataPlatformUrn(String platformName) {
super(ENTITY_TYPE, platformName);
this.platformNameEntity = platformName;
super(ENTITY_TYPE, TupleKey.create(platformName));
this._platformName = platformName;
}
public String getPlatformNameEntity() {
return platformNameEntity;
return _platformName;
}
public static DataPlatformUrn createFromString(String rawUrn) throws URISyntaxException {
String platformName = new Urn(rawUrn).getContent();
return new DataPlatformUrn(platformName);
return createFromUrn(Urn.createFromString(rawUrn));
}
public static DataPlatformUrn createFromUrn(Urn urn) throws URISyntaxException {
if (!"li".equals(urn.getNamespace())) {
throw new URISyntaxException(urn.toString(), "Urn namespace type should be 'li'.");
} else if (!ENTITY_TYPE.equals(urn.getEntityType())) {
throw new URISyntaxException(urn.toString(), "Urn entity type should be 'dataPlatform'.");
} else {
TupleKey key = urn.getEntityKey();
if (key.size() != 1) {
throw new URISyntaxException(urn.toString(), "Invalid number of keys.");
} else {
try {
return new DataPlatformUrn((String) key.getAs(0, String.class));
} catch (Exception e) {
throw new URISyntaxException(urn.toString(), "Invalid URN Parameter: '" + e.getMessage());
}
}
}
}
public static DataPlatformUrn deserialize(String rawUrn) throws URISyntaxException {

View File

@ -9,59 +9,76 @@ import java.net.URISyntaxException;
import static com.linkedin.common.urn.UrnUtils.toFabricType;
public class DataProcessUrn extends Urn {
public static final String ENTITY_TYPE = "dataProcess";
public static final String ENTITY_TYPE = "dataProcess";
private final String nameEntity;
private final String _name;
private final String _orchestrator;
private final FabricType _origin;
private static final String CONTENT_FORMAT = "(%s,%s,%s)";
public DataProcessUrn(String orchestrator, String name, FabricType origin) {
super(ENTITY_TYPE, TupleKey.create(orchestrator, name, origin));
this._orchestrator = orchestrator;
this._name = name;
this._origin = origin;
}
private final String orchestrator;
public String getNameEntity() {
return _name;
}
private final FabricType originEntity;
public String getOrchestratorEntity() {
return _orchestrator;
}
public DataProcessUrn(String orchestrator, String name, FabricType origin) {
super(ENTITY_TYPE, String.format(CONTENT_FORMAT, orchestrator, name, origin.name()));
this.orchestrator = orchestrator;
this.nameEntity = name;
this.originEntity = origin;
public FabricType getOriginEntity() {
return _origin;
}
public static DataProcessUrn createFromString(String rawUrn) throws URISyntaxException {
return createFromUrn(Urn.createFromString(rawUrn));
}
public static DataProcessUrn deserialize(String rawUrn) throws URISyntaxException {
return createFromString(rawUrn);
}
public static DataProcessUrn createFromUrn(Urn urn) throws URISyntaxException {
if (!"li".equals(urn.getNamespace())) {
throw new URISyntaxException(urn.toString(), "Urn namespace type should be 'li'.");
} else if (!ENTITY_TYPE.equals(urn.getEntityType())) {
throw new URISyntaxException(urn.toString(), "Urn entity type should be 'dataProcess'.");
} else {
TupleKey key = urn.getEntityKey();
if (key.size() != 3) {
throw new URISyntaxException(urn.toString(), "Invalid number of keys.");
} else {
try {
return new DataProcessUrn((String) key.getAs(0, String.class), (String) key.getAs(1, String.class),
(FabricType) key.getAs(2, FabricType.class));
} catch (Exception var3) {
throw new URISyntaxException(urn.toString(), "Invalid URN Parameter: '" + var3.getMessage());
}
}
}
}
public String getNameEntity() {
return nameEntity;
}
static {
Custom.initializeCustomClass(DataProcessUrn.class);
Custom.initializeCustomClass(FabricType.class);
Custom.registerCoercer(new DirectCoercer<DataProcessUrn>() {
public Object coerceInput(DataProcessUrn object) throws ClassCastException {
return object.toString();
}
public String getOrchestrator() {
return orchestrator;
}
public FabricType getOriginEntity() {
return originEntity;
}
public static DataProcessUrn createFromString(String rawUrn) throws URISyntaxException {
String content = new Urn(rawUrn).getContent();
String[] parts = content.substring(1, content.length() - 1).split(",");
return new DataProcessUrn(parts[0], parts[1], toFabricType(parts[2]));
}
public static DataProcessUrn deserialize(String rawUrn) throws URISyntaxException {
return createFromString(rawUrn);
}
static {
Custom.registerCoercer(new DirectCoercer<DataProcessUrn>() {
public Object coerceInput(DataProcessUrn object) throws ClassCastException {
return object.toString();
}
public DataProcessUrn coerceOutput(Object object) throws TemplateOutputCastException {
try {
return DataProcessUrn.createFromString((String) object);
} catch (URISyntaxException e) {
throw new TemplateOutputCastException("Invalid URN syntax: " + e.getMessage(), e);
}
}
}, DataProcessUrn.class);
}
public DataProcessUrn coerceOutput(Object object) throws TemplateOutputCastException {
try {
return DataProcessUrn.createFromString((String) object);
} catch (URISyntaxException e) {
throw new TemplateOutputCastException("Invalid URN syntax: " + e.getMessage(), e);
}
}
}, DataProcessUrn.class);
}
}

View File

@ -6,44 +6,56 @@ import com.linkedin.data.template.DirectCoercer;
import com.linkedin.data.template.TemplateOutputCastException;
import java.net.URISyntaxException;
import static com.linkedin.common.urn.UrnUtils.*;
public final class DatasetUrn extends Urn {
public static final String ENTITY_TYPE = "dataset";
private static final String CONTENT_FORMAT = "(%s,%s,%s)";
private final DataPlatformUrn platformEntity;
private final String datasetNameEntity;
private final FabricType originEntity;
private final DataPlatformUrn _platform;
private final String _datasetName;
private final FabricType _origin;
public DatasetUrn(DataPlatformUrn platform, String name, FabricType origin) {
super(ENTITY_TYPE, String.format(CONTENT_FORMAT, platform.toString(), name, origin.name()));
this.platformEntity = platform;
this.datasetNameEntity = name;
this.originEntity = origin;
super(ENTITY_TYPE, TupleKey.create(platform, name, origin));
this._platform = platform;
this._datasetName = name;
this._origin = origin;
}
public DataPlatformUrn getPlatformEntity() {
return platformEntity;
return _platform;
}
public String getDatasetNameEntity() {
return datasetNameEntity;
return _datasetName;
}
public FabricType getOriginEntity() {
return originEntity;
return _origin;
}
public static DatasetUrn createFromString(String rawUrn) throws URISyntaxException {
String content = new Urn(rawUrn).getContent();
String[] parts = content.substring(1, content.length() - 1).split(",");
return new DatasetUrn(DataPlatformUrn.createFromString(parts[0]), parts[1], toFabricType(parts[2]));
return createFromUrn(Urn.createFromString(rawUrn));
}
public static DatasetUrn createFromUrn(Urn urn) throws URISyntaxException {
if (!"li".equals(urn.getNamespace())) {
throw new URISyntaxException(urn.toString(), "Urn namespace type should be 'li'.");
} else if (!ENTITY_TYPE.equals(urn.getEntityType())) {
throw new URISyntaxException(urn.toString(), "Urn entity type should be 'dataset'.");
} else {
TupleKey key = urn.getEntityKey();
if (key.size() != 3) {
throw new URISyntaxException(urn.toString(), "Invalid number of keys.");
} else {
try {
return new DatasetUrn((DataPlatformUrn) key.getAs(0, DataPlatformUrn.class),
(String) key.getAs(1, String.class), (FabricType) key.getAs(2, FabricType.class));
} catch (Exception var3) {
throw new URISyntaxException(urn.toString(), "Invalid URN Parameter: '" + var3.getMessage());
}
}
}
}
public static DatasetUrn deserialize(String rawUrn) throws URISyntaxException {
@ -51,6 +63,9 @@ public final class DatasetUrn extends Urn {
}
static {
Custom.initializeCustomClass(DataPlatformUrn.class);
Custom.initializeCustomClass(DatasetUrn.class);
Custom.initializeCustomClass(FabricType.class);
Custom.registerCoercer(new DirectCoercer<DatasetUrn>() {
public Object coerceInput(DatasetUrn object) throws ClassCastException {
return object.toString();

View File

@ -1,17 +1,62 @@
package com.linkedin.common.urn;
import com.linkedin.data.template.Custom;
import com.linkedin.data.template.DirectCoercer;
import com.linkedin.data.template.TemplateOutputCastException;
import java.net.URISyntaxException;
public final class FabricUrn extends Urn {
public static final String ENTITY_TYPE = "fabric";
private final String nameEntity;
private final String _name;
public FabricUrn(String name) {
super(ENTITY_TYPE, name);
this.nameEntity = name;
super(ENTITY_TYPE, TupleKey.create(name));
this._name = name;
}
public String getNameEntity() {
return nameEntity;
return _name;
}
public static FabricUrn createFromString(String rawUrn) throws URISyntaxException {
return createFromUrn(Urn.createFromString(rawUrn));
}
public static FabricUrn createFromUrn(Urn urn) throws URISyntaxException {
if (!"li".equals(urn.getNamespace())) {
throw new URISyntaxException(urn.toString(), "Urn namespace type should be 'li'.");
} else if (!ENTITY_TYPE.equals(urn.getEntityType())) {
throw new URISyntaxException(urn.toString(), "Urn entity type should be 'fabric'.");
} else {
TupleKey key = urn.getEntityKey();
if (key.size() != 1) {
throw new URISyntaxException(urn.toString(), "Invalid number of keys.");
} else {
try {
return new FabricUrn((String) key.getAs(0, String.class));
} catch (Exception e) {
throw new URISyntaxException(urn.toString(), "Invalid URN Parameter: '" + e.getMessage());
}
}
}
}
static {
Custom.registerCoercer(new DirectCoercer<FabricUrn>() {
public Object coerceInput(FabricUrn object) throws ClassCastException {
return object.toString();
}
public FabricUrn coerceOutput(Object object) throws TemplateOutputCastException {
try {
return FabricUrn.createFromString((String) object);
} catch (URISyntaxException e) {
throw new TemplateOutputCastException("Invalid URN syntax: " + e.getMessage(), e);
}
}
}, FabricUrn.class);
}
}

View File

@ -1,27 +1,69 @@
package com.linkedin.common.urn;
import com.linkedin.data.template.Custom;
import com.linkedin.data.template.DirectCoercer;
import com.linkedin.data.template.TemplateOutputCastException;
import java.net.URISyntaxException;
public final class MLFeatureUrn extends Urn {
public static final String ENTITY_TYPE = "mlFeature";
private static final String CONTENT_FORMAT = "(%s,%s,%s)";
private final String _mlFeatureNamespace;
private final String mlFeatureNamespace;
private final String mlFeatureName;
private final String _mlFeatureName;
public MLFeatureUrn(String mlFeatureNamespace, String mlFeatureName) {
super(ENTITY_TYPE, String.format(CONTENT_FORMAT, mlFeatureNamespace, mlFeatureName));
this.mlFeatureNamespace = mlFeatureNamespace;
this.mlFeatureName = mlFeatureName;
super(ENTITY_TYPE, TupleKey.create(mlFeatureNamespace, mlFeatureName));
this._mlFeatureNamespace = mlFeatureNamespace;
this._mlFeatureName = mlFeatureName;
}
public String getMlFeatureName() {
return mlFeatureName;
public String getMlFeatureNameEntity() {
return _mlFeatureName;
}
public String getMlFeatureNamespace() {
return mlFeatureNamespace;
public String getMlFeatureNamespaceEntity() {
return _mlFeatureNamespace;
}
public static MLFeatureUrn createFromString(String rawUrn) throws URISyntaxException {
return createFromUrn(Urn.createFromString(rawUrn));
}
public static MLFeatureUrn createFromUrn(Urn urn) throws URISyntaxException {
if (!"li".equals(urn.getNamespace())) {
throw new URISyntaxException(urn.toString(), "Urn namespace type should be 'li'.");
} else if (!ENTITY_TYPE.equals(urn.getEntityType())) {
throw new URISyntaxException(urn.toString(), "Urn entity type should be 'mlFeature'.");
} else {
TupleKey key = urn.getEntityKey();
if (key.size() != 2) {
throw new URISyntaxException(urn.toString(), "Invalid number of keys.");
} else {
try {
return new MLFeatureUrn((String) key.getAs(0, String.class), (String) key.getAs(1, String.class));
} catch (Exception e) {
throw new URISyntaxException(urn.toString(), "Invalid URN Parameter: '" + e.getMessage());
}
}
}
}
static {
Custom.registerCoercer(new DirectCoercer<MLFeatureUrn>() {
public Object coerceInput(MLFeatureUrn object) throws ClassCastException {
return object.toString();
}
public MLFeatureUrn coerceOutput(Object object) throws TemplateOutputCastException {
try {
return MLFeatureUrn.createFromString((String) object);
} catch (URISyntaxException e) {
throw new TemplateOutputCastException("Invalid URN syntax: " + e.getMessage(), e);
}
}
}, MLFeatureUrn.class);
}
}

View File

@ -1,5 +1,8 @@
package com.linkedin.common.urn;
import com.linkedin.data.template.Custom;
import com.linkedin.data.template.DirectCoercer;
import com.linkedin.data.template.TemplateOutputCastException;
import java.net.URISyntaxException;
import com.linkedin.common.FabricType;
@ -11,40 +14,72 @@ public final class MLModelUrn extends Urn {
public static final String ENTITY_TYPE = "mlModel";
private static final String CONTENT_FORMAT = "(%s,%s,%s)";
private final DataPlatformUrn platformEntity;
private final String mlModelNameEntity;
private final FabricType originEntity;
private final DataPlatformUrn _platform;
private final String _mlModelName;
private final FabricType _origin;
public MLModelUrn(DataPlatformUrn platform, String mlModelName, FabricType origin) {
super(ENTITY_TYPE, String.format(CONTENT_FORMAT, platform.toString(), mlModelName, origin.name()));
this.platformEntity = platform;
this.mlModelNameEntity = mlModelName;
this.originEntity = origin;
super(ENTITY_TYPE, TupleKey.create(platform, mlModelName, origin));
this._platform = platform;
this._mlModelName = mlModelName;
this._origin = origin;
}
public DataPlatformUrn getPlatformEntity() {
return platformEntity;
return _platform;
}
public String getMlModelNameEntity() {
return mlModelNameEntity;
return _mlModelName;
}
public FabricType getOriginEntity() {
return originEntity;
return _origin;
}
public static MLModelUrn createFromString(String rawUrn) throws URISyntaxException {
String content = new Urn(rawUrn).getContent();
String[] parts = content.substring(1, content.length() - 1).split(",");
return new MLModelUrn(DataPlatformUrn.createFromString(parts[0]), parts[1], toFabricType(parts[2]));
return createFromUrn(Urn.createFromString(rawUrn));
}
public static MLModelUrn createFromUrn(Urn urn) throws URISyntaxException {
if (!"li".equals(urn.getNamespace())) {
throw new URISyntaxException(urn.toString(), "Urn namespace type should be 'li'.");
} else if (!ENTITY_TYPE.equals(urn.getEntityType())) {
throw new URISyntaxException(urn.toString(), "Urn entity type should be 'mlFeature'.");
} else {
TupleKey key = urn.getEntityKey();
if (key.size() != 3) {
throw new URISyntaxException(urn.toString(), "Invalid number of keys.");
} else {
try {
return new MLModelUrn((DataPlatformUrn) key.getAs(0, DataPlatformUrn.class),
(String) key.getAs(1, String.class), (FabricType) key.getAs(2, FabricType.class));
} catch (Exception e) {
throw new URISyntaxException(urn.toString(), "Invalid URN Parameter: '" + e.getMessage());
}
}
}
}
public static MLModelUrn deserialize(String rawUrn) throws URISyntaxException {
return createFromString(rawUrn);
}
static {
Custom.initializeCustomClass(DataPlatformUrn.class);
Custom.initializeCustomClass(FabricType.class);
Custom.registerCoercer(new DirectCoercer<MLModelUrn>() {
public Object coerceInput(MLModelUrn object) throws ClassCastException {
return object.toString();
}
public MLModelUrn coerceOutput(Object object) throws TemplateOutputCastException {
try {
return MLModelUrn.createFromString((String) object);
} catch (URISyntaxException e) {
throw new TemplateOutputCastException("Invalid URN syntax: " + e.getMessage(), e);
}
}
}, MLModelUrn.class);
}
}

View File

@ -1,17 +0,0 @@
package com.linkedin.common.urn;
public final class MultiProductUrn extends Urn {
public static final String ENTITY_TYPE = "multiProduct";
private final String productNameEntity;
public MultiProductUrn(String productName) {
super(ENTITY_TYPE, productName);
this.productNameEntity = productName;
}
public String getProductNameEntity() {
return productNameEntity;
}
}

View File

@ -32,7 +32,7 @@ public class DataProcessGraphBuilder extends BaseGraphBuilder<DataProcessSnapsho
final DataProcessUrn urn = snapshot.getUrn();
final DataProcessEntity entity = new DataProcessEntity().setUrn(urn)
.setName(urn.getNameEntity())
.setOrchestrator(urn.getOrchestrator())
.setOrchestrator(urn.getOrchestratorEntity())
.setOrigin(urn.getOriginEntity());
return Collections.singletonList(entity);

View File

@ -25,7 +25,7 @@ public class DataProcessIndexBuilder extends BaseIndexBuilder<DataProcessDocumen
@Nonnull
private static String buildBrowsePath(@Nonnull DataProcessUrn urn) {
return ("/" + urn.getOriginEntity() + "/" + urn.getOrchestrator() + "/" + urn.getNameEntity())
return ("/" + urn.getOriginEntity() + "/" + urn.getOrchestratorEntity() + "/" + urn.getNameEntity())
.replace('.', '/').toLowerCase();
}
@ -33,7 +33,7 @@ public class DataProcessIndexBuilder extends BaseIndexBuilder<DataProcessDocumen
private static DataProcessDocument setUrnDerivedFields(@Nonnull DataProcessUrn urn) {
return new DataProcessDocument()
.setName(urn.getNameEntity())
.setOrchestrator(urn.getOrchestrator())
.setOrchestrator(urn.getOrchestratorEntity())
.setUrn(urn)
.setBrowsePaths(new StringArray(Collections.singletonList(buildBrowsePath(urn))));
}

View File

@ -20,7 +20,7 @@ public class DataProcessGraphBuilderTest {
DataProcessSnapshot snapshot = new DataProcessSnapshot().setUrn(urn).setAspects(new DataProcessAspectArray());
DataProcessEntity expected = new DataProcessEntity().setUrn(urn)
.setName(urn.getNameEntity())
.setOrchestrator(urn.getOrchestrator())
.setOrchestrator(urn.getOrchestratorEntity())
.setOrigin(urn.getOriginEntity());
List<? extends RecordTemplate> dataProcessEntities = new DataProcessGraphBuilder().buildEntities(snapshot);