Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Patch for YCSB Cassandra Client version 1.0.6 #89

Closed
wants to merge 2 commits into from

4 participants

@jananin

We have a patch for YCSB cassandra client version 1.0.6.This allows users to choose the consistency model at runtime.Consistency level can be ONE or QUORUM or ALL (as applicable)and can be set via properties.The default value being ONE.The patch supports all 4 operations - read,write,scan and delete.The corresponding properties to be set will be cassandra.readconsistencylevel, cassandra.writeconsistencylevel, cassandra.scanconsistencylevel and cassandra.deleteconsistencylevel.
For example,to set write consistency to quorum,users can use the following property.

cassandra.writeconsistencylevel=QUORUM

Patch is applicable for current YCSB framework version 1.0.4

@m1ch1

It looks like the default values for write consistency and scan consistency got mixed up. The default value for scanConsistencyLevel should be SCAN_CONSISTENCY_LEVEL_PROPERTY_DEFAULT.

@jananin

fixed default values for scan and write consistency level

@m1ch1 m1ch1 closed this
@jbohman jbohman referenced this pull request from a commit in jbohman/YCSB
@jananin jananin gh-89 Patch for YCSB Cassandra Client version 1.0.6 8ea4317
@joey joey referenced this pull request from a commit in joey/YCSB
@jananin jananin gh-89 Patch for YCSB Cassandra Client version 1.0.6 559f6e5
@muntasirraihan

Hello,

Can anyone show me an example on how to change the consistency level property from the ycsb client command line?

For example, can I specify it with the "java -cp build/ycsb.jar com.yahoo.ycsb.Client -t ... " command?

Muntasir.

@venkateshhari

Hi muntasirraihan,
How did you change the consistency level In YCSB for Cassandra. Please can you explain the steps you followed.

@muntasirraihan
@venkateshhari

Thanks, still I am confused. I am using latest YCSB 1.0.4 and Cassandra client 1.0.6.
As, jananin mention that consistency level value from ONE to QUORUM can be changed via property within Cassandra client 1.0.6 Java code. But you mention some command line example, I am asking how do you passed as command line parameter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 4, 2012
  1. @jananin
Commits on Aug 5, 2012
  1. @jananin
This page is out of date. Refresh to see the latest.
Showing with 37 additions and 6 deletions.
  1. +37 −6 cassandra/src/main/java/com/yahoo/ycsb/db/CassandraClient10.java
View
43 cassandra/src/main/java/com/yahoo/ycsb/db/CassandraClient10.java
@@ -64,6 +64,19 @@
public static final String COLUMN_FAMILY_PROPERTY = "cassandra.columnfamily";
public static final String COLUMN_FAMILY_PROPERTY_DEFAULT = "data";
+
+ public static final String READ_CONSISTENCY_LEVEL_PROPERTY = "cassandra.readconsistencylevel";
+ public static final String READ_CONSISTENCY_LEVEL_PROPERTY_DEFAULT = "ONE";
+
+ public static final String WRITE_CONSISTENCY_LEVEL_PROPERTY = "cassandra.writeconsistencylevel";
+ public static final String WRITE_CONSISTENCY_LEVEL_PROPERTY_DEFAULT = "ONE";
+
+ public static final String SCAN_CONSISTENCY_LEVEL_PROPERTY = "cassandra.scanconsistencylevel";
+ public static final String SCAN_CONSISTENCY_LEVEL_PROPERTY_DEFAULT = "ONE";
+
+ public static final String DELETE_CONSISTENCY_LEVEL_PROPERTY = "cassandra.deleteconsistencylevel";
+ public static final String DELETE_CONSISTENCY_LEVEL_PROPERTY_DEFAULT = "ONE";
+
TTransport tr;
Cassandra.Client client;
@@ -78,6 +91,12 @@
Map<ByteBuffer, Map<String, List<Mutation>>> record = new HashMap<ByteBuffer, Map<String, List<Mutation>>>();
ColumnParent parent;
+
+ ConsistencyLevel readConsistencyLevel = ConsistencyLevel.ONE;
+ ConsistencyLevel writeConsistencyLevel = ConsistencyLevel.ONE;
+ ConsistencyLevel scanConsistencyLevel = ConsistencyLevel.ONE;
+ ConsistencyLevel deleteConsistencyLevel = ConsistencyLevel.ONE;
+
/**
* Initialize any state for this DB. Called once per DB instance; there is one
@@ -102,6 +121,12 @@ public void init() throws DBException
String username = getProperties().getProperty(USERNAME_PROPERTY);
String password = getProperties().getProperty(PASSWORD_PROPERTY);
+ readConsistencyLevel = ConsistencyLevel.valueOf(getProperties().getProperty(READ_CONSISTENCY_LEVEL_PROPERTY, READ_CONSISTENCY_LEVEL_PROPERTY_DEFAULT));
+ writeConsistencyLevel = ConsistencyLevel.valueOf(getProperties().getProperty(WRITE_CONSISTENCY_LEVEL_PROPERTY, WRITE_CONSISTENCY_LEVEL_PROPERTY_DEFAULT));
+ scanConsistencyLevel = ConsistencyLevel.valueOf(getProperties().getProperty(SCAN_CONSISTENCY_LEVEL_PROPERTY, SCAN_CONSISTENCY_LEVEL_PROPERTY_DEFAULT));
+ deleteConsistencyLevel = ConsistencyLevel.valueOf(getProperties().getProperty(DELETE_CONSISTENCY_LEVEL_PROPERTY, DELETE_CONSISTENCY_LEVEL_PROPERTY_DEFAULT));
+
+
_debug = Boolean.parseBoolean(getProperties().getProperty("debug", "false"));
String[] allhosts = hosts.split(",");
@@ -134,8 +159,6 @@ public void init() throws DBException
{
System.err.println("Unable to connect to " + myhost + " after " + ConnectionRetries
+ " tries");
- System.out.println("Unable to connect to " + myhost + " after " + ConnectionRetries
- + " tries");
throw new DBException(connectexception);
}
@@ -215,7 +238,7 @@ public int read(String table, String key, Set<String> fields, HashMap<String, By
predicate = new SlicePredicate().setColumn_names(fieldlist);
}
- List<ColumnOrSuperColumn> results = client.get_slice(ByteBuffer.wrap(key.getBytes("UTF-8")), parent, predicate, ConsistencyLevel.ONE);
+ List<ColumnOrSuperColumn> results = client.get_slice(ByteBuffer.wrap(key.getBytes("UTF-8")), parent, predicate, readConsistencyLevel);
if (_debug)
{
@@ -243,6 +266,7 @@ public int read(String table, String key, Set<String> fields, HashMap<String, By
if (_debug)
{
System.out.println();
+ System.out.println("ConsistencyLevel=" + readConsistencyLevel.toString());
}
return Ok;
@@ -320,7 +344,7 @@ public int scan(String table, String startkey, int recordcount, Set<String> fiel
KeyRange kr = new KeyRange().setStart_key(startkey.getBytes("UTF-8")).setEnd_key(new byte[] {}).setCount(recordcount);
- List<KeySlice> results = client.get_range_slices(parent, predicate, kr, ConsistencyLevel.ONE);
+ List<KeySlice> results = client.get_range_slices(parent, predicate, kr, scanConsistencyLevel);
if (_debug)
{
@@ -353,6 +377,7 @@ public int scan(String table, String startkey, int recordcount, Set<String> fiel
if (_debug)
{
System.out.println();
+ System.out.println("ConsistencyLevel=" + scanConsistencyLevel.toString());
}
}
@@ -449,11 +474,16 @@ public int insert(String table, String key, HashMap<String, ByteIterator> values
mutationMap.put(column_family, mutations);
record.put(wrappedKey, mutationMap);
- client.batch_mutate(record, ConsistencyLevel.ONE);
+ client.batch_mutate(record, writeConsistencyLevel);
mutations.clear();
mutationMap.clear();
record.clear();
+
+ if (_debug)
+ {
+ System.out.println("ConsistencyLevel=" + writeConsistencyLevel.toString());
+ }
return Ok;
} catch (Exception e)
@@ -505,11 +535,12 @@ public int delete(String table, String key)
client.remove(ByteBuffer.wrap(key.getBytes("UTF-8")),
new ColumnPath(column_family),
System.currentTimeMillis(),
- ConsistencyLevel.ONE);
+ deleteConsistencyLevel);
if (_debug)
{
System.out.println("Delete key: " + key);
+ System.out.println("ConsistencyLevel=" + deleteConsistencyLevel.toString());
}
return Ok;
Something went wrong with that request. Please try again.