// ScheduleSkeleton adds a batch of header retrieval tasks to the queue to fill
// up an already retrieved header skeleton.
541908
func (q *queue) ScheduleSkeleton(from uint64, skeleton []*types.Header) {
	q.lock.Lock()
	defer q.lock.Unlock()

	// No skeleton retrieval can be in progress, fail hard if so (huge implementation bug)
	if q.headerResults != nil {
		panic("skeleton assembly already in progress")
	}
	// Schedule all the header retrieval tasks for the skeleton assembly
	q.headerTaskPool = make(map[uint64]*types.Header)
	q.headerTaskQueue = prque.New(nil)
	q.headerPeerMiss = make(map[string]map[uint64]struct{}) // Reset availability to correct invalid chains
	q.headerResults = make([]*types.Header, len(skeleton)*MaxHeaderFetch)
	q.headerProced = 0
	q.headerOffset = from
	q.headerContCh = make(chan bool, 1)

	for i, header := range skeleton {
		index := from + uint64(i*MaxHeaderFetch)

		q.headerTaskPool[index] = header
		q.headerTaskQueue.Push(index, -int64(index))
	}
}
1140240
func (s *WriteCampaignRequest) SetSchedule(v *Schedule) *WriteCampaignRequest {
	s.Schedule = v
	return s
}
1340127
func (m *MockInterface) Scheduling() v1beta110.SchedulingV1beta1Interface {
	ret := m.ctrl.Call(m, "Scheduling")
	ret0, _ := ret[0].(v1beta110.SchedulingV1beta1Interface)
	return ret0
}
11563
func (c *Client) ScheduledJobs(page uint) ([]*ScheduledJob, int64, error) {
	key := redisKeyScheduled(c.namespace)
	jobsWithScores, count, err := c.getZsetPage(key, page)
	if err != nil {
		logError("client.scheduled_jobs.get_zset_page", err)
		return nil, 0, err
	}

	jobs := make([]*ScheduledJob, 0, len(jobsWithScores))

	for _, jws := range jobsWithScores {
		jobs = append(jobs, &ScheduledJob{RunAt: jws.Score, Job: jws.job})
	}

	return jobs, count, nil
}
775741
func (cli *OpsGenieClient) Schedule() (*OpsGenieScheduleClient, error) {
	cli.makeHTTPTransportSettings()

	scheduleClient := new(OpsGenieScheduleClient)
	scheduleClient.SetOpsGenieClient(*cli)

	if cli.opsGenieAPIURL == "" {
		scheduleClient.SetOpsGenieAPIUrl(endpointURL)
	}

	return scheduleClient, nil
}
845473
func LoadScheduler() error {

	// ensure maps are clean
	clearMaps()

	// ensure queue is empty
	clearQueue()

	LoggingClient.Info("loading intervals, interval actions ...")

	// load data from support-scheduler database
	err := loadSupportSchedulerDBInformation()
	if err != nil {
		LoggingClient.Error("failed to load information from support-scheduler:" + err.Error())
		return err
	}

	// load config intervals
	errLCI := loadConfigIntervals()
	if errLCI != nil {
		LoggingClient.Error("failed to load scheduler config data:" + errLCI.Error())
		return errLCI
	}

	// load config interval actions
	errLCA := loadConfigIntervalActions()
	if errLCA != nil {
		LoggingClient.Error("failed to load interval actions config data:" + errLCA.Error())
		return errLCA
	}

	LoggingClient.Info("finished loading intervals, interval actions")

	return nil
}
83128
func (w *WorkerConfig) scheduler() {
	pollSets := []string{w.nsKey("retry"), w.nsKey("schedule")}

	for _ = range time.Tick(w.PollInterval) {
		w.RLock() // don't let quitHandler() stop us in the middle of a run
		conn := w.RedisPool.Get()
		now := fmt.Sprintf("%f", timeFloat(time.Now()))
		for _, set := range pollSets {
			conn.Send("MULTI")
			conn.Send("ZRANGEBYSCORE", set, "-inf", now)
			conn.Send("ZREMRANGEBYSCORE", set, "-inf", now)
			res, err := redis.Values(conn.Do("EXEC"))
			if err != nil {
				w.handleError(err)
				continue
			}

			for _, msg := range res[0].([]interface{}) {
				parsedMsg := &struct {
					Queue string `json:"queue"`
				}{}
				msgBytes := msg.([]byte)
				err := json.Unmarshal(msgBytes, parsedMsg)
				if err != nil {
					w.handleError(err)
					continue
				}
				if _, err = conn.Do("RPUSH", w.nsKey("queue:"+parsedMsg.Queue), msgBytes); err != nil {
					w.handleError(err)
				}
			}
		}
		conn.Close()
		w.RUnlock()
	}
}
1070905
func (c *Client) DeleteScheduledJob(scheduledFor int64, jobID string) error {
	ok, jobBytes, err := c.deleteZsetJob(redisKeyScheduled(c.namespace), scheduledFor, jobID)
	if err != nil {
		return err
	}

	// If we get a job back, parse it and see if it's a unique job. If it is, we need to delete the unique key.
	if len(jobBytes) > 0 {
		job, err := newJob(jobBytes, nil, nil)
		if err != nil {
			logError("client.delete_scheduled_job.new_job", err)
			return err
		}

		if job.Unique {
			uniqueKey, err := redisKeyUniqueJob(c.namespace, job.Name, job.Args)
			if err != nil {
				logError("client.delete_scheduled_job.redis_key_unique_job", err)
				return err
			}
			conn := c.pool.Get()
			defer conn.Close()

			_, err = conn.Do("DEL", uniqueKey)
			if err != nil {
				logError("worker.delete_unique_job.del", err)
				return err
			}
		}
	}

	if !ok {
		return ErrNotDeleted
	}
	return nil
}
328663
func (s *DeleteBusinessReportScheduleInput) SetScheduleArn(v string) *DeleteBusinessReportScheduleInput {
	s.ScheduleArn = &v
	return s
}
192092
func (js *JobsService) ListScheduled(ctx context.Context) (jobs []*JobSchedule, resp *APIResponse, err error) {
	j := &JobScheduleResponse{}
	_, resp, err = js.client.getAction(ctx, &APIClientRequest{
		Path:         "jobs/scheduled.xml",
		ResponseBody: j,
		ResponseType: responseTypeXML,
	})
	jobs = j.Jobs

	return
}
627706
func NewSchedule(ctx ttnlog.Interface) Schedule {
	s := &schedule{
		ctx:                   ctx,
		items:                 make(map[string]*scheduledItem),
		downlinkSubscriptions: make(map[string]chan *router_pb.DownlinkMessage),
	}
	go func() {
		for {
			<-time.After(10 * time.Second)
			s.RLock()
			numItems := len(s.items)
			s.RUnlock()
			if numItems > 0 {
				s.Lock()
				for id, item := range s.items {
					// Delete the item if we are more than 2 seconds after the deadline
					if time.Now().After(item.deadlineAt.Add(2 * time.Second)) {
						delete(s.items, id)
					}
				}
				s.Unlock()
			}
		}
	}()
	return s
}
147412
func (s *stateTransitions) ScheduleTombstoneToEvict(subject subject) {
	s.Lock()
	s.schedule(subject, Tombstone, s.timeouts.Tombstone, func() {
		// transition the subject to tombstone
		s.node.memberlist.Evict(subject.address())
	})
	s.Unlock()
}
855644
func (sm *schedulerMetrics) ClaimTask(succeeded bool) {
	status := statusString(succeeded)

	sm.claimsComplete.WithLabelValues(status).Inc()
	if succeeded {
		sm.claimsActive.Inc()
	}
}
577687
func NewScheduler() *Scheduler {
	return &Scheduler{
		Sink:             NewHTTPSink(),
		Timer:            timekeeper.RealTime{},
		ErrorHandler:     DefaultErrorHandler,
		ReportingDelayNs: DefaultReportingDelay.Nanoseconds(),
		callbackMap:      make(map[string]*callbackPair),
	}
}
262050
func NewMesosScheduler(master string, uid string, privateKeyFile io.Reader) (scheduler.Scheduler, error) {
	//Create the object
	m := &mesosScheduler{
		master: master,
		uid:    uid,
	}

	//Parse and validate the private key
	if err := m.parsePrivateKey(privateKeyFile); err != nil {
		return nil, err
	}

	//Build the transport
	tr := &http.Transport{
		Proxy: http.ProxyFromEnvironment,
		DialContext: (&net.Dialer{
			Timeout:   30 * time.Second,
			KeepAlive: 30 * time.Second,
			DualStack: true,
		}).DialContext,
		MaxIdleConns:          100,
		IdleConnTimeout:       90 * time.Second,
		TLSHandshakeTimeout:   10 * time.Second,
		ExpectContinueTimeout: 1 * time.Second,
	}

	//If requested ignore the TLS verify
	if viper.GetBool("mesos-skipverify") {
		if tr.TLSClientConfig == nil {
			tr.TLSClientConfig = &tls.Config{
				InsecureSkipVerify: true,
			}
		} else {
			tr.TLSClientConfig.InsecureSkipVerify = true
		}
	}
	client := http.DefaultClient
	client.Transport = tr
	m.client = client

	//Check to see if you can communicate with the Mesos Master
	if _, _, err := m.getMesosMaster(); err != nil {
		return nil, err
	}

	//Create initial authorization token
	if err := m.createAuthorizationToken(); err != nil {
		return nil, err
	}

	return m, nil
}
1374714
func (s *TreatmentResource) SetSchedule(v *Schedule) *TreatmentResource {
	s.Schedule = v
	return s
}
821113
func (s *StateStore) SchedulerConfig() (uint64, *structs.SchedulerConfiguration, error) {
	tx := s.db.Txn(false)
	defer tx.Abort()

	// Get the scheduler config
	c, err := tx.First("scheduler_config", "id")
	if err != nil {
		return 0, nil, fmt.Errorf("failed scheduler config lookup: %s", err)
	}

	config, ok := c.(*structs.SchedulerConfiguration)
	if !ok {
		return 0, nil, nil
	}

	return config.ModifyIndex, config, nil
}