コード例 #1
0
 public function activateResource()
 {
     if (!$this->getID()) {
         throw new Exception(pht('Trying to activate a resource which has not yet been persisted.'));
     }
     $expect_status = DrydockResourceStatus::STATUS_PENDING;
     $actual_status = $this->getStatus();
     if ($actual_status != $expect_status) {
         throw new Exception(pht('Trying to activate a resource from the wrong status. Status must ' . 'be "%s", actually "%s".', $expect_status, $actual_status));
     }
     $this->openTransaction();
     $this->setStatus(DrydockResourceStatus::STATUS_ACTIVE)->save();
     DrydockSlotLock::acquireLocks($this->getPHID(), $this->slotLocks);
     $this->slotLocks = array();
     $this->saveTransaction();
     $this->isActivated = true;
     return $this;
 }
コード例 #2
0
 public function activateOnResource(DrydockResource $resource)
 {
     $expect_status = DrydockLeaseStatus::STATUS_ACQUIRED;
     $actual_status = $this->getStatus();
     if ($actual_status != $expect_status) {
         throw new Exception(pht('Trying to activate a lease which has the wrong status: status ' . 'must be "%s", actually "%s".', $expect_status, $actual_status));
     }
     if ($resource->getStatus() == DrydockResourceStatus::STATUS_PENDING) {
         // TODO: Be stricter about this?
         throw new Exception(pht('Trying to activate a lease on a pending resource.'));
     }
     $this->openTransaction();
     $this->setStatus(DrydockLeaseStatus::STATUS_ACTIVE)->save();
     DrydockSlotLock::acquireLocks($this->getPHID(), $this->slotLocks);
     $this->slotLocks = array();
     $this->saveTransaction();
     $this->isActivated = true;
     $this->didActivate();
     return $this;
 }
コード例 #3
0
 public function activateResource()
 {
     if (!$this->getID()) {
         throw new Exception(pht('Trying to activate a resource which has not yet been persisted.'));
     }
     $expect_status = DrydockResourceStatus::STATUS_PENDING;
     $actual_status = $this->getStatus();
     if ($actual_status != $expect_status) {
         throw new Exception(pht('Trying to activate a resource from the wrong status. Status must ' . 'be "%s", actually "%s".', $expect_status, $actual_status));
     }
     $this->openTransaction();
     try {
         DrydockSlotLock::acquireLocks($this->getPHID(), $this->slotLocks);
         $this->slotLocks = array();
     } catch (DrydockSlotLockException $ex) {
         $this->killTransaction();
         $this->logEvent(DrydockSlotLockFailureLogType::LOGCONST, array('locks' => $ex->getLockMap()));
         throw $ex;
     }
     $this->setStatus(DrydockResourceStatus::STATUS_ACTIVE)->save();
     $this->saveTransaction();
     $this->isActivated = true;
     $this->didActivate();
     return $this;
 }