Skip to content

Commit 554dd0f

Browse files
author
Balamurugan Kannadasan
committed
Test email commit 2
Added Hashmap for success and failure email address for taskId mapping
1 parent 4e07bf7 commit 554dd0f

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

api/src/main/java/com/homeaway/datapullclient/process/DataPullRequestProcessor.java

+14-7
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ public class DataPullRequestProcessor implements DataPullClientService {
8585

8686
private final ThreadPoolTaskScheduler scheduler;
8787

88-
private String userEmail;
89-
private String failureEmail;
88+
HashMap<String,String> successEmails = new HashMap<>();
9089

90+
HashMap<String,String> failureEmails = new HashMap<>();
9191
public DataPullRequestProcessor(){
9292
scheduler = new ThreadPoolTaskScheduler();
9393
scheduler.setPoolSize(POOL_SIZE);
@@ -127,6 +127,10 @@ public void runSimpleDataPull(String awsenv, String pipelinename) {
127127
}
128128

129129
private void runDataPull(String json, boolean isStart, boolean validateJson) throws ProcessingException {
130+
131+
String userEmail;
132+
String failureEmail;
133+
130134
String originalInputJson = json;
131135
json = extractUserJsonFromS3IfProvided(json, isStart);
132136

@@ -148,6 +152,9 @@ private void runDataPull(String json, boolean isStart, boolean validateJson) thr
148152
JsonNode jsonNode = objectMapper.readTree(json);
149153
userEmail = null != jsonNode.get("useremailaddress") ? jsonNode.get("useremailaddress").asText(): "";
150154

155+
String taskId = jsonNode.get("cluster").get("awsenv").asText().concat("-emr-").concat(jsonNode.get("cluster").get("pipelinename").asText()).concat("-pipeline");
156+
successEmails.put(taskId,userEmail);
157+
151158
JsonNode failureEmailNode = jsonNode.get("failureemailaddress");
152159
if(StringUtils.isNotEmpty(userEmail)){
153160
failureEmail = (failureEmailNode != null) ? userEmail.concat(",").concat(failureEmailNode.asText()): userEmail;
@@ -156,7 +163,7 @@ private void runDataPull(String json, boolean isStart, boolean validateJson) thr
156163
failureEmail = (failureEmailNode != null) ? (failureEmailNode.asText()): "";
157164

158165
}
159-
166+
failureEmails.put(taskId,failureEmail);
160167

161168

162169
List<Map.Entry<String, JsonNode>> result = new LinkedList<Map.Entry<String, JsonNode>>();
@@ -218,13 +225,13 @@ private void runDataPull(String json, boolean isStart, boolean validateJson) thr
218225
log.debug("runDataPull <- return");
219226
}
220227

221-
public String successMailAddress() throws ProcessingException {
222-
return userEmail;
228+
public HashMap<String, String> successMailAddress() throws ProcessingException {
229+
return successEmails;
223230
}
224231

225232

226-
public String failureMailAddress() throws ProcessingException {
227-
return failureEmail;
233+
public HashMap<String, String> failureMailAddress() throws ProcessingException {
234+
return failureEmails;
228235
}
229236

230237

api/src/main/java/com/homeaway/datapullclient/process/DataPullTask.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ public class DataPullTask implements Runnable {
7676

7777
String jobFlowId = null;
7878

79-
String emailAddress = null;
8079
String ClusterId = null;
8180

8281
enum emailStatusCode {
@@ -453,14 +452,15 @@ private RunJobFlowResult runTaskInNewCluster(final AmazonElasticMapReduce emr, f
453452

454453
private void sendEmailNotification() throws ProcessingException {
455454
String emailStatusCodeVal = null;
455+
String emailAddress = null;
456456
try {
457457

458458
if (jobFlowId != null) {
459459
emailStatusCodeVal = emailStatusCode.CLUSTER_CREATION_SUCCESS.name();
460-
emailAddress = dataPullRequestProcessor.successMailAddress();
460+
emailAddress = dataPullRequestProcessor.successMailAddress().get(taskId);
461461
} else if (ClusterId != null) {
462462
emailStatusCodeVal = emailStatusCode.SPARK_EXEC_ON_EXISTING_CLUSTER.name();
463-
emailAddress = dataPullRequestProcessor.successMailAddress();
463+
emailAddress = dataPullRequestProcessor.successMailAddress().get(taskId);
464464
} else {
465465
if (jobFlowId == null) {
466466
emailStatusCodeVal = emailStatusCode.CLUSTER_CREATION_FAILED.name();
@@ -471,7 +471,7 @@ private void sendEmailNotification() throws ProcessingException {
471471
} else if (runTaskOnExistingClusterFail == true) {
472472
emailStatusCodeVal = emailStatusCode.RUN_ON_EXISTING_CLUSTER_FAILED.name();
473473
}
474-
emailAddress = dataPullRequestProcessor.failureMailAddress();
474+
emailAddress = dataPullRequestProcessor.failureMailAddress().get(taskId);
475475
}
476476

477477
String[] emailAddressArray = null;

0 commit comments

Comments
 (0)