Created
February 24, 2011 17:15
-
-
Save sheki/842472 to your computer and use it in GitHub Desktop.
A sample test to test Riak.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ZZZ.platform.kv.riak; | |
import com.basho.riak.client.RiakClient; | |
import com.basho.riak.client.request.RequestMeta; | |
import com.basho.riak.client.response.FetchResponse; | |
import ZZZ.platform.config.ZZZConfig; | |
import ZZZ.platform.logging.ZZZLogger; | |
/* | |
*FoxPerfTest executes the RiakReaderTest in a Runnable Class in the order of BeforeTest, Test and AfterTest methods with certain profiling embedded. A ThreadPoolExecutor is used to execute tasks, each task containing a new RiakReaderTask. | |
* | |
*/ | |
public class RiakReaderTask implements FoxPerfTest | |
{ | |
private String key = null; | |
private String bucketName = null; | |
private RiakClient client = null; | |
private FoxLogger logger = null; | |
private FetchResponse fetchedValue = null; | |
private String url = null; | |
@Override //NOT a JUNIT method, | |
public void afterTest() throws Exception | |
{ | |
if (fetchedValue != null) | |
{ | |
logger.info(fetchedValue.getKey()); | |
} | |
bucketName = null; | |
key = null; | |
fetchedValue = null; | |
} | |
@Override //NOT JUNIT | |
public void beforeTest() throws Exception | |
{ | |
key = SharedQueue.poll(); | |
if(key == null) | |
{ | |
throw new Exception("key value null"); | |
} | |
bucketName = ZZZConfig.findString("kv.riak.bucket", "bucket1"); | |
logger = ZZZLogger.getLogger(this.getClass()); | |
if(client == null) | |
{ | |
url = "http://" + ZZZConfig.findString("kv.riak.node", "localhost") + ":" | |
+ ZZZConfig.findInteger("kv.riak.port", 8098) + "/riak"; | |
client = new RiakClient(url); | |
} | |
} | |
@Override | |
public void testRun() throws Exception | |
{ | |
fetchedValue = client.fetch(bucketName, key,RequestMeta.readParams(3)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment