Beispiel #1
0
 function release()
 {
     try {
         $this->zookeeper->delete($this->path);
     } catch (Scalr_Service_Zookeeper_Exception $e) {
         if ($e->getCode() != Scalr_Service_Zookeeper_Exception::NOT_FOUND) {
             throw $e;
         }
     }
 }
Beispiel #2
0
 function nodesCapacity()
 {
     try {
         return $this->zookeeper->get($this->path)->numChildren;
     } catch (Scalr_Service_Zookeeper_Exception $e) {
         if ($e->getCode() == Scalr_Service_Zookeeper_Exception::NOT_FOUND) {
             return 0;
         }
         throw $e;
     }
 }
Beispiel #3
0
 function delete()
 {
     try {
         $this->zookeeper->deleteRecursive($this->path);
     } catch (Scalr_Service_Zookeeper_Exception $ignore) {
     }
 }
Beispiel #4
0
 function clear()
 {
     $this->init();
     $this->lock->acquire();
     try {
         foreach ($this->itemNames() as $name) {
             $this->zookeeper->delete("{$this->path}/{$name}");
         }
         $this->lock->release();
     } catch (Exception $e) {
         $this->lock->release();
         throw $e;
     }
 }
Beispiel #5
0
 private function setStatus($status)
 {
     if ($status != self::STATUS_NOTSET) {
         try {
             $this->zookeeper->set("{$this->path}/status", serialize($status));
         } catch (Scalr_Service_Zookeeper_Exception $e) {
             if ($e->getCode() == Scalr_Service_Zookeeper_Exception::NOT_FOUND) {
                 $this->zookeeper->create("{$this->path}/status", serialize($status));
                 return;
             }
             throw $e;
         }
     } else {
         try {
             $this->zookeeper->delete("{$this->path}/status");
         } catch (Scalr_Service_Zookeeper_Exception $ignore) {
         }
     }
 }
Beispiel #6
0
 /**
  * Delete queue and all her items 
  */
 function delete()
 {
     $this->zookeeper->deleteRecursive($this->path);
 }