From ae2ecbf16c41e5c597a2a388c534c84842148625 Mon Sep 17 00:00:00 2001 From: mdaxini Date: Thu, 28 Feb 2019 17:52:54 -0800 Subject: [PATCH] Make error response field public so that it shows up in the response, and add exeception message to error response. --- .../core/resources/NdBenchResource.java | 18 +++++++++--------- .../netflix/ndbench/core/util/RestUtil.java | 3 ++- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/ndbench-core/src/main/java/com/netflix/ndbench/core/resources/NdBenchResource.java b/ndbench-core/src/main/java/com/netflix/ndbench/core/resources/NdBenchResource.java index c068fb0b..43884da9 100644 --- a/ndbench-core/src/main/java/com/netflix/ndbench/core/resources/NdBenchResource.java +++ b/ndbench-core/src/main/java/com/netflix/ndbench/core/resources/NdBenchResource.java @@ -87,7 +87,7 @@ public Response initfromscript(@FormDataParam("dynamicplugin") String dynamicPlu } catch (Exception e) { logger.error("Error initializing dynamic plugin from script", e); - return sendErrorResponse("script initialization failed for dynamic plugin!"+e); + return sendErrorResponse("script initialization failed for dynamic plugin!" + e.getMessage()); } } @@ -105,7 +105,7 @@ public Response startDataFill() throws Exception { return sendSuccessResponse("data fill done!"); } catch (Exception e) { logger.error("Error starting datafill", e); - return sendErrorResponse("dataFill failed!"); + return sendErrorResponse("dataFill failed!" + e.getMessage()); } } @@ -122,7 +122,7 @@ public Response startDataFillAsync() throws Exception { return sendSuccessResponse( "Async data fill started !"); } catch (Exception e) { logger.error("Error starting datafill", e); - return sendErrorResponse("Async dataFill failed to start!"); + return sendErrorResponse("Async dataFill failed to start!" + e.getMessage()); } } @@ -139,7 +139,7 @@ public Response conditionalBackfill() throws Exception { return sendSuccessResponse("data fill done!"); } catch (Exception e) { logger.error("Error starting datafill", e); - return sendErrorResponse("dataFill failed!"); + return sendErrorResponse("dataFill failed!" + e.getMessage()); } } @@ -156,7 +156,7 @@ public Response verifyBackfill() throws Exception { return sendSuccessResponse("data fill done!"); } catch (Exception e) { logger.error("Error starting datafill", e); - return sendErrorResponse("dataFill failed!"); + return sendErrorResponse("dataFill failed!" + e.getMessage()); } } @@ -172,7 +172,7 @@ public Response stopDataFill() throws Exception { return sendSuccessResponse("data fill stop!" ); } catch (Exception e) { logger.error("Error stop datafill", e); - return sendErrorResponse("dataFill failed!"); + return sendErrorResponse("dataFill failed!" + e.getMessage()); } } @@ -190,7 +190,7 @@ public Response shutdownDataFill() throws Exception { return sendSuccessResponse("data fill stop!" ); } catch (Exception e) { logger.error("Error shutdown datafill", e); - return sendErrorResponse("dataFill failed!"); + return sendErrorResponse("dataFill failed!" + e.getMessage()); } } @@ -206,7 +206,7 @@ public Response init(@PathParam("client") String clientName) throws Exception { return sendSuccessResponse("NdBench client initiated!"); } catch (Exception e) { logger.error("Error initializing the client - "+clientName, e); - return sendErrorResponse("Client initialization failed!"); + return sendErrorResponse("Client initialization failed!" + e.getMessage()); } } @@ -328,7 +328,7 @@ public Response stop() throws Exception { return sendSuccessResponse("NdBench test stopped!"); } catch (Exception e) { logger.error("Error stopping NdBench test", e); - return sendErrorResponse("NdBench stop failed! "+ e.getMessage()); + return sendErrorResponse("NdBench stop failed! " + e.getMessage()); } } diff --git a/ndbench-core/src/main/java/com/netflix/ndbench/core/util/RestUtil.java b/ndbench-core/src/main/java/com/netflix/ndbench/core/util/RestUtil.java index df04a350..d81562b6 100644 --- a/ndbench-core/src/main/java/com/netflix/ndbench/core/util/RestUtil.java +++ b/ndbench-core/src/main/java/com/netflix/ndbench/core/util/RestUtil.java @@ -85,13 +85,14 @@ public SuccessResponse(String successMessage) public static class Result { public boolean isSuccess; - String message; + public String message; Result(boolean result, String resultMessage) { this.isSuccess = result; this.message=resultMessage; } + public Result(boolean result) { this.isSuccess = result;