/**
  * @param  \Kbrw\RiakBundle\Model\Cluster\Cluster $cluster
  * @return array<string,string>
  */
 public function getConfig($cluster)
 {
     $config = array();
     $config["protocol"] = $cluster->getProtocol();
     $config["domain"] = $cluster->getDomain();
     $config["port"] = $cluster->getPort();
     return $config;
 }
 /**
  * @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;
 }
 /**
  * @param  \Kbrw\RiakBundle\Model\Cluster\Cluster $cluster
  * @return array<string,string>
  */
 public function getConfig($cluster, $buckets = null)
 {
     $config = array();
     $config["protocol"] = $cluster->getProtocol();
     $config["domain"] = $cluster->getDomain();
     $config["port"] = $cluster->getPort();
     $config["buckets"] = $buckets;
     return $config;
 }
 /**
  * @test
  */
 public function getNonExistingBucket()
 {
     // check that a default bucket has been created
     $this->assertEquals(3, $this->cluster->getBucket("bar")->getProps()->getNVal());
     // check that already known buckets are kept untouched
     $this->assertEquals(5, $this->cluster->getBucket("foo")->getProps()->getNVal());
 }
 /**
  * @param  \Kbrw\RiakBundle\Model\Cluster\Cluster $cluster
  * @param  \Kbrw\RiakBundle\Model\Bucket\Bucket   $bucket
  * @param  array<string>                          $keys
  * @return \Kbrw\RiakBundle\Model\KV\Datas
  */
 public function fetch($cluster, $bucket, $keys)
 {
     if (!is_array($keys)) {
         $keys = array($keys);
     }
     $datas = new Datas();
     // Split work in smaller pieces to avoid exception caused by too many opened connections
     if (count($keys) > $cluster->getMaxParallelCalls()) {
         $chunks = array_chunk($keys, $cluster->getMaxParallelCalls());
         foreach ($chunks as $chunk) {
             $datas->addAll($this->fetch($cluster, $bucket, $chunk));
         }
         return $datas;
     }
     foreach ($keys as $key) {
         $key = trim($key);
         $data = new Data($key);
         if (isset($this->content[$key])) {
             $data->setStringContent($this->content[$key]);
             if ($this->contentTypeNormalizer->isFormatSupportedForSerialization($bucket->getFormat())) {
                 /*var_dump($data->getRawContent());
                   var_dump($bucket->getFullyQualifiedClassName());
                   var_dump($bucket->getFormat());
                   exit;*/
                 $riakKVObject = $this->serializer->deserialize($data->getContent(true), $bucket->getFullyQualifiedClassName(), $bucket->getFormat());
                 if ($riakKVObject !== false) {
                     if ($riakKVObject instanceof Transmutable) {
                         $riakKVObject = $riakKVObject->transmute();
                     }
                     $data->setContent($riakKVObject);
                 }
             }
         }
         $datas->add($data);
     }
     return $datas;
 }
 /**
  * @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;
 }
 /**
  * @test
  */
 public function splitFetchRequestsWhenMaxParallelCallsIsReached()
 {
     $riakKVServiceClient = $this->getMockBuilder("Kbrw\\RiakBundle\\Service\\WebserviceClient\\Riak\\RiakKVServiceClient")->setMethods(array("doFetch"))->getMock();
     $riakKVServiceClient->contentTypeNormalizer = $this->getService("kbrw.content.type.normalizer");
     $riakKVServiceClient->serializer = $this->getService("jms_serializer");
     $riakKVServiceClient->logger = $this->getService("logger");
     $riakKVServiceClient->expects($this->exactly(3))->method("doFetch")->will($this->returnValue(new Datas()));
     $bucket = new Bucket();
     $bucket->setFormat("json");
     $cluster = new Cluster();
     $cluster->setMaxParallelCalls(2);
     // the 5 put requests will be done using THREE curl_multi requests
     $riakKVServiceClient->fetch($cluster, $bucket, array("foo1", "foo2", "foo3", "foo4", "foo5"));
 }
 /**
  * @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 array<string,string>
  */
 public function getConfig($cluster, $bucketName, $keys = "stream", $props = false)
 {
     $config = array();
     $config["protocol"] = $cluster->getProtocol();
     $config["domain"] = $cluster->getDomain();
     $config["port"] = $cluster->getPort();
     $config["bucket"] = $bucketName;
     $config["keys"] = $keys;
     $config["props"] = $props ? "true" : null;
     return $config;
 }
Esempio n. 10
0
 /**
  * @return mixed
  */
 public function send()
 {
     return $this->cluster->getRiakMapReduceServiceClient()->mapReduce($this->cluster, $this);
 }