Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add lix getter method #415

Merged
merged 1 commit into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
add lix getter method
  • Loading branch information
Yang Yang committed Sep 5, 2024
commit 538c2eccf1890474a2b8da3174f3a0ca3d438041
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import com.linkedin.metadata.dao.utils.ModelUtils;
import com.linkedin.metadata.events.IngestionTrackingContext;
import com.linkedin.metadata.internal.IngestionParams;
import com.linkedin.metadata.restli.lix.ResourceLix;
import com.linkedin.parseq.Task;
import com.linkedin.restli.common.HttpStatus;
import com.linkedin.restli.server.RestLiServiceException;
Expand Down Expand Up @@ -84,21 +83,6 @@ public BaseAspectRoutingResource(@Nullable Class<SNAPSHOT> snapshotClass,
_assetClass = assetClass;
}

public BaseAspectRoutingResource(@Nullable Class<SNAPSHOT> snapshotClass,
@Nullable Class<ASPECT_UNION> aspectUnionClass, @Nonnull Class<URN> urnClass, @Nonnull Class<VALUE> valueClass,
@Nonnull Class<INTERNAL_SNAPSHOT> internalSnapshotClass,
@Nonnull Class<INTERNAL_ASPECT_UNION> internalAspectUnionClass, @Nonnull Class<ASSET> assetClass,
@Nonnull ResourceLix resourceLix) {
super(snapshotClass, aspectUnionClass, urnClass, internalSnapshotClass, internalAspectUnionClass, assetClass,
resourceLix);
_valueClass = valueClass;
_aspectUnionClass = aspectUnionClass;
_snapshotClass = snapshotClass;
_internalSnapshotClass = internalSnapshotClass;
_internalAspectUnionClass = internalAspectUnionClass;
_assetClass = assetClass;
}

/**
* Get the aspect routing client manager which provides multiple aspect routing support.
* @return {@link AspectRoutingGmsClientManager}
Expand All @@ -113,7 +97,7 @@ public BaseAspectRoutingResource(@Nullable Class<SNAPSHOT> snapshotClass,
@Override
public Task<VALUE> get(@Nonnull KEY id, @QueryParam(PARAM_ASPECTS) @Optional @Nullable String[] aspectNames) {
final URN urn = toUrn(id);
return get(id, aspectNames, _resourceLix.testGet(String.valueOf(urn), urn.getEntityType()));
return get(id, aspectNames, getResourceLix().testGet(String.valueOf(urn), urn.getEntityType()));
}

@Nonnull
Expand Down Expand Up @@ -154,7 +138,7 @@ public Task<SNAPSHOT> getSnapshot(@ActionParam(PARAM_URN) @Nonnull String urnStr
@ActionParam(PARAM_ASPECTS) @Optional @Nullable String[] aspectNames) {
final URN urn = parseUrnParam(urnString);
return getSnapshot(urnString, aspectNames,
_resourceLix.testGetSnapshot(String.valueOf(urn), ModelUtils.getEntityType(urn)));
getResourceLix().testGetSnapshot(String.valueOf(urn), ModelUtils.getEntityType(urn)));
}

@Nonnull
Expand Down Expand Up @@ -244,7 +228,7 @@ public Task<BackfillResult> backfill(@ActionParam(PARAM_URNS) @Nonnull String[]
@ActionParam(PARAM_ASPECTS) @Optional @Nullable String[] aspectNames) {
final String urnString = urns[0];
final URN urn = parseUrnParam(urnString);
return backfill(urns, aspectNames, _resourceLix.testBackfillWithUrns(urnString, ModelUtils.getEntityType(urn)));
return backfill(urns, aspectNames, getResourceLix().testBackfillWithUrns(urnString, ModelUtils.getEntityType(urn)));
}

@Nonnull
Expand Down Expand Up @@ -295,7 +279,7 @@ public Task<BackfillResult> backfillWithNewValue(@ActionParam(PARAM_URNS) @Nonnu
final String urnString = urns[0];
final URN urn = parseUrnParam(urnString);
return backfillWithNewValue(urns, aspectNames,
_resourceLix.testBackfillWithNewValue(urnString, ModelUtils.getEntityType(urn)));
getResourceLix().testBackfillWithNewValue(urnString, ModelUtils.getEntityType(urn)));
}

private Task<BackfillResult> backfillWithNewValue(@ActionParam(PARAM_URNS) @Nonnull String[] urns,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import com.linkedin.metadata.dao.utils.QueryUtils;
import com.linkedin.metadata.query.BrowseResult;
import com.linkedin.metadata.query.Filter;
import com.linkedin.metadata.restli.lix.ResourceLix;
import com.linkedin.parseq.Task;
import com.linkedin.restli.server.annotations.Action;
import com.linkedin.restli.server.annotations.ActionParam;
Expand Down Expand Up @@ -62,15 +61,6 @@ public BaseBrowsableEntityResource(@Nullable Class<SNAPSHOT> snapshotClass,
super(snapshotClass, aspectUnionClass, urnClass, internalSnapshotClass, internalAspectUnionClass, assetClass);
}

public BaseBrowsableEntityResource(@Nullable Class<SNAPSHOT> snapshotClass,
@Nullable Class<ASPECT_UNION> aspectUnionClass, @Nonnull Class<URN> urnClass,
@Nonnull Class<INTERNAL_SNAPSHOT> internalSnapshotClass,
@Nonnull Class<INTERNAL_ASPECT_UNION> internalAspectUnionClass, @Nonnull Class<ASSET> assetClass,
@Nonnull ResourceLix resourceLix) {
super(snapshotClass, aspectUnionClass, urnClass, internalSnapshotClass, internalAspectUnionClass, assetClass,
resourceLix);
}

/**
* Returns a {@link BaseBrowseDAO}.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,40 +95,34 @@ public abstract class BaseEntityResource<
private final Class<INTERNAL_ASPECT_UNION> _internalAspectUnionClass;
private final Class<ASSET> _assetClass;
protected final Class<URN> _urnClass;
protected ResourceLix _resourceLix;
protected BaseTrackingManager _trackingManager = null;
private ResourceLix _defaultResourceLix = new DummyResourceLix();

// allows resource lix to be updated by real lix impl
public void setResourceLix(ResourceLix resourceLix) {
_resourceLix = resourceLix;
/**
* This method is to be overriden by specific resource endpoint implementation with real lix impl.
* @return {@link ResourceLix}
*/
protected ResourceLix getResourceLix() {
return _defaultResourceLix;
}


public BaseEntityResource(@Nullable Class<SNAPSHOT> snapshotClass, @Nullable Class<ASPECT_UNION> aspectUnionClass,
@Nonnull Class<INTERNAL_SNAPSHOT> internalSnapshotClass,
@Nonnull Class<INTERNAL_ASPECT_UNION> internalAspectUnionClass, @Nonnull Class<ASSET> assetClass) {
this(snapshotClass, aspectUnionClass, null, internalSnapshotClass, internalAspectUnionClass, assetClass,
new DummyResourceLix());
this(snapshotClass, aspectUnionClass, null, internalSnapshotClass, internalAspectUnionClass, assetClass);
}

public BaseEntityResource(@Nullable Class<SNAPSHOT> snapshotClass, @Nullable Class<ASPECT_UNION> aspectUnionClass,
@Nonnull Class<INTERNAL_SNAPSHOT> internalSnapshotClass,
@Nonnull Class<INTERNAL_ASPECT_UNION> internalAspectUnionClass, @Nonnull Class<ASSET> assetClass,
@Nonnull ResourceLix resourceLix) {
this(snapshotClass, aspectUnionClass, null, internalSnapshotClass, internalAspectUnionClass, assetClass,
resourceLix);
this(snapshotClass, aspectUnionClass, null, internalSnapshotClass, internalAspectUnionClass, assetClass);
}

public BaseEntityResource(@Nullable Class<SNAPSHOT> snapshotClass, @Nullable Class<ASPECT_UNION> aspectUnionClass,
@Nullable Class<URN> urnClass, @Nonnull Class<INTERNAL_SNAPSHOT> internalSnapshotClass,
@Nonnull Class<INTERNAL_ASPECT_UNION> internalAspectUnionClass, @Nonnull Class<ASSET> assetClass) {
this(snapshotClass, aspectUnionClass, urnClass, internalSnapshotClass, internalAspectUnionClass, assetClass,
new DummyResourceLix());
}

public BaseEntityResource(@Nullable Class<SNAPSHOT> snapshotClass, @Nullable Class<ASPECT_UNION> aspectUnionClass,
@Nullable Class<URN> urnClass, @Nonnull Class<INTERNAL_SNAPSHOT> internalSnapshotClass,
@Nonnull Class<INTERNAL_ASPECT_UNION> internalAspectUnionClass, @Nonnull Class<ASSET> assetClass,
@Nonnull ResourceLix resourceLix) {
super();
ModelUtils.validateSnapshotAspect(internalSnapshotClass, internalAspectUnionClass);
_snapshotClass = snapshotClass;
Expand All @@ -139,25 +133,22 @@ public BaseEntityResource(@Nullable Class<SNAPSHOT> snapshotClass, @Nullable Cla
_supportedAspectClasses = ModelUtils.getValidAspectTypes(_aspectUnionClass);
_supportedInternalAspectClasses = ModelUtils.getValidAspectTypes(_internalAspectUnionClass);
_assetClass = assetClass;
_resourceLix = resourceLix;
}

public BaseEntityResource(@Nullable Class<SNAPSHOT> snapshotClass, @Nullable Class<ASPECT_UNION> aspectUnionClass,
@Nullable Class<URN> urnClass, @Nullable BaseTrackingManager trackingManager,
@Nonnull Class<INTERNAL_SNAPSHOT> internalSnapshotClass,
@Nonnull Class<INTERNAL_ASPECT_UNION> internalAspectUnionClass, @Nonnull Class<ASSET> assetClass,
@Nonnull ResourceLix resourceLix) {
this(snapshotClass, aspectUnionClass, urnClass, internalSnapshotClass, internalAspectUnionClass, assetClass,
resourceLix);
this(snapshotClass, aspectUnionClass, urnClass, internalSnapshotClass, internalAspectUnionClass, assetClass);
_trackingManager = trackingManager;
}

public BaseEntityResource(@Nullable Class<SNAPSHOT> snapshotClass, @Nullable Class<ASPECT_UNION> aspectUnionClass,
@Nullable Class<URN> urnClass, @Nullable BaseTrackingManager trackingManager,
@Nonnull Class<INTERNAL_SNAPSHOT> internalSnapshotClass,
@Nonnull Class<INTERNAL_ASPECT_UNION> internalAspectUnionClass, @Nonnull Class<ASSET> assetClass) {
this(snapshotClass, aspectUnionClass, urnClass, internalSnapshotClass, internalAspectUnionClass, assetClass,
new DummyResourceLix());
this(snapshotClass, aspectUnionClass, urnClass, internalSnapshotClass, internalAspectUnionClass, assetClass);
_trackingManager = trackingManager;
}

Expand Down Expand Up @@ -221,7 +212,7 @@ protected VALUE toInternalValue(@Nonnull INTERNAL_SNAPSHOT internalSnapshot) {
@Nonnull
public Task<VALUE> get(@Nonnull KEY id, @QueryParam(PARAM_ASPECTS) @Optional @Nullable String[] aspectNames) {
final URN urn = toUrn(id);
return get(id, aspectNames, _resourceLix.testGet(String.valueOf(urn), urn.getEntityType()));
return get(id, aspectNames, getResourceLix().testGet(String.valueOf(urn), urn.getEntityType()));
}

protected Task<VALUE> get(@Nonnull KEY id, @QueryParam(PARAM_ASPECTS) @Optional @Nullable String[] aspectNames,
Expand Down Expand Up @@ -254,7 +245,7 @@ protected Task<VALUE> get(@Nonnull KEY id, @QueryParam(PARAM_ASPECTS) @Optional
public Task<Map<KEY, VALUE>> batchGet(@Nonnull Set<KEY> ids,
@QueryParam(PARAM_ASPECTS) @Optional @Nullable String[] aspectNames) {
final URN urn = ids.stream().findFirst().isPresent() ? toUrn(ids.stream().findFirst().get()) : null;
return batchGet(ids, aspectNames, _resourceLix.testBatchGet(String.valueOf(urn), ModelUtils.getEntityType(urn)));
return batchGet(ids, aspectNames, getResourceLix().testBatchGet(String.valueOf(urn), ModelUtils.getEntityType(urn)));
}

@Deprecated
Expand All @@ -281,7 +272,7 @@ public Task<BatchResult<KEY, VALUE>> batchGetWithErrors(@Nonnull Set<KEY> ids,
@QueryParam(PARAM_ASPECTS) @Optional @Nullable String[] aspectNames) {
final URN urn = ids.stream().findFirst().isPresent() ? toUrn(ids.stream().findFirst().get()) : null;
return batchGetWithErrors(ids, aspectNames,
_resourceLix.testBatchGetWithErrors(String.valueOf(urn), ModelUtils.getEntityType(urn)));
getResourceLix().testBatchGetWithErrors(String.valueOf(urn), ModelUtils.getEntityType(urn)));
}

@Nonnull
Expand Down Expand Up @@ -396,7 +387,7 @@ public Task<SNAPSHOT> getSnapshot(@ActionParam(PARAM_URN) @Nonnull String urnStr
@ActionParam(PARAM_ASPECTS) @Optional @Nullable String[] aspectNames) {
final URN urn = parseUrnParam(urnString);
return getSnapshot(urnString, aspectNames,
_resourceLix.testGetSnapshot(String.valueOf(urn), ModelUtils.getEntityType(urn)));
getResourceLix().testGetSnapshot(String.valueOf(urn), ModelUtils.getEntityType(urn)));
}

@Deprecated
Expand Down Expand Up @@ -471,7 +462,7 @@ public Task<BackfillResult> backfill(@ActionParam(PARAM_URN) @Nonnull String urn
@ActionParam(PARAM_ASPECTS) @Optional @Nullable String[] aspectNames) {
final URN urn = parseUrnParam(urnString);
return backfill(urnString, aspectNames,
_resourceLix.testBackfillLegacy(String.valueOf(urn), ModelUtils.getEntityType(urn)));
getResourceLix().testBackfillLegacy(String.valueOf(urn), ModelUtils.getEntityType(urn)));
}

@Nonnull
Expand Down Expand Up @@ -500,7 +491,7 @@ public Task<BackfillResult> backfill(@ActionParam(PARAM_URNS) @Nonnull String[]
@ActionParam(PARAM_ASPECTS) @Optional @Nullable String[] aspectNames) {
final String urnString = urns[0];
final URN urn = parseUrnParam(urnString);
return backfill(urns, aspectNames, _resourceLix.testBackfillWithUrns(urnString, ModelUtils.getEntityType(urn)));
return backfill(urns, aspectNames, getResourceLix().testBackfillWithUrns(urnString, ModelUtils.getEntityType(urn)));
}

private Task<BackfillResult> backfill(@ActionParam(PARAM_URNS) @Nonnull String[] urns,
Expand Down Expand Up @@ -528,7 +519,7 @@ public Task<BackfillResult> emitNoChangeMetadataAuditEvent(@ActionParam(PARAM_UR
final String urnString = urns[0];
final URN urn = parseUrnParam(urnString);
return emitNoChangeMetadataAuditEvent(urns, aspectNames, ingestionMode,
_resourceLix.testEmitNoChangeMetadataAuditEvent(urnString, ModelUtils.getEntityType(urn)));
getResourceLix().testEmitNoChangeMetadataAuditEvent(urnString, ModelUtils.getEntityType(urn)));
}

@Nonnull
Expand Down Expand Up @@ -559,7 +550,7 @@ public Task<BackfillResult> backfillWithNewValue(@ActionParam(PARAM_URNS) @Nonnu
final String urnString = urns[0];
final URN urn = parseUrnParam(urnString);
return backfillWithNewValue(urns, aspectNames,
_resourceLix.testBackfillWithNewValue(urnString, ModelUtils.getEntityType(urn)));
getResourceLix().testBackfillWithNewValue(urnString, ModelUtils.getEntityType(urn)));
}

private Task<BackfillResult> backfillWithNewValue(@ActionParam(PARAM_URNS) @Nonnull String[] urns,
Expand All @@ -582,7 +573,7 @@ public Task<BackfillResult> backfillEntityTables(@ActionParam(PARAM_URNS) @Nonnu
final String urnString = urns[0];
final URN urn = parseUrnParam(urnString);
return backfillEntityTables(urns, aspectNames,
_resourceLix.testBackfillEntityTables(urnString, ModelUtils.getEntityType(urn)));
getResourceLix().testBackfillEntityTables(urnString, ModelUtils.getEntityType(urn)));
}

private Task<BackfillResult> backfillEntityTables(@ActionParam(PARAM_URNS) @Nonnull String[] urns,
Expand All @@ -605,7 +596,7 @@ public Task<BackfillResult> backfillRelationshipTables(@ActionParam(PARAM_URNS)
final String urnString = urns[0];
final URN urn = parseUrnParam(urnString);
return backfillRelationshipTables(urns, aspectNames,
_resourceLix.testBackfillRelationshipTables(urnString, ModelUtils.getEntityType(urn)));
getResourceLix().testBackfillRelationshipTables(urnString, ModelUtils.getEntityType(urn)));
}

private Task<BackfillResult> backfillRelationshipTables(@ActionParam(PARAM_URNS) @Nonnull String[] urns,
Expand Down Expand Up @@ -649,7 +640,7 @@ public Task<BackfillResult> backfill(@ActionParam(PARAM_MODE) @Nonnull BackfillM
@ActionParam(PARAM_URN) @Optional @Nullable String lastUrn,
@ActionParam(PARAM_LIMIT) int limit) {
return backfill(mode, aspectNames, lastUrn, limit,
_resourceLix.testBackfill(_assetClass.getSimpleName(), mode.name()));
getResourceLix().testBackfill(_assetClass.getSimpleName(), mode.name()));
}

@Nonnull
Expand Down Expand Up @@ -849,7 +840,7 @@ public Task<List<VALUE>> filter(@QueryParam(PARAM_FILTER) @Optional @Nullable In
@QueryParam(PARAM_URN) @Optional @Nullable String lastUrn, @QueryParam(PARAM_COUNT) @Optional("10") int count) {

return filter(indexFilter, indexSortCriterion, aspectNames, lastUrn, count,
_resourceLix.testFilter(_assetClass.getSimpleName()));
getResourceLix().testFilter(_assetClass.getSimpleName()));
}

@Nonnull
Expand Down Expand Up @@ -904,7 +895,7 @@ public Task<ListResult<VALUE>> filter(@QueryParam(PARAM_FILTER) @Optional @Nulla
@QueryParam(PARAM_ASPECTS) @Optional @Nullable String[] aspectNames,
@PagingContextParam @Nonnull PagingContext pagingContext) {
return filter(indexFilter, indexSortCriterion, aspectNames, pagingContext,
_resourceLix.testFilter(_assetClass.getSimpleName()));
getResourceLix().testFilter(_assetClass.getSimpleName()));
}

@Nonnull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
import com.linkedin.metadata.query.SearchResultMetadata;
import com.linkedin.metadata.query.SortCriterion;
import com.linkedin.metadata.query.SortOrder;
import com.linkedin.metadata.restli.lix.DummyResourceLix;
import com.linkedin.metadata.restli.lix.ResourceLix;
import com.linkedin.parseq.Task;
import com.linkedin.restli.server.CollectionResult;
import com.linkedin.restli.server.PagingContext;
Expand Down Expand Up @@ -76,20 +74,9 @@ public BaseSearchableEntityResource(@Nullable Class<SNAPSHOT> snapshotClass,
@Nullable Class<ASPECT_UNION> aspectUnionClass, @Nonnull Class<URN> urnClass,
@Nonnull Class<INTERNAL_SNAPSHOT> internalSnapshotClass,
@Nonnull Class<INTERNAL_ASPECT_UNION> internalAspectUnionClass, @Nonnull Class<ASSET> assetClass) {
super(snapshotClass, aspectUnionClass, urnClass, internalSnapshotClass, internalAspectUnionClass, assetClass,
new DummyResourceLix());
super(snapshotClass, aspectUnionClass, urnClass, internalSnapshotClass, internalAspectUnionClass, assetClass);
}

public BaseSearchableEntityResource(@Nullable Class<SNAPSHOT> snapshotClass,
@Nullable Class<ASPECT_UNION> aspectUnionClass, @Nonnull Class<URN> urnClass,
@Nonnull Class<INTERNAL_SNAPSHOT> internalSnapshotClass,
@Nonnull Class<INTERNAL_ASPECT_UNION> internalAspectUnionClass, @Nonnull Class<ASSET> assetClass,
@Nonnull ResourceLix resourceLix) {
super(snapshotClass, aspectUnionClass, urnClass, internalSnapshotClass, internalAspectUnionClass, assetClass,
resourceLix);
}


/**
* Returns a document-specific {@link BaseSearchDAO}.
*/
Expand All @@ -113,7 +100,7 @@ public Task<List<VALUE>> getAll(@Nonnull PagingContext pagingContext,
@QueryParam(PARAM_FILTER) @Optional @Nullable Filter filter,
@QueryParam(PARAM_SORT) @Optional @Nullable SortCriterion sortCriterion) {
final String urnType = _urnClass == null ? null : _urnClass.getSimpleName();
return getAll(pagingContext, aspectNames, filter, sortCriterion, _resourceLix.testGetAll(urnType));
return getAll(pagingContext, aspectNames, filter, sortCriterion, getResourceLix().testGetAll(urnType));
}

@Nonnull
Expand All @@ -139,7 +126,7 @@ public Task<CollectionResult<VALUE, SearchResultMetadata>> search(@QueryParam(PA
@QueryParam(PARAM_SORT) @Optional @Nullable SortCriterion sortCriterion,
@PagingContextParam @Nonnull PagingContext pagingContext) {
final String urnType = _urnClass == null ? null : _urnClass.getSimpleName();
return search(input, aspectNames, filter, sortCriterion, pagingContext, _resourceLix.testSearch(urnType));
return search(input, aspectNames, filter, sortCriterion, pagingContext, getResourceLix().testSearch(urnType));
}

@Nonnull
Expand Down Expand Up @@ -177,7 +164,7 @@ public Task<CollectionResult<VALUE, SearchResultMetadata>> searchV2(@QueryParam(
@PagingContextParam @Nonnull PagingContext pagingContext) {
final String urnType = _urnClass == null ? null : _urnClass.getSimpleName();
return searchV2(input, aspectNames, filter, sortCriterion, preference, pagingContext,
_resourceLix.testSearchV2(urnType));
getResourceLix().testSearchV2(urnType));
}

@Nonnull
Expand Down
Loading
Loading