Examples of RiakClient


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

public class ITestUpdateValue 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_update_key1");
        UpdateValue uv = new UpdateValue.Builder(loc)
                            .withStoreOption(Option.RETURN_BODY, true)
                            .withUpdate(new UpdatePojo())
                            .build();
       
        UpdateValue.Response resp = client.execute(uv);
        Pojo pojo = resp.getValue(Pojo.class);
        assertEquals(1, pojo.value);
       
        resp = client.execute(uv);
        pojo = resp.getValue(Pojo.class);
       
        assertEquals(2, pojo.value);
       
    }
View Full Code Here

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

    }
   
    @Test
    public void updateAnnotatedPojo() throws ExecutionException, InterruptedException
    {
        RiakClient client = new RiakClient(cluster);
        Namespace ns = new Namespace(Namespace.DEFAULT_BUCKET_TYPE, bucketName.toString());
        Location loc = new Location(ns, "test_update_key2");
        UpdateValue uv = new UpdateValue.Builder(loc)
                            .withStoreOption(Option.RETURN_BODY, true)
                            .withUpdate(new UpdateAnnotatedPojo())
                            .build();
       
        UpdateValue.Response resp = client.execute(uv);
        RiakAnnotatedPojo rap = resp.getValue(RiakAnnotatedPojo.class);
       
        assertNotNull(rap.bucketName);
        assertEquals(ns.getBucketNameAsString(), rap.bucketName);
        assertNotNull(rap.key);
View Full Code Here

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

    }
   
    @Test
    public void storeParamterizedTypeJSON() throws ExecutionException, InterruptedException, JsonProcessingException
    {
        RiakClient client = new RiakClient(cluster);
        Namespace ns = new Namespace(Namespace.DEFAULT_BUCKET_TYPE, bucketName.toString());
        Location loc = new Location(ns, "test_ORM_key1");
       
        GenericPojo<Foo> gpf = new GenericPojo<Foo>();
        List<Foo> fooList = new ArrayList<Foo>();
        fooList.add(new Foo("Foo in list value"));
        gpf.value = new Foo("Foo in gp value");
        gpf.list = fooList;
       
        StoreValue sv =
            new StoreValue.Builder(gpf)
                .withLocation(loc)
                .withOption(Option.RETURN_BODY, true)
                .build();
       
        StoreValue.Response resp = client.execute(sv);
       
       
        TypeReference<GenericPojo<Foo>> tr =
            new TypeReference<GenericPojo<Foo>>(){};
        GenericPojo<Foo> gpf2 = resp.getValue(tr);
View Full Code Here

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

    }
   
    @Test
    public void storeAndFetchParamterizedTypeJSON() throws ExecutionException, InterruptedException, JsonProcessingException
    {
        RiakClient client = new RiakClient(cluster);
        Namespace ns = new Namespace(Namespace.DEFAULT_BUCKET_TYPE, bucketName.toString());
        Location loc = new Location(ns, "test_ORM_key2");
       
        GenericPojo<Foo> gpf = new GenericPojo<Foo>();
        List<Foo> fooList = new ArrayList<Foo>();
        fooList.add(new Foo("Foo in list value"));
        gpf.value = new Foo("Foo in gp value");
        gpf.list = fooList;
       
        StoreValue sv =
            new StoreValue.Builder(gpf)
                .withLocation(loc)
                .build();
       
        client.execute(sv);
           
        FetchValue fv = new FetchValue.Builder(loc).build();
        FetchValue.Response resp = client.execute(fv);
       
        TypeReference<GenericPojo<Foo>> tr =
            new TypeReference<GenericPojo<Foo>>(){};
        GenericPojo<Foo> gpf2 = resp.getValue(tr);
       
View Full Code Here

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

    }
   
    @Test
    public void updateParameterizedTypeJSON() throws ExecutionException, InterruptedException, JsonProcessingException
    {
        RiakClient client = new RiakClient(cluster);
        Namespace ns = new Namespace(Namespace.DEFAULT_BUCKET_TYPE, bucketName.toString());
        Location loc = new Location(ns, "test_ORM_key3");
       
        MyUpdate update = new MyUpdate();
        TypeReference<GenericPojo<Integer>> tr =
            new TypeReference<GenericPojo<Integer>>(){};
       
        UpdateValue uv = new UpdateValue.Builder(loc)
                        .withUpdate(update, tr)
                        .withStoreOption(Option.RETURN_BODY, true)
                        .build();
       
        UpdateValue.Response resp = client.execute(uv);
       
        GenericPojo<Integer> gpi = resp.getValue(tr);
       
        assertNotNull(gpi);
        assertNotNull(gpi.value);
        assertEquals(1, gpi.value.intValue());
       
        ObjectMapper mapper = new ObjectMapper();
        mapper.registerModule(new RiakJacksonModule());
        String json = mapper.writeValueAsString(gpi);
        RiakObject ro = resp.getValue(RiakObject.class);
        assertEquals(json, ro.getValue().toString());
       
        resp = client.execute(uv);
        gpi = resp.getValue(tr);
        assertNotNull(gpi);
        assertNotNull(gpi.value);
        assertEquals(2, gpi.value.intValue());
    }
View Full Code Here

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

                .withAllowMulti(true)
                .build();
        cluster.execute(op);
        op.get();
       
        RiakClient client = new RiakClient(cluster);
        Location loc = new Location(ns, "test_ORM_key4");
       
        MyUpdate update = new MyUpdate();
        TypeReference<GenericPojo<Integer>> tr =
            new TypeReference<GenericPojo<Integer>>(){};
       
        UpdateValue uv = new UpdateValue.Builder(loc)
                        .withUpdate(update, tr)
                        .build();
       
        client.execute(uv);
       
        // Create a sibling
        GenericPojo<Integer> gpi = update.apply(null);
        StoreValue sv =
            new StoreValue.Builder(gpi)
                .withLocation(loc)
                .build();
       
        client.execute(sv);
       
        ConflictResolverFactory.getInstance().registerConflictResolver(tr, new MyResolver());
       
        uv = new UpdateValue.Builder(loc)
                        .withUpdate(update, tr)
                        .withStoreOption(Option.RETURN_BODY, true)
                        .build();
       
        UpdateValue.Response uvResp = client.execute(uv);
       
        gpi = uvResp.getValue(tr);
        assertNotNull(gpi);
        assertNotNull(gpi.value);
        assertEquals(3, gpi.value.intValue());
View Full Code Here

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

                .build();
        cluster.execute(op);
        op.get();
       
       
        RiakClient client = new RiakClient(cluster);
        Location loc = new Location(ns, "test_ORM_key5");
       
        TypeReference<GenericPojo<Integer>> tr =
            new TypeReference<GenericPojo<Integer>>(){};
       
        ConflictResolverFactory.getInstance().registerConflictResolver(tr, new MyResolver());
        ConverterFactory.getInstance().registerConverterForClass(tr, new MyConverter(tr.getType()));
       
       
        MyUpdate update = new MyUpdate();
       
       
        UpdateValue uv = new UpdateValue.Builder(loc)
                        .withUpdate(update, tr)
                        .build();
       
        client.execute(uv);
       
        // Create a sibling
        GenericPojo<Integer> gpi = update.apply(null);
        StoreValue sv =
            new StoreValue.Builder(gpi, tr)
                .withLocation(loc)
                .build();
       
        client.execute(sv);
       
        uv = new UpdateValue.Builder(loc)
                        .withUpdate(update, tr)
                        .withStoreOption(Option.RETURN_BODY, true)
                        .build();
       
        UpdateValue.Response uvResp = client.execute(uv);
       
        gpi = uvResp.getValue(tr);
        assertNotNull(gpi);
        assertNotNull(gpi.value);
        assertEquals(3, gpi.value.intValue());
View Full Code Here

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

    when(mockCluster.execute(any(FutureOperation.class)))
      .thenReturn(new ImmediateRiakFuture<FetchOperation.Response, Location>(fetchResponse))
      .thenReturn(new ImmediateRiakFuture<StoreOperation.Response, Location>(storeResponse));

    client = new RiakClient(mockCluster);

  }
View Full Code Here

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

   
   
    @Test
    public void updateAndResolveRawTypeJSON() throws ExecutionException, InterruptedException, JsonProcessingException
    {
        RiakClient client = new RiakClient(cluster);
        Namespace ns = new Namespace(Namespace.DEFAULT_BUCKET_TYPE, bucketName.toString());
        Location loc = new Location(ns, "test_ORM_key6");
        ConflictResolverFactory.getInstance().registerConflictResolver(Foo.class, new MyFooResolver());
        MyFooUpdate update = new MyFooUpdate();
       
        UpdateValue uv = new UpdateValue.Builder(loc)
                        .withUpdate(update)
                        .build();
       
        client.execute(uv);
       
        // Create a sibling
        Foo f = update.apply(null);
        StoreValue sv =
            new StoreValue.Builder(f)
                .withLocation(loc)
                .build();
       
        client.execute(sv);
       
        uv = new UpdateValue.Builder(loc)
                        .withUpdate(update)
                        .withStoreOption(Option.RETURN_BODY, true)
                        .build();
       
        UpdateValue.Response uvResp = client.execute(uv);
       
        f = uvResp.getValue(Foo.class);
        assertNotNull(f);
        assertEquals("Little bunny", f.fooValue);
       
        uv = new UpdateValue.Builder(loc)
                        .withUpdate(update)
                        .withStoreOption(Option.RETURN_BODY, true)
                        .build();
       
        uvResp = client.execute(uv);
       
        f = uvResp.getValue(Foo.class);
        assertNotNull(f);
        assertEquals("Little bunny foo foo.", f.fooValue);
       
View Full Code Here

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

    }
   
    @Test
    public void updateAndResolveRawTypeCustom() 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_key7");
       
        ConflictResolverFactory.getInstance().registerConflictResolver(Foo.class, new MyFooResolver());
        ConverterFactory.getInstance().registerConverterForClass(Foo.class, new MyFooConverter());
        MyFooUpdate update = new MyFooUpdate();
       
        UpdateValue uv = new UpdateValue.Builder(loc)
                        .withUpdate(update)
                        .build();
       
        client.execute(uv);
       
        // Create a sibling
        Foo f = update.apply(null);
        StoreValue sv =
            new StoreValue.Builder(f)
                .withLocation(loc)
                .build();
       
        client.execute(sv);
       
        uv = new UpdateValue.Builder(loc)
                        .withUpdate(update)
                        .withStoreOption(Option.RETURN_BODY, true)
                        .build();
       
        UpdateValue.Response uvResp = client.execute(uv);
       
        f = uvResp.getValue(Foo.class);
        assertNotNull(f);
        assertEquals("Little bunny", f.fooValue);
       
        uv = new UpdateValue.Builder(loc)
                        .withUpdate(update)
                        .withStoreOption(Option.RETURN_BODY, true)
                        .build();
       
        uvResp = client.execute(uv);
       
        f = uvResp.getValue(Foo.class);
        assertNotNull(f);
        assertEquals("Little bunny foo foo.", f.fooValue);
       
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.