⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 staxprocessaction.java

📁 Software Testing Automation Framework (STAF)的开发代码
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
                for (int i = 0; i < fReturnFiles.size(); i++)        {            result.append(";ReturnFile").append(i + 1).append(":").                append((String)fReturnFiles.elementAt(i));        }        if (!fOther.equals(""))            result.append(";Other:").append(fOther);        result.append(";HoldThreadCondition:").append(fHoldCondition).            append(";RequestNumber:").append(fRequestNumber).            append(";RequestRC:").append(fRequestRC).            append(";Request:").append(fRequest).            append(";RequestResult:").append(fRequestResult).            append(";ProcessHandle:").append(fProcessHandle).            append(";ProcessRC:").append(fProcessRC).            append(";ProcessTimestamp:").append(fProcessTimestamp).            append(";StartTimestamp:").append(fStartTimestamp).            append(";BlockName:").append(fCurrentBlockName);        return result.toString();    }    public void execute(STAXThread thread)    {        synchronized (this)        {            if (fState == INIT)            {                            fThread = thread;                 // Evaluate the process element and attribute values and                // generate a process start request and assign to fRequest.                if (generateProcessStartRequest() != 0) return;                            // Set current block name                try                {                    fCurrentBlockName = fThread.pyStringEval(                        "STAXCurrentBlock");                }                catch (STAXPythonEvaluationException e)                {                    fCurrentBlockName = "";  //Shouldn't happen                }                // Set to the current date and time.                fStartTimestamp = new STAXTimestamp();                         fState = WAIT_REQUEST;                                fProcessKey = new Integer(                    fThread.getJob().getNextProcessKey()).toString();                                // Submit PROCESS START STAF Command                STAFResult submitResult = fThread.getJob().submitAsync(                    fLocation, "process", "START NOTIFY ONEND KEY " +                    fProcessKey + " " + fRequest, this);                                    if (submitResult.rc == 0 )                {                    fRequestNumber = (new Integer(submitResult.result)).                                                  intValue();                }                                if (fRequestNumber == 0)                {                    // Request failed - Raise a STAXProcessStartError signal                    fState = COMPLETE;                    fThread.popAction();                                        String msg = "<process>\n" +                        "\n  Name      : " + fName +                        "\n  Location  : " + fLocation +                        "\n  Service   : " + "PROCESS" +                        "\n  Request   : " + "START " + fRequest +                        "\n  RC        : " + submitResult.rc +                        "\n  STAFResult: " + submitResult.result;                    fThread.setSignalMsgVar("STAXProcessStartErrorMsg", msg);                    fThread.raiseSignal("STAXProcessStartError");                                        return;                        }                                if (debug)                {                    System.out.println("STAXProcessAction::execute(): " +                        "Add timed event - timeout=" +                        fThread.getJob().getSTAX().getProcessTimeout());                }                            // Add a TimedEvent to the queue and return                 fTimedEvent = new STAXTimedEvent(System.currentTimeMillis() +                     fThread.getJob().getSTAX().getProcessTimeout(), this);                fThread.getJob().getSTAX().getTimedEventQueue().addTimedEvent(                    fTimedEvent);                fThread.addCondition(fHoldCondition);            }            else if (fState == REQUEST_ERROR)            {                fState = COMPLETE;                fThread.popAction();                if (debug)                {                    System.out.println("STAXProcessAction::execute(): " +                        "fState=REQUEST_ERROR - Raise STAXProcessStartError" +                        " signal");                }                String msg = "<process>\n" +                    "\n  Name      : " + fName +                    "\n  Location  : " + fLocation +                    "\n  Service   : " + "PROCESS" +                    "\n  Request   : " + "START " + fRequest +                    "\n  RC        : " + fRequestRC +                    "\n  STAFResult: " + fRequestResult;                fThread.setSignalMsgVar("STAXProcessStartErrorMsg", msg);                fThread.raiseSignal("STAXProcessStartError");            }            else if (fState == REQUEST_TIMEOUT)            {                // The process request did not start within the timeout,                // PROCESSTIMEOUT, (requestComplete was not called) so                // generate a STAXProcessStartTimeout signal                fState = COMPLETE;                fThread.popAction();                         if (debug)                {                    System.out.println("STAXProcessAction::execute(): " +                                       "fState=REQUEST_TIMEOUT - Raise " +                                        "STAXProcessStartTimeout signal");                }                String timeoutMsg = "Process did not start within timeout " +                    "value " + fThread.getJob().getSTAX().getProcessTimeout();                String msg = "<process>\n" +                    "\n  Name      : " + fName +                    "\n  Location  : " + fLocation +                    "\n  Service   : " + "PROCESS" +                    "\n  Request   : " + "START " + fRequest +                    "\n  RC        : " + STAFResult.Timeout +                    "\n  STAFResult: " + timeoutMsg;                fThread.setSignalMsgVar("STAXProcessStartTimeoutMsg", msg);                fThread.raiseSignal("STAXProcessStartTimeout");                // Set RC and STAFResult to indicate a STAXProcessStartTimeout                // signal                fRequestRC = STAFResult.Timeout;                fThread.pySetVar("RC", new Integer(STAFResult.Timeout));                fThread.pySetVar("STAFResult", timeoutMsg);            }            else if (fState == PROCESS_COMPLETE)            {                fState = COMPLETE;                fThread.popAction();            }            else if (fState == COMPLETE)            {                // Note: We shouldn't be called in this state.                fThread.popAction();            }        }  // End synchronized (this)    }    // Note that this entire method is synchronized    public synchronized void handleCondition(STAXThread thread,         STAXCondition cond)    {        synchronized (this)        {            if (debug)            {                System.out.println("STAXProcessAction::handleCondition(): " +                                   "fState=" + getStateAsString());            }                            if ((fState == WAIT_PROCESS) ||                 (fState == PROCESS_COMPLETE_WAIT_ACTION))            {                // Set this first, in case message comes in before setting                // state below                fState = COMPLETE;                if (debug)                {                    System.out.println(                        "STAXProcessAction::handleCondition(): " +                        "removeHoldCondition and stop handle");                }                thread.removeCondition(fHoldCondition);                            thread.getJob().submitAsyncForget(fLocation, "process",                    "stop handle " + fProcessHandle);                // Generate a stop process event                generateProcessStopEvent();                // Remove the process from the processRequestMap                 String key = fLocation + ":" + fProcessHandle;                TreeMap processes = (TreeMap)thread.getJob().                                        getData("processRequestMap");                synchronized (processes)                {                    processes.remove(key.toLowerCase());                }            }            fState = COMPLETE;            thread.popAction();        }    }    public STAXAction cloneAction()    {        STAXProcessAction clone = new STAXProcessAction();                clone.fUnevalLocation = fUnevalLocation;        clone.fUnevalCommand = fUnevalCommand;        clone.fUnevalName = fUnevalName;        clone.fUnevalWorkload = fUnevalWorkload;        clone.fUnevalWorkdir = fUnevalWorkdir;        clone.fUnevalTitle = fUnevalTitle;        clone.fUnevalParms = fUnevalParms;        clone.fUnevalWorkdir = fUnevalWorkdir;        clone.fUnevalVars = fUnevalVars;        clone.fUnevalEnvs = fUnevalEnvs;        clone.fUnevalUseprocessvars = fUnevalUseprocessvars;        clone.fUnevalStopusing = fUnevalStopusing;        clone.fUnevalConsole = fUnevalConsole;        clone.fUnevalFocus = fUnevalFocus;        clone.fUnevalUsername = fUnevalUsername;        clone.fUnevalPassword = fUnevalPassword;        clone.fUnevalDisabledauth = fUnevalDisabledauth;        clone.fUnevalStatichandlename = fUnevalStatichandlename;        clone.fUnevalStdin = fUnevalStdin;        clone.fUnevalStdout = fUnevalStdout;        clone.fUnevalStdoutMode = fUnevalStdoutMode;        clone.fUnevalStderr = fUnevalStderr;        clone.fUnevalStderrMode = fUnevalStderrMode;        clone.fUnevalReturnStdout = fUnevalReturnStdout;        clone.fUnevalReturnStderr = fUnevalReturnStderr;        clone.fUnevalReturnFiles = fUnevalReturnFiles;        clone.fUnevalOther = fUnevalOther;        clone.fUnevalCommandMode = fUnevalCommandMode;        clone.fUnevalCommandShell = fUnevalCommandShell;        clone.fCurrentBlockName = fCurrentBlockName;        clone.fFactory = fFactory;        clone.fLocation = fLocation;        clone.fCommand = fCommand;        clone.fName = fName;        clone.fWorkload = fWorkload;        clone.fWorkloadIf = fWorkloadIf;        clone.fWorkdir = fWorkdir;        clone.fWorkdirIf = fWorkdirIf;        clone.fTitle = fTitle;        clone.fTitleIf = fTitleIf;        clone.fParms = fParms;        clone.fParmsIf = fParmsIf;        clone.fVars = new Vector();        clone.fVarsIf = fVarsIf;        clone.fEnvs = new Vector();        clone.fEnvsIf = fEnvsIf;        clone.fUseprocessvars = fUseprocessvars;        clone.fUseprocessvarsIf = fUseprocessvarsIf;        clone.fStopusing = fStopusing;        clone.fStopusingIf = fStopusingIf;        clone.fConsole = fConsole;        clone.fConsoleIf = fConsoleIf;        clone.fFocus = fFocus;        clone.fFocusIf = fFocusIf;        clone.fUsername = fUsername;        clone.fUsernameIf = fUsernameIf;        clone.fPassword = fPassword;        clone.fPasswordIf = fPasswordIf;        clone.fDisabledauth = fDisabledauth;        clone.fDisabledauthIf = fDisabledauthIf;        clone.fStatichandlename = fStatichandlename;        clone.fStatichandlenameIf = fStatichandlenameIf;        clone.fStdin = fStdin;        clone.fStdinIf = fStdinIf;        clone.fStdout = fStdout;        clone.fStdoutIf = fStdoutIf;        clone.fStdoutMode = fStdoutMode;        clone.fStderr = fStderr;        clone.fStderrIf = fStderrIf;        clone.fStderrMode = fStderrMode;        clone.fReturnStdout = fReturnStdout;        clone.fReturnStdoutIf = fReturnStdoutIf;        clone.fReturnStderr = fReturnStderr;        clone.fReturnStderrIf = fReturnStderrIf;        clone.fReturnFiles = new Vector();        clone.fReturnFilesIf = fReturnFilesIf;        clone.fOther = fOther;        clone.fOtherIf = fOtherIf;        clone.fProcessAction = fProcessAction;        clone.fProcessActionIf = fProcessActionIf;        clone.fCommandMode = fCommandMode;        clone.fCommandShell = fCommandShell;               return clone;    }    // STAXTimedEventListener method    // Note that this entire method is synchronized    public synchronized void timedEventOccurred(STAXTimedEvent timedEvent)    {        if (debug)        {            System.out.println(                "STAXProcessAction::timedEventOccurred(): fState=" +                getStateAsString());        }                    if (fState == WAIT_REQUEST)        {            if (debug)            {                System.out.println(                    "STAXProcessAction::timedEventOccurred(): Set " +                    "fState=REQUEST_TIMEOUT, remove holdCondition, " +                    "and schedule thread");            }                                                                 fState = REQUEST_TIMEOUT;            fThread.removeCondition(fHoldCondition);            fThread.schedule();        }    }    // STAXSTAFRequestCompleteListener method    // Note that this entire method is synchronized    public synchronized void requestComplete(int requestNumber,        STAFResult result)    {        // Already COMPLETE, so something like a STAXProcessRequestTimeout        // signal could have already been raised, so just return        if (fState == COMPLETE) return;        // Remove request timeout event         if (debug)        {            System.out.println("STAXProcessAction::requestComplete(): " +                               "removeTimedEvent()");        }        fThread.getJob().getSTAX().getTimedEventQueue().removeTimedEvent(            fTimedEvent);        fThread.pySetVar("RC", new Integer(result.rc));        

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -