Examples of RiakObject


Examples of com.basho.riak.client.core.query.RiakObject

        String value = "value";
        Namespace ns = new Namespace(bucketType, bucketName.toString());
       
        for (long i = 0; i < 20; i++)
        {
            RiakObject obj = new RiakObject().setValue(BinaryValue.create(value));

            obj.getIndexes().getIndex(StringBinIndex.named(indexName)).add("foo" + String.format("%02d", i));

           
            Location location = new Location(ns, BinaryValue.unsafeCreate(Long.toString(i).getBytes()));
            StoreOperation storeOp =
                    new StoreOperation.Builder(location)
View Full Code Here

Examples of com.basho.riak.client.core.query.RiakObject

    private void setupIndexTestData(Namespace ns, String indexName, String keyBase, String value)
            throws InterruptedException, ExecutionException
    {
        for (long i = 0; i < 100; i++)
        {
            RiakObject obj = new RiakObject().setValue(BinaryValue.create(value));

            obj.getIndexes().getIndex(LongIntIndex.named(indexName)).add(i);

            Location location = new Location(ns, keyBase + i);
            StoreOperation storeOp =
                    new StoreOperation.Builder(location)
                            .withContent(obj)
View Full Code Here

Examples of com.basho.riak.client.core.query.RiakObject

    private void testDeleteObject(String bucketType) throws InterruptedException, ExecutionException
    {
        final BinaryValue key = BinaryValue.unsafeCreate("my_key".getBytes());
        final String value = "{\"value\":\"value\"}";
       
        RiakObject rObj = new RiakObject().setValue(BinaryValue.unsafeCreate(value.getBytes()));
       
        Location location = new Location(new Namespace(bucketType, bucketName.toString()), key);
        StoreOperation storeOp =
            new StoreOperation.Builder(location)
                .withContent(rObj)
                .build();
       
        cluster.execute(storeOp);
        storeOp.get();
       
        FetchOperation fetchOp =
            new FetchOperation.Builder(location).build();
               
       
        cluster.execute(fetchOp);
        FetchOperation.Response response = fetchOp.get();
        RiakObject rObj2 = response.getObjectList().get(0);
       
        assertEquals(rObj.getValue(), rObj2.getValue());
       
        DeleteOperation delOp =
            new DeleteOperation.Builder(location)
                .withVclock(rObj2.getVClock()).build();
        cluster.execute(delOp);
        delOp.get();
       
        fetchOp =
            new FetchOperation.Builder(location).build();
View Full Code Here

Examples of com.basho.riak.client.core.query.RiakObject

    private void testFetchOpNoSiblings(String bucketType) throws InterruptedException, ExecutionException
    {
        final BinaryValue key = BinaryValue.unsafeCreate("my_key_2".getBytes());
        final String value = "{\"value\":\"value\"}";
       
        RiakObject rObj = new RiakObject().setValue(BinaryValue.create(value));
        Namespace ns = new Namespace(bucketType, bucketName.toString());
        Location location = new Location(ns, key);
        StoreOperation storeOp =
            new StoreOperation.Builder(location)
                .withContent(rObj)
                .build();
       
        cluster.execute(storeOp);
        storeOp.get();
       
        FetchOperation fetchOp =
            new FetchOperation.Builder(location).build();
       
        cluster.execute(fetchOp);
        FetchOperation.Response response = fetchOp.get();
        assertFalse(response.isNotFound());
        List<RiakObject> objectList = response.getObjectList();
        assertEquals(1, objectList.size());
        RiakObject ro = objectList.get(0);
        assertEquals(ro.getValue().toString(), value);
       
    }
View Full Code Here

Examples of com.basho.riak.client.core.query.RiakObject

                .withAllowMulti(true)
                .build();
        cluster.execute(op);
        op.get();
       
        RiakObject rObj = new RiakObject().setValue(BinaryValue.create(value));
        Location location = new Location(namespace, key);
        StoreOperation storeOp =
            new StoreOperation.Builder(location)
                .withContent(rObj)
                .build();
       
        cluster.execute(storeOp);
        storeOp.get();
       
        storeOp =
            new StoreOperation.Builder(location)
                .withContent(rObj)
                .build();
       
        cluster.execute(storeOp);
        storeOp.get();
       
        FetchOperation fetchOp =
            new FetchOperation.Builder(location).build();
               
        cluster.execute(fetchOp);
        FetchOperation.Response response = fetchOp.get();
        assertTrue(response.getObjectList().size() > 1);
       
        RiakObject ro = response.getObjectList().get(0);
        assertEquals(ro.getValue().toString(), value);
       
    }
View Full Code Here

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

                        partBucket = locationParts[locationParts.length - 2];
                        partKey = locationParts[locationParts.length - 1];
                    }
                }

                RiakObject o = new RiakObject(riak, partBucket, partKey, part.getBody(),
                                              headers.get(Constants.HDR_CONTENT_TYPE), links, usermeta, vclock,
                                              headers.get(Constants.HDR_LAST_MODIFIED), headers.get(Constants.HDR_ETAG),
                                              indexes);
                objects.add(o);
            }
View Full Code Here

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

                siblings = ClientUtils.parseMultipart(riak, r.getBucket(), r.getKey(), headers, r.getBody());
            }

            object = siblings.iterator().next();
        } else if (r.isSuccess()) {
            object = new RiakObject(riak, r.getBucket(), r.getKey(), r.getBody(),
                                    headers.get(Constants.HDR_CONTENT_TYPE), links, usermeta,
                                    headers.get(Constants.HDR_VCLOCK), headers.get(Constants.HDR_LAST_MODIFIED),
                                    headers.get(Constants.HDR_ETAG), indexes);

            Long contentLength = null;
View Full Code Here

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

                    partBucket = locationParts[locationParts.length - 2];
                    partKey = locationParts[locationParts.length - 1];
                }
            }

            RiakObject o = new RiakObject(riak, partBucket, partKey, null, headers.get(Constants.HDR_CONTENT_TYPE),
                                 links, usermeta, vclock, headers.get(Constants.HDR_LAST_MODIFIED),
                                 headers.get(Constants.HDR_ETAG), indexes);
            o.setValueStream(part.getStream());
            cache(o);
            return true;
        }

        return false;
View Full Code Here

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

                        partBucket = locationParts[locationParts.length - 2];
                        partKey = urlDecode(locationParts[locationParts.length - 1]);
                    }
                }

                RiakObject o = new RiakObject(riak, partBucket, partKey, part.getBody(),
                                              headers.get(Constants.HDR_CONTENT_TYPE), links, usermeta, vclock,
                                              headers.get(Constants.HDR_LAST_MODIFIED), headers.get(Constants.HDR_ETAG),
                                              indexes);
                objects.add(o);
            }
View Full Code Here

Examples of com.basho.riak.client.query.RiakObject

  @Test
  public void testStoreFetchDelete() throws ExecutionException, InterruptedException
  {

    RiakObject o = RiakObject.create(bucket.unsafeGetValue()).setValue("test value");
    StoreMeta storeMeta = new StoreMeta.Builder().returnBody(true).build();

    StoreOperation<RiakObject> store =
      new StoreOperation<RiakObject>(bucket, o)
        .withConverter(domainObjectConverter)
        .withStoreMeta(storeMeta);

    cluster.execute(store);

    RiakObject storeReturn = store.get();

    BinaryValue returnedKey = BinaryValue.create(storeReturn.getBucketAsBytes());
    FetchOperation<RiakObject> fetch =
      new FetchOperation<RiakObject>(bucket, returnedKey)
      .withConverter(domainObjectConverter);

    cluster.execute(fetch);

    RiakObject fetchReturn = fetch.get();

    DeleteOperation delete = new DeleteOperation(bucket, returnedKey);

    cluster.execute(delete);

    delete.get();

    FetchOperation<RiakObject> tombstoneFetch =
      new FetchOperation<RiakObject>(bucket, returnedKey)
      .withConverter(domainObjectConverter);

    cluster.execute(tombstoneFetch);

    RiakObject tombstone = tombstoneFetch.get();

    Assert.assertTrue(tombstone.isNotFound());

  }
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.