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
Nested Classes Modifier and Type Class Description static class
AbstractDataList.DrainOnGetFuture<DATATYPE extends Data>
-
Constructor Summary
Constructors Modifier Constructor Description protected
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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description com.google.common.util.concurrent.ListenableFuture<DataList<DATATYPE>>
complete()
Returns a future in which all incoming data in this has become available.IncomingData<DATATYPE>
incoming()
Returns the holder of incoming data to this.boolean
isOrdered()
Returns false if the data in this list can be returned in any order.boolean
isStreamed()
Returns false if the data in this list can not be returned until it is completed.Request
request()
Returns the request which created this datajava.lang.String
toString()
-
Methods inherited from class com.yahoo.component.provider.ListenableFreezableClass
addFreezeListener, clone, freeze
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
-
-
-
Constructor Detail
-
AbstractDataList
protected AbstractDataList(Request request)
Creates a simple data list which does not allow late incoming data- Parameters:
request
- the request which created this data list
-
AbstractDataList
protected AbstractDataList(Request request, IncomingData<DATATYPE> incomingData)
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 Detail
-
request
public Request request()
Returns the request which created this data
-
incoming
public IncomingData<DATATYPE> 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
public com.google.common.util.concurrent.ListenableFuture<DataList<DATATYPE>> complete()
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.
- 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
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-