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