/**
  * @param  \Kbrw\RiakBundle\Model\Cluster\Cluster $cluster
  * @param  \Kbrw\RiakBundle\Model\Bucket\Bucket   $bucket
  * @param  \Kbrw\RiakBundle\Model\Search\Query    $query
  * @return array<string,string>
  */
 public function getConfig($cluster, $bucket, $query)
 {
     $config = $query->getConfig();
     $config["protocol"] = $cluster->getProtocol();
     $config["domain"] = $cluster->getDomain();
     $config["port"] = $cluster->getPort();
     $config["bucket"] = $bucket->getName();
     return $config;
 }
Exemplo n.º 2
0
 /**
  * @param  \Kbrw\RiakBundle\Model\Cluster\Cluster $cluster
  * @param  \Kbrw\RiakBundle\Model\Bucket\Bucket   $bucket
  * @return array<string,string>
  */
 public function getConfig($cluster, $bucket, $r = null, $w = null, $dw = null)
 {
     $config = array();
     $config["protocol"] = $cluster->getProtocol();
     $config["domain"] = $cluster->getDomain();
     $config["port"] = $cluster->getPort();
     $config["bucket"] = $bucket->getName();
     $config["r"] = $r;
     $config["w"] = $w;
     $config["dw"] = $dw;
     return $config;
 }
Exemplo n.º 3
0
 /**
  * @test
  */
 public function saveBucketProperties()
 {
     $this->bucket->getProps()->setNVal(5);
     $this->assertTrue($this->bucket->save());
     $this->assertEquals(5, $this->cluster->bucketProperties($this->bucket->getName())->getProps()->getNVal());
 }
 /**
  * @param  \Kbrw\RiakBundle\Model\Cluster\Cluster $cluster
  * @param  \Kbrw\RiakBundle\Model\Bucket\Bucket   $bucket
  * @return boolean
  */
 public function save($cluster, $bucket)
 {
     $request = $this->getClient($cluster->getGuzzleClientProviderService(), $this->getConfig($cluster, $bucket->getName(), null))->put();
     try {
         $extra = array("method" => "PUT");
         $ts = microtime(true);
         $request->setBody($this->serializer->serialize($bucket, "json"));
         $extra["serialization_time"] = microtime(true);
         -$ts;
         $request->setHeader("Content-Type", "application/json");
         $response = $request->send();
         $this->logResponse($response, $extra);
         return $response->getStatusCode() == "204";
     } catch (CurlException $e) {
         $this->logger->err("Riak is unavailable" . $e->getMessage());
         throw new RiakUnavailableException();
     } catch (\Exception $e) {
         $this->logger->err("Error while setting properties on bucket '" . $bucket->getName() . "'. Full message is : " . $e->getMessage());
     }
     return false;
 }