~ubuntu-branches/ubuntu/utopic/gridengine/utopic

« back to all changes in this revision

Viewing changes to source/libs/jdrmaa/src/org/ggf/drmaa/SimpleJobTemplate.java

  • Committer: Bazaar Package Importer
  • Author(s): Mark Hymers
  • Date: 2008-06-25 22:36:13 UTC
  • Revision ID: james.westby@ubuntu.com-20080625223613-tvd9xlhuoct9kyhm
Tags: upstream-6.2~beta2
ImportĀ upstreamĀ versionĀ 6.2~beta2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*___INFO__MARK_BEGIN__*/
 
2
/*************************************************************************
 
3
 *
 
4
 *  The Contents of this file are made available subject to the terms of
 
5
 *  the Sun Industry Standards Source License Version 1.2
 
6
 *
 
7
 *  Sun Microsystems Inc., March, 2001
 
8
 *
 
9
 *
 
10
 *  Sun Industry Standards Source License Version 1.2
 
11
 *  =================================================
 
12
 *  The contents of this file are subject to the Sun Industry Standards
 
13
 *  Source License Version 1.2 (the "License"); You may not use this file
 
14
 *  except in compliance with the License. You may obtain a copy of the
 
15
 *  License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
 
16
 *
 
17
 *  Software provided under this License is provided on an "AS IS" basis,
 
18
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 
19
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 
20
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 
21
 *  See the License for the specific provisions governing your rights and
 
22
 *  obligations concerning the Software.
 
23
 *
 
24
 *   The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 
25
 *
 
26
 *   Copyright: 2001 by Sun Microsystems, Inc.
 
27
 *
 
28
 *   All Rights Reserved.
 
29
 *
 
30
 ************************************************************************/
 
31
/*___INFO__MARK_END__*/
 
32
package org.ggf.drmaa;
 
33
 
 
34
import java.io.Serializable;
 
35
import java.util.ArrayList;
 
36
import java.util.Arrays;
 
37
import java.util.Collections;
 
38
import java.util.HashMap;
 
39
import java.util.HashSet;
 
40
import java.util.Iterator;
 
41
import java.util.List;
 
42
import java.util.Map;
 
43
import java.util.Properties;
 
44
import java.util.Set;
 
45
 
 
46
/**
 
47
 * This class is a trivial implementation of the JobTemplate interface.  This
 
48
 * class can either be used as the base class for a implementation-specific
 
49
 * job template class, or for implementations which do not need more than the
 
50
 * required properties, it can be used as the job template implementation
 
51
 * directly.
 
52
 *
 
53
 * <p>All non-primitive properties default to <code>null</code>.  All boolean
 
54
 * properties default to <code>false</code>.  All other primitive properties
 
55
 * default to zero.</p>
 
56
 *
 
57
 * <p>The SimpleJobTemplate class is not thread safe.  No attempt is made to
 
58
 * prevent setters and getters from interfering with each other or the
 
59
 * toString() method.</p>
 
60
 *
 
61
 * @author dan.templeton@sun.com
 
62
 * @see JobTemplate
 
63
 * @since 1.0
 
64
 */
 
65
public class SimpleJobTemplate implements JobTemplate, Serializable {
 
66
    private String toString = null;
 
67
    private Set allPropertyNames = null;
 
68
    private boolean modified = true;
 
69
    /**
 
70
     * Remote command to execute
 
71
     * @see JobTemplate#setRemoteCommand(String)
 
72
     */
 
73
    protected String remoteCommand = null;
 
74
    /**
 
75
     * Input parameters passed as arguments to the job
 
76
     * @see JobTemplate#setArgs(List)
 
77
     */
 
78
    protected List args = null;
 
79
    /**
 
80
     * Job state at submission, either HOLD or ACTIVE
 
81
     * @see JobTemplate#setJobSubmissionState(int)
 
82
     */
 
83
    protected int jobSubmissionState = ACTIVE_STATE;
 
84
    /**
 
85
     * The environment values that define the job's remote environment
 
86
     * @see JobTemplate#setJobEnvironment(Map)
 
87
     */
 
88
    protected Map jobEnvironment = null;
 
89
    /**
 
90
     * The directory where the job is executed.
 
91
     * @see JobTemplate#setWorkingDirectory(String)
 
92
     */
 
93
    protected String workingDirectory = null;
 
94
    /**
 
95
     * An implementation-defined string specifying how to resolve site-specific
 
96
     * resources and/or policies
 
97
     * @see JobTemplate#setJobCategory(String)
 
98
     */
 
99
    protected String jobCategory = null;
 
100
    /**
 
101
     * An implementation-defined string that is passed by the end user to DRMAA
 
102
     * to specify site-specific resources and/or policies
 
103
     * @see JobTemplate#setNativeSpecification(String)
 
104
     */
 
105
    protected String nativeSpecification = null;
 
106
    /**
 
107
     * E-mail addresses used to report the job completion and status
 
108
     * @see JobTemplate#setEmail(Set)
 
109
     */
 
110
    protected Set email = null;
 
111
    /**
 
112
     * Blocks sending e-mail by default, regardless of the DRMS setting
 
113
     * @see JobTemplate#setBlockEmail(boolean)
 
114
     */
 
115
    protected boolean blockEmail = false;
 
116
    /**
 
117
     * The earliest time when the job may be eligible to be run
 
118
     * @see JobTemplate#setStartTime(PartialTimestamp)
 
119
     */
 
120
    protected PartialTimestamp startTime = null;
 
121
    /**
 
122
     * Job name
 
123
     * @see JobTemplate#setJobName(String)
 
124
     */
 
125
    protected String jobName = null;
 
126
    /**
 
127
     * The job's standard input stream
 
128
     * @see JobTemplate#setInputPath(String)
 
129
     */
 
130
    protected String inputPath = null;
 
131
    /**
 
132
     * The job's standard output stream
 
133
     * @see JobTemplate#setOutputPath(String)
 
134
     */
 
135
    protected String outputPath = null;
 
136
    /**
 
137
     * The job's standard error stream
 
138
     * @see JobTemplate#setErrorPath(String)
 
139
     */
 
140
    protected String errorPath = null;
 
141
    /**
 
142
     * Whether the error stream should be intermixed with the output stream
 
143
     * @see JobTemplate#setJoinFiles(boolean)
 
144
     */
 
145
    protected boolean joinFiles = false;
 
146
    
 
147
    /**
 
148
     * Create a new instance of a JobTemplate.
 
149
     */
 
150
    public SimpleJobTemplate() {
 
151
    }
 
152
    
 
153
    public void setRemoteCommand(String remoteCommand) throws DrmaaException {
 
154
        this.remoteCommand = remoteCommand;
 
155
        modified = true;
 
156
    }
 
157
    
 
158
    public String getRemoteCommand() throws DrmaaException {
 
159
        return remoteCommand;
 
160
    }
 
161
    
 
162
    public void setArgs(List args) throws DrmaaException {
 
163
        if (args != null) {
 
164
            this.args = new ArrayList(args);
 
165
        } else {
 
166
            this.args = null;
 
167
        }
 
168
 
 
169
        modified = true;
 
170
    }
 
171
    
 
172
    public List getArgs() throws DrmaaException {
 
173
        List returnValue = null;
 
174
 
 
175
        if (args != null) {
 
176
            returnValue = Collections.unmodifiableList(args);
 
177
        }
 
178
 
 
179
        return returnValue;
 
180
    }
 
181
    
 
182
    public void setJobSubmissionState(int state) throws DrmaaException {
 
183
        if ((state != ACTIVE_STATE) && (state != HOLD_STATE)) {
 
184
            throw new IllegalArgumentException("Invalid state");
 
185
        }
 
186
        
 
187
        this.jobSubmissionState = state;
 
188
        modified = true;
 
189
    }
 
190
    
 
191
    public int getJobSubmissionState() throws DrmaaException {
 
192
        return jobSubmissionState;
 
193
    }
 
194
    
 
195
    public void setJobEnvironment(Map env) throws DrmaaException {
 
196
        if (env != null) {
 
197
            this.jobEnvironment = new HashMap(env);
 
198
        } else {
 
199
            this.jobEnvironment = null;
 
200
        }
 
201
 
 
202
        modified = true;
 
203
    }
 
204
    
 
205
    public Map getJobEnvironment() throws DrmaaException {
 
206
        Map returnValue = null;
 
207
 
 
208
        if (jobEnvironment != null) {
 
209
            returnValue = Collections.unmodifiableMap(jobEnvironment);
 
210
        }
 
211
 
 
212
        return returnValue;
 
213
    }
 
214
    
 
215
    public void setWorkingDirectory(String wd) throws DrmaaException {
 
216
        if (wd.indexOf(HOME_DIRECTORY) > 0) {
 
217
            throw new InvalidAttributeFormatException(HOME_DIRECTORY +
 
218
                    " may only appear at the beginning of the path.");
 
219
        } else if (wd.indexOf(WORKING_DIRECTORY) >= 0) {
 
220
            throw new InvalidAttributeFormatException(WORKING_DIRECTORY +
 
221
                    " may not be used in the workingDirectory path.");
 
222
        }
 
223
        
 
224
        this.workingDirectory = wd;
 
225
        modified = true;
 
226
    }
 
227
    
 
228
    public String getWorkingDirectory() throws DrmaaException {
 
229
        return workingDirectory;
 
230
    }
 
231
    
 
232
    public void setJobCategory(String category) throws DrmaaException {
 
233
        this.jobCategory = category;
 
234
        modified = true;
 
235
    }
 
236
    
 
237
    public String getJobCategory() throws DrmaaException {
 
238
        return jobCategory;
 
239
    }
 
240
    
 
241
    public void setNativeSpecification(String spec) throws DrmaaException {
 
242
        this.nativeSpecification = spec;
 
243
        modified = true;
 
244
    }
 
245
    
 
246
    public String getNativeSpecification() throws DrmaaException {
 
247
        return nativeSpecification;
 
248
    }
 
249
    
 
250
    public void setEmail(Set email) throws DrmaaException {
 
251
        if (email != null) {
 
252
            this.email = new HashSet(email);
 
253
        } else {
 
254
            this.email = null;
 
255
        }
 
256
 
 
257
        modified = true;
 
258
    }
 
259
    
 
260
    public Set getEmail() throws DrmaaException {
 
261
        Set returnValue = null;
 
262
 
 
263
        if (email != null) {
 
264
            returnValue = Collections.unmodifiableSet(email);
 
265
        }
 
266
 
 
267
        return returnValue;
 
268
    }
 
269
    
 
270
    public void setBlockEmail(boolean blockEmail) throws DrmaaException {
 
271
        this.blockEmail = blockEmail;
 
272
        modified = true;
 
273
    }
 
274
    
 
275
    public boolean getBlockEmail() throws DrmaaException {
 
276
        return blockEmail;
 
277
    }
 
278
    
 
279
    public void setStartTime(PartialTimestamp startTime) throws DrmaaException {
 
280
        if (startTime != null) {
 
281
            if (startTime.getTimeInMillis() < System.currentTimeMillis()) {
 
282
                throw new IllegalArgumentException("Start time is in the past.");
 
283
            }
 
284
            
 
285
            this.startTime = startTime;
 
286
        } else {
 
287
            startTime = null;
 
288
        }
 
289
 
 
290
        modified = true;
 
291
    }
 
292
    
 
293
    public PartialTimestamp getStartTime() throws DrmaaException {
 
294
        if (startTime != null) {
 
295
            return (PartialTimestamp)startTime.clone();
 
296
        } else {
 
297
            return null;
 
298
        }
 
299
    }
 
300
    
 
301
    public void setJobName(String name) throws DrmaaException {
 
302
        this.jobName = name;
 
303
        modified = true;
 
304
    }
 
305
    
 
306
    public String getJobName() throws DrmaaException {
 
307
        return jobName;
 
308
    }
 
309
    
 
310
    public void setInputPath(String inputPath) throws DrmaaException {
 
311
        this.checkPath(inputPath);
 
312
        this.inputPath = inputPath;
 
313
        modified = true;
 
314
    }
 
315
    
 
316
    public String getInputPath() throws DrmaaException {
 
317
        return inputPath;
 
318
    }
 
319
    
 
320
    public void setOutputPath(String outputPath) throws DrmaaException {
 
321
        this.checkPath(outputPath);
 
322
        this.outputPath = outputPath;
 
323
        modified = true;
 
324
    }
 
325
    
 
326
    public String getOutputPath() throws DrmaaException {
 
327
        return outputPath;
 
328
    }
 
329
    
 
330
    public void setErrorPath(String errorPath) throws DrmaaException {
 
331
        this.checkPath(errorPath);
 
332
        this.errorPath = errorPath;
 
333
        modified = true;
 
334
    }
 
335
    
 
336
    public String getErrorPath() throws DrmaaException {
 
337
        return errorPath;
 
338
    }
 
339
    
 
340
    public void setJoinFiles(boolean join) throws DrmaaException {
 
341
        this.joinFiles = join;
 
342
        modified = true;
 
343
    }
 
344
    
 
345
    public boolean getJoinFiles() throws DrmaaException {
 
346
        return joinFiles;
 
347
    }
 
348
    
 
349
    public void setTransferFiles(FileTransferMode mode) throws DrmaaException {
 
350
        throw new UnsupportedAttributeException("The transferFiles attribute " +
 
351
                                                "is not supported.");
 
352
    }
 
353
    
 
354
    public FileTransferMode getTransferFiles() throws DrmaaException {
 
355
        throw new UnsupportedAttributeException("The transferFiles attribute " +
 
356
                                                "is not supported.");
 
357
    }
 
358
    
 
359
    public void setDeadlineTime(PartialTimestamp deadline)
 
360
            throws DrmaaException {
 
361
        throw new UnsupportedAttributeException("The deadlineTime attribute " +
 
362
                                                "is not supported.");
 
363
    }
 
364
    
 
365
    public PartialTimestamp getDeadlineTime() throws DrmaaException {
 
366
        throw new UnsupportedAttributeException("The deadlineTime attribute " +
 
367
                                                "is not supported.");
 
368
    }
 
369
    
 
370
    public void setHardWallclockTimeLimit(long hardWallclockLimit)
 
371
             throws DrmaaException {
 
372
        throw new UnsupportedAttributeException("The hardWallclockTimeLimit " +
 
373
                                                "attribute is not supported.");
 
374
    }
 
375
    
 
376
    public long getHardWallclockTimeLimit() throws DrmaaException {
 
377
        throw new UnsupportedAttributeException("The hardWallclockTimeLimit " +
 
378
                                                "attribute is not supported.");
 
379
    }
 
380
    
 
381
    public void setSoftWallclockTimeLimit(long softWallclockLimit)
 
382
             throws DrmaaException {
 
383
        throw new UnsupportedAttributeException("The softWallclockTimeLimit " +
 
384
                                                "attribute is not supported.");
 
385
    }
 
386
    
 
387
    public long getSoftWallclockTimeLimit() throws DrmaaException {
 
388
        throw new UnsupportedAttributeException("The softWallclockTimeLimit " +
 
389
                                                "attribute is not supported.");
 
390
    }
 
391
    
 
392
    public void setHardRunDurationLimit(long hardRunLimit)
 
393
            throws DrmaaException {
 
394
        throw new UnsupportedAttributeException("The hardRunDurationLimit " +
 
395
                                                "attribute is not supported.");
 
396
    }
 
397
    
 
398
    public long getHardRunDurationLimit() throws DrmaaException {
 
399
        throw new UnsupportedAttributeException("The hardRunDurationLimit " +
 
400
                                                "attribute is not supported.");
 
401
    }
 
402
    
 
403
    public void setSoftRunDurationLimit(long softRunLimit)
 
404
            throws DrmaaException {
 
405
        throw new UnsupportedAttributeException("The softRunDurationLimit " +
 
406
                                                "attribute is not supported.");
 
407
    }
 
408
    
 
409
    public long getSoftRunDurationLimit() throws DrmaaException {
 
410
        throw new UnsupportedAttributeException("The softRunDurationLimit " +
 
411
                                                "attribute is not supported.");
 
412
    }
 
413
    
 
414
    public Set getAttributeNames() throws DrmaaException {
 
415
        if (allPropertyNames == null) {
 
416
            allPropertyNames = new HashSet();
 
417
            addRequiredNames(allPropertyNames);
 
418
            allPropertyNames.addAll(getOptionalAttributeNames());
 
419
        }
 
420
        
 
421
        return allPropertyNames;
 
422
    }
 
423
    
 
424
    /** This method returns the names of all optional and implementation-specific
 
425
     * properties supported by this DRMAA implementation.  Unless overridden by the
 
426
     * DRMAA implementation, this method returns an empty list.
 
427
     * This method is used by the getAttributeNames() method to construct the full list
 
428
     * of implementation-supported property names.
 
429
     * @return The names of all optional and implementation-specific
 
430
     * properties supported by this DRMAA implementation
 
431
     * @see #getAttributeNames
 
432
     */
 
433
    protected Set getOptionalAttributeNames() {
 
434
        return Collections.EMPTY_SET;
 
435
    }
 
436
 
 
437
    private static final void addRequiredNames(Set names) {
 
438
        names.add("args");
 
439
        names.add("blockEmail");
 
440
        names.add("email");
 
441
        names.add("errorPath");
 
442
        names.add("inputPath");
 
443
        names.add("jobCategory");
 
444
        names.add("jobEnvironment");
 
445
        names.add("jobName");
 
446
        names.add("jobSubmissionState");
 
447
        names.add("joinFiles");
 
448
        names.add("nativeSpecification");
 
449
        names.add("outputPath");
 
450
        names.add("remoteCommand");
 
451
        names.add("startTime");
 
452
        names.add("workingDirectory");
 
453
    }
 
454
 
 
455
    /**
 
456
     * Checks for a valid path.  Throws an InvalidArgumentException is the path
 
457
     * is not valid.
 
458
     * @param path The path to validate
 
459
     */
 
460
    private void checkPath(String path) throws IllegalArgumentException {
 
461
        /* On a null path, we just return because null paths are OK. */
 
462
        if (path == null) {
 
463
            return;
 
464
        }
 
465
        
 
466
        if (path.indexOf(HOME_DIRECTORY) > 0) {
 
467
            throw new IllegalArgumentException(HOME_DIRECTORY +
 
468
                    " may only appear at the beginning of the path.");
 
469
        }
 
470
        
 
471
        if (path.indexOf(WORKING_DIRECTORY) > 0) {
 
472
            throw new IllegalArgumentException(WORKING_DIRECTORY +
 
473
                    " may only appear at the beginning of the path.");
 
474
        }
 
475
    }
 
476
 
 
477
    /**
 
478
     * Calling this method indicates that the job template's properties have
 
479
     * been* modified since the last call to toString().  All setters should
 
480
     * call this method before returning.
 
481
     */
 
482
    protected void modified() {
 
483
        modified = true;
 
484
    }
 
485
 
 
486
    /**
 
487
     * Converts this JobTemplate into a String which contains all property
 
488
     * settings.  The generated string is then cached and reused until one of
 
489
     * the property settings is modified.
 
490
     * @return a string containing all property settings
 
491
     */
 
492
    public String toString() {
 
493
        if (modified) {
 
494
            boolean error = false;
 
495
            boolean firstProperty = true;
 
496
            StringBuffer out = new StringBuffer();
 
497
 
 
498
            List args = null;
 
499
            
 
500
            try {
 
501
                args = getArgs();
 
502
            } catch (DrmaaException e) {
 
503
                out.append("{args = <ERROR>}");
 
504
                firstProperty = false;
 
505
                error = true;
 
506
            }
 
507
 
 
508
            if ((args != null) && (args.size() > 0)) {
 
509
                Iterator i = args.iterator();
 
510
                boolean firstArg = true;
 
511
 
 
512
                out.append("{args = ");
 
513
 
 
514
                while (i.hasNext()) {
 
515
                    if (firstArg) {
 
516
                        firstArg = false;
 
517
                    } else {
 
518
                        out.append(", ");
 
519
                    }
 
520
 
 
521
                    out.append("\"");
 
522
                    out.append(i.next());
 
523
                    out.append("\"");
 
524
                }
 
525
 
 
526
                out.append("}");
 
527
                firstProperty = false;
 
528
            }
 
529
 
 
530
            if (!firstProperty) {
 
531
                out.append(" ");
 
532
            }
 
533
 
 
534
            out.append("{blockEmail = ");
 
535
 
 
536
            try {
 
537
                out.append(Boolean.toString(getBlockEmail()));
 
538
            } catch (DrmaaException e) {
 
539
                out.append("<ERROR>");
 
540
                error = true;
 
541
            }
 
542
            out.append("}");
 
543
 
 
544
            try {
 
545
                if (getDeadlineTime() != null) {
 
546
                    PartialTimestampFormat ptf = new PartialTimestampFormat();
 
547
 
 
548
                    out.append(" {deadlineTime = ");
 
549
                    out.append(ptf.format(getDeadlineTime()));
 
550
                    out.append("}");
 
551
                }
 
552
            } catch (UnsupportedAttributeException e) {
 
553
                /* Skip it. */
 
554
            } catch (DrmaaException e) {
 
555
                out.append(" {deadlineTime = <ERROR>}");
 
556
                error = true;
 
557
            }
 
558
 
 
559
            Set email = null;
 
560
    
 
561
            try {
 
562
                email = getEmail();
 
563
            } catch (DrmaaException e) {
 
564
                out.append(" {email = <ERROR>}");
 
565
                error = true;
 
566
            }
 
567
 
 
568
            if ((email != null) && (email.size() > 0)) {
 
569
                Iterator i = email.iterator();
 
570
                boolean firstEmail = true;
 
571
 
 
572
                out.append(" {email = ");
 
573
 
 
574
                while (i.hasNext()) {
 
575
                    if (firstEmail) {
 
576
                        firstEmail = false;
 
577
                    } else {
 
578
                        out.append(", ");
 
579
                    }
 
580
 
 
581
                    out.append("\"");
 
582
                    out.append(i.next());
 
583
                    out.append("\"");
 
584
                }
 
585
    
 
586
                out.append("}");
 
587
            }
 
588
 
 
589
            try {
 
590
                if (getErrorPath() != null) {
 
591
                    out.append(" {errorPath = ");
 
592
                    out.append(getErrorPath());
 
593
                    out.append("}");
 
594
                }
 
595
            } catch (DrmaaException e) {
 
596
                out.append(" {errorPath = <ERROR>}");
 
597
                error = true;
 
598
            }
 
599
 
 
600
            try {
 
601
                if (getHardRunDurationLimit() != 0L) {
 
602
                    out.append(" {hardRunDurationLimit = ");
 
603
                    out.append(getHardRunDurationLimit());
 
604
                    out.append("ms}");
 
605
                }
 
606
            } catch (UnsupportedAttributeException e) {
 
607
                /* Skip it. */
 
608
            } catch (DrmaaException e) {
 
609
                out.append(" {hardRunDurationLimit = <ERROR>}");
 
610
                error = true;
 
611
            }
 
612
 
 
613
            try {
 
614
                if (getHardWallclockTimeLimit() != 0L) {
 
615
                    out.append(" {hardWallclockTimeLimit = ");
 
616
                    out.append(getHardWallclockTimeLimit());
 
617
                    out.append("ms}");
 
618
                }
 
619
            } catch (UnsupportedAttributeException e) {
 
620
                /* Skip it. */
 
621
            } catch (DrmaaException e) {
 
622
                out.append(" {hardWallclockTimeLimit = <ERROR>}");
 
623
                error = true;
 
624
            }
 
625
 
 
626
            try {
 
627
                if (getInputPath() != null) {
 
628
                    out.append(" {inputPath = ");
 
629
                    out.append(getInputPath());
 
630
                    out.append("}");
 
631
                }
 
632
            } catch (DrmaaException e) {
 
633
                out.append(" {inputPath = <ERROR>}");
 
634
                error = true;
 
635
            }
 
636
 
 
637
            try {
 
638
                if (getJobCategory() != null) {
 
639
                    out.append(" {jobCategory = ");
 
640
                    out.append(getJobCategory());
 
641
                    out.append("}");
 
642
                }
 
643
            } catch (DrmaaException e) {
 
644
                out.append(" {jobCategory = <ERROR>}");
 
645
                error = true;
 
646
            }
 
647
 
 
648
            Map env = null;
 
649
            
 
650
            try {
 
651
                env = getJobEnvironment();
 
652
            } catch (DrmaaException e) {
 
653
                out.append(" {jobEnvironment = <ERROR>}");
 
654
                error = true;
 
655
            }
 
656
 
 
657
            if ((env != null) && (env.size() > 0)) {
 
658
                Iterator i = env.keySet().iterator();
 
659
                boolean firstEnv = true;
 
660
 
 
661
                out.append(" {jobEnvironment = ");
 
662
 
 
663
                while (i.hasNext()) {
 
664
                    String entry = (String)i.next();
 
665
                    if (firstEnv) {
 
666
                        firstEnv = false;
 
667
                    } else {
 
668
                        out.append(", ");
 
669
                    }
 
670
 
 
671
                    out.append("[\"");
 
672
                    out.append(entry);
 
673
                    out.append("\" = \"");
 
674
                    out.append(env.get(entry));
 
675
                    out.append("\"]");
 
676
                }
 
677
 
 
678
                out.append("}");
 
679
            }
 
680
 
 
681
            try {
 
682
                if (getJobName() != null) {
 
683
                    out.append(" {jobName = ");
 
684
                    out.append(getJobName());
 
685
                    out.append("}");
 
686
                }
 
687
            } catch (DrmaaException e) {
 
688
                out.append(" {jobName = <ERROR>}");
 
689
                error = true;
 
690
            }
 
691
 
 
692
            out.append(" {jobSubmissionState = ");
 
693
            
 
694
            try {
 
695
                if (getJobSubmissionState() == HOLD_STATE) {
 
696
                    out.append("HOLD_STATE}");
 
697
                } else {
 
698
                    out.append("ACTIVE_STATE}");
 
699
                }
 
700
            } catch (DrmaaException e) {
 
701
                out.append(" {jobSubmissionState = <ERROR>}");
 
702
                error = true;
 
703
            }
 
704
 
 
705
            out.append(" {joinFiles = ");
 
706
            
 
707
            try {
 
708
                out.append(Boolean.toString(getJoinFiles()));
 
709
            } catch (DrmaaException e) {
 
710
                out.append(" {joinFiles = <ERROR>}");
 
711
                error = true;
 
712
            }
 
713
                
 
714
            out.append("}");
 
715
 
 
716
            try {
 
717
                if (getNativeSpecification() != null) {
 
718
                    out.append(" {nativeSpecification = \"");
 
719
                    out.append(getNativeSpecification());
 
720
                    out.append("\"}");
 
721
                }
 
722
            } catch (DrmaaException e) {
 
723
                out.append(" {nativeSpecification = <ERROR>}");
 
724
                error = true;
 
725
            }
 
726
 
 
727
            try {
 
728
                if (getOutputPath() != null) {
 
729
                    out.append(" {outputPath = ");
 
730
                    out.append(getOutputPath());
 
731
                    out.append("}");
 
732
                }
 
733
            } catch (DrmaaException e) {
 
734
                out.append(" {outputPath = <ERROR>}");
 
735
                error = true;
 
736
            }
 
737
 
 
738
            try {
 
739
                if (getRemoteCommand() != null) {
 
740
                    out.append(" {remoteCommand = ");
 
741
                    out.append(getRemoteCommand());
 
742
                    out.append("}");
 
743
                }
 
744
            } catch (DrmaaException e) {
 
745
                out.append(" {remoteCommand = <ERROR>}");
 
746
                error = true;
 
747
            }
 
748
 
 
749
            try {
 
750
                if (getSoftRunDurationLimit() != 0L) {
 
751
                    out.append(" {softRunDurationLimit = ");
 
752
                    out.append(getSoftRunDurationLimit());
 
753
                    out.append("ms}");
 
754
                }
 
755
            } catch (UnsupportedAttributeException e) {
 
756
                /* Skip it. */
 
757
            } catch (DrmaaException e) {
 
758
                out.append(" {softRunDurationLimit = <ERROR>}");
 
759
                error = true;
 
760
            }
 
761
 
 
762
            try {
 
763
                if (getSoftWallclockTimeLimit() != 0L) {
 
764
                    out.append(" {softWallclockTimeLimit = ");
 
765
                    out.append(getSoftWallclockTimeLimit());
 
766
                    out.append("ms}");
 
767
                }
 
768
            } catch (UnsupportedAttributeException e) {
 
769
                /* Skip it. */
 
770
            } catch (DrmaaException e) {
 
771
                out.append(" {softWallclockTimeLimit = <ERROR>}");
 
772
                error = true;
 
773
            }
 
774
 
 
775
            try {
 
776
                if (getStartTime() != null) {
 
777
                    PartialTimestampFormat ptf = new PartialTimestampFormat();
 
778
 
 
779
                    out.append(" {startTime = \"");
 
780
                    out.append(ptf.format(getStartTime()));
 
781
                    out.append("\"}");
 
782
                }
 
783
            } catch (DrmaaException e) {
 
784
                out.append(" {startTime = <ERROR>}");
 
785
                error = true;
 
786
            }
 
787
 
 
788
            try {
 
789
                if (getTransferFiles() != null) {
 
790
                    out.append(" {transferFiles = \"");
 
791
                    out.append(getTransferFiles().toString());
 
792
                    out.append("\"}");
 
793
                }
 
794
            } catch (UnsupportedAttributeException e) {
 
795
                /* Skip it. */
 
796
            } catch (DrmaaException e) {
 
797
                out.append(" {transferFiles = <ERROR>}");
 
798
                error = true;
 
799
            }
 
800
 
 
801
            try {
 
802
                if (getWorkingDirectory() != null) {
 
803
                    out.append(" {workingDirectory = ");
 
804
                    out.append(getWorkingDirectory());
 
805
                    out.append("}");
 
806
                }
 
807
            } catch (DrmaaException e) {
 
808
                out.append(" {workingDirectory = <ERROR>}");
 
809
                error = true;
 
810
            }
 
811
 
 
812
            toString = out.toString();
 
813
 
 
814
            /* If there was an error while getting a property value, we can't
 
815
             * unset the modified flag.  Because the errored property getter
 
816
             * might work during a later attempt, we have to leave the modified
 
817
             * flag as true so that we try again on the next call to
 
818
             * toString(). */
 
819
            modified = error;
 
820
        }
 
821
 
 
822
        return toString;
 
823
    }
 
824
}