Ejemplo n.º 1
0
 private function _getKeys($startToken, $endToken, $count)
 {
     $count = (int) $count;
     if ($count < 1) {
         $count = 1;
     }
     $cass = Cassandra::getAccessor($this->_getCassServiceName());
     $cf = $cass->cf($this->_getColumnFamilyName(), false);
     echo "Start token: " . $startToken . "\n";
     $tokens = $cf->getTokens($startToken, $startToken, $count);
     foreach (array_keys($tokens) as $key) {
         echo md5($key) . " - " . $key . "\n";
     }
     echo "\n";
     echo "End token: " . $endToken . "\n";
     $tokens = $cf->getTokens($endToken, $endToken, $count);
     foreach (array_keys($tokens) as $key) {
         echo md5($key) . " - " . $key . "\n";
     }
     echo "\n";
 }
Ejemplo n.º 2
0
 private function _getCF($refresh = false)
 {
     if ($refresh || !$this->_cf) {
         EventManager::trigger(Events::CASS_CONNECT_START);
         $cass = Cassandra::getAccessor($this->_cassandraServiceName);
         if ($refresh) {
             $cass->disconnect();
             $tries = 0;
             while (true) {
                 try {
                     $cass->connect();
                     break;
                 } catch (\Exception $e) {
                     $tries++;
                     if ($tries >= 5) {
                         throw $e;
                     }
                     Log::info('Connect failed. Retrying...');
                     usleep($tries * 10000);
                 }
             }
         }
         $this->_cf = $cass->cf($this->_columnFamily, false);
         $this->setColumnDataType($this->_columnDataType);
         $this->setReadConsistencyLevel($this->_readConsistencyLevel);
         $this->setWriteConsistencyLevel($this->_writeConsistencyLevel);
         $this->setCassTimeout($this->_cassSendTimeout, $this->_cassReceiveTimeout);
         $this->_processor->sourceColumnFamily = $this->_cf;
         EventManager::trigger(Events::CASS_CONNECT_END);
     }
     return $this->_cf;
 }