Created
June 22, 2012 06:41
-
-
Save jmshoffs0812/2970816 to your computer and use it in GitHub Desktop.
Newer 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.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