Class BulkGetFuture<T>

  • Type Parameters:
    T - types of objects returned from the GET
    All Implemented Interfaces:
    java.util.concurrent.Future<java.util.Map<java.lang.String,​T>>, BulkFuture<java.util.Map<java.lang.String,​T>>, ListenableFuture<java.util.Map<java.lang.String,​T>,​BulkGetCompletionListener>

    public class BulkGetFuture<T>
    extends AbstractListenableFuture<java.util.Map<java.lang.String,​T>,​BulkGetCompletionListener>
    implements BulkFuture<java.util.Map<java.lang.String,​T>>
    Future for handling results from bulk gets. Not intended for general use.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private boolean cancelled  
      private java.util.concurrent.CountDownLatch latch  
      private java.util.Collection<Operation> ops  
      private java.util.Map<java.lang.String,​java.util.concurrent.Future<T>> rvMap  
      private OperationStatus status  
      private boolean timeout  
    • Constructor Summary

      Constructors 
      Constructor Description
      BulkGetFuture​(java.util.Map<java.lang.String,​java.util.concurrent.Future<T>> m, java.util.Collection<Operation> getOps, java.util.concurrent.CountDownLatch l, java.util.concurrent.ExecutorService service)  
    • Field Detail

      • rvMap

        private final java.util.Map<java.lang.String,​java.util.concurrent.Future<T>> rvMap
      • ops

        private final java.util.Collection<Operation> ops
      • latch

        private final java.util.concurrent.CountDownLatch latch
      • cancelled

        private boolean cancelled
      • timeout

        private boolean timeout
    • Constructor Detail

      • BulkGetFuture

        public BulkGetFuture​(java.util.Map<java.lang.String,​java.util.concurrent.Future<T>> m,
                             java.util.Collection<Operation> getOps,
                             java.util.concurrent.CountDownLatch l,
                             java.util.concurrent.ExecutorService service)
    • Method Detail

      • cancel

        public boolean cancel​(boolean ign)
        Specified by:
        cancel in interface java.util.concurrent.Future<T>
      • get

        public java.util.Map<java.lang.String,​T> get()
                                                    throws java.lang.InterruptedException,
                                                           java.util.concurrent.ExecutionException
        Specified by:
        get in interface java.util.concurrent.Future<T>
        Throws:
        java.lang.InterruptedException
        java.util.concurrent.ExecutionException
      • getSome

        public java.util.Map<java.lang.String,​T> getSome​(long to,
                                                               java.util.concurrent.TimeUnit unit)
                                                        throws java.lang.InterruptedException,
                                                               java.util.concurrent.ExecutionException
        Description copied from interface: BulkFuture
        Wait for the operation to complete and return results If operation could not complete within specified timeout, partial result is returned. Otherwise, the behavior is identical to Future.get(long, TimeUnit)
        Specified by:
        getSome in interface BulkFuture<T>
        Returns:
        a partial get bulk result
        Throws:
        java.lang.InterruptedException
        java.util.concurrent.ExecutionException
      • get

        public java.util.Map<java.lang.String,​T> get​(long to,
                                                           java.util.concurrent.TimeUnit unit)
                                                    throws java.lang.InterruptedException,
                                                           java.util.concurrent.ExecutionException,
                                                           java.util.concurrent.TimeoutException
        Specified by:
        get in interface java.util.concurrent.Future<T>
        Throws:
        java.lang.InterruptedException
        java.util.concurrent.ExecutionException
        java.util.concurrent.TimeoutException
      • internalGet

        private java.util.Map<java.lang.String,​T> internalGet​(long to,
                                                                    java.util.concurrent.TimeUnit unit,
                                                                    java.util.Collection<Operation> timedoutOps)
                                                             throws java.lang.InterruptedException,
                                                                    java.util.concurrent.ExecutionException
        refactored code common to both get(long, TimeUnit) and getSome(long, TimeUnit).
        Parameters:
        to -
        unit -
        timedoutOps -
        Returns:
        Throws:
        java.lang.InterruptedException
        java.util.concurrent.ExecutionException
      • getStatus

        public OperationStatus getStatus()
        Description copied from interface: BulkFuture
        Gets the status of the operation upon completion.
        Specified by:
        getStatus in interface BulkFuture<T>
        Returns:
        the operation status.
      • isCancelled

        public boolean isCancelled()
        Specified by:
        isCancelled in interface java.util.concurrent.Future<T>
      • isDone

        public boolean isDone()
        Specified by:
        isDone in interface java.util.concurrent.Future<T>
      • isTimeout

        public boolean isTimeout()
        Specified by:
        isTimeout in interface BulkFuture<T>
        Returns:
        true if timeout was reached, false otherwise
      • addListener

        public java.util.concurrent.Future<java.util.Map<java.lang.String,​T>> addListener​(BulkGetCompletionListener listener)
        Description copied from interface: BulkFuture
        Add a listener to the future, which will be executed once the operation completes.
        Specified by:
        addListener in interface BulkFuture<T>
        Specified by:
        addListener in interface ListenableFuture<java.util.Map<java.lang.String,​T>,​BulkGetCompletionListener>
        Parameters:
        listener - the listener which will be executed.
        Returns:
        the current future to allow for object-chaining.
      • signalComplete

        public void signalComplete()
        Signals that this future is complete.