Search in sources :

Example 1 with MonitoringService

use of fish.payara.jmx.monitoring.MonitoringService in project Payara by payara.

the class SetMonitoringConfiguration method execute.

@Override
public void execute(AdminCommandContext context) {
    final ActionReport actionReport = context.getActionReport();
    Config config = targetUtil.getConfig(target);
    final MonitoringService service = serviceLocator.getService(MonitoringService.class);
    if (service == null) {
        actionReport.appendMessage("Could not find a monitoring service.");
        actionReport.setActionExitCode(ActionReport.ExitCode.FAILURE);
        return;
    }
    monitoringConfig = config.getExtensionByType(MonitoringServiceConfiguration.class);
    try {
        ConfigSupport.apply(new SingleConfigCode<MonitoringServiceConfiguration>() {

            @Override
            public Object run(final MonitoringServiceConfiguration monitoringConfigProxy) throws PropertyVetoException, TransactionFailure {
                updateConfiguration(monitoringConfigProxy);
                updateAttributes(monitoringConfigProxy, actionReport);
                actionReport.setActionExitCode(ActionReport.ExitCode.SUCCESS);
                return monitoringConfigProxy;
            }
        }, monitoringConfig);
        if (dynamic) {
            enableOnTarget(actionReport, context, enabled);
        }
    } catch (TransactionFailure ex) {
        Logger.getLogger(SetMonitoringConfiguration.class.getName()).log(Level.WARNING, "Exception during command " + "set-monitoring-configuration: " + ex.getCause().getMessage());
        actionReport.setMessage(ex.getCause().getMessage());
        actionReport.setActionExitCode(ActionReport.ExitCode.FAILURE);
    }
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) TransactionFailure(org.jvnet.hk2.config.TransactionFailure) Config(com.sun.enterprise.config.serverbeans.Config) MonitoringServiceConfiguration(fish.payara.jmx.monitoring.configuration.MonitoringServiceConfiguration) ActionReport(org.glassfish.api.ActionReport) MonitoringService(fish.payara.jmx.monitoring.MonitoringService)

Aggregations

Config (com.sun.enterprise.config.serverbeans.Config)1 MonitoringService (fish.payara.jmx.monitoring.MonitoringService)1 MonitoringServiceConfiguration (fish.payara.jmx.monitoring.configuration.MonitoringServiceConfiguration)1 PropertyVetoException (java.beans.PropertyVetoException)1 ActionReport (org.glassfish.api.ActionReport)1 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)1