Package com.sun.enterprise.config.serverbeans

Examples of com.sun.enterprise.config.serverbeans.Cluster$DeleteDecorator


                    }
                    //If target is a clustered instance and the allowed types does not allow operations on clustered
                    //instance, return error
                    if ((CommandTarget.CLUSTERED_INSTANCE.isValid(habitat, targetName))
                            && (!targetTypesAllowed.contains(CommandTarget.CLUSTERED_INSTANCE))) {
                        Cluster c = domain.getClusterForInstance(targetName);
                        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
                        report.setMessage(adminStrings.getLocalString("commandrunner.executor.instanceopnotallowed",
                                "The {0} command is not allowed on instance {1} because it is part of cluster {2}",
                                model.getCommandName(), targetName, c.getName()));
                        return;
                    }
                    logger.fine(adminStrings.getLocalString("dynamicreconfiguration.diagnostics.replicationvalidationdone",
                            "All @ExecuteOn attribute and type validation completed successfully. Starting replication stages"));
                }
View Full Code Here


        // so we need to add System Properties in *reverse order* to get the
        // right precedence.

        List<SystemProperty> domainSPList = domain.getSystemProperty();
        List<SystemProperty> configSPList = getConfigSystemProperties();
        Cluster cluster = server.getCluster();
        List<SystemProperty> clusterSPList = null;


        if (cluster != null) {
            clusterSPList = cluster.getSystemProperty();


        }
        List<SystemProperty> serverSPList = server.getSystemProperty();

View Full Code Here

        Logger logger = context.getLogger();
        ActionReport report = context.getActionReport();

        // Get the cluster specified by clusterName
        Cluster cluster = domain.getClusterNamed(clusterName);
        if (cluster == null) {
            String msg = Strings.get("cluster.command.unknownCluster",
                    clusterName);
            throw new CommandException(msg);
        }
View Full Code Here

                        return newServer;
                    }
                }, domain.getServers());

                // create server-ref on cluster
                Cluster thisCluster = domain.getClusterNamed(clusterName);
                if (thisCluster != null) {
                    ConfigSupport.apply(new SingleConfigCode<Cluster>() {

                        public Object run(Cluster param) throws PropertyVetoException, TransactionFailure {
View Full Code Here

                    }
                    //If target is a clustered instance and the allowed types does not allow operations on clustered
                    //instance, return error
                    if ((CommandTarget.CLUSTERED_INSTANCE.isValid(habitat, targetName))
                            && (!targetTypesAllowed.contains(CommandTarget.CLUSTERED_INSTANCE))) {
                        Cluster c = domain.getClusterForInstance(targetName);
                        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
                        report.setMessage(adminStrings.getLocalString("commandrunner.executor.instanceopnotallowed",
                                "The {0} command is not allowed on instance {1} because it is part of cluster {2}",
                                model.getCommandName(), targetName, c.getName()));
                        return;
                    }
                    logger.fine(adminStrings.getLocalString("dynamicreconfiguration.diagnostics.replicationvalidationdone",
                            "All @ExecuteOn attribute and type validation completed successfully. Starting replication stages"));
                }
View Full Code Here

    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 {
View Full Code Here

                  //  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;
View Full Code Here

            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;
        }
        Cluster cluster = newMBServer.getCluster();//domain.getClusterNamed(clusterName);

        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.getJmsService();
       Server oldMBServer = null;
       //If Master broker has been set previously using this command, use that master broker as the old MB instance
       //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{
            updateMasterBroker(oldMBServer.getName(), oldMasterBroker, newMasterBroker);
       }catch(Exception e){
                      report.setMessage(localStrings.getLocalString("change.master.broker.CannotChangeMB",
                                    "Unable to change master broker."));
                            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).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);
    }
View Full Code Here

                  //  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;
View Full Code Here

                    return;
                }
                // create new ResourceRef as a child of Server
                server.createResourceRef(enabled.toString(), refName);
            } else {
                Cluster cluster = domain.getClusterNamed(target);
                if (cluster.isResourceRefExists(refName)) {
                    report.setMessage(localStrings.getLocalString("create.resource.ref.existsAlready",
                            "Resource ref {0} already exists", refName));
                    report.setActionExitCode(ActionReport.ExitCode.FAILURE);
                    return;
                }
                // create new ResourceRef as a child of Cluster
                cluster.createResourceRef(enabled.toString(), refName);

                // create new ResourceRef for all instances of Cluster
                Target tgt = habitat.getComponent(Target.class);
                List<Server> instances = tgt.getInstances(target);
                for (Server svr : instances) {
View Full Code Here

TOP

Related Classes of com.sun.enterprise.config.serverbeans.Cluster$DeleteDecorator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.