[riak] Set strong consistency as default consistency model.

This commit is contained in:
nygard_89 2016-04-15 13:11:49 +02:00
Родитель 5ded6ede6f
Коммит 3891efc686
4 изменённых файлов: 30 добавлений и 35 удалений

Просмотреть файл

@ -17,7 +17,7 @@ LICENSE file.
-->
Riak KV Client for Yahoo! Cloud System Benchmark (YCSB)
--------------------------------------------------------
=======================================================
The Riak KV YCSB client is designed to work with the Yahoo! Cloud System Benchmark (YCSB) project (https://github.com/brianfrankcooper/YCSB) to support performance testing for the 2.x.y line of the Riak KV database.
@ -32,43 +32,38 @@ Set the default backend for Riak to <i>LevelDB</i> in the `riak.conf` file of ev
storage_backend = leveldb
```
Create a bucket type named "ycsb"<sup id="a1">[1](#f1)</sup> by logging into one of the nodes in your cluster.
Then, if you want to use the <i>eventual consistency model</i> (default), type:
Now, create a bucket type named "ycsb"<sup id="a1">[1](#f1)</sup> by logging into one of the nodes in your cluster. Then, to use the <i>strong consistency model</i><sup id="a2">[2](#f2)</sup> (default), you need to follow the next two steps.
1. In every `riak.conf` file, search for the `##strong_consistency=on` line and uncomment it. It's important that you do this <b>before you start your cluster</b>!
2. Run the following `riak-admin` commands:
```
riak-admin bucket-type create ycsb '{"props":{"allow_mult":"false","consistent":true}}'
riak-admin bucket-type activate ycsb
```
If instead you want to use the <i>eventual consistency model</i> implemented in Riak, then type:
```
riak-admin bucket-type create ycsb '{"props":{"allow_mult":"false"}}'
riak-admin bucket-type activate ycsb
```
If instead you want to use the <i>strong consistency model</i><sup id="a2">[2](#f2)</sup> implemented in Riak, then you have to follow the next two steps.
1) In every `riak.conf` file, search for the `##strong_consistency=on` line and uncomment it. It is important that you do this <b>before you start your cluster</b>!
2) Run the following riak-admin commands:
```
riak-admin bucket-type create ycsb '{"props":{"allow_mult":"false","consistent":true}}'
riak-admin bucket-type activate ycsb
```
Note that you may want to specify the number of replicas to create for each object. To do so, you can add `"n_val":N` to the list of properties shown above (by default `N` is set to 3).
Riak KV configuration parameters
----------------------------
You can either specify these configuration parameters via command line or set them in the `riak.properties` file.
* `riak.hosts` - <b>string list</b>, comma separated list of IPs or FQDNs. <newline>Example: `riak.hosts=127.0.0.1,127.0.0.2,127.0.0.3` or `riak.hosts=riak1.mydomain.com,riak2.mydomain.com,riak3.mydomain.com`.
* `riak.hosts` - <b>string list</b>, comma separated list of IPs or FQDNs. For example: `riak.hosts=127.0.0.1,127.0.0.2,127.0.0.3` or `riak.hosts=riak1.mydomain.com,riak2.mydomain.com,riak3.mydomain.com`.
* `riak.port` - <b>int</b>, the port on which every node is listening. It must match the one specified in the `riak.conf` file at the line `listener.protobuf.internal`.
* `riak.bucket_type` - <b>string</b>, it must match the value of the bucket type created during setup (see section above).
* `riak.r_val` - <b>int</b>, the R value represents the number of Riak nodes that must return results for a read before the read is considered successfully completed.
* `riak.w_val` - <b>int</b>, the W value represents the number of Riak nodes that must report success before an update is considered complete.
* `riak.bucket_type` - <b>string</b>, it must match the name of the bucket type created during setup (see section above).
* `riak.r_val` - <b>int</b>, this value represents the number of Riak nodes that must return results for a read operation before the transaction is considered successfully completed.
* `riak.w_val` - <b>int</b>, this value represents the number of Riak nodes that must report success before an insert/update transaction is considered complete.
* `riak.read_retry_count` - <b>int</b>, the number of times the client will try to read a key from Riak.
* `riak.wait_time_before_retry` - <b>int</b>, the time (in milliseconds) before client attempts to perform another read if the previous one failed.
* `riak.wait_time_before_retry` - <b>int</b>, the time (in milliseconds) before the client attempts to perform another read if the previous one failed.
* `riak.transaction_time_limit` - <b>int</b>, the time (in seconds) the client waits before aborting the current transaction.
* `riak.strong_consistency` - <b>boolean</b>, indicates whether to use strong consistency (true) or eventual consistency (false).
* `riak.strong_consistency` - <b>boolean</b>, indicates whether to use *strong consistency* (true) or *eventual consistency* (false).
* `riak.debug` - <b>boolean</b>, enables debug mode. This displays all the properties (specified or defaults) when a benchmark is started. Moreover, it shows error causes whenever these occur.
<b>Note</b>: For more information on workloads and how to run them please see: https://github.com/brianfrankcooper/YCSB/wiki/Running-a-Workload
<b id="f1">1</b> As specified in the `riak.properties` file. See parameters configuration section for further info. [](#a1)
<b id="f2">2</b> <b>IMPORTANT NOTE:</b> Currently the `scan` transactions are <b>NOT SUPPORTED</b> for the benchmarks which use the strong consistency model! However this will not cause the benchmark to fail, but simply it won't perform any scan transaction at all. [](#a2)
<b id="f2">2</b> <b>IMPORTANT NOTE:</b> Currently the `scan` transactions are <b>NOT SUPPORTED</b> for the benchmarks which use the strong consistency model! However this will not cause the benchmark to fail, it simply won't perform any scan transaction at all. These latter will immediately return with a `Status.NOT_IMPLEMENTED` code. [](#a2)

Просмотреть файл

@ -64,8 +64,7 @@ public final class RiakKVClient extends DB {
private static final String STRONG_CONSISTENCY_PROPERTY = "riak.strong_consistency";
private static final String DEBUG_PROPERTY = "riak.debug";
private static final Status TIME_OUT = new Status("TIME_OUT", "Cluster didn't respond after maximum wait time " +
"for transaction indicated");
private static final Status TIME_OUT = new Status("TIME_OUT", "Cluster didn't respond after maximum wait time.");
private String[] hosts;
private int port;
@ -389,10 +388,9 @@ public final class RiakKVClient extends DB {
}
/**
* Insert a record in the database. Any field/value pairs in the specified values HashMap
* will be written into the record with the specified record key. Also creates a
* secondary index (2i) for each record consisting of the key converted to long to be used
* for the scan operation
* Insert a record in the database. Any field/value pairs in the specified values HashMap will be written into the
* record with the specified record key. Also creates a secondary index (2i) for each record consisting of the key
* converted to long to be used for the scan operation.
*
* @param table The name of the table (Riak bucket)
* @param key The record key of the record to insert.

Просмотреть файл

@ -50,7 +50,7 @@ riak.wait_time_before_retry=200
riak.transaction_time_limit=10
# riak.strong_consistency - boolean, indicates whether to use strong consistency (true) or eventual consistency (false).
riak.strong_consistency=false
riak.strong_consistency=true
# riak.debug - boolean, enables debug mode. This displays all the properties (specified or defaults) when a benchmark
# is started.

Просмотреть файл

@ -94,7 +94,7 @@ public class RiakKVClientTest {
/**
* Test method for read transaction. It is designed to read two of the three fields stored for each key, to also test
* if the returnHashMap() function implemented in RiakKVClient.java works as expected.
* if the createResultHashMap() function implemented in RiakKVClient.java works as expected.
*/
@Test
public void testRead() {
@ -111,11 +111,11 @@ public class RiakKVClientTest {
expectedValue.put(firstField, Integer.toString(readKeyNumber));
expectedValue.put(thirdField, Integer.toString(readKeyNumber * readKeyNumber));
// Define a HashMap to store the actual results.
// Define a HashMap to store the actual result.
HashMap<String, ByteIterator> readValue = new HashMap<>();
// If a read transaction has been properly done, then one has to receive a Status.OK return from the read()
// function. Moreover, actual returned results MUST match the expected ones.
// function. Moreover, the actual returned result MUST match the expected one.
assertEquals("Read transaction FAILED.",
Status.OK,
riakClient.read(bucket, keyPrefix + Integer.toString(readKeyNumber), fields, readValue));
@ -126,7 +126,9 @@ public class RiakKVClientTest {
}
/**
* Test method for scan transaction.
* Test method for scan transaction. A scan transaction has to be considered successfully completed only if all the
* requested values are read (i.e. scan transaction returns with Status.OK). Moreover, one has to check if the
* obtained results match the expected ones.
*/
@Test
public void testScan() {
@ -218,8 +220,8 @@ public class RiakKVClientTest {
}
/**
* Test method for delete transaction. The test deletes a key, then performs a read that should give a NOT_FOUND
* status response. Finally, it restores the previously read key.
* Test method for delete transaction. The test deletes a key, then performs a read that should give a
* Status.NOT_FOUND response. Finally, it restores the previously read key.
*/
@Test
public void testDelete() {