Search in sources :

Example 1 with FaultToleranceServiceConfiguration

use of fish.payara.microprofile.faulttolerance.FaultToleranceServiceConfiguration in project Payara by payara.

the class SetFaultToleranceConfigurationCommand method execute.

@Override
public void execute(AdminCommandContext acc) {
    Config targetConfig = targetUtil.getConfig(target);
    FaultToleranceServiceConfiguration faultToleranceServiceConfiguration = targetConfig.getExtensionByType(FaultToleranceServiceConfiguration.class);
    try {
        ConfigSupport.apply((FaultToleranceServiceConfiguration configProxy) -> {
            if (managedExecutorServiceName != null) {
                configProxy.setManagedExecutorService(managedExecutorServiceName);
            }
            if (managedScheduledExecutorServiceName != null) {
                configProxy.setManagedScheduledExecutorService(managedScheduledExecutorServiceName);
            }
            return null;
        }, faultToleranceServiceConfiguration);
    } catch (TransactionFailure ex) {
        acc.getActionReport().failure(logger, "Failed to update Fault Tolerance configuration", ex);
    }
}
Also used : TransactionFailure(org.jvnet.hk2.config.TransactionFailure) Config(com.sun.enterprise.config.serverbeans.Config) FaultToleranceServiceConfiguration(fish.payara.microprofile.faulttolerance.FaultToleranceServiceConfiguration)

Example 2 with FaultToleranceServiceConfiguration

use of fish.payara.microprofile.faulttolerance.FaultToleranceServiceConfiguration in project Payara by payara.

the class GetFaultToleranceConfigurationCommand method execute.

@Override
public void execute(AdminCommandContext acc) {
    Config targetConfig = targetUtil.getConfig(target);
    if (targetConfig == null) {
        acc.getActionReport().setMessage("No such config name: " + targetUtil);
        acc.getActionReport().setActionExitCode(ActionReport.ExitCode.FAILURE);
        return;
    }
    FaultToleranceServiceConfiguration faultToleranceServiceConfiguration = targetConfig.getExtensionByType(FaultToleranceServiceConfiguration.class);
    ColumnFormatter columnFormatter = new ColumnFormatter(OUTPUT_HEADERS);
    Object[] outputValues = { faultToleranceServiceConfiguration.getManagedExecutorService(), faultToleranceServiceConfiguration.getManagedScheduledExecutorService() };
    columnFormatter.addRow(outputValues);
    acc.getActionReport().appendMessage(columnFormatter.toString());
    Map<String, Object> extraPropertiesMap = new HashMap<>();
    extraPropertiesMap.put("managedExecutorServiceName", faultToleranceServiceConfiguration.getManagedExecutorService());
    extraPropertiesMap.put("managedScheduledExecutorServiceName", faultToleranceServiceConfiguration.getManagedScheduledExecutorService());
    Properties extraProperties = new Properties();
    extraProperties.put("faultToleranceConfiguration", extraPropertiesMap);
    acc.getActionReport().setExtraProperties(extraProperties);
}
Also used : HashMap(java.util.HashMap) Config(com.sun.enterprise.config.serverbeans.Config) FaultToleranceServiceConfiguration(fish.payara.microprofile.faulttolerance.FaultToleranceServiceConfiguration) Properties(java.util.Properties) ColumnFormatter(com.sun.enterprise.util.ColumnFormatter)

Aggregations

Config (com.sun.enterprise.config.serverbeans.Config)2 FaultToleranceServiceConfiguration (fish.payara.microprofile.faulttolerance.FaultToleranceServiceConfiguration)2 ColumnFormatter (com.sun.enterprise.util.ColumnFormatter)1 HashMap (java.util.HashMap)1 Properties (java.util.Properties)1 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)1