📄 staxjobactionfactory.java
字号:
if (factory == null) { throw new STAXInvalidXMLElementException( jobActionChild.getNodeName()); } jobAction = factory.parseAction( staxService, job, jobActionChild); } } subjob.setJobAction(jobAction, ifValue); } } else { throw new STAXInvalidXMLNodeTypeException( Integer.toString(thisChild.getNodeType())); } } return subjob; } private String handleChild(Node root) throws STAXException { NodeList children = root.getChildNodes(); for (int i = 0; i < children.getLength(); ++i) { Node thisChild = children.item(i); // XXX: Should I be able to have a COMMENT_NODE here? if (thisChild.getNodeType() == Node.COMMENT_NODE) { /* Do nothing */ } else if (thisChild.getNodeType() == Node.TEXT_NODE) { boolean compileFlag = true; if (!root.getNodeName().equals("job-data")) { String errorInfo = "\n Element: " + root.getNodeName(); return STAXUtil.parseAndCompileForPython( thisChild.getNodeValue(), errorInfo); } else { // Call the parseForPython method for this element instead // of parseAndCompileForPython to remove the leading // whitespace but don't compile the value. This is // because it has an "eval" attribute which if set to // false means don't evaluate it via Python in the parent // job as its value may be XML, not a Python string. return STAXUtil.parseForPython( thisChild.getNodeValue()); } } else if (thisChild.getNodeType() == Node.CDATA_SECTION_NODE) { /* Do nothing */ } else { throw new STAXInvalidXMLNodeTypeException( Integer.toString(thisChild.getNodeType())); } } return new String(); } // STAXJobManagement methods public void initJob(STAXJob job) { boolean result = job.setData("subJobMap", new TreeMap()); if (!result) { String msg = "STAXJobActionFactory.initJob: setData for " + "subJobMap failed."; job.log(STAXJob.JOB_LOG, "error", msg); } } public void terminateJob(STAXJob job) { // Remove from map of currently executing sub-jobs TreeMap subJobs = (TreeMap)job.getData("subJobMap"); synchronized (subJobs) { subJobs.remove(String.valueOf(job.getJobNumber())); } } // STAXListRequestHandler method public STAFResult handleListRequest(String type, STAXJob job, STAXRequestSettings settings) { if (type.equalsIgnoreCase("subjobs")) { // LIST JOB <Job ID> SUBJOBS // Create the marshalling context and set its map class definitions // and create an empty list to contain the block map entries STAFMarshallingContext mc = new STAFMarshallingContext(); mc.setMapClassDefinition(fSubjobInfoMapClass); List subjobOutputList = new ArrayList(); // Iterate through the subjob map, generating the output list TreeMap subjobs = (TreeMap)job.getData("subJobMap"); synchronized (subjobs) { Iterator iter = subjobs.values().iterator(); while (iter.hasNext()) { STAXJobAction subjob = (STAXJobAction)iter.next(); Map subjobMap = fSubjobInfoMapClass.createInstance(); if (!subjob.getName().equals("")) subjobMap.put("jobName", subjob.getName()); subjobMap.put("jobID", "" + subjob.getJobID()); subjobMap.put("startTimestamp", subjob.getStartTimestamp(). getTimestampString()); subjobMap.put("function", subjob.getStartFunction()); subjobMap.put("blockName", subjob.getCurrentBlockName()); subjobOutputList.add(subjobMap); } } mc.setRootObject(subjobOutputList); return new STAFResult(STAFResult.Ok, mc.marshall()); } else return new STAFResult(STAFResult.DoesNotExist, type); } private STAFMapClassDefinition fSubjobInfoMapClass; private static String fDTDInfo ="\n" +"<!--================== The STAX Job Element ===================== -->\n" +"<!--\n" +" Specifies a STAX sub-job to be executed. This element is equivalent\n" +" to a STAX EXECUTE request.\n" +"\n" +" The name attribute specifies the name of the job. The job name\n" +" defaults to the value of the function name called to start the job.\n" +" Its name and all of its element values are evaluated via Python.\n" +" The job element must contain a location element and either a\n" +" file or data element. This attribute is equivalent to the\n" +" JOBNAME option for a STAX EXECUTE command.\n" +"\n" +" The clearlogs attribute specifies to delete the STAX Job and Job\n" +" User logs before the job is executed to ensure that only one job's\n" +" contents are in the log. This attribute is equivalent to the\n" +" CLEARLOGS option for a STAX EXECUTE command. The default is the\n" +" same option that was specified for the parent job. Valid values\n" +" include 'parent', 'default', 'enabled', and 'disabled'.\n" +"\n" +" The monitor attribute specifies whether to automatically monitor the\n" +" subjob. Note that 'Automatically monitor recommended sub-jobs' must\n" +" be selected in the STAX Job Monitor properties in order for it to be\n" +" used. The default value for the monitor attribute is 0, a false\n" +" value.\n" +"\n" +" The logtcelapsedtime attribute specifies to log the elapsed time\n" +" for a testcase in the summary record in the STAX Job log and on a\n" +" LIST TESTCASES request. This attribute is equivalent to the\n" +" LOGTCELAPSEDTIME option for a STAX EXECUTE command. The default is\n" +" the same option that was specified for the parent job. Valid values\n" +" include 'parent', 'default', 'enabled', and 'disabled'.\n" +"\n" +" The logtcnumstarts attribute specifies to log the number of starts\n" +" for a testcase in the summary record in the STAX Job log and on a\n" +" LIST TESTCASES request. This attribute is equivalent to the\n" +" LOGNUMSTARTS option for a STAX EXECUTE command. The default is\n" +" the same option that was specified for the parent job. Valid values\n" +" include 'parent', 'default', 'enabled', and 'disabled'.\n" +"\n" +" The logtcstartstop attribute specifies to log start/stop records\n" +" for testcases in the STAX Job log. This attribute is equivalent to\n" +" the LOGTCSTARTSTOP option for a STAX EXECUTE command. The default\n" +" is the same option that was specified for the parent job. Valid\n" +" values include 'parent', 'default', 'enabled', and 'disabled'.\n" +"\n" +" The job element must contain either a job-file or job-data element.\n" +"\n" +" The job element has the following optional elements:\n" +" job-function, job-function-args, job-scriptfile(s), and job-script\n" +"\n" +" Each of these optional elements may specify an if attribute.\n" +" The if attribute must evaluate via Python to a true or false value.\n" +" If it does not evaluate to a true value, the element is ignored.\n" +" The default value for the if attribute is 1, a true value.\n" +" Note that in Python, true means any nonzero number or nonempty\n" + " object; false means not true, such as a zero number, an empty\n" +" object, or None. Comparisons and equality tests return 1 or 0\n" +" (true or false).\n" + "-->\n" +"<!ELEMENT job ((job-file | job-data),\n" +" job-function?, job-function-args?,\n" +" (job-scriptfile | job-scriptfiles)?,\n" +" job-script*, job-action?)>\n" +"<!ATTLIST job\n" +" name CDATA #IMPLIED\n" +" clearlogs CDATA \"'parent'\"\n" +" monitor CDATA #IMPLIED\n" +" logtcelapsedtime CDATA \"'parent'\"\n" +" logtcnumstarts CDATA \"'parent'\"\n" +" logtcstartstop CDATA \"'parent'\"\n" +">\n" +"\n" +"<!--\n" +" The job-file element specifies the fully qualified name of a file\n" +" containing the XML document for the STAX job to be executed.\n" +" The job-file element is equivalent to the FILE option for a STAX\n" +" EXECUTE command.\n" +"\n" +" The machine attribute specifies the name of the machine where the\n" +" xml file is located. If not specified, it defaults to Python\n" +" variable STAXJobXMLMachine. The machine attribute is equivalent\n" +" to the MACHINE option for a STAX EXECUTE command.\n" +" -->\n" +"<!ELEMENT job-file (#PCDATA)>\n" +"<!ATTLIST job-file\n" +" machine CDATA \"STAXJobXMLMachine\"\n" +">\n" +"\n" +"<!--\n" +" The job-data element specifies a string containing the XML document\n" +" for the job to be executed. This element is equivalent to the\n" +" DATA option for a STAX EXECUTE command.\n" +"\n" + " The eval attribute specifies whether the data is be evaluated by\n" +" Python in the parent job. For example, if the job-data information\n" +" is dynamically generated and assigned to a Python variable, rather\n" +" than just containing the literal XML information, then you would\n" +" need to set the eval attribute to true (e.g. eval=\"1\").\n" +" The default for the eval attribute is false (\"0\").\n" +" -->\n" +"<!ELEMENT job-data (#PCDATA)>\n" +"<!ATTLIST job-data\n" +" eval CDATA \"0\"\n" +">\n" +"\n" +"<!--\n" +" The job-function element specifies the name of the function element\n" +" to call to start the job, overriding the defaultcall element, if any,\n" +" specified in the XML document. The <function name> must be the name\n" +" of a function element specified in the XML document. This element is\n" +" equivalent to the FUNCTION option for a STAX EXECUTE command.\n" +"-->\n" +"<!ELEMENT job-function (#PCDATA)>\n" +"<!ATTLIST job-function\n" +" if CDATA \"1\"\n" +">\n" +"\n" +"<!--\n" +" The job-function-args element specifies arguments to pass to the\n" +" function element called to start the job, overriding the arguments,\n" +" if any, specified for the defaultcall element in the XML document.\n" +" This element is equivalent to the ARGS option for a STAX EXECUTE\n" +" command.\n" +"\n" +" The eval attribute specifies whether the data is to be evaluated\n" +" by Python in the parent job. The default for the eval attribute\n" +" is false (\"0\").\n" +"-->\n" +"<!ELEMENT job-function-args (#PCDATA)>\n" +"<!ATTLIST job-function-args\n" +" if CDATA \"1\"\n" +" eval CDATA \"0\"\n" +">\n" +"\n" +"<!--\n" +" The job-script element specifies Python code to be executed.\n" +" This element is equivalent to the SCRIPT option for a STAX\n" +" EXECUTE command. Multiple job-script elements may be specified.\n" +"\n" +" The eval attribute specifies whether the data is to be evaluated\n" +" by Python in the parent job. The default for the eval attribute\n" +" is false (\"0\").\n" +"-->\n" +"<!ELEMENT job-script (#PCDATA)>\n" +"<!ATTLIST job-script\n" +" if CDATA \"1\"\n" +" eval CDATA \"0\"\n" +">\n" +"\n" +"<!--\n" +" The job-scriptfile element (equivalent to the job-scriptfiles\n" +" element) specifies the fully qualified name of a file containing\n" +" Python code to be executed, or a list of file names containing\n" +" Python code to be executed. The value must evaluate via Python to\n" +" a string or a list of strings. This element is equivalent to the\n" +" SCRIPTFILE option for a STAX EXECUTE command.\n" +"\n" +" Specifying only one scriptfile could look like either:\n" +" ['C:/stax/scriptfiles/scriptfile1.py'] or \n" +" 'C:/stax/scriptfiles/scriptfiel1.py'\n" +" Specifying a list containing 3 scriptfiles could look like:\n" +" ['C:/stax/scriptfiles/scriptfile1.py',\n" +" 'C:/stax/scriptfiles/scriptfile2.py',\n" +" C:/stax/scriptfiles/scriptfile2.py' ]\n" +"\n" +" The machine attribute specifies the name of the machine where the\n" +" SCRIPTFILE(s) are located. If not specified, it defaults to Python\n" +" variable STAXJobScriptFileMachine. This attribute is equivalent\n" +" to the SCRIPTFILEMACHINE option for a STAX EXECUTE command.\n" +"-->\n" +"<!ELEMENT job-scriptfile (#PCDATA)>\n" +"<!ATTLIST job-scriptfile\n" +" if CDATA \"1\"\n" +" machine CDATA \"STAXJobScriptFileMachine\"\n" +">\n" +"\n" +"<!ELEMENT job-scriptfiles (#PCDATA)>\n" +"<!ATTLIST job-scriptfiles\n" +" if CDATA \"1\"\n" +" machine CDATA \"STAXJobScriptFileMachine\"\n" +">\n" +"\n" +"<!--\n" +" The job-action element specifies a task to be executed after the\n" +" sub-job has started. This task will be executed in parallel with\n" +" the sub-job via a new STAX-Thread. The task will be able to use the\n" +" STAXSubJobID variable to obtain the sub-job ID in order to interact\n" +" with the job. If the job completes before the task completes, the\n" +" job will remain in a non-complete state until the task completes.\n" +" If the job cannot be started, the job-action task is not executed.\n" +"-->\n" +"<!ELEMENT job-action (%task;)>\n" +"<!ATTLIST job-action\n" +" if CDATA \"1\"\n" +">\n";}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -