[477] | 1 | package simulator.stats.implementation; |
---|
| 2 | |
---|
| 3 | |
---|
| 4 | import java.util.List; |
---|
| 5 | |
---|
[539] | 6 | import dcworms.schedframe.scheduling.Executable; |
---|
| 7 | |
---|
[477] | 8 | import simulator.stats.implementation.out.StatsSerializer; |
---|
| 9 | |
---|
| 10 | /** |
---|
| 11 | * |
---|
| 12 | * @author Marcin Krystek |
---|
| 13 | * |
---|
| 14 | */ |
---|
| 15 | public class TaskStats implements StatsInterface { |
---|
| 16 | protected List<String> processorsName; |
---|
| 17 | protected double reservationStartDate; |
---|
| 18 | protected double reservationFinishDate; |
---|
| 19 | |
---|
| 20 | protected Executable task; |
---|
| 21 | protected long startSimulationTimeSek; |
---|
| 22 | |
---|
| 23 | private String headers[] = { "JobID", "TaskID", "UserDN", "ResName", "CpuCnt", |
---|
| 24 | "ExecStartDate", "ExecFinishDate", "ExecEndDate", "GB_SubDate", |
---|
| 25 | "LB_SubDate", "CompletionTime", "ExecStartTime", |
---|
| 26 | "ExecutionTime", "ReadyTime", "StartTime", "FlowTime", |
---|
| 27 | "WaitingTime", "GQ_WaitingTime", "Lateness", "Tardiness", |
---|
| 28 | "ReservStartDate", "ReservFinishDate", "ProcessorName", "Energy"}; |
---|
| 29 | |
---|
| 30 | public TaskStats(Executable task, long startSimulationTime) { |
---|
| 31 | this.task = task; |
---|
| 32 | this.startSimulationTimeSek = startSimulationTime / 1000; |
---|
| 33 | } |
---|
| 34 | |
---|
| 35 | public Object serialize(StatsSerializer serializer) { |
---|
| 36 | return serializer.visit(this); |
---|
| 37 | } |
---|
| 38 | |
---|
| 39 | public String getJobID() { |
---|
| 40 | return this.task.getJobId(); |
---|
| 41 | } |
---|
| 42 | |
---|
| 43 | public String getTaskID() { |
---|
| 44 | return this.task.getId(); |
---|
| 45 | } |
---|
| 46 | |
---|
| 47 | public String getUserDN() { |
---|
[539] | 48 | return this.task.getUserDN(); |
---|
[477] | 49 | } |
---|
| 50 | |
---|
| 51 | public String getResName() { |
---|
[539] | 52 | String resName = this.task.getSchedulerName(); |
---|
| 53 | |
---|
[477] | 54 | return resName; |
---|
| 55 | } |
---|
| 56 | |
---|
| 57 | public long getCpuCnt() { |
---|
| 58 | long cpuCnt = -1; |
---|
| 59 | try { |
---|
| 60 | cpuCnt = Double.valueOf(task.getCpuCntRequest()).longValue(); |
---|
| 61 | } catch (NoSuchFieldException e) { |
---|
| 62 | } |
---|
| 63 | |
---|
| 64 | return cpuCnt; |
---|
| 65 | } |
---|
| 66 | |
---|
| 67 | public double getExecStartDate() { |
---|
| 68 | return task.getExecStartTime(); |
---|
| 69 | } |
---|
| 70 | |
---|
| 71 | public double getExecFinishDate() { |
---|
| 72 | return task.getFinishTime(); |
---|
| 73 | } |
---|
| 74 | |
---|
| 75 | public double getExecEndDate() { |
---|
| 76 | double ret = -1; |
---|
| 77 | try { |
---|
| 78 | ret = task.getExecutionEndTime().getMillis() / 1000; |
---|
| 79 | } catch (NoSuchFieldException e) { |
---|
| 80 | ret = task.getFinishTime(); |
---|
| 81 | } |
---|
| 82 | return ret; |
---|
| 83 | } |
---|
| 84 | |
---|
| 85 | public double getGB_SubDate() { |
---|
| 86 | return task.getSubmissionTimeToBroker().getMillis() / 1000; |
---|
| 87 | } |
---|
| 88 | |
---|
| 89 | public double getLB_SubDate() { |
---|
| 90 | return task.getSubmissionTime(); |
---|
| 91 | } |
---|
| 92 | |
---|
| 93 | public double getCompletionTime() { |
---|
| 94 | return task.getFinishTime() - startSimulationTimeSek; |
---|
| 95 | } |
---|
| 96 | |
---|
| 97 | public double getExecutionTime() { |
---|
| 98 | return task.getFinishTime() - task.getExecStartTime(); |
---|
| 99 | } |
---|
| 100 | |
---|
| 101 | public double getExecStartTime() { |
---|
| 102 | return task.getExecStartTime() - startSimulationTimeSek; |
---|
| 103 | } |
---|
| 104 | |
---|
| 105 | public double getReadyTime() { |
---|
| 106 | double readyTime = 0; |
---|
| 107 | |
---|
| 108 | try { |
---|
| 109 | readyTime = task.getExecutionStartTime().getMillis() / 1000 |
---|
| 110 | - startSimulationTimeSek; |
---|
| 111 | } catch (Exception ex) { |
---|
| 112 | readyTime = task.getSubmissionTimeToBroker().getMillis()/1000 - startSimulationTimeSek; |
---|
| 113 | } |
---|
| 114 | |
---|
| 115 | return readyTime; |
---|
| 116 | } |
---|
| 117 | |
---|
| 118 | public double getStartTime() { |
---|
| 119 | return task.getExecStartTime() |
---|
| 120 | - task.getSubmissionTimeToBroker().getMillis() / 1000; |
---|
| 121 | } |
---|
| 122 | |
---|
| 123 | public double getFlowTime() { |
---|
| 124 | return getCompletionTime() - getReadyTime(); |
---|
| 125 | } |
---|
| 126 | |
---|
| 127 | public double getWaitingTime() { |
---|
| 128 | return task.getWaitingTime(); |
---|
| 129 | } |
---|
| 130 | |
---|
| 131 | public double getGQ_WaitingTime() { |
---|
| 132 | return task.getSubmissionTime() |
---|
| 133 | - task.getSubmissionTimeToBroker().getMillis() / 1000; |
---|
| 134 | } |
---|
| 135 | |
---|
| 136 | public double getLateness() { |
---|
| 137 | double execEndDate = getExecEndDate(); |
---|
| 138 | double lateness = 0; |
---|
| 139 | if (execEndDate != -1) { |
---|
| 140 | lateness = task.getFinishTime() - execEndDate; |
---|
| 141 | } |
---|
| 142 | return lateness; |
---|
| 143 | } |
---|
| 144 | |
---|
| 145 | public double getTardiness() { |
---|
| 146 | return Math.max(getLateness(), 0.0); |
---|
| 147 | } |
---|
| 148 | |
---|
| 149 | public void setProcessorsName(List<String> value) { |
---|
| 150 | this.processorsName = value; |
---|
| 151 | } |
---|
| 152 | |
---|
| 153 | public void setReservationStartDate(double value) { |
---|
| 154 | this.reservationStartDate = value; |
---|
| 155 | } |
---|
| 156 | |
---|
| 157 | public void setReservationFinishDate(double value) { |
---|
| 158 | this.reservationFinishDate = value; |
---|
| 159 | } |
---|
| 160 | |
---|
| 161 | public List<String> getProcessorsName() { |
---|
| 162 | return processorsName; |
---|
| 163 | } |
---|
| 164 | |
---|
| 165 | public double getReservationStartDate() { |
---|
| 166 | return reservationStartDate; |
---|
| 167 | } |
---|
| 168 | |
---|
| 169 | public double getReservationFinishDate() { |
---|
| 170 | return reservationFinishDate; |
---|
| 171 | } |
---|
| 172 | |
---|
| 173 | public String[] getHeaders() { |
---|
| 174 | return headers; |
---|
| 175 | } |
---|
| 176 | |
---|
| 177 | } |
---|