public class Sink
extends org.opendof.datatransfer.Endpoint
ValueSetListener will receive load-balanced
data. Usually, a single sink in each database site receives a given piece of data. However, network problems may cause duplication,
and load-balanced sinks should be prepared to handle duplicate submissions.
All sinks must implement the StatusListener.
The SLF4J library is used for all non-OpenDOF logging. If logging of the OpenDOF OAL library is desired, a logger must
be added to the OAL by calling DOF.Log#addListener.
This class can be instantiated only by using its static create(org.opendof.datatransfer.sink.Sink.Config) method.| Modifier and Type | Class and Description |
|---|---|
static class |
Sink.Config
The Config class represents the configuration of a sink.
|
| Modifier and Type | Method and Description |
|---|---|
void |
cancelRequestValues(org.opendof.core.oal.DOFObjectID source,
org.opendof.core.oal.DOFObjectID sink,
long requestID)
Cancels a request for full-resolution data with the specified requestID and target sink.
|
void |
cancelRequestValues(org.opendof.core.oal.DOFObjectID source,
long requestID)
Cancels a request for full-resolution data with the specified requestId.
|
void |
close()
Closes the sink, which releases all resources and stops all listeners.
|
static Sink |
create(Sink.Config config)
Creates and returns an instance of
Sink that uses the specified configuration. |
org.opendof.core.oal.DOFObjectID |
getBaseID()
Get the base ID of the Sink (excluding any instance ID).
|
org.opendof.core.oal.DOFObjectID |
getID()
Get the full, unique ID of the Sink (including any instance ID).
|
int |
getOperationTimeout()
Get the Sink's operation timeout.
|
org.opendof.core.oal.DOFSystem |
getSystem()
Gets the OpenDOF system used by the sink to facilitate network communications.
|
int |
getThreadpoolSize()
Get the maximum number of operations that will be allowed to process simultaneously.
|
void |
requestValues(org.opendof.core.oal.DOFObjectID source,
org.opendof.core.oal.DOFObjectID sink,
long requestID,
org.opendof.core.oal.DOFObjectID deviceID,
org.opendof.core.oal.DOFInterfaceID propertyInterfaceID,
int propertyItemID,
java.util.Date start,
int duration,
int timeout)
Requests that the full-resolution data be sent to the database site with the specified sink for
the specified object, item, and period of time.
|
void |
requestValues(org.opendof.core.oal.DOFObjectID source,
long requestID,
org.opendof.core.oal.DOFObjectID deviceID,
org.opendof.core.oal.DOFInterfaceID propertyInterfaceID,
int propertyItemID,
java.util.Date start,
int duration,
int timeout)
Requests that the full-resolution data be sent to the database site for
the specified object, item, and period of time.
|
void |
sendNotification(org.opendof.core.oal.DOFObjectID rootID,
org.opendof.core.oal.DOFObjectID deviceID,
java.lang.String notification) |
java.lang.String |
toString() |
public static Sink create(Sink.Config config)
Sink that uses the specified configuration. The sink immediately begins
processing and continues processing until close() is called or the object is garbage collected.
The sink will start with StatusLevel.ERROR during initialization. The StatusListener will be notified with
StatusLevel.OK once the sink has finished initializing.
config - The configuration to use. This must not be null.Sink.Config,
Sink.Config.Builder,
StatusListenerpublic void close()
StatusListener, may continue receiving information until the sink is fully closed.public void requestValues(org.opendof.core.oal.DOFObjectID source,
long requestID,
org.opendof.core.oal.DOFObjectID deviceID,
org.opendof.core.oal.DOFInterfaceID propertyInterfaceID,
int propertyItemID,
java.util.Date start,
int duration,
int timeout)
throws org.opendof.datatransfer.SourceNotFoundException,
org.opendof.datatransfer.OutOfRangeException,
org.opendof.datatransfer.OutOfResourcesException,
org.opendof.datatransfer.SinkNotFoundException,
org.opendof.datatransfer.UnknownDataException,
org.opendof.datatransfer.DuplicateRequestIDException,
java.lang.Exception
cancelRequestValues(DOFObjectID, long)
method, or by any other sink using the cancelRequestValues(DOFObjectID, DOFObjectID, long) method.
The request key will also be passed to the ValueSetListener.requestComplete(org.opendof.datatransfer.sink.Sink, long, org.opendof.datatransfer.DetailRequestStatus) method.
The platform does not track which sink initiated a request. Full-resolution data will be sent to any sink whose
base ID matches that of the requesting sink and that has a ValueSetListener. Any sink that knows the request key may call
the cancelRequestValues(DOFObjectID, long) method and cancel the request.
The database site must have a sink with an active ValueSetListener for the request to be accepted.
The source identifier may include an attribute which identifies a specific source instance ID. However, the instance ID
may be ignored if no matching source is currently available.source - Identifies the source from which to request the data.requestID - A unique identifier for the request (within the context of the target sink). requestID is an unsigned 32-bit integer
and must be non-negative and less than 2^32.deviceID - Identifies the object to request full-resolution data for. Must not be null.propertyInterfaceID - Identifies the interface ID of the property to request full-resolution data for. Must not be null.propertyItemID - Identifies the item ID of the property to request full-resolution data for. Must not be null.start - The earliest timestamp of data entries to send. This may be in the past or future. Must not be null.duration - The number of milliseconds from the start for which data will be returned. Must be greater than 0.timeout - The timeout of the request. If the timeout is reached before all data has been received ValueSetListener.requestComplete(org.opendof.datatransfer.sink.Sink, long, org.opendof.datatransfer.DetailRequestStatus)
will be called with status DetailRequestStatus.TIMEOUT.org.opendof.datatransfer.SourceNotFoundException - Thrown if the sink is not connected to the specified source.org.opendof.datatransfer.OutOfRangeException - Thrown if the request is outside the time range for which the source stores data or if timeout is
greater than the source Allows. The valid range can be obtained by calling OutOfRangeException.getMaxHistoricalAge(),
OutOfRangeException.getMaxDuration() and OutOfRangeException.getMaxTimeout().org.opendof.datatransfer.OutOfResourcesException - Thrown if the source has insufficient resources to persist or process the request.org.opendof.datatransfer.SinkNotFoundException - Thrown if the sink is not known by the source.org.opendof.datatransfer.UnknownDataException - Thrown if the requested device ID or property are not known by the source.org.opendof.datatransfer.DuplicateRequestIDException - Thrown if a request with the specified requestID already exists.java.lang.Exception - Thrown if there is an error communicating with the source.public void requestValues(org.opendof.core.oal.DOFObjectID source,
org.opendof.core.oal.DOFObjectID sink,
long requestID,
org.opendof.core.oal.DOFObjectID deviceID,
org.opendof.core.oal.DOFInterfaceID propertyInterfaceID,
int propertyItemID,
java.util.Date start,
int duration,
int timeout)
throws org.opendof.datatransfer.SourceNotFoundException,
org.opendof.datatransfer.OutOfRangeException,
org.opendof.datatransfer.OutOfResourcesException,
org.opendof.datatransfer.SinkNotFoundException,
org.opendof.datatransfer.UnknownDataException,
org.opendof.datatransfer.DuplicateRequestIDException,
java.lang.Exception
cancelRequestValues(DOFObjectID, long)
method, or by any other sink using the cancelRequestValues(DOFObjectID, DOFObjectID, long) method.
The request key will also be passed to the ValueSetListener.requestComplete(org.opendof.datatransfer.sink.Sink, long, org.opendof.datatransfer.DetailRequestStatus) method.
The platform does not track which sink initiated a request. Full-resolution data will be sent to
sinks that match the specified sink ID and have a ValueSetListener. Any sink that knows the request key may call
the cancelRequestValues(DOFObjectID, DOFObjectID, long) method and cancel the request.
The database site must have a sink with an active ValueSetListener for the request to be accepted.
The source identifier may include an attribute which identifies a specific source instance ID. However, the instance ID
may be ignored if no matching source is currently available.source - Identifies the source from which to request the data.sink - Identifies the target sink to which the response should be sent.requestID - A unique identifier for the request (within the context of the target sink). requestID is an unsigned 32-bit integer
and Must be non-negative and less than 2^32.deviceID - Identifies the object to request full-resolution data for. Must not be null.propertyInterfaceID - Identifies the interface ID of the property to request full-resolution data for. Must not be null.propertyItemID - Identifies the item ID of the property to request full-resolution data for. Must not be null.start - The earliest timestamp of data entries to send. This may be in the past or future. Must not be null.duration - The number of milliseconds from the start for which data will be returned. Must be greater than 0.timeout - The timeout of the request. If the timeout is reached before all data has been received ValueSetListener.requestComplete(org.opendof.datatransfer.sink.Sink, long, org.opendof.datatransfer.DetailRequestStatus)
will be called with status DetailRequestStatus.TIMEOUT.org.opendof.datatransfer.SourceNotFoundException - Thrown if the sink is not connected to the specified source.org.opendof.datatransfer.OutOfRangeException - Thrown if the request is outside the time range for which the source stores data or if timeout is
greater than the source Allows. The valid range can be obtained by calling OutOfRangeException.getMaxHistoricalAge(),
OutOfRangeException.getMaxDuration() and OutOfRangeException.getMaxTimeout().org.opendof.datatransfer.OutOfResourcesException - Thrown if the source has insufficient resources to persist or process the request.org.opendof.datatransfer.SinkNotFoundException - Thrown if the specified sink is not known by the source.org.opendof.datatransfer.UnknownDataException - Thrown if the requested device ID or property are not known by the source.org.opendof.datatransfer.DuplicateRequestIDException - Thrown if a request with the specified requestID already exists.java.lang.Exception - Thrown if there is an error communicating with the source.public void cancelRequestValues(org.opendof.core.oal.DOFObjectID source,
long requestID)
throws org.opendof.datatransfer.SourceNotFoundException,
java.lang.Exception
requestValues(org.opendof.core.oal.DOFObjectID, long, org.opendof.core.oal.DOFObjectID, org.opendof.core.oal.DOFInterfaceID, int, java.util.Date, int, int) method.
This method returns successfully even if the request cannot be found.
The source identifier may include an attribute which identifies a specific source instance ID. However, the instance ID
may be ignored if no matching source is currently available.source - The identifier of the Source that received the initial request.requestID - The unique identifier passed into requestValues(org.opendof.core.oal.DOFObjectID, long, org.opendof.core.oal.DOFObjectID, org.opendof.core.oal.DOFInterfaceID, int, java.util.Date, int, int). requestID is an unsigned 32-bit integer
and must be non-negative and less than 2^32.org.opendof.datatransfer.SourceNotFoundException - Thrown if the sink is not connected to the specified source.java.lang.Exception - Thrown if the platform cannot accept the request.public void cancelRequestValues(org.opendof.core.oal.DOFObjectID source,
org.opendof.core.oal.DOFObjectID sink,
long requestID)
throws org.opendof.datatransfer.SourceNotFoundException,
java.lang.Exception
source - The identifier of the Source that received the initial request.sink - The identifier of the Sink specified to receive data for the initial request.requestID - The unique identifier passed into requestValues(org.opendof.core.oal.DOFObjectID, long, org.opendof.core.oal.DOFObjectID, org.opendof.core.oal.DOFInterfaceID, int, java.util.Date, int, int). requestID is an unsigned 32-bit integer
and must be non-negative and less than 2^32.org.opendof.datatransfer.SourceNotFoundException - Thrown if the sink is not connected to the specified source.java.lang.Exception - Thrown if the platform cannot accept the request.public void sendNotification(org.opendof.core.oal.DOFObjectID rootID,
org.opendof.core.oal.DOFObjectID deviceID,
java.lang.String notification)
throws java.lang.Exception
sendNotification in class org.opendof.datatransfer.Endpointjava.lang.Exceptionpublic org.opendof.core.oal.DOFSystem getSystem()
public org.opendof.core.oal.DOFObjectID getID()
public org.opendof.core.oal.DOFObjectID getBaseID()
public int getThreadpoolSize()
public int getOperationTimeout()
public java.lang.String toString()
toString in class java.lang.Object