Commit 92f3a91e by Madhan Neethiraj

ATLAS-2729: fix - audit logging fails for large entities

parent 52d5e474
......@@ -187,6 +187,17 @@ public class EntityAuditListener implements EntityChangeListener {
entity.setValues(null);
auditString = auditPrefix + AtlasType.toV1Json(entity);
auditBytes = auditString.getBytes(StandardCharsets.UTF_8); // recheck auditString size
auditSize = auditBytes != null ? auditBytes.length : 0;
if (auditMaxSize >= 0 && auditSize > auditMaxSize) { // don't store classifications as well
LOG.warn("audit record still too long: entityType={}, guid={}, size={}; maxSize={}. audit will have only summary details",
entity.getTypeName(), entity.getId()._getId(), auditSize, auditMaxSize);
Referenceable shallowEntity = new Referenceable(entity.getId(), entity.getTypeName(), null, entity.getSystemAttributes(), null, null);
auditString = auditPrefix + AtlasType.toJson(shallowEntity);
}
entity.setValues(attrValues);
}
......
......@@ -235,12 +235,35 @@ public class EntityAuditListenerV2 implements EntityChangeListenerV2 {
entity.getTypeName(), entity.getGuid(), auditSize, auditMaxSize);
Map<String, Object> attrValues = entity.getAttributes();
Map<String, Object> relAttrValues = entity.getRelationshipAttributes();
entity.setAttributes(null);
entity.setRelationshipAttributes(null);
auditString = auditPrefix + AtlasType.toJson(entity);
auditBytes = auditString.getBytes(StandardCharsets.UTF_8); // recheck auditString size
auditSize = auditBytes != null ? auditBytes.length : 0;
if (auditMaxSize >= 0 && auditSize > auditMaxSize) { // don't store classifications and meanings as well
LOG.warn("audit record still too long: entityType={}, guid={}, size={}; maxSize={}. audit will have only summary details",
entity.getTypeName(), entity.getGuid(), auditSize, auditMaxSize);
AtlasEntity shallowEntity = new AtlasEntity();
shallowEntity.setGuid(entity.getGuid());
shallowEntity.setTypeName(entity.getTypeName());
shallowEntity.setCreateTime(entity.getCreateTime());
shallowEntity.setUpdateTime(entity.getUpdateTime());
shallowEntity.setCreatedBy(entity.getCreatedBy());
shallowEntity.setUpdatedBy(entity.getUpdatedBy());
shallowEntity.setStatus(entity.getStatus());
shallowEntity.setVersion(entity.getVersion());
auditString = auditPrefix + AtlasType.toJson(shallowEntity);
}
entity.setAttributes(attrValues);
entity.setRelationshipAttributes(relAttrValues);
}
restoreEntityAttributes(entity, prunedAttributes);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment