Skip to content

Commit

Permalink
DG-1697: review fix
Browse files Browse the repository at this point in the history
  • Loading branch information
arpit-at committed Jul 25, 2024
1 parent e8b73a5 commit 2cc48af
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 22 deletions.
1 change: 1 addition & 0 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ on:
- development
- master
- lineageondemand
- policyendpointsmasterss

jobs:
build:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,12 @@ public class AtlasEntityStoreV2 implements AtlasEntityStore {

private final ESAliasStore esAliasStore;

private final IAtlasAlternateChangeNotifier atlasAlternateChangeNotifier;
private final IAtlasMinimalChangeNotifier atlasAlternateChangeNotifier;
@Inject
public AtlasEntityStoreV2(AtlasGraph graph, DeleteHandlerDelegate deleteDelegate, RestoreHandlerV1 restoreHandlerV1, AtlasTypeRegistry typeRegistry,
IAtlasEntityChangeNotifier entityChangeNotifier, EntityGraphMapper entityGraphMapper, TaskManagement taskManagement,
AtlasRelationshipStore atlasRelationshipStore, FeatureFlagStore featureFlagStore,
IAtlasAlternateChangeNotifier atlasAlternateChangeNotifier) {
IAtlasMinimalChangeNotifier atlasAlternateChangeNotifier) {
this.graph = graph;
this.deleteDelegate = deleteDelegate;
this.restoreHandlerV1 = restoreHandlerV1;
Expand Down Expand Up @@ -2765,11 +2765,6 @@ public void unlinkBusinessPolicy(String policyGuid, Set<String> unlinkGuids) thr

private void handleBusinessPolicyMutation(List<AtlasVertex> vertices) throws AtlasBaseException {
AtlasPerfMetrics.MetricRecorder metricRecorder = RequestContext.get().startMetricRecord("handleBusinessPolicyMutation");
vertices.forEach(vertex -> {
Map<String, Object> attributes = new HashMap<>(0);
attributes.put(ASSET_POLICY_GUIDS, vertex.getMultiValuedSetProperty(ASSET_POLICY_GUIDS, String.class));
attributes.put(ASSET_POLICIES_COUNT, vertex.getPropertyValues(ASSET_POLICIES_COUNT, Long.class));
});
this.atlasAlternateChangeNotifier.onEntitiesMutation(vertices);
RequestContext.get().endMetricRecord(metricRecorder);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,19 @@
import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.listener.EntityChangeListenerV2;
import org.apache.atlas.model.instance.AtlasEntity;
import org.apache.atlas.model.instance.AtlasEntityHeader;
import org.apache.atlas.model.instance.EntityMutationResponse;
import org.apache.atlas.repository.graphdb.AtlasVertex;
import org.apache.atlas.utils.AtlasPerfMetrics;
import org.springframework.stereotype.Component;

import javax.inject.Inject;
import java.util.*;
import java.util.stream.Collectors;

import static org.apache.atlas.repository.Constants.*;
import static org.apache.atlas.repository.graph.GraphHelper.*;


@Component
public class BusinessPolicyNotifierImpl implements IAtlasAlternateChangeNotifier {
public class BusinessPolicyNotifierImpl implements IAtlasMinimalChangeNotifier {

private final Set<EntityChangeListenerV2> entityChangeListenersV2;

Expand Down Expand Up @@ -56,14 +53,9 @@ private AtlasEntity createAtlasEntity(AtlasVertex vertex) {
atlasEntity.setIsIncomplete(vertex.getProperty(IS_INCOMPLETE_PROPERTY_KEY, Boolean.class));
atlasEntity.setStatus(getStatus(vertex));
atlasEntity.setProvenanceType(getProvenanceType(vertex));
atlasEntity.setCustomAttributes(getCustomAttributes(vertex));
atlasEntity.setHomeId(getHomeId(vertex));
atlasEntity.setVersion(getVersion(vertex));

atlasEntity.setAttribute(NAME, vertex.getProperty(NAME, String.class));
atlasEntity.setAttribute(EntityGraphRetriever.DESCRIPTION, vertex.getProperty(EntityGraphRetriever.DESCRIPTION, String.class));
atlasEntity.setAttribute(OWNER_ATTRIBUTE, vertex.getProperty(OWNER_ATTRIBUTE, String.class));
atlasEntity.setAttribute(EntityGraphRetriever.CREATE_TIME, new Date(vertex.getProperty(TIMESTAMP_PROPERTY_KEY, Long.class)));

return atlasEntity;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@
package org.apache.atlas.repository.store.graph.v2;

import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.model.instance.*;
import org.apache.atlas.repository.graphdb.AtlasVertex;

import java.util.List;
import java.util.Map;

public interface IAtlasAlternateChangeNotifier {
public interface IAtlasMinimalChangeNotifier {
void onEntitiesMutation(final List<AtlasVertex> vertices) throws AtlasBaseException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
public class BusinessPolicyREST {

private static final Logger LOG = LoggerFactory.getLogger(BusinessPolicyREST.class);
private static final Logger PERF_LOG = AtlasPerfTracer.getPerfLogger("rest.AlternateREST");
private static final Logger PERF_LOG = AtlasPerfTracer.getPerfLogger("rest.BusinessPolicyREST");

private final AtlasEntityStore entitiesStore;

Expand Down Expand Up @@ -62,7 +62,7 @@ public void linkBusinessPolicy(@PathParam("policyId") final String policyGuid, f
try {
// Start performance tracing if enabled
if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "AlternateREST.linkBusinessPolicy(" + policyGuid + ")");
perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "BusinessPolicyREST.linkBusinessPolicy(" + policyGuid + ")");
}

// Link the business policy to the specified entities
Expand Down Expand Up @@ -99,7 +99,7 @@ public void unlinkBusinessPolicy(@PathParam("policyId") final String policyGuid,
try {
// Start performance tracing if enabled
if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "AlternateREST.unlinkBusinessPolicy(" + policyGuid + ")");
perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "BusinessPolicyREST.unlinkBusinessPolicy(" + policyGuid + ")");
}

// Unlink the business policy from the specified entities
Expand Down

0 comments on commit 2cc48af

Please sign in to comment.