deanhiller / playorm

ORM for nosql with SCALABLE SQL
https://github.com/deanhiller/playorm/wiki
Other
76 stars 18 forks source link

Astyanax retry policy is missing as configuration option #32

Open nadenf opened 11 years ago

nadenf commented 11 years ago

To make PlayOrm more robust it would be very useful to add configuration for Astyanax's retry policy:

CassandraSession.java:

ColumnList<String> result = keyspace.prepareQuery(CF_STANDARD1)
    .withRetryPolicy(new ExponentialBackoff(250, 5))
    .getKey(rowKey)
    .execute().getResult();

So for example in application.conf we could have:

nosql.cassandra.retryPolicy=none, ntimes, exponential, constant, boundedexponential

nosql.cassandra.retryPolicy.ntimes.maxAttempts=5

nosql.cassandra.retryPolicy.constant.sleepTime=250
nosql.cassandra.retryPolicy.constant.maxAttempts=5

nosql.cassandra.retryPolicy.exponential.baseSleepTime=250
nosql.cassandra.retryPolicy.exponential.maxAttempts=5

nosql.cassandra.retryPolicy.boundedexponential.baseSleepTime=250
nosql.cassandra.retryPolicy.boundedexponential.maxSleepTime=5000
nosql.cassandra.retryPolicy.boundedexponential.maxAttempts=5

Alternatively we can make it simpler in the config and then decide which mode to use in the code:

nosql.cassandra.retry=true
nosql.cassandra.retry.maxAttempts=10
nosql.cassandra.retry.useExponentialSleepTime=true
nosql.cassandra.retry.sleepTimeBetweenAttempts=250
nosql.cassandra.retry.maxSleepTimeBetweenAttempts=5000

See here: https://github.com/Netflix/astyanax/wiki/Customizing-calls

deanhiller commented 11 years ago

We actually allow you to inject the astyanax client itself ;) so you can do what you want today ;) . That said, I am going to modify this requirement to say that for our default astyanax client that we create for you(when you don't inject your own), This requirement is now we want to change BootstrapImpl.createBestConfig such that we use reflection on the method names so they can chain the above methods and we automatically pass it through from the properties they give us to calling the correct methods. In this fashion, whatever properties astyanax adds would be automatically accessible so as we upgrade, the new functions are exposed without any work on our part.

deanhiller commented 11 years ago

NOTE: Check on issue #33 and make sure that works before this ticket is closed. Both 33 and 32 is really the same work that needs to be done but just perhaps different testing.

hsn10 commented 11 years ago

Default astyanax policy needs to be changed. Currently if i am using playframework plugin and restart cassandra then all previously opened connection will fail and present error page to user.

Astyanax has ExecuteWithFailover and RetryPolicy. It should be configured by default to retry connection before throwing error.