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());
}
}
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());
}
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());
}
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);
}
}
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());
}
}
Aggregations