Title: Embedded Middleware
1Embedded Middleware
2Previous Lecture
- Source of deterministic errors and random noises
- Basics of signal spectrum
- Nyquist sampling
- Fourier transform
- Basic filters
- What you can do and when you should ask for help
3Overview of Todays Lecture
- What is middleware?
- CORBA
- Java (EJB)
- DCOM
- Comparing different middleware
- Get to know one middleware (CORBA) in depth
- Middleware in embedded systems
- What are the criteria?
4Moving Beyond A Single Processor
- So far, weve only dealt with the issues of a
single embedded processor - What if we want to get embedded processors to run
applications that communicate across the network? - Networked/distributed programs
- Processes that communicate over the network (or
on the same machine) - Client piece of code that requests services
- Server piece of code that provides the services
5Writing Distributed Programs
- Common ways of writing distributed client-server
programs - Sockets
- Low-level interface to the operating system for
TCP and UDP - STREAMS
- Even lower-level interface within the kernel
(almost device-driver level) - Shared memory
- Low-level interface for clients and servers on
the same machine to communicate using a chunk of
memory that they share - Shared files
- Clients and servers exchange information through
a shared file system - RPC (Remote Procedure Call)
- Clients communicate with long-lived server
processes (daemons) over the network
6Socket Programming
- Servers role
- Binds to an Internet (IP) address
- Listens for clients on the network
- Provides services to clients that connect to it
- Clients role
- Knows the servers IP address
- Connects to the server
- Sends service requests
- Client and server exchange messages over TCP or
UDP - Socket/networking code mixed with real client
and server logic
Server
Client
Listens for more clients
TCP or UDP
TCP or UDP
Exchange of messages over an established
connection
7Low-level Network Programming
- Very efficient mechanism
- Available on almost every operating system
- Standardized application programming interface
(API) - Can be used for clients and servers to
communicate on the same machine and across the
network - But ..
- Exposes too many low-level details
- Application writer must be able to debug
network-level issues and problems - Mixes application logic with networking logic
- Clients must know where servers live
- If client and server run on different
byte-ordered machines, they must be aware of
these differences in talking to each other
8.. And Middleware was Born
- Layer between the operating system and the
application - Hides the operating systems details from the
application developer - CORBA, EJB, DCOM
- Why do we need/have middleware?
- It makes it easier to write distributed
applications - Takes care of all the networking code and the
messaging - Leaves you free to focus on writing the
application
9High-Level Overview of Middleware
10CORBA (Common Object Request Broker Architecture)
- Middleware for interoperability from
the Object Management
Group - CMU is a member of the OMG, along
with 800 other
companies/universities - The key component is the broker (ORB)
- Shields the client and the server from
each
others differences - Whats the CORBA client-server model?
- Language transparency Clients and servers can be
written in different programming languages - Location transparency Client and server dont
care about each others locations - Interoperability Clients and servers can run on
different hardware, operating systems and still
be able to talk to each other using a protocol
called IIOP - No support for distributed garbage collection
- Real-Time CORBA standard available
11CORBA - Putting All The Pieces Together
12J2EE (Java 2 Enterprise Edition)
- Sun Microsystems Java-based middleware
- Implicitly has all of Javas portability
advantages - Component application-level software unit
- Container runtime support/services for a
component - On the client side
- Applets, application clients executing in their
own JVM - On the server side
- Web components
- Servlets and Java Server Pages (JSP)
- Enterprise Java Beans (EJB) components can
contain two kinds of objects - Session beans valid for the duration of a
client-server session - Entity beans valid for the lifetime of the
persistent data that it manages - What makes J2EE powerful?
- Can interface to multiple existing back-end
systems and technologies - Power of Javas intrinsic portability, graphical,
web garbage collection capabilities - Real-Time Java standard available
13J2EE - Putting All The Pieces Together
14DCOM (Distributed Component Object Model)
- Microsofts middleware
- DCOM server
- Body of code containing multiple objects
- Each object can support multiple interfaces
- Can be written in Java, C, Pascal
- DCOM client
- Gets a pointer to one of the interfaces
- Talks to the server over that interface
- Doesnt care if the server is local or remote
- Client-server communication
- Occurs over the Object Remote Procedure Call
(ORPC) - Originates from DCEs RPC (where Distributed
Computing Environment, or DCE, was one of the
earliest middleware platforms) - The broker is called the Service Control Manager
(SCM) - Some support for distributed garbage collection
15DCOM - Putting All The Pieces Together
16Critical Thinking
- What are the differences between DCOM, EJB and
CORBA?
17Overview of CORBA
18Interface Definition Language (IDL)
- Used to define
- Interfaces methods or behavior (but not
attributes or state) of a server object - Modules packages of related interfaces and types
- IDL is not a programming language
- No conditional constructs such as if, else, then,
while, do, etc. - IDL compiler
- Provided with every ORB
- Input Servers interface in IDL
- Output Skeleton and stub in a programming
language (Java, C, etc.) - What are the IDL types?
- Basic types octet, char, short, long, double
- Structured types string, sequence,
union, struct - Arbitrary types any
- User-defined types e.g., interfaces
19Example of an IDL Interface
module Bank exception ZeroBalance
typedef sequence DepositHistory
interface Account
string getBalance(in string accountNumber)
void depositMoney(in double amount,
out double balance,
inout
DepositHistory latest) double
withdrawMoney (in double amount)
raises (ZeroBalance)
20Stubs and Skeletons
- What is a stub, anyway?
- Automatically generated by the IDL compiler
- Client-side glue in Java/C
- Marshals (packages) parameters from the client
into a message to be sent to the server - Unmarshals results from the response message
- What is a skeleton, anyway?
- Automatically generated by the IDL compiler
- Server-side glue in Java/C
- Unmarshals (unpackages) messages into the
parameters that the client
intended to send - Marshals results into a response message
21Portable Object Adapter (POA)
- Exists only within CORBA servers
- Dispatches incoming requests to the right target
servants - Also acts as a namespace for the collection of
servants it manages - Additional policies that you can use to customize
a POA - Multithreading
- Activation on demand
- Persistent references (lifespan of objects)
- Unique object identifiers
- A server process can have multiple POAs, each
configured differently, and each responsible for
a certain set of servants
22CORBAs Protocols
- General Inter-ORB Protocol (GIOP)
- Specification of a protocol, and not the
implementation - Eight message formats Request, Reply,
LocateRequest, LocateReply, CancelRequest,
MessageError, CloseConnection, Fragment - Well-defined headers for every message
- Carries the senders byte ordering
- Can be mapped onto any real protocol that is
connection-oriented - Internet Inter-ORB Protocol (IIOP)
- Concrete implementation of GIOP specification
onto TCP/IP - Must be supported by every ORB
- Allows objects to communicate without caring
about their operating systems, hardware
architectures, etc.
23Other CORBA Components
- Implementation Repository
- Stores location of the executables in your file
system - Run-time registry of servers and clients
- Very specific to the vendor
- Interface Repository
- Stores the type information of all CORBA objects
in your application - Dynamic invocation interface implies that you
dont know your types ahead of time, and you can
look these up at run-time - Naming Service
- Registry of user-friendly names associated with
object references - Servants can bind references by a name
- Clients can look up references by that name
24Interoperable Object References (IORs)
- Stringified format of a reference
- Can be stored in a file, sent across the network,
etc. - Contains servers hostname, port number, object
key, etc. - Sample IOR looks like this
- IOR010000001000000049444c3a4163636f756e743a312e
30000200000000000000300000000101000013000000752d6d
61792e7468696e6b6f6e652e636f6d00007b0900000c000000
424f410a20b053000005503010000002400000001000000010
00000010000001400000001000000010001000000000009010
10000000000 -
25System and User Exceptions
- Exception Something bad/illegal/undesirable
occurred - System Exceptions
- Defined within the CORBA standard
- Can alert the application of communication
errors, resource exhaustion, invalid
object references, host crashes - Usually raised by the ORB before the request gets
to the servant - Format of a System Exception
- Minor code Identifies the source of the problem
(e.g., COMM_FAILURE) - Completion status COMPLETED_YES, COMPLETED_NO,
COMPLETED_MAYBE - Make sure that your CORBA clients catch system
exceptions! - User Exceptions
- Can be defined within IDL interfaces
- Each method of an interface can raise exceptions
26(No Transcript)
27Inside Your Netscape Browser
28Middleware in Embedded Systems
- Requirements
- Limited resources Smaller footprint (requires
less code-bloat) - Real-time support (available in Real-Time CORBA
specification) - Full CORBA implementation 150 Kbytes 5 Mbytes!
- What are your options?
- Minimal CORBA Throw out some of the heavyweight
CORBA mechanisms ( 30-60 Kbytes) - IIOP Engine Use a library that keeps only the
IIOP protocol part ( 15 Kbytes) - CORBA Gateways TCP bridge from the embedded
processors to a CORBA gateway that talks to the
rest of the world
29Using CORBA Gateways
30Summary of Lecture
- What is middleware?
- CORBA
- Java (EJB)
- DCOM
- Compare the different middleware
- Get to know one middleware (CORBA) really well
- Middleware in embedded systems
- What are the criteria?