System Models Bina Ramamurthy (Based on Slides from CDK text) 5/28/2016

advertisement
System Models
Bina Ramamurthy
(Based on Slides from CDK text)
5/28/2016
B.Ramamurthy
1
Fundamental Issues
There is no global time.
All communications are by means of
messages.
Message communication may be affected by
network delays and can suffer from a variety
of failures and security attacks.
How does one express a solution/process for
handling an issue? One of the ways is to
establish a model.
5/28/2016
B.Ramamurthy
2
System Models
Interaction model deals with performance and
setting time limits in a distributed system, say, for
message delivery.
Failure model gives specification of faults and
defines reliable communication and correct
processes.
Security model specifies possible threats and
defines the concept of secure channels.
Architectural model defines the way in which the
components of the system interact with one another
and the way in which they are mapped onto the
underlying network of computers.
5/28/2016
B.Ramamurthy
3
Architectural Model
Abstracts the functions of the individual
components.
Defines patterns for distribution of data and
workload.
Defines patterns of communication among
the components.
Example: Definition of server process, client
process and peer process and protocols for
communication among processes; definition
client/server model and its variations.
5/28/2016
B.Ramamurthy
4
Software and hardware service layers in
distributed systems
Applications, services
Middlew are
Operating s ys tem
Platform
Computer and netw ork hardw are
5/28/2016
B.Ramamurthy
5
Middleware
Layer of software whose purpose is to mask
the heterogeneity and to provide a
convenient programming model for
application programmers.
Middleware supports such abstractions as
remote method invocation, group
communications, event notification,
replication of shared data, real-time data
streaming.
Examples: CORBA spec by OMG, Java RMI,
MS’s DCOM. We will look at RMI in this
discussion.
5/28/2016
B.Ramamurthy
6
Clients invoke individual servers
Client
invocation
res ult
Client
invocation
Server
res ult
Server
EX: 1. File server,
2. Web crawler
EX: Web server
Key:
Process :
Computer:
EX: browser,
web client
5/28/2016
B.Ramamurthy
7
A service provided by multiple servers
Service
Server
Client
Server
Client
Server
EX: akamai, altavista, Sun’s NIS (data replication)
5/28/2016
B.Ramamurthy
8
Web proxy server and caches
Web
server
Client
Proxy
server
Web
server
Client
Proxy servers + cache are used to provide increased
Availability and performance. They also play a major role
Firewall based security. http://www.interhack.net/pubs/fwfaq/
5/28/2016
B.Ramamurthy
9
A distributed application based on peer
processes
Application
Application
Coordination
code
Coordination
code
Ex: distributed
Whiteboard
Application;
EJB-based?
5/28/2016
Application
Coordination
code
B.Ramamurthy
10
Web applets
a) client request res ults in the dow nloading of applet c ode
Client
Applet code
Web
s erv er
b) client interac ts w ith the applet
Client
Applet
Web
s erv er
EX: Look at Object by value in CORBA
5/28/2016
B.Ramamurthy
11
Spontaneous networking in a hotel
Music
service
gateway
Alarm
service
Internet
Hotel wireless
network
Discovery
service
Camera
TV/PC
Laptop
EX: Jini, blue tooth protocol, UDDI
5/28/2016
B.Ramamurthy
PDA
Guests
devices
12
Remote Method Invocation
Remote Method Invocation (RMI) is Java’s
implementation of object-to-object
communication among Java objects to realize
a distributed computing model.
RMI allows us to distribute our objects on
various machines, and invoke methods on the
objects located on remote sites.
Source code for the demo is a modified
version of code in Chapter 20 of Deitel &
Deitel’s text Java : How to Program.
5/28/2016
B.Ramamurthy
13
RMI-based Distributed System
4.
5.
3.
XYZ
Client
3.
Skeleton
Stub
uses
1.
XYZ
interface
Client Host
5/28/2016
2.
XYZ
Implementation
implements
Server Host
B.Ramamurthy
14
Steps in RMI-based
Application
1. Design the interface for the service.
2. Implement the methods specified in
the interface.
3. Generate the stub and the skeleton.
4. Register the service by name and
location.
5. Use the service in an application.
5/28/2016
B.Ramamurthy
15
Compile and Register
Commands
Finds object by name
5.
rmiregistry
rmic
3.
XYZ
Client
3.
1.
XYZ
interface
Client Host
5/28/2016
2.
Skeleton
Stub
uses
Stores object by name
XYZ
Implementation
implements
Server Host
B.Ramamurthy
16
More Details
Once the object (or service) is registered, a
client can look up that service.
A client (application) receives a reference that
allows the client to use the service (call the
method).
Syntax of calling is identical to a call to a
method of another object in the same
program.
5/28/2016
B.Ramamurthy
17
Parameter Marshalling
Transfer of parameters (or marshalling)
is done by the RMI.
Complex objects are streamed using
Serialization.
RMI model of networking for distributed
system involves only Java.
No need to learn IDL or any other
language.
5/28/2016
B.Ramamurthy
18
Case Study : Temperature
Service
Lets create a distributed system using
RMI model for networking (remote
access).
Basically this program will download the
weather (temperature) information from
the site:
http://iwin.nws.noaa.gov/iwin/us/traveler.html
5/28/2016
B.Ramamurthy
19
Defining Remote Interface
import java.rmi.*;
// the interface extends Remote interface
// any class implementing Remote can be
accessed remotely security permitting
public interface TemperatureServer extends
Remote
{ // specify methods that can be called
remotely
// each method “throws RemoteException”
}
5/28/2016
B.Ramamurthy
20
RemoteException
Any time you depend on outside entities
there is a potential for problems in
communication, networking, server crash etc.
Any exception due to these should be
handled by the services.
This feature imparts robustness to the
application.
Java mandates this feature for any RMI
service.
5/28/2016
B.Ramamurthy
21
Implementing the Remote
Interface
import java.rmi.*;
import java.rmi.server.*;
import java.net.*;
// others as needed
TemperatureServerImpl
extends UnicastRemoteObject
implements TemperatureServer {
5/28/2016
B.Ramamurthy
22
TemperatureServerImpl
This class’s constructor calls a private method
which in turn:
1. Connects to the url specified
2. Streams into a buffer the page referenced.
3. Parses the buffer to get the required data.
4. Creates an array of weather information.
5/28/2016
B.Ramamurthy
23
TemperatureServerImpl
(contd.)
It implements the service method
getWeatherInfo which simply returns
the weather data gathered.
The main method instantiates an object
for the service, and registers it with
rmiregistry.
5/28/2016
B.Ramamurthy
24
Streaming URLs
Using the openStream of java.net.URL class
you can stream in the file spefied by an
universal resource locator(url).
It can be streamed into a buffer where it can
be analyzed for information.
Any number of urls can be streamed in.
Unicast Communication : When you are
interested in a particular remote site you will
direct your net connection to that particular
site using unicast.
5/28/2016
B.Ramamurthy
25
Server Object Name
Syntax for the server object name is:
//host:port/remoteObjectName
Default port number for rmiregistry is 1099
For local host the object name:
//localhost/TempServer
For a remote host
//127.0.0.1/TempServer
5/28/2016
B.Ramamurthy
26
Name Binding
rebind method binds a server’s object
name to the object’s name as it is in the
registry.
Clients use the name in the registry.
There is also a bind() method.
But rebind is better since it binds the
most recently registered object.
5/28/2016
B.Ramamurthy
27
WeatherInfo class
It is very traditional class for keeping
the information about the temperature
at a single location.
It has data fields : cityName,
temperature, and description and get
methods for these.
An array of objects of this class is used
in the server implementation.
5/28/2016
B.Ramamurthy
28
Temperature Client
import java.rmi.*;
// import other packages
constructor calls a private method
getRemoteTemp which takes care of
lookup of remote object and access.
In this application it also displays the
information.
5/28/2016
B.Ramamurthy
29
Temperature Client (contd.)
The main method in this client can get
the IP address of the remote host as a
command line argument.
Command line argument is an array of
String of items in the command line
after the name of the application.
5/28/2016
B.Ramamurthy
30
Client Details
The name of the server object along
with the IP of the remote location is
used in Naming class’s lookup method
to get an object reference.
This object reference is then used for
remote method calls.
Observe that there is no difference
between the local and remote call.
5/28/2016
B.Ramamurthy
31
WeatherItem class
Is used in the Graphical display of the
weather information.
5/28/2016
B.Ramamurthy
32
Preparing the Application
1. Compile all the class using javac.
2. Generate the stub and the skeleton:
rmic -v1.2 TemperatureServerImpl
3. Then start the registry (this will be
running as a daemon)
rmiregistry &
5/28/2016
B.Ramamurthy
33
Preparing the Application
4. Run the server which will register with the
RMI registry.
Java TemperatureServerImpl &
5. Run the client.
Java TemperatureClient &
or
java TemperatureClient {IPAddress}
java TemperatureClient 192.168.0.150
5/28/2016
B.Ramamurthy
34
Summary
We discussed the various models of
distributes systems.
Java RMI was used to illustrate the
distributed system concepts.
Temperature examples shown illustrates
some of the distributed system model
discussed and all the important RMI
features.
5/28/2016
B.Ramamurthy
35
Download