Ejemplo n.º 1
0
 /**
  * Set a node to a value. If the node doesn't exist yet, it is created.
  * Existing values of the node are overwritten
  *
  * @param string $path  The path to the node
  * @param mixed  $value The new value for the node
  *
  * @return mixed previous value if set, or null
  */
 public function set($path, $value)
 {
     if (!$this->zookeeper->exists($path)) {
         $this->makePath($path);
         $this->makeNode($path, $value);
     } else {
         $this->zookeeper->set($path, $value);
     }
 }
Ejemplo n.º 2
0
 /**
  * Commits the given offset for the given partition
  *
  * @param string $topic     the topic the partition belongs to
  * @param int    $broker    the broker holding the partition
  * @param int    $partition the partition on the broker
  * @param int    $offset    the offset to commit
  */
 public function commit($topic, $broker, $partition, $offset)
 {
     $path = sprintf(self::OFFSET_PATH, $this->group, $topic, (int) $broker, (int) $partition);
     if (!$this->zookeeper->exists($path)) {
         $this->makeZkPath($path);
         $this->makeZkNode($path, (int) $offset);
     } else {
         $this->zookeeper->set($path, (int) $offset);
     }
 }
 /**
  * Set a node to a value. If the node doesn't exist yet, it is created.
  * Existing values of the node are overwritten
  *
  * @param string $path  The path to the node
  * @param mixed  $value The new value for the node
  *
  * @return mixed previous value if set, or null
  */
 public function set($path, $value)
 {
     $flag = false;
     if (!$this->zookeeper->exists($path)) {
         $this->makePath($path);
         $flag = $this->makeNode($path, $value);
     } else {
         $flag = $this->zookeeper->set($path, $value);
     }
     return $flag;
 }
Ejemplo n.º 4
0
 function commitOffset($groupId, $topic, $brokerId, $partition, \Kafka\Offset $offset)
 {
     $this->zkConnect();
     $path = "/consumers/{$groupId}/offsets/{$topic}";
     if (!$this->zk->exists($path)) {
         $this->createPermaNode($path);
     }
     if (!$this->zk->exists("{$path}/{$brokerId}-{$partition}")) {
         $this->createPermaNode("{$path}/{$brokerId}-{$partition}", $offset->__toString());
     } else {
         $this->zk->set("{$path}/{$brokerId}-{$partition}", $offset->__toString());
     }
 }