static OnlineManagementClient wrap(OnlineManagementClient client) { if (client instanceof AutomaticErrorHandlingForCommands) { return client; } return new AutomaticErrorHandlingForCommands(client); }
@Override public void executeCli(String cliOperation) { try { delegate.executeCli(cliOperation); } catch (Exception e) { commandFailedWithCause(e); } }
@Override public ModelNodeResult execute(ModelNode operation) { try { ModelNodeResult result = delegate.execute(operation); if (result.isFailed() && throwExceptionsOnOperationFailures) { commandFailedWithMessage("Operation " + operation.asString() + " failed: " + result.asString()); } return result; } catch (RuntimeCommandFailedException e) { throw e; } catch (Exception e) { commandFailedWithCause(e); return null; // dead code } }
@Override public void apply(Iterable<OnlineCommand> commands) throws CommandFailedException { checkClosed(); try { OnlineManagementClient client = AutomaticErrorHandlingForCommands.wrap(this); OnlineCommandContext ctx = new OnlineCommandContext(client, version); for (OnlineCommand command : commands) { log.infof("Applying command %s", command); command.apply(ctx); } } catch (RuntimeCommandFailedException e) { throw e.original; } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new CommandFailedException(e); } catch (Exception e) { throw new CommandFailedException(e); } }
@Override public ModelNodeResult execute(String operation) { try { ModelNodeResult result = delegate.execute(operation); if (result.isFailed() && throwExceptionsOnOperationFailures) { commandFailedWithMessage("Operation " + operation + " failed: " + result.asString()); } return result; } catch (RuntimeCommandFailedException e) { throw e; } catch (Exception e) { commandFailedWithCause(e); return null; // dead code } }
@Override public ModelNodeResult execute(Operation operation) { try { ModelNodeResult result = delegate.execute(operation); if (result.isFailed() && throwExceptionsOnOperationFailures) { commandFailedWithMessage("Operation " + operation.getOperation().asString() + " failed: " + result.asString()); } return result; } catch (RuntimeCommandFailedException e) { throw e; } catch (Exception e) { commandFailedWithCause(e); return null; // dead code } }