Package com.yahoo.processing.response
Class AbstractDataList<DATATYPE extends Data>
java.lang.Object
com.yahoo.component.provider.FreezableClass
com.yahoo.component.provider.ListenableFreezableClass
com.yahoo.processing.response.AbstractDataList<DATATYPE>
- All Implemented Interfaces:
com.yahoo.component.provider.Freezable
,com.yahoo.component.provider.ListenableFreezable
,Data
,DataList<DATATYPE>
,Ordered
,Streamed
- Direct Known Subclasses:
ArrayDataList
public abstract class AbstractDataList<DATATYPE extends Data>
extends com.yahoo.component.provider.ListenableFreezableClass
implements DataList<DATATYPE>, Streamed, Ordered
A convenience superclass for dataList implementations which handles references to the request and to incoming data.
- Author:
- bratseth
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractDataList
(Request request) Creates a simple data list which does not allow late incoming dataprotected
AbstractDataList
(Request request, IncomingData<DATATYPE> incomingData) Creates a simple data list which receives incoming data in the given instanceprotected
AbstractDataList
(Request request, IncomingData<DATATYPE> incomingData, boolean ordered, boolean streamed) Creates a simple data list which receives incoming data in the given instance -
Method Summary
Modifier and TypeMethodDescriptioncomplete()
Deprecated, for removal: This API element is subject to removal in a future version.Returns a future in which all incoming data in this has become available.incoming()
Returns the holder of incoming data to this.boolean
Returns false if the data in this list can be returned in any order.boolean
Returns false if the data in this list can not be returned until it is completed.request()
Returns the request which created this datatoString()
Methods inherited from class com.yahoo.component.provider.ListenableFreezableClass
addFreezeListener, clone, freeze
Methods inherited from class com.yahoo.component.provider.FreezableClass
ensureNotFrozen, isFrozen
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.yahoo.processing.response.DataList
add, addDataListener, asList, close, get
Methods inherited from interface com.yahoo.component.provider.Freezable
freeze, isFrozen
Methods inherited from interface com.yahoo.component.provider.ListenableFreezable
addFreezeListener
-
Constructor Details
-
AbstractDataList
Creates a simple data list which does not allow late incoming data- Parameters:
request
- the request which created this data list
-
AbstractDataList
Creates a simple data list which receives incoming data in the given instance- Parameters:
request
- the request which created this data list, never nullincomingData
- the recipient of incoming data to this list, never null
-
AbstractDataList
protected AbstractDataList(Request request, IncomingData<DATATYPE> incomingData, boolean ordered, boolean streamed) Creates a simple data list which receives incoming data in the given instance- Parameters:
request
- the request which created this data list, never nullincomingData
- the recipient of incoming data to this list, never null
-
-
Method Details
-
request
Returns the request which created this data -
incoming
Returns the holder of incoming data to this. This may be used to add, consume, wait for and be notified about incoming data. If this instance does not support late incoming data, the read methods of the return object behaves as expected and is synchronization free. The write methods throws an exception. -
complete
@Deprecated(forRemoval=true, since="7") public com.google.common.util.concurrent.ListenableFuture<DataList<DATATYPE>> complete()Deprecated, for removal: This API element is subject to removal in a future version. -
completeFuture
Description copied from interface:DataList
Returns a future in which all incoming data in this has become available. This has two uses:- Calling
DataList.get(int)
on this future will block (if necessary) until all incoming data has arrived, transfer that data from the incoming buffer into this list and invoke any listeners on this event on the calling thread. - Adding a listener on this future will cause it to be called when completion().get() is called, after the incoming data has been moved to this thread and before the get() call returns.
Note that if no thread calls completed().get(), this future will never occur.
Any data list consumer who wishes to make sure it sees the complete data for this list must call
dataList.complete().get()
before consuming this list. If a guaranteed non-blocking call to this method is desired, register a listener on the future where all data is available for draining (that is, ondataList.incoming().completed()
) and resume by calling this method from the listener.Making this call on a list which does not support future data always returns immediately and causes no memory synchronization cost.
- Specified by:
completeFuture
in interfaceDataList<DATATYPE extends Data>
- Calling
-
isOrdered
public boolean isOrdered()Description copied from interface:Ordered
Returns false if the data in this list can be returned in any order. Default: true, meaning the order matters -
isStreamed
public boolean isStreamed()Description copied from interface:Streamed
Returns false if the data in this list can not be returned until it is completed. Default: true, meaning eager streaming of the data is permissible.- Specified by:
isStreamed
in interfaceStreamed
-
toString
-