Search in sources :

Example 1 with StuckThreadsHealthCheck

use of fish.payara.nucleus.healthcheck.stuck.StuckThreadsHealthCheck in project Payara by payara.

the class SetHealthCheckServiceConfigurationTest method stuckThreadsThresholdUnitAffectsConfigButNotService.

@Test
public void stuckThreadsThresholdUnitAffectsConfigButNotService() {
    CommandResult result = asadmin("set-healthcheck-service-configuration", "--service", "st", "--enabled", "true", "--stuck-threads-threshold-unit", TimeUnit.DAYS.name());
    assertSuccess(result);
    StuckThreadsChecker stConfig = config.getCheckerByType(stuckThreads.getCheckerType());
    assertEquals(TimeUnit.DAYS.name(), stConfig.getThresholdTimeUnit());
    StuckThreadsHealthCheck activeService = (StuckThreadsHealthCheck) service.getCheck(stConfig.getName());
    if (activeService != null) {
        assertNotEquals(TimeUnit.DAYS, activeService.getOptions().getUnitStuck());
    }
}
Also used : StuckThreadsChecker(fish.payara.nucleus.healthcheck.configuration.StuckThreadsChecker) StuckThreadsHealthCheck(fish.payara.nucleus.healthcheck.stuck.StuckThreadsHealthCheck) CommandResult(org.glassfish.embeddable.CommandResult) Test(org.junit.Test)

Example 2 with StuckThreadsHealthCheck

use of fish.payara.nucleus.healthcheck.stuck.StuckThreadsHealthCheck in project Payara by payara.

the class SetHealthCheckServiceConfigurationTest method stuckThreadsThresholdUnitDynamicAffectsConfigButNotService.

@Test
public void stuckThreadsThresholdUnitDynamicAffectsConfigButNotService() {
    ensureHealthChecksAreEnabled();
    CommandResult result = asadmin("set-healthcheck-service-configuration", "--service", "st", "--enabled", "true", "--stuck-threads-threshold-unit", TimeUnit.HOURS.name(), "--dynamic", "true");
    assertSuccess(result);
    StuckThreadsChecker stConfig = config.getCheckerByType(stuckThreads.getCheckerType());
    assertEquals(TimeUnit.HOURS.name(), stConfig.getThresholdTimeUnit());
    StuckThreadsHealthCheck activeService = (StuckThreadsHealthCheck) service.getCheck(stConfig.getName());
    assertEquals(TimeUnit.HOURS, activeService.getOptions().getUnitStuck());
}
Also used : StuckThreadsChecker(fish.payara.nucleus.healthcheck.configuration.StuckThreadsChecker) StuckThreadsHealthCheck(fish.payara.nucleus.healthcheck.stuck.StuckThreadsHealthCheck) CommandResult(org.glassfish.embeddable.CommandResult) Test(org.junit.Test)

Example 3 with StuckThreadsHealthCheck

use of fish.payara.nucleus.healthcheck.stuck.StuckThreadsHealthCheck in project Payara by payara.

the class SetHealthCheckServiceConfigurationTest method stuckThreadsThresholdDynamicAffectsConfigAndService.

@Test
public void stuckThreadsThresholdDynamicAffectsConfigAndService() {
    ensureHealthChecksAreEnabled();
    CommandResult result = asadmin("set-healthcheck-service-configuration", "--service", "st", "--enabled", "true", "--stuck-threads-threshold", "17", "--dynamic", "true");
    assertSuccess(result);
    StuckThreadsChecker stConfig = config.getCheckerByType(stuckThreads.getCheckerType());
    assertEquals(17, Integer.parseInt(stConfig.getThreshold()));
    StuckThreadsHealthCheck activeService = (StuckThreadsHealthCheck) service.getCheck(stConfig.getName());
    assertEquals(Long.valueOf(17), activeService.getOptions().getTimeStuck());
}
Also used : StuckThreadsChecker(fish.payara.nucleus.healthcheck.configuration.StuckThreadsChecker) StuckThreadsHealthCheck(fish.payara.nucleus.healthcheck.stuck.StuckThreadsHealthCheck) CommandResult(org.glassfish.embeddable.CommandResult) Test(org.junit.Test)

Example 4 with StuckThreadsHealthCheck

use of fish.payara.nucleus.healthcheck.stuck.StuckThreadsHealthCheck in project Payara by payara.

the class StuckThreadsConfigurer method execute.

@Override
public void execute(AdminCommandContext context) {
    Config config = targetUtil.getConfig(target);
    StuckThreadsHealthCheck service = habitat.getService(StuckThreadsHealthCheck.class);
    final ActionReport actionReport = context.getActionReport();
    if (service == null) {
        actionReport.appendMessage(strings.getLocalString("healthcheck.stuckthreads.configure.status.error", "Stuck Threads Checker Service could not be found"));
        actionReport.setActionExitCode(ActionReport.ExitCode.FAILURE);
        return;
    }
    try {
        HealthCheckServiceConfiguration healthCheckServiceConfiguration = config.getExtensionByType(HealthCheckServiceConfiguration.class);
        StuckThreadsChecker stuckThreadConfiguration = healthCheckServiceConfiguration.getCheckerByType(StuckThreadsChecker.class);
        if (stuckThreadConfiguration == null) {
            ConfigSupport.apply(new SingleConfigCode<HealthCheckServiceConfiguration>() {

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

                @Override
                public Object run(final StuckThreadsChecker hoggingThreadConfigurationProxy) throws PropertyVetoException, TransactionFailure {
                    applyValues(hoggingThreadConfigurationProxy);
                    actionReport.setActionExitCode(ActionReport.ExitCode.SUCCESS);
                    return hoggingThreadConfigurationProxy;
                }
            }, stuckThreadConfiguration);
        }
        if (dynamic) {
            if (server.isDas()) {
                if (targetUtil.getConfig(target).isDas()) {
                    StuckThreadsChecker checkerByType = healthCheckServiceConfiguration.getCheckerByType(StuckThreadsChecker.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
                StuckThreadsChecker checkerByType = healthCheckServiceConfiguration.getCheckerByType(StuckThreadsChecker.class);
                service.setOptions(service.constructOptions(stuckThreadConfiguration));
                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) StuckThreadsChecker(fish.payara.nucleus.healthcheck.configuration.StuckThreadsChecker) Config(com.sun.enterprise.config.serverbeans.Config) SetHealthCheckServiceConfiguration(fish.payara.nucleus.healthcheck.admin.SetHealthCheckServiceConfiguration) HealthCheckServiceConfiguration(fish.payara.nucleus.healthcheck.configuration.HealthCheckServiceConfiguration) ActionReport(org.glassfish.api.ActionReport) StuckThreadsHealthCheck(fish.payara.nucleus.healthcheck.stuck.StuckThreadsHealthCheck)

Example 5 with StuckThreadsHealthCheck

use of fish.payara.nucleus.healthcheck.stuck.StuckThreadsHealthCheck in project Payara by payara.

the class SetHealthCheckServiceConfigurationTest method stuckThreadsThresholdAffectsConfigButNotError.

@Test
public void stuckThreadsThresholdAffectsConfigButNotError() {
    CommandResult result = asadmin("set-healthcheck-service-configuration", "--service", "st", "--enabled", "true", "--stuck-threads-threshold", "13");
    assertSuccess(result);
    StuckThreadsChecker stConfig = config.getCheckerByType(stuckThreads.getCheckerType());
    assertEquals(13, Integer.parseInt(stConfig.getThreshold()));
    StuckThreadsHealthCheck activeService = (StuckThreadsHealthCheck) service.getCheck(stConfig.getName());
    if (activeService != null) {
        assertNotEquals(Long.valueOf(13), activeService.getOptions().getTimeStuck());
    }
}
Also used : StuckThreadsChecker(fish.payara.nucleus.healthcheck.configuration.StuckThreadsChecker) StuckThreadsHealthCheck(fish.payara.nucleus.healthcheck.stuck.StuckThreadsHealthCheck) CommandResult(org.glassfish.embeddable.CommandResult) Test(org.junit.Test)

Aggregations

StuckThreadsChecker (fish.payara.nucleus.healthcheck.configuration.StuckThreadsChecker)5 StuckThreadsHealthCheck (fish.payara.nucleus.healthcheck.stuck.StuckThreadsHealthCheck)5 CommandResult (org.glassfish.embeddable.CommandResult)4 Test (org.junit.Test)4 Config (com.sun.enterprise.config.serverbeans.Config)1 SetHealthCheckServiceConfiguration (fish.payara.nucleus.healthcheck.admin.SetHealthCheckServiceConfiguration)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