'Check if a job is ready to run by verifying that each of its input
datasets is ready (specifically in the OK state). If any input dataset
has an error, fail the job and return JOB_INPUT_ERROR. If any input
dataset is deleted, fail the job and return JOB_INPUT_DELETED.  If all
input datasets are in OK state, return JOB_READY indicating that the
job can be dispatched. Otherwise, return JOB_WAIT indicating that input
datasets are still being prepared.'

def __check_job_state(self, job):

    if (not self.track_jobs_in_database):
        in_memory_not_ready_state = self.__verify_in_memory_job_inputs(job)
        if in_memory_not_ready_state:
            return in_memory_not_ready_state
    job_id = job.id
    job_wrapper = self.job_wrappers.get(job_id, None)
    if (not job_wrapper):
        job_wrapper = self.job_wrapper(job)
        self.job_wrappers[job_id] = job_wrapper
    (state, job_destination) = self.__verify_job_ready(job, job_wrapper)
    if (state == JOB_READY):
        self.increase_running_job_count(job.user_id, job_destination.id)
    return state
