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

test PR for BAM- Taskheaders #3682

Open
wants to merge 5 commits into
base: beta
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ on:
- staging
- lineageondemand
- gziplineage
- taskheaders

jobs:
build:
Expand Down
19 changes: 19 additions & 0 deletions common/src/main/java/org/apache/atlas/repository/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.HashSet;
import java.util.Set;

Expand Down Expand Up @@ -409,6 +410,24 @@ public final class Constants {
public static final String TASK_ENTITY_GUID = encodePropertyKey(TASK_PREFIX + "entityGuid");
public static final String TASK_CLASSIFICATION_TYPENAME = encodePropertyKey(TASK_PREFIX + "classificationTypeName");
public static final String ACTIVE_STATE_VALUE = "ACTIVE";
public static final String TASK_HEADER_ATLAN_AGENT = "x-atlan-agent"
public static final String TASK_HEADER_ATLAN_AGENT_ID = "x-atlan-agent-id"
public static final String TASK_HEADER_ATLAN_PKG_NAME = "x-atlan-package-name"
public static final String TASK_HEADER_ATLAN_AGENT_WORKFLOW_ID = "x-atlan-agent-workflow-id"
public static final String TASK_HEADER_ATLAN_VIA_UI = "x-atlan-via-ui"
public static final String TASK_HEADER_ATLAN_REQUEST_ID = "x-atlan-request-id"
public static final String TASK_HEADER_ATLAN_GOOGLE_SHEETS_ID = "x-atlan-google-sheets-id"
public static final String TASK_HEADER_ATLAN_MS_EXCEL_ID = "x-atlan-microsoft-excel-id"
public static final Map<String, bool> TASK_HEADER_MAP = Map.of(
TASK_HEADER_ATLAN_AGENT, true,
TASK_HEADER_ATLAN_AGENT_ID, true,
TASK_HEADER_ATLAN_PKG_NAME, true,
TASK_HEADER_ATLAN_AGENT_WORKFLOW_ID, true,
TASK_HEADER_ATLAN_VIA_UI, true,
TASK_HEADER_ATLAN_REQUEST_ID, true,
TASK_HEADER_ATLAN_GOOGLE_SHEETS_ID, true,
TASK_HEADER_ATLAN_MS_EXCEL_ID, true
);

/**
* Index Recovery vertex property keys.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,15 @@ private void initialize(AtlasGraph graph) throws RepositoryException, IndexExcep
createCommonVertexIndex(management, TASK_TIME_TAKEN_IN_SECONDS, UniqueKind.NONE, Long.class, SINGLE, false, false);
createCommonVertexIndex(management, TASK_START_TIME, UniqueKind.NONE, Long.class, SINGLE, false, false);
createCommonVertexIndex(management, TASK_END_TIME, UniqueKind.NONE, Long.class, SINGLE, false, false);

createCommonVertexIndex(management, TASK_HEADER_ATLAN_AGENT, UniqueKind.NONE, String.class, SINGLE, true, false, true);
createCommonVertexIndex(management, TASK_HEADER_ATLAN_AGENT_ID, UniqueKind.NONE, String.class, SINGLE, true, false, true);
createCommonVertexIndex(management, TASK_HEADER_ATLAN_PKG_NAME, UniqueKind.NONE, String.class, SINGLE, true, false, true);
createCommonVertexIndex(management, TASK_HEADER_ATLAN_AGENT_WORKFLOW_ID, UniqueKind.NONE, String.class, SINGLE, true, false, true);
createCommonVertexIndex(management, TASK_HEADER_ATLAN_VIA_UI, UniqueKind.NONE, String.class, SINGLE, true, false, true);
createCommonVertexIndex(management, TASK_HEADER_ATLAN_REQUEST_ID, UniqueKind.NONE, String.class, SINGLE, true, false, true);
createCommonVertexIndex(management, TASK_HEADER_ATLAN_GOOGLE_SHEETS_ID, UniqueKind.NONE, String.class, SINGLE, true, false, true);
createCommonVertexIndex(management, TASK_HEADER_ATLAN_MS_EXCEL_ID, UniqueKind.NONE, String.class, SINGLE, true, false, true);

// index recovery
createCommonVertexIndex(management, PROPERTY_KEY_INDEX_RECOVERY_NAME, UniqueKind.GLOBAL_UNIQUE, String.class, SINGLE, true, false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ private void deleteTask(String taskGuid) throws AtlasBaseException {
@Override
public AtlasVertex createTaskVertex(AtlasTask task) {
AtlasVertex ret = graph.addVertex();
Map<String, String> requestContextHeaders = RequestContext.get().getRequestContextHeaders();

setEncodedProperty(ret, Constants.TASK_GUID, task.getGuid());
setEncodedProperty(ret, Constants.TASK_TYPE_PROPERTY_KEY, Constants.TASK_TYPE_NAME);
Expand Down Expand Up @@ -253,6 +254,16 @@ public AtlasVertex createTaskVertex(AtlasTask task) {
setEncodedProperty(ret, Constants.TASK_END_TIME, task.getEndTime().getTime());
}

if (MapUtils.isNotEmpty(requestContextHeaders)) {
for (Map.Entry<String, String> entry : requestContextHeaders.entrySet()) {
String key = entry.getKey();
if (Constants.TASK_HEADER_MAP.containsKey(key)) {
String val = entry.getValue();
setEncodedProperty(ret, key, val);
}
}
}

setEncodedProperty(ret, Constants.TASK_PARAMETERS, AtlasJson.toJson(task.getParameters()));
setEncodedProperty(ret, Constants.TASK_ATTEMPT_COUNT, task.getAttemptCount());
setEncodedProperty(ret, Constants.TASK_ERROR_MESSAGE, task.getErrorMessage());
Expand Down
Loading