@Override public BootstrapStepResult execute(String label, JsonObject argumentsObj) throws InterruptedException { T arguments; try { arguments = GSON.fromJson(argumentsObj, getArgumentsType()); } catch (JsonParseException e) { LOG.warn("Bootstrap step {} failed because its arguments are malformed: {}", label, e.getMessage()); return new BootstrapStepResult(label, BootstrapStepResult.Status.FAILED, String.format("Argument decoding failed. Reason: %s", e.getMessage())); } try { arguments.validate(); } catch (RuntimeException e) { LOG.warn("Bootstrap step {} failed due to invalid arguments: {}", label, e.getMessage()); return new BootstrapStepResult(label, BootstrapStepResult.Status.FAILED, e.getMessage()); } try { LOG.debug("Executing bootstrap step {}", label); Retries.runWithInterruptibleRetries(() -> execute(arguments), getRetryStrategy(), t -> t instanceof RetryableException); LOG.debug("Bootstrap step {} completed successfully", label); return new BootstrapStepResult(label, BootstrapStepResult.Status.SUCCEEDED); } catch (InterruptedException e) { throw e; } catch (Exception e) { LOG.warn("Bootstrap step {} failed to execute", label, e); return new BootstrapStepResult(label, BootstrapStepResult.Status.FAILED, e.getMessage()); } }
@Override public BootstrapStepResult execute(String label, JsonObject argumentsObj) throws InterruptedException { T arguments; try { arguments = GSON.fromJson(argumentsObj, getArgumentsType()); } catch (JsonParseException e) { LOG.warn("Bootstrap step {} failed because its arguments are malformed: {}", label, e.getMessage()); return new BootstrapStepResult(label, BootstrapStepResult.Status.FAILED, String.format("Argument decoding failed. Reason: %s", e.getMessage())); } try { arguments.validate(); } catch (RuntimeException e) { LOG.warn("Bootstrap step {} failed due to invalid arguments: {}", label, e.getMessage()); return new BootstrapStepResult(label, BootstrapStepResult.Status.FAILED, e.getMessage()); } try { LOG.debug("Executing bootstrap step {}", label); Retries.runWithInterruptibleRetries(() -> execute(arguments), getRetryStrategy(), t -> t instanceof RetryableException); LOG.debug("Bootstrap step {} completed successfully", label); return new BootstrapStepResult(label, BootstrapStepResult.Status.SUCCEEDED); } catch (InterruptedException e) { throw e; } catch (Exception e) { LOG.warn("Bootstrap step {} failed to execute", label, e); return new BootstrapStepResult(label, BootstrapStepResult.Status.FAILED, e.getMessage()); } }