[riak] Removed test unit as it only works with a local cluster installation (there is no Riak test or mock utility).

[riak] Packaged into com.yahoo.ycsb.db.riak.
[riak] Removed unused dependencies.
[riak] Bugfix for update() function that returned positive even with no nodes in the cluster.
This commit is contained in:
nygard_89 2016-04-12 00:54:13 +02:00
Родитель 1ff7e2b8fb
Коммит 2797f9a026
5 изменённых файлов: 13 добавлений и 140 удалений

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

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- <!--
Copyright (c) 2016 YCSB contributors. All rights reserved. Copyright (c) 2016 YCSB contributors. All rights reserved.
Copyright 2014 Basho Technologies, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you Licensed under the Apache License, Version 2.0 (the "License"); you
may not use this file except in compliance with the License. You may not use this file except in compliance with the License. You
@ -47,12 +48,6 @@ LICENSE file.
<artifactId>google-collections</artifactId> <artifactId>google-collections</artifactId>
<version>1.0</version> <version>1.0</version>
</dependency> </dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
</project> </project>

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

@ -16,7 +16,7 @@
* LICENSE file. * LICENSE file.
*/ */
package com.yahoo.ycsb.db; package com.yahoo.ycsb.db.riak;
import com.basho.riak.client.api.commands.kv.UpdateValue; import com.basho.riak.client.api.commands.kv.UpdateValue;
import com.basho.riak.client.core.RiakFuture; import com.basho.riak.client.core.RiakFuture;
@ -43,9 +43,9 @@ import com.basho.riak.client.core.query.RiakObject;
import com.basho.riak.client.core.query.indexes.LongIntIndex; import com.basho.riak.client.core.query.indexes.LongIntIndex;
import com.basho.riak.client.core.util.BinaryValue; import com.basho.riak.client.core.util.BinaryValue;
import static com.yahoo.ycsb.db.RiakUtils.deserializeTable; import static com.yahoo.ycsb.db.riak.RiakUtils.deserializeTable;
import static com.yahoo.ycsb.db.RiakUtils.getKeyAsLong; import static com.yahoo.ycsb.db.riak.RiakUtils.getKeyAsLong;
import static com.yahoo.ycsb.db.RiakUtils.serializeTable; import static com.yahoo.ycsb.db.riak.RiakUtils.serializeTable;
/** /**
* Riak KV 2.0.x client for YCSB framework. * Riak KV 2.0.x client for YCSB framework.
@ -479,7 +479,10 @@ public final class RiakKVClient extends DB {
RiakFuture<UpdateValue.Response, Location> future = riakClient.executeAsync(update); RiakFuture<UpdateValue.Response, Location> future = riakClient.executeAsync(update);
try { try {
future.get(transactionTimeLimit, TimeUnit.SECONDS); // For some reason, the update transaction doesn't throw any exception when no cluster has been started, so one
// needs to check whether it was done or not. When calling the wasUpdated() function with no nodes available, a
// NullPointerException is thrown.
future.get(transactionTimeLimit, TimeUnit.SECONDS).wasUpdated();
} catch (TimeoutException e) { } catch (TimeoutException e) {
if (debug) { if (debug) {
System.err.println("Unable to update key " + key + ". Reason: TIME OUT"); System.err.println("Unable to update key " + key + ". Reason: TIME OUT");

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

@ -16,7 +16,7 @@
* LICENSE file. * LICENSE file.
*/ */
package com.yahoo.ycsb.db; package com.yahoo.ycsb.db.riak;
import java.io.*; import java.io.*;
import java.util.Map; import java.util.Map;

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

@ -17,7 +17,7 @@
*/ */
/** /**
* The YCSB binding for <a href="http://basho.com/products/riak-kv/">Riak KV</a> * The YCSB binding for <a href="http://basho.com/products/riak-kv/">Riak KV</a> 2.0.x.
* 2.0.x. *
*/ */
package com.yahoo.ycsb.db; package com.yahoo.ycsb.db.riak;

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

@ -1,125 +0,0 @@
/**
* Copyright (c) 2016 YCSB contributors All rights reserved.
* Copyright 2014 Basho Technologies, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you
* may not use this file except in compliance with the License. You
* may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License. See accompanying
* LICENSE file.
*/
package com.yahoo.ycsb.db;
import java.util.*;
import com.yahoo.ycsb.ByteIterator;
import com.yahoo.ycsb.Status;
import com.yahoo.ycsb.StringByteIterator;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
/**
* Integration tests for the Riak KV client. All tests are configured to return positive.
*/
public class RiakKVClientTest {
private static RiakKVClient riakClient;
private static String bucket = "testBucket";
private static String startKey = "testKey";
private static int recordsToInitiallyInsert = 10;
/**
* Creates a cluster for testing purposes.
*/
@BeforeClass
public static void setUpClass() throws Exception {
riakClient = new RiakKVClient();
riakClient.init();
HashMap<String, String> values = new HashMap<>();
// Just add some random values to work on...
for (int i = 0; i < recordsToInitiallyInsert; i++) {
values.put("testRecord_1", "testValue_1");
values.put("testRecord_2", "testValue_2");
riakClient.insert(bucket, startKey + String.valueOf(i), StringByteIterator.getByteIteratorMap(values));
}
}
/**
* Shuts down the cluster created.
*/
@AfterClass
public static void tearDownClass() throws Exception {
riakClient.cleanup();
}
/**
* Test method for read transaction.
*/
@Test
public void testRead() {
Set<String> fields = new HashSet<>();
fields.add("testRecord_1");
fields.add("testRecord_2");
HashMap<String, ByteIterator> results = new HashMap<>();
assertEquals(Status.OK, riakClient.read(bucket, startKey + "1", fields, results));
}
/**
* Test method for scan transaction.
*/
@Test
public void testScan() {
Vector<HashMap<String, ByteIterator>> results = new Vector<>();
assertEquals(Status.OK, riakClient.scan(bucket, startKey + "1", recordsToInitiallyInsert - 1, null, results));
}
/**
* Test method for update transaction.
*/
@Test
public void testUpdate() {
HashMap<String, String> values = new HashMap<>();
values.put("testRecord_1", "testValue_1_updated");
values.put("testRecord_2", "testValue_2_updated");
assertEquals(Status.OK, riakClient.update(bucket, startKey + "0", StringByteIterator.getByteIteratorMap(values)));
}
/**
* Test method for insert transaction.
*/
@Test
public void testInsert() {
HashMap<String, String> values = new HashMap<>();
values.put("testRecord_1", "testValue_1");
values.put("testRecord_2", "testValue_2");
assertEquals(Status.OK, riakClient.insert(bucket, startKey + Integer.toString(recordsToInitiallyInsert),
StringByteIterator.getByteIteratorMap(values)));
}
/**
* Test method for delete transaction.
*/
@Test
public void testDelete() {
assertEquals(Status.OK, riakClient.delete(bucket, startKey + "0"));
}
}