[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class PhabricatorWorkerArchiveTask extends PhabricatorWorkerTask { 4 5 const RESULT_SUCCESS = 0; 6 const RESULT_FAILURE = 1; 7 const RESULT_CANCELLED = 2; 8 9 protected $duration; 10 protected $result; 11 12 public function getConfiguration() { 13 $config = array( 14 // We manage the IDs in this table; they are allocated in the ActiveTask 15 // table and moved here without alteration. 16 self::CONFIG_IDS => self::IDS_MANUAL, 17 ) + parent::getConfiguration(); 18 19 20 $config[self::CONFIG_COLUMN_SCHEMA] = array( 21 'result' => 'uint32', 22 'duration' => 'uint64', 23 ) + $config[self::CONFIG_COLUMN_SCHEMA]; 24 25 $config[self::CONFIG_KEY_SCHEMA] = array( 26 'dateCreated' => array( 27 'columns' => array('dateCreated'), 28 ), 29 'leaseOwner' => array( 30 'columns' => array('leaseOwner', 'priority', 'id'), 31 ), 32 ); 33 34 return $config; 35 } 36 37 public function save() { 38 if ($this->getID() === null) { 39 throw new Exception('Trying to archive a task with no ID.'); 40 } 41 42 $other = new PhabricatorWorkerActiveTask(); 43 $conn_w = $this->establishConnection('w'); 44 45 $this->openTransaction(); 46 queryfx( 47 $conn_w, 48 'DELETE FROM %T WHERE id = %d', 49 $other->getTableName(), 50 $this->getID()); 51 $result = parent::insert(); 52 $this->saveTransaction(); 53 54 return $result; 55 } 56 57 public function delete() { 58 $this->openTransaction(); 59 if ($this->getDataID()) { 60 $conn_w = $this->establishConnection('w'); 61 $data_table = new PhabricatorWorkerTaskData(); 62 63 queryfx( 64 $conn_w, 65 'DELETE FROM %T WHERE id = %d', 66 $data_table->getTableName(), 67 $this->getDataID()); 68 } 69 70 $result = parent::delete(); 71 $this->saveTransaction(); 72 return $result; 73 } 74 75 public function unarchiveTask() { 76 $this->openTransaction(); 77 $active = id(new PhabricatorWorkerActiveTask()) 78 ->setID($this->getID()) 79 ->setTaskClass($this->getTaskClass()) 80 ->setLeaseOwner(null) 81 ->setLeaseExpires(0) 82 ->setFailureCount(0) 83 ->setDataID($this->getDataID()) 84 ->setPriority($this->getPriority()) 85 ->insert(); 86 87 $this->setDataID(null); 88 $this->delete(); 89 $this->saveTransaction(); 90 91 return $active; 92 } 93 94 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |