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; }
public static List<ApplicationRef> getApplicationRefsInTarget( Domain me, String tgt, boolean includeInstances) { List<String> targets = getTargets(me, tgt); List<ApplicationRef> allAppRefs = new ArrayList<ApplicationRef>(); for (String target : targets) { Server server = me.getServerNamed(target); if (server != null) { allAppRefs.addAll(server.getApplicationRef()); } else { Cluster cluster = getClusterNamed(me, target); if (cluster != null) { allAppRefs.addAll(cluster.getApplicationRef()); if (includeInstances) { for (Server svr : cluster.getInstances() ) { allAppRefs.addAll(svr.getApplicationRef()); } } } } } return allAppRefs; }
/** * Returns the config element that represents a given cluster * @param targetName the name of the target * @return Config element representing the cluster */ public Config getClusterConfig(String targetName) { Cluster cl = getCluster(targetName); if(cl == null) return null; return(domain.getConfigNamed(cl.getConfigRef())); }
private GMSAdapter checkCluster(Cluster cluster) { GMSAdapter result = null; String gmsEnString = cluster.getGmsEnabled(); if (GMSBS_LOGGER.isLoggable(TRACE_LEVEL)) { GMSBS_LOGGER.log(TRACE_LEVEL, String.format("cluster %s found with gms-enabled='%s'", cluster.getName(), gmsEnString)); } if (gmsEnString != null && Boolean.parseBoolean(gmsEnString)) { result = loadModule(cluster); } return result; }
public Object run(Cluster param) throws PropertyVetoException, TransactionFailure { ResourceRef newResourceRef = param.createChild(ResourceRef.class); newResourceRef.setEnabled(enabled); newResourceRef.setRef(refName); param.getResourceRef().add(newResourceRef); return newResourceRef; } }, cluster);
public Object run(Cluster param) throws PropertyVetoException, TransactionFailure { ServerRef newServerRef = param.createChild(ServerRef.class); newServerRef.setRef(instanceName); newServerRef.setLbEnabled(lbEnabled); param.getServerRef().add(newServerRef); return param; } }, thisCluster);
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);
if (cluster != null && clusterName.equals(cluster.getName())) { ourCluster = cluster; String configName = cluster.getConfigRef(); instance.setConfigRef(configName); clusterExists = true; ourConfig = domain.getConfigNamed(configName); break; if (ourCluster.getProperty("GMS_DISCOVERY_URI_LIST") != null && "generate".equals( ourCluster.getProperty("GMS_DISCOVERY_URI_LIST").getValue())) { ourCluster.getName(); File configConfigDir = new File(env.getConfigDirPath(), ourCluster.getConfigRef()); File docroot = new File(configConfigDir, "docroot"); if (!docroot.exists() && !docroot.mkdirs()) { ServerRef newServerRef = c.createChild(ServerRef.class); newServerRef.setRef(instanceName); if (lbEnabled != null) { List<ServerRef> serverRefs = c.getServerRef(); Iterator<ServerRef> serverRefIter = serverRefs.iterator(); boolean allLBEnabled = false; c.getServerRef().add(newServerRef);
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 String instanceName = instance.getName(); if (instance.getGmsBindInterfaceAddress() == null) { instance.setGmsBindInterfaceAddress(String.format( "${GMS-BIND-INTERFACE-ADDRESS-%s}", instanceName)); if (instance.getGmsMulticastAddress() == null) { instance.setGmsMulticastAddress(generateHeartbeatAddress()); if (instance.getGmsMulticastPort() == null) { instance.setGmsMulticastPort(generateHeartbeatPort()); Property gmsListenerPort = instance.createChild(Property.class); gmsListenerPort.setName("GMS_LISTENER_PORT"); gmsListenerPort.setValue(String.format("${GMS_LISTENER_PORT-%s}", instanceName)); instance.getProperty().add(gmsListenerPort); if (config==null) { config = habitat.getAllByContract(Config.class).iterator().next(); logger.warning(localStrings.getLocalString(Cluster.class, "Cluster.no_default_config_found", "No default config found, using config {0} as the default config for the cluster {1}", config.getName(), instance.getName())); Configs configs = domain.getConfigs(); Configs writableConfigs = t.enroll(configs); final String configName = instance.getName() + "-config"; instance.setConfigRef(configName); command.copyConfig(writableConfigs,config,configName,logger);
context.getActionReport(). setResultType(String.class, cluster.getName()); String instanceConfig = child.getConfigRef(); final Config config = configs.getConfigByName(instanceConfig); if (config != null && domain.getReferenceContainersOf(config).size() > 1) { return; final String autoGeneratedName = child.getName() + "-config"; if (!autoGeneratedName.equals(instanceConfig)) return; File configConfigDir = new File(env.getConfigDirPath(), config.getName()); FileUtils.whack(configConfigDir); Cluster c = t.enroll(cluster); List<ServerRef> serverRefList = c.getServerRef(); ServerRef serverRef = null; "Unable to remove server-ref {0} from cluster {1}", instanceName, cluster.getName()), ex); "Unable to remove server-ref {0} from cluster {1}", instanceName, cluster.getName());
@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); }
PropertyVetoException, TransactionFailure{ Logger logger = LogDomains.getLogger(Cluster.class, LogDomains.ADMIN_LOGGER); LocalStringManagerImpl localStrings = new LocalStringManagerImpl(Cluster.class); final ActionReport report = context.getActionReport(); String instanceConfig = child.getConfigRef(); final Config config = configs.getConfigByName(instanceConfig); Transaction t = Transaction.getTransaction(parent); List<ServerRef> serverRefs = child.getServerRef(); StringBuffer namesOfServers = new StringBuffer(); if (serverRefs.size() > 0) { final String msg = localStrings.getLocalString( "Cluster.hasInstances", "Cluster {0} contains server instances {1} and must not contain any instances" ,child.getName() ,namesOfServers.toString() ); if(config == null || domain.getReferenceContainersOf(config).size() > 1 || !instanceConfig.equals(child.getName() + "-config")) return; File configConfigDir = new File(env.getConfigDirPath(), config.getName()); FileUtils.whack(configConfigDir);
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;
targets.add(tgt); } else { targets = domain.getAllReferencedTargetsForApplication(appName); Server servr = dmn.getServerNamed(target); if (servr != null) { servr.getApplicationRef()) { if (appRef.getRef().equals(appName)) { ((Server)servr_w).getApplicationRef().remove( appRef); break; Cluster cluster = dmn.getClusterNamed(target); if (cluster != null) { cluster.getApplicationRef()) { if (appRef.getRef().equals(appName)) { ((Cluster)cluster_w).getApplicationRef().remove( appRef); break; for (Server svr : cluster.getInstances() ) { ConfigBeanProxy svr_w = t.enroll(svr); for (ApplicationRef appRef : svr.getApplicationRef()) { if (appRef.getRef().equals(appName)) { ((Server)svr_w).getApplicationRef(
public void execute(AdminCommandContext context) { ActionReport report = context.getActionReport(); Services services = domain.getExtensionByType(Services.class); if (services != null) { for (org.glassfish.paas.orchestrator.config.Service service : services.getServices()) { sharedServiceFound = true; if (sharedService.getState().equalsIgnoreCase(ServiceStatus.STOPPED.toString())) { report.setMessage("A shared service by name [" + sharedService.getServiceName() + "] is not running."); report.setActionExitCode(ActionReport.ExitCode.SUCCESS); return; appName = serviceRef.getApplicationName(); if (appName != null) { Clusters clusters = domain.getClusters(); List<Cluster> clusterList = clusters.getCluster(); for (Cluster cluster : clusterList) { ApplicationRef applicationRef = cluster.getApplicationRef(appName); if (applicationRef != null) { if ("true".equalsIgnoreCase(applicationRef.getEnabled())) { appEnabled = true; report.setMessage("A shared service by name [" + serviceName + "] is used by an application " + "[" + appName + "]."); report.setActionExitCode(ActionReport.ExitCode.FAILURE);
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++;
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; }
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; }