use of com.sun.enterprise.config.serverbeans.Server in project Payara by payara.
the class ServerConfigSource method getProperties.
@Override
public Map<String, String> getProperties() {
Server config = domainConfiguration.getServerNamed(configurationName);
HashMap<String, String> result = new HashMap<>();
if (config != null) {
List<Property> properties = config.getProperty();
for (Property property : properties) {
if (property.getName().startsWith(PROPERTY_PREFIX)) {
result.put(property.getName().substring(PROPERTY_PREFIX.length()), property.getValue());
}
}
}
return result;
}
use of com.sun.enterprise.config.serverbeans.Server in project Payara by payara.
the class ServerConfigSource method deleteValue.
public boolean deleteValue(String propertyName) throws TransactionFailure {
boolean result = false;
Server config = domainConfiguration.getServerNamed(configurationName);
if (config != null) {
for (Property object : config.getProperty()) {
if ((PROPERTY_PREFIX + propertyName).equals(object.getName())) {
ConfigSupport.deleteChild((ConfigBean) ConfigBean.unwrap(config), (ConfigBean) ConfigBean.unwrap(object));
result = true;
}
}
}
return result;
}
use of com.sun.enterprise.config.serverbeans.Server in project Payara by payara.
the class ServerConfigSource method setValue.
public boolean setValue(final String propertyName, final String propertyValue) throws TransactionFailure {
boolean result = false;
Server config = domainConfiguration.getServerNamed(configurationName);
if (config != null) {
Property p = config.getProperty(PROPERTY_PREFIX + propertyName);
if (p == null) {
ConfigSupport.apply(new SingleConfigCode<Server>() {
@Override
public Object run(Server configuration) throws TransactionFailure, PropertyVetoException {
Property prop = configuration.createChild(Property.class);
prop.setName(PROPERTY_PREFIX + propertyName);
prop.setValue(propertyValue);
configuration.getProperty().add(prop);
return null;
}
}, config);
} else {
ConfigSupport.apply(new SingleConfigCode<Property>() {
@Override
public Object run(Property config) throws TransactionFailure, PropertyVetoException {
config.setValue(propertyValue);
return null;
}
}, p);
}
result = true;
}
return result;
}
use of com.sun.enterprise.config.serverbeans.Server in project Payara by payara.
the class SetHazelcastConfiguration method execute.
@Override
public void execute(AdminCommandContext context) {
final AdminCommandContext theContext = context;
final ActionReport actionReport = context.getActionReport();
Properties extraProperties = actionReport.getExtraProperties();
if (extraProperties == null) {
extraProperties = new Properties();
actionReport.setExtraProperties(extraProperties);
}
if (!validate(actionReport)) {
return;
}
HazelcastRuntimeConfiguration hazelcastRuntimeConfiguration = domain.getExtensionByType(HazelcastRuntimeConfiguration.class);
if (hazelcastRuntimeConfiguration != null) {
try {
ConfigSupport.apply(new SingleConfigCode<HazelcastRuntimeConfiguration>() {
@Override
public Object run(final HazelcastRuntimeConfiguration hazelcastRuntimeConfigurationProxy) throws PropertyVetoException, TransactionFailure {
if (startPort != null) {
hazelcastRuntimeConfigurationProxy.setStartPort(startPort);
}
if (multiCastGroup != null) {
hazelcastRuntimeConfigurationProxy.setMulticastGroup(multiCastGroup);
}
if (multicastPort != null) {
hazelcastRuntimeConfigurationProxy.setMulticastPort(multicastPort);
}
if (configFile != null) {
hazelcastRuntimeConfigurationProxy.setHazelcastConfigurationFile(configFile);
}
if (hostawarePartitioning != null) {
hazelcastRuntimeConfigurationProxy.setHostAwarePartitioning(hostawarePartitioning.toString());
}
if (hzClusterName != null) {
hazelcastRuntimeConfigurationProxy.setClusterGroupName(hzClusterName);
}
if (hzClusterPassword != null) {
hazelcastRuntimeConfigurationProxy.setClusterGroupPassword(hzClusterPassword);
}
if (licenseKey != null) {
hazelcastRuntimeConfigurationProxy.setLicenseKey(licenseKey);
}
if (dasPublicAddress != null) {
hazelcastRuntimeConfigurationProxy.setDASPublicAddress(dasPublicAddress);
}
if (dasBindAddress != null) {
hazelcastRuntimeConfigurationProxy.setDASBindAddress(dasBindAddress);
}
if (dasPort != null) {
hazelcastRuntimeConfigurationProxy.setDasPort(dasPort);
}
if (clusterMode != null) {
hazelcastRuntimeConfigurationProxy.setDiscoveryMode(clusterMode);
}
if (tcpipMembers != null) {
hazelcastRuntimeConfigurationProxy.setTcpipMembers(tcpipMembers);
}
if (interfaces != null) {
hazelcastRuntimeConfigurationProxy.setInterface(interfaces);
}
actionReport.setActionExitCode(ActionReport.ExitCode.SUCCESS);
return null;
}
}, hazelcastRuntimeConfiguration);
// get the configs that need the change applied if target is domain it is all configs
Config config = targetUtil.getConfig(target);
List<Config> configsToApply = new ArrayList<>(5);
if (config == null && target.equals("domain")) {
configsToApply.addAll(domain.getConfigs().getConfig());
} else if (config != null) {
configsToApply.add(config);
}
for (Config configToApply : configsToApply) {
HazelcastConfigSpecificConfiguration nodeConfiguration = configToApply.getExtensionByType(HazelcastConfigSpecificConfiguration.class);
ConfigSupport.apply(new SingleConfigCode<HazelcastConfigSpecificConfiguration>() {
@Override
public Object run(final HazelcastConfigSpecificConfiguration hazelcastRuntimeConfigurationProxy) throws PropertyVetoException, TransactionFailure {
if (jndiName != null) {
hazelcastRuntimeConfigurationProxy.setJNDIName(jndiName);
}
if (enabled != null) {
hazelcastRuntimeConfigurationProxy.setEnabled(enabled.toString());
}
if (lite != null) {
hazelcastRuntimeConfigurationProxy.setLite(lite.toString());
}
if (cacheManagerJndiName != null) {
hazelcastRuntimeConfigurationProxy.setCacheManagerJNDIName(cacheManagerJndiName);
}
if (cachingProviderJndiName != null) {
hazelcastRuntimeConfigurationProxy.setCachingProviderJNDIName(cachingProviderJndiName);
}
if (executorPoolSize != null) {
hazelcastRuntimeConfigurationProxy.setExecutorPoolSize(executorPoolSize);
}
if (executorQueueCapacity != null) {
hazelcastRuntimeConfigurationProxy.setExecutorQueueCapacity(executorQueueCapacity);
}
if (scheduledExecutorPoolSize != null) {
hazelcastRuntimeConfigurationProxy.setScheduledExecutorPoolSize(scheduledExecutorPoolSize);
}
if (scheduledExecutorQueueCapacity != null) {
hazelcastRuntimeConfigurationProxy.setScheduledExecutorQueueCapacity(scheduledExecutorQueueCapacity);
}
if (memberName != null) {
hazelcastRuntimeConfigurationProxy.setMemberName(memberName);
}
if (memberGroup != null) {
hazelcastRuntimeConfigurationProxy.setMemberGroup(memberGroup);
}
actionReport.setActionExitCode(ActionReport.ExitCode.SUCCESS);
return null;
}
}, nodeConfiguration);
}
} catch (TransactionFailure ex) {
logger.log(Level.WARNING, "Exception during command ", ex);
actionReport.setMessage(ex.getCause().getMessage());
actionReport.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
if (dynamic) {
boolean isEnabled = false;
if (enabled != null) {
isEnabled = enabled;
} else {
isEnabled = hazelcast.isEnabled();
}
// this command runs on all instances so they can update their configuration.
if ("domain".equals(target)) {
hazelcast.setEnabled(isEnabled);
} else {
for (Server targetServer : targetUtil.getInstances(target)) {
if (server.getInstanceName().equals(targetServer.getName())) {
hazelcast.setEnabled(isEnabled);
}
}
}
}
}
}
use of com.sun.enterprise.config.serverbeans.Server in project Payara by payara.
the class SetHazelcastConfiguration method enableOnTarget.
private void enableOnTarget(ActionReport actionReport, AdminCommandContext context, Boolean enabled) {
// for all affected targets restart hazelcast.
// However do in turn to prevent a major data loss
CommandRunner runner = serviceLocator.getService(CommandRunner.class);
ActionReport subReport = context.getActionReport().addSubActionsReport();
CommandRunner.CommandInvocation inv;
inv = runner.getCommandInvocation("restart-hazelcast", subReport, context.getSubject());
List<Server> serversAffected = targetUtil.getInstances(target);
for (Server server : serversAffected) {
ParameterMap params = new ParameterMap();
params.add("target", server.getName());
inv.parameters(params);
inv.execute();
// swallow the offline warning as it is not a problem
if (subReport.hasWarnings()) {
subReport.setMessage("");
}
}
}
Aggregations