コード例 #1
0
ファイル: JobManagerCest.php プロジェクト: ifigenija/server
 /**
  * Test resetiranja joba
  * @depends testRunJob
  * @param \UnitTester $I
  */
 public function testResetJob(\UnitTester $I)
 {
     $job = $this->job;
     $this->jm->resetJob($job);
     $I->assertEquals(0, $job->getStatus());
     $I->assertEquals(0, count($job->getReports()));
     $I->assertEquals(0, strlen($job->getLog()));
     $I->assertEmpty($job->getAlert());
 }
コード例 #2
0
ファイル: JobManagerTest.php プロジェクト: Maksold/platform
 public function testGetJobStatistics()
 {
     $stat = $this->object->getJobStatistics($this->job);
     $this->assertInternalType('array', $stat);
     $this->assertNotEmpty($stat);
     $this->assertEquals('Time', $stat[0][0]);
     $this->assertEquals('memory', $stat[0][1]);
     $this->assertInternalType('float', $stat[1][1]);
     $this->assertEquals(780, (int) $stat[1][1]);
 }
コード例 #3
0
ファイル: JobManager.php プロジェクト: oktoshi/skyhook
 public static function _init()
 {
     if (self::$initialized) {
         return;
     }
     foreach (glob(__DIR__ . '/JobHandlers/*.php') as $file) {
         $class = "JobHandlers\\" . basename($file, ".php");
         self::addHandler($class);
     }
     self::$initialized = true;
 }
コード例 #4
0
ファイル: EnqueueTrait.php プロジェクト: uafrica/delayed-jobs
 /**
  * Enqueues a batch of similar jobs
  *
  * @param string $worker Worker class to enqueue (In CakePHP format)
  * @param array $jobsToEnqueue Array of jobs to enqueue. Can either be a simple array for the payload, or contain two keys (_payload, and _options)
  * @param array $options Default options for all jobs. Can be overridden with the `_options` key
  * @return array
  */
 public function enqueueBatch($worker, array $jobsToEnqueue, array $options = [])
 {
     $jobs = [];
     foreach ($jobsToEnqueue as $jobInfo) {
         $jobPayload = $jobInfo;
         $jobOptions = $options;
         if (isset($jobInfo['_payload'])) {
             $jobPayload = $jobInfo['_payload'];
         }
         if (isset($jobInfo['_options'])) {
             $jobOptions = $jobInfo['_options'] + $options;
         }
         $job = new Job();
         $job->setWorker($worker)->setPayload($jobPayload)->setData($jobOptions);
         $jobs[] = $job;
     }
     return JobManager::instance()->enqueueBatch($jobs);
 }
コード例 #5
0
ファイル: JobCrudApi.php プロジェクト: rbowen/openstack-org
 public function addJob()
 {
     try {
         $data = $this->getJsonRequest();
         if (!$data) {
             return $this->serverError();
         }
         $job_id = $this->manager->addJob($data);
         return $job_id;
     } catch (NotFoundEntityException $ex1) {
         SS_Log::log($ex1, SS_Log::WARN);
         return $this->notFound($ex1->getMessage());
     } catch (EntityValidationException $ex2) {
         SS_Log::log($ex2, SS_Log::WARN);
         return $this->validationError($ex2->getMessages());
     } catch (Exception $ex) {
         SS_Log::log($ex, SS_Log::ERR);
         return $this->serverError();
     }
 }