use of fish.payara.nucleus.healthcheck.preliminary.BaseThresholdHealthCheck in project Payara by payara.
the class HealthCheckServiceThresholdConfigurer method execute.
@Override
public void execute(AdminCommandContext context) {
final ActionReport actionReport = context.getActionReport();
final AdminCommandContext theContext = context;
Properties extraProperties = actionReport.getExtraProperties();
if (extraProperties == null) {
extraProperties = new Properties();
actionReport.setExtraProperties(extraProperties);
}
final BaseThresholdHealthCheck service = habitat.getService(BaseThresholdHealthCheck.class, serviceName);
Config config = targetUtil.getConfig(target);
if (service == null) {
actionReport.appendMessage(strings.getLocalString("healthcheck.service.configure.status.error", "Service with name {0} could not be found.", serviceName));
actionReport.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
HealthCheckServiceConfiguration healthCheckServiceConfiguration = config.getExtensionByType(HealthCheckServiceConfiguration.class);
final ThresholdDiagnosticsChecker checker = healthCheckServiceConfiguration.<ThresholdDiagnosticsChecker>getCheckerByType(service.getCheckerType());
if (checker == null) {
actionReport.appendMessage(strings.getLocalString("healthcheck.service.configure.threshold.checker.not.exists", "Health Check Service Checker Configuration with name {0} could not be found.", serviceName));
actionReport.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
try {
evaluateThresholdProp(actionReport, checker, HealthCheckConstants.THRESHOLD_CRITICAL, thresholdCritical);
evaluateThresholdProp(actionReport, checker, HealthCheckConstants.THRESHOLD_WARNING, thresholdWarning);
evaluateThresholdProp(actionReport, checker, HealthCheckConstants.THRESHOLD_GOOD, thresholdGood);
} catch (TransactionFailure ex) {
logger.log(Level.WARNING, "Exception during command ", ex);
actionReport.setMessage(ex.getCause().getMessage());
actionReport.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
if (dynamic) {
if (service.getOptions() == null) {
service.setOptions(service.constructOptions(checker));
}
if (server.isDas()) {
if (targetUtil.getConfig(target).isDas()) {
configureDynamically(actionReport, service);
healthCheckService.reboot();
}
} else {
// it implicitly targeted to us as we are not the DAS
// restart the service
configureDynamically(actionReport, service);
healthCheckService.reboot();
}
}
}
Aggregations