Top Banner
Angelo Corsaro, Ph.D. Chief Technology Officer PrismTech OMG DDS SIG Co-Chair [email protected] OpenSplice DDS OpenSplice DDS OpenSplice DDS OpenSplice DDS OpenSplice DDS Getting Started with DDS For C++ and Java Programmers 1
78

Getting Started in DDS with C++ and Java

Apr 30, 2015

Download

Technology

Angelo Corsaro

DDS is a very powerful technology built around a few simple and orthogonal concepts. If you understand the core concepts then you can really quickly get up to speed and start exploiting all of its power. On the other hand, if you haven’t grasped the key abstractions you might not be able to exploit all the benefits that DDS can bring.

This presentation provides you with an introduction to the core DDS concepts and illustrates how to program DDS applications. The new C++ and Java API will be explained and used throughout the webcast for coding examples thus giving you a chance to learn the new API from one of the main authors!
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Getting Started in DDS with C++ and Java

Angelo Corsaro, Ph.D.Chief Technology OfficerPrismTechOMG DDS SIG [email protected]

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

Getting Started with DDS For C++ and Java Programmers

1

Page 2: Getting Started in DDS with C++ and Java

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

./background-info

2

Page 3: Getting Started in DDS with C++ and Java

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

The OMG DDS

The OMG DDS Standard‣ Introduced in 2004 to address the Data

distribution challenges typical of Defense and Aerospace Mission Critical Applications

‣ Key requirements for the standard were high performance and scalability from embedded to ultra-large-scale deployments

‣ Today recommended by key administrations worldwide and widely adopted well beyond Aerospace and Defense in domains, such as, Automated Trading, Simulations, SCADA, Telemetry, etc.

3

Page 4: Getting Started in DDS with C++ and Java

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

DDS RecommendationsIncreasingly Mandated/Recommended by Administrations

‣ US Navy: Open Architecture

‣ DISR/DISA: Net-centric Systems

‣ EuroControl: Air Traffic Control Center Operational Interoperability

‣ QinetiQ & MILVA: Recommending DDS for Vehicles Electronic Architecture

A Great Time for DDS!

! The infrastructure evolution cycle is churning…– New -> Emerging -> Standard -> Commodity

– Middleware is emerging as OS declines

! …DDS is maturing…– OMG focus

– Wire spec

– Tools

– Enterprise integration

– Multiple products fielded

– Deployed applications!

! …and adoption is on the rise– Navy

– DISR

– FCS/SoSCOE

– Many significant applications 4

Page 5: Getting Started in DDS with C++ and Java

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

The OMG Data Distribution Service

DDS v1.2 API Standard

‣ Language Independent, OS and HW architecture independent

‣ DCPS. Standard API for Data-Centric, Topic-Based, Real-Time Publish/Subscribe

‣ DLRL. Standard API for creating Object Views out of collection of Topics

Object/Relational Mapping

Ownership DurabilityContent

Subscription

Minimum Profile

Data Centric Publish/Subscribe (DCPS)

Data Local Reconstruction Layer (DLRL)

DDS Interoperability Wire Protocol

Application

UDP/IP

Real-Time Publish/Subscribe Protocol

5

Page 6: Getting Started in DDS with C++ and Java

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

The OMG Data Distribution Service

DDS v1.2 API Standard

‣ Language Independent, OS and HW architecture independent

‣ DCPS. Standard API for Data-Centric, Topic-Based, Real-Time Publish/Subscribe

‣ DLRL. Standard API for creating Object Views out of collection of Topics

Object/Relational Mapping

Ownership DurabilityContent

Subscription

Minimum Profile

Data Centric Publish/Subscribe (DCPS)

Data Local Reconstruction Layer (DLRL)

DDS Interoperability Wire Protocol

Application

UDP/IP

Real-Time Publish/Subscribe Protocol

5

Page 7: Getting Started in DDS with C++ and Java

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

The OMG Data Distribution Service

DDS-RTPS v2.1 Wire Protocol Standard

‣ Standard wire protocol allowing interoperability between different implementations of the DDS standard

‣ Interoperability demonstrated among key DDS vendors in March 2009

Object/Relational Mapping

Ownership DurabilityContent

Subscription

Minimum Profile

Data Centric Publish/Subscribe (DCPS)

Data Local Reconstruction Layer (DLRL)

DDS Interoperability Wire Protocol

Application

UDP/IP

Real-Time Publish/Subscribe Protocol

6

Page 8: Getting Started in DDS with C++ and Java

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

./dds-foundations

7

Page 9: Getting Started in DDS with C++ and Java

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

What is Data Distribution?‣ Data distribution is about

making application defined data available where needed and when needed

‣ Data is a first class concept, it can be created, updated, read and eventually disposed

‣ The last value (or last N-values) of a Data is available

VehicleSpeedVehicleSpeedVehicleSpeed

plate

“A123”

“B456”

“C789”

dx dy

50 0

0 45

10 30

VehiclePositionVehiclePositionVehiclePosition

plate

“A123”

“B456”

“C789”

x y

101 202

303 404

505 606

[1/2]

TrakCo.VehiclePosition

struct VehiclePosition { string plate; long x, y; }

TrakCo.VehicleSpeed

struct VehicleSpeed { string plate; long dx, dy; }

Brokers

8

Page 10: Getting Started in DDS with C++ and Java

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

What is Data Distribution?

‣ Producer, Consumers as well as Topics are dynamically discovered

‣ A rich set of QoS is used to control the non-functional properties of data (e.g. durability, availability, etc.)

[2/2]

TrakCo.VehiclePosition

struct VehiclePosition { string plate; long x, y; }

TrakCo.VehicleSpeed

struct VehicleSpeed { string plate; long dx, dy; }

VehicleSpeedVehicleSpeedVehicleSpeed

plate

“A123”

“B456”

“C789”

dx dy

50 0

0 45

10 30

VehiclePositionVehiclePositionVehiclePosition

plate

“A123”

“B456”

“C789”

x y

101 202

303 404

505 606

Brokers

9

Page 11: Getting Started in DDS with C++ and Java

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

./dds-topics

10

Page 12: Getting Started in DDS with C++ and Java

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

Data in DDS

‣ The definition of Data in DDS is tied to the definition of a Topic

‣ A Topic is the association between: ‣ Unique Name‣ Type‣ QoS

‣ A Topic can have associated a key in order to express data instances identities

VehiclePosition

TrackCo.VehiclePosition

{ Reliability Deadline, Priority Transient, ...}

TopicType QoS

Name

[1/2]

Topics

11

Page 13: Getting Started in DDS with C++ and Java

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

Data in DDS

‣ A Topic key can be made of an arbitrary number of Topic Type attributes

‣ Each unique key value identify a Topic Instance

‣ Topic Instance, can be Created, Read, Updated, and Disposed (CRUD)

[2/2]

VehiclePositionVehiclePositionVehiclePosition

plate

“A123”

“B456”

“C789”

x y

101 202

303 202

101 606

TrakCo.VehiclePositionTopic

Topic Type

Topic Instances

Topic Key

Topic Instances

12

Page 14: Getting Started in DDS with C++ and Java

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

./qos

13

Page 15: Getting Started in DDS with C++ and Java

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

DDS QoS 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

‣ QoS-Policies provide control over 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 Model thus QoS-enforcement

14

Page 16: Getting Started in DDS with C++ and Java

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

QoS Policy Applicability

RxO Modifiable

DURABILITY

DURABILITY SERVICE

LIFESPAN

HISTORY

PRESENTATION

RELIABILITY

PARTITION

DESTINATION ORDER

OWNERSHIP

OWNERSHIP STRENGTH

DEADLINE

LATENCY BUDGET

TRANSPORT PRIORITY

T, DR, DW Y N

Data Availability

T, DW N NData Availability

T, DW N/A Y

Data Availability

T, DR, DW N N

Data Availability

P, S Y N

Data Delivery

T, DR, DW Y N

Data Delivery

P, S N YData DeliveryT, DR, DW Y NData Delivery

T, DR, DW Y N

Data Delivery

DW N/A Y

Data Delivery

T, DR, DW Y Y

Data Timeliness

T, DR, DW Y YData Timeliness

T, DW N/A Y

Data Timeliness

TIME BASED FILTER

RESOURCE LIMITS

ENTITY FACTORY

USER DATA

TOPIC DATA

GROUP DATA

LIVELINESS

WRITER DATA LIFECYCLE

READER DATA LIFECYCLE

DR N/A Y

ResourcesT, DR, DW N N

Resources

Configuration

DP, DR, DW N Y ConfigurationT N YConfiguration

P, S N Y

Configuration

T, DR, DW Y N

Configuration

DW N/A Y

LifecycleDR N/A Y

Lifecycle

QoS Policy Applicability RxO Modifiable

QoS Policies

15

Page 17: Getting Started in DDS with C++ and Java

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

./dds-in-action

16

Page 18: Getting Started in DDS with C++ and Java

Brokers

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

Data Distribution in Action

17

Page 19: Getting Started in DDS with C++ and Java

Brokers

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

Data Distribution in Action

VehicleSpeedVehicleSpeedVehicleSpeed

plate dx dy

VehiclePositionVehiclePositionVehiclePosition

plate x y

17

Page 20: Getting Started in DDS with C++ and Java

Brokers

VehicleSpeedVehicleSpeedVehicleSpeed

plate dx dy

VehiclePositionVehiclePositionVehiclePosition

plate x y

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

Data Distribution in Action

VehiclePositionVehiclePositionVehiclePosition

plate x y

VehicleSpeedVehicleSpeedVehicleSpeed

plate dx dy

VehiclePositionVehiclePositionVehiclePosition

plate x y

VehiclePositionVehiclePositionVehiclePosition

plate x y

VehiclePositionVehiclePositionVehiclePosition

plate x y

18

Page 21: Getting Started in DDS with C++ and Java

Brokers

VehicleSpeedVehicleSpeedVehicleSpeed

plate dx dy

VehiclePositionVehiclePositionVehiclePosition

plate x y

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

Data Distribution in Action

VehiclePositionVehiclePositionVehiclePosition

plate x y

VehicleSpeedVehicleSpeedVehicleSpeed

plate dx dy

“A123” 101 202

“A123” 101 202

“A123” 101 202

VehiclePositionVehiclePositionVehiclePosition

plate x y

VehiclePositionVehiclePositionVehiclePosition

plate x y

VehiclePositionVehiclePositionVehiclePosition

plate x y

18

Page 22: Getting Started in DDS with C++ and Java

Brokers

VehicleSpeedVehicleSpeedVehicleSpeed

plate dx dy

VehiclePositionVehiclePositionVehiclePosition

plate x y

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

Data Distribution in Action

VehiclePositionVehiclePositionVehiclePosition

plate x y

VehicleSpeedVehicleSpeedVehicleSpeed

plate dx dy

“A123” 101 202

“A123” 101 202

“A123” 101 202

VehiclePositionVehiclePositionVehiclePosition

plate x y

VehiclePositionVehiclePositionVehiclePosition

plate x y

“B456” 303 404

“B456” 303 404

“B456” 303 404

VehiclePositionVehiclePositionVehiclePosition

plate x y

18

Page 23: Getting Started in DDS with C++ and Java

VehiclePositionVehiclePositionVehiclePosition

plate x y

“A123” 101 202

“B456” 303 404

Brokers

VehicleSpeedVehicleSpeedVehicleSpeed

plate dx dy

VehiclePositionVehiclePositionVehiclePosition

plate x y

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

Data Distribution in Action

VehiclePositionVehiclePositionVehiclePosition

plate x y

VehicleSpeedVehicleSpeedVehicleSpeed

plate dx dy

“A123” 101 202“A123” 101 202VehiclePositionVehiclePositionVehiclePosition

plate x y“B456” 303 404“B456” 303 404

VehiclePositionVehiclePositionVehiclePosition

plate x y

“A123” 101 202

“B456” 303 404

19

Page 24: Getting Started in DDS with C++ and Java

VehiclePositionVehiclePositionVehiclePosition

plate x y

“A123” 101 202

“B456” 303 404

Brokers

VehicleSpeedVehicleSpeedVehicleSpeed

plate dx dy

VehiclePositionVehiclePositionVehiclePosition

plate x y

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

Data Distribution in Action

VehiclePositionVehiclePositionVehiclePosition

plate x y

VehicleSpeedVehicleSpeedVehicleSpeed

plate dx dy

“A123” 101 202“A123” 101 202VehiclePositionVehiclePositionVehiclePosition

plate x y“B456” 303 404“B456” 303 404

VehiclePositionVehiclePositionVehiclePosition

plate x y

“C789” 505 606

“C789” 505 606

“C789” 505 606

“A123” 101 202

“B456” 303 404

19

Page 25: Getting Started in DDS with C++ and Java

VehiclePositionVehiclePositionVehiclePosition

plate x y

“A123” 101 202

“B456” 303 404

Brokers

VehicleSpeedVehicleSpeedVehicleSpeed

plate dx dy

VehiclePositionVehiclePositionVehiclePosition

plate x y

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

Data Distribution in Action

VehiclePositionVehiclePositionVehiclePosition

plate x y

VehicleSpeedVehicleSpeedVehicleSpeed

plate dx dy

“A123” 101 202“A123” 101 202VehiclePositionVehiclePositionVehiclePosition

plate x y“B456” 303 404“B456” 303 404

VehiclePositionVehiclePositionVehiclePosition

plate x y

“C789” 505 606“C789” 505 606

“A123” 101 202

“B456” 303 404

“C789” 505 606

“C789” 505 606

20

Page 26: Getting Started in DDS with C++ and Java

VehiclePositionVehiclePositionVehiclePosition

plate x y

“A123” 101 202

“B456” 303 404

Brokers

VehicleSpeedVehicleSpeedVehicleSpeed

plate dx dy

VehiclePositionVehiclePositionVehiclePosition

plate x y

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

Data Distribution in Action

VehiclePositionVehiclePositionVehiclePosition

plate x y

VehicleSpeedVehicleSpeedVehicleSpeed

plate dx dy

“A123” 101 202“A123” 101 202VehiclePositionVehiclePositionVehiclePosition

plate x y“B456” 303 404“B456” 303 404

VehiclePositionVehiclePositionVehiclePosition

plate x y

“C789” 505 606“C789” 505 606

“A123” 101 202

“B456” 303 404

“C789” 505 606

“C789” 505 606

“A123” 50 0

20

Page 27: Getting Started in DDS with C++ and Java

VehiclePositionVehiclePositionVehiclePosition

plate x y

“A123” 101 202

“B456” 303 404

Brokers

VehicleSpeedVehicleSpeedVehicleSpeed

plate dx dy

VehiclePositionVehiclePositionVehiclePosition

plate x y

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

Data Distribution in Action

VehiclePositionVehiclePositionVehiclePosition

plate x y

VehicleSpeedVehicleSpeedVehicleSpeed

plate dx dy

“A123” 101 202“A123” 101 202VehiclePositionVehiclePositionVehiclePosition

plate x y“B456” 303 404“B456” 303 404

VehiclePositionVehiclePositionVehiclePosition

plate x y

“C789” 505 606“C789” 505 606

“A123” 101 202

“B456” 303 404

“C789” 505 606

“C789” 505 606

“A123” 50 0

VehicleSpeedVehicleSpeedVehicleSpeed

plate dx dy

21

Page 28: Getting Started in DDS with C++ and Java

VehiclePositionVehiclePositionVehiclePosition

plate x y

“A123” 101 202

“B456” 303 404

Brokers

VehicleSpeedVehicleSpeedVehicleSpeed

plate dx dy

VehiclePositionVehiclePositionVehiclePosition

plate x y

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

Data Distribution in Action

VehiclePositionVehiclePositionVehiclePosition

plate x y

VehicleSpeedVehicleSpeedVehicleSpeed

plate dx dy

“A123” 101 202“A123” 101 202VehiclePositionVehiclePositionVehiclePosition

plate x y“B456” 303 404“B456” 303 404

VehiclePositionVehiclePositionVehiclePosition

plate x y

“C789” 505 606“C789” 505 606

“A123” 101 202

“B456” 303 404

“C789” 505 606

“C789” 505 606

“A123” 50 0

“A123” 50 0

VehicleSpeedVehicleSpeedVehicleSpeed

plate dx dy

21

Page 29: Getting Started in DDS with C++ and Java

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

./cxx-java-psm

22

Page 30: Getting Started in DDS with C++ and Java

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

DDS PIM/PSM Approach

‣ The DDS standard is composed by a PIM specified in UML and A PSM specified in IDL

‣ Language specific APIs are derived via IDL-based mappings (e.g. IDL2C++, etc.)

PIM (UML)

PSM (IDL)

C JavaC++

IDL2CIDL2C++ IDL2Java

23

Page 31: Getting Started in DDS with C++ and Java

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

What is the problem?

‣ IDL is very good for describing DDS Topic Types, yet...

‣ IDL’s biggest strength, namely (programming) language independence, becomes its biggest weakness when trying to define APIs that are well integrated with a programming language

‣ For some programming languages (e.g. C++) the IDL2C++ mapping is “seasoned”

24

Page 32: Getting Started in DDS with C++ and Java

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

Why is this a problem?

‣ Resulting DDS APIs are more complicated than they should

‣ API don’t feel natural or ergonomic to programmers

‣ API (esp. for C++) don’t integrate well with standard libraries nor implements common idioms/patterns.

25

Page 33: Getting Started in DDS with C++ and Java

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

Native C++/Java PSMs‣ The new C++/Java PSM are derived

starting directly from the PIM

‣ The new C++/Java PSM take advantage of all the features available in C++/Java to provide a natural, productive, efficient, safe and portable API

PIM (UML)

ISO C++ PSM

The new PSM simplify DDS programming w/o limiting the expensiveness or introducing limitations in what possible

Java 5 PSM

26

Page 34: Getting Started in DDS with C++ and Java

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

ISO C++ PSM in a Nutshell‣ Provides transparent, safe, precise and real-time automatic

memory management

‣ Takes advantage of C++ Template Meta-programming to automate tasks such as type registration and provide a strongly typed API (no downcast ever!)

‣ Provides a DDS API that exploits Iterators and containers as well as other C++ Standard Types

‣ API is extensible, efficient and portable

27

Page 35: Getting Started in DDS with C++ and Java

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

Java 5 PSM in a Nutshell

‣ Takes advantage of Java Generics to simplify the API and facilitate tasks such as type registration

‣ Provides a DDS API that exploits Iterators and containers

‣ API is extensible, efficient and portable

28

Page 36: Getting Started in DDS with C++ and Java

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

Anatomy of a DDS Application

‣ Tree-like dependency between DP->(P,S)->(DR, DW) in creation and life-cycle management

‣ Example: DW alive requires the parent P to be alive

‣ This tree-like dependency allows precise GC of DDS Entities via reference counting

DomainParticipant

Publisher Subscriber

DataWriter DataReader

Topic

Partition

Domain

DP: DomainParticipant DR: DataReaderP: Publisher DW: DataWriterS: Subscribe

29

Page 37: Getting Started in DDS with C++ and Java

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

DDS App Steps

1. Define the Information Model1

30

Page 38: Getting Started in DDS with C++ and Java

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

DDS App Steps

1. Define the Information Model

2. Connect to proper Domain/Partition

1

2

31

Page 39: Getting Started in DDS with C++ and Java

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

DDS App Steps

1. Define the Information Model

2. Connect to proper Domain/Partition

3. Create Topic

1

2

3

32

Page 40: Getting Started in DDS with C++ and Java

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

DDS App Steps

1. Define the Information Model

2. Connect to proper Domain/Partition

3. Create Topic

4. Create DataWriter

1

2

3

4

33

Page 41: Getting Started in DDS with C++ and Java

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

DDS App Steps

1. Define the Information Model

2. Connect to proper Domain/Partition

3. Create Topic

4. Create DataWriter

5. Create DataReader

1

2

3

4

4

34

Page 42: Getting Started in DDS with C++ and Java

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

DDS App Steps

1. Define the Information Model1

35

Page 43: Getting Started in DDS with C++ and Java

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

./cxx

36

Page 44: Getting Started in DDS with C++ and Java

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

Topics in C++

‣ Topic are associated to a C++ template class parametrized in the topic type, e.g. Topic<VehiclePosition>, Topic<VehicleSpeed>

‣ Topic types can be described in IDL, XML, UML, and Java

‣ Topic types are mapped to C++ classes having one set of accessors per Topic attribute

37

Page 45: Getting Started in DDS with C++ and Java

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

Types Mapping

‣ DDS primitive types are mapped to C99/C++ standard types

‣ DDS container types are mapped to standard C++ containers, namely std::vector and std::map

38

Page 46: Getting Started in DDS with C++ and Java

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

Topic Type Mapping

struct VehiclePosition {! string plate;! long x;! long y;};#pragma keylist VehiclePosition plate

IDL Topic Type Definition

class VehiclePosition {

! VehiclePosition();! VehiclePosition(const std::string& plate,! ! ! int32_t x, int32_t y);

! virtual ~VehiclePosition();

! const std::string& plate() const;! void plate(const std::string& s);

! const int32_t x() const;! void x(int32_t i);

! const int32_t y() const;! void y(int32_t i);

private:! // Encapsulated state representation};

C++ Topic Type Mapping

39

Page 47: Getting Started in DDS with C++ and Java

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

./java

40

Page 48: Getting Started in DDS with C++ and Java

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

Topics in Java‣ Topic are associated to a Java Generic class parametrized in

the topic type, e.g. Topic<VehiclePosition>, Topic<VehicleSpeed>

‣ Topic types can be described in IDL, XML, UML, and Java

‣ Topic types are mapped to Java classes having one set of accessors per Topic attribute

‣ Properly annotated, user provided Java classes, can be used as topic types w/o the need of code generation

41

Page 49: Getting Started in DDS with C++ and Java

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

Types Mapping

‣ DDS primitive types are mapped to Java primitive types

‣ DDS container types are mapped to standard Java containers

DDS Type Java Type

Boolean boolean

Char8 char

Char32 int

Byte byte

Int16 short

UInt16 short

Int32 int

Uint32 int

Int64 long

Uint64 long

Float64 double

Float32 float

string<Char8> String

string<Char32> String

sequence<T> Collection

map<K,T> java.util.Map

T[] T[]

42

Page 50: Getting Started in DDS with C++ and Java

Java Topic Type Mapping

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

Topic Type Mappingclass VehiclePosition {

public VehiclePosition() { /* impl */ } public VehiclePosition(String plate, ! ! ! int x, int y) { /* impl */}

String getPlate() { /* impl */ } void setPlate(String plate) { /* impl */ }

int getX() { /* impl */ } void setX(int x) { /* impl */ }

int getY() { /* impl */ } void setY(int y) { /* impl */ } // Private state implementation }

struct VehiclePosition {! string plate;! long x;! long y;};#pragma keylist VehiclePosition plate

IDL Topic Type Definition

43

Page 51: Getting Started in DDS with C++ and Java

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

Java Topic Type Definitionclass VehiclePosition { @key private string plate; private int x; private int y;

public VehiclePosition() { } public VehiclePosition(String plate, ! ! ! int x, int y) {

this.plate = plate;! this.x = x;! this.y = y;

}

String getPlate() { return this.plate; } void setPlate(String plate) {

this.plate = plate; }

int getX() { return this.x; } void setX(int x) { this.x = x; }

int getY() { return this.y; } void setY(int y) { this.y = y; } }

44

Page 52: Getting Started in DDS with C++ and Java

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

DDS App Steps

1. Define the Information Model

2. Connect to proper Domain/Partition

1

2

45

Page 53: Getting Started in DDS with C++ and Java

Domain

‣ A Domain is one instance of the DDS Global Data Space

‣ DDS entities always belong to a specific domain

Partition

‣ A partition is a scoping mechanism provided by DDS organize a partition

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

DomainId = 0

VechicleTelemetry

Domain and Partitions

46

Page 54: Getting Started in DDS with C++ and Java

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

./cxx

47

Page 55: Getting Started in DDS with C++ and Java

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

Joining Domain/Partition

Note:

‣ Reference types are always created via factory methods on the parent entity

‣ Policies can be “streamed” into QoS objects

// Create Domain Participant in the Domain “0”DomainId id = 0;DomainParticipant dp =

TheParticipantFactory().create_participant(id);

// Set the Publisher QoS with the proper partitionpub::qos::PublisherQos pqos;pqos << policy::Partition("VehicleTelemetry");

// Create the Publisherpub::Publisher pub =

dp.create_publisher(pqos);

using namespace dds::core;using namespace dds;using namespace dds::domain;

48

Page 56: Getting Started in DDS with C++ and Java

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

./java

49

Page 57: Getting Started in DDS with C++ and Java

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

Joining Domain/Partition

Note:

‣ The Boostrap class allows to run multiple DDS instances, even from different vendors on the same application

// Create Domain Participant in the Domain “0”DomainId id = 0;DomainParticipantFactory factory =! ! DomainParticipantFactory.getInstance(Bootstrap.createInstance());

DomainParticipant dp = factory.createParticipant(id);

// Create the Publisherpub::Publisher pub =

dp.create_publisher(pqos);

import org.omg.dds.core.Bootstrap;import org.omg.dds.domain.DomainParticipant;import org.omg.dds.domain.DomainParticipantFactory;

50

Page 58: Getting Started in DDS with C++ and Java

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

DDS App Steps

1. Define the Information Model

2. Connect to proper Domain/Partition

3. Create Topic

1

2

3

51

Page 59: Getting Started in DDS with C++ and Java

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

./cxx

52

Page 60: Getting Started in DDS with C++ and Java

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

Topic CreationNote:

‣ QoS setting is optional and only required to override defaults

‣ QoS override shown to highlight how effective is the new QoS API

// Create and set TopicQos (if different from // default) topic::qos::TopicQos tqos;tqos << policy::Reliability::Reliable() << policy::Durability::Transient() << policy::History::KeepLast(10) << policy::TransportPriority(14);

// Create the Topic with specific Qostopic::Topic<VehiclePosition> topic = dp.create_topic<VehiclePosition>("VPosTopic", tqos);

using namespace dds;

// Create the Topic with default Qostopic::Topic<VehiclePosition> topic = dp.create_topic<VehiclePosition>("VPosTopic");

53

Page 61: Getting Started in DDS with C++ and Java

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

./java

54

Page 62: Getting Started in DDS with C++ and Java

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

Topic Creation

Note:

‣ The TopicType class is passed to work-around Java Generics type-erasure

import org.omg.dds.topic.Topic;

// Create the Topic with default QosTopic<VehiclePosition> topic = dp.createTopic("VPosTopic", VehiclePosition.class);

55

Page 63: Getting Started in DDS with C++ and Java

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

DDS App Steps

1. Define the Information Model

2. Connect to proper Domain/Partition

3. Create Topic

4. Create DataWriter

1

2

3

4

56

Page 64: Getting Started in DDS with C++ and Java

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

./cxx

57

Page 65: Getting Started in DDS with C++ and Java

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

Writing DataNote:

‣ The DataWriter is parametrized on the Topic Type

‣ The stream operator can be used to write sample as well as override Qos, policies and to do coherent updates

// Create and set DataWriterQos from TopicQospub::qos::DataWriterQos dwqos(tqos);

// Create DataWriterpub::DataWriter<VehiclePosition> dw =

pub.create_datawriter(topic, dwqos);

// Create SampleVehiclePosition vpos("A123", 100, 200);

// Writedw.write(vpos);

// Stream-like Writedw << vpos;

// Stream-like Write + Policy overridedw << policy::TransportPriority(55) << vpos;

using namespace dds::core;using namespace dds;

58

Page 66: Getting Started in DDS with C++ and Java

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

./java

59

Page 67: Getting Started in DDS with C++ and Java

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

Writing Data

Note:

‣ No need to pass the class type since it is maintained by the Topic

import org.omg.dds.pub.DataWriter;

// Create the Topic with default QosDataWriter<VehiclePosition> dw = pub.createDataWriter(topic);

// Create SampleVehiclePosition vp = new VehiclePosition("A123", 100, 200);

// Write Sampledw.write(vp);

60

Page 68: Getting Started in DDS with C++ and Java

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

DDS App Steps

1. Define the Information Model

2. Connect to proper Domain/Partition

3. Create Topic

4. Create DataWriter

5. Create DataReader

1

2

3

4

4

61

Page 69: Getting Started in DDS with C++ and Java

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

./cxx

62

Page 70: Getting Started in DDS with C++ and Java

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

Reading DataNote:

‣ The read API is heavily based on iterators

‣ The stream operator can also be used read samples and a mutator is used to control the read/take behaviour

‣ Back-inserting iterators and zero-copy API also supported

// (1) Create and set DataReaderQos from TopicQossub::qos::DataReaderQos drqos(tqos);

// (2) Create DataReadersub::DataReader<VehiclePosition> dr =

sub.create_datareader(topic, drqos);

// (3) Read with using Forward Iterators on std::vectorstd::vector<VehiclePosition> data(N);std::vector<SampleInfo> info(N);dr.read(data.begin(), info.begin(), N);

// (3) Read with using Forward Iterators on arraysVehiclePosition adata[N];SampleInfo ainfo[N];dr.read(&adata[0], &ainfo[0], N);

using namespace dds::core;using namespace dds;

63

Page 71: Getting Started in DDS with C++ and Java

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

./java

64

Page 72: Getting Started in DDS with C++ and Java

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

Reading Data

Note:

‣ No need to pass the class type since it is maintained by the Topic

import org.omg.dds.pub.DataReader;

// Create the Topic with default QosDataReader <VehiclePosition> dr = sub.createDataReader(topic);

List<Sample<VehiclePosition>> data = new Vector<Sample<VehiclePosition>>();

dr.read(data);

65

Page 73: Getting Started in DDS with C++ and Java

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

Putting all togetherint main(int, char**) { // -- Create Domain Participant DomainParticipant dp = ! ! TheParticipantFactory().create_participant();

// -- Create Publisher pub::Publisher pub = dp.create_publisher();

// -- Create Topic dds::topic::Topic<VehiclePosition> topic = ! ! dp.create_topic<VehiclePosition>("VSPosTopic");

// -- Create DataWriter pub::DataWriter<VehiclePosition> dw =! ! ! pub.create_datawriter(topic);

// -- Write Sample dw << VehiclePosition("A123", 100, 200);}

‣ Writing a DDS can take as 5 lines of code

‣ Default domain‣ Default Qos

66

Page 74: Getting Started in DDS with C++ and Java

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

./summ-up

67

Page 75: Getting Started in DDS with C++ and Java

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

Concluding Remarks

‣ DDS provide a powerful abstraction for building high available, scalable and high performance distributed systems

‣ The new C++ and Java API make DDS very simple to use while improving safety, performances and portability

‣ These new API are now finalized and planned for adoption during the December 2010 OMG meeting

68

Page 76: Getting Started in DDS with C++ and Java

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

./references

69

Page 77: Getting Started in DDS with C++ and Java

Ope

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

SOpe

nSpl

ice

DD

S

References‣ Working incubator from which most of

the ISO C++ PSM was derived

‣ Available at:

‣ http://code.google.com/p/simd-cxx

The Simple DDS API

SimD

‣ OMG submission for C++/Java PSM are also available as Open Source project at the following URL

‣ http://code.google.com/p/dds-psm-cxx/‣ http://code.google.com/p/datadistrib4j/

70

Page 78: Getting Started in DDS with C++ and Java

http://www.opensplice.com/

http://www.opensplice.org/

emailto:[email protected]

http://www.youtube.com/OpenSpliceTube http://opensplice.blogspot.com

http://bit.ly/1Sreg

http://www.slideshare.net/angelo.corsaro

http://twitter.com/acorsaro/

D e l i v e r i n g P e r f o r m a n c e , O p e n n e s s , a n d F r e e d o m

OpenSplice DDSReferences

71