use of org.glassfish.api.admin.CommandRunner in project Payara by payara.
the class SetNotificationConfiguration method enableNotificationNotifierConfigurerOnTarget.
private void enableNotificationNotifierConfigurerOnTarget(ActionReport actionReport, AdminCommandContext context) {
CommandRunner runner = serviceLocator.getService(CommandRunner.class);
ActionReport subReport = context.getActionReport().addSubActionsReport();
inv = runner.getCommandInvocation("set-log-notifier-configuration", subReport, context.getSubject());
ParameterMap params = new ParameterMap();
params.add("dynamic", notifierDynamic.toString());
params.add("target", target);
params.add("enabled", notifierEnabled.toString());
params.add("noisy", noisy.toString());
params.add("useSeparateLogFile", useSeparateLogFile.toString());
inv.parameters(params);
inv.execute();
// swallow the offline warning as it is not a problem
if (subReport.hasWarnings()) {
subReport.setMessage("");
}
}
use of org.glassfish.api.admin.CommandRunner in project Payara by payara.
the class SetHazelcastConfiguration method enableOnTarget.
private void enableOnTarget(ActionReport actionReport, AdminCommandContext context, Boolean enabled) {
// for all affected targets restart hazelcast.
// However do in turn to prevent a major data loss
CommandRunner runner = serviceLocator.getService(CommandRunner.class);
ActionReport subReport = context.getActionReport().addSubActionsReport();
CommandRunner.CommandInvocation inv;
inv = runner.getCommandInvocation("restart-hazelcast", subReport, context.getSubject());
List<Server> serversAffected = targetUtil.getInstances(target);
for (Server server : serversAffected) {
ParameterMap params = new ParameterMap();
params.add("target", server.getName());
inv.parameters(params);
inv.execute();
// swallow the offline warning as it is not a problem
if (subReport.hasWarnings()) {
subReport.setMessage("");
}
}
}
use of org.glassfish.api.admin.CommandRunner in project Payara by payara.
the class StatusGenerator method listOfCommands.
public void listOfCommands() {
CommandRunner cr = serviceLocator.getService(CommandRunner.class);
RestActionReporter ar = new RestActionReporter();
ParameterMap parameters = new ParameterMap();
cr.getCommandInvocation("list-commands", ar, getSubject()).parameters(parameters).execute();
List<ActionReport.MessagePart> children = ar.getTopMessagePart().getChildren();
for (ActionReport.MessagePart part : children) {
allCommands.add(part.getMessage());
}
ar = new RestActionReporter();
parameters = new ParameterMap();
parameters.add("DEFAULT", "_");
cr.getCommandInvocation("list-commands", ar, getSubject()).parameters(parameters).execute();
children = ar.getTopMessagePart().getChildren();
for (ActionReport.MessagePart part : children) {
allCommands.add(part.getMessage());
}
}
use of org.glassfish.api.admin.CommandRunner in project Payara by payara.
the class StatusGenerator method getParamMetaData.
public Collection<CommandModel.ParamModel> getParamMetaData(String commandName) {
CommandRunner cr = serviceLocator.getService(CommandRunner.class);
CommandModel cm = cr.getModel(commandName, RestLogging.restLogger);
return cm.getParameters();
}
use of org.glassfish.api.admin.CommandRunner in project Payara by payara.
the class ResourceUtil method runCommandWithSse.
public static EventOutput runCommandWithSse(final String commandName, final ParameterMap parameters, final Subject subject, final SseCommandHelper.ActionReportProcessor processor) {
CommandRunner cr = Globals.getDefaultHabitat().getService(CommandRunner.class);
final RestActionReporter ar = new RestActionReporter();
final CommandInvocation commandInvocation = cr.getCommandInvocation(commandName, ar, subject).parameters(parameters);
return SseCommandHelper.invokeAsync(commandInvocation, new SseCommandHelper.ActionReportProcessor() {
@Override
public ActionReport process(ActionReport report, EventOutput ec) {
addCommandLog(ar, commandName, parameters);
if (processor != null) {
return processor.process(report, ec);
}
return ar;
}
});
}
Aggregations