use of fish.payara.nucleus.healthcheck.configuration.HealthCheckServiceConfiguration in project Payara by payara.
the class BaseHealthCheckNotifierConfigurer method execute.
@Override
public void execute(AdminCommandContext context) {
final ActionReport actionReport = context.getActionReport();
Properties extraProperties = actionReport.getExtraProperties();
if (extraProperties == null) {
extraProperties = new Properties();
actionReport.setExtraProperties(extraProperties);
}
Config configuration = targetUtil.getConfig(target);
final HealthCheckServiceConfiguration healthCheckServiceConfiguration = configuration.getExtensionByType(HealthCheckServiceConfiguration.class);
ParameterizedType genericSuperclass = (ParameterizedType) getClass().getGenericSuperclass();
notifierClass = (Class<C>) genericSuperclass.getActualTypeArguments()[0];
C c = healthCheckServiceConfiguration.getNotifierByType(notifierClass);
final C[] config = ObjectArrays.newArray(notifierClass, 1);
try {
if (c == null) {
ConfigSupport.apply(new SingleConfigCode<HealthCheckServiceConfiguration>() {
@Override
public Object run(final HealthCheckServiceConfiguration healthCheckServiceConfigurationProxy) throws PropertyVetoException, TransactionFailure {
C c = healthCheckServiceConfigurationProxy.createChild(notifierClass);
applyValues(c);
healthCheckServiceConfigurationProxy.getNotifierList().add(c);
actionReport.setActionExitCode(ActionReport.ExitCode.SUCCESS);
return healthCheckServiceConfigurationProxy;
}
}, healthCheckServiceConfiguration);
} else {
config[0] = c;
ConfigSupport.apply(new SingleConfigCode<C>() {
public Object run(C cProxy) throws PropertyVetoException, TransactionFailure {
applyValues(cProxy);
actionReport.setActionExitCode(ActionReport.ExitCode.SUCCESS);
return cProxy;
}
}, c);
}
if (dynamic) {
if (server.isDas()) {
if (targetUtil.getConfig(target).isDas()) {
configureDynamically();
}
} else {
configureDynamically();
}
}
} 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.configuration.HealthCheckServiceConfiguration 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);
}
}
Aggregations