Package com.basho.riak.client

Examples of com.basho.riak.client.IRiakObject


     *         fails because a match exists
     */
    public T execute() throws RiakRetryFailedException, UnresolvedConflictException, ConversionException {
        final T resolved = fetchObject.execute();
        final T mutated = mutation.apply(resolved);
        final IRiakObject o = converter.fromDomain(mutated, fetchObject.getVClock());
        final StoreMeta storeMeta = storeMetaBuilder.returnBody(returnBody).build();

        // if non match and if not modified require extra data for the HTTP API
        // pull that from the riak object if possible
        if(storeMeta.hasIfNoneMatch() && storeMeta.getIfNoneMatch() && o != null) {
            storeMeta.etags(new String[] {o.getVtag()});
        }

        if(storeMeta.hasIfNotModified() && storeMeta.getIfNotModified()  && o != null) {
            storeMeta.lastModified(o.getLastModified());
        }

        final RiakResponse stored = retrier.attempt(new Callable<RiakResponse>() {
            public RiakResponse call() throws Exception {
                return client.store(o, storeMeta);
View Full Code Here


     *         fails because a match exists
     */
    public T execute() throws RiakRetryFailedException, UnresolvedConflictException, ConversionException {
        final T resolved = fetchObject.execute();
        final T mutated = mutation.apply(resolved);
        final IRiakObject o = converter.fromDomain(mutated, fetchObject.getVClock());
        final StoreMeta storeMeta = generateStoreMeta();

        // if non match and if not modified require extra data for the HTTP API
        // pull that from the riak object if possible
        if(storeMeta.hasIfNonMatch() && storeMeta.getIfNonMatch() && o != null) {
            storeMeta.etags(new String[] {o.getVtag()});
        }

        if(storeMeta.hasIfNotModified() && storeMeta.getIfNotModified()  && o != null) {
            storeMeta.lastModified(o.getLastModified());
        }

        final RiakResponse stored = retrier.attempt(new Callable<RiakResponse>() {
            public RiakResponse call() throws Exception {
                return client.store(o, storeMeta);
View Full Code Here

     *         fails because a match exists
     */
    public T execute() throws RiakRetryFailedException, UnresolvedConflictException, ConversionException {
        final T resolved = fetchObject.execute();
        final T mutated = mutation.apply(resolved);
        final IRiakObject o = converter.fromDomain(mutated, fetchObject.getVClock());
        final StoreMeta storeMeta = storeMetaBuilder.returnBody(returnBody).build();

        // if non match and if not modified require extra data for the HTTP API
        // pull that from the riak object if possible
        if(storeMeta.hasIfNoneMatch() && storeMeta.getIfNoneMatch() && o != null) {
            storeMeta.etags(new String[] {o.getVtag()});
        }

        if(storeMeta.hasIfNotModified() && storeMeta.getIfNotModified()  && o != null) {
            storeMeta.lastModified(o.getLastModified());
        }

        final RiakResponse stored = retrier.attempt(new Callable<RiakResponse>() {
            public RiakResponse call() throws Exception {
                return client.store(o, storeMeta);
View Full Code Here

    {
        try
        {

            Bucket bucket = riakClient.fetchBucket( bucketKey ).execute();
            IRiakObject entity = bucket.fetch( entityReference.identity() ).execute();
            if( entity == null )
            {
                throw new EntityNotFoundException( entityReference );
            }
            String jsonState = entity.getValueAsString();
            return new StringReader( jsonState );

        }
        catch( RiakRetryFailedException ex )
        {
View Full Code Here

                            throws IOException
                        {
                            try
                            {
                                super.close();
                                IRiakObject entity = bucket.fetch( ref.identity() ).execute();
                                if( entity == null )
                                {
                                    throw new EntityNotFoundException( ref );
                                }
                                bucket.store( ref.identity(), toString() ).execute();
                            }
                            catch( RiakException ex )
                            {
                                throw new EntityStoreException( "Unable to apply entity change: updateEntity", ex );
                            }
                        }

                    };
                }

                @Override
                public void removeEntity( EntityReference ref, EntityDescriptor entityDescriptor )
                    throws EntityNotFoundException
                {
                    try
                    {
                        IRiakObject entity = bucket.fetch( ref.identity() ).execute();
                        if( entity == null )
                        {
                            throw new EntityNotFoundException( ref );
                        }
                        bucket.delete( ref.identity() ).execute();
View Full Code Here

        if (doNotFetch) {
            vclock = VClockUtil.getVClock(mutated);
        }
       
       
        final IRiakObject o = converter.fromDomain(mutated, vclock);
        final StoreMeta storeMeta = storeMetaBuilder.returnBody(returnBody).build();

        // if non match and if not modified require extra data for the HTTP API
        // pull that from the riak object if possible
        if(storeMeta.hasIfNoneMatch() && storeMeta.getIfNoneMatch() && o != null) {
            storeMeta.etags(new String[] {o.getVtag()});
        }

        if(storeMeta.hasIfNotModified() && storeMeta.getIfNotModified()  && o != null) {
            storeMeta.lastModified(o.getLastModified());
        }

        final boolean hasMutated =
            mutation instanceof ConditionalStoreMutation<?>
            ? ((ConditionalStoreMutation<T>)mutation).hasMutated()
View Full Code Here

      {
        KeyValueMessage result = null;
        final String key = (String) parameters[0];
        final EncodingMetadata expectedEncoding = (EncodingMetadata) parameters[1];
        // FIXME: use the vector clock...
        IRiakObject riakObj = null;
        try {
          riakObj = RiakOperationFactory.this.bucket.fetch (key).execute ();
        } catch (final UnresolvedConflictException e) {
          FallbackExceptionTracer.defaultInstance.traceIgnoredException (e);
        } catch (final RiakRetryFailedException e) {
          // TODO: shutdown all connectors for this bucket?
          FallbackExceptionTracer.defaultInstance.traceIgnoredException (e);
        } catch (final ConversionException e) {
          FallbackExceptionTracer.defaultInstance.traceIgnoredException (e);
        }
        if (null != riakObj) {
          result = new KeyValueMessage (key, riakObj.getValue (), riakObj.getUsermeta (IOperationFactory.CONTENT_ENCODING), riakObj.getContentType ());
        } else {
          result = new KeyValueMessage (key, null, expectedEncoding.getContentEncoding (), expectedEncoding.getContentType ());
        }
        return result;
      }
View Full Code Here

          throws IOException
      {
        final KeyValueMessage kvMessage = (KeyValueMessage) parameters[0];
        final String key = kvMessage.getKey ();
        // FIXME: use the vector clock...
        final IRiakObject riakObject = RiakObjectBuilder.newBuilder (RiakOperationFactory.this.bucket.getName (), key).addUsermeta (IOperationFactory.CONTENT_ENCODING, kvMessage.getContentEncoding ()).withContentType (kvMessage.getContentType ()).withValue (kvMessage.getData ()).build ();
        final RiakBucket riakBucket = RiakBucket.newRiakBucket (RiakOperationFactory.this.bucket);
        try {
          riakBucket.store (riakObject);
        } catch (final RiakException e) {
          // TODO: shutdown all connectors for this bucket?
View Full Code Here

        if (doNotFetch) {
            vclock = VClockUtil.getVClock(mutated);
        }
       
       
        final IRiakObject o = converter.fromDomain(mutated, vclock);
        final StoreMeta storeMeta = storeMetaBuilder.returnBody(returnBody).build();

        // if non match and if not modified require extra data for the HTTP API
        // pull that from the riak object if possible
        if(storeMeta.hasIfNoneMatch() && storeMeta.getIfNoneMatch() && o != null) {
            storeMeta.etags(new String[] {o.getVtag()});
        }

        if(storeMeta.hasIfNotModified() && storeMeta.getIfNotModified()  && o != null) {
            storeMeta.lastModified(o.getLastModified());
        }

        final boolean hasMutated =
            mutation instanceof ConditionalStoreMutation<?>
            ? ((ConditionalStoreMutation<T>)mutation).hasMutated()
View Full Code Here

        if (doNotFetch) {
            vclock = VClockUtil.getVClock(mutated);
        }
       
       
        final IRiakObject o = converter.fromDomain(mutated, vclock);
        final StoreMeta storeMeta = storeMetaBuilder.returnBody(returnBody).build();

        // if non match and if not modified require extra data for the HTTP API
        // pull that from the riak object if possible
        if(storeMeta.hasIfNoneMatch() && storeMeta.getIfNoneMatch() && o != null) {
            storeMeta.etags(new String[] {o.getVtag()});
        }

        if(storeMeta.hasIfNotModified() && storeMeta.getIfNotModified()  && o != null) {
            storeMeta.lastModified(o.getLastModified());
        }

        final boolean hasMutated =
            mutation instanceof ConditionalStoreMutation<?>
            ? ((ConditionalStoreMutation<T>)mutation).hasMutated()
View Full Code Here

TOP

Related Classes of com.basho.riak.client.IRiakObject

Copyright © 2018 www.massapicom. 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.