Skip to content

Commit

Permalink
Add Command.execute that accepts a configurable FailoverPolicy
Browse files Browse the repository at this point in the history
  • Loading branch information
rantav committed May 20, 2010
1 parent 344f2fe commit a7aca75
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Expand Up @@ -9,6 +9,7 @@ Changes by version:
0.6.0-14
========
Add getRangeSuperSlices http://github.com/rantav/hector/issues/#issue/38
Add Command.execute that accepts a configurable FailoverPolicy

0.6.0-13
========
Expand Down
25 changes: 20 additions & 5 deletions src/main/java/me/prettyprint/cassandra/dao/Command.java
Expand Up @@ -4,6 +4,8 @@
import me.prettyprint.cassandra.service.CassandraClientPool;
import me.prettyprint.cassandra.service.CassandraClientPoolFactory;
import me.prettyprint.cassandra.service.Keyspace;
import me.prettyprint.cassandra.service.CassandraClient.FailoverPolicy;

import org.apache.cassandra.thrift.ConsistencyLevel;

/**
Expand Down Expand Up @@ -86,14 +88,27 @@ public final OUTPUT execute(CassandraClientPool pool, String[] hosts, String key
}
}

/**
* Use this execute method if you need a special {@link FailoverPolicy}
*/
public OUTPUT execute(String[] hosts, String keyspace, ConsistencyLevel consistency,
FailoverPolicy failoverPolicy) throws Exception {
return execute(getPool().borrowClient(hosts), keyspace, consistency, failoverPolicy);
}

protected OUTPUT execute(CassandraClient c, String keyspace, ConsistencyLevel consistency,
FailoverPolicy failoverPolicy) throws Exception {
Keyspace ks = c.getKeyspace(keyspace, consistency, failoverPolicy);
try {
return execute(ks);
} finally {
getPool().releaseClient(ks.getClient());
}
}


/**
* Executes on a client obtained from the default pool
* @param c
* @param keyspace
* @param consistency
* @return
* @throws Exception
*/
protected final OUTPUT execute(CassandraClient c, String keyspace, ConsistencyLevel consistency)
throws Exception {
Expand Down

0 comments on commit a7aca75

Please sign in to comment.