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][Runner] Fixed Multiple metric are configured for a Job By Local mode, resulting in abnormal alarm information. #375

Merged
merged 1 commit into from
Mar 8, 2024
Merged
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
78 changes: 41 additions & 37 deletions datavines-runner/src/main/java/io/datavines/runner/JobRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,46 +99,50 @@ public void run() {
Map<String,String> scriptConfigMap = new HashMap<>();
scriptConfigMap.put("execution_id", String.valueOf(jobExecutionId));
executeRequestParam.setScript(validateResultStorageFactory.getDialect().getValidateResultDataScript(scriptConfigMap));
ConnectorResponse response = validateResultStorageFactory.getExecutor().queryForOne(executeRequestParam);
ConnectorResponse response = validateResultStorageFactory.getExecutor().queryForList(executeRequestParam);
if (response != null && response.getResult()!= null) {
ListWithQueryColumn validateResultDataList = (ListWithQueryColumn)response.getResult();
Map<String, Object> validateResultData = validateResultDataList.getResultList().get(0);
MetricExecutionResult metricExecutionResult = new MetricExecutionResult(validateResultData);
if (!MetricValidator.isSuccess(metricExecutionResult)) {
if (StringUtils.isEmpty(jobExecutionRequest.getNotificationParameters())) {
log.warn("notification parameter is null");
return;
}

List<NotificationParameter> notificationParameters =
JSONUtils.toList(jobExecutionRequest.getNotificationParameters(), NotificationParameter.class);

if (CollectionUtils.isEmpty(notificationParameters)) {
log.error("parse notification parameter error");
return;
}

SlaNotificationMessage notificationMessage = new SlaNotificationMessage();
notificationMessage.setMessage(buildAlertMessage(metricExecutionResult, jobExecutionRequest.getEngineType(), jobExecutionRequest.isEn()));
notificationMessage.setSubject(buildAlertSubject(metricExecutionResult, jobExecutionRequest.isEn()));
Map<SlaSenderMessage, Set<SlaConfigMessage>> configMap = new HashMap<>();
for (NotificationParameter notificationParameter : notificationParameters) {
SlaSenderMessage slaSenderMessage = new SlaSenderMessage();
slaSenderMessage.setType(notificationParameter.getType());
slaSenderMessage.setConfig(JSONUtils.toJsonString(notificationParameter.getConfig()));

Set<SlaConfigMessage> set = new HashSet<>();
if (MapUtils.isNotEmpty(notificationParameter.getReceiver())) {
SlaConfigMessage slaConfigMessage = new SlaConfigMessage();
slaConfigMessage.setType(notificationParameter.getType());
slaConfigMessage.setConfig(JSONUtils.toJsonString(notificationParameter.getReceiver()));
set.add(slaConfigMessage);
ListWithQueryColumn validateResult = (ListWithQueryColumn)response.getResult();
List<Map<String, Object>> validateResultDataList = validateResult.getResultList();
if(validateResultDataList != null){
for(Map<String, Object> validateResultData : validateResultDataList){
MetricExecutionResult metricExecutionResult = new MetricExecutionResult(validateResultData);
if (!MetricValidator.isSuccess(metricExecutionResult)) {
if (StringUtils.isEmpty(jobExecutionRequest.getNotificationParameters())) {
log.warn("notification parameter is null");
return;
}

List<NotificationParameter> notificationParameters =
JSONUtils.toList(jobExecutionRequest.getNotificationParameters(), NotificationParameter.class);

if (CollectionUtils.isEmpty(notificationParameters)) {
log.error("parse notification parameter error");
return;
}

SlaNotificationMessage notificationMessage = new SlaNotificationMessage();
notificationMessage.setMessage(buildAlertMessage(metricExecutionResult, jobExecutionRequest.getEngineType(), jobExecutionRequest.isEn()));
notificationMessage.setSubject(buildAlertSubject(metricExecutionResult, jobExecutionRequest.isEn()));
Map<SlaSenderMessage, Set<SlaConfigMessage>> configMap = new HashMap<>();
for (NotificationParameter notificationParameter : notificationParameters) {
SlaSenderMessage slaSenderMessage = new SlaSenderMessage();
slaSenderMessage.setType(notificationParameter.getType());
slaSenderMessage.setConfig(JSONUtils.toJsonString(notificationParameter.getConfig()));

Set<SlaConfigMessage> set = new HashSet<>();
if (MapUtils.isNotEmpty(notificationParameter.getReceiver())) {
SlaConfigMessage slaConfigMessage = new SlaConfigMessage();
slaConfigMessage.setType(notificationParameter.getType());
slaConfigMessage.setConfig(JSONUtils.toJsonString(notificationParameter.getReceiver()));
set.add(slaConfigMessage);
}
configMap.put(slaSenderMessage, set);
}

NotificationManager notificationManager = new NotificationManager();
notificationManager.notify(notificationMessage, configMap);
}
configMap.put(slaSenderMessage, set);
}

NotificationManager notificationManager = new NotificationManager();
notificationManager.notify(notificationMessage, configMap);
}
}
}
Expand Down
Loading