// adjust our count of how many jobs with this schedulerGroup we need in the job // scheduler. func (s *Server) decrementGroupCount(schedulerGroup string, q *queue.Queue) { if s.rc != "" { doSchedule := false doTrigger := false s.sgcmutex.Lock() if _, existed := s.sgroupcounts[schedulerGroup]; existed { s.sgroupcounts[schedulerGroup]-- doSchedule = true //log.Printf("decremented group [%s] to %d\n", schedulerGroup, s.sgroupcounts[schedulerGroup]) if count, set := s.sgrouptrigs[schedulerGroup]; set { s.sgrouptrigs[schedulerGroup]++ if count >= 100 { s.sgrouptrigs[schedulerGroup] = 0 if s.sgroupcounts[schedulerGroup] > 10 { doTrigger = true } } } } s.sgcmutex.Unlock() if doTrigger { // we most likely have completed 100 more jobs for this group, so // we'll trigger our ready callback which will re-calculate the // best resource requirements for the remaining jobs in the group // and then call scheduleRunners q.TriggerReadyAddedCallback() } else if doSchedule { // notify the job scheduler we need less jobs for this job's cmd now; // it will remove extraneous ones from its queue s.scheduleRunners(q, schedulerGroup) } } }