use of com.sun.enterprise.config.serverbeans.Server in project Payara by payara.
the class CLIUtil method chooseConfig.
/**
* Selects a config of interest from the domain, based on the target. (Eliminates duplicated code formerly in Create,
* Delete, and ListAuthRealm).
*
* @param domain
* @param target
* @return
*/
static Config chooseConfig(final Domain domain, final String target) {
Config config = null;
Config tmp = null;
try {
tmp = domain.getConfigs().getConfigByName(target);
} catch (Exception ex) {
}
if (tmp != null) {
return tmp;
}
Server targetServer = domain.getServerNamed(target);
if (targetServer != null) {
config = domain.getConfigNamed(targetServer.getConfigRef());
}
com.sun.enterprise.config.serverbeans.Cluster cluster = domain.getClusterNamed(target);
if (cluster != null) {
config = domain.getConfigNamed(cluster.getConfigRef());
}
return config;
}
use of com.sun.enterprise.config.serverbeans.Server in project Payara by payara.
the class LDAPAdminAccessConfigurator method chooseConfig.
private Config chooseConfig() {
Server s = configBeansUtilities.getServerNamed(ADMIN_SERVER);
String ac = s.getConfigRef();
return targetService.getConfig(ac);
}
use of com.sun.enterprise.config.serverbeans.Server in project Payara by payara.
the class JmsHandlers method getMBeanServerConnection.
private static MBeanServerConnection getMBeanServerConnection(String target) throws ConnectorRuntimeException, Exception {
ServiceLocator habitat = GuiUtil.getHabitat();
Domain domain = habitat.getService(Domain.class);
Cluster cluster = domain.getClusterNamed(target);
String configRef = null;
if (cluster == null) {
Server server = domain.getServerNamed(target);
configRef = server.getConfigRef();
} else {
configRef = cluster.getConfigRef();
}
PhysicalDestinations pd = new PhysicalDestinations();
MQJMXConnectorInfo mqInfo = pd.getConnectorInfo(target, configRef, habitat, domain);
return mqInfo.getMQMBeanServerConnection();
}
use of com.sun.enterprise.config.serverbeans.Server in project Payara by payara.
the class FlushInstancesConnectionPool method execute.
@Override
public void execute(AdminCommandContext context) {
final ActionReport report = context.getActionReport();
Resources resources = domain.getResources();
String scope = "";
if (moduleName != null) {
if (!poolUtil.isValidModule(applicationName, moduleName, poolName, report)) {
report.setMessage("Modulename is not that of a valid module: " + moduleName);
report.setActionExitCode(ActionReport.ExitCode.WARNING);
return;
}
Application application = applications.getApplication(applicationName);
Module module = application.getModule(moduleName);
resources = module.getResources();
scope = ConnectorConstants.JAVA_MODULE_SCOPE_PREFIX;
} else if (applicationName != null) {
if (!poolUtil.isValidApplication(applicationName, poolName, report)) {
report.setMessage("ApplicationName is not that of a valid module: " + applicationName);
report.setActionExitCode(ActionReport.ExitCode.WARNING);
return;
}
Application application = applications.getApplication(applicationName);
resources = application.getResources();
scope = ConnectorConstants.JAVA_APP_SCOPE_PREFIX;
}
if (!poolUtil.isValidPool(resources, poolName, scope, report)) {
report.setMessage("Connection Pool is not valid");
report.setActionExitCode(ActionReport.ExitCode.WARNING);
return;
}
List<Future> instanceFlushes = new ArrayList<>();
for (Server server : domain.getServers().getServer()) {
instanceFlushes.add(executor.submit(new Runnable() {
@Override
public void run() {
ActionReport subReport = report.addSubActionsReport();
try {
if (!server.isRunning()) {
// skip servers that are stopped
return;
}
String host = server.getAdminHost();
int port = server.getAdminPort();
ParameterMap map = new ParameterMap();
map.add("poolName", poolName);
if (applicationName != null) {
map.add("appname", applicationName);
}
if (moduleName != null) {
map.add("modulename", moduleName);
}
if (server.isDas()) {
CommandRunner runner = habitat.getService(CommandRunner.class);
CommandRunner.CommandInvocation invocation = runner.getCommandInvocation("_flush-connection-pool", subReport, context.getSubject());
invocation.parameters(map);
invocation.execute();
} else {
RemoteRestAdminCommand rac = new ServerRemoteRestAdminCommand(habitat, "_flush-connection-pool", host, port, false, "admin", null, LOGGER);
rac.executeCommand(map);
ActionReport result = rac.getActionReport();
subReport.setActionExitCode(result.getActionExitCode());
subReport.setMessage(result.getMessage());
}
} catch (CommandException ex) {
subReport.failure(Logger.getLogger("CONNECTORS-ADMIN"), ex.getLocalizedMessage(), ex);
subReport.appendMessage(server.getName());
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
}
}
}));
}
for (Future future : instanceFlushes) {
try {
future.get();
} catch (InterruptedException | ExecutionException ex) {
LOGGER.log(Level.SEVERE, null, ex);
}
}
if (report.hasFailures()) {
report.setActionExitCode(ActionReport.ExitCode.WARNING);
}
}
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