use of fish.payara.enterprise.config.serverbeans.DeploymentGroup 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();
}
use of fish.payara.enterprise.config.serverbeans.DeploymentGroup in project Payara by payara.
the class MigrateTimers method validateDG.
private String validateDG() {
List<DeploymentGroup> dgs = targetUtil.getDGForInstance(fromServer);
if (dgs == null) {
return localStrings.getString("migrate.timers.fromServerNotDG", fromServer);
}
// in the same cluster as fromServer
if (target.equals(SystemPropertyConstants.DEFAULT_SERVER_INSTANCE_NAME)) {
List<Server> instances = dgs.get(0).getInstances();
for (Server instance : instances) {
if (instance.isRunning() && !instance.getName().equals(fromServer)) {
target = instance.getName();
needRedirect = true;
}
}
// if destination is still DAS, that means no running server is available
if (target.equals(SystemPropertyConstants.DEFAULT_SERVER_INSTANCE_NAME)) {
return localStrings.getString("migrate.timers.noRunningInstanceToChoose", target);
}
} else {
// verify fromServer and destinationServer are in the same dg, and
boolean inSameDG = false;
for (DeploymentGroup dg : dgs) {
for (Server instance : dg.getInstances()) {
if (instance.getName().equals(target)) {
inSameDG = true;
break;
}
}
}
if (!inSameDG) {
return localStrings.getString("migrate.timers.destinationIsNotInDG", target);
}
// verify destinationServer is running
if (!isServerRunning(target)) {
return localStrings.getString("migrate.timers.destinationServerIsNotAlive", target);
}
}
return null;
}
use of fish.payara.enterprise.config.serverbeans.DeploymentGroup in project Payara by payara.
the class DatabaseEJBTimerService method memberRemoved.
@Override
public void memberRemoved(MemberEvent event) {
// work out whether we should be attempting to migrate timers
String server = event.getServer();
String group = event.getServerGroup();
String thisServer = serverEnv.getInstanceName();
// check whether the server is any of the same clusters or deployment groups
// as the disappeared server and if so migrate timers
boolean migrate = false;
Cluster forServer = domain.getClusterForInstance(server);
if (forServer != null) {
for (Server instance : forServer.getInstances()) {
if (instance.getName().equals(thisServer)) {
// if I am in the same cluster
migrate = true;
break;
}
}
}
if (!migrate) {
for (DeploymentGroup deploymentGroup : domain.getDeploymentGroupsForInstance(server)) {
for (Server instance : deploymentGroup.getInstances()) {
if (instance.getName().equals(thisServer)) {
// if I am in the same cluster
migrate = true;
break;
}
}
}
}
if (migrate) {
migrateTimers(event.getServer());
}
}
use of fish.payara.enterprise.config.serverbeans.DeploymentGroup in project Payara by payara.
the class UpdateApplicationRefCommand method execute.
/**
* Execution method for updating the configuration of an ApplicationRef.
* Will be replicated if the target is a cluster.
*
* @param context context for the command.
*/
@Override
public void execute(AdminCommandContext context) {
final ActionReport report = context.getActionReport();
final Logger logger = context.getLogger();
// Make a list of all ApplicationRefs that need to change
List<ApplicationRef> applicationRefsToChange = new ArrayList<>();
// Add the ApplicationRef which is being immediately targetted
{
ApplicationRef primaryApplicationRef = domain.getApplicationRefInTarget(name, target);
if (primaryApplicationRef == null) {
report.failure(logger, LOCAL_STRINGS.getLocalString("appref.not.exists", "Target {1} does not have a reference to application {0}.", name, target));
return;
}
applicationRefsToChange.add(primaryApplicationRef);
}
// Add the implicitly targetted ApplicationRefs if the target is in a cluster or deployment group
{
Cluster cluster = domain.getClusterNamed(target);
// if the target is a cluster
if (cluster != null) {
for (Server server : cluster.getInstances()) {
ApplicationRef instanceAppRef = server.getApplicationRef(name);
// if the server in the cluster contains the ApplicationRef
if (instanceAppRef != null) {
applicationRefsToChange.add(instanceAppRef);
}
}
}
DeploymentGroup dg = domain.getDeploymentGroupNamed(target);
if (dg != null) {
for (Server server : dg.getInstances()) {
ApplicationRef instanceAppRef = server.getApplicationRef(name);
// if the server in the dg contains the ApplicationRef
if (instanceAppRef != null) {
applicationRefsToChange.add(instanceAppRef);
}
}
}
}
// Apply the configuration to the listed ApplicationRefs
try {
ConfigSupport.apply(new ConfigCode() {
@Override
public Object run(ConfigBeanProxy... params) throws PropertyVetoException, TransactionFailure {
for (ConfigBeanProxy proxy : params) {
if (proxy instanceof ApplicationRef) {
ApplicationRef applicationRefProxy = (ApplicationRef) proxy;
if (enabled != null) {
applicationRefProxy.setEnabled(enabled.toString());
}
if (virtualservers != null) {
applicationRefProxy.setVirtualServers(virtualservers);
}
if (lbenabled != null) {
applicationRefProxy.setLbEnabled(lbenabled.toString());
}
}
}
report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
return true;
}
}, applicationRefsToChange.toArray(new ApplicationRef[] {}));
} catch (TransactionFailure ex) {
report.failure(logger, ex.getLocalizedMessage());
}
}
use of fish.payara.enterprise.config.serverbeans.DeploymentGroup in project Payara by payara.
the class CreateJMSResource method filterForTarget.
private boolean filterForTarget(String jndiName) {
// List<String> resourceList = new ArrayList();
if (target != null) {
List<ResourceRef> resourceRefs = null;
Cluster cluster = domain.getClusterNamed(target);
if (cluster != null)
resourceRefs = cluster.getResourceRef();
else {
Server server = domain.getServerNamed(target);
if (server != null) {
resourceRefs = server.getResourceRef();
} else {
DeploymentGroup dg = domain.getDeploymentGroupNamed(target);
if (dg != null) {
resourceRefs = dg.getResourceRef();
}
}
}
if (resourceRefs != null && resourceRefs.size() != 0) {
for (ResourceRef resource : resourceRefs) if (jndiName.equalsIgnoreCase(resource.getRef()))
return true;
}
}
return false;
}
Aggregations