Examples of RiakClient


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

        notFound(bucketType.toString());
    }
   
    private void notFound(String bucketType) throws ExecutionException, InterruptedException
    {
        RiakClient client = new RiakClient(cluster);
        Namespace ns = new Namespace(bucketType, bucketName.toString());
        Location loc = new Location(ns, "test_fetch_key2");
        FetchValue fv = new FetchValue.Builder(loc).build();
        FetchValue.Response fResp = client.execute(fv);
       
        assertFalse(fResp.hasValues());
        assertTrue(fResp.isNotFound());
        assertNull(fResp.getValue(Pojo.class));
        RiakObject ro = fResp.getValue(RiakObject.class);
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_fetch_key3");
       
        Pojo pojo = new Pojo();
        pojo.value = "test value";
        StoreValue sv =
            new StoreValue.Builder(pojo).withLocation(loc).build();
       
        client.execute(sv);
       
        resetAndEmptyBucket(bucketName);
       
        client.execute(sv);
       
        FetchValue fv = new FetchValue.Builder(loc)
                            .withOption(Option.DELETED_VCLOCK, false)
                            .build();
       
        FetchValue.Response fResp = client.execute(fv);
       
        assertEquals(2, fResp.getValues(RiakObject.class).size());
       
    }
View Full Code Here

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

        resolveSiblings(bucketType.toString());
    }
   
    private void resolveSiblings(String bucketType) throws ExecutionException, InterruptedException
    {
        RiakClient client = new RiakClient(cluster);
        Namespace ns = new Namespace(bucketType, bucketName.toString());
        Location loc = new Location(ns, "test_fetch_key4");
       
        Pojo pojo = new Pojo();
        pojo.value = "test value";
        StoreValue sv =
            new StoreValue.Builder(pojo).withLocation(loc).build();
       
        client.execute(sv);
       
        pojo.value = "Pick me!";
       
        sv = new StoreValue.Builder(pojo).withLocation(loc).build();
       
        client.execute(sv);
       
        ConflictResolverFactory.getInstance()
            .registerConflictResolver(Pojo.class, new MyResolver());
       
        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

        fetchAnnotatedPojo(bucketType.toString());
    }
   
    private void fetchAnnotatedPojo(String bucketType) throws ExecutionException, InterruptedException
    {
        RiakClient client = new RiakClient(cluster);
        Namespace ns = new Namespace(bucketType, bucketName.toString());
        Location loc = new Location(ns, "test_fetch_key5");
       
        String jsonValue = "{\"value\":\"my value\"}";
       
        RiakObject ro = new RiakObject()
                        .setValue(BinaryValue.create(jsonValue))
                        .setContentType("application/json");
       
        StoreValue sv = new StoreValue.Builder(ro).withLocation(loc).build();
        client.execute(sv);
       
        FetchValue fv = new FetchValue.Builder(loc).build();
        FetchValue.Response resp = client.execute(fv);
       
        RiakAnnotatedPojo rap = resp.getValue(RiakAnnotatedPojo.class);
       
        assertNotNull(rap.bucketName);
        assertEquals(ns.getBucketNameAsString(), rap.bucketName);
View Full Code Here

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

    }
   
    @Test
    public void fetchAnnotatedPojoWIthIndexes() throws ExecutionException, InterruptedException
    {
        RiakClient client = new RiakClient(cluster);
        Namespace ns = new Namespace(Namespace.DEFAULT_BUCKET_TYPE, bucketName.toString());
        Location loc = new Location(ns,"test_fetch_key6");
       
        String jsonValue = "{\"value\":\"my value\"}";
       
        RiakObject ro = new RiakObject()
                        .setValue(BinaryValue.create(jsonValue))
                        .setContentType("application/json");
       
        ro.getIndexes().getIndex(StringBinIndex.named("email")).add("roach@basho.com");
        ro.getIndexes().getIndex(LongIntIndex.named("user_id")).add(1L);
       
        StoreValue sv = new StoreValue.Builder(ro).withLocation(loc).build();
        client.execute(sv);
       
        FetchValue fv = new FetchValue.Builder(loc).build();
        FetchValue.Response resp = client.execute(fv);
       
        RiakAnnotatedPojo rap = resp.getValue(RiakAnnotatedPojo.class);
       
        assertNotNull(rap.emailIndx);
        assertTrue(rap.emailIndx.contains("roach@basho.com"));
View Full Code Here

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

        when(mockFuture.get(anyLong(), any(TimeUnit.class))).thenReturn(null);
        when(mockFuture.isCancelled()).thenReturn(false);
        when(mockFuture.isDone()).thenReturn(true);
        when(mockFuture.isSuccess()).thenReturn(true);
        when(mockCluster.<DeleteOperation, Location>execute(any(FutureOperation.class))).thenReturn(mockFuture);
        client = new RiakClient(mockCluster);
    }
View Full Code Here

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

    when(mockFuture.get()).thenReturn(mockResponse);
    when(mockFuture.get(anyLong(), any(TimeUnit.class))).thenReturn(mockResponse);
    when(mockFuture.isCancelled()).thenReturn(false);
    when(mockFuture.isDone()).thenReturn(true);
    when(mockCluster.execute(any(FutureOperation.class))).thenReturn(mockFuture);
    client = new RiakClient(mockCluster);
    riakObject = new RiakObject();
        riakObject.setVClock(vClock);
    riakObject.setValue(BinaryValue.create(new byte[]{'O', '_', 'o'}));
  }
View Full Code Here

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

        when(mockFuture.get(anyLong(), any(TimeUnit.class))).thenReturn(mockResponse);
        when(mockFuture.isCancelled()).thenReturn(false);
        when(mockFuture.isDone()).thenReturn(true);
        when(mockFuture.isSuccess()).thenReturn(true);
        when(mockCluster.execute(any(FutureOperation.class))).thenReturn(mockFuture);
        client = new RiakClient(mockCluster);
    }
View Full Code Here

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

        when(mockFuture.get()).thenReturn(mockResponse);
        when(mockFuture.get(anyLong(), any(TimeUnit.class))).thenReturn(mockResponse);
        when(mockFuture.isCancelled()).thenReturn(false);
        when(mockFuture.isDone()).thenReturn(true);
        when(mockCluster.execute(any(FutureOperation.class))).thenReturn(mockFuture);
        client = new RiakClient(mockCluster);
    }
View Full Code Here

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

        when(mockFuture.isCancelled()).thenReturn(false);
        when(mockFuture.isDone()).thenReturn(true);
        when(mockFuture.isSuccess()).thenReturn(true);
        when(mockCluster.execute(any(FutureOperation.class))).thenReturn(mockFuture);
        when(context.getValue()).thenReturn(BinaryValue.unsafeCreate(new byte[] {'1'}));
        client = new RiakClient(mockCluster);
    }
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.