Search in sources :

Example 16 with CommandRunner

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("");
    }
}
Also used : ParameterMap(org.glassfish.api.admin.ParameterMap) ActionReport(org.glassfish.api.ActionReport) CommandRunner(org.glassfish.api.admin.CommandRunner)

Example 17 with CommandRunner

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("");
        }
    }
}
Also used : Server(com.sun.enterprise.config.serverbeans.Server) ParameterMap(org.glassfish.api.admin.ParameterMap) ActionReport(org.glassfish.api.ActionReport) CommandRunner(org.glassfish.api.admin.CommandRunner)

Example 18 with CommandRunner

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());
    }
}
Also used : RestActionReporter(org.glassfish.admin.rest.utils.xml.RestActionReporter) ParameterMap(org.glassfish.api.admin.ParameterMap) ActionReport(org.glassfish.api.ActionReport) CommandRunner(org.glassfish.api.admin.CommandRunner)

Example 19 with CommandRunner

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();
}
Also used : CommandModel(org.glassfish.api.admin.CommandModel) CommandRunner(org.glassfish.api.admin.CommandRunner)

Example 20 with CommandRunner

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;
        }
    });
}
Also used : EventOutput(org.glassfish.jersey.media.sse.EventOutput) RestActionReporter(org.glassfish.admin.rest.utils.xml.RestActionReporter) ActionReport(org.glassfish.api.ActionReport) CommandRunner(org.glassfish.api.admin.CommandRunner) CommandInvocation(org.glassfish.api.admin.CommandRunner.CommandInvocation)

Aggregations

CommandRunner (org.glassfish.api.admin.CommandRunner)26 ParameterMap (org.glassfish.api.admin.ParameterMap)14 ActionReport (org.glassfish.api.ActionReport)12 ArrayList (java.util.ArrayList)8 Properties (java.util.Properties)5 RestActionReporter (org.glassfish.admin.rest.utils.xml.RestActionReporter)4 IOException (java.io.IOException)3 RemoteRestAdminCommand (com.sun.enterprise.admin.remote.RemoteRestAdminCommand)2 Server (com.sun.enterprise.config.serverbeans.Server)2 File (java.io.File)2 AdminCommand (org.glassfish.api.admin.AdminCommand)2 CommandException (org.glassfish.api.admin.CommandException)2 CommandModel (org.glassfish.api.admin.CommandModel)2 CommandInvocation (org.glassfish.api.admin.CommandRunner.CommandInvocation)2 InternalSystemAdministrator (org.glassfish.internal.api.InternalSystemAdministrator)2 ConnectorRuntimeException (com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)1 ServerRemoteRestAdminCommand (com.sun.enterprise.admin.remote.ServerRemoteRestAdminCommand)1 DoNothingActionReporter (com.sun.enterprise.admin.report.DoNothingActionReporter)1 PlainTextActionReporter (com.sun.enterprise.admin.report.PlainTextActionReporter)1 Application (com.sun.enterprise.config.serverbeans.Application)1