Title: System Models
1System Models
2Fundamental 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.
3System 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.
4Architectural 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.
5Software and hardware service layers in
distributed systems
6Middleware
- 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, MSs DCOM.
7Clients invoke individual servers
EX 1. File server, 2. Web crawler
EX Web server
EX browser, web client
8A service provided by multiple servers
EX akamai, altavista, Suns NIS (data
replication)
9Web proxy server and caches
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/
10A distributed application based on peer processes
Ex distributed Whiteboard Application EJB-base
d?
11Web applets
EX Look at Object by value in CORBA
12Java Object Serialization
- The capability to store and retrieve Java objects
is essential to building persistence and
streaming into application. - We will discuss details about Serialization and
saving and restoring objects in files/streams.
13Object Serialization
- Key to storing and retrieving objects is
representing the state of the objects in a
serialized form sufficient to reconstruct the
objects. - Object ltgtbyte stream, other data to help in
reconstruction - Converting an object into an organized byte form
for storage, streaming etc.
14How to use Serialization?
- 1. import java.io.
- 2. Implement java.io.Serialization interface.
- 3. Use writeObject and readObject methods whose
header are as given below - void writeObject (Object obj) throws
IOException - Object readObject() thorws ClassNotFoundExcepti
on, IOException
15Writing to an Object Stream
- // serilaize various objects into a file
- FileOutputStream f new FileOutputStream(tmp)
- ObjectOutputStream s new ObjectOutputStream(f)
- s.writeObject(Today)
- s.writeObject(new Date())
- Theater t new Theater(4,6,10)
- //4 shows, 6 rows, 10 cols
- s.writeObject(t)
16Reading from an Object Stream
- // Deserialize a objects from a file
- FileInputStream inf new FileInputStream(tmp)
- ObjectInputStream s1 new ObjectInputStream(inf)
- //read the Object and cast to retrieve the
- // actual object
- String (String)s1.readObject()
- Data date (Date)s1.readObject()
17Exception Handling
- When a condition arises that the currently
executing code cannot handle an exception occurs. - Such conditions require special exception
handling facilities. - Traditionally these were handled by function
return value.
18Basics of Java Exception Handling
- Use try, throw, catch primitives.
- Enclose the code that you expect to result in an
exception within a try block - Attach a catch block that contains the code to
handle the exception, following the try block.
Use throw to transfer control to catch an
exception (thrown). - There can be many catch blocks following a single
try to process the various types of exceptions.
19Try blocks
- Syntax
- try
- normal statements
- statements that may result in exceptions
//dynamic scope - throw happens from here
-
20Throwing an Exception
- throw is a keyword that can be used to announce
that an exception has occurred. - Throw normally specifies one operand.
- Thrown operand is an Object an object of
Exception class is thrown. - When an exception is thrown, control exits the
try block and proceeds to the appropriate catch
handler after the try block.
21Catching an Exception
- Exception handlers are located within catch
blocks. - Each catch block starts with the keyword catch
followed by parentheses containing a type of the
exception this catch can handle. - This is followed by the code for handling the
exception enclosed within parentheses.
22Exception handling examples
- For distributed computing Ex waiting for other
host to respond. - When dynamically allocating memory (large
chunks). - In large projects to handle error processing in a
uniform manner project-wide.
23Java Exception class
- java.lang.Exception class
- public class Exception extends Throwable
- public Exception() super()
- public Exception(String s)super(s)
24User-defined Exception class
- For every project you implement you need to have
a project dependent exception class so that
objects of this type can be thrown. - Java API also supports an extensive list of
Exceptions.