-
Notifications
You must be signed in to change notification settings - Fork 2
Container Jobs Functions Contract
DantheJack edited this page Nov 26, 2019
·
4 revisions
In order to answer these functions, you will need to have a database already full of jobs and you will need to have all the end_times calculated and written down in the database (end_time = arrival_time + duration).
- Function name : least_arrival_time
- Full definition : int arrival_time least_arrival_time()
- Parameters : none
- Description : You have to read all the jobs in the database and to find the one that has the least arrival time AND that has the status “WAITING”. It might be several jobs corresponding to this definition, but it does not matter. All I need is the arrival_time of this job, return as an integer.
- Exceptions : If there is no jobs corresponding to this definition, send me -1.
- Function name : foreman_done
- Full definition : list[[int job_id][char container_type]] foreman_done(int sys_time)
- Parameters : sys_time as an integer
- Description : First of all, you need to find all the jobs in your database that have an end_time equal or smaller than the sys_time variable that you received in argument and that have the status “PROCESSING”. I need you to return them all to me as a list of server_id and container_type. Then you will have to update all the status of the jobs corresponding to the definition above, and to modify all their “PROCESSING” status to “DONE”.
- Exceptions : If there are no jobs that have an end_time equal or smaller than sys_time, just send me a list containing only one unique row, with -1 as server_id and ‘X’ as container_type.
- Function name : foreman_waiting
- Full definition : list[[int job_id][char container_type]] foreman_waiting(int sys_time)
- Parameters : sys_time as an integer
- Description : First of all, you need to find all the jobs in your database that have an arrival_time equal to the sys_time variable that you received in argument. I need you to return them all to me as a list of job_id and container_type.
- Exceptions : If there are no jobs that have an arrival_time equal or smaller than sys_time, just send me a list containing only one unique row, with -1 as job_id and ‘X’ as container_type.
- Function name : ack_allocation
- Full definition : int ack_allocation(int job_id, int server_id)
- Parameters : job_id as an integer, server_id as an integer
- Description : You have to read all the jobs in the database and to find the one that has the same job_id as the job_id given as argument. You can then replace the null value of the “server_id” field by the server_id given as argument, and update its status from “WAITING” to “PROCESSING”. Then return a 1.
- Exceptions : If you cannot find a job with the corresponding id, send -1. If you can find a job, but it already has a value in its “server_id” field or that it already has the status “PROCESSING”, send 0.
- Function name : least_end_time
- Full definition : int arrival_time least_end_time()
- Parameters : none
- Description : If everything is normal, you should have no more “WAITING” status at this point. I would like if you can read all the database, before doing the following task, to verify that there is no “WAITING” at all. When this function is called, you are expected to do only one task : You have to read all the jobs in the database and to find the one that has the least arrival time AND that has the status “PROCESSING”. It might be several jobs corresponding to this definition, but it does not matter. All I need is the arrival_time of this job, return as an integer.
- Exceptions : If there is no jobs corresponding to this definition, send me -1. If you see one or more “WAITING” during your first scan, you can return 0 directly.