opensplice dds tutorial -- part ii
DESCRIPTION
The Data Distribution Service (DDS) is a standard for efficient and ubiquitous data sharing built upon the concept of a, strongly typed, distributed data space. The ability to scale from resource constrained embedded systems to ultra-large scale distributed systems, has made DDS the technology of choice for applications, such as, Power Generation, Large Scale SCADA, Air Traffic Control and Management, Smart Cities, Smart Grids, Vehicles, Medical Devices, Simulation, Aerospace, Defense and Financial Trading. This two part webcast provides an in depth introduction to DDS – the universal data sharing technology. Specifically, we will introduce (1) the DDS conceptual model and data-centric design, (2) DDS data modeling fundamentals, (3) the complete set of C++ and Java API, (4) the most important programming, data modeling and QoS Idioms, and (5) the integration between DDS and web applications. After attending this webcast you will understand how to exploit DDS architectural features when designing your next system, how to write idiomatic DDS applications in C++ and Java and what are the fundamental patterns that you should adopt in your applications.TRANSCRIPT
![Page 1: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/1.jpg)
OpenSplice | DDS Tutorial-- Part II --
Angelo CORSARO, Ph.D. Chief Technology Officer OMG DDS Sig Co-Chair
PrismTech [email protected]
![Page 2: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/2.jpg)
Part I Recap
![Page 3: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/3.jpg)
DDS is a standard technology for ubiquitous, interoperable, secure, platform independent, and real-time data sharing
across network connected devices
![Page 4: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/4.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
Data Distribution Service (DDS)
• DDS provides a Global Data Space abstraction that allow applications to autonomously, anonymously, securely and efficiently share data
• DDS’ Global Data Space is fully distributed, highly efficient and scalable
DDS Global Data Space
...
Data Writer
Data Writer
Data Writer
Data Reader
Data Reader
Data Reader
Data Reader
Data Writer
TopicAQoS
TopicBQoS
TopicCQoS
TopicDQoS
![Page 5: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/5.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
DDS Entities
• DomainParticipant: Provides access to a data cloud -- called a domain in DDS
• Topic: Domain-wide definition of a kind of Information
• Publisher/Subscriber: Provide scope to data sharing through the concept of partitions
• DataReader/DataWriter: Allow to read/write data for a given topic in the partitions their Subscriber/Publisher are associated with.
Domain (e.g. Domain 123)
Domain Participant
Topic
Publisher
DataWrter
Subscriber
DataReader
Partition (e.g. “Telemetry”, “Shapes”, )
Topic Instances/Samples
TaTb
Tc
Tx
Ty
T1
T1 T3
![Page 6: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/6.jpg)
Part II
![Page 7: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/7.jpg)
Quality of Service
![Page 8: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/8.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
QoS Model• QoS-Policies control local and end-
to-end properties of DDS entities
• Local properties controlled by QoS are related resource usage
• End-to-end properties controlled by QoS are related to temporal and spatial aspects of data distribution
• Some QoS-Policies are matched based on a Request vs. Offered (RxO) Model
Publisher
DataWriter
Topic
Type
QoS
Name
writes
QoS
DataWriter
Topic
Typewrites
Subscriber
DataReaderreads
DataReaderreads
...
QoS
Name
QoS
QoS QoS
QoS matching
......
QoS QoS
Type Matching
DomainParticipant DomainParticipant
QoS QoS
![Page 9: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/9.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
QoS Policies
QoS Policy Applicability RxO Modifiable
USER_DATA DP, DR, DW N Y
ConfigurationTOPIC_DATA T N Y
GROUP_DATA P, S N Y
DURABILITY T, DR, DW Y N
Data AvailabilityDURABILITY
SERVICET, DW N N
HISTORY T, DR, DW N N
PRESENTATION P, S Y N
Data Delivery
RELIABILITY T, DR, DW Y N
PARTITION P, S N Y
DESTINATION ORDER
T, DR, DW Y N
LIFESPAN T, DW N Y
[T: Topic] [DR: DataReader] [DW: DataWriter] [P: Publisher] [S: Subscriber] [DP: Domain Participant]
![Page 10: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/10.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
QoS Policies
QoS Policy Applicability RxO Modifiable
DEADLINE T, DR, DW Y Y
Temporal/Importance
Characteristics
LATENCY BUDGET T, DR, DW Y Y
TRANSPORT PRIORITY
T, DW N Y
TIME BASED FILTER DR N Y
OWNERSHIP T, DR, DW Y N
ReplicationOWNERSHIP STRENGTH
DW N Y
LIVELINESS T, DR, DW Y N Fault-Detection
[T: Topic] [DR: DataReader] [DW: DataWriter] [P: Publisher] [S: Subscriber] [DP: Domain Participant]
![Page 11: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/11.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
QoS DSL
• The ISO C++ and Java 5 APIs provide DSL for dealing with QoS Policies configuration
• The DSL uses language specific idioms, such as fluid interfaces, as well as specific features of the languages
• Policies as well as Entity QoS are immutable — this allows for better safety and object sharing
• Policies are treated as algebraic data types and the DSL provide constructors of each of the cases
• A QoS Provider can now be used to retrieve QoS settings from external sources, e.g. a file, an HTTP server, DDS durability
![Page 12: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/12.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
C++ QoS Policy DSL
!
!
// == ISO C++ DDS API == !DataWriterQos dwqos = pub.default_datawriter_qos() << History.KeepLast(10) << Durability.Transient(); !
![Page 13: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/13.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
Java 5 QoS Policy DSL
!
!
// == Java 5 DDS API == !final PolicyFactory pf = ... !DataWriterQos dwqos = pub.getDefaultDataWriterQos() .withPolicies ( pf.History.withKeepLast(10), pf.Durability.withTransient(), ); !
![Page 14: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/14.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
Data Delivery
Data Delivery
Reliability
Presentation
Destination OrderPartition
![Page 15: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/15.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
Reliability QoS Policy
The Reliability Policy controls the level of guarantee offered by the DDS in delivering data to subscribers
• Reliable. In steady-state, and with no data writer crashes, guarantees that all samples in the DataWriter history will eventually be delivered to all the DataReader
• Best Effort. Indicates that it is acceptable not to retry propagation of samples
QoS Policy Applicability RxO Modifiable
RELIABILITY T, DR, DW Y N
![Page 16: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/16.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
Setting Reliability Policy
!
!
// == ISO C++ DDS API == !// Reliable Reliability DataWriterQos dwqos = pub.default_datawriter_qos() << Reliability.Reliable(); !// Best-‐Effort Reliability DataWriterQos dwqos = pub.default_datawriter_qos() << Reliability.BestEffort();
![Page 17: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/17.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
Setting Reliability Policy
!
!
// == Java 5 DDS API == !final PolicyFactory pf = ... !// Reliable Reliability DataWriterQos dwqos = pub.getDefaultDataWriterQos() .withPolicies(pf.Reliability.withReliable()); !// Best-‐Effort Reliability DataWriterQos dwqos = pub.getDefaultDataWriterQos() .withPolicies(pf.Reliability.withBestEffort());
![Page 18: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/18.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
Partitions
• Partitions are the mechanism provided by DDS to organise information within a domain
• Access to partitions is controlled through QoS Policies
• Partitions are defined as strings:
• “system:telemetry”
• “system:log”
• “data:row-‐2:col-‐3”
• Partitions addressed by name or regular expressions:
• ”system:telemetry”
• “data:row-‐2:col-‐*”
Partitions
![Page 19: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/19.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
Partition QoS Policy
• The Partition QoS Policy can be used as subjects for organising the flows of data
• The Partition QoS Policy is used to connect Publishers/Subscribers to a Partitions’ List which might also contain wildcards, e.g. tracks.*
• Topics instances are published and subscribed across one or more Partitions
Partitions
![Page 20: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/20.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
Setting Partition QoS Policy
!
!
// == ISO C++ DDS API == !// Setting a Partition PublisherQos pqos = dp.default_publisher_qos() << Partition(“MyPartition”); !// Setting a List of Partitions PublisherQos pqos = dp.default_publisher_qos() << Partition(myPartitionList);
![Page 21: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/21.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
Setting Partition QoS Policy
!
!
// == Java 5 DDS API == !final PolicyFactory pf = ... !// Setting a Partition PublisherQos pqos = dp.getDefaultPublisherQos() .withPolicies(pf.Partition(“MyPartition”)); !// Setting a List of Partitions PublisherQos pqos = dp.getDefaultPublisherQos() .withPolicies(pf.Partition(myPartitionList));
![Page 22: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/22.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
Data Availability
Data Availability
History
Ownership
DurabilityLifespan
OwnershipStrength
![Page 23: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/23.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
History QoS PolicyThe DataWriter HISTORY QoS Policy controls the amount of data that can be made available to late joining DataReaders under TRANSIENT_LOCAL Durability
The DataReader HISTORY QoS Policy controls how many samples will be kept on the reader cache
• Keep Last. DDS will keep the most recent “depth” samples of each instance of data identified by its key
• Keep All. The DDS keep all the samples of each instance of data identified by its key -- up to reaching some configurable resource limits
QoS Policy Applicability RxO ModifiableHISTORY T, DR, DW N N
0 1 2 3
0
1
2
3
4
Pressure time
Pressure time
Pressure time
KeepLast(3)
KeepLast(1)
KeepAll
![Page 24: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/24.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
Durability QoS PolicyThe DURABILITY QoS controls the data availability w.r.t. late joiners, specifically the DDS provides the following variants:
• Volatile. No need to keep data instances for late joining data readers
• Transient Local. Data instance availability for late joining data reader is tied to the data writer availability
• Transient. Data instance availability outlives the data writer
• Persistent. Data instance availability outlives system restarts
QoS Policy Applicability RxO ModifiableDURABILITY T, DR, DW Y N
![Page 25: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/25.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
Data Writer
Data Reader
TopicAQoS
Volatile Durability
• No Time Decoupling
• Readers get only data produced after they joined the Global Data Space
1
![Page 26: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/26.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
!
!
Volatile Durability
• No Time Decoupling
• Readers get only data produced after they joined the Global Data Space
Data Writer
Data Reader
TopicAQoS
Data Reader
1
Late Joiner
![Page 27: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/27.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
!
!
Volatile Durability
• No Time Decoupling
• Readers get only data produced after they joined the Global Data Space
Data Writer
Data Reader
TopicAQoS
Data Reader
1
Late Joiner
22
![Page 28: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/28.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
Data Writer
Data Reader
TopicAQoS
Transient Local Durability
• Some Time Decoupling
• Data availability is tied to the availability of the data writer and the history settings
11
![Page 29: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/29.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
!
!
Transient Local Durability
• Some Time Decoupling
• Data availability is tied to the availability of the data writer and the history settings
Data Writer
Data Reader
TopicAQoS
Data Reader
1
Late Joiner
11
![Page 30: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/30.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
Data Writer
Data Reader
TopicAQoS
Data Reader
2
Transient-Local Durability
• Some Time Decoupling
• Data availability is tied to the availability of the data writer and the history settings
1
2
1
12
![Page 31: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/31.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
Data Writer
Data Reader
TopicAQoS
Transient Durability
• Time Decoupling
• Data availability is tied to the availability of the durability service
1
1
![Page 32: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/32.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
!
!
Data Writer
Data Reader
TopicAQoS
Data Reader
1
Transient Durability
• Time Decoupling
• Data availability is tied to the availability of the durability service
1
Late Joiner
1
![Page 33: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/33.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
Data Writer
Data Reader
TopicAQoS
Data Reader
2
Transient Durability
• Time Decoupling
• Data availability is tied to the availability of the durability service
1
2
1
1
2
![Page 34: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/34.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
Data Reader
TopicAQoS
Data Reader
Transient Durability
• Time Decoupling
• Data availability is tied to the availability of the durability service
1
1
2
2
12
![Page 35: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/35.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
!
!
Transient Durability
• Time Decoupling
• Data availability is tied to the availability of the durability service
1
Late Joiner
1
Data Reader
TopicAQoS
Data Reader
Data Reader
2
2
12 12
![Page 36: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/36.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
Setting the Durability Policy
!
!
// == Java 5 DDS API == !final PolicyFactory pf = ... !// Setting TransientLocalDurability PublisherQos pqos = dp.getDefaultPublisherQos() .withPolicies(pf.Durability().withTransientLocal()); !
![Page 37: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/37.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
Ownership QoS Policy
Availability of data producers can be controlled via two QoS Policies
• OWNERSHIP (SHARED vs. EXCLUSIVE)
• OWNERSHIP STRENGTH
• Instances of exclusively owned Topics can be modified (are owned) by the higher strength writer
• Writer strength is used to coordinate replicated writersQoS Policy Applicability RxO Modifiable
OWNERSHIP T, DR, DW Y NSTRENGTH DW N Y
![Page 38: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/38.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
Temporal Properties
Throughput
TimeBasedFilter
[Inbound]
[Outbound]Latency
Deadline
TransportPriority
LatencyBudget
![Page 39: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/39.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
Latency Budget
• The LATENCY_BUDGET QoS policy specifies the maximum acceptable delay from the time the data is written until the data is inserted in the receiver's application-cache
• A non-zero latency-budget allows a DDS implementation to batch samples and improve CPU/Network utilisation
QoS Policy Applicability RxO ModifiableLATENCY BUDGET
T, DR, DW Y Y
DataWriter DataReaderT1
T2
T3
Latency = T1+T2+T3
Batching
![Page 40: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/40.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
Deadline QoS Policy
The DEADLINE QoS policy defines the maximum inter-arrival time between data samples
• DataWriter indicates that the application commits to write a new sample at least once every deadline period
• DataReaders are notified when the DEADLINE is violated
DataWriter DataReaderDeadlineDeadlineDeadlineDeadlineDeadline
Deadline Violation
QoS Policy Applicability RxO ModifiableDEADLINE T, DR, DW Y Y
![Page 41: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/41.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
Transport Priority QoS Policy
• The TRANSPORT_PRIORITY QoS policy is a hint to the infrastructure as to how to set the priority of the underlying transport used to send the data.
QoS Policy Applicability RxO ModifiableTRANSPORT
PRIORITYT, DW N Y
![Page 42: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/42.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
Time-Based Filter QoS Policy
• The Time Based Filter allows to control the throughput at which data is received by a data reader
• Samples produced more often than the minimum inter-arrival time are not delivered to the data reader
QoS Policy Applicability RxO ModifiableTIME BASED FILTER DR N Y
DataWriter DataReader
mit
T2
T3
Latency = T1+T2+T3
discarded sample
mit
mit
mit
mit = minimum inter-arrival time
produced sample delivered sample
![Page 43: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/43.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
!
!
QoS Provider
• The new C++ and Java APIs introduce the concept of a QoS Provider
• This class allows to externally define policies and decouples the mechanism used to define and access policy definition with policy creation
// QosProvider... QosProvider qos_provider( "http://www.opensplice.org/demo/config/qos.xml", "ishapes-‐profile"); ! DataReader<ShapeType> dr(sub, topic, qos_provider.datareader_qos());
![Page 44: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/44.jpg)
Demo: QoS in Action
![Page 45: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/45.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
Shapes Application
• The iShapes application is used by DDS vendors to demonstrate some of the basic mechanism as well as product interoperability
• Three Topics
• Circle, Square, Triangle
• One Type
struct ShapeType { string color; long x; long y; long shapesize; }; #pragma keylist ShapeType color
Spotted shapes represent subscriptions
Pierced shapes represent publications
![Page 46: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/46.jpg)
QoS Idioms
![Page 47: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/47.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
Soft State
• In distributed systems you often need to model soft-state -- a state that is periodically updated
• Examples are the reading of a sensor (e.g. Temperature Sensor), the position of a vehicle, etc.
• The QoS combination to model Soft-State is the following:
Reliability => BestEffort Durability => Volatile History => KeepLast(n) [with n = 1 in most of the cases] Deadline => updatePeriod LatencyBudget => updatePeriod/3 [rule of thumb] DestinationOrder => SourceTimestamp [if multiple writers per instance]
![Page 48: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/48.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
Hard State
• In distributed systems you often need to model hard-state -- a state that is sporadically updated and that often has temporal persistence requirements
• Examples are system configuration, a price estimate, etc.
• The QoS combination to model Hard-State is the following:
Reliability => Reliable Durability => Transient | Persistent History => KeepLast(n) [with n = 1 in most of the cases] DestinationOrder => SourceTimestamp [if multiple writers per instance]
![Page 49: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/49.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
Events
• In distributed systems you often need to model events -- the occurrence of something noteworthy for our system
• Examples are a collision alert, the temperature beyond a given threshold, etc.
• The QoS combination to model Events is the following:
Reliability => Reliable Durability => any [depends on system requirements] History => KeepAll [on both DataWriter and DataReader!] DestinationOrder => SourceTimestamp
![Page 50: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/50.jpg)
Accessing the Reader Cache
![Page 51: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/51.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
Reading Samples
• Samples can be read from the Data Reader History Cache
• The action of reading a sample is non-destructive. Samples are not removed from the cache
DataReader Cache
DataReader
...
DataReader Cache
DataReader
... read
![Page 52: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/52.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
Taking Samples
• Samples can be taken from the Data Reader History Cache
• The action of taking a sample is destructive. Samples are removed from the cache
DataReader Cache
DataReader
...
DataReader Cache
DataReader
... take
![Page 53: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/53.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
Sample Selectors
• DDS provides some very flexible mechanisms for selecting the samples to be read/take:
• Content
• Status
• These mechanisms are composable
![Page 54: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/54.jpg)
Content-Based Selection
![Page 55: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/55.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
Filters and Queries• DDS Filters allow to control what gets
into a DataReader cache
• DDS Queries allow to control what gets out of a DataReader cache
• Filters are defined by means of ContentFilteredTopics
• Queries operate in conjunction with read operations
• Filters and Queries are expressed as SQL where clauses
DataReader Cache
DataReader
...... ... ...
Filter
Query
Application
![Page 56: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/56.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
!
!
Filters
// == ISO C++ DDS API !// Create a Topic auto topic = Topic<ShapeType>(dp, “Circle”); !// Define filter expression and parameters auto filter = Filter(“x < 100 AND y < 200”); !// Define content filtered topic auto cftopic = ContentFilteredTopic<ShapeType>(“CFCircle”, topic, filter) !// Create a DataReader for the content-filtered Topic auto dr = DataReader<ShapeType>(sub,cftopic)
struct ShapeType { string color; long x; long y; long shapesize; }; #pragma keylist ShapeType color
![Page 57: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/57.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
!
!
Filters
// == Java 5DDS API == !final PolicyFactory pf = runtime.policyFactory(); final DataReaderQos drqos = sub.getDefaultDataReaderQos() .withPolicy ( pf.ContentFilter() .withFilter( new JavaScriptFilter<ShapeType>("data.x > data.y")) ); !final DataReader<ShapeType> dr = sub.createDataReader(shape, drqos);
struct ShapeType { string color; long x; long y; long shapesize; }; #pragma keylist ShapeType color
![Page 58: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/58.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
!
!
Query
// == ISO C++ DDS API == !// Define filter expression and parameters auto dr = DataReader<ShapeType>(sub, topic) val query = Query(dr, “x < 100 AND y < 200”); !dr.select() .content(query) .read();
struct ShapeType { string color; long x; long y; long shapesize; }; #pragma keylist ShapeType color
![Page 59: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/59.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
!
!
Query
// == Java 5 DDS API == !Filter<ShapeType> filter = new JavaScriptFilter<ShapeType>("data.x > data.y")) !!dr.select() .content(filter) .read();
struct ShapeType { string color; long x; long y; long shapesize; }; #pragma keylist ShapeType color
![Page 60: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/60.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.!
!
Instances
• DDS provides a very efficient way of reading data belonging to a specific Topic Instance
• Obviously, one could use queries to match the key’s value, but this is not as efficient as the special purpose instance selector
// == ISO C++ DDS API == !auto handle = dr.lookup_instance(ShapeType(“RED”, 0, 0, 0)); !auto data = dr.select() .instance(handle) .read();
![Page 61: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/61.jpg)
State Based Selection
![Page 62: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/62.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
Sample, Instance, and View State
• The samples included in the DataReader cache have associated some meta-information which, among other things, describes the status of the sample and its associated stream/instance
• The Sample State (READ, NOT_READ) allows to distinguish between new samples and samples that have already been read
• The View State (NEW, NOT_NEW) allows to distinguish a new instance from an existing one
• The Instance State (ALIVE, NOT_ALIVE_DISPOSED, NOT_ALIVE_NO_WRITERS) allows to track the life-cycle transitions of the instance to which a sample belongs
![Page 63: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/63.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
!
!
State Selector in Action
// == ISO C++ DDS API == !// Read only new samples auto data = dr.read() !// Read any samples from live instances auto data = dr.select() .state(DataState::any_data()) .read();
![Page 64: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/64.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
!
!
State Selector in Action
// == Java 5 DDS API == !// Read only new samples auto data = dr.read() !// Read any samples from live instances auto data = dr.select() .dataState(sub.createDataState().withAnySampleState()) .read();
![Page 65: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/65.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
!
!
// == ISO C++ DDS API == !auto data = dr.select() .content(query) .state(data_state) .instance(handle) .read();
Putting all Together
• Selectors can be composed in a flexible and expressive manner
![Page 66: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/66.jpg)
Application / DDS Interaction Models
![Page 67: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/67.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
Interaction ModelsPolling
• The application proactively polls for data availability as well as special events, such as a deadline being missed, etc. Notice that all DDS API calls, exclusion made for wait operations, are non-blocking
Synchronous Notification
• The application synchronously waits for some conditions to be verified, e.g., data availability, instance lifecycle change, etc.
Asynchronous Notification
• The application registers the interest to be asynchronously notified when specific condition are satisfied, e.g. data available, a publication matched, etc.
![Page 68: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/68.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
Synchronous Notifications
• DDS provides a mechanism known as WaitSet to synchronously wait for a condition
• Condition can predicate on:
• communication statuses
• data availability
• data availability with specific content
• user-triggered conditions
![Page 69: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/69.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
WaitSet// == Java 5 DDS API == !// Create the waitset WaitSet ws = runtime.createWaitSet(); !Subscriber.DataState ds = sub.createDataState(); !// Create the condition Condition c = dr.createReadCondition( ds.withAnyViewState() .with(InstanceState.ALIVE) .with(SampleState.NOT_READ)); !// Attach the condition ws.attachCondition(c); !// Wait for the condition ws.wait();
!
!
![Page 70: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/70.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
Asynchronous Notifications
• DDS provides a mechanism known as Listeners for asynchronous notification of a given condition
• Listener interest can predicate on:
• communication statuses
• data availability
![Page 71: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/71.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
!
!
Listener Declaration// == ISO C++ DDS API == !class ShapeListener : public dds::sub::NoOpDataReaderListener<ShapeType> { public: ShapeListener() {} ! virtual void on_data_available(dds::sub::DataReader<ShapeType>& dr) { auto samples = dr.read(); std::for_each(samples.begin(), samples.end(), [](const dds::sub::Sample<ShapeType>& sample) { if (sample.info().valid()) // Check if sample contains valid data std::cout << sample.data() << std::endl; }); } ! virtual void on_liveliness_changed(dds::sub::DataReader<ShapeType>& the_reader, const dds::core::status::LivelinessChangedStatus& status) { std::cout << ">> Liveliness Changed! " << std::endl; } };
![Page 72: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/72.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
Listener Registration
!
!
// == ISO C++ DDS API == !auto l = new ShapeListener(); !// Create a “nothing” status mask StatusMask mask = StatusMask::none(); !// Add the statuses we are interested in. mask << StatusMask::data_available() << StatusMask::liveliness_changed() << StatusMask::liveliness_lost(); !// Register the listener with the associated mask dr.listener(l, mask);
![Page 73: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/73.jpg)
Common Bootstrap Questions
![Page 74: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/74.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
Can I use C++11?
• OpenSplice default configuration does not require C++11
• If you want to use C++11 in your DDS applications then you need to enable support for it. Check:
• http://dev.opensplice.org/releases/downloads/docs/isocpp/html/isocpp_customlibs.html
![Page 75: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/75.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
Which DDS Implementation
• If you are planning to use C/C++ or C# you may consider OpenSplice DDS
• If you are developing Java Applications or are interested in targeting Android then you may consider OpenSplice Mobile
![Page 76: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/76.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
Where can I find the Java 5 API?
• The Java 5 API is currently implemented only as part of OpenSplice Mobile
• OpenSplice Mobile is a pure Java implementation of DDS
![Page 77: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/77.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
Can I “Script” DDS Applications?Assuming you deploy on the JVM then you have two options
• Use the DDS API from JavaScript (or any other script language supported by the JVM) and execute the script through the javax.script.ScriptEngine
• Use the DDS Java 5 API through Scala, and then run your scala program as a script
• The Molière Scala API for DDS and run the resulting program as a script
![Page 78: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/78.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
How can I Debug my DDS App?
OpenSplice DDS
• Use the Tuner to inspect entities and QoS
!
OpenSplice Mobile
• Use OpenSplice Monitor to inspect entities and QoS
![Page 79: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/79.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
OpenSplice Monitor
![Page 80: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/80.jpg)
Part II Summary & Concluding Remarks
![Page 81: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/81.jpg)
Copyrig
ht 2013, PrismTech – A
ll Rights Reserved.
Summary & Remarks
• DDS provides an elegant Data Space abstraction that allows application to share data ubiquitously and efficiently -- the Data Space implementation is fully distributed
• DDS a rich set of QoS to control the key non-functional properties of data
• DDS provides idiomatic API which are highly expressive and simple to use
![Page 82: OpenSplice DDS Tutorial -- Part II](https://reader036.vdocuments.us/reader036/viewer/2022081716/54b6e6ed4a7959b35f8b4673/html5/thumbnails/82.jpg)
¥@prismtech
¥@acorsaro
¥youtube.com/opensplicetube ¥slideshare.net/angelo.corsaro
¥ [email protected] ¥[email protected]
¥opensplice.com ¥forums.opensplice.org
¥opensplice.org ¥[email protected]
:: Connect with Us ::