Software Engineering 3156

clumpsmackoverΛογισμικό & κατασκευή λογ/κού

2 Δεκ 2013 (πριν από 3 χρόνια και 10 μήνες)

78 εμφανίσεις

Software Engineering 3156

17
-
Oct
-
01

#13: Concurrent Models

Phil Gross

2

Administrivia


C++ for Java Programmers


Thursday 6
-
8pm, 415 CEPSR


Research Fair


30 November

3

Group Fun


Superslacker members


Working on possibilities


Probably can’t eject from class


but can hammer grades down further

4

Distributed Objects


We’re using “socket model” communications


To connect to a another machine, you explicitly
“open a connection” to it, returning a stream


You then write to and read from the stream,
using standard I/O methods

5

Downsides


Plenty of parsing involved


Have to know which machine to connect to


Synchronous


Unless manually threaded


Versioning and consistency

6

Serialization


Standard method of encoding objects to a
stream


Problem: what to do about pointers


E.g. how to serialize a linked list


Answer: number each object as it goes out,
starting with 0


Replace pointer with serial number

7

Serialization II


C++ gives framework


<<, >> operators


Stream abstraction


Does no serialization


Java builds it in


Built on top of
Reflection

8

Java Reflection


At runtime, can completely determine
composition of classes


Surprisingly powerful technique


The Class class


Object.getClass() / Class.forName()


newInstance()


getMethods(), getConstructors(), etc.

9

New Serialization Trends


What is the format on the wire


Java Object serialization has same answer as
everyone else for last 20 years: Proprietary
format


21
st

Century answer: why not XML?


We’ll see…

10

Remember…


Any time you need to write structured data


Why
not

XML?


Not the end of data formats


But should be the death of most parsing


Good riddance


Useful design concept: Excise

11

Mobile Code


Java style


Bytecode is fully machine independent


Can actually ship the .class file to another
machine


And then load it dynamically at runtime


Alternative style: send scripts or source


Note jdk1.3 weirdness on Cunix


Software “agents”

12

Remote Procedure Calls


Functions/Methods already provide “boundary”
within program


Drop in arguments, wait for result back


Why not use that as a transparent point for
remote invocation


Grab args, send them across network, run
remotely, wait for result, send back

13

Complications


Functions are generally reliable
-

call them and they
eventually come back


Usually after roughly the same duration


Across network, all bets are off


May never come back, or may be extremely delayed


Still have data format problem


Marshalling/Unmarshalling


Stubs = phantom implementation


Security

14

Implementations


Sun RPC


1988


Transport independent


Doesn’t specify
binding

method


How to attach to remote server


Simple security model


XDR is platform independent data representation


Also has standard text representation


And so functions as
IDL:
Interface Description Language


Used in NFS


Network File System

15

DCE RPC


Distributed Computing Environment


Comprehensive Multivendor standard


Can get a little complicated


Two major uses


Large, proprietary Unix
-
based projects


Everything Microsoft


Yes, that’s a big one

16

CORBA


RPC for the OO Generation


ORB = Object Request Broker


Common ORB Architecture


IDL for CORBA is OO


Super
-
cross
-
platformable


Has grown vast


Java library support

17

Java RMI


Sun’s own Java
-
only solution


Need to run separate program rmiregistry


Create the interface, extending Remote and
throwing RemoteException


Implement, extending UnicastRemoteObject,
implementing interface


Install a Security Manager and bind to registry

18

RMI Continued


Client is a little easier


Create a Security Manager and bind to registry


Get reference to object with Naming.lookup()


Use object, watching out for
RemoteExceptions


Actually running the thing requires extra “rmic”
compilation

19

XML
-
RPC and SOAP


Wire format? Why not XML?


XML
-
RPC


HTTP POST command + super
-
simple XML
representation


http://www.xmlrpc.com/spec


20

SOAP


Envelope + Encoding


Full XML, including namespaces


Complex datatypes


Microsoft is a major backer

21

Higher Level Than RPC


Components


Standard, manageable, “thingies” that support remote
interfaces


Microsoft COM+


Strategic for MS


Sun Enterprise Java Beans


Used at many big companies


Key ideas: Deployment, transactions, scalability

22

Interesting Questions


Service Discovery


LDAP, etc.


Interoperability


Performance


Transactions

23

Advanced RPC: Messaging


Asynchronous


Every participating process has a message
queue


Sending returns immediately


Server pulls things off queue at its own pace


Still need to know where to send


Unicast

24

Events: Better Than RPC?


Asynchronous


Publish returns immediately


Multicasting


Many subscribers possible


Moves service discovery problem elsewhere


Content
-
based routing


Publisher doesn’t know subscribers and vice versa


Can be combined with queues

25

Really Nice to Program For


Start up components in any sequence


Start kicking out events


Interested parties start picking up events


Load balancing is trivial


Just add more subscribing servers


Participants happily appearing and
disappearing

26

But Not Always


Load balancing actually not that easy


How to partition tasks?


Sometimes you want to Unicast


Call
-
response


What if I want to know what happens to the
events I publish?


What if I want events to be held until a
participant is available?

27

Example: Siena


Antonio Carzaniga at Colorado Boulder


http://www.cs.colorado.edu/~carzanig/siena



Scalable publish and subscribe


Pros


Works, well documented, pleasure to program with

28

Siena Cons


Performance


No reflection / status


Hierarchical


Proprietary wire format