The main loop for the thread. The loop does the following: Check the states of the running jobs Update the states of waiting jobs Submit the jobs in ready state
()
| 156 | * Submit the jobs in ready state |
| 157 | */ |
| 158 | public void run() { |
| 159 | if (!initSuccesful) { |
| 160 | super.run(); |
| 161 | return; |
| 162 | } |
| 163 | try { |
| 164 | setRunnerState(ThreadState.RUNNING); |
| 165 | while (true) { |
| 166 | while (getRunnerState() == ThreadState.SUSPENDED) { |
| 167 | try { |
| 168 | Thread.sleep(timeToSleep); |
| 169 | } |
| 170 | catch (Exception e) { |
| 171 | //TODO the thread was interrupted, do something!!! |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | synchronized(this) { |
| 176 | Iterator<ControlledJob> it = getJobs(jobsInProgress).iterator(); |
| 177 | if (!it.hasNext()) { |
| 178 | stop(); |
| 179 | } |
| 180 | while(it.hasNext()) { |
| 181 | ControlledJob j = it.next(); |
| 182 | |
| 183 | // TODO: Need to re-visit the following try...catch |
| 184 | // when Pig picks up a Hadoop release with MAPREDUCE-6762 applied |
| 185 | // as its dependency. |
| 186 | try { |
| 187 | log.debug("Checking state of job " + j); |
| 188 | } catch(NullPointerException npe) { |
| 189 | log.warn("Failed to get job name " + |
| 190 | "when checking state of job. " + |
| 191 | "Check if job status is null.", npe); |
| 192 | } |
| 193 | |
| 194 | switch(checkState(j)) { |
| 195 | case SUCCESS: |
| 196 | getJobs(successfulJobs).add(j); |
| 197 | it.remove(); |
| 198 | break; |
| 199 | case FAILED: |
| 200 | case DEPENDENT_FAILED: |
| 201 | getJobs(failedJobs).add(j); |
| 202 | it.remove(); |
| 203 | break; |
| 204 | case READY: |
| 205 | submit(j); |
| 206 | break; |
| 207 | case RUNNING: |
| 208 | case WAITING: |
| 209 | //Do Nothing |
| 210 | break; |
| 211 | } |
| 212 | } |
| 213 | } |
| 214 | |
| 215 | if (getRunnerState() != ThreadState.RUNNING && |
nothing calls this directly
no test coverage detected