Skip to content

Commit f6171f1

Browse files
committed
updated CloudWatch scenario
1 parent 00f4371 commit f6171f1

File tree

1 file changed

+22
-23
lines changed

1 file changed

+22
-23
lines changed

javav2/example_code/cloudwatch/src/main/java/com/example/cloudwatch/scenario/CloudWatchScenario.java

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ provided by Amazon Web Services (AWS). It is designed to help you monitor your
125125
int num;
126126
try {
127127
CompletableFuture<ArrayList<String>> future = cwActions.listNameSpacesAsync();
128-
ArrayList<String> list = future.join(); // Wait for async operation to complete.
128+
ArrayList<String> list = future.join();
129129
for (int z = 0; z < 5; z++) {
130130
int index = z + 1;
131131
logger.info(" " + index + ". {}", list.get(z));
@@ -165,7 +165,7 @@ provided by Amazon Web Services (AWS). It is designed to help you monitor your
165165
try {
166166
CompletableFuture<ArrayList<String>> future = cwActions.listMetsAsync(selectedNamespace);
167167
ArrayList<String> metList = future.join();
168-
logger.info("Metrics successfully retrieved. Total metrics: " + metList.size());
168+
logger.info("Metrics successfully retrieved. Total metrics: {}", metList.size());
169169
for (int z = 0; z < 5; z++) {
170170
int index = z + 1;
171171
logger.info(" " + index + ". " + metList.get(z));
@@ -184,20 +184,19 @@ provided by Amazon Web Services (AWS). It is designed to help you monitor your
184184
if (cause instanceof CloudWatchException cwEx) {
185185
logger.info("CloudWatch error occurred: Error message: {}, Error code {}", cwEx.getMessage(), cwEx.awsErrorDetails().errorCode());
186186
} else {
187-
logger.info("An unexpected error occurred: " + rt.getMessage());
187+
logger.info("An unexpected error occurred: {}", rt.getMessage());
188188
}
189189
}
190190

191191
try {
192-
// CompletableFuture<Dimension> future = cwActions.getSpecificMetAsync(selectedNamespace);
193192
myDimension = cwActions.getSpecificMetAsync(selectedNamespace).join();
194193
logger.info("Metric statistics successfully retrieved and displayed.");
195194
} catch (RuntimeException rt) {
196195
Throwable cause = rt.getCause();
197196
if (cause instanceof CloudWatchException cwEx) {
198197
logger.info("CloudWatch error occurred: Error message: {}, Error code {}", cwEx.getMessage(), cwEx.awsErrorDetails().errorCode());
199198
} else {
200-
logger.info("An unexpected error occurred: " + rt.getMessage());
199+
logger.info("An unexpected error occurred: {}", rt.getMessage());
201200
}
202201
}
203202

@@ -243,7 +242,7 @@ provided by Amazon Web Services (AWS). It is designed to help you monitor your
243242
if (cause instanceof CloudWatchException cwEx) {
244243
logger.info("CloudWatch error occurred: Error message: {}, Error code {}", cwEx.getMessage(), cwEx.awsErrorDetails().errorCode());
245244
} else {
246-
logger.info("An unexpected error occurred: " + rt.getMessage());
245+
logger.info("An unexpected error occurred: {}", rt.getMessage());
247246
}
248247
}
249248
waitForInputToContinue(scanner);
@@ -262,7 +261,7 @@ provided by Amazon Web Services (AWS). It is designed to help you monitor your
262261
if (cause instanceof CloudWatchException cwEx) {
263262
logger.info("CloudWatch error occurred: Error message: {}, Error code {}", cwEx.getMessage(), cwEx.awsErrorDetails().errorCode());
264263
} else {
265-
logger.info("An unexpected error occurred: " + rt.getMessage());
264+
logger.info("An unexpected error occurred: {}", rt.getMessage());
266265
}
267266
}
268267
waitForInputToContinue(scanner);
@@ -280,7 +279,7 @@ provided by Amazon Web Services (AWS). It is designed to help you monitor your
280279
if (cause instanceof CloudWatchException cwEx) {
281280
logger.info("CloudWatch error occurred: Error message: {}, Error code {}", cwEx.getMessage(), cwEx.awsErrorDetails().errorCode());
282281
} else {
283-
logger.info("An unexpected error occurred: " + rt.getMessage());
282+
logger.info("An unexpected error occurred: {}", rt.getMessage());
284283
}
285284
}
286285
waitForInputToContinue(scanner);
@@ -298,7 +297,7 @@ provided by Amazon Web Services (AWS). It is designed to help you monitor your
298297
if (cause instanceof CloudWatchException cwEx) {
299298
logger.info("CloudWatch error occurred: Error message: {}, Error code {}", cwEx.getMessage(), cwEx.awsErrorDetails().errorCode());
300299
} else {
301-
logger.info("An unexpected error occurred: " + rt.getMessage());
300+
logger.info("An unexpected error occurred: {}", rt.getMessage());
302301
}
303302
}
304303
waitForInputToContinue(scanner);
@@ -320,7 +319,7 @@ provided by Amazon Web Services (AWS). It is designed to help you monitor your
320319
if (cause instanceof CloudWatchException cwEx) {
321320
logger.info("CloudWatch error occurred: Error message: {}, Error code {}", cwEx.getMessage(), cwEx.awsErrorDetails().errorCode());
322321
} else {
323-
logger.info("An unexpected error occurred: " + rt.getMessage());
322+
logger.info("An unexpected error occurred: {}", rt.getMessage());
324323
}
325324
}
326325
waitForInputToContinue(scanner);
@@ -338,7 +337,7 @@ provided by Amazon Web Services (AWS). It is designed to help you monitor your
338337
if (cause instanceof CloudWatchException cwEx) {
339338
logger.info("CloudWatch error occurred: Error message: {}, Error code {}", cwEx.getMessage(), cwEx.awsErrorDetails().errorCode());
340339
} else {
341-
logger.info("An unexpected error occurred: " + rt.getMessage());
340+
logger.info("An unexpected error occurred: {}", rt.getMessage());
342341
}
343342
}
344343
logger.info(DASHES);
@@ -356,7 +355,7 @@ provided by Amazon Web Services (AWS). It is designed to help you monitor your
356355
if (cause instanceof CloudWatchException cwEx) {
357356
logger.info("CloudWatch error occurred: Error message: {}, Error code {}", cwEx.getMessage(), cwEx.awsErrorDetails().errorCode());
358357
} else {
359-
logger.info("An unexpected error occurred: " + rt.getMessage());
358+
logger.info("An unexpected error occurred: {}", rt.getMessage());
360359
}
361360
}
362361
waitForInputToContinue(scanner);
@@ -374,7 +373,7 @@ provided by Amazon Web Services (AWS). It is designed to help you monitor your
374373
if (cause instanceof CloudWatchException cwEx) {
375374
logger.info("CloudWatch error occurred: Error message: {}, Error code {}", cwEx.getMessage(), cwEx.awsErrorDetails().errorCode());
376375
} else {
377-
logger.info("An unexpected error occurred: " + rt.getMessage());
376+
logger.info("An unexpected error occurred: {}", rt.getMessage());
378377
}
379378
}
380379
waitForInputToContinue(scanner);
@@ -391,7 +390,7 @@ provided by Amazon Web Services (AWS). It is designed to help you monitor your
391390
if (cause instanceof CloudWatchException cwEx) {
392391
logger.info("CloudWatch error occurred: Error message: {}, Error code {}", cwEx.getMessage(), cwEx.awsErrorDetails().errorCode());
393392
} else {
394-
logger.info("An unexpected error occurred: " + rt.getMessage());
393+
logger.info("An unexpected error occurred: {}", rt.getMessage());
395394
}
396395
}
397396
waitForInputToContinue(scanner);
@@ -409,7 +408,7 @@ provided by Amazon Web Services (AWS). It is designed to help you monitor your
409408
if (cause instanceof CloudWatchException cwEx) {
410409
logger.info("CloudWatch error occurred: Error message: {}, Error code {}", cwEx.getMessage(), cwEx.awsErrorDetails().errorCode());
411410
} else {
412-
logger.info("An unexpected error occurred: " + rt.getMessage());
411+
logger.info("An unexpected error occurred: {}", rt.getMessage());
413412
}
414413
}
415414
waitForInputToContinue(scanner);
@@ -427,7 +426,7 @@ provided by Amazon Web Services (AWS). It is designed to help you monitor your
427426
if (cause instanceof CloudWatchException cwEx) {
428427
logger.info("CloudWatch error occurred: Error message: {}, Error code {}", cwEx.getMessage(), cwEx.awsErrorDetails().errorCode());
429428
} else {
430-
logger.info("An unexpected error occurred: " + rt.getMessage());
429+
logger.info("An unexpected error occurred: {}", rt.getMessage());
431430
}
432431
}
433432
waitForInputToContinue(scanner);
@@ -445,7 +444,7 @@ provided by Amazon Web Services (AWS). It is designed to help you monitor your
445444
if (cause instanceof CloudWatchException cwEx) {
446445
logger.info("CloudWatch error occurred: Error message: {}, Error code {}", cwEx.getMessage(), cwEx.awsErrorDetails().errorCode());
447446
} else {
448-
logger.info("An unexpected error occurred: " + rt.getMessage());
447+
logger.info("An unexpected error occurred: {}", rt.getMessage());
449448
}
450449
}
451450
logger.info(DASHES);
@@ -472,7 +471,7 @@ provided by Amazon Web Services (AWS). It is designed to help you monitor your
472471
if (cause instanceof CloudWatchException cwEx) {
473472
logger.info("CloudWatch error occurred: Error message: {}, Error code {}", cwEx.getMessage(), cwEx.awsErrorDetails().errorCode());
474473
} else {
475-
logger.info("An unexpected error occurred: " + rt.getMessage());
474+
logger.info("An unexpected error occurred: {}", rt.getMessage());
476475
}
477476
}
478477
waitForInputToContinue(scanner);
@@ -490,7 +489,7 @@ provided by Amazon Web Services (AWS). It is designed to help you monitor your
490489
if (cause instanceof CloudWatchException cwEx) {
491490
logger.info("CloudWatch error occurred: Error message: {}, Error code {}", cwEx.getMessage(), cwEx.awsErrorDetails().errorCode());
492491
} else {
493-
logger.info("An unexpected error occurred: " + rt.getMessage());
492+
logger.info("An unexpected error occurred: {}", rt.getMessage());
494493
}
495494
}
496495
waitForInputToContinue(scanner);
@@ -507,7 +506,7 @@ provided by Amazon Web Services (AWS). It is designed to help you monitor your
507506
if (cause instanceof CloudWatchException cwEx) {
508507
logger.info("CloudWatch error occurred: Error message: {}, Error code {}", cwEx.getMessage(), cwEx.awsErrorDetails().errorCode());
509508
} else {
510-
logger.info("An unexpected error occurred: " + rt.getMessage());
509+
logger.info("An unexpected error occurred: {}", rt.getMessage());
511510
}
512511
}
513512
logger.info(DASHES);
@@ -526,7 +525,7 @@ provided by Amazon Web Services (AWS). It is designed to help you monitor your
526525
if (cause instanceof CloudWatchException cwEx) {
527526
logger.info("CloudWatch error occurred: Error message: {}, Error code {}", cwEx.getMessage(), cwEx.awsErrorDetails().errorCode());
528527
} else {
529-
logger.info("An unexpected error occurred: " + rt.getMessage());
528+
logger.info("An unexpected error occurred: {}", rt.getMessage());
530529
}
531530
}
532531

@@ -541,7 +540,7 @@ provided by Amazon Web Services (AWS). It is designed to help you monitor your
541540
if (cause instanceof CloudWatchException cwEx) {
542541
logger.info("CloudWatch error occurred: Error message: {}, Error code {}", cwEx.getMessage(), cwEx.awsErrorDetails().errorCode());
543542
} else {
544-
logger.info("An unexpected error occurred: " + rt.getMessage());
543+
logger.info("An unexpected error occurred: {}", rt.getMessage());
545544
}
546545
}
547546

@@ -556,7 +555,7 @@ provided by Amazon Web Services (AWS). It is designed to help you monitor your
556555
if (cause instanceof CloudWatchException cwEx) {
557556
logger.info("CloudWatch error occurred: Error message: {}, Error code {}", cwEx.getMessage(), cwEx.awsErrorDetails().errorCode());
558557
} else {
559-
logger.info("An unexpected error occurred: " + rt.getMessage());
558+
logger.info("An unexpected error occurred: {}", rt.getMessage());
560559
}
561560
}
562561
waitForInputToContinue(scanner);

0 commit comments

Comments
 (0)