Gets the task that updates the ASG information periodically.

@return TimerTask that updates the ASG information periodically.
425206
private TimerTask getASGUpdateTask() {
        return new TimerTask() {

            @Override
            public void run() {
                try {
                    if (!serverConfig.shouldUseAwsAsgApi()) {
                        // Disabled via the config, no-op.
                        return;
                    }

                    // First get the active ASG names
                    Set<CacheKey> cacheKeys = getCacheKeys();
                    if (logger.isDebugEnabled()) {
                        logger.debug("Trying to  refresh the keys for {}", Arrays.toString(cacheKeys.toArray()));
                    }
                    for (CacheKey key : cacheKeys) {
                        try {
                            asgCache.refresh(key);
                        } catch (Throwable e) {
                            logger.error("Error updating the ASG cache for {}", key, e);
                        }

                    }

                } catch (Throwable e) {
                    logger.error("Error updating the ASG cache", e);
                }

            }

        };
    }
1197716
private function checkTask()
    {
        $settings  = App::getAppProperties()->get('server');
        $settings  = $settings['setting'];
        $collector = SwooleListenerCollector::getCollector();

        $isConfigTask  = isset($settings['task_worker_num']) && $settings['task_worker_num'] > 0;
        $isInstallTask = isset($collector[SwooleEvent::TYPE_SERVER][SwooleEvent::ON_TASK]) && isset($collector[SwooleEvent::TYPE_SERVER][SwooleEvent::ON_FINISH]);

        if ($isConfigTask && !$isInstallTask) {
            throw new InvalidArgumentException("Please 'composer require swoft/task' or set task_worker_num=0 !");
        }

        if (!$isConfigTask && $isInstallTask) {
            throw new InvalidArgumentException('Please set task_worker_num > 0 !');
        }
    }
1095419
public function getAwsSdk()
    {
        if (empty($this->_awssdk) || !$this->_awssdk instanceof Aws\Sdk) {
            $this->setAwsSdk();
        }
        return $this->_awssdk;
    }
40133
public function save() {
    if ($this->id) {
      return self::update($this->id, $this);
    }
    else {
      $new = self::create($this);
      $this->task_id = $new->task_id;
      return $this;
    }
  }
1360453
public static WorkQueue getWorkQueue() {
        if (singleton == null) {
            synchronized (WorkQueue.class) {
                if (singleton == null)
                    // REMINDER: default number of threads?
                    singleton = new WorkQueue(); 
            }
        }
        return singleton;
    }
864568
public function dequeue()
    {
        // if there is only one queue defined, let's use that
        if(count($this->getQueues()) === 1) {
            return $this->getFirstQueue()->dequeue();
        }

        // default: getting a task using the current task selector strategy
        return $this->selectorStrategy->pickNextTask($this->getQueues());
    }
72603
public function process()
    {
        $taskRows = $this->getTasksWithAssignedSite();
        $legacySchedulerTasks = $taskRows->fetchAll();
        $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable("tx_scheduler_task");

        $status = FlashMessage::OK;
        $title = 'Remove site from scheduler task';
        $failedTaskCount = 0;
        $migratedTaskCount = 0;
        foreach ($legacySchedulerTasks as $legacySchedulerTask) {
            try {
                $uid = $legacySchedulerTask['uid'];
                $task = unserialize($legacySchedulerTask['serialized_task_object']);
                $task->setRootPageId($task->getSite()->getRootPageId());
                $updatedTask = serialize($task);
                $updatedRows = $queryBuilder->update('tx_scheduler_task')
                    ->where($queryBuilder->expr()->eq('uid', $uid))
                    ->set('serialized_task_object', $updatedTask)
                    ->execute();

                $migratedTaskCount += $updatedRows;
            } catch (\Exception $e) {
                $failedTaskCount++;
                $status = FlashMessage::ERROR;
            }
        }

        $message = 'Migrated ' . (int)$migratedTaskCount . ' scheduler tasks! Update of ' . (int)$failedTaskCount . ' failed!';
        return [$status, $title, $message];
    }
1087660
protected function getStatistics() {
        if (!$this->_statistics) {
            $this->_statistics = new TaskStatisticsList(
                $this->version,
                $this->solution['assistantSid'],
                $this->solution['sid']
            );
        }

        return $this->_statistics;
    }
233603
public BoxFutureTask<BoxSession> refresh() {
        if (mRefreshTask != null && mRefreshTask.get() != null){
            BoxFutureTask<BoxSession> lastRefreshTask = mRefreshTask.get();
            if (!(lastRefreshTask.isCancelled() || lastRefreshTask.isDone())){
                return lastRefreshTask;
            }
        }
        final BoxFutureTask<BoxSession> task = (new BoxSessionRefreshRequest(this)).toTask();
        new Thread(){
            @Override
            public void run() {
                task.run();
            }
        }.start();
        mRefreshTask = new WeakReference<BoxFutureTask<BoxSession>>(task);
        return task;
    }
234364
protected function proxy() {
        if (!$this->context) {
            $this->context = new TaskContext(
                $this->version,
                $this->solution['workspaceSid'],
                $this->solution['sid']
            );
        }

        return $this->context;
    }
436116
public function saveTaskRun()
    {
        //if monolog not found does nothing
        if (!class_exists('Monolog\Logger')) {
            return false;
        }
        $logger = new Logger('cron_logger');
        $logger->pushHandler(new RotatingFileHandler($this->logs_folder . $this->log_name));
        $task = TaskFile::taskGet($this->task_id);
        if (self::RUN_STATUS_STARTED == $this->status) {
            $message = 'task ' . $task->getCommand() . ' just started';
        } else {
            $message = 'task ' . $task->getCommand() . ' ended with status ' . $this->status
                . ', execution time ' . $this->execution_time . ', output: ' . PHP_EOL . $this->output;
        }
        return $logger->addNotice($message);
    }
116012
public Task obtainJobSetupTask(TaskTrackerStatus tts,
                                             int clusterSize,
                                             int numUniqueHosts,
                                             boolean isMapSlot
                                            ) throws IOException {
    if(!tasksInited.get() || !jobSetupCleanupNeeded) {
      return null;
    }

    synchronized(this) {
      if (!canLaunchSetupTask()) {
        return null;
      }
      String taskTracker = tts.getTrackerName();
      // Update the last-known clusterSize
      this.clusterSize = clusterSize;
      if (!shouldRunOnTaskTracker(taskTracker)) {
        return null;
      }

      List<TaskInProgress> setupTaskList = new ArrayList<TaskInProgress>();
      if (isMapSlot) {
        setupTaskList.add(setup[0]);
      } else {
        setupTaskList.add(setup[1]);
      }
      TaskInProgress tip = findTaskFromList(setupTaskList,
                             tts, numUniqueHosts, false);
      if (tip == null) {
        return null;
      }

      // Now launch the setupTask
      Task result = tip.getTaskToRun(tts.getTrackerName());
      if (result != null) {
        addRunningTaskToTIP(tip, result.getTaskID(), tts, true);
      }
      return result;
    }
  }
1115936
public function getTasks()
    {

        //build URI
        $strURI = Product::$baseProductUri . '/tasks/' . $this->getFileName() . '/tasks';

        //sign URI
        $signedURI = Utils::sign($strURI);

        $responseStream = Utils::processCommand($signedURI, 'GET', '', '');

        $json = json_decode($responseStream);

        if ($json->Code == 200)
            return $json->Tasks->TaskItem;
        else
            return false;
    }
723100
private function needsSchedulingForSynchronization()
    {
        return $this->owner && $this->dm && ! empty($this->mapping['isOwningSide'])
            && $this->dm->getClassMetadata(get_class($this->owner))->isChangeTrackingNotify();
    }
1349159
public function collectGarbage()
    {
        $this->synchronized(function () {
            foreach ($this->timerTasks as $taskId => $timerTask) {
                if ($timerTask->isRunning()) {
                    continue;
                } else {
                    unset($this->timerTasks[$taskId]);
                }
            }
        });
    }
218732
public TaskEntity getParentTask() {
    if ( parentTask == null && parentTaskId != null) {
      this.parentTask = Context.getCommandContext()
                                .getTaskManager()
                                .findTaskById(parentTaskId);
    }
    return parentTask;
  }
815395
public function isAlwaysTask()
    {
        $isAlwaysTask = false;
        try {
            $job = $this->getJob();
            $isAlwaysTask = $job && $job->isAlwaysTask();
        } catch (Exception $e) {
            Mage::logException($e);
        }
        return $isAlwaysTask;
    }