OpenSplice Java 5 DCPS  v6.x
OpenSplice Java 5 OpenSplice Data Distribution Service Data-Centric Publish-Subscribe API
All Classes Namespaces Files Functions Variables Pages
org.omg.dds.sub.Sample< TYPE > Interface Template Reference

A Sample represents an atom of data information (i.e., one value for one instance) as returned by a org.omg.dds.sub.DataReader's read or take operations. More...

Inheritance diagram for org.omg.dds.sub.Sample< TYPE >:
Inheritance graph
Collaboration diagram for org.omg.dds.sub.Sample< TYPE >:
Collaboration graph

Classes

interface  Iterator
 

Public Member Functions

Sample< TYPE > clone ()
 
int getAbsoluteGenerationRank ()
 The sampleRank and generationRank available in the Sample are computed based solely on the actual samples in the ordered collection returned by org.omg.dds.sub.DataReader#read() or org.omg.dds.sub.DataReader#take(). More...
 
TYPE getData ()
 Get the data associated with this Sample, if any. More...
 
int getDisposedGenerationCount ()
 For each instance the middleware internally maintains two counts: the disposedGenerationCount and noWritersGenerationCount, relative to each org.omg.dds.sub.DataReader: More...
 
ServiceEnvironment getEnvironment ()
 
int getGenerationRank ()
 The sampleRank and generationRank available in the Sample are computed based solely on the actual samples in the ordered collection returned by org.omg.dds.sub.DataReader#read() or org.omg.dds.sub.DataReader#take(). More...
 
InstanceHandle getInstanceHandle ()
 Gets the InstanceHandle of the associated data Sample. More...
 
InstanceState getInstanceState ()
 For each instance the middleware internally maintains an instanceState. More...
 
int getNoWritersGenerationCount ()
 For each instance the middleware internally maintains two counts: the disposedGenerationCount and noWritersGenerationCount, relative to each org.omg.dds.sub.DataReader: More...
 
InstanceHandle getPublicationHandle ()
 Gets the InstanceHandle of the associated publication. More...
 
int getSampleRank ()
 The sampleRank and generationRank available in the Sample are computed based solely on the actual samples in the ordered collection returned by org.omg.dds.sub.DataReader#read() or org.omg.dds.sub.DataReader#take(). More...
 
SampleState getSampleState ()
 For each sample received, the middleware internally maintains a sampleState relative to each org.omg.dds.sub.DataReader. More...
 
Time getSourceTimestamp ()
 Gets the timestamp of the sample. More...
 
ViewState getViewState ()
 For each instance (identified by the key), the middleware internally maintains a viewState relative to each org.omg.dds.sub.DataReader More...
 

Detailed Description

A Sample represents an atom of data information (i.e., one value for one instance) as returned by a org.omg.dds.sub.DataReader's read or take operations.

It consists of two parts: the Data (getData()) and the "Sample Info" (the remainder of the methods defined by this interface).

Interpretation of the Sample Info

In addition to the data value itself, the Sample contains information pertaining to it:

Interpretation of the Counters and Ranks

A Sample provides several counters and ranks: the disposedGenerationCount ( getDisposedGenerationCount()), noWritersGenerationCount ( getNoWritersGenerationCount()), sampleRank (getSampleRank() ), generationRank (getGenerationRank()), and absoluteGenerationRank (getAbsoluteGenerationRank()). These counters and ranks allow the application to distinguish samples belonging to different 'generations' of the instance. Note that it is possible for an instance to transition from not-alive to alive (and back) several times before the application accesses the data by means of org.omg.dds.sub.DataReader#read() or org.omg.dds.sub.DataReader#take(). In this case the returned collection may contain samples that cross generations (i.e., some samples were received before the instance became not-alive, others after the instance reappeared again). Using the information in the Sample the application can anticipate what other information regarding the same instance appears in the returned collection as well as in the infrastructure and thus make appropriate decisions. For example, an application desiring to only consider the most current sample for each instance would only look at samples with sampleRank == 0. Similarly an application desiring to only consider samples that correspond to the latest generation in the collection will only look at samples with generationRank == 0. An application desiring only samples pertaining to the latest generation available will ignore samples for which absoluteGenerationRank != 0. Other application-defined criteria may also be used.

Parameters
<TYPE>The concrete type of the data encapsulated by this Sample.

Definition at line 116 of file Sample.java.

Member Function Documentation

◆ clone()

◆ getAbsoluteGenerationRank()

int org.omg.dds.sub.Sample< TYPE >.getAbsoluteGenerationRank ( )

The sampleRank and generationRank available in the Sample are computed based solely on the actual samples in the ordered collection returned by org.omg.dds.sub.DataReader#read() or org.omg.dds.sub.DataReader#take().

  • The sampleRank indicates the number of samples of the same instance that follow the current one in the collection.
  • The generationRank available in the Sample indicates the difference in 'generations' between the sample (S) and the Most Recent Sample of the same instance that appears In the returned Collection (MRSIC). That is, it counts the number of times the instance transitioned from not-alive to alive in the time from the reception of S to the reception of MRSIC.

The absoluteGenerationRank available in the Sample indicates the difference in 'generations' between the sample (S) and the Most Recent Sample of the same instance that the middleware has received (MRS). That is, it counts the number of times the instance transitioned from not-alive to alive in the time from the reception of S to the time when org.omg.dds.sub.DataReader#read() or org.omg.dds.sub.DataReader#take() was called.

absoluteGenerationRank = (MRS.disposedGenerationCount

Implemented in org.opensplice.dds.sub.SampleImpl< TYPE >.

◆ getData()

TYPE org.omg.dds.sub.Sample< TYPE >.getData ( )

Get the data associated with this Sample, if any.

Normally each Sample contains both meta-data ("Sample Info") and some data. However there are situations where a Sample contains only the Sample Info and does not have any associated data. This occurs when the Service notifies the application of a change of state for an instance that was caused by some internal mechanism (such as a timeout) for which there is no associated data. An example of this situation is when the Service detects that an instance has no writers and changes the corresponding instanceState to org.omg.dds.sub.InstanceState#NOT_ALIVE_NO_WRITERS.

The actual set of scenarios under which the middleware returns Samples containing no data is implementation dependent. The application can distinguish whether a particular Sample has data by examining the value returned by this method. If the result is not null, then the Sample contains valid data. If it is null, the Sample contains no data.

To ensure correctness and portability, the application must check for a null result from this method prior to using it. If the data is null, the application should access only the Sample Info.

Returns
the data associated with this sample. This method will return null if this sample contains no valid data.

Implemented in org.opensplice.dds.sub.SampleImpl< TYPE >.

◆ getDisposedGenerationCount()

int org.omg.dds.sub.Sample< TYPE >.getDisposedGenerationCount ( )

For each instance the middleware internally maintains two counts: the disposedGenerationCount and noWritersGenerationCount, relative to each org.omg.dds.sub.DataReader:

  • The disposedGenerationCount and noWritersGenerationCount are initialized to zero when the DataReader first detects the presence of a never-seen-before instance.
  • The disposedGenerationCount is incremented each time the instanceState of the corresponding instance changes from NOT_ALIVE_DISPOSED to ALIVE.
  • The noWritersGenerationCount is incremented each time the instanceState of the corresponding instance changes from NOT_ALIVE_NO_WRITERS to ALIVE.

The disposedGenerationCount and noWritersGenerationCount available in the Sample capture a snapshot of the corresponding counters at the time the sample was received.

Returns
the disposed generation count
See also
getNoWritersGenerationCount()

Implemented in org.opensplice.dds.sub.SampleImpl< TYPE >.

◆ getEnvironment()

ServiceEnvironment org.omg.dds.core.DDSObject.getEnvironment ( )
inherited
Returns
the org.omg.dds.core.ServiceEnvironment object that directly or indirectly was used to create this object.

Implemented in org.omg.dds.core.ServiceEnvironment, org.opensplice.dds.sub.ReflectionDataReader< TYPE, OUT_TYPE >, org.opensplice.dds.core.ModifiableTimeImpl, org.opensplice.dds.pub.ReflectionDataWriter< TYPE >, org.opensplice.dds.core.DurationImpl, org.opensplice.dds.topic.ContentFilteredTopicImpl< TYPE >, org.opensplice.dds.sub.ReadConditionImpl< TYPE >, org.opensplice.dds.core.EntityQosImpl< T extends QosPolicy >, org.opensplice.dds.type.TypeSupportImpl< TYPE >, org.opensplice.dds.topic.PublicationBuiltinTopicDataImpl, org.opensplice.dds.topic.SubscriptionBuiltinTopicDataImpl, org.opensplice.dds.topic.TopicBuiltinTopicDataImpl, org.opensplice.dds.domain.DomainParticipantFactoryImpl, org.opensplice.dds.core.QosProviderImpl, org.opensplice.dds.core.status.OfferedIncompatibleQosStatusImpl, org.opensplice.dds.core.status.RequestedIncompatibleQosStatusImpl, org.opensplice.dds.core.InstanceHandleImpl, org.opensplice.dds.core.StatusConditionImpl< T extends Entity<?, ?>, org.opensplice.dds.core.status.LivelinessChangedStatusImpl, org.opensplice.dds.core.status.PublicationMatchedStatusImpl, org.opensplice.dds.core.status.SubscriptionMatchedStatusImpl, org.opensplice.dds.sub.SampleImpl< TYPE >, org.opensplice.dds.core.policy.ShareImpl, org.opensplice.dds.core.status.OfferedDeadlineMissedStatusImpl, org.opensplice.dds.core.status.SampleRejectedStatusImpl, org.opensplice.dds.core.WaitSetImpl, org.opensplice.dds.topic.ParticipantBuiltinTopicDataImpl, org.opensplice.dds.core.status.RequestedDeadlineMissedStatusImpl, org.opensplice.dds.topic.BuiltinTopicKeyImpl, org.opensplice.dds.core.GuardConditionImpl, org.opensplice.dds.core.event.AllDataDisposedEventImpl< TYPE >, org.opensplice.dds.core.policy.QosPolicyCountImpl, org.opensplice.dds.core.status.InconsistentTopicStatusImpl, org.opensplice.dds.core.status.LivelinessLostStatusImpl, org.opensplice.dds.core.status.SampleLostStatusImpl, org.opensplice.dds.core.policy.QosPolicyImpl, org.opensplice.dds.core.status.AllDataDisposedStatusImpl, org.opensplice.dds.core.IllegalArgumentExceptionImpl, org.opensplice.dds.core.InconsistentPolicyExceptionImpl, org.opensplice.dds.core.policy.PolicyFactoryImpl, org.opensplice.dds.core.policy.TypeConsistencyEnforcementImpl, org.opensplice.dds.core.PreconditionNotMetExceptionImpl, org.opensplice.dds.core.AlreadyClosedExceptionImpl, org.opensplice.dds.core.IllegalOperationExceptionImpl, org.opensplice.dds.core.ImmutablePolicyExceptionImpl, org.opensplice.dds.core.NotEnabledExceptionImpl, org.opensplice.dds.core.OutOfResourcesExceptionImpl, org.opensplice.dds.core.DDSExceptionImpl, org.opensplice.dds.core.status.DataAvailableStatusImpl, and org.opensplice.dds.core.status.DataOnReadersStatusImpl.

◆ getGenerationRank()

int org.omg.dds.sub.Sample< TYPE >.getGenerationRank ( )

The sampleRank and generationRank available in the Sample are computed based solely on the actual samples in the ordered collection returned by org.omg.dds.sub.DataReader#read() or org.omg.dds.sub.DataReader#take().

  • The sampleRank indicates the number of samples of the same instance that follow the current one in the collection.
  • The generationRank available in the Sample indicates the difference in 'generations' between the sample (S) and the Most Recent Sample of the same instance that appears In the returned Collection (MRSIC). That is, it counts the number of times the instance transitioned from not-alive to alive in the time from the reception of S to the reception of MRSIC.

The generationRank is computed using the formula:

generationRank = (MRSIC.disposedGenerationCount

Implemented in org.opensplice.dds.sub.SampleImpl< TYPE >.

◆ getInstanceHandle()

InstanceHandle org.omg.dds.sub.Sample< TYPE >.getInstanceHandle ( )

Gets the InstanceHandle of the associated data Sample.

Returns
the InstanceHandle of the sample

Implemented in org.opensplice.dds.sub.SampleImpl< TYPE >.

◆ getInstanceState()

InstanceState org.omg.dds.sub.Sample< TYPE >.getInstanceState ( )

For each instance the middleware internally maintains an instanceState.

The instanceState can be org.omg.dds.sub.InstanceState#ALIVE, org.omg.dds.sub.InstanceState#NOT_ALIVE_DISPOSED, or org.omg.dds.sub.InstanceState#NOT_ALIVE_NO_WRITERS.

  • ALIVE indicates that (a) samples have been received for the instance, (b) there are live org.omg.dds.pub.DataWriter entities writing the instance, and (c) the instance has not been explicitly disposed (or else more samples have been received after it was disposed).
  • NOT_ALIVE_DISPOSED indicates the instance was explicitly disposed by a DataWriter by means of org.omg.dds.pub.DataWriter#dispose(InstanceHandle).
  • NOT_ALIVE_NO_WRITERS indicates the instance has been declared as not-alive by the org.omg.dds.sub.DataReader because it detected that there are no live DataWriter entities writing that instance.

The precise behavior events that cause the instanceState to change depends on the setting of the org.omg.dds.core.policy.Ownership:

The instanceState available in the Sample is a snapshot of the instanceState of the instance at the time the collection was obtained (i.e., at the time org.omg.dds.sub.DataReader#read() or org.omg.dds.sub.DataReader#take() was called). The instanceState is therefore the same for all samples in the returned collection that refer to the same instance.

Returns
the InstanceState

Implemented in org.opensplice.dds.sub.SampleImpl< TYPE >.

◆ getNoWritersGenerationCount()

int org.omg.dds.sub.Sample< TYPE >.getNoWritersGenerationCount ( )

For each instance the middleware internally maintains two counts: the disposedGenerationCount and noWritersGenerationCount, relative to each org.omg.dds.sub.DataReader:

  • The disposedGenerationCount and noWritersGenerationCount are initialized to zero when the DataReader first detects the presence of a never-seen-before instance.
  • The disposedGenerationCount is incremented each time the instanceState of the corresponding instance changes from NOT_ALIVE_DISPOSED to ALIVE.
  • The noWritersGenerationCount is incremented each time the instanceState of the corresponding instance changes from NOT_ALIVE_NO_WRITERS to ALIVE.

The disposedGenerationCount and noWritersGenerationCount available in the Sample capture a snapshot of the corresponding counters at the time the sample was received.

Returns
the no writers generation count
See also
getDisposedGenerationCount()

Implemented in org.opensplice.dds.sub.SampleImpl< TYPE >.

◆ getPublicationHandle()

InstanceHandle org.omg.dds.sub.Sample< TYPE >.getPublicationHandle ( )

Gets the InstanceHandle of the associated publication.

Returns
the PublicationHandle

Implemented in org.opensplice.dds.sub.SampleImpl< TYPE >.

◆ getSampleRank()

int org.omg.dds.sub.Sample< TYPE >.getSampleRank ( )

The sampleRank and generationRank available in the Sample are computed based solely on the actual samples in the ordered collection returned by org.omg.dds.sub.DataReader#read() or org.omg.dds.sub.DataReader#take().

  • The sampleRank indicates the number of samples of the same instance that follow the current one in the collection.
  • The generationRank available in the Sample indicates the difference in 'generations' between the sample (S) and the Most Recent Sample of the same instance that appears In the returned Collection (MRSIC). That is, it counts the number of times the instance transitioned from not-alive to alive in the time from the reception of S to the reception of MRSIC.
Returns
the sample rank
See also
getAbsoluteGenerationRank()
getGenerationRank()

Implemented in org.opensplice.dds.sub.SampleImpl< TYPE >.

◆ getSampleState()

SampleState org.omg.dds.sub.Sample< TYPE >.getSampleState ( )

For each sample received, the middleware internally maintains a sampleState relative to each org.omg.dds.sub.DataReader.

The sampleState can either be org.omg.dds.sub.SampleState#READ or org.omg.dds.sub.SampleState#NOT_READ.

The sampleState will, in general, be different for each sample in the collection returned by org.omg.dds.sub.DataReader#read() or org.omg.dds.sub.DataReader#take().

Returns
the SampleState

Implemented in org.opensplice.dds.sub.SampleImpl< TYPE >.

◆ getSourceTimestamp()

Time org.omg.dds.sub.Sample< TYPE >.getSourceTimestamp ( )

Gets the timestamp of the sample.

This is the timestamp provided by the DataWriter at the time the sample was produced.

Returns
the timestamp

Implemented in org.opensplice.dds.sub.SampleImpl< TYPE >.

◆ getViewState()

ViewState org.omg.dds.sub.Sample< TYPE >.getViewState ( )

For each instance (identified by the key), the middleware internally maintains a viewState relative to each org.omg.dds.sub.DataReader

The viewState can either be org.omg.dds.sub.ViewState#NEW or org.omg.dds.sub.ViewState#NOT_NEW.

  • NEW indicates that either this is the first time that the DataReader has ever accessed samples of that instance, or else that the DataReader has accessed previous samples of the instance, but the instance has since been reborn (i.e., become not-alive and then alive again). These two cases are distinguished by examining the disposedGenerationCount and the noWritersGenerationCount.
  • NOT_NEW indicates that the DataReader has already accessed samples of the same instance and that the instance has not been reborn since.

The viewState available in the Sample is a snapshot of the viewState of the instance relative to the DataReader used to access the samples at the time the collection was obtained (i.e., at the time org.omg.dds.sub.DataReader#read() or org.omg.dds.sub.DataReader#take() was called). The viewState is therefore the same for all samples in the returned collection that refer to the same instance.

Returns
the ViewState
See also
getDisposedGenerationCount()
getNoWritersGenerationCount()

Implemented in org.opensplice.dds.sub.SampleImpl< TYPE >.


The documentation for this interface was generated from the following file: