From 72dd79015a00d29015bec30f1bfc7ededab6a2b1 Mon Sep 17 00:00:00 2001 From: Mukul Kumar Singh Date: Tue, 28 May 2019 07:52:56 +0530 Subject: [PATCH] HDDS-1534. freon should return non-zero exit code on failure. Contributed by Nilotpal Nandi. --- .../hadoop/ozone/freon/RandomKeyGenerator.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/freon/RandomKeyGenerator.java b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/freon/RandomKeyGenerator.java index a255342679..b0461cb108 100644 --- a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/freon/RandomKeyGenerator.java +++ b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/freon/RandomKeyGenerator.java @@ -107,7 +107,7 @@ enum FreonOps { LoggerFactory.getLogger(RandomKeyGenerator.class); private boolean completed = false; - private boolean exception = false; + private Exception exception = null; @Option(names = "--numOfThreads", description = "number of threads to be launched for the run", @@ -278,7 +278,7 @@ public Void call() throws Exception { processor.awaitTermination(Integer.MAX_VALUE, TimeUnit.MILLISECONDS); completed = true; - if (exception) { + if (exception != null) { progressbar.terminate(); } else { progressbar.shutdown(); @@ -288,6 +288,9 @@ public Void call() throws Exception { validator.join(); } ozoneClient.close(); + if (exception != null) { + throw exception; + } return null; } @@ -337,7 +340,7 @@ private void printStats(PrintStream out) { out.println(); out.println("***************************************************"); - out.println("Status: " + (exception ? "Failed" : "Success")); + out.println("Status: " + (exception != null ? "Failed" : "Success")); out.println("Git Base Revision: " + VersionInfo.getRevision()); out.println("Number of Volumes created: " + numberOfVolumesCreated); out.println("Number of Buckets created: " + numberOfBucketsCreated); @@ -577,7 +580,7 @@ public void run() { numberOfVolumesCreated.getAndIncrement(); volume = objectStore.getVolume(volumeName); } catch (IOException e) { - exception = true; + exception = e; LOG.error("Could not create volume", e); return; } @@ -644,13 +647,13 @@ public void run() { } } } catch (Exception e) { - exception = true; + exception = e; LOG.error("Exception while adding key: {} in bucket: {}" + " of volume: {}.", key, bucket, volume, e); } } } catch (Exception e) { - exception = true; + exception = e; LOG.error("Exception while creating bucket: {}" + " in volume: {}.", bucketName, volume, e); } @@ -696,7 +699,7 @@ private final class FreonJobInfo { private String[] tenQuantileKeyWriteTime; private FreonJobInfo() { - this.status = exception ? "Failed" : "Success"; + this.status = exception != null ? "Failed" : "Success"; this.numOfVolumes = RandomKeyGenerator.this.numOfVolumes; this.numOfBuckets = RandomKeyGenerator.this.numOfBuckets; this.numOfKeys = RandomKeyGenerator.this.numOfKeys;