connected mobile and web applications with vortex

93
Connected Mobile and Web Applications with Angelo Corsaro, PhD Chief Technology Officer [email protected]

Upload: angelo-corsaro

Post on 14-Jan-2017

736 views

Category:

Technology


1 download

TRANSCRIPT

Connected Mobile and Web Applications with

AngeloCorsaro,PhDChiefTechnologyOfficer

[email protected]

Connectivity

IaaS

analytics

operational systems

information systems

mobile

desktop

web

embeddedfog computing

integration

Vortex “Connectivity” Model

Applications can autonomously and asynchronously read and write data enjoying spatial and

temporal decoupling DDS Global Data Space

...

Data Writer

Data Writer

Data Writer

Data Reader

Data Reader

Data Reader

Data Reader

Data Writer

TopicAQoS

TopicBQoS

TopicCQoS

TopicDQoS

Global Data Space

Built-in dynamic discovery isolates applications from

network topology and connectivity details

DDS Global Data Space

...

Data Writer

Data Writer

Data Writer

Data Reader

Data Reader

Data Reader

Data Reader

Data Writer

TopicAQoS

TopicBQoS

TopicCQoS

TopicDQoS

Dynamic Discovery

QoS policies allow to express temporal and availability

constraints for data

DDS Global Data Space

...

Data Writer

Data Writer

Data Writer

Data Reader

Data Reader

Data Reader

Data Reader

Data Writer

TopicAQoS

TopicBQoS

TopicCQoS

TopicDQoS

QoS - Enabled

No single point of failure or bottleneck

Decentralised Data Space Data

Writer

Data Writer

Data Writer

Data Reader

Data Reader

Data Reader

Data Writer

TopicAQoS

TopicBQoS

TopicCQoS

TopicDQoS

TopicDQoS

TopicDQoS

TopicAQoS

Connectivity is dynamically adapted to chose the most

effective way of sharing data

Adaptive ConnectivityData

Writer

Data Writer

Data Writer

Data Reader

Data Reader

Data Reader

Data Writer

TopicAQoS

TopicBQoS

TopicCQoS

TopicDQoS

TopicDQoS

TopicDQoS

TopicAQoS

ThecommunicationbetweentheDataWriterandmatchingDataReaderscanbepeer-to-peerexploitingUDP/IP(UnicastandMulticast)orTCP/IP

ThecommunicationbetweentheDataWriterandmatchingDataReaderscanbe“brokered”butstillexploitingUDP/IP(UnicastandMulticast)orTCP/IP

A domain-wide information’s class A Topic defined by means

of a <name, type, qos>

TopicDDS Global Data Space

...

Data Writer

Data Writer

Data Writer

Data Reader

Data Reader

Data Reader

Data Reader

Data Writer

TopicAQoS

TopicBQoS

TopicCQoS

TopicDQoS

TopicTypeName

QoS

Topic types can be expressed using different syntaxes,

including IDL and ProtoBuf

Topic Type struct CarDynamics { string cid; long x; long y; float dx; long dy; } #pragma keylist CarDynamics cid

IDL

Topic types can be expressed using different syntaxes,

including IDL and ProtoBuf

Topic Type message CarDynamics { option (.omg.dds.type) = {name: "CarDynamics"}; required string cid = 0 [(.omg.dds.member).key = true]; required long x = 1; required long y = 2; required float dx = 3; required long dy = 4; }

ProtoBuf

Topic types can be expressed using different syntaxes,

including IDL and ProtoBuf

Topic Type class CarDynamics: constructor: (@cid, @x, @y, @dx, @dy) ->

CoffeeScript

Topic types can be expressed using different syntaxes,

including IDL and ProtoBuf

Topic Type public struct VehicleDynamics { public string cid { get; set; } public int x { get; set; } public int y { get; set; } public int dx { get; set; } public int dy { get; set; } public VehicleDynamics (string cid, int x, int y, int dx, int dy) { this.cid = cid; this.x = x; this.y = y; this.dx = dx; this.dy = dy; } }

C#

Vortex “knows” about application

data types and uses this

information provide type-

safety and content-based

routing

Content Awareness structCarDynamics{

@keystringcid;longx;longy;floatdx;longdy;}

cid x y dx dyGR 33N GO 167 240 45 0LO 00V IN 65 26 65 0AN 637 OS 32 853 0 50AB 123 CD 325 235 80 0

“dx>50ORdy>50”

Type

CarDynamics

cid x y dx dyLO 00V IN 65 26 65 0AB 123 CD 325 235 80 0

A collection of policies that control non-functional

properties such as reliability, persistence, temporal

constraints and priority

QoS HISTORY

LIFESPAN

DURABILITY

DEADLINE

LATENCY BUDGET

TRANSPORT PRIO

TIME-BASED FILTER

RESOURCE LIMITS

USER DATA

TOPIC DATA

GROUP DATA

OWENERSHIP

OWN. STRENGTH

LIVELINESS

ENTITY FACTORY

DW LIFECYCLE

DR LIFECYCLE

PRESENTATION

RELIABILITY

PARTITION

DEST. ORDER

RxO QoS Local QoS

QoS Policies controlling end-to-end properties follow a Request

vs. Offered

QoS Domain

Participant

DURABILITY

OWENERSHIP

DEADLINE

LATENCY BUDGET

LIVELINESS

RELIABILITY

DEST. ORDER

Publisher

DataWriter

PARTITION

DataReader

Subscriber

DomainParticipant

offered QoS

Topicwrites reads

Domain Idjoins joins

produces-in consumes-from

RxO QoS Policies

requested QoS

Vortex Technology Stack

Device-2-DeviceDevice-2-Cloud

Fog-2-Cloud

Device-2-Fog

Cloud-2-Cloud

Fog-2-Fog

Device implementations optimised for OT, IT and

consumer platforms

Native support for Cloud and Fog Computing Architectures

Available across IT, Consumer and OT platforms Device-2-DeviceDevice-2-Cloud

Fog-2-Cloud

Device-2-Fog

Cloud-2-Cloud

Fog-2-Fog

Polyglot and Interoperable across Programming

Languages Device-2-DeviceDevice-2-Cloud

Fog-2-Cloud

Device-2-Fog

Cloud-2-Cloud

Fog-2-Fog

Fully Independent of the Cloud Infrastructure

Device-2-DeviceDevice-2-Cloud

Fog-2-Cloud

Device-2-Fog

Cloud-2-Cloud

Fog-2-Fog

Private Clouds

Native Integration with the hottest real-time analytics

platforms and CEP Device-2-DeviceDevice-2-Cloud

Fog-2-Cloud

Device-2-Fog

Cloud-2-Cloud

Fog-2-Fog

Device-2-DeviceDevice-2-Cloud

Fog-2-Cloud

Device-2-Fog

Cloud-2-Cloud

Fog-2-Fog

High Performance

30 μs peer-to-peer latency

4.2M+ msgs/sec peer-to-peer throughput

Device-2-DeviceDevice-2-Cloud

Fog-2-Cloud

Device-2-Fog

Cloud-2-Cloud

Fog-2-Fog

High Performance

4 μs fog/cloud routing latency

Device-2-DeviceDevice-2-Cloud

Fog-2-Cloud

Device-2-Fog

Cloud-2-Cloud

Fog-2-Fog

SecureData-Level security with

Pluggable Authentication Access Control and Crypto

Real-World Example

Vortex device such are used to share data between different kinds of applications within a car

Café can be used in Android based infotainment

Lite in ECU, sensors and onboard analytics

Vortex Fog is used to transparently (for in car apps) decouple and control the data sharing within and across the car

Vortex Fog also helps defining security boundaries and policies

Vortex Fog efficiently and securely deals with car to car communication

Vortex Fog efficiently and securely deals with cloud connectivity adapting traffic flows and protocols

Device-to-Cloud Communication

Cloud Analytics

Fog AnalyticsFog Analytics

Fog Analytics

Vortex Cloud efficiently and securely makes data available to any device at an Internet Scale

Device-to-Cloud Communication

Cloud Analytics

Fog AnalyticsFog Analytics

Fog Analytics

Web and Mobile in Vortex

dds.js Overview

Cop

yrig

ht P

rism

Tech

, 201

4

DataCache Operations

# Folds the content of the data cache using z as “zero” for the folding function f# For instance, assuming that the operator “+” is defined for the elements of # the cache, then you could compute the sum of all elements doing:# c.fold(0)((a, v) -> a + v)# the product by: # c.fold(1)((a, v) -> a * v)# a comma separated string representation of the content:# c.fold(“”)(a, v) -> a + “, “ + vfold(z)(f)

# Register a listener l to be notified whenever data which matches a # predicate p is written into the cache. If no predicate is provided # then the listeners is always notified upon data insertion.addListener(l, p)

hacking time

Cop

yrig

ht P

rism

Tech

, 201

4

The Chat CoffeeScriptpostReader=z_.NonepostWriter=z_.None

avatar="avatar"+Math.floor((Math.random()*10000)+1);

#AddposttothechatandformatittoshowitisfrommecreateMyPost=(post)->...

#AddposttothechatandformatittoshowitisfromotherscreateOtherPost=(post)->...

#AddposttothechatandformatittoshowitisfromothersprocessPost=()->msg=$("#ChatMessage").val()post=newPost(avatar,msg)#Publishthepost(noticethatpostWriterisanOptionMonad)#Takealookat(http://en.wikibooks.org/wiki/Haskell/Understanding_monads/Maybe)#or(http://www.scala-lang.org/api/2.11.0/index.html#scala.Option)postWriter.map((dw)->dw.write(post))$("#ChatMessageList").append(createMyPost(post))$("#ChatMessage").val("")

Cop

yrig

ht P

rism

Tech

, 201

4

The Chat CoffeeScript#Handletheruntimeonconnecteventruntime.onconnect=()->#CreateDataReaderandDataWriterforourposts

runtime.registerTopic(postTopic)dr=newdds.DataReader(runtime,postTopic,drQos)dw=newdds.DataWriter(runtime,postTopic,dwQos)

#Registeralistenerwiththedatareadertopostmessages#inourchatdr.addListener((post)->if(post.nameisntavatar)$("#ChatMessageList").append(createOtherPost(post)))postReader=z_.Some(dr)postWriter=z_.Some(dw)

connectRuntime=()->$("#AvatarName").val(avatar)runtime.connect(server,"uid:pwd")

$(document).ready(()->connectRuntime())

some hacking. . .

class VortexApp { public DataWriter<Post> dw { get; set; } public DataReader<Post> dr { get; set; } private MainWindow win; public string user { get; } public string uri { get; } public VortexApp(string user, string uri) { this.user = user; this.uri = uri; } public async Task Init() { var auth = user + ":nopwd"; var v = new Vortex (0); await v.Connect (uri, auth); if (v.IsConnected) { var tname = "Post"; var post = await v.CreateTopic<Post> (tname); dr = await v.CreateDataReader<Post> (post); dw = await v.CreateDataWriter<Post> (post); } else Console.WriteLine ("Unable to connect to: " + uri); } public void Run () { Application.Init (); Init ().Wait (); win = new MainWindow (user, this.dw); win.Show (); dr.OnDataAvailable += (object sender, SampleData<Post> e) => { win.addPost(e.Data); } ; Application.Run (); } }

Listener are lambdas

Readers and Writers are strongly typed (but can do projections)

using System;using Gtk;using vortex.web;using sharpchat;public partial class MainWindow: Gtk.Window{ private DataWriter<Post> dw; private string user; […]

protected void onKeyReleaseEvent (object o, KeyReleaseEventArgs args) { var k = args.Event.Key; if (k == Gdk.Key.Return) { var rmsg = this.inputText.Buffer.Text; var msg = rmsg.Remove(rmsg.Length -1); dw.Write(new Post(this.user, msg)); this.inputText.Buffer.Clear (); } } private void appendToMessageBoard (string user, string msg) { var text = this.messageBoard.Buffer.Text + "\ n" + user + " >> " + msg; this.messageBoard.Buffer.Text = text; } public void addPost(Post p) { appendToMessageBoard (p.name, p.msg); } }

Async Write

Dashboards

Vortex integrates with Freeboard and makes it supersimple to create dashboards from data coming from Mobile, Web, Embedded, and Cloud apps

Native Mobile Apps

Vortex Cafe can be used to develop android applications in Java

The .Net client for Vortex-Web can be used to along with Xamain to develop native applications for Android , iOS and Windows Phone

The JS client for Vortex-Web can be used to develop native applications with Apache Cordova.

Vortex Cafe

Android Chat

Cop

yrig

ht P

rism

Tech

, 201

4

Applicationpublic class ChatApplication extends Application {

DataReader<Post> dr; DataWriter <Post> dw; DomainParticipant dp;

@Override public void onCreate() { super.onCreate(); // This should be defined via a resource -- but for a small // demo that’s OK.

System.setProperty(ServiceEnvironment.IMPLEMENTATION_CLASS_NAME_PROPERTY, "com.prismtech.cafe.core.ServiceEnvironmentImpl"); ServiceEnvironment env = ServiceEnvironment.createInstance( ChatApplication.class.getClassLoader()); DomainParticipantFactory dpf = DomainParticipantFactory.getInstance(env);

dp = dpf.createParticipant(0); Topic<Post> topic = dp.createTopic("Post",Post.class); Publisher pub = dp.createPublisher(); Subscriber sub = dp.createSubscriber();

dw = pub.createDataWriter(topic); dr = sub.createDataReader(topic); }

Cop

yrig

ht P

rism

Tech

, 201

4

Activity GUI<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" >

<TextView android:id="@+id/chatMessages" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/chat_msgs" android:visibility="gone" android:background="#666" android:textColor="#fff" android:paddingLeft="5dp" /> <ListView android:id="@+id/messageList" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" />

Cop

yrig

ht P

rism

Tech

, 201

4

Activity 1 2 public class MainActivity extends Activity { 3 4 private static final String TAG = "ChatMainActivity"; 5 private final Handler handler = new Handler(); 6 private ArrayAdapter<String> chatMessages; 7 8 public class ChatMessageListener extends ChatMessageDataListener { 9 // ...10 }11 12 @Override13 protected void onCreate(Bundle savedInstanceState) {14 super.onCreate(savedInstanceState);15 setContentView(R.layout.activity_main);16 chatMessages = new ArrayAdapter<String>(this, R.layout.messages);17 chatMessages.add("Welcome to the DDS Chat Room");18 ListView mview = (ListView) findViewById(R.id.messageList);19 mview.setAdapter(chatMessages);20 ChatApplication app = (ChatApplication) getApplication();21 22 app.reader().setListener(new ChatMessageListener());23 24 }25

Cop

yrig

ht P

rism

Tech

, 201

4

DDS Listener & Android Handler10 @Override11 public void onDataAvailable(DataAvailableEvent<Post> dae) {12 final Iterator<Post> i = dr.read();13 14 Log.i(TAG, ">>> DataReaderListener.onDataAvailable");15 if (i.hasNext()) {16 Runnable dispatcher = new Runnable() {17 public void run() {18 while (i.hasNext()) {19 Sample<Post> s = i.next();20 21 if (s.getSampleState() == SampleState.NOT_READ) {22 Post cm = s.getData();23 chatMessages.add(cm.name + " > " + cm.msg);24 }25 }26 }27 };28 handler.post(dispatcher);29 }30 }31 }

Live Demo

Cop

yrig

ht P

rism

Tech

, 201

5