-
Notifications
You must be signed in to change notification settings - Fork 245
Expand file tree
/
Copy pathJobManager.java
More file actions
503 lines (439 loc) · 11.3 KB
/
JobManager.java
File metadata and controls
503 lines (439 loc) · 11.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
/*
* Copyright Contributors to the OpenCue Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package com.imageworks.spcue.service;
import java.util.List;
import com.imageworks.spcue.BuildableJob;
import com.imageworks.spcue.DispatchFrame;
import com.imageworks.spcue.DispatchJob;
import com.imageworks.spcue.ExecutionSummary;
import com.imageworks.spcue.FrameDetail;
import com.imageworks.spcue.FrameInterface;
import com.imageworks.spcue.FrameStateTotals;
import com.imageworks.spcue.JobDetail;
import com.imageworks.spcue.JobInterface;
import com.imageworks.spcue.LayerDetail;
import com.imageworks.spcue.LayerInterface;
import com.imageworks.spcue.LimitEntity;
import com.imageworks.spcue.ThreadStats;
import com.imageworks.spcue.dao.criteria.FrameSearchInterface;
import com.imageworks.spcue.grpc.job.CheckpointState;
import com.imageworks.spcue.grpc.job.FrameState;
import com.imageworks.spcue.grpc.job.JobState;
import com.imageworks.spcue.grpc.job.Order;
import com.imageworks.spcue.util.FrameSet;
/**
* JobManager pretty much handles all job management functions. From launching killing jobs, to
* managing the layers, frames, etc within jobs.
*/
public interface JobManager {
/**
* Pause/unpause a job
*
* @param job
* @param paused
*/
void setJobPaused(JobInterface job, boolean paused);
/**
*
* @param id
* @return
*/
public DispatchJob getDispatchJob(String id);
/**
*
* @param id
* @return
*/
public DispatchFrame getDispatchFrame(String id);
/**
* Returns true if there is a pending job with the specifed name on the cue.
*
* @param name
* @return
*/
boolean isJobPending(String name);
/**
* Returns true if the job has no more frames that can possibly be dispatched.
*
* @return
*/
boolean isJobComplete(JobInterface job);
/**
* Returns true if the layer is complete.
*
* @param layer
* @return
*/
boolean isLayerComplete(LayerInterface layer);
/**
* Launches a job spec.
*
* @param spec
*/
void launchJobSpec(JobSpec spec);
/**
* Creates a new job entry
*
* @param BuildableJob job
* @return JobDetail
*/
JobDetail createJob(BuildableJob job);
/**
* Removes an existing job entry. The job must be in the Finished state before it can be
* removed.
*
* @param JobDetail job
*/
void removeJob(JobInterface job);
/**
* Shutting down a job will signal RQD to kill all frames and drop all dependencies for
* specified job. Job is put into Shutdown state which should be commited before any other
* operations are done on the job. When shutdown is complete, the job shoud be marked Finished.
*
* @param JobDetail job
*/
boolean shutdownJob(JobInterface job);
/**
* Finds and active job by name.
*
* @param String name
* @return JobDetail
*/
JobDetail findJobDetail(String name);
/**
* Finds and active job by name.
*
* @param String name
* @return JobDetail
*/
JobInterface findJob(String name);
/**
* Gets an active job by ID.
*
* @param String id
* @return JobDetail
*/
JobDetail getJobDetail(String id);
/**
* Gets a job by unique id
*
* @param id
* @return
*/
JobInterface getJob(String id);
/**
*
* @param id
* @return LayerDetail
*/
LayerDetail getLayerDetail(String id);
/**
* Return a layer by its unique ID.
*
* @param id
* @return LayerDetail
*/
LayerInterface getLayer(String id);
/**
*
* @param id
* @return FrameDetail
*/
FrameDetail getFrameDetail(String id);
/**
* Return a frame with the given ID.
*
* @param id
* @return
*/
FrameInterface getFrame(String id);
/**
* Marks a specific frame as waiting, setting its dependency count to 0 in the process even
* though it has active dependencies.
*
* @param frame
*/
public void markFrameAsWaiting(FrameInterface frame);
/**
* Marks a specific frame as Depend if the frame has active dependencies. This will pretty much
* undo a markFrameAsWaiting. If the frame has no active depends this call should have no
* effect.
*
* @param frame
*/
public void markFrameAsDepend(FrameInterface frame);
/**
* Return the result of the given FrameSearch.
*
* @param job
* @param r
* @return
*/
public List<FrameInterface> findFrames(FrameSearchInterface r);
/**
* Updates specified frame to new state.
*
* @param frame
* @param state
*/
public void updateFrameState(FrameInterface frame, FrameState state);
/**
* Updates specified job to new state.
*
* @param job
* @param state
*/
public void updateJobState(JobInterface job, JobState state);
/**
* Reorders the specified layer.
*
* @param job
* @param frameSet
*/
public void reorderLayer(LayerInterface layer, FrameSet frameSet, Order order);
/**
*
* @param layer
* @param frameSet
*/
public void staggerLayer(LayerInterface layer, String range, int stagger);
/**
* Returns all of the layers for the specified job
*
* @param job
* @return
*/
public List<LayerInterface> getLayers(JobInterface job);
/**
* Returns all of the layers for the specified job
*
* @param job
* @return
*/
public List<LayerDetail> getLayerDetails(JobInterface job);
/**
* Creates the job log directory. The JobDetail object must have the logDir property populated.
*
* @param newJob
*/
public void createJobLogDirectory(JobDetail newJob);
/**
* Optimizes layer settings based on the specified maxRss and run time.
*
* @param layer
* @param maxRss
* @param runTime
*/
void optimizeLayer(LayerInterface layer, int cores, long maxRss, int runTime);
/**
* Return true if the given job is booked greater than min cores.
*
* @param job
* @return
*/
boolean isOverMinCores(JobInterface job);
/**
* Increase the layer memory requirement to given KB value.
*
* @param layer
* @param memKb
*/
void increaseLayerMemoryRequirement(LayerInterface layer, long memKb);
/**
* Appends a tag to a layer's existing tags.
*
* @param layer
* @param tag
*/
void appendLayerTag(LayerInterface layer, String tag);
/**
* Replace all existing tags with the specified tag.
*
* @param layer
* @param tag
*/
void setLayerTag(LayerInterface layer, String tag);
/**
* Return true if the given layer is threadable.
*
* @param layer
* @return
*/
boolean isLayerThreadable(LayerInterface layer);
/**
* Enable or disable the layer memory optimizer.
*/
void enableMemoryOptimizer(LayerInterface layer, boolean state);
/**
* Return the frame for the given layer and frame number.
*
* @param layer
* @param number
* @return
*/
FrameInterface findFrame(LayerInterface layer, int number);
/**
*
* @param job
* @return
*/
FrameDetail findLongestFrame(JobInterface job);
/**
*
* @param job
* @return
*/
FrameDetail findShortestFrame(JobInterface job);
/**
*
* @param job
* @return
*/
FrameStateTotals getFrameStateTotals(JobInterface job);
/**
*
* @param job
* @return
*/
ExecutionSummary getExecutionSummary(JobInterface job);
/**
*
* @param job
* @return
*/
FrameDetail findHighestMemoryFrame(JobInterface job);
/**
*
* @param job
* @return
*/
FrameDetail findLowestMemoryFrame(JobInterface job);
/**
* Return the frame state totals by layer.
*
* @param layer
* @return
*/
FrameStateTotals getFrameStateTotals(LayerInterface layer);
/**
* Return the execution summary by layer.
*
* @param layer
* @return
*/
ExecutionSummary getExecutionSummary(LayerInterface layer);
/**
* Update the checkpoint state for the given frame.
*
* @param frame
* @param state
*/
void updateCheckpointState(FrameInterface frame, CheckpointState state);
/**
* Return a list of frames that failed to checkpoint within the given checkpoint point.
*
* @param cutoffTimeMs
* @return
*/
List<FrameInterface> getStaleCheckpoints(int cutoffTimeSec);
/**
* Return a list of registered layer outputs.
*
* @param layer
* @return
*/
List<String> getLayerOutputs(LayerInterface layer);
/**
* Register layer output.
*
* @param layer
* @return
*/
void registerLayerOutput(LayerInterface layer, String filespec);
/**
* Return thread stats for the given layer.
*
* @param layer
* @return
*/
List<ThreadStats> getThreadStats(LayerInterface layer);
/**
* Update the dispatch order for the given layer.
*
* @param layer
* @param order
*/
void setLayerDispatchOrder(LayerInterface layer, int order);
/**
* Update the max core value for the given layer.
*
* @param layer
* @param coreUnits
*/
void setLayerMaxCores(LayerInterface layer, int coreUnits);
/**
* Update the min core value for the given layer.
*
* @param layer
* @param coreUnits
*/
void setLayerMinCores(LayerInterface layer, int coreUnits);
/**
* Update the max gpu value for the given layer.
*
* @param layer
* @param gpuUnits
*/
void setLayerMaxGpus(LayerInterface layer, int gpuUnits);
/**
* Update the min gpu value for the given layer.
*
* @param layer
* @param gpuUnits
*/
void setLayerMinGpus(LayerInterface layer, int gpuUnits);
/**
* Add a limit to the given layer.
*
* @param layer
* @param limitId
*/
void addLayerLimit(LayerInterface layer, String limitId);
/**
* Remove a limit from the given layer.
*
* @param layer
* @param limitId
*/
void dropLayerLimit(LayerInterface layer, String limitId);
/**
* Return a list of limits for the given layer.
*
* @param layer
*/
List<LimitEntity> getLayerLimits(LayerInterface layer);
/**
* Update email(s) of subscribers for job
*
* @param job
* @param email
*/
void updateEmail(JobInterface job, String email);
/**
* Return a list of limits for the given layer.
*
* @param job
*/
String getEmail(JobInterface job);
}