Skip to content

Commit bf4d46a

Browse files
Merge pull request #5370 from atlanhq/MLH-1224
MLH-1224 Ensure restoration info is captured in ENTITY_UPDATE events for MDLH
2 parents 32c9021 + 63c56d1 commit bf4d46a

File tree

5 files changed

+23
-11
lines changed

5 files changed

+23
-11
lines changed

common/src/main/java/org/apache/atlas/service/FeatureFlagStore.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.apache.atlas.service;
22

3+
import org.apache.atlas.service.redis.NoRedisServiceImpl;
34
import org.apache.atlas.service.redis.RedisService;
45
import org.apache.commons.lang.StringUtils;
56
import org.springframework.beans.BeansException;
@@ -105,6 +106,10 @@ public void initialize() throws InterruptedException {
105106
private void validateDependencies() {
106107
LOG.info("Validating FeatureFlagStore dependencies...");
107108
try {
109+
if (redisService instanceof NoRedisServiceImpl) {
110+
return;
111+
}
112+
108113
// Test Redis connectivity with a simple operation
109114
String testKey = "ff:_health_check";
110115
redisService.putValue(testKey, "test");

common/src/main/java/org/apache/atlas/service/redis/NoRedisServiceImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import javax.annotation.PostConstruct;
99

10-
@Component
10+
@Component("redisServiceImpl")
1111
@ConditionalOnAtlasProperty(property = "atlas.redis.service.impl", isDefault = true)
1212
public class NoRedisServiceImpl extends AbstractRedisService {
1313

common/src/main/java/org/apache/atlas/service/redis/RedisServiceLocalImpl.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
import javax.annotation.PostConstruct;
1111

12-
@Component
12+
@Component("redisServiceImpl")
1313
@ConditionalOnAtlasProperty(property = "atlas.redis.service.impl")
1414
public class RedisServiceLocalImpl extends AbstractRedisService {
1515

@@ -24,17 +24,17 @@ public void init() throws AtlasException {
2424

2525
@Override
2626
public String getValue(String key) {
27-
return null;
27+
return super.getValue(key);
2828
}
2929

3030
@Override
3131
public String putValue(String key, String value, int timeout) {
32-
return null;
32+
return super.putValue(key, value, timeout);
3333
}
3434

3535
@Override
3636
public void removeValue(String key) {
37-
37+
super.removeValue(key);
3838
}
3939

4040
@Override

repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasEntityComparator.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.apache.atlas.model.TypeCategory;
2424
import org.apache.atlas.model.instance.AtlasClassification;
2525
import org.apache.atlas.model.instance.AtlasEntity;
26+
import org.apache.atlas.repository.graph.GraphHelper;
2627
import org.apache.atlas.repository.graphdb.AtlasVertex;
2728
import org.apache.atlas.repository.util.AtlasEntityUtils;
2829
import org.apache.atlas.service.FeatureFlagStore;
@@ -245,6 +246,15 @@ private AtlasEntityDiffResult getDiffResult(AtlasEntity updatedEntity, AtlasEnti
245246
}
246247
}
247248

249+
AtlasEntity.Status newStatus = updatedEntity.getStatus();
250+
if (newStatus != null && newStatus.equals(AtlasEntity.Status.ACTIVE)) {
251+
String currStatus = GraphHelper.getStateAsString(storedVertex);
252+
if (currStatus != null && !currStatus.equals(newStatus.name())) {
253+
sectionsWithDiff++;
254+
diffEntity.setStatus(AtlasEntity.Status.ACTIVE);
255+
}
256+
}
257+
248258
return new AtlasEntityDiffResult(diffEntity, sectionsWithDiff > 0, sectionsWithDiff == 1 && hasDiffInCustomAttributes, sectionsWithDiff == 1 && hasDiffInBusinessAttributes);
249259
}
250260

repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphMapper.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,9 @@ public EntityMutationResponse mapAttributesAndClassifications(EntityMutationCont
358358

359359
if (CollectionUtils.isNotEmpty(context.getEntitiesToRestore())) {
360360
restoreHandlerV1.restoreEntities(context.getEntitiesToRestore());
361+
for (AtlasEntityHeader restoredEntity : reqContext.getRestoredEntities()) {
362+
resp.addEntity(UPDATE, restoredEntity);
363+
}
361364
}
362365

363366
Collection<AtlasEntity> createdEntities = context.getCreatedEntities();
@@ -594,12 +597,6 @@ public EntityMutationResponse mapAttributesAndClassifications(EntityMutationCont
594597
resp.addEntity(updateType, entity);
595598
}
596599

597-
if (req.getRestoredEntities() != null && req.getRestoredEntities().size() > 0) {
598-
for (AtlasEntityHeader entity : req.getRestoredEntities()) {
599-
resp.addEntity(UPDATE, entity);
600-
}
601-
}
602-
603600
RequestContext.get().endMetricRecord(metric);
604601

605602
return resp;

0 commit comments

Comments
 (0)