![]() |
OpenSplice Java 5 DCPS
v6.x
OpenSplice Java 5 OpenSplice Data Distribution Service Data-Centric Publish-Subscribe API
|
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...
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... | |
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.
<TYPE> | The concrete type of the data encapsulated by this Sample. |
Definition at line 116 of file Sample.java.
Sample<TYPE> org.omg.dds.sub.Sample< TYPE >.clone | ( | ) |
Implemented in org.opensplice.dds.sub.SampleImpl< TYPE >.
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 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
- MRS.noWritersGenerationCount)
- (S.disposedGenerationCount
- S.noWritersGenerationCount)
- Returns
- the absolute generation rank
- See also
- getGenerationRank()
-
getSampleRank()
Implemented in org.opensplice.dds.sub.SampleImpl< TYPE >.
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.
Implemented in org.opensplice.dds.sub.SampleImpl< TYPE >.
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 available in the Sample capture a snapshot of the corresponding counters at the time the sample was received.
Implemented in org.opensplice.dds.sub.SampleImpl< TYPE >.
|
inherited |
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.
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 generationRank is computed using the formula:
generationRank = (MRSIC.disposedGenerationCount
- MRSIC.noWritersGenerationCount)
- (S.disposedGenerationCount
- S.noWritersGenerationCount)
- Returns
- the generation rank
Implemented in org.opensplice.dds.sub.SampleImpl< TYPE >.
InstanceHandle org.omg.dds.sub.Sample< TYPE >.getInstanceHandle | ( | ) |
Gets the InstanceHandle of the associated data Sample.
Implemented in org.opensplice.dds.sub.SampleImpl< TYPE >.
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.
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.
Implemented in org.opensplice.dds.sub.SampleImpl< TYPE >.
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 available in the Sample capture a snapshot of the corresponding counters at the time the sample was received.
Implemented in org.opensplice.dds.sub.SampleImpl< TYPE >.
InstanceHandle org.omg.dds.sub.Sample< TYPE >.getPublicationHandle | ( | ) |
Gets the InstanceHandle of the associated publication.
Implemented in org.opensplice.dds.sub.SampleImpl< TYPE >.
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().
Implemented in org.opensplice.dds.sub.SampleImpl< TYPE >.
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().
Implemented in org.opensplice.dds.sub.SampleImpl< TYPE >.
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.
Implemented in org.opensplice.dds.sub.SampleImpl< TYPE >.
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.
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.
Implemented in org.opensplice.dds.sub.SampleImpl< TYPE >.