use of com.sun.enterprise.config.serverbeans.Server in project Payara by payara.
the class ServerConfigSource method getValue.
@Override
public String getValue(String propertyName) {
String result = null;
Server config = domainConfiguration.getServerNamed(configurationName);
if (config != null) {
result = config.getPropertyValue(PROPERTY_PREFIX + propertyName);
}
return result;
}
use of com.sun.enterprise.config.serverbeans.Server in project Payara by payara.
the class SetCommand method replicateSetCommand.
private boolean replicateSetCommand(AdminCommandContext context, String targetName, String value) {
// "domain." on the front of the attribute name is optional. So if it is
// there, strip it off.
List<Server> replicationInstances = null;
String tName;
if (targetName.startsWith("domain.")) {
tName = targetName.substring("domain.".length());
if (tName.indexOf('.') == -1) {
// This is a domain-level attribute, replicate to all instances
replicationInstances = targetService.getAllInstances();
}
} else {
tName = targetName;
}
if (replicationInstances == null) {
int dotIdx = tName.indexOf('.');
String firstElementOfName = dotIdx != -1 ? tName.substring(0, dotIdx) : tName;
Integer targetElementLocation = targetLevel.get(firstElementOfName);
if (targetElementLocation == null) {
targetElementLocation = 1;
}
if (targetElementLocation == 0) {
if ("resources".equals(firstElementOfName)) {
replicationInstances = targetService.getAllInstances();
}
if ("applications".equals(firstElementOfName)) {
String appName = getElementFromString(tName, 3);
if (appName == null) {
fail(context, localStrings.getLocalString("admin.set.invalid.appname", "Unable to extract application name from {0}", targetName));
return false;
}
replicationInstances = targetService.getInstances(domain.getAllReferencedTargetsForApplication(appName));
}
} else {
String target = getElementFromString(tName, targetElementLocation);
if (target == null) {
fail(context, localStrings.getLocalString("admin.set.invalid.target", "Unable to extract replication target from {0}", targetName));
return false;
}
replicationInstances = targetService.getInstances(target);
}
}
if (replicationInstances != null && !replicationInstances.isEmpty()) {
ParameterMap params = new ParameterMap();
params.set("DEFAULT", targetName + "=" + value);
ActionReport.ExitCode ret = ClusterOperationUtil.replicateCommand("set", FailurePolicy.Error, FailurePolicy.Warn, FailurePolicy.Ignore, replicationInstances, context, params, habitat);
if (ret.equals(ActionReport.ExitCode.FAILURE)) {
return false;
}
}
return true;
}
use of com.sun.enterprise.config.serverbeans.Server in project Payara by payara.
the class RestartHazelcast method isThisForMe.
private boolean isThisForMe() {
boolean result = false;
String instanceName = serverEnv.getInstanceName();
if (instanceName.equals(target)) {
result = true;
}
if (targetUtil.isCluster(target)) {
List<Server> servers = targetUtil.getInstances(target);
for (Server server : servers) {
if (server.getName().equals(instanceName)) {
result = true;
break;
}
}
} else if (target.equals("domain")) {
result = true;
}
return result;
}
use of com.sun.enterprise.config.serverbeans.Server in project Payara by payara.
the class NotificationEventFactory method initializeEvent.
protected E initializeEvent(E e) {
try {
e.setHostName(InetAddress.getLocalHost().getHostName());
} catch (UnknownHostException ex) {
// No-op
}
e.setDomainName(environment.getDomainName());
e.setInstanceName(environment.getInstanceName());
Server server = habitat.getService(Server.class, environment.getInstanceName());
e.setServerName(server.getName());
return e;
}
use of com.sun.enterprise.config.serverbeans.Server in project Payara by payara.
the class EjbDeployer method getOwnerId.
private String getOwnerId(String target) {
// If target is a cluster or deployment group replace it with the instance
List<Server> instances = Collections.EMPTY_LIST;
Cluster cluster = domain.getClusterNamed(target);
if (cluster != null) {
instances = cluster.getInstances();
} else {
DeploymentGroup dg = domain.getDeploymentGroupNamed(target);
if (dg != null) {
instances = dg.getInstances();
} else {
return target;
}
}
// Try a random instance in a cluster
int useInstance = random.nextInt(instances.size());
Server s0 = instances.get(useInstance);
if (s0.isRunning()) {
return s0.getName();
} else {
// Pick the first running instead
for (Server s : instances) {
if (s.isRunning()) {
return s.getName();
}
}
}
// cluster
return s0.getName();
}
Aggregations