Package com.sun.enterprise.deployment.backend

Examples of com.sun.enterprise.deployment.backend.DeploymentStatus


        try {
            SunTarget[] targetObjs = (SunTarget[]) targetList.toArray(new SunTarget[targetList.size()]);
            for(int i=0; i<targetObjs.length; i++) {
                int state = ((Integer)targetState.get(targetObjs[i].getName())).intValue();
                if(state == APP_STARTED) {
                    DeploymentStatus status =
                        DeploymentClientUtils.stopApplication(
                            dasConnection.getExistingMBeanServerConnection(),
                            moduleID, targetObjs[i], tmpOptions);
                    rollbackStatus.addSubStage(status);
                    if (status!=null && status.getStatus() < DeploymentStatus.WARNING) {
                        return false;
                    }
                    targetState.put(targetObjs[i].getName(), new Integer(APP_REF_CREATED));
                }
            }
View Full Code Here


        try {
            SunTarget[] targetObjs = (SunTarget[]) targetList.toArray(new SunTarget[targetList.size()]);
            for(int i=0; i<targetObjs.length; i++) {
                int state = ((Integer)targetState.get(targetObjs[i].getName())).intValue();
                if(state == APP_REF_DELETED) {
                    DeploymentStatus status =
                        DeploymentClientUtils.createApplicationReference(
                            dasConnection.getExistingMBeanServerConnection(),
                            moduleID, targetObjs[i], options);
                    rollbackStatus.addSubStage(status);
                    if (status!=null && status.getStatus() < DeploymentStatus.WARNING) {
                        return false;
                    }
                    targetState.put(targetObjs[i].getName(), new Integer(APP_STOPPED));
                }
            }
View Full Code Here

        try {
            SunTarget[] targetObjs = (SunTarget[]) targetList.toArray(new SunTarget[targetList.size()]);
            for(int i=0; i<targetObjs.length; i++) {
                int state = ((Integer)targetState.get(targetObjs[i].getName())).intValue();
                if(state == APP_STOPPED) {
                    DeploymentStatus status =
                        DeploymentClientUtils.startApplication(
                            dasConnection.getExistingMBeanServerConnection(),
                            moduleID, targetObjs[i], options);
                    rollbackStatus.addSubStage(status);
                    // We don't check the start return because we can't do anything if the instance is down
View Full Code Here

        // the target module ids in which the operation was successful
        ArrayList resultTargetModuleIDs = new ArrayList();            

        for(int i=0; i<targets.length; i++) {
            DeploymentStatus stat = new DeploymentStatus();
            stat.setStageDescription(
                localStrings.getString("enterprise.deployment.client.state_change_desc", action, moduleID));
            try {
                /*
                 *If the module type supports state changes, change the state.
                 *Otherwise prepare a warning status with a "no-op" message.
                 */
                String messageKey;
                int deplStatus;
                if (! unchangeableStateModuleTypes.contains(moduleType)) {
                    messageKey = "enterprise.deployment.client.state_change_success";
                    deplStatus = DeploymentStatus.SUCCESS;
                   
                    DeploymentClientUtils.changeStateOfModule(dasConnection.getExistingMBeanServerConnection(), moduleID,
                                    ((moduleType == null) ? null : moduleType.toString()), targets[i], state);
                } else {
                    messageKey = "enterprise.deployment.client.state_change_noop";
                    deplStatus = DeploymentStatus.SUCCESS;
                }
                stat.setStageStatus(deplStatus);
                stat.setStageStatusMessage(localStrings.getString(messageKey, action, moduleID));
            } catch (Throwable ex) {
                String msg;
                if (CommandType.START.equals(newState)) {
                    msg = localStrings.getString(
                        "enterprise.deployment.client.start.failed");
                } else {
                    msg = localStrings.getString(
                        "enterprise.deployment.client.stop.failed");
                }
                stat.setStageException(ex);
                stat.setStageStatus(DeploymentStatus.FAILURE);
                stat.setStageStatusMessage(msg + ex.getMessage());
            }
            if(!checkStatusAndAddStage(targets[i], null,
                            localStrings.getString("enterprise.deployment.client.change_state", action, moduleID, targets[i].getName()), dasConnection, stat, state)) {
                return;
            }
View Full Code Here

                       
                        DeploymentClientUtils.setResourceOptions(
                            options,
                            DeploymentProperties.RES_UNDEPLOYMENT,
                            targetList[i].getName());
                        DeploymentStatus stat =
                            DeploymentClientUtils.stopApplication(
                                dasConnection.getExistingMBeanServerConnection(),
                                moduleID, targetList[i], options);
                        if (!checkStatusAndAddStage(targetList[i], null, localStrings.getString("enterprise.deployment.client.redeploy_stop", targetList[i].getName()) , dasConnection, stat)) {
                            return;
                        }
                       
                        // del-app-ref from all targets
                        options.put(DeploymentProperties.DEPLOY_OPTION_CASCADE_KEY, "false");
                        // set enable flag of options as per state of the app
                        // before redeploy
                        options.put(DeploymentProperties.DEPLOY_OPTION_ENABLE_KEY, deployedTargets.get(targetList[i].getName()).toString());
                        stat = DeploymentClientUtils.deleteApplicationReference(
                                dasConnection.getExistingMBeanServerConnection(),
                                moduleID, targetList[i], options);
                        if(!checkStatusAndAddStage(targetList[i], undeplRollback, localStrings.getString("enterprise.deployment.client.redeploy_remove_ref", targetList[i].getName()), dasConnection, stat)) {
                            return;
                        }
                        undeplRollback.addTarget(targetList[i], RollBackAction.APP_REF_DELETED);
                    }
                }
            }

            // Get a deploy ID
            deployActionID = deplMgr.initDeploy();
           
            // Make a copy of deployOptions and set the ENABLE flag in this copy to true
            // This is so that the enabled flag during deploy-to-domain is always true
            // This might need to be replaced with an efficient logic to look up the current enabled flag
            // using AMX
            Map dupOptions = new HashMap();
            dupOptions.putAll(deployOptions);
            dupOptions.put(DeploymentProperties.DEPLOY_OPTION_ENABLE_KEY, Boolean.TRUE.toString());
            dupOptions.put(DeploymentProperties.REDEPLOY, Boolean.toString(isModuleDeployed));
    
            // if deploy to "domain" or redeploy to "domain" with no
            // existing application-ref
            if ((TargetType.DOMAIN.equals(targetList[0].getName()))) {
                if (isRedeploy) {
                    DeploymentClientUtils.setResourceOptions(
                        dupOptions,
                        DeploymentProperties.RES_REDEPLOYMENT,
                        targetList);
                } else {
                    DeploymentClientUtils.setResourceOptions(
                        dupOptions,
                        DeploymentProperties.RES_DEPLOYMENT,
                        targetList);
                }
            } else {
                DeploymentClientUtils.setResourceOptions(
                    dupOptions,
                    DeploymentProperties.RES_NO_OP,
                    targetList);
            }
           
            // Now start a fresh deploy in domain
            // upload file only if this not a directory deploy AND it is not a local connection source (not from gui)
           
            String uploadProp = (String) deployOptions.get(DeploymentProperties.UPLOAD);
            boolean upload = new Boolean((uploadProp != null) ? uploadProp : DeploymentProperties.DEFAULT_UPLOAD).booleanValue();
            if(!isDirectoryDeploy && !isLocalConnectionSource && upload) {
                // upload the archive

                long startTime = System.currentTimeMillis();
                long endTime = startTime;

                // we use jmx upload for following scenarios:
                // 1. for secure connection: https
                // 2. if the JMX_UPLOAD_CHUNK_SIZE system property is set
                // 3. if the HTTP_PROXYHOST system property is set
          if ( serverId.isSecure() ||
                     (jmxUploadChunkSizeProp != null &&
                      jmxUploadChunkSizeProp.length() > 0) ||
                     (httpProxyHostProp != null &&
                      httpProxyHostProp.length() > 0) ){
                    // using jmx
                    archiveUploadID = uploadArchive(deployArchive);
                   
                    // If there is a plan, upload the plan
                    if (deployPlan != null){
                        if (deployPlan.getURI()!=null) {
                            File f = new File(deployPlan.getURI().getPath());
                            if (f.length()!= 0) {
                                planUploadID = uploadArchive(deployPlan);
                            }
                        }
                    }

                    endTime = System.currentTimeMillis();

                    // Call DeploymentMgr to start deploy
                    deplMgr.startDeploy(deployActionID, archiveUploadID, planUploadID, dupOptions);
                } else {
                    // using http
                    String archivePath = uploadArchiveOverHTTP(serverId,
                        deployArchive);
                    DeploymentSourceImpl archiveSource =
                        new DeploymentSourceImpl(archivePath, true,
                            new String[1], new String[1], new String[1],
                            new HashMap());

                    String planPath = null;
                    DeploymentSourceImpl planSource = null;

                    // If there is a plan, upload the plan
                    if (deployPlan != null){
                        if (deployPlan.getURI()!=null){
                            File f = new File(deployPlan.getURI().getPath());
                            if (f.length()!= 0) {
                                planPath = uploadArchiveOverHTTP(serverId, deployPlan);
                                planSource =
                                    new DeploymentSourceImpl(planPath, true,
                                    new String[1], new String[1], new String[1],
                                    new HashMap());
                            }
                        }
                    }

                    endTime = System.currentTimeMillis();

                    deplMgr.startDeploy(deployActionID, archiveSource.asMap(),
                        planSource == null ? null : planSource.asMap(),
                        dupOptions);
                }
                _logger.log(Level.FINE,
                    "time in upload: " + (endTime-startTime));
            } else {
                // Directory deploy is supported only on DAS - check that here
                if((isDirectoryDeploy) && (!isDomainLocal(domain))) {
                    setupForAbnormalExit(localStrings.getString("enterprise.deployment.client.domainNotLocal"),
                        domain);
                    return;                   
                }
                DeploymentSourceImpl archive = new DeploymentSourceImpl(deployArchive.getURI().getPath(), true,
                                                    new String[1], new String[1], new String[1], new HashMap());
                // we do not support deployment plan for directory deployment
                // currently
                deplMgr.startDeploy(deployActionID, archive.asMap(), null, dupOptions);
            }

            // if deployActionID is still null, then there is some failure - report this and die
            if(deployActionID == null) {
                setupForAbnormalExit(localStrings.getString("enterprise.deployment.client.no_deployment_id"), domain);
                return;
            }

            // Wait till deploy is over
            boolean done = false;
            int waitLoopCount = 0;
            com.sun.appserv.management.deploy.DeploymentStatus finalStatusFromMBean = null;
            do {
                Notification[] notifs = deplMgr.takeNotifications(deployActionID);
                for(int i=0; i<notifs.length; i++) {
                    Map notifType = (Map) notifs[i].getUserData();
                    if(notifType.get(deplMgr.NOTIF_DEPLOYMENT_COMPLETED_STATUS_KEY) != null) {
                        finalStatusFromMBean =
                            DeploymentSupport.mapToDeploymentStatus((Map)deplMgr.getFinalDeploymentStatus(deployActionID));
                        done = true;
                    } else if(notifType.get(deplMgr.NOTIF_DEPLOYMENT_PROGRESS_KEY) != null) {
                        DeploymentProgress prog = DeploymentSupport.mapToDeploymentProgress((Map)notifType.get(deplMgr.NOTIF_DEPLOYMENT_PROGRESS_KEY));
                        String progStr = prog.getDescription() + " : " + prog.getProgressPercent() + "%";
                        fireProgressEvent(StateType.RUNNING, progStr, domain);
                    }
                }
                if(!done) {
                    if(waitLoopCount > TIMEOUT_LOOPS) {
                        setupForAbnormalExit(localStrings.getString("enterprise.deployment.client.deployment_time_out"), domain);
                        return;
                    }
                    try {
                        Thread.sleep(SLEEP_TIME);
                    } catch(InterruptedException e) {
                        //Swallowing this exception deliberately; we dont want to do anything but wait
                    }
                }
                waitLoopCount++;
            } while(!done);

            DeploymentStatus tmp = DeploymentClientUtils.getDeploymentStatusFromAdminStatus(finalStatusFromMBean);

            if(!checkStatusAndAddStage(
                domain, null,
                localStrings.getString("enterprise.deployment.client.deploy_in_domain"),
                dasConnection, tmp)) {
                return;
            }

            //Take the one returned from the server
            if (moduleID == null) {
                moduleID = tmp.getProperty(DeploymentStatus.MODULE_ID);
            }

            String key = moduleID + DeploymentStatus.KEY_SEPARATOR +
                                                  DeploymentStatus.MODULE_TYPE;
            String xKey = moduleID + DeploymentStatus.KEY_SEPARATOR +
                                                  DeploymentStatus.XMODULE_TYPE;
            this.moduleType =
                        DeploymentClientUtils.getXModuleType(tmp, key, xKey);

            // Start keeping track of actions to be rolled back
            RollBackAction rollback = new RollBackAction(RollBackAction.DEPLOY_OPERATION, moduleID, deployOptions);

            // Deploy is done; create app ref if target[0] was not a domain
            if(!(TargetType.DOMAIN.equals(targetList[0].getName()))) {
                for(int i=0; i<targetList.length; i++) {
                   
                    // If this is a redeploy, set enable flag of options as per state of the app before redeploy
                    if(deployedTargets != null) {
                        dupOptions.put(DeploymentProperties.DEPLOY_OPTION_ENABLE_KEY, deployedTargets.get(targetList[i].getName()).toString());
                    } else {
                        dupOptions.put(DeploymentProperties.DEPLOY_OPTION_ENABLE_KEY, deployOptions.get(DeploymentProperties.DEPLOY_OPTION_ENABLE_KEY));
                    }
                    DeploymentStatus stat =
                        DeploymentClientUtils.createApplicationReference(
                            dasConnection.getExistingMBeanServerConnection(),
                            moduleID, targetList[i], dupOptions);
                    if(!checkStatusAndAddStage(targetList[i], rollback,
                       localStrings.getString("enterprise.deployment.client.deploy_create_ref", targetList[i].getName()), dasConnection, stat)) {
                        return;
                    }
                    rollback.addTarget(targetList[i], rollback.APP_REF_CREATED);

                    /*
                      XXX Start the application regardless the value of "enable"
                      Otherwise no DeployEvent would be sent to the listeners on
                      a remote instance, which would in turn synchronize the app
                      bits.  Note that the synchronization is only called during
                      applicationDeployed, not applicationEnabled.  To make sure
                      the deployment code can work with both the new and the old
                      mbeans, we will call the start for now (as the old mbeans
                      would do).  The backend listeners are already enhanced to
                      make sure the apps are not actually loaded unless the enable
                      attributes are true for both the application and
                      application-ref elements.
                    */
                   
                    // We dont rollback for start failure because start failure may be because of server being down
                    // We just add DeploymentStatus of this phase to the complete DeploymentStatus
                   
                    if (isRedeploy) {
                        DeploymentClientUtils.setResourceOptions(
                            deployOptions,
                            DeploymentProperties.RES_REDEPLOYMENT,
                            targetList[i].getName());
                    } else {
                        DeploymentClientUtils.setResourceOptions(
                            deployOptions,
                            DeploymentProperties.RES_DEPLOYMENT,
                            targetList[i].getName());
                    }

                    stat = DeploymentClientUtils.startApplication(
                            dasConnection.getExistingMBeanServerConnection(),
                            moduleID, targetList[i], deployOptions);
                    checkStatusAndAddStage(targetList[i], null,
                        localStrings.getString("enterprise.deployment.client.deploy_start", targetList[i].getName()), dasConnection, stat, true);
                }
            }

            // Do WSDL publishing only if the caller is not GUI
            if ( !isLocalConnectionSource ) {
                try {
                    DeploymentClientUtils.doWsdlFilePublishing(tmp, dasConnection);
                } catch (Exception wsdlEx) {
                    DeploymentStatus newStatus = new DeploymentStatus();
                    newStatus.setStageStatus(DeploymentStatus.FAILURE);
                    newStatus.setStageStatusMessage(wsdlEx.getMessage());
                    newStatus.setStageException(wsdlEx);
                    checkStatusAndAddStage(domain, rollback,
                        localStrings.getString("enterprise.deployment.client.deploy_publish_wsdl"), dasConnection, newStatus);
                    String msg =  localStrings.getString("enterprise.deployment.client.deploy_publish_wsdl_exception", wsdlEx.getMessage());
                    setupForAbnormalExit(msg, domain);
                    return;
View Full Code Here

     * this progress object.
     * @param the progress object to wait for completion
     * @return the deployment status
     */
    public DeploymentStatus waitFor(JESProgressObject po) {
        DeploymentStatus status = null;
        do {
            try {
                Thread.currentThread().sleep(100);
            } catch (InterruptedException ie) {
                // Exception swallowed deliberately
View Full Code Here

        String action = (CommandType.DISTRIBUTE.equals(cmd)) ? "Creation" : "Removal";


        try {
            for(int i=0; i<targetList.length; i++) {
                DeploymentStatus stat = null;
                if(CommandType.DISTRIBUTE.equals(cmd)) {
                    stat = DeploymentClientUtils.createLifecycleModuleReference(
                        dasConnection.getExistingMBeanServerConnection(), id, targetList[i].getName(), options);
                } else {
                    stat = DeploymentClientUtils.removeLifecycleModuleReference(
View Full Code Here

                rollback = new RollBackAction(RollBackAction.DELETE_APP_REF_OPERATION, moduleID, deployOptions);
            }

            for(int i=0; i<targetList.length; i++) {
                if(CommandType.DISTRIBUTE.equals(cmd)) {
                    DeploymentStatus stat = 
                        DeploymentClientUtils.createApplicationReference(
                            dasConnection.getExistingMBeanServerConnection(),
                            moduleID, targetList[i], deployOptions);
                    if(!checkStatusAndAddStage(targetList[i], rollback,
                                    localStrings.getString("enterprise.deployment.client.create_reference", targetList[i].getName()), dasConnection, stat)) {
                        return;
                    }
                    rollback.addTarget(targetList[i], RollBackAction.APP_REF_CREATED);
                   
                    /*
                      XXX Start the application regardless the value of "enable"
                      Otherwise no DeployEvent would be sent to the listeners on
                      a remote instance, which would in turn synchronize the app
                      bits.  Note that the synchronization is only called during
                      applicationDeployed, not applicationEnabled.  To make sure
                      the deployment code can work with both the new and the old
                      mbeans, we will call the start for now (as the old mbeans
                      would do).  The backend listeners are already enhanced to
                      make sure the apps are not actually loaded unless the enable
                      attributes are true for both the application and
                      application-ref elements.
                    */
                    DeploymentClientUtils.setResourceOptions(
                        deployOptions,
                        DeploymentProperties.RES_CREATE_REF,
                        targetList[i].getName());
                    stat = DeploymentClientUtils.startApplication(
                            dasConnection.getExistingMBeanServerConnection(),
                            moduleID, targetList[i], deployOptions);
                   
                    // We dont rollback for start failure because start failure may be because of server being down
                    // We just add DeploymentStatus of this phase to the complete DeploymentStatus
                   
                    checkStatusAndAddStage(targetList[i], null,
                        localStrings.getString("enterprise.deployment.client.reference_start", targetList[i].getName()), dasConnection, stat, true);

                } else {
                    deployOptions.put(DeploymentProperties.DEPLOY_OPTION_FORCE_KEY, "false");
                   
                    // We dont rollback for stop failure because the failure may be because of server being down
                    // We just add DeploymentStatus of this phase to the complete DeploymentStatus
                   
                    DeploymentClientUtils.setResourceOptions(
                        deployOptions,
                        DeploymentProperties.RES_DELETE_REF,
                        targetList[i].getName());
                    DeploymentStatus stat =
                        DeploymentClientUtils.stopApplication(
                            dasConnection.getExistingMBeanServerConnection(),
                            moduleID, targetList[i], deployOptions);
                    if (!checkStatusAndAddStage(targetList[i], null,
                                  localStrings.getString("enterprise.deployment.client.reference_stop", targetList[i].getName()), dasConnection, stat)) {
View Full Code Here

                   
                    DeploymentClientUtils.setResourceOptions(
                        deployOptions,
                        DeploymentProperties.RES_UNDEPLOYMENT,
                        targetList[i].getName());
                    DeploymentStatus stat =  DeploymentClientUtils.stopApplication(
                        dasConnection.getExistingMBeanServerConnection(),
                        moduleID, targetList[i], deployOptions);
                    if (!checkStatusAndAddStage(targetList[i], null,
                                localStrings.getString("enterprise.deployment.client.undeploy_stop", targetList[i].getName()), dasConnection, stat)) {
                        return;
                    }
                   
                    stat = DeploymentClientUtils.deleteApplicationReference(
                        dasConnection.getExistingMBeanServerConnection(),
                        moduleID, targetList[i], deployOptions);
                    if(!checkStatusAndAddStage(targetList[i], rollback,
                                localStrings.getString("enterprise.deployment.client.undeploy_remove_ref", targetList[i].getName()), dasConnection, stat)) {
                        return;
                    }
                    rollback.addTarget(targetList[i], RollBackAction.APP_REF_DELETED);
                    resultTargetModuleIDs.add(new SunTargetModuleID(moduleID, targetList[i]));
                }
            }
           
            // if undeploy from "domain" with no existing application-ref
            if ((TargetType.DOMAIN.equals(targetList[0].getName()))) {
                DeploymentClientUtils.setResourceOptions(
                    deployOptions,
                    DeploymentProperties.RES_UNDEPLOYMENT,
                    targetList);
            } else {
                DeploymentClientUtils.setResourceOptions(
                    deployOptions,
                    DeploymentProperties.RES_NO_OP,
                    targetList);
            }
            // Call DeploymentMgr to start undeploy
            fireProgressEvent(StateType.RUNNING, localStrings.getString("enterprise.deployment.client.undeploying"), domain);
            Map undeployStatus = deplMgr.undeploy(moduleID, deployOptions);           
           
            com.sun.appserv.management.deploy.DeploymentStatus finalStatusFromMBean =
                            DeploymentSupport.mapToDeploymentStatus(undeployStatus);
            DeploymentStatus tmp = DeploymentClientUtils.getDeploymentStatusFromAdminStatus(finalStatusFromMBean);
            if(!checkStatusAndAddStage(domain, null, localStrings.getString("enterprise.deployment.client.undeploy_from_domain"), dasConnection, tmp)) {
                return;
            }
           
            // undeploy over - add this to the result target module ID
View Full Code Here

        return deployedTargets;
    }   
   
    public static DeploymentStatus
                getDeploymentStatusFromAdminStatus(com.sun.appserv.management.deploy.DeploymentStatus stat) {
        DeploymentStatus tmp = new DeploymentStatus();
        tmp.setStageStatus(stat.getStageStatus());
        if(stat.getThrowable() != null) {
            tmp.setStageException(stat.getThrowable());
        }
        tmp.setStageDescription(stat.getStageDescription());
        tmp.setStageStatusMessage(stat.getStageStatusMessage());
        Iterator it = stat.getSubStages();
        while(it.hasNext()) {
            com.sun.appserv.management.deploy.DeploymentStatus stageStatus =
                            DeploymentSupport.mapToDeploymentStatus((Map)it.next());
            tmp.addSubStage(getDeploymentStatusFromAdminStatus(stageStatus));
        }

        if (stat.getAdditionalStatus() != null) {
            it = stat.getAdditionalStatus().entrySet().iterator();
            while (it.hasNext()) {
                Map.Entry entry = (Map.Entry) it.next();
                tmp.addProperty((String)entry.getKey(), (String)entry.getValue());
            }
        }
        return tmp;
    }   
View Full Code Here

TOP

Related Classes of com.sun.enterprise.deployment.backend.DeploymentStatus

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.