Skip to content

Instantly share code, notes, and snippets.

@sheki
Created February 24, 2011 17:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sheki/842472 to your computer and use it in GitHub Desktop.
Save sheki/842472 to your computer and use it in GitHub Desktop.
A sample test to test Riak.
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