public class Source
extends org.opendof.datatransfer.Endpoint
DataRequestHandler listener in order to receive requests for detailed data.
Additionally, sources are able to send ValueSets, Events, and TopologyInformation to a
Sink. If many sinks with matching base DOFObjectIDs exist, data will be automatically load balanced between
the sinks.
All sources must implement the StatusListener and the DeliveryListener.
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.source.Source.Config) method.| Modifier and Type | Class and Description |
|---|---|
static class |
Source.Config
The Config class represents the configuration of a source.
|
| Modifier and Type | Method and Description |
|---|---|
void |
cancelEvent(long eventID)
Cancel an event signal call made to
submitEvent(DOFObjectID, Event, long). |
void |
cancelTopologyUpdate(long topologyUpdateID)
Cancel a topology update call made to
submitTopologyUpdate(DOFObjectID, TopologyInformation, long, Date)
. |
void |
cancelValueSet(long valueSetID)
Cancel a ValueSet submission call made to
submitValueSet(DOFObjectID, ValueSet, long). |
void |
close()
Closes the source, which releases all resources and stops all listeners.
|
void |
completeRequest(org.opendof.core.oal.DOFObjectID sink,
long requestID,
org.opendof.datatransfer.DetailRequestStatus status)
Notify the sink that it has received all ValueSets for a given request, specified by the requestID.
|
static Source |
create(Source.Config config)
Creates and returns an instance of
Source that uses the specified configuration. |
org.opendof.core.oal.DOFObjectID |
getBaseID()
Get the base ID of the Source (excluding any instance ID).
|
org.opendof.core.oal.DOFObjectID |
getID()
Get the full, unique ID of the Source (including any instance ID).
|
long |
getMaxDeliveryPeriod()
Get the maximum amount of time that the Source will wait for an acknowledgment before
reporting failure to the DeliveryListener.
|
int |
getOperationTimeout()
Get the Sources's operation timeout.
|
int |
getRetryTime()
Get the minimum amount of time that the source will wait before re-advertising ValueSets, Events or
TopologyUpdates.
|
org.opendof.core.oal.DOFSystem |
getSystem()
Gets the OpenDOF system used by the source to facilitate network communications.
|
int |
getThreadpoolSize()
Get the maximum number of operations that will be allowed to process simultaneously.
|
void |
sendNotification(org.opendof.core.oal.DOFObjectID rootID,
org.opendof.core.oal.DOFObjectID deviceID,
java.lang.String notification) |
void |
submitEvent(org.opendof.core.oal.DOFObjectID sink,
org.opendof.datatransfer.Event event,
long eventID)
Sends an
Event regarding a particular object. |
void |
submitTopologyUpdate(org.opendof.core.oal.DOFObjectID sink,
org.opendof.datatransfer.TopologyInformation topologyInformation,
long topologyUpdateID,
java.util.Date time)
Sends a topology update regarding a particular object.
|
void |
submitValueSet(org.opendof.core.oal.DOFObjectID sink,
org.opendof.datatransfer.ValueSet valueSet,
long valueSetID)
Submit a
ValueSet to be advertised to the specified sink. |
java.lang.String |
toString() |
public static Source create(Source.Config config)
Source that uses the specified configuration. The source immediately
begins
processing and continues processing until close() is called or the object is garbage collected.
The source will start with StatusLevel.ERROR during initialization. The
StatusListener will be notified with
StatusLevel.OK once the source has finished initializing.
config - The configuration to use. This must not be null.Source.Config,
Source.Config.Builder,
StatusListenerpublic void close()
StatusListener, may continue receiving information until the source is fully closed.public void submitValueSet(org.opendof.core.oal.DOFObjectID sink,
org.opendof.datatransfer.ValueSet valueSet,
long valueSetID)
ValueSet to be advertised to the specified sink. Once the ValueSet has been acknowledged by the
sink, DeliveryListener.valueSetDelivered(Source, long, Throwable) will be notified. If the maximum delivery
period ends
before an acknowledgment has been received, the listener will be notified of failure.
Each ValueSet must be assigned a unique identifier. A ValueSet may be resubmitted using the same
valueSetID in order to reset its maxDeliveryPeriod timer. While it is possible to reuse a valueSetID once the
previous ValueSet to use that ID has been delivered (and after a reasonable grace period), multiple
ValueSets sharing a valueSetID
must not be submitted at the same time.sink - The identifier of the sink where the ValueSet should be sent. If the specified identifier includes
an attribute, only a sink whose identity includes a matching attribute will receive the data. If the
specified
identifier does not include an attribute, any sink whose base ID matches the specified ID may receive the
ValueSet.
Must not be null.valueSet - The ValueSet to be sent to the sink. Must not be null.valueSetID - The unique identifier for this ValueSet. valueSetID is an unsigned 32-bit integer
and must be non-negative and less than 2^32.DeliveryListener,
DOFObjectID.Attributepublic void submitEvent(org.opendof.core.oal.DOFObjectID sink,
org.opendof.datatransfer.Event event,
long eventID)
Event regarding a particular object. Events are intended for automatic
processing. They are symmetrical to the org.opendof.datatransfer.sink.EventListener functionality of
the sink—but they are sent to the platform,
rather than received from the platform.
Once the Event has been acknowledged by the sink,
DeliveryListener.eventDelivered(Source, long, Throwable) will be notified. If the maximum delivery period
ends before an acknowledgment has been received, the listener will be notified of failure.
Each Event must be assigned a unique identifier. A Event may be resubmitted using the same
eventID in order to reset its maxDeliveryPeriod timer. While it is possible to reuse a eventID once the
previous Event to use that ID has been delivered (and after a reasonable grace period), multiple
Events sharing a eventID
must not be submitted at the same time.sink - The identifier of the sink where the Event should be sent. If the specified identifier includes
an attribute, only a sink whose identity includes a matching attribute will receive the event. If the
specified identifier does not include an attribute, any sink whose base ID matches the specified ID may receive the Event.
Must not be null.event - The event that has occurred. Must not be null.eventID - The unique identifier for this Event. eventID is an unsigned 32-bit integer
and must be non-negative and less than 2^32.DeliveryListener,
DOFObjectID.Attributepublic void submitTopologyUpdate(org.opendof.core.oal.DOFObjectID sink,
org.opendof.datatransfer.TopologyInformation topologyInformation,
long topologyUpdateID,
java.util.Date time)
DeliveryListener.topologyUpdateDelivered(Source, long, Throwable) will be notified. If the maximum
delivery period ends
before an acknowledgment has been received, the listener will be notified of failure.
Topology information is also included in ValueSets. Therefore, topology updates need only be made by devices
which do not already send data.
Each topology update must be assigned a unique identifier. A topology update may be resubmitted using the same
topologyUpdateID in order to reset its maxDeliveryPeriod timer. While it is possible to reuse a topologyUpdateID
once the previous topology update to use that ID has been delivered (and after a reasonable grace period),
multiple topology updates sharing a topologyUpdateID must not be submitted at the same time.sink - The identifier of the sink where the topology update should be sent. If the specified identifier
includes
an attribute, only a sink whose identity includes a matching attribute will receive the update. If the
specified
identifier does not include an attribute, any sink whose base ID matches the specified ID may receive the
update.
Must not be null.topologyInformation - The topology information. Must not be null.topologyUpdateID - The unique identifier for this topology update. topologyUpdateID is an unsigned 32-bit
integer
and must be non-negative and less than 2^32.time - The time at which the topology information is valid.DeliveryListener,
DOFObjectID.Attributepublic void completeRequest(org.opendof.core.oal.DOFObjectID sink,
long requestID,
org.opendof.datatransfer.DetailRequestStatus status)
throws org.opendof.datatransfer.SinkNotFoundException,
java.lang.Exception
sink - The identifier of the sink to be notified that the request is complete. If the specified identifier
includes an attribute, only a sink whose identity includes a matching attribute will receive notification. If the
specified identifier does not include an attribute, any sink whose base ID matches the specified ID may receive the notification.
Must not be null.requestID - The id of the request.status - The completion status of the request.org.opendof.datatransfer.SinkNotFoundException - Thrown if the source is not connected to the specified sink.java.lang.Exception - thrown if an error occurs while attempting to notify the sink.public void cancelValueSet(long valueSetID)
submitValueSet(DOFObjectID, ValueSet, long).valueSetID - The identifier of the ValueSet.public void cancelEvent(long eventID)
submitEvent(DOFObjectID, Event, long).eventID - The identifier of the event.public void cancelTopologyUpdate(long topologyUpdateID)
submitTopologyUpdate(DOFObjectID, TopologyInformation, long, Date)
.topologyUpdateID - The identifier of the update.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 long getMaxDeliveryPeriod()
public int getRetryTime()
public int getThreadpoolSize()
public int getOperationTimeout()
Source.Config.Builder.setOperationTimeout(int)public java.lang.String toString()
toString in class java.lang.Object