1
/*___INFO__MARK_BEGIN__*/
2
/*************************************************************************
4
* The Contents of this file are made available subject to the terms of
5
* the Sun Industry Standards Source License Version 1.2
7
* Sun Microsystems Inc., March, 2001
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
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.
24
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
26
* Copyright: 2001 by Sun Microsystems, Inc.
28
* All Rights Reserved.
30
************************************************************************/
31
/*___INFO__MARK_END__*/
32
package com.sun.grid.jgdi.monitoring;
34
import java.io.Serializable;
35
import java.util.ArrayList;
36
import java.util.Collections;
37
import java.util.Date;
38
import java.util.HashMap;
39
import java.util.List;
44
* The class JobSummary extends the class JobInfo and adds addtional
45
* information about the job.
48
public class JobSummaryImpl extends JobInfoImpl implements JobSummary, Serializable {
53
private double nprior;
54
private double ntckts;
55
private double rrcontr;
56
private double wtcontr;
57
private double dlcontr;
58
private String project;
59
private String department;
60
private Date deadline;
62
private boolean hasCpuUsage;
64
private boolean hasMemUsage;
65
private double memUsage;
66
private boolean hasIoUsage;
67
private double ioUsage;
69
private boolean isZombie;
70
private long overrideTickets;
71
private boolean isQueueAssigned;
73
private long otickets;
74
private long ftickets;
75
private long stickets;
79
private String master;
81
private boolean isArray;
82
private boolean isRunning;
84
private String parallelEnvironmentName;
85
private String parallelEnvironmentRange;
87
private String grantedPEName;
88
private int grantedPESlots;
90
private String checkpointEnv;
91
private String masterQueue;
93
private List<TaskSummary> taskList;
95
/* Name value pairs for requested resources */
96
private Map<String, String> requestMap;
98
private Map<String, HardRequestValue> hardRequestMap;
100
private Map<String, String> softRequestMap;
102
private List<String> hardRequestedQueueList;
104
private List<String> softRequestedQueueList;
106
private List<String> hardRequestedMasterQueueList;
108
private List<String> softRequestedMasterQueueList;
110
private List<String> requestedPredecessorList;
112
private List<String> requestedArrayPredecessorList;
114
private List<Integer> predecessorList;
116
private List<Integer> arrayPredecessorList;
118
/** Creates a new instance of JobSummary */
119
public JobSummaryImpl() {
123
* Get the list of tasks of this job
124
* @return the list of tasks
126
public List<TaskSummary> getTaskList() {
127
if (taskList == null) {
128
return Collections.EMPTY_LIST;
134
* Get the number of tasks of this job
135
* @return the number of tasks
137
public int getTaskCount() {
138
if (taskList == null) {
141
return taskList.size();
146
* Add a new task to the job
147
* @param taskSummary the new task
149
public void addTask(TaskSummary taskSummary) {
151
if (taskList == null) {
152
taskList = new ArrayList<TaskSummary>();
154
taskList.add(taskSummary);
158
* Add a resource request to the job
159
* @param name of the resource
160
* @param value requested value of the resource
162
public void addRequest(String name, String value) {
163
if (requestMap == null) {
164
requestMap = new HashMap<String, String>();
166
requestMap.put(name, value);
170
* <p>Get all resources which have been requested by this job.</p>
172
* <p>recource requsts are specified by qsub with the -l option (see man qsub).</p>
174
* @return set of resources names
176
public Set<String> getRequestNames() {
177
if (requestMap == null) {
178
return Collections.EMPTY_SET;
180
return requestMap.keySet();
185
* Get value of a requested resource
187
* @param name name of the requested resource
188
* @return value of the requested resource
190
public String getRequestValue(String name) {
191
if (requestMap == null) {
194
return requestMap.get(name);
199
* Add a hard resource request to the job summary.
200
* @param name name of the resource
201
* @param value requested value
202
* @param uc jobs urgency contribution for this resource
204
public void addHardRequest(String name, String value, double uc) {
205
if (hardRequestMap == null) {
206
hardRequestMap = new HashMap<String, HardRequestValue>();
208
hardRequestMap.put(name, new HardRequestValue(name, value, uc));
212
* Get a set of all hard requested resources.
213
* @return set of resource names
215
public Set<String> getHardRequestNames() {
216
if (hardRequestMap == null) {
217
return Collections.EMPTY_SET;
219
return hardRequestMap.keySet();
224
* Get a value of a hard requested resource
225
* @param name name of the hard requested resource
226
* @return the hard requested resource value (includes the
227
* requested value and the urgency contribution)
229
public HardRequestValue getHardRequestValue(String name) {
230
if (hardRequestMap == null) {
233
return hardRequestMap.get(name);
238
* Add a soft request to the job
239
* @param name name of the requested resource
240
* @param value requested value
242
public void addSoftRequest(String name, String value) {
243
if (softRequestMap == null) {
244
softRequestMap = new HashMap<String, String>();
246
softRequestMap.put(name, value);
250
* Get a set of all soft requested resources
251
* @return set of all soft requested resources
253
public Set<String> getSoftRequestNames() {
254
if (softRequestMap == null) {
255
return Collections.EMPTY_SET;
257
return softRequestMap.keySet();
262
* Get the value of a soft requested resource
263
* @param name name of the resource
264
* @return requested value
266
public String getSoftRequestValue(String name) {
267
if (softRequestMap == null) {
270
return softRequestMap.get(name);
275
* Add a hard requested queue
277
* @param qname of the hard requested queue
279
public void addHardRequestedQueue(String qname) {
280
if (hardRequestedQueueList == null) {
281
hardRequestedQueueList = new ArrayList<String>();
283
hardRequestedQueueList.add(qname);
287
* Get a list of all hard requested queues
288
* @return list of hard requested queues
290
public List<String> getHardRequestedQueues() {
291
if (hardRequestedQueueList == null) {
292
return Collections.EMPTY_LIST;
294
return Collections.unmodifiableList(hardRequestedQueueList);
299
* Add a soft requested queue
301
* @param qname name of the soft requested queue
303
public void addSoftRequestedQueue(String qname) {
304
if (softRequestedQueueList == null) {
305
softRequestedQueueList = new ArrayList<String>();
307
softRequestedQueueList.add(qname);
311
* Get a list of all soft requested queues
312
* @return list of all soft requested queues
314
public List<String> getSoftRequestedQueues() {
315
if (softRequestedQueueList == null) {
316
return Collections.EMPTY_LIST;
318
return Collections.unmodifiableList(softRequestedQueueList);
323
* Adds a hard requested master queue to the job
324
* (see qsub -masterq).
326
* @param qname name of the hard requested master queue
328
public void addHardRequestedMasterQueue(String qname) {
329
if (hardRequestedMasterQueueList == null) {
330
hardRequestedMasterQueueList = new ArrayList<String>();
332
hardRequestedMasterQueueList.add(qname);
336
* Get a list of all hard requested master queues
337
* @return list of all hard requested master queues
339
public List<String> getHardRequestedMasterQueues() {
340
if (hardRequestedMasterQueueList == null) {
341
return Collections.EMPTY_LIST;
343
return Collections.unmodifiableList(hardRequestedMasterQueueList);
348
* Add a soft requested master queue
349
* (see qsub -masterq)
350
* @param qname of the soft requested master queue
352
public void addSoftRequestedMasterQueue(String qname) {
353
if (softRequestedMasterQueueList == null) {
354
softRequestedMasterQueueList = new ArrayList<String>();
356
softRequestedMasterQueueList.add(qname);
360
* Get a list of all soft requested master queues
361
* @return list of all soft requested master queues
363
public List getSoftRequestedMasterQueues() {
364
if (softRequestedMasterQueueList == null) {
365
return Collections.EMPTY_LIST;
367
return Collections.unmodifiableList(softRequestedMasterQueueList);
372
* add a requested predecessor to the job
373
* (predecessor of a job can be requested with
376
* @param name of the predecessor
378
public void addRequestedPredecessor(String name) {
379
if (requestedPredecessorList == null) {
380
requestedPredecessorList = new ArrayList<String>();
382
requestedPredecessorList.add(name);
386
* add a requested array predecessor to the job
387
* (array predecessor of a job can be requested with
390
* @param name of the array predecessor
392
public void addRequestedArrayPredecessor(String name) {
393
if (requestedArrayPredecessorList == null) {
394
requestedArrayPredecessorList = new ArrayList<String>();
396
requestedArrayPredecessorList.add(name);
401
* Get a list of all requested predecessors
402
* @return list of requested predecessors job names
404
public List<String> getRequestedPredecessors() {
405
if (requestedPredecessorList == null) {
406
return Collections.EMPTY_LIST;
408
return Collections.unmodifiableList(requestedPredecessorList);
413
* Get a list of all requested array predecessors
414
* @return list of requested array predecessors job names
416
public List<String> getRequestedArrayPredecessors() {
417
if(requestedArrayPredecessorList == null) {
418
return Collections.EMPTY_LIST;
420
return Collections.unmodifiableList(requestedArrayPredecessorList);
425
* Add the job id of a predecessor
426
* @param job_id job id of the predecessor
428
public void addPredecessor(int job_id) {
429
if (predecessorList == null) {
430
predecessorList = new ArrayList<Integer>();
432
predecessorList.add(new Integer(job_id));
436
* Add the job id of an array predecessor
437
* @param job_id job id of the array predecessor
439
public void addArrayPredecessor(int job_id) {
440
if (arrayPredecessorList == null) {
441
arrayPredecessorList = new ArrayList<Integer>();
443
arrayPredecessorList.add(new Integer(job_id));
447
* Get a list of all predecessor job id
448
* @return list of job ids (java.lang.Integer)
450
public List<Integer> getPredecessors() {
451
if (predecessorList == null) {
452
return Collections.EMPTY_LIST;
454
return Collections.unmodifiableList(predecessorList);
459
* Get a list of all array predecessor job id
460
* @return list of job ids (java.lang.Integer)
462
public List<Integer> getArrayPredecessors() {
463
if(arrayPredecessorList == null) {
464
return Collections.EMPTY_LIST;
466
return Collections.unmodifiableList(arrayPredecessorList);
471
* Get the jobs total urgency value in normalized fashion.
472
* @return the jobs total urgency value in normalized fashion
474
public double getNormalizedUrgency() {
479
* Set the jobs total urgency value in normalized fashion.
480
* @param nurg the normalized total urgency
482
public void setNormalizedUrgency(double nurg) {
487
* Get the total urgency of the job
488
* @return total urgency of the job
490
public double getUrgency() {
495
* Set the total urgency of the job
496
* @param urg the total urgency
498
public void setUrgency(double urg) {
503
* Get the priority of the job which has been
504
* requested by the user in normalized form
506
* @return the normalized job priority
508
public double getNormalizedRequestedPriority() {
513
* Set the priority of the job which has been requested
514
* by the user in normalized form
515
* @param nppri requested priority in normalized
517
public void setNormalizedRequestedPriority(double nppri) {
522
* Get the normalized priority of the job
523
* @return the normalized priority of the job
525
public double getNormalizedPriority() {
530
* Get the normalized priority of the job
531
* param nprior the normalized priority
533
public void setNormalizedPriority(double nprior) {
534
this.nprior = nprior;
538
* Get the normalized total number of tickets
539
* @return the normalized total number of tickets
541
public double getNormalizedTickets() {
546
* Set the normalized total number of tickets
547
* @param ntckts the normalized total number of tickets
549
public void setNormalizedTickets(double ntckts) {
550
this.ntckts = ntckts;
554
* Get the urgency value contribution that reflects the urgency
555
* that is related to the jobs overall resource requirement.
557
* @return the urgency value contribution
559
public double getRrcontr() {
564
* Set the urgency value contribution that reflects the urgency
565
* that is related to the jobs overall resource requirement.
567
public void setRrcontr(double rrcontr) {
568
this.rrcontr = rrcontr;
572
* Get the urgency value contribution that reflects the
573
* urgency related to the jobs waiting time.
574
* @return the urgency value contribution
576
public double getWtcontr() {
581
* Set the urgency value contribution that reflects the
582
* urgency related to the jobs waiting time.
583
* @param wtcontr the urgency value contribution
585
public void setWtcontr(double wtcontr) {
586
this.wtcontr = wtcontr;
590
* Get the urgency value contribution that reflects the
591
* urgency related to the jobs deadline initiation time.
592
* @return the urgency value contribution
594
public double getDlcontr() {
599
* Set the urgency value contribution that reflects the
600
* urgency related to the jobs deadline initiation time.
601
* @param dlcontr the urgency value contribution
603
public void setDlcontr(double dlcontr) {
604
this.dlcontr = dlcontr;
608
* Get the project of the job
609
* @return the project of the job
611
public String getProject() {
616
* Set the project of the job
617
* @param project project of the job
619
public void setProject(String project) {
620
this.project = project;
624
* Get the department of the job
625
* @return the department of the job
627
public String getDepartment() {
632
* Set the department of the job
633
* @param department the department of the job
635
public void setDepartment(String department) {
636
this.department = department;
640
* Get the deadline of the job
641
* @return the deadline
643
public Date getDeadline() {
648
* Set the deadline of the job
649
* @param deadline the deadline of the job
651
public void setDeadline(Date deadline) {
652
this.deadline = deadline;
656
* Set the deadline of the job
657
* @param deadline the deadline of the job in millis
659
public void setDeadline(long deadline) {
660
this.deadline = new Date(deadline);
664
* Determine if the job has a cpu usage
665
* @return true of the job has a cpu usage
667
public boolean hasCpuUsage() {
672
* Get the cpu usage of the job. If the jobs has no
673
* cpu usage, <code>0</code> is returned
674
* @return the cpu usage of the job
677
public int getCpuUsage() {
682
* Set the cpu usage of the job
683
* @param cpuUsage the cpu usage
685
public void setCpuUsage(int cpuUsage) {
686
this.cpuUsage = cpuUsage;
691
* Determine if the job has a memory usage
692
* @return <code>true</code> if the job has a memory usage
694
public boolean hasMemUsage() {
699
* Get the memory usage of the job. If the job has no memory
700
* usage <code>0</code> is returned.
702
* @return the memory usage of the job
705
public double getMemUsage() {
710
* Set the memory usage of the job
711
* @param memUsage the memory usage
713
public void setMemUsage(double memUsage) {
714
this.memUsage = memUsage;
719
* Determine if the job has a io usage
720
* @return true of the job has a io usage
722
public boolean hasIoUsage() {
727
* Get the io usage of the job. If the job has no io
728
* usage <code>0</code> is returned.
730
* @return the io usage of the job
733
public double getIoUsage() {
738
* Set the io usage of the job.
739
* @param ioUsage the io usage of the job
741
public void setIoUsage(double ioUsage) {
742
this.ioUsage = ioUsage;
747
* Determine if the job is a zombie
748
* @return <code>false</code> if the job a zombie
750
public boolean isZombie() {
755
* Set the zombie flag
756
* @param isZombie the zombie flag
758
public void setZombie(boolean isZombie) {
759
this.isZombie = isZombie;
763
* Get the override tickets of the job
764
* @return the override tickets of the job
766
public long getOverrideTickets() {
767
return overrideTickets;
771
* Set the override tickets of the job
772
* @param overrideTickets the override tickets of the job
774
public void setOverrideTickets(long overrideTickets) {
775
this.overrideTickets = overrideTickets;
779
* Determine if the job is assigned to a queue
780
* @return <code>true</code> if the job is assigned to a queue
782
public boolean isQueueAssigned() {
783
return isQueueAssigned;
787
* Set the queue assigned falg
788
* @param isQueueAssigned the queue assigned flag
790
public void setQueueAssigned(boolean isQueueAssigned) {
791
this.isQueueAssigned = isQueueAssigned;
795
* Get the currently number of tickets of the job
796
* @return currently number of tickets
798
public long getTickets() {
803
* Set the currently number of tickets of the job
804
* @param tickets currently number of tickets
806
public void setTickets(long tickets) {
807
this.tickets = tickets;
811
* Get the override portion of the total number of tickets
812
* assigned to the job currently
813
* @return override portion of the total number of tickets
815
public long getOtickets() {
820
* Set the override portion of the total number of tickets
821
* assigned to the job currently
822
* @param otickets the override portion of the total number of tickets
824
public void setOtickets(long otickets) {
825
this.otickets = otickets;
829
* Get the functional portion of the total number of tickets
830
* assigned to the job currently.
832
* @return the functional portion of the total number of tickets
834
public long getFtickets() {
839
* Set the functional portion of the total number of tickets
840
* assigned to the job currently.
842
* @param ftickets the functional portion of the total number of tickets
844
public void setFtickets(long ftickets) {
845
this.ftickets = ftickets;
849
* Get the share portion of the total number of tickets
850
* assigned to the job currently.
852
* @return the share portion of the total number of tickets
854
public long getStickets() {
859
* Set the share portion of the total number of tickets
860
* assigned to the job currently.
862
* @param stickets the share portion of the total number of tickets
864
public void setStickets(long stickets) {
865
this.stickets = stickets;
869
* Get the share of the total system to which the job is entitled currently.
870
* @return the share of the job
872
public double getShare() {
877
* Set the share of the total system to which the job is entitled currently.
878
* @param share the share of the job
880
public void setShare(double share) {
885
* Get the number of used slots
886
* @return the number of used slots
888
public int getSlots() {
893
* Set the number of used slots
894
* @param slots the number of used slots
896
public void setSlots(int slots) {
901
* Determine if the job is an array job
902
* @return <code>true</code> if the job is an array job
904
public boolean isArray() {
909
* Set the array job flag
910
* @param isArray the array job flag
912
public void setArray(boolean isArray) {
913
this.isArray = isArray;
917
* Determine if the job is running
918
* @return <code>true</code> of the job is running
920
public boolean isRunning() {
925
* Set the is running flag
926
* @param isRunning the is running flag
928
public void setRunning(boolean isRunning) {
929
this.isRunning = isRunning;
933
* Get the name of the parallel environment of the job
934
* @return name of the parallel environment
936
public String getParallelEnvironmentName() {
937
return parallelEnvironmentName;
941
* Set the name of the parallel environment of the job
942
* @param parallelEnvironmentName name of the parallel environment
944
public void setParallelEnvironmentName(String parallelEnvironmentName) {
945
this.parallelEnvironmentName = parallelEnvironmentName;
949
* Get the requested PE slot range.
950
* @return the requested PE slot range
952
public String getParallelEnvironmentRange() {
953
return parallelEnvironmentRange;
957
* Set the requested PE slot range.
958
* @param parallelEnvironmentRange the requested PE slot range
960
public void setParallelEnvironmentRange(String parallelEnvironmentRange) {
961
this.parallelEnvironmentRange = parallelEnvironmentRange;
965
* Get the name of the granted PE
966
* @return name of the granted PE
968
public String getGrantedPEName() {
969
return grantedPEName;
973
* Set the name of the granted PE
974
* @param grantedPEName name of the granted PE
976
public void setGrantedPEName(String grantedPEName) {
977
this.grantedPEName = grantedPEName;
981
* Get the number of granted PE slots
982
* @return number of granted PE slots
984
public int getGrantedPESlots() {
985
return grantedPESlots;
989
* Set the number of granted PE slots
990
* @param grantedPESlots number of granted PE slots
992
public void setGrantedPESlots(int grantedPESlots) {
993
this.grantedPESlots = grantedPESlots;
997
* Get the checkpoint environment of the job
998
* @return the checkpoint environment of the job
1000
public String getCheckpointEnv() {
1001
return checkpointEnv;
1005
* Set the checkpoint environment of the job
1006
* @param checkpointEnv the checkpoint environment of the job
1008
public void setCheckpointEnv(String checkpointEnv) {
1009
this.checkpointEnv = checkpointEnv;