Package com.sun.enterprise.ee.admin.servermgmt

Examples of com.sun.enterprise.ee.admin.servermgmt.EEInstancesManager


    {
        int newStatusCode = statusCode;
        try {
            InstanceConfig instanceConfig=new InstanceConfig(
                InstanceDirs.getRepositoryName(), InstanceDirs.getRepositoryRoot(), instanceName);
            EEInstancesManager eeInstancesManager=new EEInstancesManager(instanceConfig);       
            newStatusCode = eeInstancesManager.getInstanceStatus();             
            if (newStatusCode != statusCode) {
                getLogger().log(Level.INFO, "server " + instanceName + " has admin channel status of " +
                    Status.getStatusString(newStatusCode) + " and desired status of " +
                    Status.getStatusString(statusCode));
            }
View Full Code Here


           
            // get EEInstancesManager and get instances that currently
            // physically exist in repository
            InstanceConfig instanceConfig = new InstanceConfig(
                                            InstanceDirs.getInstanceRoot());
            EEInstancesManager eeInstancesManager = new EEInstancesManager(
                                                    instanceConfig);
            HashMap hmInstances = getInstancesAndStatus(
                                  instanceConfig, eeInstancesManager);
            // loop through for creatation of instances boolean match = false;
            Iterator serverIt = null;
            String instanceName = null;
            int status = 0;
           
            // get node controller config bean from domain
            com.sun.enterprise.config.serverbeans.NodeAgent nodeController
        = getNodeAgentConfigBean(getConfigContext());

            if (nodeController != null) {
                Properties props = null;
                ElementProperty elementProperty = null;
                Cluster cluster = null;
                // need a default, can't have %%%DOMAIN_NAME%%% go into
                // running server
                String domainName="DomainPropertyNotFound";
                // set default to "" because this string will actual be placed
                // in the startserv's java command for starting the instance
                // via the ProcessLauncher. This is the easiest way to have the
                // com.sun.aas.clusterName set to null for a standalone Instance
                String clusterArg = "";
               
                for (int ii = 0; ii < servers.length; ii++) {
                    // check to see if the server belongs to this
                    // node agent (repository)
                    if (instanceConfig.getRepositoryName().equals(
                            servers[ii].getNodeAgentRef())) {
                        // check if instance already exists or
                        // needs to be created.
                        if (instanceExists(servers[ii].getName())) {
                            getLogger().log(Level.INFO,
                            "nodeagent.instance.exists", servers[ii].getName());
                        } else {
                            // instance does not exist so create it
                            getLogger().log(Level.INFO,
                            "nodeagent.create.instance", servers[ii].getName());
                            instanceConfig.setInstanceName(servers[ii].getName());
                            // set properties for token replacing startserv scripts
                            props = new Properties();
                            // add proper domain
                            elementProperty = domain.getElementPropertyByName(
                                           DOMAIN_XML_DOMAIN_NAME_PROPERTY_NAME);
                            if (elementProperty != null)
                               domainName=elementProperty.getValue();
                           
                            getLogger().log(Level.INFO,
                                        "domain for instance - " + domainName);
                            props.setProperty(EEScriptsTokens.DOMAIN_NAME,
                                              domainName);

                            if (ServerHelper.isServerClustered(
                                  getConfigContext(), servers[ii].getName())) {
                                try {
                                    // see if part of cluster
                                    cluster = ClusterHelper.getClusterForInstance(
                                      getConfigContext(), servers[ii].getName());
                                    if (cluster != null)
                                        clusterArg = "-D" + CLUSTER_NAME + "=\""
                                                   + cluster.getName() + "\"";                                   
                                } catch (ConfigException ce) {
                                    // show at finest, because the server may
                                    // not be part of cluster
                                    getLogger().log(Level.FINEST,
                                        "Server isn't part of cluster", ce);
                                }
                            }
                            props.setProperty(EEScriptsTokens.CLUSTER_NAME, clusterArg);                           
                            // set the overriding properties used in token replacement
                            eeInstancesManager.setOverridingProperties(props);
                            // create instance
                            eeInstancesManager.createInstance();                           
                            // make list of created server instances to know which ones to
                            // sync on nodeagent startup.
                            createdInstances.add(servers[ii].getName());
                        }
                        // remove it from delete instances array
                        hmInstances.remove(servers[ii].getName());
                    }
                }
            }
           
            // loop through and delete instances if nessesary
            serverIt = hmInstances.keySet().iterator();
            while (serverIt.hasNext()) {
                instanceName = (String)serverIt.next();
                status = ((Status)hmInstances.get(instanceName)).getStatusCode();
               
                // delete instances
                if (bDebug) System.out.println("Delete Server =" + instanceName
                                             + " with status:" + status);
                getLogger().log(Level.INFO, "nodeagent.delete.instance",
                                instanceName);
                instanceConfig.setInstanceName(instanceName);
               
                // check to see if instances is
                if(status != Status.kInstanceNotRunningCode) {
                    try {
                        stopInstance(instanceName);
                    } catch (AgentException e) {
                        // only log exception, and continue deleting
                        StringManagerBase sm = StringManagerBase.getStringManager(
                            getLogger().getResourceBundleName())
                        getLogger().log(
                          Level.INFO,
                          sm.getString(
                             "nodeagent.stop.instance.exception", instanceName),
                          e);                         
                    }
                }
                // delete instance, without checking for JMS
                // instances (RepositoryManager)
                eeInstancesManager.deleteInstance(false);
            }
           
            // after all has been completed successfully
            // synchonize newly created instances to make sure that the new
            // synchroniztion strategy doesn't leave an instance without a
View Full Code Here

     * @return HashMap of instance names as the key and the status as the value
     */
    protected HashMap getInstancesAndStatus() throws RepositoryException {
        InstanceConfig instanceConfig =
            new InstanceConfig(InstanceDirs.getInstanceRoot());
        EEInstancesManager eeInstancesManager =
            new EEInstancesManager(instanceConfig);
        return getInstancesAndStatus(instanceConfig, eeInstancesManager);
    }
View Full Code Here

     */
    public void startInstance() throws ProcessManagerException {
        try {
            if(bDebug) System.err.println("\n" + this.getClass().getName() + ": ProcessInstanceInternal:startInstance for :" + getName());
            InstanceConfig instanceConfig=new InstanceConfig(InstanceDirs.getRepositoryName(), InstanceDirs.getRepositoryRoot(), getName());
            EEInstancesManager eeInstancesManager=new EEInstancesManager(instanceConfig);
            // reset exitcode to make sure on restart it doesn't incur a race condition in the
            // monitor where the exitCode is non-zero and it has a process so another reset is attempted
            setExitCode(0);
            // start instance, this will not sync since sync call was moved to nodeagent, and it is not supposed to sync
            setProcess(eeInstancesManager.startInstance());
            if(bDebug) System.out.println("\nCurrently Running:" + ProcessManager.getInstance().toString());
           
        } catch (Exception e) {
            throw new ProcessManagerException(e);
        }
View Full Code Here

           
            InstanceConfig instanceConfig =
                new InstanceConfig(InstanceDirs.getRepositoryName(),
                                   InstanceDirs.getRepositoryRoot(), getName());
            //instanceConfig.setInstanceName(getName());
            EEInstancesManager eeInstancesManager =
                new EEInstancesManager(instanceConfig);
           
            if (isTimeBound) {
                boolean stopped = false;
               
                if(timeout > 0)
                    stopped = eeInstancesManager.stopInstanceWithinTime(timeout);
               
                if (!stopped) eeInstancesManager.killRelatedProcesses();
            } else {
                eeInstancesManager.stopInstance("true");
            }
           
            if (bDebug) System.out.println("\nCurrently Running:" +
                                    ProcessManager.getInstance().toString());
        } catch (Exception e) {
View Full Code Here

    public RuntimeStatus getRuntimeStatus() throws InstanceException
    {       
        String serverName =
            System.getProperty(SystemPropertyConstants.SERVER_NAME);
        EEInstancesManager manager = new EEInstancesManager(new RepositoryConfig());
        return RuntimeStatus.getRuntimeStatus(serverName, manager);       
    }
View Full Code Here

                    break;
                case NA:   
                    new AgentManager((AgentConfig)config).stopInstance("true");
                    break;
                case INSTANCE:
                    new EEInstancesManager(config).stopInstance("true");
                    break;
            }
        }
        catch(Exception e)
        {
View Full Code Here

TOP

Related Classes of com.sun.enterprise.ee.admin.servermgmt.EEInstancesManager

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.