System Models Bina Ramamurthy 2122022 B Ramamurthy 1
System Models Bina Ramamurthy 2/12/2022 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. 2/12/2022 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. 2/12/2022 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. 2/12/2022 B. Ramamurthy 4
Software and hardware service layers in distributed systems 2/12/2022 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. 2/12/2022 B. Ramamurthy 6
Clients invoke individual servers EX: 1. File server, 2. Web crawler EX: Web server EX: browser, web client 2/12/2022 B. Ramamurthy 7
A service provided by multiple servers EX: akamai, altavista, Sun’s NIS (data replication) 2/12/2022 B. Ramamurthy 8
Web 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/ 2/12/2022 B. Ramamurthy 9
A distributed application based on peer processes Ex: distributed Whiteboard Application; EJB-based? 2/12/2022 B. Ramamurthy 10
Web applets EX: Look at Object by value in CORBA 2/12/2022 B. Ramamurthy 11
Java 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. 2/12/2022 B. Ramamurthy 12
Object Serialization Key to storing and retrieving objects is representing the “state” of the objects in a serialized form sufficient to reconstruct the objects. Object <===>byte stream, other data to help in reconstruction Converting an object into an organized byte form for storage, streaming etc. 2/12/2022 B. Ramamurthy 13
How to use Serialization? 1. import java. io. *; 2. Implement java. io. Serialization interface. 3. Use write. Object and read. Object methods whose header are as given below: void write. Object (Object obj) throws IOException; Object read. Object() thorws Class. Not. Found. Exception, IOException; 2/12/2022 B. Ramamurthy 14
Writing to an Object Stream // serilaize various objects into a file File. Output. Stream f = new File. Output. Stream(“tmp”); Object. Output. Stream s = new Object. Output. Stream(f); s. write. Object(“Today”); s. write. Object(new Date()); Theater t = new Theater(4, 6, 10); //4 shows, 6 rows, 10 cols s. write. Object(t); 2/12/2022 B. Ramamurthy 15
Reading from an Object Stream // Deserialize a objects from a file File. Input. Stream inf = new File. Input. Stream(“tmp”); Object. Input. Stream s 1 = new Object. Input. Stream(inf); //read the Object and cast to retrieve the // actual object String = (String)s 1. read. Object(); Data date = (Date)s 1. read. Object(); 2/12/2022 B. Ramamurthy 16
Exception 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. 2/12/2022 B. Ramamurthy 17
Basics 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. 2/12/2022 B. Ramamurthy 18
Try blocks Syntax: try { normal statements; statements that may result in exceptions; //dynamic scope “throw” happens from here } 2/12/2022 B. Ramamurthy 19
Throwing 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. 2/12/2022 B. Ramamurthy 20
Catching an 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. 2/12/2022 B. Ramamurthy 21
Exception 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. 2/12/2022 B. Ramamurthy 22
Java Exception class java. lang. Exception class : public class Exception extends Throwable { public Exception() { super(); } public Exception(String s){super(s); } } 2/12/2022 B. Ramamurthy 23
User-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. 2/12/2022 B. Ramamurthy 24
- Slides: 24