public Set<String> getTargetsReferringResourceRef(String refName) { Set<String> targets = new HashSet<String>(); List<Server> servers = domain.getServers().getServer(); for(Server server: servers){ if(server.getResourceRef(refName) != null){ if(server.getCluster() != null){ targets.add(server.getCluster().getName()); }else if(server.isDas()){ targets.add(SystemPropertyConstants.DAS_SERVER_NAME); }else if(server.isInstance()){ targets.add(server.getName()); } } } return targets; }
ServerPorts(Domain domain, Server theServer) { Cluster cluster = null; Config config = null; if (theServer.isInstance()) cluster = domain.getClusterForInstance(theServer.getName()); String configName = theServer.getConfigRef(); if (StringUtils.ok(configName)) config = domain.getConfigNamed(configName); initialize(cluster, config, domain, theServer); }
public static ApplicationRef getApplicationRefInServer(Domain me, String sn, String name) { Servers ss = me.getServers(); List<Server> list = ss.getServer(); Server theServer = null; for (Server s : list) { if (s.getName().equals(sn)) { theServer = s; break; } } ApplicationRef aref = null; if (theServer != null) { List <ApplicationRef> arefs = theServer.getApplicationRef(); for (ApplicationRef ar : arefs) { if (ar.getRef().equals(name)) { aref = ar; break; } } } return aref; }
private static String serverListToString(List<Server> servers) { StringBuilder sb = new StringBuilder(); for (Server s : servers) { sb.append(s.getNodeRef() + ":" + s.getName() + " "); } return sb.toString().trim(); }
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()); SecurityService securityService = config.getSecurityService(); ActionReport report = context.getActionReport(); report.setMessage(localStrings.getLocalString( "delete.audit.module.notfound", "Specified Audit Module {0} not found", auditModuleName)); report.setActionExitCode(ActionReport.ExitCode.FAILURE); return; report.setMessage(localStrings.getLocalString( "delete.audit.module.fail", "Deletion of Audit Module {0} failed", auditModuleName));
@Override public void execute(AdminCommandContext context) { final ActionReport report = context.getActionReport(); Config tmp = null; try { tmp = configs.getConfigByName(target); } catch (Exception ex) { } if (tmp != null) { config = tmp; } if (tmp == null) { 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()); } } final SecurityService securityService = config.getSecurityService(); List<JaccProvider> jaccProviders = securityService.getJaccProvider(); JaccProvider jprov = null; for (JaccProvider jaccProv : jaccProviders) { ActionReport.MessagePart part = report.getTopMessagePart().addChild(); part.setMessage(jaccProv.getName()); } report.setActionExitCode(ActionReport.ExitCode.SUCCESS); }
final ActionReport report = context.getActionReport(); Config targetConfig = domain.getConfigNamed(target); if (targetConfig != null) config = targetConfig; Server targetServer = domain.getServerNamed(target); config = domain.getConfigNamed(targetServer.getConfigRef()); com.sun.enterprise.config.serverbeans.Cluster cluster =domain.getClusterNamed(target); if (cluster!=null) { config = domain.getConfigNamed(cluster.getConfigRef()); JmsService jmsService = config.getExtensionByType(JmsService.class); report.setMessage(localStrings.getLocalString("list.jms.host.invalidTarget", "Invalid Target specified.")); report.setActionExitCode(ActionReport.ExitCode.FAILURE); return; final ActionReport.MessagePart part = report.getTopMessagePart().addChild(); part.setMessage(jmsName); report.setMessage(localStrings.getLocalString("list.jms.host.fail", "Unable to list JMS Hosts") + " " + e.getLocalizedMessage()); report.setActionExitCode(ActionReport.ExitCode.FAILURE);
final ActionReport report = context.getActionReport(); Server targetServer = domain.getServerNamed(target); config = domain.getConfigNamed(targetServer.getConfigRef()); com.sun.enterprise.config.serverbeans.Cluster cluster =domain.getClusterNamed(target); if (cluster!=null) { config = domain.getConfigNamed(cluster.getConfigRef()); JmsService jmsservice = config.getExtensionByType(JmsService.class); ActionReport subReport = report.addSubActionsReport(); createJMSResource(defaultJmsHost, subReport, tmpJMSResource, context.getSubject()); if (ActionReport.ExitCode.FAILURE.equals(subReport.getActionExitCode())){ report.setMessage(localStrings.getLocalString("jms-ping.cannotCreateJMSResource", "Unable to create a temporary Connection Factory to the JMS Host")); report.setActionExitCode(ActionReport.ExitCode.FAILURE); report.setActionExitCode(ActionReport.ExitCode.FAILURE); deleteJMSResource(subReport, tmpJMSResource, context.getSubject()); if (ActionReport.ExitCode.FAILURE.equals(subReport.getActionExitCode())){ report.setMessage(localStrings.getLocalString("jms-ping.cannotdeleteJMSResource",
final ActionReport report = context.getActionReport(); String[] serverIds = null; if(targetUtil.isCluster(target)) { serverIds = new String[serversInCluster.size()]; for(int i = 0; i < serverIds.length; i++) { serverIds[i] = serversInCluster.get(i).getName(); String[] timerCounts = listTimers(serverIds); for (int i = 0; i < serverIds.length; i++) { final ActionReport.MessagePart part = report.getTopMessagePart().addChild(); part.setMessage(serverIds[i] + ": " + timerCounts[i]); report.setActionExitCode(ActionReport.ExitCode.SUCCESS); } catch (Exception e) { report.setMessage(localStrings.getLocalString("list.timers.failed", "List Timers command failed")); report.setActionExitCode(ActionReport.ExitCode.FAILURE);
final ActionReport report = context.getActionReport(); List<ResourceRef> resourceRefs = targetServer.getResourceRef(); processResourceRefs(report, resourceRefs); } else { if(clusterList != null){ for(com.sun.enterprise.config.serverbeans.Cluster cl : clusterList){ if(cl.getName().equals(target)){ List<ResourceRef> resourceRefs = cl.getResourceRef(); processResourceRefs(report, resourceRefs); break; report.setMessage(localStrings.getLocalString("list.resource.refs.failed", "list-resource-refs failed")); report.setActionExitCode(ActionReport.ExitCode.FAILURE); report.setFailureCause(e); return;
public void execute(AdminCommandContext context) { final ActionReport report = context.getActionReport(); ActionReport.MessagePart part = report.getTopMessagePart(); Server server = domain.getServerNamed(target); if (server != null) { configName = server.getConfigRef(); } else { Cluster cluster = domain.getClusterNamed(target); if (cluster == null) { throw new Exception("No such target:" + target); configName = cluster.getConfigRef(); httpService = config.getHttpService(); report.setMessage(e.getMessage()); report.setActionExitCode(ActionReport.ExitCode.FAILURE); return;
copyActionReportContent(super.getActionReport(), aReport); if(StringUtils.ok(getCommandOutput())) aReport.setMessage(strings.getLocalString("ice.successmessage", "{0}:\n{1}\n", getServer().getName(), getCommandOutput())); } catch (CommandException cmdEx) { ActionReport.ExitCode finalResult; finalResult = FailurePolicy.applyFailurePolicy(offlinePolicy, ActionReport.ExitCode.FAILURE); if(!finalResult.equals(ActionReport.ExitCode.FAILURE)) aReport.setMessage(strings.getLocalString("clusterutil.warnoffline", "WARNING: Instance {0} seems to be offline; command {1} was not replicated to that instance", getServer().getName(), commandName)); else aReport.setMessage(strings.getLocalString("clusterutil.failoffline", "FAILURE: Instance {0} seems to be offline; command {1} was not replicated to that instance", getServer().getName(), commandName)); } else { finalResult = FailurePolicy.applyFailurePolicy(failPolicy, ActionReport.ExitCode.FAILURE); if(finalResult.equals(ActionReport.ExitCode.FAILURE)) aReport.setMessage(strings.getLocalString("clusterutil.commandFailed", "FAILURE: Command {0} failed on server instance {1}: {2}", commandName, getServer().getName(), cmdEx.getMessage())); else aReport.setMessage(strings.getLocalString("clusterutil.commandWarning", "WARNING: Command {0} did not complete successfully on server instance {1}: {2}", commandName, getServer().getName(), cmdEx.getMessage())); aReport.setActionExitCode(finalResult);
PropertyVetoException, TransactionFailure{ Logger logger = LogDomains.getLogger(Node.class, LogDomains.ADMIN_LOGGER); LocalStringManagerImpl localStrings = new LocalStringManagerImpl(Node.class); final ActionReport report = context.getActionReport(); String nodeName = child.getName(); if (nodeName.equals("localhost-" + domain.getName())) { // can't delete localhost node final String msg = localStrings.getLocalString( "Node.localhost", "Cannot remove Node {0}. ",child.getName() ); if (n > 0) sb.append(", "); sb.append(server.getName()); n++; final String msg = localStrings.getLocalString( "Node.referencedByInstance", "Node {0} referenced in server instance(s): {1}. Remove instances before removing node."
private String killInstance(AdminCommandContext context) { String msg = initializeInstance(); if (msg != null) return msg; String nodeName = instance.getNodeRef(); Node node = nodes.getNode(nodeName); NodeUtils nodeUtils = new NodeUtils(habitat, logger); // asadmin command to run on instances node ArrayList<String> command = new ArrayList<String>(); command.add("stop-local-instance"); command.add("--kill"); command.add(instanceName); String humanCommand = makeCommandHuman(command); String firstErrorMessage = Strings.get("stop.local.instance.kill", instanceName, nodeName, humanCommand); if (logger.isLoggable(Level.FINE)) logger.fine("stop-instance: running " + humanCommand + " on " + nodeName); nodeUtils.runAdminCommandOnNode(node, command, context, firstErrorMessage, humanCommand, null); ActionReport killreport = context.getActionReport(); if (killreport.getActionExitCode() != ActionReport.ExitCode.SUCCESS) { return killreport.getMessage(); } return null; }
@Override public void execute(AdminCommandContext context) { ActionReport report = context.getActionReport(); final Logger logger = context.getLogger(); final String clusterName = context.getActionReport().getResultType(String.class); if (clusterName != null) { try { ParameterMapExtractor pme = new ParameterMapExtractor(this); final ParameterMap paramMap = pme.extract(); List<String> targets = new ArrayList<String>(); List<Server> instances = target.getInstances(clusterName); for (Server s : instances) { targets.add(s.getName()); } ClusterOperationUtil.replicateCommand( "_unregister-instance", FailurePolicy.Warn, FailurePolicy.Warn, targets, context, paramMap, habitat); } catch (Exception e) { report.failure(logger, e.getMessage()); } } } }
defs++; bag = domain.getServerNamed(target); if (bag != null && bag.containsProperty(propName)) { defs++; Server server = (Server)bag; Cluster cluster = server.getCluster(); if (cluster != null && cluster.containsProperty(propName)) defs++; if (server.getConfig().containsProperty(propName)) defs++; bag = domain.getClusterNamed(target); if (bag != null && bag.containsProperty(propName)) { defs++; Cluster c = (Cluster)bag; Config clusterConfig = domain.getConfigNamed(c.getConfigRef()); if (clusterConfig.containsProperty(propName)) defs++;
public static List<String> getAllTargets(Domain d) { List<String> targets = new ArrayList<String>(); // only add non-clustered servers as the cluster // targets will be separately added for (Server server : d.getServers().getServer()) { if (server.getCluster() == null) { targets.add(server.getName()); } } if (d.getClusters() != null) { for (Cluster cluster : d.getClusters().getCluster()) { targets.add(cluster.getName()); } } return targets; }
protected Config getConfigForName(String targetName, ServiceLocator serviceLocator, Domain domain) { if (CommandTarget.CONFIG.isValid(serviceLocator, targetName)) { return domain.getConfigNamed(targetName); } if (CommandTarget.DAS.isValid(serviceLocator, targetName) || CommandTarget.STANDALONE_INSTANCE.isValid(serviceLocator, targetName)) { Server s = domain.getServerNamed(targetName); return s == null ? null : domain.getConfigNamed(s.getConfigRef()); } if (CommandTarget.CLUSTER.isValid(serviceLocator, targetName)) { Cluster cl = domain.getClusterNamed(targetName); return cl == null ? null : domain.getConfigNamed(cl.getConfigRef()); } return null; }
private void setupSupplemental(AdminCommandContext context, final Server instance) { if (clusterName != null) { InstanceRegisterInstanceCommandParameters cp = new InstanceRegisterInstanceCommandParameters(); context.getActionReport(). setResultType(InstanceRegisterInstanceCommandParameters.class, cp); Node instNode = domain.getNodeNamed(node); cp.config = instance.getConfigRef(); cp.nodehost = instNode.getNodeHost(); cp.nodedir = instNode.getNodeDir(); cp.installdir = instNode.getInstallDir(); List<SystemProperty> spList = instance.getSystemProperty(); if (spList != null) { Properties p = new Properties(); for (SystemProperty sp : spList) { p.put(sp.getName(), sp.getValue()); } cp.systemProperties = p; } } }
protected CommandTarget getTypeForTarget(String target){ Domain domain = Globals.get(Domain.class); Config config = domain.getConfigNamed(target); if (config != null) return CommandTarget.CONFIG; Server targetServer = domain.getServerNamed(target); if (targetServer!=null) { // Clusters clusters = domain.getClusters(); // List clustersList = clusters.getCluster(); //if (JmsRaUtil.isServerClustered(clustersList, target)) // return CommandTarget.CLUSTERED_INSTANCE; if (targetServer.isDas()) return CommandTarget.DAS; else return CommandTarget.STANDALONE_INSTANCE; }//end if (targetServer!=null) Cluster cluster =domain.getClusterNamed(target); if (cluster!=null) { return CommandTarget.CLUSTER; } return CommandTarget.DAS; } /*