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

fix: Add error code for unknown errors so we could run pinpoint on them #2803

Merged
merged 4 commits into from
Jan 31, 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
3 changes: 3 additions & 0 deletions intg/src/main/java/org/apache/atlas/AtlasErrorCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,8 @@ public enum AtlasErrorCode {
CATEGORY_PARENT_FROM_OTHER_GLOSSARY(409, "ATLAS-400-00-0015", "Parent category from another Anchor(glossary) not supported"),
CLASSIFICATION_TYPE_HAS_REFERENCES(409, "ATLAS-400-00-0016", "Given classification {0} [{1}] has references"),
// All internal errors go here
UNKNOWN_SERVER_ERROR(500, "ATLAS-500-00-000", "Unknown server error detected {0}"),

INTERNAL_ERROR(500, "ATLAS-500-00-001", "Internal server error {0}"),
INDEX_CREATION_FAILED(500, "ATLAS-500-00-002", "Index creation failed for {0}"),
INDEX_ROLLBACK_FAILED(500, "ATLAS-500-00-003", "Index rollback failed for {0}"),
Expand Down Expand Up @@ -271,6 +273,7 @@ public enum AtlasErrorCode {
CINV_UNHEALTHY(500, "ATLAS-500-00-21", "Unable to process type-definition operations"),
RUNTIME_EXCEPTION(500, "ATLAS-500-00-020", "Runtime exception {0}"),
KEYCLOAK_INIT_FAILED(500, "ATLAS-500-00-022", "Failed to initialize keycloak client: {0}"),

BATCH_SIZE_TOO_LARGE(406, "ATLAS-406-00-001", "Batch size is too large, please use a smaller batch size"),


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@
import static org.apache.atlas.repository.graph.GraphHelper.*;
import static org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2.getIdFromVertex;
import static org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2.isReference;
import static org.apache.atlas.repository.store.graph.v2.tasks.ClassificationPropagateTaskFactory.CLASSIFICATION_ONLY_PROPAGATION_DELETE;
import static org.apache.atlas.type.AtlasStructType.AtlasAttribute.AtlasRelationshipEdgeDirection;
import static org.apache.atlas.type.AtlasStructType.AtlasAttribute.AtlasRelationshipEdgeDirection.BOTH;
import static org.apache.atlas.type.AtlasStructType.AtlasAttribute.AtlasRelationshipEdgeDirection.IN;
Expand Down Expand Up @@ -975,76 +974,84 @@ private AtlasEntityHeader mapVertexToAtlasEntityHeader(AtlasVertex entityVertex)
private AtlasEntityHeader mapVertexToAtlasEntityHeader(AtlasVertex entityVertex, Set<String> attributes) throws AtlasBaseException {
AtlasPerfMetrics.MetricRecorder metricRecorder = RequestContext.get().startMetricRecord("mapVertexToAtlasEntityHeader");
AtlasEntityHeader ret = new AtlasEntityHeader();
try {
String typeName = entityVertex.getProperty(Constants.TYPE_NAME_PROPERTY_KEY, String.class);
String guid = entityVertex.getProperty(Constants.GUID_PROPERTY_KEY, String.class);
Boolean isIncomplete = isEntityIncomplete(entityVertex);

ret.setTypeName(typeName);
ret.setGuid(guid);
ret.setStatus(GraphHelper.getStatus(entityVertex));
if(RequestContext.get().includeClassifications()){
ret.setClassificationNames(getAllTraitNames(entityVertex));
}
ret.setIsIncomplete(isIncomplete);
ret.setLabels(getLabels(entityVertex));

ret.setCreatedBy(GraphHelper.getCreatedByAsString(entityVertex));
ret.setUpdatedBy(GraphHelper.getModifiedByAsString(entityVertex));
ret.setCreateTime(new Date(GraphHelper.getCreatedTime(entityVertex)));
ret.setUpdateTime(new Date(GraphHelper.getModifiedTime(entityVertex)));

if(RequestContext.get().includeMeanings()) {
List<AtlasTermAssignmentHeader> termAssignmentHeaders = mapAssignedTerms(entityVertex);
ret.setMeanings(termAssignmentHeaders);
ret.setMeaningNames(
termAssignmentHeaders.stream().map(AtlasTermAssignmentHeader::getDisplayText)
.collect(Collectors.toList()));
}
AtlasEntityType entityType = typeRegistry.getEntityTypeByName(typeName);

String typeName = entityVertex.getProperty(Constants.TYPE_NAME_PROPERTY_KEY, String.class);
String guid = entityVertex.getProperty(Constants.GUID_PROPERTY_KEY, String.class);
Boolean isIncomplete = isEntityIncomplete(entityVertex);

ret.setTypeName(typeName);
ret.setGuid(guid);
ret.setStatus(GraphHelper.getStatus(entityVertex));
if(RequestContext.get().includeClassifications()){
ret.setClassificationNames(getAllTraitNames(entityVertex));
}
ret.setIsIncomplete(isIncomplete);
ret.setLabels(getLabels(entityVertex));

ret.setCreatedBy(GraphHelper.getCreatedByAsString(entityVertex));
ret.setUpdatedBy(GraphHelper.getModifiedByAsString(entityVertex));
ret.setCreateTime(new Date(GraphHelper.getCreatedTime(entityVertex)));
ret.setUpdateTime(new Date(GraphHelper.getModifiedTime(entityVertex)));
if (entityType != null) {
for (AtlasAttribute headerAttribute : entityType.getHeaderAttributes().values()) {
Object attrValue = getVertexAttribute(entityVertex, headerAttribute);

if(RequestContext.get().includeMeanings()) {
List<AtlasTermAssignmentHeader> termAssignmentHeaders = mapAssignedTerms(entityVertex);
ret.setMeanings(termAssignmentHeaders);
ret.setMeaningNames(
termAssignmentHeaders.stream().map(AtlasTermAssignmentHeader::getDisplayText)
.collect(Collectors.toList()));
}
AtlasEntityType entityType = typeRegistry.getEntityTypeByName(typeName);
if (attrValue != null) {
ret.setAttribute(headerAttribute.getName(), attrValue);
}
}

if (entityType != null) {
for (AtlasAttribute headerAttribute : entityType.getHeaderAttributes().values()) {
Object attrValue = getVertexAttribute(entityVertex, headerAttribute);
Object displayText = getDisplayText(entityVertex, entityType);

if (attrValue != null) {
ret.setAttribute(headerAttribute.getName(), attrValue);
if (displayText != null) {
ret.setDisplayText(displayText.toString());
}
}

Object displayText = getDisplayText(entityVertex, entityType);
if (CollectionUtils.isNotEmpty(attributes)) {
for (String attrName : attributes) {
AtlasAttribute attribute = entityType.getAttribute(attrName);

if (displayText != null) {
ret.setDisplayText(displayText.toString());
}
if (attribute == null) {
attrName = toNonQualifiedName(attrName);

if (CollectionUtils.isNotEmpty(attributes)) {
for (String attrName : attributes) {
AtlasAttribute attribute = entityType.getAttribute(attrName);
if (ret.hasAttribute(attrName)) {
continue;
}

if (attribute == null) {
attrName = toNonQualifiedName(attrName);
attribute = entityType.getAttribute(attrName);

if (ret.hasAttribute(attrName)) {
continue;
if (attribute == null) {
attribute = entityType.getRelationshipAttribute(attrName, null);
}
}

attribute = entityType.getAttribute(attrName);
Object attrValue = getVertexAttribute(entityVertex, attribute);

if (attribute == null) {
attribute = entityType.getRelationshipAttribute(attrName, null);
if (attrValue != null) {
ret.setAttribute(attrName, attrValue);
}
}

Object attrValue = getVertexAttribute(entityVertex, attribute);

if (attrValue != null) {
ret.setAttribute(attrName, attrValue);
}
}
}
}
RequestContext.get().endMetricRecord(metricRecorder);
catch (NullPointerException npe) {
String id = entityVertex.getIdForDisplay()==null ? "null" :entityVertex.getIdForDisplay();
LOG.error("mapVertexToAtlasEntityHeader: failed for entityVertex with id {}", id, npe);
throw new AtlasBaseException(AtlasErrorCode.UNKNOWN_SERVER_ERROR, npe, "mapVertexToAtlasEntityHeader: failed for entityVertex with id " + id);
}
finally {
RequestContext.get().endMetricRecord(metricRecorder);
}
return ret;
}

Expand Down
Loading