Created
June 22, 2012 05:38
-
-
Save jmshoffs0812/2970546 to your computer and use it in GitHub Desktop.
Bucket Walk
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
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.httpClient("Source IP"); | |
IRiakClient destRiakClient = RiakFactory.httpClient("Dest IP"); | |
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