Transcript
Page 1: Desktop, Embedded and Mobile Apps with Vortex Café

Desktop, Embedded and Mobile Distributed Apps with

Angelo  Corsaro,  PhD  Chief  Technology  Officer  

[email protected]

Café

Page 2: Desktop, Embedded and Mobile Apps with Vortex Café

Vortex

Page 5: Desktop, Embedded and Mobile Apps with Vortex Café

Vortex Café

Page 8: Desktop, Embedded and Mobile Apps with Vortex Café

Cop

yrig

ht P

rism

Tech

, 201

4

Decomposes a complex, event-driven application into a set of stages connected by queues

Avoids the high overhead associated with thread-based concurrency models, and decouples event and thread scheduling from application logic.

Through admission control on each event queue, SEDAs can be well-conditioned to load, preventing resources from being overcommitted when demand exceeds service capacity

SEDA

[Matt Welsh, David Culler, and Eric Brewer, SEDA: An Architecture for Well-Conditioned, Scalable Internet Services]

Page 12: Desktop, Embedded and Mobile Apps with Vortex Café

Cop

yrig

ht P

rism

Tech

, 201

4

Vortex Café is SEDA architecture as well as all the protocol parameters can be configured through configuration file or via command line properties , i.e. providing -D options to the JVM

Configuration parameters are listed on the user manual

Example:

Configuration in Practice

java  -­‐server    -­‐cp  .:./target/vortex-­‐cafe-­‐demo-­‐assembly-­‐2.0.jar  \    -­‐Ddds.listeners.useTransportThread=true  \  -­‐Dddsi.writers.heartbeatPeriod=0.001    \  -­‐Dddsi.writers.nackResponseDelay=0    \  -­‐Dddsi.readers.heartbeatResponseDelay=0  \  -­‐Dddsi.timer.threadPool.size=1    \  -­‐Dddsi.receiver.threadPool.size=0  \    -­‐Dddsi.dataProcessor.threadPool.size=0  \  -­‐Dddsi.acknackProcessor.threadPool.size=0  \  -­‐Dddsi.writers.reliabilityQueue.size=128    \  com.prismtech.cafe.demo.perf.RoundTripDemoReader  $*

Page 13: Desktop, Embedded and Mobile Apps with Vortex Café

Anatomy of a Vortex-Cafe App

Page 15: Desktop, Embedded and Mobile Apps with Vortex Café

Cop

yrig

ht P

rism

Tech

, 201

4

Brewing Vortex-Cafeint  domain_id  =  18;  DomainParticipantFactory  dpf  =                DomainParticipantFactory.getInstance(env)  !DomainParticipant  dp  =            dpf.createParticipant(domainId);  Topic<Post>  topic  =            dp.createTopic(“Post”,  Post.class);

struct  Post  {      string  name;      string  msg;  };                  #pragma  keylist  Post  name  

Publisher  pub  =  dp.createPublisher();  DataWriter<Post>  dw  =          pub.createDataWriter<Post>(topic);  dw.write(new  Post(“Barman”,                                        “Would  you  like  an  espresso?”);

Subscriber  sub  =  dp.createSubscriber();  DataReader<Post>  dr  =            sub.createDataReader<Post>(topic);  LoanedSamples<Post>  samples  =  dw.read();

Page 16: Desktop, Embedded and Mobile Apps with Vortex Café

Cop

yrig

ht P

rism

Tech

, 201

4

Escalating Vortex-Cafe

val  topic  =  Topic[Post](“Post”) struct  Post  {      string  name;      string  msg;  };                  #pragma  keylist  Post  name  

val  dw  =  DataWriter[Post](topic)    dw  write(new  Post(“Barman”,                                        “Would  you  like  an  espresso?”)

val  dr  =  DataReader[Post](topic)  dr.listen  {        case  DataAvailable(_)  =>                          dr.read.foreach(println(_.getData())  }

Page 17: Desktop, Embedded and Mobile Apps with Vortex Café

Android

Page 19: Desktop, Embedded and Mobile Apps with Vortex Café

Cop

yrig

ht P

rism

Tech

, 201

4

An Android application runs in its own JVM and (by default) on its own linux process

An application may be composed of the following elements:

- Activities: a single screen with a user interface

- Services: a component that runs in the background to perform long-running operations or to perform work for remote processes.

- Content Providers: a component that manages shared data for a set of applications

- Broadcast Receivers: a component that responds to system-wide broadcast announcements

Android allows any applications to start any other application component and potentially consume the data it produces

Android Application in a Nutshell

Page 25: Desktop, Embedded and Mobile Apps with Vortex Café

DDS Chat

Page 30: Desktop, Embedded and Mobile Apps with Vortex Café

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);! }!!

Page 34: Desktop, Embedded and Mobile Apps with Vortex Café

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"! />!!

Page 35: Desktop, Embedded and Mobile Apps with Vortex Café

Cop

yrig

ht P

rism

Tech

, 201

4

Activity GUI

! <LinearLayout! android:layout_width="fill_parent"! android:layout_height="wrap_content"! android:orientation="horizontal" >!! <EditText! android:id="@+id/message"! android:layout_width="0dp"! android:layout_height="wrap_content"! android:layout_weight="1"! android:hint="@string/edit_message" />!! <Button! android:layout_width="wrap_content"! android:layout_height="wrap_content"! android:onClick="sendChatMessage"! android:text="@string/button_send" />! </LinearLayout>!!!</LinearLayout>!

Page 36: Desktop, Embedded and Mobile Apps with Vortex Café

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 @Override!13 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

Page 41: Desktop, Embedded and Mobile Apps with Vortex Café

Cop

yrig

ht P

rism

Tech

, 201

4

DDS Listener & Android Handler

10 @Override!11 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 }!

Page 42: Desktop, Embedded and Mobile Apps with Vortex Café

Raspberry Pi

Page 44: Desktop, Embedded and Mobile Apps with Vortex Café

Cop

yrig

ht P

rism

Tech

, 201

4

Several Images are available nowadays, I tend to use Raspbian

To get started get the image from: http://www.raspberrypi.org/downloads/

Then copy the image on an SD card following instruct ructions available at http://www.raspberrypi.org/documentation/installation/installing-images/

For MacOS X:

-­‐ diskutil  list  [to  check  the  SD  card  /dev/diskN]  

-­‐ diskutil  unmontDisk  /dev/diskN  

-­‐ sudo  dd  bs=1m  if=2014-­‐01-­‐07-­‐wheezy-­‐raspbian.img  of=/dev/diskN  

-­‐ sudo  diskutil  eject  /dev/diskN

Raspberry Pi Image

Page 49: Desktop, Embedded and Mobile Apps with Vortex Café

Let’s get Action!


Recommended