remove the job from the state.
        if means that next time we run, this job will start over from scratch.
329745
def reset_job(self, description):
        
        class_list = self.config.crontabber.jobs.class_list
        class_list = self._reorder_class_list(class_list)
        for class_name, job_class in class_list:
            if (
                job_class.app_name == description or
                description == job_class.__module__ + '.' + job_class.__name__
            ):
                if job_class.app_name in self.job_state_database:
                    self.config.logger.info('App reset')
                    self.job_state_database.pop(job_class.app_name)
                else:
                    self.config.logger.warning('App already reset')
                return
        raise JobNotFoundError(description)
17246
def removeRecordState( self, state ):
        
        curr_state = self.recordState()
        if curr_state & state:
            self.setRecordState(curr_state ^ state)
1224658
public static void clear() {
        JobContext ctx = current_.get();
        if (null != ctx) {
            ctx.bag_.clear();
            JobContext parent = ctx.parent;
            if (null != parent) {
                current_.set(parent);
                ctx.parent = null;
            } else {
                current_.remove();
                Act.eventBus().trigger(new JobContextDestroyed(ctx));
            }
        }
    }
615117
public void unregisterJob(GramJob job) {
	String id = job.getIDAsString();
	_jobs.remove(id);
    }
975288
def clear_jobs(self, recursive=True):
        
        if recursive:
            self._scatter_link.clear_jobs(recursive)
        self.jobs.clear()
1013952
public boolean startJob(final Long jobId) {

		final ScheduledJob job = removeFromQueueInternal(jobId);

		if (job != null) {
			activeJobs.put(jobId, job);
			job.startJob();
			return true;
		} else {
			return false;
		}
	}
485709
@Override
  public final void abortJob(org.apache.hadoop.mapreduce.JobContext context, 
                          org.apache.hadoop.mapreduce.JobStatus.State runState) 
  throws IOException {
    int state = JobStatus.getOldNewJobRunState(runState);
    if (state != JobStatus.FAILED && state != JobStatus.KILLED) {
      throw new IOException ("Invalid job run state : " + runState.name());
    }
    abortJob((JobContext) context, state);
  }
985223
def cleanup(api_instance=None):
    
    api = api_instance or get_api()
    r = api.list_job_for_all_namespaces()
    delete_opts = kubernetes.client.V1DeleteOptions(
            propagation_policy="Background")
    for job in r.items:
        if job.status.succeeded == job.spec.completions:
            print(job.metadata.name, "finished!")
            api.delete_namespaced_job(
                job.metadata.name, 'default', body=delete_opts)
90054
private void purgeDeadJobInstances(DbConn cnx, Node node)
    {
        for (JobInstance ji : JobInstance.select(cnx, "ji_select_by_node", node.getId()))
        {
            try
            {
                cnx.runSelectSingle("history_select_state_by_id", String.class, ji.getId());
            }
            catch (NoResultException e)
            {
                History.create(cnx, ji, State.CRASHED, Calendar.getInstance());
                Message.create(cnx,
                        "Job was supposed to be running at server startup - usually means it was killed along a server by an admin or a crash",
                        ji.getId());
            }

            cnx.runUpdate("ji_delete_by_id", ji.getId());
        }
        cnx.commit();
    }
602197
def start(self):
        

        logger.info('Job {0} starting job run'.format(self.name))
        if not self.state.allow_start:
            raise DagobahError('job cannot be started in its current state; ' +
                               'it is probably already running')

        self.initialize_snapshot()

        # don't increment if the job was run manually
        if self.cron_iter and datetime.utcnow() > self.next_run:
            self.next_run = self.cron_iter.get_next(datetime)

        self.run_log = {'job_id': self.job_id,
                        'name': self.name,
                        'parent_id': self.parent.dagobah_id,
                        'log_id': self.backend.get_new_log_id(),
                        'start_time': datetime.utcnow(),
                        'tasks': {}}
        self._set_status('running')

        logger.debug('Job {0} resetting all tasks prior to start'.format(self.name))
        for task in self.tasks.itervalues():
            task.reset()

        logger.debug('Job {0} seeding run logs'.format(self.name))
        for task_name in self.ind_nodes(self.snapshot):
            self._put_task_in_run_log(task_name)
            self.tasks[task_name].start()

        self._commit_run_log()
1037822
public void clearJob() {
    EncodedImage oldEncodedImage;
    synchronized (this) {
      oldEncodedImage = mEncodedImage;
      mEncodedImage = null;
      mStatus = 0;
    }
    EncodedImage.closeSafely(oldEncodedImage);
  }
1254207
function abort(state)
{
  Object.keys(state.jobs).forEach(clean.bind(state));

  // reset leftover jobs
  state.jobs = {};
}
166480
def run(self):
        
        while not self.stopped:
            now = datetime.utcnow()
            for job in self.parent.jobs:
                if not job.next_run:
                    continue
                if job.next_run >= self.last_check and job.next_run <= now:
                    if job.state.allow_start:
                        job.start()
                    else:
                        job.next_run = job.cron_iter.get_next(datetime)
            self.last_checked = now
            time.sleep(1)
331005
def clean_old_jobs():
    '''
    
    '''
    if __opts__['keep_jobs'] != 0:
        jid_root = _job_dir()

        if not os.path.exists(jid_root):
            return

        # Keep track of any empty t_path dirs that need to be removed later
        dirs_to_remove = set()

        for top in os.listdir(jid_root):
            t_path = os.path.join(jid_root, top)

            if not os.path.exists(t_path):
                continue

            # Check if there are any stray/empty JID t_path dirs
            t_path_dirs = os.listdir(t_path)
            if not t_path_dirs and t_path not in dirs_to_remove:
                dirs_to_remove.add(t_path)
                continue

            for final in t_path_dirs:
                f_path = os.path.join(t_path, final)
                jid_file = os.path.join(f_path, 'jid')
                if not os.path.isfile(jid_file) and os.path.exists(f_path):
                    # No jid file means corrupted cache entry, scrub it
                    # by removing the entire f_path directory
                    shutil.rmtree(f_path)
                elif os.path.isfile(jid_file):
                    jid_ctime = os.stat(jid_file).st_ctime
                    hours_difference = (time.time() - jid_ctime) / 3600.0
                    if hours_difference > __opts__['keep_jobs'] and os.path.exists(t_path):
                        # Remove the entire f_path from the original JID dir
                        try:
                            shutil.rmtree(f_path)
                        except OSError as err:
                            log.error('Unable to remove %s: %s', f_path, err)

        # Remove empty JID dirs from job cache, if they're old enough.
        # JID dirs may be empty either from a previous cache-clean with the bug
        # Listed in #29286 still present, or the JID dir was only recently made
        # And the jid file hasn't been created yet.
        if dirs_to_remove:
            for t_path in dirs_to_remove:
                # Checking the time again prevents a possible race condition where
                # t_path JID dirs were created, but not yet populated by a jid file.
                t_path_ctime = os.stat(t_path).st_ctime
                hours_difference = (time.time() - t_path_ctime) / 3600.0
                if hours_difference > __opts__['keep_jobs']:
                    shutil.rmtree(t_path)
801933
def delete(self):
        
        if self.jenkins_host.has_job(self.name):
            LOGGER.info("deleting {0}...".format(self.name))
            self.jenkins_host.delete_job(self.name)
267585
def clean():
    
    for queue in MyQueue.collection().instances():
        queue.delete()
    for job in MyJob.collection().instances():
        job.delete()
    for person in Person.collection().instances():
        person.delete()
239322
private synchronized boolean canLaunchJobCleanupTask() {
    // check if the job is running
    if (status.getRunState() != JobStatus.RUNNING &&
        status.getRunState() != JobStatus.PREP) {
      return false;
    }
    // check if cleanup task has been launched already or if setup isn't
    // launched already. The later check is useful when number of maps is
    // zero.
    if (launchedCleanup || !isSetupFinished()) {
      return false;
    }
    // check if job has failed or killed
    if (jobKilled || jobFailed) {
      return true;
    }

    boolean mapsDone = ((finishedMapTasks + failedMapTIPs) == (numMapTasks));
    boolean reducesDone = ((finishedReduceTasks + failedReduceTIPs) == numReduceTasks);
    boolean mapOnlyJob = (numReduceTasks == 0);

    if (mapOnlyJob) {
      return mapsDone;
    }
    if (jobFinishWhenReducesDone) {
      return reducesDone;
    }
    return mapsDone && reducesDone;
  }