Search in sources :

Example 21 with Cluster

use of com.sun.enterprise.config.serverbeans.Cluster in project Payara by payara.

the class ConfigureLBWeightCommand method execute.

@Override
public void execute(AdminCommandContext context) {
    final ActionReport report = context.getActionReport();
    final Logger logger = context.getLogger();
    report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
    Map<String, Integer> instanceWeights = null;
    try {
        instanceWeights = getInstanceWeightsMap(weights);
    } catch (CommandException ce) {
        report.setMessage(localStrings.getLocalString("InvalidWeightValue", "Invalid weight value"));
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        report.setFailureCause(ce);
        return;
    }
    Cluster cl = domain.getClusterNamed(cluster);
    if (cl == null) {
        String msg = localStrings.getLocalString("NoSuchCluster", "No such cluster {0}", cluster);
        logger.warning(msg);
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        report.setMessage(msg);
        return;
    }
    for (Iterator it = instanceWeights.entrySet().iterator(); it.hasNext(); ) {
        Map.Entry entry = (Map.Entry) it.next();
        String instance = (String) entry.getKey();
        try {
            Server s = domain.getServerNamed(instance);
            if (s == null) {
                String msg = localStrings.getLocalString("NoSuchInstance", "No such instance {0}", instance);
                logger.warning(msg);
                report.setActionExitCode(ActionReport.ExitCode.FAILURE);
                report.setMessage(msg);
                return;
            }
            Cluster c = domain.getClusterForInstance(s.getName());
            if (c == null) {
                String msg = localStrings.getLocalString("InstanceDoesNotBelongToCluster", "Instance {0} does not belong to cluster {1}.", instance, cluster);
                logger.warning(msg);
                report.setActionExitCode(ActionReport.ExitCode.FAILURE);
                report.setMessage(msg);
                return;
            }
            if (!c.getName().equals(cluster)) {
                String msg = localStrings.getLocalString("InstanceDoesNotBelongToCluster", "Instance {0} does not belong to cluster {1}.", instance, cluster);
                logger.warning(msg);
                report.setActionExitCode(ActionReport.ExitCode.FAILURE);
                report.setMessage(msg);
                return;
            }
            updateLBWeight(s, entry.getValue().toString());
        } catch (TransactionFailure ex) {
            report.setMessage(ex.getMessage());
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            report.setFailureCause(ex);
            return;
        }
    }
}
Also used : Server(com.sun.enterprise.config.serverbeans.Server) Cluster(com.sun.enterprise.config.serverbeans.Cluster) ActionReport(org.glassfish.api.ActionReport) Logger(java.util.logging.Logger) Iterator(java.util.Iterator) Map(java.util.Map)

Example 22 with Cluster

use of com.sun.enterprise.config.serverbeans.Cluster in project Payara by payara.

the class DeleteHTTPLBRefCommand method deleteClusterFromLBConfig.

private void deleteClusterFromLBConfig(LbConfigs lbconfigs, String configName, String clusterName) {
    LbConfig lbConfig = lbconfigs.getLbConfig(configName);
    ClusterRef cRef = lbConfig.getRefByRef(ClusterRef.class, clusterName);
    if (cRef == null) {
        // does not exist, just return from here
        String msg = localStrings.getLocalString("ClusterNotDefined", "Cluster {0} cannot be used as target", target);
        if (logger.isLoggable(Level.FINEST)) {
            logger.finest("Cluster " + clusterName + " does not exist.");
        }
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        report.setMessage(msg);
        return;
    }
    if (!Boolean.parseBoolean(force)) {
        Cluster c = domain.getClusterNamed(clusterName);
        if (c == null) {
            String msg = localStrings.getLocalString("ClusterNotDefined", "Cluster {0} cannot be used as target", target);
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            report.setMessage(msg);
            return;
        }
        List<ServerRef> sRefs = c.getServerRef();
        boolean refLbEnabled = false;
        for (ServerRef ref : sRefs) {
            if (Boolean.parseBoolean(ref.getLbEnabled())) {
                refLbEnabled = true;
            }
        }
        if (refLbEnabled) {
            String msg = localStrings.getLocalString("ServerNeedsToBeDisabled", "Server [{0}] needs to be disabled before it can be removed from the load balancer.", target);
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            report.setMessage(msg);
            return;
        }
    }
    removeClusterRef(lbConfig, cRef);
}
Also used : LbConfig(org.glassfish.loadbalancer.config.LbConfig) Cluster(com.sun.enterprise.config.serverbeans.Cluster) ClusterRef(com.sun.enterprise.config.serverbeans.ClusterRef) ServerRef(com.sun.enterprise.config.serverbeans.ServerRef)

Example 23 with Cluster

use of com.sun.enterprise.config.serverbeans.Cluster in project Payara by payara.

the class ConfigureJMSCluster method execute.

/**
 * Executes the command with the command parameters passed as Properties
 * where the keys are the paramter names and the values the parameter values
 *
 * @param context information
 */
public void execute(AdminCommandContext context) {
    final ActionReport report = context.getActionReport();
    // Server targetServer = domain.getServerNamed(target);
    // String configRef = targetServer.getConfigRef();
    Cluster cluster = domain.getClusterNamed(clusterName);
    if (cluster == null) {
        report.setMessage(localStrings.getLocalString("configure.jms.cluster.invalidClusterName", "No Cluster by this name has been configured"));
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        return;
    }
    List instances = cluster.getInstances();
    String warning = null;
    if (instances.size() > 0) {
        ActionReport listReport = habitat.getService(ActionReport.class);
        ParameterMap parameters = new ParameterMap();
        parameters.set("DEFAULT", clusterName);
        commandRunner.getCommandInvocation("list-instances", listReport, context.getSubject()).parameters(parameters).execute();
        if (ActionReport.ExitCode.FAILURE.equals(listReport.getActionExitCode())) {
            warning = localStrings.getLocalString("configure.jms.cluster.clusterWithInstances", "Warning: Please make sure running this command with all cluster instances stopped, otherwise it may lead to inconsistent JMS behavior and corruption of configuration and message stores.");
        } else {
            String result = listReport.getMessage();
            String fixedResult = result.replaceAll("not running", "stopped");
            if (fixedResult.indexOf("running") > -1) {
                warning = localStrings.getLocalString("configure.jms.cluster.clusterWithInstances", "Warning: Please make sure running this command with all cluster instances stopped, otherwise it may lead to inconsistent JMS behavior and corruption of configuration and message stores.");
                warning = warning + "\r\n" + result + "\r\n";
            }
        }
    }
    Config config = domain.getConfigNamed(cluster.getConfigRef());
    JmsService jmsService = config.getExtensionByType(JmsService.class);
    if (jmsService == null) {
        report.setMessage(localStrings.getLocalString("configure.jms.cluster.nojmsservice", "No JMS Service element in config"));
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        return;
    }
    if (!CONVENTIONAL.equalsIgnoreCase(clusterType) && !ENHANCED.equalsIgnoreCase(clusterType)) {
        report.setMessage(localStrings.getLocalString("configure.jms.cluster.wrongClusterType", "Invalid option sepecified for clustertype. Valid options are conventional and enhanced"));
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        return;
    }
    if (CONVENTIONAL.equalsIgnoreCase(clusterType) && !MASTER_BROKER.equalsIgnoreCase(configStoreType) && !SHARED_DB.equalsIgnoreCase(configStoreType)) {
        report.setMessage(localStrings.getLocalString("configure.jms.cluster.wrongConfigStoreType", "Invalid option sepecified for configstoretype. Valid options are masterbroker and shareddb"));
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        return;
    }
    if (ENHANCED.equalsIgnoreCase(clusterType) && configStoreType != null) {
        report.setMessage(localStrings.getLocalString("configure.jms.cluster.wrongStoreType", "configstoretype option is not configurable for Enhanced clusters."));
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        return;
    }
    if (CONVENTIONAL.equalsIgnoreCase(clusterType) && !MASTER_BROKER.equalsIgnoreCase(configStoreType) && !FILE.equalsIgnoreCase(messageStoreType) && !JDBC.equalsIgnoreCase(messageStoreType)) {
        report.setMessage(localStrings.getLocalString("configure.jms.cluster.wrongMessageStoreType", "Invalid option sepecified for messagestoretype. Valid options are file and jdbc"));
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        return;
    }
    if (ENHANCED.equalsIgnoreCase(clusterType) && messageStoreType != null) {
        report.setMessage(localStrings.getLocalString("configure.jms.cluster.wrongmsgStoreType", "messagestoretype option is not configurable for Enhanced clusters."));
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        return;
    }
    String integrationMode = jmsService.getType();
    if (REMOTE.equalsIgnoreCase(integrationMode)) {
        report.setMessage(localStrings.getLocalString("configure.jms.cluster.remoteMode", "JMS integration mode should be either EMBEDDED or LOCAL to run this command. Please use the asadmin.set command to change the integration mode"));
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        return;
    }
    String changeIntegrationMode = null;
    if (EMBEDDED.equalsIgnoreCase(integrationMode) && ENHANCED.equalsIgnoreCase(clusterType)) {
        try {
            ConfigSupport.apply(new SingleConfigCode<JmsService>() {

                public Object run(JmsService param) throws PropertyVetoException, TransactionFailure {
                    param.setType(LOCAL);
                    return param;
                }
            }, jmsService);
            changeIntegrationMode = localStrings.getLocalString("configure.jms.cluster.integrationModeChanged", "WARNING: JMS integration mode has been changed from EMBEDDED to LOCAL automatically.");
        } catch (TransactionFailure tfe) {
            report.setMessage(localStrings.getLocalString("configure.jms.cluster.cannotChangeIntegrationMode", "Unable to change the JMS integration mode to LOCAL for Enhanced cluster {0}.", clusterName) + " " + tfe.getLocalizedMessage());
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            report.setFailureCause(tfe);
            return;
        }
    }
    if (MASTER_BROKER.equalsIgnoreCase(configStoreType) && FILE.equals(messageStoreType)) {
        if (dbvendor != null || dburl != null || dbuser != null) {
            report.setMessage(localStrings.getLocalString("configure.jms.cluster.invalidDboptions", "Database options should not be specified for this configuration"));
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            return;
        }
    }
    if (!MASTER_BROKER.equalsIgnoreCase(configStoreType) || ENHANCED.equalsIgnoreCase(clusterType) || JDBC.equalsIgnoreCase(messageStoreType)) {
        if (dbvendor == null) {
            report.setMessage(localStrings.getLocalString("configure.jms.cluster.nodbvendor", "No DataBase vendor specified"));
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            return;
        } else if (dburl == null) {
            report.setMessage(localStrings.getLocalString("configure.jms.cluster.nojdbcurl", "No JDBC URL specified"));
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            return;
        } else if (!isSupportedDbVendor()) {
            report.setMessage(localStrings.getLocalString("configure.jms.cluster.invaliddbvendor", "Invalid DB Vednor specified"));
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            return;
        }
    }
    if (CONVENTIONAL.equalsIgnoreCase(clusterType) && configStoreType == null) {
        report.setMessage(localStrings.getLocalString("configure.jms.cluster.noConfigStoreType", "No configstoretype specified. Using the default value - masterbroker"));
        configStoreType = "masterbroker";
    }
    if (CONVENTIONAL.equalsIgnoreCase(clusterType) && messageStoreType == null) {
        report.setMessage(localStrings.getLocalString("configure.jms.cluster.noMessagetoreType", "No messagestoretype specified. Using the default value - file"));
        messageStoreType = "file";
    }
    config = domain.getConfigNamed(cluster.getConfigRef());
    JmsAvailability jmsAvailability = config.getAvailabilityService().getExtensionByType(JmsAvailability.class);
    final Boolean availabilityEnabled = Boolean.valueOf(ENHANCED.equalsIgnoreCase(clusterType));
    try {
        ConfigSupport.apply(new SingleConfigCode<JmsAvailability>() {

            public Object run(JmsAvailability param) throws PropertyVetoException, TransactionFailure {
                param.setAvailabilityEnabled(availabilityEnabled.toString());
                if (availabilityEnabled.booleanValue()) {
                    param.setMessageStoreType(JDBC);
                } else {
                    param.setConfigStoreType(configStoreType.toLowerCase(Locale.ENGLISH));
                    param.setMessageStoreType(messageStoreType.toLowerCase(Locale.ENGLISH));
                }
                param.setDbVendor(dbvendor);
                param.setDbUsername(dbuser);
                param.setDbPassword(jmsDbPassword);
                param.setDbUrl(dburl);
                if (props != null) {
                    for (Map.Entry e : props.entrySet()) {
                        Property prop = param.createChild(Property.class);
                        prop.setName((String) e.getKey());
                        prop.setValue((String) e.getValue());
                        param.getProperty().add(prop);
                    }
                }
                return param;
            }
        }, jmsAvailability);
    /* //update the useMasterBroker flag on the JmsService only if availabiltyEnabled is false
            if(!availabilityEnabled.booleanValue()){
              ConfigSupport.apply(new SingleConfigCode<JmsService>() {
                public Object run(JmsService param) throws PropertyVetoException, TransactionFailure {

                    param.setUseMasterBroker(useMasterBroker.toString());
                    return param;
                }
            }, jmsservice);
            }*/
    } catch (TransactionFailure tfe) {
        report.setMessage((changeIntegrationMode == null ? "" : changeIntegrationMode + "\n") + localStrings.getLocalString("configure.jms.cluster.fail", "Unable to Configure JMS Cluster for cluster {0}.", clusterName) + " " + tfe.getLocalizedMessage());
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        report.setFailureCause(tfe);
    }
    report.setMessage((warning == null ? "" : warning + "\n") + (changeIntegrationMode == null ? "" : changeIntegrationMode + "\n") + localStrings.getLocalString("configure.jms.cluster.success", "JMS Cluster Configuration updated for Cluster {0}.", clusterName));
    report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}
Also used : TransactionFailure(org.jvnet.hk2.config.TransactionFailure) JmsService(com.sun.enterprise.connectors.jms.config.JmsService) Cluster(com.sun.enterprise.config.serverbeans.Cluster) ActionReport(org.glassfish.api.ActionReport) PropertyVetoException(java.beans.PropertyVetoException) JmsAvailability(com.sun.enterprise.connectors.jms.config.JmsAvailability) List(java.util.List) Property(org.jvnet.hk2.config.types.Property)

Example 24 with Cluster

use of com.sun.enterprise.config.serverbeans.Cluster in project Payara by payara.

the class JMSPing method execute.

/**
 * Executes the command with the command parameters passed as Properties
 * where the keys are the paramter names and the values the parameter values
 *
 * @param context information
 */
public void execute(AdminCommandContext context) {
    final ActionReport report = context.getActionReport();
    Server targetServer = domain.getServerNamed(target);
    // String configRef = targetServer.getConfigRef();
    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());
    }
    JmsService jmsservice = config.getExtensionByType(JmsService.class);
    /* for (Config c : configs.getConfig()) {

                      if(configRef.equals(c.getName()))
                            jmsservice = c.getJmsService();
                   } */
    String defaultJmshostStr = jmsservice.getDefaultJmsHost();
    JmsHost defaultJmsHost = null;
    for (JmsHost jmshost : jmsservice.getJmsHost()) {
        if (jmshost.getName().equals(defaultJmshostStr)) {
            defaultJmsHost = jmshost;
        }
    }
    if (defaultJmsHost == null) {
        report.setMessage(localStrings.getLocalString("jms-ping.noDefaultJMSHost", "Unable to PING the JMS Broker as no Default JMS Host is configured on the DAS"));
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        return;
    }
    String tmpJMSResource = "test_jms_adapter";
    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);
        return;
    }
    try {
        boolean value = pingConnectionPool(tmpJMSResource + JNDINAME_APPENDER);
        if (!value) {
            report.setMessage(localStrings.getLocalString("jms-ping.pingConnectionPoolFailed", "Pinging to the JMS Host failed."));
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        } else {
            report.setMessage(localStrings.getLocalString("jms-ping.pingConnectionPoolSuccess", "JMS-ping command executed successfully"));
            report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
        }
    } catch (ResourceException e) {
        report.setMessage(localStrings.getLocalString("jms-ping.pingConnectionPoolException", "An exception occured while trying to ping the JMS Host.", e.getMessage()));
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
    }
    deleteJMSResource(subReport, tmpJMSResource, context.getSubject());
    if (ActionReport.ExitCode.FAILURE.equals(subReport.getActionExitCode())) {
        report.setMessage(localStrings.getLocalString("jms-ping.cannotdeleteJMSResource", "Unable to delete the temporary JMS Resource " + tmpJMSResource + ". Please delete this manually.", tmpJMSResource));
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        return;
    }
}
Also used : Server(com.sun.enterprise.config.serverbeans.Server) JmsService(com.sun.enterprise.connectors.jms.config.JmsService) ResourceException(javax.resource.ResourceException) ActionReport(org.glassfish.api.ActionReport) JmsHost(com.sun.enterprise.connectors.jms.config.JmsHost) Cluster(com.sun.enterprise.config.serverbeans.Cluster)

Example 25 with Cluster

use of com.sun.enterprise.config.serverbeans.Cluster in project Payara by payara.

the class ChangeMasterBrokerCommand method execute.

/**
 * Executes the command with the command parameters passed as Properties
 * where the keys are the paramter names and the values the parameter values
 *
 * @param context information
 */
public void execute(AdminCommandContext context) {
    final ActionReport report = context.getActionReport();
    final String newMB = newMasterBroker;
    Server newMBServer = domain.getServerNamed(newMasterBroker);
    if (newMBServer == null) {
        report.setMessage(localStrings.getLocalString("change.master.broker.invalidServerName", "Invalid server name specified. There is no server by this name"));
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        return;
    }
    // domain.getClusterNamed(clusterName);
    Cluster cluster = newMBServer.getCluster();
    if (cluster == null) {
        report.setMessage(localStrings.getLocalString("change.master.broker.invalidClusterName", "The server specified is not associated with a cluster. The server assocaited with the master broker has to be a part of the cluster"));
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        return;
    }
    /*if(!cluster.getName().equals(newMBServer.getCluster().getName()))
        {
            report.setMessage(localStrings.getLocalString("configure.jms.cluster.invalidClusterName",
                            "{0} does not belong to the specified cluster", newMasterBroker));
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            return;
        } */
    Nodes nodes = domain.getNodes();
    config = domain.getConfigNamed(cluster.getConfigRef());
    JmsService jmsservice = config.getExtensionByType(JmsService.class);
    Server oldMBServer = null;
    // Else use the first configured instance in the cluster list
    if (jmsservice.getMasterBroker() != null) {
        oldMBServer = domain.getServerNamed(jmsservice.getMasterBroker());
    } else {
        List<Server> serverList = cluster.getInstances();
        // if(serverList == null || serverList.size() == 0){
        // report.setMessage(localStrings.getLocalString("change.master.broker.invalidCluster",
        // "No servers configured in cluster {0}", clusterName));
        // report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        // return;
        // }
        oldMBServer = serverList.get(0);
    }
    String oldMasterBrokerPort = JmsRaUtil.getJMSPropertyValue(oldMBServer);
    if (oldMasterBrokerPort == null) {
        SystemProperty sp = config.getSystemProperty("JMS_PROVIDER_PORT");
        if (sp != null)
            oldMasterBrokerPort = sp.getValue();
    }
    if (oldMasterBrokerPort == null)
        oldMasterBrokerPort = getDefaultJmsHost(jmsservice).getPort();
    String oldMasterBrokerHost = nodes.getNode(oldMBServer.getNodeRef()).getNodeHost();
    String newMasterBrokerPort = JmsRaUtil.getJMSPropertyValue(newMBServer);
    if (newMasterBrokerPort == null)
        newMasterBrokerPort = getDefaultJmsHost(jmsservice).getPort();
    String newMasterBrokerHost = nodes.getNode(newMBServer.getNodeRef()).getNodeHost();
    String oldMasterBroker = oldMasterBrokerHost + ":" + oldMasterBrokerPort;
    String newMasterBroker = newMasterBrokerHost + ":" + newMasterBrokerPort;
    // System.out.println("1: IN deleteinstanceCheck supplimental oldMasterBroker = " + oldMasterBroker + " newmasterBroker " + newMasterBroker);
    try {
        CompositeData result = updateMasterBroker(oldMBServer.getName(), oldMasterBroker, newMasterBroker);
        boolean success = ((Boolean) result.get("Success")).booleanValue();
        if (!success) {
            int statusCode = ((Integer) result.get("StatusCode")).intValue();
            String detailMessage = (String) result.get("DetailMessage");
            String msg = " " + detailMessage;
            if (BrokerStatusCode.BAD_REQUEST.getCode() == statusCode || BrokerStatusCode.NOT_ALLOWED.getCode() == statusCode || BrokerStatusCode.UNAVAILABLE.getCode() == statusCode || BrokerStatusCode.PRECONDITION_FAILED.getCode() == statusCode) {
                msg = localStrings.getLocalString("change.master.broker.errorMsg", "{0}. But it didn't affect current master broker configuration.", msg);
            } else {
                msg = msg + ". " + localStrings.getLocalString("change.master.broker.otherErrorMsg", "The cluster should be shutdown and configured with the new master broker then restarts.");
            }
            report.setMessage(localStrings.getLocalString("change.master.broker.CannotChangeMB", "Unable to change master broker.{0}", msg));
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            return;
        }
    } catch (Exception e) {
        report.setMessage(localStrings.getLocalString("change.master.broker.CannotChangeMB", "Unable to change master broker.{0}", ""));
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        return;
    }
    try {
        /*String setCommandStr = cluster.getConfigRef() + "." + "jms-service" + "." +"master-Broker";
            ParameterMap parameters = new ParameterMap();
            parameters.set(setCommandStr, newMB );

            ActionReport subReport = report.addSubActionsReport();
	        commandRunner.getCommandInvocation("set", subReport, context.getSubject()).parameters(parameters).execute();

              if (ActionReport.ExitCode.FAILURE.equals(subReport.getActionExitCode())){
                    report.setMessage(localStrings.getLocalString("create.jms.resource.cannotCreateConnectionPool",
                            "Unable to create connection pool."));
                    report.setActionExitCode(ActionReport.ExitCode.FAILURE);
                    return;
              }*/
        ConfigSupport.apply(new SingleConfigCode<JmsService>() {

            public Object run(JmsService param) throws PropertyVetoException, TransactionFailure {
                param.setMasterBroker(newMB);
                return param;
            }
        }, jmsservice);
    } catch (Exception tfe) {
        report.setMessage(localStrings.getLocalString("change.master.broker.fail", "Unable to update the domain.xml with the new master broker") + " " + tfe.getLocalizedMessage());
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        report.setFailureCause(tfe);
    }
    report.setMessage(localStrings.getLocalString("change.master.broker.success", "Master broker change has executed successfully for Cluster {0}.", cluster.getName()));
    report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}
Also used : TransactionFailure(org.jvnet.hk2.config.TransactionFailure) JmsService(com.sun.enterprise.connectors.jms.config.JmsService) CompositeData(javax.management.openmbean.CompositeData) Cluster(com.sun.enterprise.config.serverbeans.Cluster) ActionReport(org.glassfish.api.ActionReport) PropertyVetoException(java.beans.PropertyVetoException) PropertyVetoException(java.beans.PropertyVetoException)

Aggregations

Cluster (com.sun.enterprise.config.serverbeans.Cluster)45 Server (com.sun.enterprise.config.serverbeans.Server)26 ActionReport (org.glassfish.api.ActionReport)12 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)9 Domain (com.sun.enterprise.config.serverbeans.Domain)8 HashMap (java.util.HashMap)8 Config (com.sun.enterprise.config.serverbeans.Config)6 DeploymentGroup (fish.payara.enterprise.config.serverbeans.DeploymentGroup)6 ArrayList (java.util.ArrayList)6 Map (java.util.Map)6 ServerRef (com.sun.enterprise.config.serverbeans.ServerRef)5 ConfigApiTest (com.sun.enterprise.configapi.tests.ConfigApiTest)5 PropertyVetoException (java.beans.PropertyVetoException)5 Test (org.junit.Test)5 SystemProperty (com.sun.enterprise.config.serverbeans.SystemProperty)4 Logger (java.util.logging.Logger)4 ConfigBean (org.jvnet.hk2.config.ConfigBean)4 ConfigSupport (org.jvnet.hk2.config.ConfigSupport)4 ApplicationRef (com.sun.enterprise.config.serverbeans.ApplicationRef)3 JmsService (com.sun.enterprise.connectors.jms.config.JmsService)3