Skip to content

Commit

Permalink
Merge pull request #658 from woolfel/master
Browse files Browse the repository at this point in the history
Changed to use HConsistencyLevel
  • Loading branch information
zznate committed Mar 6, 2014
2 parents 5301af2 + cba8383 commit a8d5795
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package me.prettyprint.cassandra.model;

import org.apache.cassandra.thrift.ConsistencyLevel;

import me.prettyprint.cassandra.utils.Assert;
import me.prettyprint.hector.api.HConsistencyLevel;
import me.prettyprint.hector.api.Keyspace;
import me.prettyprint.hector.api.Serializer;
import me.prettyprint.hector.api.query.Query;
Expand All @@ -22,7 +21,7 @@ public abstract class AbstractBasicQuery<K, N, T> implements Query<T> {
protected Serializer<K> keySerializer;
protected Serializer<N> columnNameSerializer;
// For now keep it simple and use the Thrift consistency level directly
protected ConsistencyLevel consistency;
protected HConsistencyLevel consistency;
// add: FailoverPolicy, Credentials?
protected String cqlVersion;
// default is set to false. Subclasses should check the cqlVersion and
Expand Down Expand Up @@ -70,11 +69,11 @@ public AbstractBasicQuery setCqlVersion(String cqlVersion) {
return this;
}

public ConsistencyLevel getConsistencyLevel() {
public HConsistencyLevel getConsistencyLevel() {
return this.consistency;
}

public void setConsistencyLevel(ConsistencyLevel level) {
public void setConsistencyLevel(HConsistencyLevel level) {
this.consistency = level;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
import java.util.List;
import java.util.Map;

import me.prettyprint.cassandra.model.thrift.ThriftConverter;
import me.prettyprint.cassandra.serializers.StringSerializer;
import me.prettyprint.cassandra.service.Operation;
import me.prettyprint.cassandra.service.OperationType;
import me.prettyprint.hector.api.HConsistencyLevel;
import me.prettyprint.hector.api.Keyspace;
import me.prettyprint.hector.api.Serializer;
import me.prettyprint.hector.api.exceptions.HectorException;
Expand Down Expand Up @@ -107,11 +109,11 @@ public CqlQuery<K, N, V> useCompression() {
return this;
}

protected ConsistencyLevel getConsistency() {
protected HConsistencyLevel getConsistency() {
if (consistency != null) {
return consistency;
} else {
return ConsistencyLevel.ONE;
return HConsistencyLevel.ONE;
}
}

Expand Down Expand Up @@ -143,7 +145,7 @@ public CqlRows<K, N, V> execute(Client cassandra) throws HectorException {
CqlResult result = null;
if (cql3) {
result = cassandra.execute_cql3_query(query,
useCompression ? Compression.GZIP : Compression.NONE, getConsistency());
useCompression ? Compression.GZIP : Compression.NONE, ThriftConverter.consistencyLevel(getConsistency()));
} else {
result = cassandra.execute_cql_query(query,
useCompression ? Compression.GZIP : Compression.NONE);
Expand Down

0 comments on commit a8d5795

Please sign in to comment.