Examples of RiakClient


Examples of com.basho.riak.client.api.RiakClient

    }
   
    @Test
    public void updateRiakObject() throws ExecutionException, InterruptedException
    {
        RiakClient client = new RiakClient(cluster);
        Namespace ns = new Namespace(Namespace.DEFAULT_BUCKET_TYPE, bucketName.toString());
        Location loc = new Location(ns, "test_ORM_key9");
        UpdateValue uv = new UpdateValue.Builder(loc)
                        .withUpdate(new Update<RiakObject>(){

                                        @Override
                                        public RiakObject apply(RiakObject original)
                                        {
                                            return new RiakObject().setValue(BinaryValue.create("value"));
                                        }
                                    })
                        .withStoreOption(Option.RETURN_BODY, true)
                        .build();
       
        UpdateValue.Response response = client.execute(uv);
        RiakObject ro = response.getValues().get(0);
        assertNotNull(ro.getVClock());
    }
View Full Code Here

Examples of com.basho.riak.client.api.RiakClient

public class ITestStoreValue extends ITestBase
{
    @Test
    public void simpleTest() throws ExecutionException, InterruptedException
    {
        RiakClient client = new RiakClient(cluster);
        Namespace ns = new Namespace(Namespace.DEFAULT_BUCKET_TYPE, bucketName.toString());
        Location loc = new Location(ns, "test_store_key");
        Pojo pojo = new Pojo();
        pojo.value = "test store value";
        StoreValue sv =
            new StoreValue.Builder(pojo).withLocation(loc)
                .withOption(Option.RETURN_BODY, true)
                .build();
       
        StoreValue.Response resp = client.execute(sv);
       
        Pojo pojo2 = resp.getValue(Pojo.class);
       
        assertEquals(pojo.value, pojo2.value);
       
        FetchValue fv = new FetchValue.Builder(loc)
                            .build();
       
        FetchValue.Response fResp = client.execute(fv);
       
        assertEquals(pojo.value, fResp.getValue(Pojo.class).value);
       
    }
View Full Code Here

Examples of com.basho.riak.client.api.RiakClient

   
   
    @Test
    public void storeAnnotatedPojo() throws ExecutionException, InterruptedException
    {
        RiakClient client = new RiakClient(cluster);
       
        RiakAnnotatedPojo pojo = new RiakAnnotatedPojo();
       
        pojo.bucketType = "default";
        pojo.bucketName = bucketName.toString();
        pojo.key = "test_store_key_3";
        pojo.contentType = null; // converter will set
        pojo.value = "my value";
       
         StoreValue sv =
            new StoreValue.Builder(pojo)
                .withOption(Option.RETURN_BODY, true)
                .build();
       
        StoreValue.Response resp = client.execute(sv);
       
        RiakAnnotatedPojo rap = resp.getValue(RiakAnnotatedPojo.class);
       
        assertNotNull(rap.bucketName);
        assertEquals(pojo.bucketName, rap.bucketName);
View Full Code Here

Examples of com.basho.riak.client.api.RiakClient

    @Test
    public void storeAnnotatedPojoWithIndexes() throws ExecutionException, InterruptedException
    {
        Assume.assumeTrue(test2i);
       
        RiakClient client = new RiakClient(cluster);
       
        RiakAnnotatedPojo pojo = new RiakAnnotatedPojo();
       
        pojo.bucketType = "default";
        pojo.bucketName = bucketName.toString();
        pojo.key = "test_store_key_3";
        pojo.contentType = null; // converter will set
        pojo.value = "my value";
       
        Set<String> emailAddys = new HashSet<String>();
        emailAddys.add("roach@basho.com");
       
        pojo.emailIndx = emailAddys;
        pojo.userId = 1L;
       
        StoreValue sv =
            new StoreValue.Builder(pojo)
                .withOption(Option.RETURN_BODY, true)
                .build();
       
        StoreValue.Response resp = client.execute(sv);
       
        RiakAnnotatedPojo rap = resp.getValue(RiakAnnotatedPojo.class);
       
        assertTrue(rap.emailIndx.containsAll(emailAddys));
        assertEquals(rap.userId, pojo.userId);
View Full Code Here

Examples of com.basho.riak.client.api.RiakClient

    }
   
    @Test
    public void riakGeneratesKey() throws ExecutionException, InterruptedException
    {
        RiakClient client = new RiakClient(cluster);
       
        RiakAnnotatedPojo pojo = new RiakAnnotatedPojo();
       
        pojo.bucketType = "default";
        pojo.bucketName = bucketName.toString();
        pojo.contentType = null; // converter will set
        pojo.value = "my value";
       
         StoreValue sv =
            new StoreValue.Builder(pojo)
                .withOption(Option.RETURN_BODY, true)
                .build();
       
        StoreValue.Response resp = client.execute(sv);
       
        RiakAnnotatedPojo rap = resp.getValue(RiakAnnotatedPojo.class);
       
        assertNotNull(rap.key);
        assertFalse(rap.key.isEmpty());
View Full Code Here

Examples of com.basho.riak.client.api.RiakClient

{
   
    @Test
    public void simpleTest() throws ExecutionException, InterruptedException
    {
        RiakClient client = new RiakClient(cluster);
       
        String keyPrefix = "key_";
        String valuePrefix = "value_";
        List<Location> locations = new LinkedList<Location>();
        List<BinaryValue> values = new LinkedList<BinaryValue>();
        Namespace ns = new Namespace(Namespace.DEFAULT_BUCKET_TYPE, bucketName.toString());
       
        // Store some stuff
        for (int i = 0; i < 5; i++)
        {
            String key = keyPrefix + i;
            String value = valuePrefix + i;
            Location loc = new Location(ns, key);
            locations.add(loc);
            values.add(BinaryValue.create(value));
            RiakObject o = new RiakObject().setValue(BinaryValue.create(value));
           
            StoreValue sv = new StoreValue.Builder(o).withLocation(loc).build();
            client.execute(sv);
        }
       
        MultiFetch mf = new MultiFetch.Builder().addLocations(locations).build();
       
        MultiFetch.Response mfr = client.execute(mf);
       
        assertEquals(locations.size(), mfr.getResponses().size());
       
        List<Location> returnedLocations = new LinkedList<Location>();
        List<BinaryValue> returnedValues = new LinkedList<BinaryValue>();
View Full Code Here

Examples of com.basho.riak.client.http.RiakClient

     *
     * @param url
     *            of the riak REST interface
     */
    public HTTPClientAdapter(String url) {
        this(new RiakClient(url));
    }
View Full Code Here

Examples of com.basho.riak.client.http.RiakClient

                RiakConfig riakConfig = new RiakConfig(node.getUrl());
                riakConfig.setMapReducePath(node.getMapreducePath());
                riakConfig.setTimeout(node.getTimeout());
                riakConfig.setHttpClient(httpClient);

                clients.add(new HTTPClientAdapter(new RiakClient(riakConfig)));
            }
        }
        return clients.toArray(new RawClient[clients.size()]);
    }
View Full Code Here

Examples of com.basho.riak.client.http.RiakClient

        riakConfig.setMapReducePath(config.getMapreducePath());
        riakConfig.setMaxConnections(config.getMaxConnections());
        riakConfig.setTimeout(config.getTimeout());
        riakConfig.setRetryHandler(config.getRetryHandler());

        return new HTTPClientAdapter(new RiakClient(riakConfig));
    }
View Full Code Here

Examples of com.basho.riak.client.http.RiakClient

     *
     * @param url
     *            of the riak REST interface
     */
    public HTTPClientAdapter(String url) {
        this(new RiakClient(url));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.