On Mon, Aug 30, 2010 at 4:24 PM, Mike Peters
<cassan...@softwareprojects.com> wrote:
> Have you considered instead of retrying the failing node, to iterate through
> other nodes in your cluster?


Yes, the $this->connect() does just that: it removes the previous node
from the node list and gives the list back to thrift connection
function. In case all nodes have been tried (and thus removed) it
refills the node list and starts looping it again. In practice this
will never happen but the code is there just to be sure :)

 - Juho Mäkinen



>
> If one node is failing (let's assume it's overloaded for a minute), you're
> probably going to be better off having the client send the insert to the
> next node in line.
>
> Thoughts?
>
> On 8/30/2010 9:17 AM, Juho Mäkinen wrote:
>>
>> Yes, I've already planning to do so. The class has still some
>> dependencies into our other functions which I need to first clear out.
>>
>> Basically each api call is wrapped inside a retry loop as we can
>> assume that each operation can be retried as many times as needed:
>>                $tries = 0;
>>                $this->last_exception = null;
>>                $delay = 1000; // start with 1ms retry delay
>>                do {
>>                        try {
>>                                $this->client->insert($this->keyspace,
>> $key, $column_path, $value,
>> $timestamp, $consistency_level);
>>                                return;
>>                        } catch (cassandra_InvalidRequestException $e) {
>>                                Logger::error("InvalidRequestException: " .
>> $e->why . ',
>> stacktrace: ' . $e->getMessage());
>>                                throw $e;
>>                        } catch (Exception $e) {
>>                                $this->last_exception = $e;
>>                                $tries++;
>>
>>                                // sleep for some time and try again
>>                                usleep($delay);
>>                                $delay = $delay * 3;
>>                                $this->connect(); // Drop current server
>> and reopen a connection
>> into another server
>>                        }
>>
>>
>>
>>                } while ($tries<  4);
>>                // Give up and throw the last exception
>>                throw $this->last_exception;
>>
>>
>>  - Juho Mäkinen
>>
>> On Mon, Aug 30, 2010 at 3:48 PM, Mike Peters
>> <cassan...@softwareprojects.com>  wrote:
>>>
>>> Juho, do you mind sharing your implementation with the group?
>>>
>>> We'd love to help as well with rewriting the thrift interface,
>>> specificaly
>>> TSocket.php which seems to be where the majority of the problems are
>>> lurking.
>>>
>>> Has anyone tried compiling native thrift support as described here
>>> https://wiki.fourkitchens.com/display/PF/Using+Cassandra+with+PHP
>>> https://wiki.fourkitchens.com/display/PF/Using+Cassandra+with+PHP
>>> --
>>> View this message in context:
>>> http://cassandra-user-incubator-apache-org.3065146.n2.nabble.com/Thrift-PHP-help-tp5437314p5478057.html
>>> Sent from the cassandra-u...@incubator.apache.org mailing list archive at
>>> Nabble.com.
>>>
>>
>
>

Reply via email to