00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 package org.objectweb.proactive.core.descriptor.xml;
00032
00033 import java.util.StringTokenizer;
00034
00035 import javax.naming.directory.InvalidAttributeValueException;
00036
00037 import org.glite.wms.jdlj.*;
00038 import org.objectweb.proactive.core.ProActiveException;
00039 import org.objectweb.proactive.core.descriptor.data.ProActiveDescriptor;
00040 import org.objectweb.proactive.core.process.AbstractListProcessDecorator;
00041 import org.objectweb.proactive.core.process.DependentListProcess;
00042 import org.objectweb.proactive.core.process.ExternalProcess;
00043 import org.objectweb.proactive.core.process.ExternalProcessDecorator;
00044 import org.objectweb.proactive.core.process.HierarchicalProcess;
00045 import org.objectweb.proactive.core.process.IndependentListProcess;
00046 import org.objectweb.proactive.core.process.JVMProcess;
00047 import org.objectweb.proactive.core.process.filetransfer.FileTransferWorkShop;
00048 import org.objectweb.proactive.core.process.glite.GLiteProcess;
00049 import org.objectweb.proactive.core.process.globus.GlobusProcess;
00050 import org.objectweb.proactive.core.process.gridengine.GridEngineSubProcess;
00051 import org.objectweb.proactive.core.process.lsf.LSFBSubProcess;
00052 import org.objectweb.proactive.core.process.mpi.MPIProcess;
00053 import org.objectweb.proactive.core.process.nordugrid.NGProcess;
00054 import org.objectweb.proactive.core.process.oar.OARGRIDSubProcess;
00055 import org.objectweb.proactive.core.process.oar.OARSubProcess;
00056 import org.objectweb.proactive.core.process.pbs.PBSSubProcess;
00057 import org.objectweb.proactive.core.process.prun.PrunSubProcess;
00058 import org.objectweb.proactive.core.process.rsh.maprsh.MapRshProcess;
00059 import org.objectweb.proactive.core.process.unicore.UnicoreProcess;
00060 import org.objectweb.proactive.core.util.HostsInfos;
00061 import org.objectweb.proactive.core.xml.handler.AbstractUnmarshallerDecorator;
00062 import org.objectweb.proactive.core.xml.handler.BasicUnmarshaller;
00063 import org.objectweb.proactive.core.xml.handler.BasicUnmarshallerDecorator;
00064 import org.objectweb.proactive.core.xml.handler.CollectionUnmarshaller;
00065 import org.objectweb.proactive.core.xml.handler.PassiveCompositeUnmarshaller;
00066 import org.objectweb.proactive.core.xml.handler.SingleValueUnmarshaller;
00067 import org.objectweb.proactive.core.xml.handler.UnmarshallerHandler;
00068 import org.objectweb.proactive.core.xml.io.Attributes;
00069 import org.xml.sax.SAXException;
00070
00071
00072
00073 public class ProcessDefinitionHandler extends AbstractUnmarshallerDecorator
00074 implements ProActiveDescriptorConstants {
00075 protected String id;
00076 protected ProActiveDescriptor proActiveDescriptor;
00077 protected ExternalProcess targetProcess;
00078
00079 public ProcessDefinitionHandler(ProActiveDescriptor proActiveDescriptor) {
00080 super(false);
00081 this.proActiveDescriptor = proActiveDescriptor;
00082 this.addHandler(JVM_PROCESS_TAG,
00083 new JVMProcessHandler(proActiveDescriptor));
00084 this.addHandler(RSH_PROCESS_TAG,
00085 new RSHProcessHandler(proActiveDescriptor));
00086 this.addHandler(MAPRSH_PROCESS_TAG,
00087 new MapRshProcessHandler(proActiveDescriptor));
00088 this.addHandler(SSH_PROCESS_TAG,
00089 new SSHProcessHandler(proActiveDescriptor));
00090 this.addHandler(RLOGIN_PROCESS_TAG,
00091 new RLoginProcessHandler(proActiveDescriptor));
00092 this.addHandler(BSUB_PROCESS_TAG,
00093 new BSubProcessHandler(proActiveDescriptor));
00094 this.addHandler(GLOBUS_PROCESS_TAG,
00095 new GlobusProcessHandler(proActiveDescriptor));
00096 this.addHandler(PRUN_PROCESS_TAG,
00097 new PrunProcessHandler(proActiveDescriptor));
00098 this.addHandler(PBS_PROCESS_TAG,
00099 new PBSProcessHandler(proActiveDescriptor));
00100 this.addHandler(GRID_ENGINE_PROCESS_TAG,
00101 new GridEngineProcessHandler(proActiveDescriptor));
00102 this.addHandler(OAR_PROCESS_TAG,
00103 new OARProcessHandler(proActiveDescriptor));
00104 this.addHandler(GLITE_PROCESS_TAG,
00105 new GLiteProcessHandler(proActiveDescriptor));
00106 this.addHandler(OARGRID_PROCESS_TAG,
00107 new OARGRIDProcessHandler(proActiveDescriptor));
00108 this.addHandler(HIERARCHICAL_PROCESS_TAG,
00109 new HierarchicalProcessHandler(proActiveDescriptor));
00110 this.addHandler(MPI_PROCESS_TAG,
00111 new MPIProcessHandler(proActiveDescriptor));
00112 this.addHandler(DEPENDENT_PROCESS_SEQUENCE_TAG,
00113 new DependentProcessSequenceHandler(proActiveDescriptor));
00114 this.addHandler(SEQUENTIAL_PROCESS_TAG,
00115 new SequentialProcessHandler(proActiveDescriptor));
00116 ProcessListHandler handler = new ProcessListHandler(proActiveDescriptor);
00117 this.addHandler(PROCESS_LIST_TAG, handler);
00118 this.addHandler(PROCESS_LIST_BYHOST_TAG, handler);
00119 this.addHandler(UNICORE_PROCESS_TAG,
00120 new UnicoreProcessHandler(proActiveDescriptor));
00121 this.addHandler(NG_PROCESS_TAG,
00122 new NGProcessHandler(proActiveDescriptor));
00123 this.addHandler(CLUSTERFORK_PROCESS_TAG,
00124 new ClusterForkProcessHandler(proActiveDescriptor));
00125 }
00126
00131 protected void notifyEndActiveHandler(String name,
00132 UnmarshallerHandler activeHandler) throws SAXException {
00133
00134
00135
00136
00137
00138
00139
00140 }
00141
00145 public Object getResultObject() throws SAXException {
00146 ExternalProcess result = targetProcess;
00147 targetProcess = null;
00148
00149 return result;
00150 }
00151
00156 public void startContextElement(String name, Attributes attributes)
00157 throws SAXException {
00158 id = attributes.getValue("id");
00159 }
00160
00161 public class ProcessHandler extends AbstractUnmarshallerDecorator
00162 implements ProActiveDescriptorConstants {
00163 protected ProActiveDescriptor proActiveDescriptor;
00164 protected boolean isRef;
00165
00166 public ProcessHandler(ProActiveDescriptor proActiveDescriptor) {
00167 super();
00168 this.proActiveDescriptor = proActiveDescriptor;
00169 addHandler(ENVIRONMENT_TAG, new EnvironmentHandler());
00170 addHandler(PROCESS_REFERENCE_TAG, new ProcessReferenceHandler());
00171 addHandler(COMMAND_PATH_TAG, new CommandPathHanlder());
00172 addHandler(FILE_TRANSFER_DEPLOY_TAG,
00173 new FileTransferStructureHandler("deploy"));
00174 addHandler(FILE_TRANSFER_RETRIEVE_TAG,
00175 new FileTransferStructureHandler("retrieve"));
00176 }
00177
00178 public void startContextElement(String name, Attributes attributes)
00179 throws org.xml.sax.SAXException {
00180 String className = attributes.getValue("class");
00181
00182 if (!checkNonEmpty(className)) {
00183 throw new org.xml.sax.SAXException(
00184 "Process defined without specifying the class");
00185 }
00186
00187 try {
00188 targetProcess = proActiveDescriptor.createProcess(id, className);
00189 } catch (ProActiveException e) {
00190
00191 throw new org.xml.sax.SAXException(e.getMessage());
00192 }
00193
00194 String closeStream = attributes.getValue("closeStream");
00195
00196 if (checkNonEmpty(closeStream) && closeStream.equals("yes")) {
00197 targetProcess.closeStream();
00198 }
00199
00200 String hostname = attributes.getValue("hostname");
00201
00202 if (checkNonEmpty(hostname)) {
00203 targetProcess.setHostname(hostname);
00204 }
00205
00206 String username = attributes.getValue("username");
00207
00208 if (checkNonEmpty(username)) {
00209 targetProcess.setUsername(username);
00210 }
00211 }
00212
00213
00214
00215
00216
00217 public Object getResultObject() throws org.xml.sax.SAXException {
00218 return null;
00219 }
00220
00221
00222
00223
00224
00225 protected void notifyEndActiveHandler(String name,
00226 UnmarshallerHandler activeHandler) throws org.xml.sax.SAXException {
00227 if (name.equals(ENVIRONMENT_TAG)) {
00228 targetProcess.setEnvironment((String[]) activeHandler.getResultObject());
00229 } else if (name.equals(PROCESS_REFERENCE_TAG)) {
00230 if (!(targetProcess instanceof ExternalProcessDecorator)) {
00231 throw new org.xml.sax.SAXException(
00232 "found a Process defined inside a non composite process");
00233 }
00234
00235 ExternalProcessDecorator cep = (ExternalProcessDecorator) targetProcess;
00236 Object result = activeHandler.getResultObject();
00237 proActiveDescriptor.registerProcess(cep, (String) result);
00238 } else if (name.equals(COMMAND_PATH_TAG)) {
00239 targetProcess.setCommandPath((String) activeHandler.getResultObject());
00240 }
00241 }
00242
00243
00244
00245
00246
00247 protected class EnvironmentHandler extends BasicUnmarshaller {
00248 private java.util.ArrayList<String> variables;
00249
00250 public EnvironmentHandler() {
00251 }
00252
00253 public void startContextElement(String name, Attributes attributes)
00254 throws org.xml.sax.SAXException {
00255 variables = new java.util.ArrayList<String>();
00256 }
00257
00258 public Object getResultObject() throws org.xml.sax.SAXException {
00259 if (variables == null) {
00260 isResultValid = false;
00261 } else {
00262 int n = variables.size();
00263 String[] result = new String[n];
00264
00265 if (n > 0) {
00266 variables.toArray(result);
00267 }
00268
00269 setResultObject(result);
00270 variables.clear();
00271 variables = null;
00272 }
00273
00274 return super.getResultObject();
00275 }
00276
00277 public void startElement(String name, Attributes attributes)
00278 throws org.xml.sax.SAXException {
00279 if (name.equals(VARIABLE_TAG)) {
00280 String vName = attributes.getValue("name");
00281 String vValue = attributes.getValue("value");
00282
00283 if (checkNonEmpty(vName) && (vValue != null)) {
00284 logger.info("Found environment variable name=" + vName +
00285 " value=" + vValue);
00286 variables.add(vName + "=" + vValue);
00287 }
00288 }
00289 }
00290 }
00291
00292
00293 protected class CommandPathHanlder extends BasicUnmarshaller {
00294 public CommandPathHanlder() {
00295 }
00296
00297 public void startContextElement(String name, Attributes attributes)
00298 throws org.xml.sax.SAXException {
00299 String path = attributes.getValue("value");
00300
00301 if (checkNonEmpty(path)) {
00302 setResultObject(path);
00303 } else {
00304 throw new org.xml.sax.SAXException(
00305 "The Id of the referenced definition cannot be set to an empty string");
00306 }
00307 }
00308 }
00309
00310 protected class FileTransferStructureHandler
00311 extends PassiveCompositeUnmarshaller {
00312
00313
00314
00315
00316
00317
00318 protected String fileTransferQueue;
00319 protected FileTransferWorkShop fileTransferStructure;
00320
00321 public FileTransferStructureHandler(String queue) {
00322 super();
00323 fileTransferQueue = queue;
00324 fileTransferStructure = null;
00325
00326 addHandler(FILE_TRANSFER_COPY_PROTOCOL_TAG,
00327 new SingleValueUnmarshaller());
00328 addHandler(FILE_TRANSFER_SRC_INFO_TAG,
00329 new InfoAttributeHandler());
00330 addHandler(FILE_TRANSFER_DST_INFO_TAG,
00331 new InfoAttributeHandler());
00332 }
00333
00334 protected void notifyEndActiveHandler(String name,
00335 UnmarshallerHandler activeHandler)
00336 throws org.xml.sax.SAXException {
00337 if (name.equals(FILE_TRANSFER_COPY_PROTOCOL_TAG)) {
00338 fileTransferStructure.setFileTransferCopyProtocol((String) activeHandler.getResultObject());
00339 }
00340 }
00341
00342 public void startContextElement(String name, Attributes attributes)
00343 throws org.xml.sax.SAXException {
00344 if (fileTransferQueue.equalsIgnoreCase("deploy")) {
00345 fileTransferStructure = targetProcess.getFileTransferWorkShopDeploy();
00346 } else {
00347 fileTransferStructure = targetProcess.getFileTransferWorkShopRetrieve();
00348 }
00349
00350 String ftRefId = attributes.getValue("refid");
00351 if (!checkNonEmpty(ftRefId)) {
00352 throw new org.xml.sax.SAXException(name +
00353 " defined without 'refid' attribute");
00354 }
00355
00356 if (ftRefId.equalsIgnoreCase(FILE_TRANSFER_IMPLICT_KEYWORD)) {
00357 fileTransferStructure.setImplicit(true);
00358 } else {
00359 fileTransferStructure.setImplicit(false);
00360 fileTransferStructure.addFileTransfer(proActiveDescriptor.getFileTransfer(
00361 ftRefId));
00362 }
00363 }
00364
00365 protected class InfoAttributeHandler extends BasicUnmarshaller {
00366 public void startContextElement(String name,
00367 Attributes attributes) throws org.xml.sax.SAXException {
00368 String[] parameter = {
00369 "prefix", "hostname", "username", "password"
00370 };
00371
00372 for (int i = 0; i < parameter.length; i++) {
00373 String value = attributes.getValue(parameter[i]);
00374
00375 if (checkNonEmpty(value)) {
00376 if (name.equals(FILE_TRANSFER_SRC_INFO_TAG)) {
00377 fileTransferStructure.setFileTransferStructureSrcInfo(parameter[i],
00378 value);
00379 } else if (name.equals(FILE_TRANSFER_DST_INFO_TAG)) {
00380 fileTransferStructure.setFileTransferStructureDstInfo(parameter[i],
00381 value);
00382 } else {
00383 System.err.println(
00384 "Error skipping unknown tag name:" + name);
00385 }
00386 }
00387 }
00388 }
00389 }
00390 }
00391 }
00392
00393 public class ProcessListHandler extends ProcessHandler
00394 implements ProActiveDescriptorConstants {
00395 public ProcessListHandler(ProActiveDescriptor proActiveDescriptor) {
00396 super(proActiveDescriptor);
00397 }
00398
00399 public void startContextElement(String name, Attributes attributes)
00400 throws org.xml.sax.SAXException {
00401 int padding = 0;
00402 int repeat = 1;
00403 String className = attributes.getValue("class");
00404
00405 if (!checkNonEmpty(className)) {
00406 throw new org.xml.sax.SAXException(
00407 "Process defined without specifying the class");
00408 }
00409
00410 try {
00411 targetProcess = proActiveDescriptor.createProcess(id, className);
00412 } catch (ProActiveException e) {
00413
00414 throw new org.xml.sax.SAXException(e.getMessage());
00415 }
00416
00417 String closeStream = attributes.getValue("closeStream");
00418
00419 String fixedName = attributes.getValue("fixedName");
00420 String list = attributes.getValue("list");
00421 String domain = attributes.getValue("domain");
00422 String spadding = attributes.getValue("padding");
00423 String hostlist = attributes.getValue("hostlist");
00424 String srepeat = attributes.getValue("repeat");
00425
00426 if (checkNonEmpty(spadding)) {
00427 padding = Integer.parseInt(spadding);
00428 }
00429
00430 if (checkNonEmpty(srepeat)) {
00431 repeat = Integer.parseInt(srepeat);
00432 }
00433
00434 if (checkNonEmpty(fixedName) && checkNonEmpty(list)) {
00435 ((AbstractListProcessDecorator) targetProcess).setHostConfig(fixedName,
00436 list, domain, padding, repeat);
00437 }
00438
00439 if (checkNonEmpty(hostlist)) {
00440 ((AbstractListProcessDecorator) targetProcess).setHostList(hostlist,
00441 domain);
00442 }
00443
00444 if (checkNonEmpty(closeStream) && closeStream.equals("yes")) {
00445 targetProcess.closeStream();
00446 }
00447
00448 String username = attributes.getValue("username");
00449
00450 if (checkNonEmpty(username)) {
00451 targetProcess.setUsername(username);
00452 }
00453 }
00454 }
00455
00456
00457 protected class PrunProcessHandler extends ProcessHandler {
00458 public PrunProcessHandler(ProActiveDescriptor proActiveDescriptor) {
00459 super(proActiveDescriptor);
00460 this.addHandler(PRUN_OPTIONS_TAG, new PrunOptionHandler());
00461
00462
00463 }
00464
00465 public void startContextElement(String name, Attributes attributes)
00466 throws org.xml.sax.SAXException {
00467 super.startContextElement(name, attributes);
00468
00469 String queueName = (attributes.getValue("queue"));
00470
00471 if (checkNonEmpty(queueName)) {
00472 ((PrunSubProcess) targetProcess).setQueueName(queueName);
00473 }
00474 }
00475
00476 protected class PrunOptionHandler extends PassiveCompositeUnmarshaller {
00477
00478
00479
00480 public PrunOptionHandler() {
00481
00482
00483 UnmarshallerHandler pathHandler = new PathHandler();
00484 this.addHandler(HOST_LIST_TAG, new SingleValueUnmarshaller());
00485 this.addHandler(HOSTS_NUMBER_TAG, new SingleValueUnmarshaller());
00486 this.addHandler(PROCESSOR_PER_NODE_TAG,
00487 new SingleValueUnmarshaller());
00488 this.addHandler(BOOKING_DURATION_TAG,
00489 new SingleValueUnmarshaller());
00490 this.addHandler(OUTPUT_FILE, new SingleValueUnmarshaller());
00491
00492 BasicUnmarshallerDecorator bch = new BasicUnmarshallerDecorator();
00493 bch.addHandler(ABS_PATH_TAG, pathHandler);
00494 bch.addHandler(REL_PATH_TAG, pathHandler);
00495
00496
00497 }
00498
00499 public void startContextElement(String name, Attributes attributes)
00500 throws org.xml.sax.SAXException {
00501 }
00502
00503 protected void notifyEndActiveHandler(String name,
00504 UnmarshallerHandler activeHandler)
00505 throws org.xml.sax.SAXException {
00506
00507
00508 PrunSubProcess prunSubProcess = (PrunSubProcess) targetProcess;
00509
00510
00511 if (name.equals(HOST_LIST_TAG)) {
00512 prunSubProcess.setHostList((String) activeHandler.getResultObject());
00513 } else if (name.equals(HOSTS_NUMBER_TAG)) {
00514 prunSubProcess.setHostsNumber((String) activeHandler.getResultObject());
00515 } else if (name.equals(PROCESSOR_PER_NODE_TAG)) {
00516 prunSubProcess.setProcessorPerNodeNumber((String) activeHandler.getResultObject());
00517
00518
00519
00520
00521
00522 } else if (name.equals(BOOKING_DURATION_TAG)) {
00523 prunSubProcess.setBookingDuration((String) activeHandler.getResultObject());
00524 } else if (name.equals(OUTPUT_FILE)) {
00525 prunSubProcess.setOutputFile((String) activeHandler.getResultObject());
00526 } else {
00527 super.notifyEndActiveHandler(name, activeHandler);
00528 }
00529 }
00530 }
00531 }
00532
00533 protected class PBSProcessHandler extends ProcessHandler {
00534 public PBSProcessHandler(ProActiveDescriptor proActiveDescriptor) {
00535 super(proActiveDescriptor);
00536 this.addHandler(PBS_OPTIONS_TAG, new PBSOptionHandler());
00537 }
00538
00539 public void startContextElement(String name, Attributes attributes)
00540 throws org.xml.sax.SAXException {
00541 super.startContextElement(name, attributes);
00542
00543 String interactive = (attributes.getValue("interactive"));
00544
00545 if (checkNonEmpty(interactive)) {
00546 ((PBSSubProcess) targetProcess).setInteractive(interactive);
00547 }
00548
00549 String queueName = (attributes.getValue("queue"));
00550
00551 if (checkNonEmpty(queueName)) {
00552 ((PBSSubProcess) targetProcess).setQueueName(queueName);
00553 }
00554 }
00555
00556 protected class PBSOptionHandler extends PassiveCompositeUnmarshaller {
00557 public PBSOptionHandler() {
00558 UnmarshallerHandler pathHandler = new PathHandler();
00559 this.addHandler(HOST_LIST_TAG, new SingleValueUnmarshaller());
00560 this.addHandler(HOSTS_NUMBER_TAG, new SingleValueUnmarshaller());
00561 this.addHandler(PROCESSOR_PER_NODE_TAG,
00562 new SingleValueUnmarshaller());
00563 this.addHandler(BOOKING_DURATION_TAG,
00564 new SingleValueUnmarshaller());
00565 this.addHandler(OUTPUT_FILE, new SingleValueUnmarshaller());
00566
00567 BasicUnmarshallerDecorator bch = new BasicUnmarshallerDecorator();
00568 bch.addHandler(ABS_PATH_TAG, pathHandler);
00569 bch.addHandler(REL_PATH_TAG, pathHandler);
00570 this.addHandler(SCRIPT_PATH_TAG, bch);
00571 }
00572
00573 public void startContextElement(String name, Attributes attributes)
00574 throws org.xml.sax.SAXException {
00575 }
00576
00577 protected void notifyEndActiveHandler(String name,
00578 UnmarshallerHandler activeHandler)
00579 throws org.xml.sax.SAXException {
00580 PBSSubProcess pbsSubProcess = (PBSSubProcess) targetProcess;
00581
00582 if (name.equals(HOST_LIST_TAG)) {
00583 pbsSubProcess.setHostList((String) activeHandler.getResultObject());
00584 } else if (name.equals(HOSTS_NUMBER_TAG)) {
00585 pbsSubProcess.setHostsNumber((String) activeHandler.getResultObject());
00586 } else if (name.equals(PROCESSOR_PER_NODE_TAG)) {
00587 pbsSubProcess.setProcessorPerNodeNumber((String) activeHandler.getResultObject());
00588 } else if (name.equals(SCRIPT_PATH_TAG)) {
00589 pbsSubProcess.setScriptLocation((String) activeHandler.getResultObject());
00590 } else if (name.equals(BOOKING_DURATION_TAG)) {
00591 pbsSubProcess.setBookingDuration((String) activeHandler.getResultObject());
00592 } else if (name.equals(OUTPUT_FILE)) {
00593 pbsSubProcess.setOutputFile((String) activeHandler.getResultObject());
00594 } else {
00595 super.notifyEndActiveHandler(name, activeHandler);
00596 }
00597 }
00598 }
00599 }
00600
00601 protected class GridEngineProcessHandler extends ProcessHandler {
00602 public GridEngineProcessHandler(ProActiveDescriptor proActiveDescriptor) {
00603 super(proActiveDescriptor);
00604 this.addHandler(GRID_ENGINE_OPTIONS_TAG,
00605 new GridEngineOptionHandler());
00606 }
00607
00608 public void startContextElement(String name, Attributes attributes)
00609 throws org.xml.sax.SAXException {
00610 super.startContextElement(name, attributes);
00611
00612 String queueName = (attributes.getValue("queue"));
00613 if (checkNonEmpty(queueName)) {
00614 ((GridEngineSubProcess) targetProcess).setQueueName(queueName);
00615 }
00616 }
00617
00618 protected class GridEngineOptionHandler
00619 extends PassiveCompositeUnmarshaller {
00620 public GridEngineOptionHandler() {
00621 UnmarshallerHandler pathHandler = new PathHandler();
00622 this.addHandler(HOST_LIST_TAG, new SingleValueUnmarshaller());
00623 this.addHandler(HOSTS_NUMBER_TAG, new SingleValueUnmarshaller());
00624 this.addHandler(PARALLEL_ENVIRONMENT_TAG,
00625 new SingleValueUnmarshaller());
00626
00627
00628
00629 this.addHandler(BOOKING_DURATION_TAG,
00630 new SingleValueUnmarshaller());
00631
00632
00633
00634 BasicUnmarshallerDecorator bch = new BasicUnmarshallerDecorator();
00635 bch.addHandler(ABS_PATH_TAG, pathHandler);
00636 bch.addHandler(REL_PATH_TAG, pathHandler);
00637 this.addHandler(SCRIPT_PATH_TAG, bch);
00638 }
00639
00640 public void startContextElement(String name, Attributes attributes)
00641 throws org.xml.sax.SAXException {
00642 }
00643
00644 protected void notifyEndActiveHandler(String name,
00645 UnmarshallerHandler activeHandler)
00646 throws org.xml.sax.SAXException {
00647 GridEngineSubProcess geSubProcess = (GridEngineSubProcess) targetProcess;
00648
00649 if (name.equals(HOST_LIST_TAG)) {
00650 geSubProcess.setHostList((String) activeHandler.getResultObject());
00651 } else if (name.equals(HOSTS_NUMBER_TAG)) {
00652 geSubProcess.setHostsNumber((String) activeHandler.getResultObject());
00653 } else if (name.equals(PARALLEL_ENVIRONMENT_TAG)) {
00654 geSubProcess.setParallelEnvironment((String) activeHandler.getResultObject());
00655 } else if (name.equals(SCRIPT_PATH_TAG)) {
00656 geSubProcess.setScriptLocation((String) activeHandler.getResultObject());
00657 } else if (name.equals(BOOKING_DURATION_TAG)) {
00658 geSubProcess.setBookingDuration((String) activeHandler.getResultObject());
00659 } else {
00660 super.notifyEndActiveHandler(name, activeHandler);
00661 }
00662 }
00663 }
00664 }
00665
00666 protected class ClusterForkProcessHandler extends ProcessHandler {
00667 public ClusterForkProcessHandler(
00668 ProActiveDescriptor proActiveDescriptor) {
00669 super(proActiveDescriptor);
00670 }
00671
00672 public void startContextElement(String name, Attributes attributes)
00673 throws SAXException {
00674 super.startContextElement(name, attributes);
00675 }
00676 }
00677
00678 protected class OARProcessHandler extends ProcessHandler {
00679 public OARProcessHandler(ProActiveDescriptor proActiveDescriptor) {
00680 super(proActiveDescriptor);
00681 this.addHandler(OAR_OPTIONS_TAG, new OAROptionHandler());
00682 }
00683
00684 public void startContextElement(String name, Attributes attributes)
00685 throws org.xml.sax.SAXException {
00686 super.startContextElement(name, attributes);
00687
00688 String interactive = (attributes.getValue("interactive"));
00689
00690 if (checkNonEmpty(interactive)) {
00691 ((OARSubProcess) targetProcess).setInteractive(interactive);
00692 }
00693
00694 String queueName = (attributes.getValue("queue"));
00695
00696 if (checkNonEmpty(queueName)) {
00697 ((OARSubProcess) targetProcess).setQueueName(queueName);
00698 }
00699
00700 String accessProtocol = (attributes.getValue("bookedNodesAccess"));
00701
00702 if (checkNonEmpty(accessProtocol)) {
00703 ((OARSubProcess) targetProcess).setAccessProtocol(accessProtocol);
00704 }
00705 }
00706
00707 protected class OAROptionHandler extends PassiveCompositeUnmarshaller {
00708 public OAROptionHandler() {
00709 UnmarshallerHandler pathHandler = new PathHandler();
00710
00711
00712
00713
00714 this.addHandler(OAR_RESOURCE_TAG, new SingleValueUnmarshaller());
00715
00716 BasicUnmarshallerDecorator bch = new BasicUnmarshallerDecorator();
00717 bch.addHandler(ABS_PATH_TAG, pathHandler);
00718 bch.addHandler(REL_PATH_TAG, pathHandler);
00719 this.addHandler(SCRIPT_PATH_TAG, bch);
00720 }
00721
00722 public void startContextElement(String name, Attributes attributes)
00723 throws org.xml.sax.SAXException {
00724 }
00725
00726 protected void notifyEndActiveHandler(String name,
00727 UnmarshallerHandler activeHandler)
00728 throws org.xml.sax.SAXException {
00729 OARSubProcess oarSubProcess = (OARSubProcess) targetProcess;
00730
00731 if (name.equals(OAR_RESOURCE_TAG)) {
00732 oarSubProcess.setResources((String) activeHandler.getResultObject());
00733 }
00734
00735
00736
00737
00738
00739 else if (name.equals(SCRIPT_PATH_TAG)) {
00740 oarSubProcess.setScriptLocation((String) activeHandler.getResultObject());
00741 } else {
00742 super.notifyEndActiveHandler(name, activeHandler);
00743 }
00744 }
00745 }
00746 }
00747
00748 protected class OARGRIDProcessHandler extends ProcessHandler {
00749 public OARGRIDProcessHandler(ProActiveDescriptor proActiveDescriptor) {
00750 super(proActiveDescriptor);
00751 this.addHandler(OARGRID_OPTIONS_TAG, new OARGRIDOptionHandler());
00752 }
00753
00754 public void startContextElement(String name, Attributes attributes)
00755 throws org.xml.sax.SAXException {
00756 super.startContextElement(name, attributes);
00757
00758 String queueName = (attributes.getValue("queue"));
00759
00760 if (checkNonEmpty(queueName)) {
00761 ((OARGRIDSubProcess) targetProcess).setQueueName(queueName);
00762 }
00763
00764 String accessProtocol = (attributes.getValue("bookedNodesAccess"));
00765
00766 if (checkNonEmpty(accessProtocol)) {
00767 ((OARGRIDSubProcess) targetProcess).setAccessProtocol(accessProtocol);
00768 }
00769 }
00770
00771 protected class OARGRIDOptionHandler
00772 extends PassiveCompositeUnmarshaller {
00773 public OARGRIDOptionHandler() {
00774 UnmarshallerHandler pathHandler = new PathHandler();
00775
00776 this.addHandler(OAR_RESOURCE_TAG, new SingleValueUnmarshaller());
00777 this.addHandler(OARGRID_WALLTIME_TAG,
00778 new SingleValueUnmarshaller());
00779
00780 BasicUnmarshallerDecorator bch = new BasicUnmarshallerDecorator();
00781 bch.addHandler(ABS_PATH_TAG, pathHandler);
00782 bch.addHandler(REL_PATH_TAG, pathHandler);
00783 this.addHandler(SCRIPT_PATH_TAG, bch);
00784 }
00785
00786 public void startContextElement(String name, Attributes attributes)
00787 throws org.xml.sax.SAXException {
00788 }
00789
00790 protected void notifyEndActiveHandler(String name,
00791 UnmarshallerHandler activeHandler)
00792 throws org.xml.sax.SAXException {
00793 OARGRIDSubProcess oarGridSubProcess = (OARGRIDSubProcess) targetProcess;
00794
00795 if (name.equals(OAR_RESOURCE_TAG)) {
00796 oarGridSubProcess.setResources((String) activeHandler.getResultObject());
00797 } else if (name.equals(OARGRID_WALLTIME_TAG)) {
00798 oarGridSubProcess.setWallTime((String) activeHandler.getResultObject());
00799 } else if (name.equals(SCRIPT_PATH_TAG)) {
00800 oarGridSubProcess.setScriptLocation((String) activeHandler.getResultObject());
00801 } else {
00802 super.notifyEndActiveHandler(name, activeHandler);
00803 }
00804 }
00805 }
00806 }
00807
00808 protected class HierarchicalProcessHandler extends ProcessHandler {
00809 public HierarchicalProcessHandler(
00810 ProActiveDescriptor proActiveDescriptor) {
00811 super(proActiveDescriptor);
00812 addHandler(HIERARCHICIAL_REFERENCE_TAG,
00813 new ProcessReferenceHandler());
00814 }
00815
00816 protected void notifyEndActiveHandler(String name,
00817 UnmarshallerHandler activeHandler) throws SAXException {
00818 if (name.equals(HIERARCHICIAL_REFERENCE_TAG)) {
00819 if (!(targetProcess instanceof HierarchicalProcess)) {
00820 throw new org.xml.sax.SAXException(
00821 "found a hierarchical reference inside a non hierarchical process");
00822 }
00823
00824 HierarchicalProcess hp = (HierarchicalProcess) targetProcess;
00825 Object result = activeHandler.getResultObject();
00826 proActiveDescriptor.registerHierarchicalProcess(hp,
00827 (String) result);
00828 } else {
00829 super.notifyEndActiveHandler(name, activeHandler);
00830 }
00831 }
00832
00833 public void startContextElement(String name, Attributes attributes)
00834 throws org.xml.sax.SAXException {
00835 String hostname = attributes.getValue("hostname");
00836 String internal_ip = attributes.getValue("internal_ip");
00837
00838 if (checkNonEmpty(internal_ip) && checkNonEmpty(hostname)) {
00839 HostsInfos.setSecondaryName(internal_ip, hostname);
00840 }
00841
00842 super.startContextElement(name, attributes);
00843 }
00844 }
00845
00846 protected class JVMProcessHandler extends ProcessHandler {
00847 public JVMProcessHandler(ProActiveDescriptor proActiveDescriptor) {
00848 super(proActiveDescriptor);
00849
00850 UnmarshallerHandler pathHandler = new PathHandler();
00851
00852 {
00853 CollectionUnmarshaller cu = new CollectionUnmarshaller(String.class);
00854 cu.addHandler(ABS_PATH_TAG, pathHandler);
00855 cu.addHandler(REL_PATH_TAG, pathHandler);
00856 cu.addHandler(JVMPARAMETER_TAG, new SimpleValueHandler());
00857 this.addHandler(CLASSPATH_TAG, cu);
00858 this.addHandler(BOOT_CLASSPATH_TAG, cu);
00859 this.addHandler(JVMPARAMETERS_TAG, cu);
00860 }
00861
00862 BasicUnmarshallerDecorator bch = new BasicUnmarshallerDecorator();
00863 bch.addHandler(ABS_PATH_TAG, pathHandler);
00864 bch.addHandler(REL_PATH_TAG, pathHandler);
00865 bch.addHandler(JVMPARAMETER_TAG, new BasicUnmarshaller());
00866
00867
00868 this.addHandler(JAVA_PATH_TAG, bch);
00869 this.addHandler(POLICY_FILE_TAG, bch);
00870 this.addHandler(LOG4J_FILE_TAG, bch);
00871 this.addHandler(PROACTIVE_PROPS_FILE_TAG, bch);
00872 this.addHandler(CLASSNAME_TAG, new SingleValueUnmarshaller());
00873 this.addHandler(PARAMETERS_TAG, new SingleValueUnmarshaller());
00874 this.addHandler(EXTENDED_JVM_TAG, new ExtendedJVMHandler());
00875
00876
00877
00878 }
00879
00880
00881
00882
00883
00884
00885
00886
00887
00888 protected void notifyEndActiveHandler(String name,
00889 UnmarshallerHandler activeHandler) throws org.xml.sax.SAXException {
00890
00891
00892
00893 JVMProcess jvmProcess = (JVMProcess) targetProcess;
00894
00895 if (name.equals(CLASSPATH_TAG)) {
00896 String[] paths = (String[]) activeHandler.getResultObject();
00897
00898 if (paths.length > 0) {
00899 StringBuffer sb = new StringBuffer();
00900 String pathSeparator = System.getProperty("path.separator");
00901 sb.append(paths[0].trim());
00902
00903
00904
00905 for (int i = 1; i < paths.length; i++) {
00906 sb.append(pathSeparator);
00907 sb.append(paths[i].trim());
00908 }
00909
00910 jvmProcess.setClasspath(sb.toString());
00911 }
00912 } else if (name.equals(BOOT_CLASSPATH_TAG)) {
00913 String[] paths = (String[]) activeHandler.getResultObject();
00914
00915 if (paths.length > 0) {
00916 StringBuffer sb = new StringBuffer();
00917 String pathSeparator = System.getProperty("path.separator");
00918 sb.append(paths[0].trim());
00919
00920 for (int i = 1; i < paths.length; i++) {
00921 sb.append(pathSeparator);
00922 sb.append(paths[i].trim());
00923 }
00924
00925 jvmProcess.setBootClasspath(sb.toString());
00926 }
00927 } else if (name.equals(JVMPARAMETERS_TAG)) {
00928 String[] paths = (String[]) activeHandler.getResultObject();
00929
00930 if (paths.length > 0) {
00931 StringBuffer sb = new StringBuffer();
00932
00933 for (int i = 0; i < paths.length; i++) {
00934
00935 sb.append(paths[i]);
00936 sb.append(" ");
00937 }
00938
00939 jvmProcess.setJvmOptions(sb.toString());
00940 }
00941 } else if (name.equals(JAVA_PATH_TAG)) {
00942 String jp = (String) activeHandler.getResultObject();
00943 jvmProcess.setJavaPath(jp.trim());
00944 } else if (name.equals(POLICY_FILE_TAG)) {
00945 jvmProcess.setPolicyFile(((String) activeHandler.getResultObject()).trim());
00946 } else if (name.equals(LOG4J_FILE_TAG)) {
00947 jvmProcess.setLog4jFile(((String) activeHandler.getResultObject()).trim());
00948 } else if (name.equals(PROACTIVE_PROPS_FILE_TAG)) {
00949 jvmProcess.setJvmOptions("-Dproactive.configuration=" +
00950 (String) activeHandler.getResultObject());
00951 } else if (name.equals(CLASSNAME_TAG)) {
00952 jvmProcess.setClassname((String) activeHandler.getResultObject());
00953 } else if (name.equals(PARAMETERS_TAG)) {
00954 jvmProcess.setParameters((String) activeHandler.getResultObject());
00955 } else if (name.equals(EXTENDED_JVM_TAG)) {
00956 try {
00957 proActiveDescriptor.mapToExtendedJVM((JVMProcess) targetProcess,
00958 (String) activeHandler.getResultObject());
00959 } catch (ProActiveException e) {
00960 throw new SAXException(e);
00961 }
00962 } else {
00963 super.notifyEndActiveHandler(name, activeHandler);
00964 }
00965 }
00966
00967 protected class ExtendedJVMHandler extends ProcessReferenceHandler {
00968 public ExtendedJVMHandler() {
00969 }
00970
00971 public void startContextElement(String name, Attributes attributes)
00972 throws org.xml.sax.SAXException {
00973 super.startContextElement(name, attributes);
00974
00975 String overwrite = attributes.getValue("overwriteParameters");
00976
00977 if ((overwrite != null) && overwrite.equals("yes")) {
00978 ((JVMProcess) targetProcess).setOverwrite(true);
00979 }
00980 }
00981 }
00982 }
00983
00984
00985 protected class RSHProcessHandler extends ProcessHandler {
00986 public RSHProcessHandler(ProActiveDescriptor proActiveDescriptor) {
00987 super(proActiveDescriptor);
00988 }
00989 }
00990
00991
00992 protected class MapRshProcessHandler extends ProcessHandler {
00993 public MapRshProcessHandler(ProActiveDescriptor proActiveDescriptor) {
00994 super(proActiveDescriptor);
00995
00996 UnmarshallerHandler pathHandler = new PathHandler();
00997 BasicUnmarshallerDecorator bch = new BasicUnmarshallerDecorator();
00998 bch.addHandler(ABS_PATH_TAG, pathHandler);
00999 bch.addHandler(REL_PATH_TAG, pathHandler);
01000 this.addHandler(SCRIPT_PATH_TAG, bch);
01001 }
01002
01003 public void startContextElement(String name, Attributes attributes)
01004 throws org.xml.sax.SAXException {
01005
01006
01007
01008 super.startContextElement(name, attributes);
01009
01010 String parallelize = attributes.getValue("parallelize");
01011
01012 if (checkNonEmpty(parallelize)) {
01013 ((MapRshProcess) targetProcess).setParallelization(
01014 "parallelize");
01015 }
01016 }
01017
01018 protected void notifyEndActiveHandler(String name,
01019 UnmarshallerHandler activeHandler) throws org.xml.sax.SAXException {
01020
01021 if (name.equals(SCRIPT_PATH_TAG)) {
01022 ((MapRshProcess) targetProcess).setScriptLocation((String) activeHandler.getResultObject());
01023 } else {
01024 super.notifyEndActiveHandler(name, activeHandler);
01025 }
01026 }
01027 }
01028
01029
01030 protected class SSHProcessHandler extends ProcessHandler {
01031 public SSHProcessHandler(ProActiveDescriptor proActiveDescriptor) {
01032 super(proActiveDescriptor);
01033 }
01034 }
01035
01036
01037 protected class RLoginProcessHandler extends ProcessHandler {
01038 public RLoginProcessHandler(ProActiveDescriptor proActiveDescriptor) {
01039 super(proActiveDescriptor);
01040 }
01041 }
01042
01043
01044 protected class BSubProcessHandler extends ProcessHandler {
01045 public BSubProcessHandler(ProActiveDescriptor proActiveDescriptor) {
01046 super(proActiveDescriptor);
01047 this.addHandler(BSUB_OPTIONS_TAG, new BsubOptionHandler());
01048 }
01049
01050 public void startContextElement(String name, Attributes attributes)
01051 throws org.xml.sax.SAXException {
01052
01053
01054
01055 super.startContextElement(name, attributes);
01056
01057 String interactive = (attributes.getValue("interactive"));
01058
01059 if (checkNonEmpty(interactive)) {
01060 ((LSFBSubProcess) targetProcess).setInteractive(interactive);
01061 }
01062
01063 String queueName = (attributes.getValue("queue"));
01064
01065 if (checkNonEmpty(queueName)) {
01066 ((LSFBSubProcess) targetProcess).setQueueName(queueName);
01067 }
01068 String jobName = (attributes.getValue("jobname"));
01069
01070 if (checkNonEmpty(jobName)) {
01071 ((LSFBSubProcess) targetProcess).setJobname(jobName);
01072 }
01073 }
01074
01075 protected class BsubOptionHandler extends PassiveCompositeUnmarshaller {
01076
01077
01078
01079 public BsubOptionHandler() {
01080
01081 UnmarshallerHandler pathHandler = new PathHandler();
01082 this.addHandler(HOST_LIST_TAG, new SingleValueUnmarshaller());
01083 this.addHandler(PROCESSOR_TAG, new SingleValueUnmarshaller());
01084 this.addHandler(RES_REQ_TAG, new SimpleValueHandler());
01085
01086 BasicUnmarshallerDecorator bch = new BasicUnmarshallerDecorator();
01087 bch.addHandler(ABS_PATH_TAG, pathHandler);
01088 bch.addHandler(REL_PATH_TAG, pathHandler);
01089 this.addHandler(SCRIPT_PATH_TAG, bch);
01090 }
01091
01092 public void startContextElement(String name, Attributes attributes)
01093 throws org.xml.sax.SAXException {
01094 }
01095
01096 protected void notifyEndActiveHandler(String name,
01097 UnmarshallerHandler activeHandler)
01098 throws org.xml.sax.SAXException {
01099
01100
01101 LSFBSubProcess bSubProcess = (LSFBSubProcess) targetProcess;
01102
01103 if (name.equals(HOST_LIST_TAG)) {
01104 bSubProcess.setHostList((String) activeHandler.getResultObject());
01105 } else if (name.equals(PROCESSOR_TAG)) {
01106 bSubProcess.setProcessorNumber((String) activeHandler.getResultObject());
01107 } else if (name.equals(RES_REQ_TAG)) {
01108 bSubProcess.setRes_requirement((String) activeHandler.getResultObject());
01109 } else if (name.equals(SCRIPT_PATH_TAG)) {
01110 bSubProcess.setScriptLocation((String) activeHandler.getResultObject());
01111 } else {
01112 super.notifyEndActiveHandler(name, activeHandler);
01113 }
01114 }
01115 }
01116
01117
01118 }
01119
01120
01121 protected class GlobusProcessHandler extends ProcessHandler {
01122 public GlobusProcessHandler(ProActiveDescriptor proActiveDescriptor) {
01123 super(proActiveDescriptor);
01124 this.addHandler(GLOBUS_OPTIONS_TAG, new GlobusOptionHandler());
01125 }
01126
01127 protected class GlobusOptionHandler extends PassiveCompositeUnmarshaller {
01128 public GlobusOptionHandler() {
01129 this.addHandler(COUNT_TAG, new SingleValueUnmarshaller());
01130 this.addHandler(GLOBUS_MAXTIME_TAG,
01131 new SingleValueUnmarshaller());
01132 this.addHandler(OUTPUT_FILE, new SingleValueUnmarshaller());
01133 this.addHandler(ERROR_FILE, new SingleValueUnmarshaller());
01134 }
01135
01136 public void startContextElement(String name, Attributes attributes)
01137 throws org.xml.sax.SAXException {
01138 }
01139
01140 protected void notifyEndActiveHandler(String name,
01141 UnmarshallerHandler activeHandler)
01142 throws org.xml.sax.SAXException {
01143
01144
01145 GlobusProcess globusProcess = (GlobusProcess) targetProcess;
01146
01147 if (name.equals(COUNT_TAG)) {
01148 globusProcess.setCount((String) activeHandler.getResultObject());
01149 } else if (name.equals(GLOBUS_MAXTIME_TAG)) {
01150 globusProcess.setMaxTime((String) activeHandler.getResultObject());
01151 } else if (name.equals(OUTPUT_FILE)) {
01152 globusProcess.setStdout((String) activeHandler.getResultObject());
01153 } else if (name.equals(ERROR_FILE)) {
01154 globusProcess.setStderr((String) activeHandler.getResultObject());
01155 } else {
01156 super.notifyEndActiveHandler(name, activeHandler);
01157 }
01158 }
01159 }
01160
01161
01162 }
01163
01164 protected class GLiteProcessHandler extends ProcessHandler {
01165 protected Object resultObject = null;
01166
01167 public GLiteProcessHandler(ProActiveDescriptor proActiveDescriptor) {
01168 super(proActiveDescriptor);
01169 UnmarshallerHandler pathHandler = new PathHandler();
01170 BasicUnmarshallerDecorator bch = new BasicUnmarshallerDecorator();
01171 bch.addHandler(ABS_PATH_TAG, pathHandler);
01172 bch.addHandler(REL_PATH_TAG, pathHandler);
01173 this.addHandler(GLITE_CONFIG_TAG, bch);
01174 this.addHandler(GLITE_ENVIRONMENT_TAG, new SingleValueUnmarshaller());
01175 this.addHandler(GLITE_REQUIREMENTS_TAG,
01176 new SingleValueUnmarshaller());
01177 this.addHandler(GLITE_INPUTDATA_TAG, new GLiteInputDataHandler());
01178 this.addHandler(GLITE_RANK_TAG, new SingleValueUnmarshaller());
01179 this.addHandler(GLITE_PROCESS_OPTIONS_TAG, new GLiteOptionHandler());
01180 }
01181
01182 public void setResultObject(Object obj) {
01183 try {
01184 resultObject = obj;
01185 } catch (Exception e) {
01186 e.printStackTrace();
01187 }
01188 }
01189
01190 public Object getResultObject() throws org.xml.sax.SAXException {
01191 setResultObject(targetProcess);
01192 return resultObject;
01193 }
01194
01195 public void startContextElement(String name, Attributes attributes)
01196 throws org.xml.sax.SAXException {
01197 super.startContextElement(name, attributes);
01198
01199 try {
01200 String type = (attributes.getValue("Type"));
01201 if (checkNonEmpty(type)) {
01202 ((GLiteProcess) targetProcess).setJobType(type);
01203 }
01204 String jobJobType = (attributes.getValue("jobType"));
01205 if (checkNonEmpty(type)) {
01206 ((GLiteProcess) targetProcess).setJobJobType(jobJobType);
01207 }
01208 String jdlFile = (attributes.getValue("JDLFileName"));
01209 if (checkNonEmpty(jdlFile)) {
01210 ((GLiteProcess) targetProcess).setFileName(jdlFile);
01211 }
01212 String hostname = (attributes.getValue("hostname"));
01213 if (checkNonEmpty(hostname)) {
01214 ((GLiteProcess) targetProcess).setNetServer(hostname);
01215 }
01216 String executable = (attributes.getValue("executable"));
01217 if (checkNonEmpty(executable)) {
01218 ((GLiteProcess) targetProcess).setJobExecutable(executable);
01219 ((GLiteProcess) targetProcess).setCommand_path(executable);
01220 }
01221 String stdOutput = (attributes.getValue("stdOutput"));
01222 if (checkNonEmpty(stdOutput)) {
01223 ((GLiteProcess) targetProcess).setJobStdOutput(stdOutput);
01224 }
01225 String stdInput = (attributes.getValue("stdInput"));
01226 if (checkNonEmpty(stdInput)) {
01227 ((GLiteProcess) targetProcess).setJobStdInput(stdInput);
01228 }
01229 String stdError = (attributes.getValue("stdError"));
01230 if (checkNonEmpty(stdError)) {
01231 ((GLiteProcess) targetProcess).setJobStdError(stdError);
01232 }
01233 String outputse = (attributes.getValue("outputse"));
01234 if (checkNonEmpty(outputse)) {
01235 ((GLiteProcess) targetProcess).setJobOutput_se(outputse);
01236 }
01237 String virtualOrganisation = (attributes.getValue(
01238 "virtualOrganisation"));
01239 if (checkNonEmpty(virtualOrganisation)) {
01240 ((GLiteProcess) targetProcess).setJobVO(virtualOrganisation);
01241 }
01242 String retryCount = (attributes.getValue("retryCount"));
01243 if (checkNonEmpty(retryCount)) {
01244 ((GLiteProcess) targetProcess).setJobRetryCount(retryCount);
01245 }
01246 String myProxyServer = (attributes.getValue("myProxyServer"));
01247 if (checkNonEmpty(myProxyServer)) {
01248 ((GLiteProcess) targetProcess).setJobMyProxyServer(myProxyServer);
01249 }
01250 String nodeNumber = (attributes.getValue("nodeNumber"));
01251 if (checkNonEmpty(nodeNumber)) {
01252 ((GLiteProcess) targetProcess).setJobNodeNumber(Integer.parseInt(
01253 nodeNumber));
01254 }
01255 } catch (IllegalArgumentException e) {
01256 e.printStackTrace();
01257 } catch (Exception e) {
01258 e.printStackTrace();
01259 }
01260 }
01261
01262 protected void notifyEndActiveHandler(String name,
01263 UnmarshallerHandler activeHandler) throws org.xml.sax.SAXException {
01264 try {
01265 if (name.equals(GLITE_CONFIG_TAG)) {
01266 ((GLiteProcess) targetProcess).setConfigFile((String) activeHandler.getResultObject());
01267 }
01268 if (name.equals(GLITE_ENVIRONMENT_TAG)) {
01269 String value = (String) activeHandler.getResultObject();
01270 ((GLiteProcess) targetProcess).setJobEnvironment(value);
01271 } else if (name.equals(GLITE_REQUIREMENTS_TAG)) {
01272 String value = (String) activeHandler.getResultObject();
01273 ((GLiteProcess) targetProcess).setJobRequirements(value);
01274 } else if (name.equals(GLITE_RANK_TAG)) {
01275 String value = (String) activeHandler.getResultObject();
01276 ((GLiteProcess) targetProcess).setJobRank(value);
01277 } else {
01278 super.notifyEndActiveHandler(name, activeHandler);
01279 }
01280 } catch (IllegalArgumentException e) {
01281 e.printStackTrace();
01282 } catch (Exception e) {
01283 e.printStackTrace();
01284 }
01285 }
01286
01287 protected class GLiteInputDataHandler
01288 extends PassiveCompositeUnmarshaller {
01289 public GLiteInputDataHandler() {
01290 super();
01291 }
01292
01293 public void startContextElement(String name, Attributes attributes)
01294 throws org.xml.sax.SAXException {
01295 super.startContextElement(name, attributes);
01296
01297 try {
01298 String dataAccessProtocol = (attributes.getValue(
01299 "dataAccessProtocol"));
01300 if (checkNonEmpty(dataAccessProtocol)) {
01301 ((GLiteProcess) targetProcess).setJobDataAccessProtocol(dataAccessProtocol);
01302 }
01303 String storageIndex = (attributes.getValue("storageIndex"));
01304 if (checkNonEmpty(storageIndex)) {
01305 ((GLiteProcess) targetProcess).setJobStorageIndex(storageIndex);
01306 }
01307
01308
01309
01310
01311
01312 } catch (IllegalArgumentException e) {
01313 e.printStackTrace();
01314 } catch (Exception e) {
01315 e.printStackTrace();
01316 }
01317 }
01318
01319 protected void notifyEndActiveHandler(String name,
01320 UnmarshallerHandler activeHandler)
01321 throws org.xml.sax.SAXException {
01322 }
01323 }
01324
01325 protected class GLiteRankHandler extends PassiveCompositeUnmarshaller {
01326 public GLiteRankHandler() {
01327 super();
01328 }
01329
01330 public void startContextElement(String name, Attributes attributes)
01331 throws org.xml.sax.SAXException {
01332 super.startContextElement(name, attributes);
01333
01334 try {
01335 String fuzzyrank = (attributes.getValue("fuzzyrank"));
01336 if (checkNonEmpty(fuzzyrank)) {
01337 ((GLiteProcess) targetProcess).setJobFuzzyRank(fuzzyrank);
01338 }
01339 } catch (IllegalArgumentException e) {
01340 e.printStackTrace();
01341 } catch (Exception e) {
01342 e.printStackTrace();
01343 }
01344 }
01345
01346 protected void notifyEndActiveHandler(String name,
01347 UnmarshallerHandler activeHandler)
01348 throws org.xml.sax.SAXException {
01349 }
01350 }
01351
01352 protected class GLiteOptionHandler extends PassiveCompositeUnmarshaller {
01353 public GLiteOptionHandler() {
01354 UnmarshallerHandler pathHandler = new PathHandler();
01355 BasicUnmarshallerDecorator bch = new BasicUnmarshallerDecorator();
01356 bch.addHandler(ABS_PATH_TAG, pathHandler);
01357 bch.addHandler(REL_PATH_TAG, pathHandler);
01358 this.addHandler(GLITE_PATH_TAG, bch);
01359 this.addHandler(GLITE_CONFIG_TAG, bch);
01360 this.addHandler(GLITE_REMOTE_PATH_TAG, bch);
01361 this.addHandler(GLITE_INPUTSANDBOX_TAG,
01362 new SingleValueUnmarshaller());
01363 this.addHandler(GLITE_OUTPUTSANDBOX_TAG,
01364 new SingleValueUnmarshaller());
01365 this.addHandler(GLITE_ARGUMENTS_TAG,
01366 new SingleValueUnmarshaller());
01367 }
01368
01369 public void startContextElement(String name, Attributes attributes)
01370 throws org.xml.sax.SAXException {
01371 }
01372
01373 protected void notifyEndActiveHandler(String name,
01374 UnmarshallerHandler activeHandler)
01375 throws org.xml.sax.SAXException {
01376 try {
01377 if (name.equals(GLITE_PATH_TAG)) {
01378 ((GLiteProcess) targetProcess).setFilePath((String) activeHandler.getResultObject());
01379 } else if (name.equals(GLITE_REMOTE_PATH_TAG)) {
01380 ((GLiteProcess) targetProcess).setRemoteFilePath((String) activeHandler.getResultObject());
01381 ((GLiteProcess) targetProcess).setJdlRemote(true);
01382 } else if (name.equals(GLITE_CONFIG_TAG)) {
01383 ((GLiteProcess) targetProcess).setConfigFile((String) activeHandler.getResultObject());
01384 ((GLiteProcess) targetProcess).setConfigFileOption(true);
01385 } else if (name.equals(GLITE_INPUTSANDBOX_TAG)) {
01386 String sandbox = (String) activeHandler.getResultObject();
01387 StringTokenizer st = new StringTokenizer(sandbox);
01388 while (st.hasMoreTokens()) {
01389 ((GLiteProcess) targetProcess).addInputSBEntry(st.nextToken());
01390 }
01391 } else if (name.equals(GLITE_OUTPUTSANDBOX_TAG)) {
01392 String sandbox = (String) activeHandler.getResultObject();
01393 StringTokenizer st = new StringTokenizer(sandbox);
01394 while (st.hasMoreTokens()) {
01395 ((GLiteProcess) targetProcess).addOutputSBEntry(st.nextToken());
01396 }
01397 } else if (name.equals(GLITE_ARGUMENTS_TAG)) {
01398 String value = (String) activeHandler.getResultObject();
01399 ((GLiteProcess) targetProcess).setJobArgument(value);
01400 } else {
01401 super.notifyEndActiveHandler(name, activeHandler);
01402 }
01403 } catch (IllegalArgumentException e) {
01404 e.printStackTrace();
01405 } catch (Exception e) {
01406 e.printStackTrace();
01407 }
01408 }
01409 }
01410 }
01411
01412
01413 protected class UnicoreProcessHandler extends ProcessHandler {
01414 public UnicoreProcessHandler(ProActiveDescriptor proActiveDescriptor) {
01415 super(proActiveDescriptor);
01416 this.addHandler(UNICORE_OPTIONS_TAG, new UnicoreOptionHandler());
01417
01418 UnmarshallerHandler pathHandler = new PathHandler();
01419 BasicUnmarshallerDecorator bch = new BasicUnmarshallerDecorator();
01420 bch.addHandler(ABS_PATH_TAG, pathHandler);
01421 bch.addHandler(REL_PATH_TAG, pathHandler);
01422 this.addHandler(UNICORE_DIR_PATH_TAG, bch);
01423
01424 pathHandler = new PathHandler();
01425 bch = new BasicUnmarshallerDecorator();
01426 bch.addHandler(ABS_PATH_TAG, pathHandler);
01427 bch.addHandler(REL_PATH_TAG, pathHandler);
01428 this.addHandler(UNICORE_KEYFILE_PATH_TAG, bch);
01429
01430 CollectionUnmarshaller cu = new CollectionUnmarshaller(String.class);
01431 cu.addHandler(ABS_PATH_TAG, pathHandler);
01432 cu.addHandler(REL_PATH_TAG, pathHandler);
01433
01434
01435 }
01436
01437 public void startContextElement(String name, Attributes attributes)
01438 throws org.xml.sax.SAXException {
01439 super.startContextElement(name, attributes);
01440
01441 String jobName = (attributes.getValue("jobname"));
01442
01443 if (checkNonEmpty(jobName)) {
01444 ((UnicoreProcess) targetProcess).uParam.setUsiteName(jobName);
01445 }
01446
01447 String keyPassword = (attributes.getValue("keypassword"));
01448
01449 if (checkNonEmpty(keyPassword)) {
01450 ((UnicoreProcess) targetProcess).uParam.setKeyPassword(keyPassword);
01451 }
01452
01453 String submitJob = (attributes.getValue("submitjob"));
01454
01455 if (checkNonEmpty(submitJob)) {
01456 ((UnicoreProcess) targetProcess).uParam.setSubmitJob(submitJob);
01457 }
01458
01459 String saveJob = (attributes.getValue("savejob"));
01460
01461 if (checkNonEmpty(saveJob)) {
01462 ((UnicoreProcess) targetProcess).uParam.setSaveJob(saveJob);
01463 }
01464 }
01465
01466 protected void notifyEndActiveHandler(String name,
01467 UnmarshallerHandler activeHandler) throws org.xml.sax.SAXException {
01468 if (name.equals(UNICORE_DIR_PATH_TAG)) {
01469 ((UnicoreProcess) targetProcess).uParam.setUnicoreDir((String) activeHandler.getResultObject());
01470 } else if (name.equals(UNICORE_KEYFILE_PATH_TAG)) {
01471 ((UnicoreProcess) targetProcess).uParam.setKeyFilePath((String) activeHandler.getResultObject());
01472 } else {
01473 super.notifyEndActiveHandler(name, activeHandler);
01474 }
01475 }
01476
01477 protected class UnicoreOptionHandler
01478 extends PassiveCompositeUnmarshaller {
01479 public UnicoreOptionHandler() {
01480 this.addHandler(UNICORE_USITE_TAG, new UsiteHandler());
01481 this.addHandler(UNICORE_VSITE_TAG, new VsiteHandler());
01482 }
01483
01484 public void startContextElement(String name, Attributes attributes)
01485 throws org.xml.sax.SAXException {
01486 }
01487
01488
01489
01490
01491
01492
01493
01494
01495
01496
01497
01498
01499
01500
01501
01502 }
01503
01504 protected class UsiteHandler extends PassiveCompositeUnmarshaller {
01505 public UsiteHandler() {
01506 }
01507
01508 public void startContextElement(String name, Attributes attributes)
01509 throws org.xml.sax.SAXException {
01510 super.startContextElement(name, attributes);
01511
01512 String usiteName = (attributes.getValue("name"));
01513
01514 if (checkNonEmpty(usiteName)) {
01515 ((UnicoreProcess) targetProcess).uParam.setUsiteName(usiteName);
01516 }
01517
01518 String type = (attributes.getValue("type"));
01519
01520 if (checkNonEmpty(type)) {
01521 ((UnicoreProcess) targetProcess).uParam.setUsiteType(type);
01522 }
01523
01524 String url = (attributes.getValue("url"));
01525
01526 if (checkNonEmpty(url)) {
01527 ((UnicoreProcess) targetProcess).uParam.setUsiteUrl(url);
01528 }
01529 }
01530 }
01531
01532 protected class VsiteHandler extends PassiveCompositeUnmarshaller {
01533 public VsiteHandler() {
01534 }
01535
01536 public void startContextElement(String name, Attributes attributes)
01537 throws org.xml.sax.SAXException {
01538 super.startContextElement(name, attributes);
01539
01540 String vsiteName = (attributes.getValue("name"));
01541
01542 if (checkNonEmpty(vsiteName)) {
01543 ((UnicoreProcess) targetProcess).uParam.setVsiteName(vsiteName);
01544 }
01545
01546 String nodes = (attributes.getValue("nodes"));
01547
01548 if (checkNonEmpty(nodes)) {
01549 ((UnicoreProcess) targetProcess).uParam.setVsiteNodes(Integer.parseInt(
01550 nodes));
01551 }
01552
01553 String processors = (attributes.getValue("processors"));
01554
01555 if (checkNonEmpty(processors)) {
01556 ((UnicoreProcess) targetProcess).uParam.setVsiteProcessors(Integer.parseInt(
01557 processors));
01558 }
01559
01560 String memory = (attributes.getValue("memory"));
01561
01562 if (checkNonEmpty(memory)) {
01563 ((UnicoreProcess) targetProcess).uParam.setVsiteMemory(Integer.parseInt(
01564 memory));
01565 }
01566
01567 String runtime = (attributes.getValue("runtime"));
01568
01569 if (checkNonEmpty(runtime)) {
01570 ((UnicoreProcess) targetProcess).uParam.setVsiteRuntime(Integer.parseInt(
01571 runtime));
01572 }
01573
01574 String priority = (attributes.getValue("priority"));
01575
01576 if (checkNonEmpty(priority)) {
01577 ((UnicoreProcess) targetProcess).uParam.setVsitePriority(priority);
01578 }
01579 }
01580 }
01581 }
01582
01583
01584 protected class NGProcessHandler extends ProcessHandler {
01585 public NGProcessHandler(ProActiveDescriptor proActiveDescriptor) {
01586 super(proActiveDescriptor);
01587 this.addHandler(NG_OPTIONS_TAG, new NGOptionHandler());
01588 }
01589
01590 public void startContextElement(String name, Attributes attributes)
01591 throws org.xml.sax.SAXException {
01592 super.startContextElement(name, attributes);
01593 String jobname = (attributes.getValue("jobname"));
01594 if (checkNonEmpty(jobname)) {
01595 ((NGProcess) targetProcess).setJobname(jobname);
01596 }
01597
01598 String queueName = (attributes.getValue("queue"));
01599 if (checkNonEmpty(queueName)) {
01600 ((NGProcess) targetProcess).setQueue(queueName);
01601 }
01602 }
01603
01604 protected class NGOptionHandler extends PassiveCompositeUnmarshaller {
01605 public NGOptionHandler() {
01606 this.addHandler(COUNT_TAG, new SingleValueUnmarshaller());
01607 this.addHandler(OUTPUT_FILE, new SingleValueUnmarshaller());
01608 this.addHandler(ERROR_FILE, new SingleValueUnmarshaller());
01609 BasicUnmarshallerDecorator bch = new BasicUnmarshallerDecorator();
01610 UnmarshallerHandler pathHandler = new PathHandler();
01611 bch.addHandler(ABS_PATH_TAG, pathHandler);
01612 bch.addHandler(REL_PATH_TAG, pathHandler);
01613 this.addHandler(EXECUTABLE_TAG, bch);
01614 }
01615
01616 public void startContextElement(String name, Attributes attributes)
01617 throws org.xml.sax.SAXException {
01618 }
01619
01620 protected void notifyEndActiveHandler(String name,
01621 UnmarshallerHandler activeHandler)
01622 throws org.xml.sax.SAXException {
01623
01624
01625 NGProcess ngProcess = (NGProcess) targetProcess;
01626
01627 if (name.equals(COUNT_TAG)) {
01628 ngProcess.setCount((String) activeHandler.getResultObject());
01629 } else if (name.equals(OUTPUT_FILE)) {
01630 ngProcess.setStdout((String) activeHandler.getResultObject());
01631 } else if (name.equals(ERROR_FILE)) {
01632 ngProcess.setStderr((String) activeHandler.getResultObject());
01633 } else if (name.equals(EXECUTABLE_TAG)) {
01634 ngProcess.setExecutable((String) activeHandler.getResultObject());
01635 } else {
01636 super.notifyEndActiveHandler(name, activeHandler);
01637 }
01638 }
01639 }
01640 }
01641
01642
01643 protected class MPIProcessHandler extends ProcessHandler {
01644 public MPIProcessHandler(ProActiveDescriptor proActiveDescriptor) {
01645 super(proActiveDescriptor);
01646 this.addHandler(MPI_PROCESS_OPTIONS_TAG, new MPIOptionHandler());
01647 }
01648
01649 public void startContextElement(String name, Attributes attributes)
01650 throws org.xml.sax.SAXException {
01651 super.startContextElement(name, attributes);
01652
01653 try {
01654 String mpiFileName = (attributes.getValue("mpiFileName"));
01655 if (checkNonEmpty(mpiFileName)) {
01656 ((MPIProcess) targetProcess).setMpiFileName(mpiFileName);
01657 }
01658 String hostsFileName = (attributes.getValue("hostsFileName"));
01659 if (checkNonEmpty(hostsFileName)) {
01660 ((MPIProcess) targetProcess).setHostsFileName(hostsFileName);
01661 }
01662 String mpiCommandOptions = (attributes.getValue(
01663 "mpiCommandOptions"));
01664 if (checkNonEmpty(mpiCommandOptions)) {
01665 ((MPIProcess) targetProcess).setMpiCommandOptions(mpiCommandOptions);
01666 }
01667 } catch (IllegalArgumentException e) {
01668 e.printStackTrace();
01669 } catch (Exception e) {
01670 e.printStackTrace();
01671 }
01672 }
01673
01674 protected void notifyEndActiveHandler(String name,
01675 UnmarshallerHandler activeHandler) throws SAXException {
01676 super.notifyEndActiveHandler(name, activeHandler);
01677 }
01678
01679 protected class MPIOptionHandler extends PassiveCompositeUnmarshaller {
01680 public MPIOptionHandler() {
01681 UnmarshallerHandler pathHandler = new PathHandler();
01682 BasicUnmarshallerDecorator bch = new BasicUnmarshallerDecorator();
01683 bch.addHandler(ABS_PATH_TAG, pathHandler);
01684 bch.addHandler(REL_PATH_TAG, pathHandler);
01685 this.addHandler(MPI_LOCAL_PATH_TAG, bch);
01686 this.addHandler(MPI_REMOTE_PATH_TAG, bch);
01687 this.addHandler(PROCESS_NUMBER_TAG,
01688 new SingleValueUnmarshaller());
01689 }
01690
01691 public void startContextElement(String name, Attributes attributes)
01692 throws org.xml.sax.SAXException {
01693 }
01694
01695 protected void notifyEndActiveHandler(String name,
01696 UnmarshallerHandler activeHandler)
01697 throws org.xml.sax.SAXException {
01698 try {
01699 if (name.equals(MPI_LOCAL_PATH_TAG)) {
01700 ((MPIProcess) targetProcess).setLocalPath((String) activeHandler.getResultObject());
01701 } else if (name.equals(MPI_REMOTE_PATH_TAG)) {
01702 ((MPIProcess) targetProcess).setRemotePath((String) activeHandler.getResultObject());
01703 } else if (name.equals(PROCESS_NUMBER_TAG)) {
01704 ((MPIProcess) targetProcess).setHostsNumber((String) activeHandler.getResultObject());
01705 } else {
01706 super.notifyEndActiveHandler(name, activeHandler);
01707 }
01708 } catch (IllegalArgumentException e) {
01709 e.printStackTrace();
01710 } catch (Exception e) {
01711 e.printStackTrace();
01712 }
01713 }
01714 }
01715 }
01716
01717
01718 public class DependentProcessSequenceHandler
01719 extends AbstractUnmarshallerDecorator
01720 implements ProActiveDescriptorConstants {
01721 protected ProActiveDescriptor proActiveDescriptor;
01722 protected boolean isRef;
01723
01724 public DependentProcessSequenceHandler(
01725 ProActiveDescriptor proActiveDescriptor) {
01726 super();
01727 this.proActiveDescriptor = proActiveDescriptor;
01728 this.addHandler(PROCESS_REFERENCE_TAG, new ProcessReferenceHandler());
01729 this.addHandler(SERVICE_REFERENCE_TAG, new ProcessReferenceHandler());
01730 }
01731
01732 public void startContextElement(String name, Attributes attributes)
01733 throws org.xml.sax.SAXException {
01734 String className = attributes.getValue("class");
01735
01736 if (!checkNonEmpty(className)) {
01737 throw new org.xml.sax.SAXException(
01738 "Process defined without specifying the class");
01739 }
01740
01741 try {
01742 targetProcess = proActiveDescriptor.createProcess(id, className);
01743 } catch (ProActiveException e) {
01744
01745 e.printStackTrace();
01746 }
01747 }
01748
01749
01750 public Object getResultObject() throws org.xml.sax.SAXException {
01751 return null;
01752 }
01753
01754
01755 protected void notifyEndActiveHandler(String name,
01756 UnmarshallerHandler activeHandler) throws org.xml.sax.SAXException {
01757 if (name.equals(PROCESS_REFERENCE_TAG)) {
01758 DependentListProcess dep = (DependentListProcess) targetProcess;
01759 Object result = activeHandler.getResultObject();
01760 proActiveDescriptor.addProcessToSequenceList(dep,
01761 (String) result);
01762 }
01763 if (name.equals(SERVICE_REFERENCE_TAG)) {
01764 DependentListProcess dep = (DependentListProcess) targetProcess;
01765 Object result = activeHandler.getResultObject();
01766
01767 proActiveDescriptor.addServiceToSequenceList(dep,
01768 (String) result);
01769 }
01770 }
01771 }
01772
01773
01774 public class SequentialProcessHandler extends AbstractUnmarshallerDecorator
01775 implements ProActiveDescriptorConstants {
01776 protected ProActiveDescriptor proActiveDescriptor;
01777 protected boolean isRef;
01778
01779 public SequentialProcessHandler(ProActiveDescriptor proActiveDescriptor) {
01780 super();
01781 this.proActiveDescriptor = proActiveDescriptor;
01782 this.addHandler(PROCESS_REFERENCE_TAG, new ProcessReferenceHandler());
01783 }
01784
01785 public void startContextElement(String name, Attributes attributes)
01786 throws org.xml.sax.SAXException {
01787 String className = attributes.getValue("class");
01788
01789 if (!checkNonEmpty(className)) {
01790 throw new org.xml.sax.SAXException(
01791 "Process defined without specifying the class");
01792 }
01793
01794 try {
01795 targetProcess = proActiveDescriptor.createProcess(id, className);
01796 } catch (ProActiveException e) {
01797
01798 e.printStackTrace();
01799 }
01800 }
01801
01802
01803 public Object getResultObject() throws org.xml.sax.SAXException {
01804 return null;
01805 }
01806
01807
01808 protected void notifyEndActiveHandler(String name,
01809 UnmarshallerHandler activeHandler) throws org.xml.sax.SAXException {
01810 if (name.equals(PROCESS_REFERENCE_TAG)) {
01811 IndependentListProcess dep = (IndependentListProcess) targetProcess;
01812 Object result = activeHandler.getResultObject();
01813 proActiveDescriptor.addProcessToSequenceList(dep,
01814 (String) result);
01815 }
01816 }
01817 }
01818
01819
01820 private class SimpleValueHandler extends BasicUnmarshaller {
01821 public void startContextElement(String name, Attributes attributes)
01822 throws org.xml.sax.SAXException {
01823
01824 String value = attributes.getValue("value");
01825
01826 setResultObject(value);
01827 }
01828 }
01829 }