Search in sources :

Example 1 with HoggingThreadsHealthCheck

use of fish.payara.nucleus.healthcheck.preliminary.HoggingThreadsHealthCheck in project Payara by payara.

the class SetHealthCheckServiceConfigurationTest method hogginThreadsThresholdDynamicAffectsConfigAndService.

@Test
public void hogginThreadsThresholdDynamicAffectsConfigAndService() {
    ensureHealthChecksAreEnabled();
    CommandResult result = asadmin("set-healthcheck-service-configuration", "--service", "ht", "--enabled", "true", "--hogging-threads-threshold", "42", "--dynamic", "true");
    assertSuccess(result);
    HoggingThreadsChecker htConfig = config.getCheckerByType(hoggingThreads.getCheckerType());
    assertEquals(42, Integer.parseInt(htConfig.getThresholdPercentage()));
    HoggingThreadsHealthCheck checkTask = (HoggingThreadsHealthCheck) service.getCheck(htConfig.getName());
    assertEquals(Long.valueOf(42), checkTask.getOptions().getThresholdPercentage());
}
Also used : HoggingThreadsChecker(fish.payara.nucleus.healthcheck.configuration.HoggingThreadsChecker) HoggingThreadsHealthCheck(fish.payara.nucleus.healthcheck.preliminary.HoggingThreadsHealthCheck) CommandResult(org.glassfish.embeddable.CommandResult) Test(org.junit.Test)

Example 2 with HoggingThreadsHealthCheck

use of fish.payara.nucleus.healthcheck.preliminary.HoggingThreadsHealthCheck in project Payara by payara.

the class SetHealthCheckServiceConfigurationTest method hogginThreadsRetryCountAffectsConfigButNotService.

@Test
public void hogginThreadsRetryCountAffectsConfigButNotService() {
    CommandResult result = asadmin("set-healthcheck-service-configuration", "--service", "ht", "--enabled", "true", "--hogging-threads-retry-count", "13");
    assertSuccess(result);
    HoggingThreadsChecker htConfig = config.getCheckerByType(hoggingThreads.getCheckerType());
    assertEquals(13, Integer.parseInt(htConfig.getRetryCount()));
    HoggingThreadsHealthCheck checkTask = (HoggingThreadsHealthCheck) service.getCheck(htConfig.getName());
    assertNotEquals(13, checkTask.getOptions().getRetryCount());
}
Also used : HoggingThreadsChecker(fish.payara.nucleus.healthcheck.configuration.HoggingThreadsChecker) HoggingThreadsHealthCheck(fish.payara.nucleus.healthcheck.preliminary.HoggingThreadsHealthCheck) CommandResult(org.glassfish.embeddable.CommandResult) Test(org.junit.Test)

Example 3 with HoggingThreadsHealthCheck

use of fish.payara.nucleus.healthcheck.preliminary.HoggingThreadsHealthCheck in project Payara by payara.

the class SetHealthCheckServiceConfigurationTest method hogginThreadsThresholdAffectsConfigButNotService.

@Test
public void hogginThreadsThresholdAffectsConfigButNotService() {
    CommandResult result = asadmin("set-healthcheck-service-configuration", "--service", "ht", "--enabled", "true", "--hogging-threads-threshold", "33");
    assertSuccess(result);
    HoggingThreadsChecker htConfig = config.getCheckerByType(hoggingThreads.getCheckerType());
    assertEquals(33, Integer.parseInt(htConfig.getThresholdPercentage()));
    HoggingThreadsHealthCheck checkTask = (HoggingThreadsHealthCheck) service.getCheck(htConfig.getName());
    assertNotEquals(Long.valueOf(33), checkTask.getOptions().getThresholdPercentage());
}
Also used : HoggingThreadsChecker(fish.payara.nucleus.healthcheck.configuration.HoggingThreadsChecker) HoggingThreadsHealthCheck(fish.payara.nucleus.healthcheck.preliminary.HoggingThreadsHealthCheck) CommandResult(org.glassfish.embeddable.CommandResult) Test(org.junit.Test)

Example 4 with HoggingThreadsHealthCheck

use of fish.payara.nucleus.healthcheck.preliminary.HoggingThreadsHealthCheck in project Payara by payara.

the class HoggingThreadsConfigurer method execute.

@Override
public void execute(AdminCommandContext context) {
    Config config = targetUtil.getConfig(target);
    HoggingThreadsHealthCheck service = habitat.getService(HoggingThreadsHealthCheck.class);
    final ActionReport actionReport = context.getActionReport();
    if (service == null) {
        actionReport.appendMessage(strings.getLocalString("healthcheck.hoggingthreads.configure.status.error", "Hogging Threads Checker Service could not be found"));
        actionReport.setActionExitCode(ActionReport.ExitCode.FAILURE);
        return;
    }
    // Warn about deprecated option
    if (name != null) {
        actionReport.appendMessage("\n--name parameter is decremented, please begin using the --checkerName option\n");
    }
    try {
        HealthCheckServiceConfiguration healthCheckServiceConfiguration = config.getExtensionByType(HealthCheckServiceConfiguration.class);
        HoggingThreadsChecker hoggingThreadConfiguration = healthCheckServiceConfiguration.getCheckerByType(HoggingThreadsChecker.class);
        if (hoggingThreadConfiguration == null) {
            ConfigSupport.apply(new SingleConfigCode<HealthCheckServiceConfiguration>() {

                @Override
                public Object run(final HealthCheckServiceConfiguration healthCheckServiceConfigurationProxy) throws PropertyVetoException, TransactionFailure {
                    HoggingThreadsChecker checkerProxy = healthCheckServiceConfigurationProxy.createChild(HoggingThreadsChecker.class);
                    applyValues(checkerProxy);
                    healthCheckServiceConfigurationProxy.getCheckerList().add(checkerProxy);
                    actionReport.setActionExitCode(ActionReport.ExitCode.SUCCESS);
                    return healthCheckServiceConfigurationProxy;
                }
            }, healthCheckServiceConfiguration);
        } else {
            ConfigSupport.apply(new SingleConfigCode<HoggingThreadsChecker>() {

                @Override
                public Object run(final HoggingThreadsChecker hoggingThreadConfigurationProxy) throws PropertyVetoException, TransactionFailure {
                    applyValues(hoggingThreadConfigurationProxy);
                    actionReport.setActionExitCode(ActionReport.ExitCode.SUCCESS);
                    return hoggingThreadConfigurationProxy;
                }
            }, hoggingThreadConfiguration);
        }
        if (dynamic) {
            if (server.isDas()) {
                if (targetUtil.getConfig(target).isDas()) {
                    HoggingThreadsChecker checkerByType = healthCheckServiceConfiguration.getCheckerByType(HoggingThreadsChecker.class);
                    service.setOptions(service.constructOptions(checkerByType));
                    healthCheckService.registerCheck(checkerByType.getName(), service);
                    healthCheckService.reboot();
                }
            } else {
                // it implicitly targetted to us as we are not the DAS
                // restart the service
                HoggingThreadsChecker checkerByType = healthCheckServiceConfiguration.getCheckerByType(HoggingThreadsChecker.class);
                service.setOptions(service.constructOptions(hoggingThreadConfiguration));
                healthCheckService.registerCheck(checkerByType.getName(), service);
                healthCheckService.reboot();
            }
        }
    } catch (TransactionFailure ex) {
        logger.log(Level.WARNING, "Exception during command ", ex);
        actionReport.setMessage(ex.getCause().getMessage());
        actionReport.setActionExitCode(ActionReport.ExitCode.FAILURE);
    }
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) TransactionFailure(org.jvnet.hk2.config.TransactionFailure) HoggingThreadsChecker(fish.payara.nucleus.healthcheck.configuration.HoggingThreadsChecker) Config(com.sun.enterprise.config.serverbeans.Config) HoggingThreadsHealthCheck(fish.payara.nucleus.healthcheck.preliminary.HoggingThreadsHealthCheck) HealthCheckServiceConfiguration(fish.payara.nucleus.healthcheck.configuration.HealthCheckServiceConfiguration) ActionReport(org.glassfish.api.ActionReport)

Example 5 with HoggingThreadsHealthCheck

use of fish.payara.nucleus.healthcheck.preliminary.HoggingThreadsHealthCheck in project Payara by payara.

the class SetHealthCheckServiceConfigurationTest method hogginThreadsRetryCountDynamicAffectsConfigAndService.

@Test
public void hogginThreadsRetryCountDynamicAffectsConfigAndService() {
    ensureHealthChecksAreEnabled();
    CommandResult result = asadmin("set-healthcheck-service-configuration", "--service", "ht", "--enabled", "true", "--hogging-threads-retry-count", "24", "--dynamic", "true");
    assertSuccess(result);
    HoggingThreadsChecker htConfig = config.getCheckerByType(hoggingThreads.getCheckerType());
    assertEquals(24, Integer.parseInt(htConfig.getRetryCount()));
    HoggingThreadsHealthCheck checkTask = (HoggingThreadsHealthCheck) service.getCheck(htConfig.getName());
    assertEquals(24, checkTask.getOptions().getRetryCount());
}
Also used : HoggingThreadsChecker(fish.payara.nucleus.healthcheck.configuration.HoggingThreadsChecker) HoggingThreadsHealthCheck(fish.payara.nucleus.healthcheck.preliminary.HoggingThreadsHealthCheck) CommandResult(org.glassfish.embeddable.CommandResult) Test(org.junit.Test)

Aggregations

HoggingThreadsChecker (fish.payara.nucleus.healthcheck.configuration.HoggingThreadsChecker)5 HoggingThreadsHealthCheck (fish.payara.nucleus.healthcheck.preliminary.HoggingThreadsHealthCheck)5 CommandResult (org.glassfish.embeddable.CommandResult)4 Test (org.junit.Test)4 Config (com.sun.enterprise.config.serverbeans.Config)1 HealthCheckServiceConfiguration (fish.payara.nucleus.healthcheck.configuration.HealthCheckServiceConfiguration)1 PropertyVetoException (java.beans.PropertyVetoException)1 ActionReport (org.glassfish.api.ActionReport)1 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)1