Skip to content

Instantly share code, notes, and snippets.

@jmshoffs0812
Created June 22, 2012 06:41
Show Gist options
  • Save jmshoffs0812/2970816 to your computer and use it in GitHub Desktop.
Save jmshoffs0812/2970816 to your computer and use it in GitHub Desktop.
Newer Bucket Walk
import com.basho.riak.client.IRiakClient;
import com.basho.riak.client.IRiakObject;
import com.basho.riak.client.RiakException;
import com.basho.riak.client.RiakFactory;
import com.basho.riak.client.bucket.Bucket;
public class App
{
public static void main( String[] args )
{
try{
IRiakClient sourceRiakClient = RiakFactory.pbcClient("127.0.0.1", 8081);
IRiakClient destRiakClient = RiakFactory.pbcClient("127.0.0.1", 8083);
Iterable<String> bucketList = sourceRiakClient.listBuckets();
for (String bucketName : bucketList)
{
Bucket sourceBucket = sourceRiakClient.fetchBucket(bucketName).execute();
Bucket destBucket = destRiakClient.fetchBucket(bucketName).execute();
Iterable<String> keyList = sourceBucket.keys();
for (String key : keyList)
{
IRiakObject myObject = sourceBucket.fetch(key).execute();
IRiakObject destObject = destBucket.store(myObject).execute();
if (myObject != destObject)
{
System.err.print(destObject);
}
}
}
sourceRiakClient.shutdown();
destRiakClient.shutdown();
}
catch(RiakException e) {
System.err.println(e);
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment