Distributed Systems
Distributed Systems
The Internet
1. Architectural Models
a. Client-Server Model
Characteristics:
Advantages:
o Simplified security.
Disadvantages:
Definition: All nodes (peers) in the system are equal and can act as
both clients and servers.
Characteristics:
o Decentralized architecture.
Advantages:
Disadvantages:
c. Hybrid Model
Advantages:
Disadvantages:
2. Interaction Models
a. Synchronous Communication
Characteristics:
Advantages:
Disadvantages:
b. Asynchronous Communication
Characteristics:
Advantages:
Disadvantages:
3. Failure Models
a. Crash Failures
Impact:
b. Omission Failures
Impact:
c. Timing Failures
Impact:
d. Byzantine Failures
Impact:
4. Consistency Models
a. Strict Consistency
Characteristics:
Advantages:
Disadvantages:
b. Eventual Consistency
Characteristics:
Advantages:
Disadvantages:
c. Causal Consistency
Characteristics:
Advantages:
Disadvantages:
1. Transparency
2. Scalability
3. Reliability
4. Resource Management
5. Communication
6. Security
Models of IPC
o Key Features:
o Advantages:
o Disadvantages:
Steps in an RPC:
Implementation Issues:
1. Transparency:
2. Stub Generation:
4. Error Handling:
Advantages:
Difficult to handle partial failures (e.g., when only part of the system
crashes).
1. Point-to-Point Communication:
o Characteristics:
2. Group Communication:
o Characteristics:
Client-Server Model:
Implementation:
Socket Programming
1. Server Side:
o Create a socket.
2. Client Side:
o Create a socket.
Socket Types:
Case Studies
1. SUN RPC:
2. DEC RPC:
Features:
Introduction
Defined as:
Logical Clocks:
1. Lamport Clocks:
o Rules:
2. Vector Clocks:
Due to the absence of a global clock, nodes must synchronize their clocks
to maintain consistency.
Types of Synchronization:
1. External Synchronization:
2. Internal Synchronization:
1. Cristian’s Algorithm:
o Steps:
2. Berkeley Algorithm:
o Steps:
Mutual exclusion ensures that only one process accesses a critical section
at any time.
1. Centralized Algorithm:
o Steps:
2. Ricart-Agrawala Algorithm:
o Steps:
3. Token-Based Algorithms:
2. Hold and Wait: Processes hold resources while waiting for others.
o Preempting resources.
o Terminating processes.
Deadlock Prevention:
Examples:
o Allow preemption.
Election Algorithms
Requirements:
Fault tolerance.
Popular Algorithms:
1. Bully Algorithm:
o Assumes processes have unique IDs.
o Steps:
2. Ring Algorithm:
o Steps:
Introduction
RMI is inherently built into Java and uses standard Java objects and
interfaces. The communication between different JVMs is done using
serialization (converting objects to byte streams for transmission) and
TCP/IP (for reliable communication over the network).
Key Concepts in RMI
1. Remote Objects:
2. Stub:
o The stub is the object that the client interacts with when it
calls a method on a remote object.
4. RMI Registry:
5. Transport Layer:
1. Client-Server Model:
o The client interacts with the stub, which sends the request
over the network to the skeleton (or the dynamic dispatcher in
modern RMI) on the server.
o Client Side:
o Server Side:
3. Serialization:
4. RMI Registry:
Components of RMI
1. Remote Interface
java
Copy code
import java.rmi.Remote;
import java.rmi.RemoteException;
java
Copy code
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
super();
@Override
Stub: Acts as a proxy for the client. It handles the task of making
the remote call on behalf of the client and returning the response.
4. Naming Class
The Naming class provides utility methods for binding and looking
up remote objects in the RMI registry.
The Naming.rebind() method binds a remote object to a name in the
registry, while Naming.lookup() retrieves the object reference based
on the name.
java
Copy code
Naming.rebind("rmi://localhost/MyRemoteService", myRemoteObject);
5. Transport Layer
The transport layer is responsible for ensuring that the method call
and its result are transmitted reliably across the network.
RMI also supports client callbacks, which allow the server to invoke
methods on the client. This creates a two-way communication between
the client and server. A common use case is in event-driven systems,
where the server notifies the client of specific events (e.g., progress
updates, alerts).
2. The client can export the callback object, allowing the server to call
methods on the client’s object.
Example:
java
Copy code
import java.rmi.Remote;
import java.rmi.RemoteException;
java
Copy code
client.notify("Event occurred!");
1. The server specifies the location (URL) of the stub classes using the
java.rmi.server.codebase system property.
3. The stub class is loaded and used by the client to invoke remote
methods.
Example Command:
bash
Copy code
In CORBA:
idl
Copy code
interface MyObject {
};
IIOP can be used over both local and wide-area networks (LAN and
WAN).
IIOP is the core protocol of CORBA for enabling communication between
distributed objects across different ORBs.
Object Server:
o The server registers its objects with the ORB, which provides
clients with the necessary references to access remote
objects.
Object Client:
o The client does not need to know the actual location of the
object; it only interacts with the stub, which acts as a local
representative of the remote object.
Object Registration:
Object Lookup:
Example:
java
Copy code
NamingContextExt namingContext =
NamingContextExtHelper.narrow(orb.resolve_initial_references("NameServ
ice"));
Transaction Service:
o Manages distributed transactions across multiple objects,
ensuring that operations are committed or rolled back in a
consistent and coordinated manner.
Security Service:
Event Service:
Persistence Service:
Lifecycle Service:
Component Description
Thread Management:
Centralized Model:
Decentralized Model:
Hybrid Model:
Processor Allocation:
Scheduling Algorithms:
Types of Faults:
Timing faults: Occur when processes are out of sync or take too
long to complete a task.
Characteristics: