Distributed Systems Assignment
General Instructions: Please answer the following questions clearly and concisely. Where
appropriate, use examples to illustrate your points. Reference concepts directly from the textbook
where applicable. For the programming question, ensure your code compiles, runs, and follows good
programming practices, addressing the specific requirements.
Question 1: Goals and Challenges of Distributed Systems (Chapter 1)
Tanenbaum discusses several goals when designing distributed systems, including resource
sharing, distribution transparency, openness, and scalability.
o (a) Select three different forms of distribution transparency (e.g., access, location,
migration, replication, concurrency, failure). For each selected form, define it clearly
and provide a practical example illustrating why it is desirable in a distributed system.
o (b) Discuss two major challenges or pitfalls (as outlined in Chapter 1, e.g.,
complexity, security, failure handling, concurrency) faced when trying to achieve
these goals, explaining how they complicate the design and implementation of
distributed systems.
Question 2: Architectural Styles and System Architectures (Chapter 2)
Chapter 2 contrasts different architectural styles and system architectures. Consider the
traditional Client-Server model and Peer-to-Peer (P2P) architectures (both structured and
unstructured).
o (a) Compare and contrast the Client-Server architecture with Decentralized Peer-to-
Peer architectures regarding scalability, fault tolerance, and ease of management.
o (b) Briefly explain the fundamental difference between a structured P2P system (like
a Distributed Hash Table - DHT) and an unstructured P2P system in terms of data
lookup and overlay network organization.
Question 3: Processes, Threads, and Code Migration (Chapter 3)
Chapter 3 explores fundamental concepts like processes, threads, and the migration of code
and execution state in distributed environments.
o (a) Compare and contrast the use of processes versus threads for implementing
concurrent components within a distributed system node (e.g., a server, agent, or
peer). Discuss their key differences concerning:
Resource consumption (memory, creation overhead)
Inter-component communication mechanisms (efficiency, complexity)
Fault isolation (impact of a failure in one component on others)
Provide a specific scenario within a distributed system where using multiple
processes might be advantageous despite higher overhead, and another
scenario where threads would likely be the preferred choice for concurrency.
o (b) Explain the concept of code migration in distributed systems. Discuss at least
two primary motivations for migrating code (e.g., reducing communication overhead,
achieving flexibility, load balancing). Describe the difference between weak
mobility (code segment migration, e.g., Java applets/servlets) and strong
mobility (execution segment migration, including process state). What are some
significant security and state management challenges associated with implementing
code migration, especially strong mobility?
Question 4: Communication Paradigms - RPC vs. Message-Oriented Middleware (Chapter 4)
Chapter 4 details various communication mechanisms, including Remote Procedure Calls
(RPC) and Message-Oriented Middleware (MOM).
o (a) Describe the basic steps involved in making a Remote Procedure Call, from the
client's perspective initiating the call to receiving the result. Highlight the role of client
and server stubs in achieving transparency.
o (b) Compare RPC with asynchronous Message-Oriented Communication (e.g., using
message queues). Discuss the differences in terms of coupling (temporal and
spatial), synchronicity, reliability semantics (e.g., handling failures), and suitability for
different types of distributed applications (e.g., tightly integrated systems vs. loosely
coupled event-driven systems).
Question 5: Multi-Tier Distributed Inventory Management System using Java RMI and MySQL
This question requires you to design and implement a multi-tier distributed inventory
management system. Clients with a graphical user interface (GUI) will interact via Java RMI
with an application server, which in turn manages inventory data persistently stored in a
MySQL database.
Note: This assignment emphasizes the separation of concerns in a multi-tier architecture,
using RMI for inter-tier communication (Client <-> App Server), JDBC for database
interaction (App Server <-> DB Server), and addressing data persistence.
o System Architecture (3-Tier):
1. Client Tier: Java GUI application (Swing or JavaFX). Interacts only with the
Application Server via RMI.
2. Application Server Tier: Java RMI Server. Exposes the remote inventory
service. Contains business logic. Interacts only with the Database Server via
JDBC.
3. Database Tier: MySQL Server instance. Stores inventory data persistently.
o Requirements:
1. Database Schema (MySQL): Design and create a MySQL table
(e.g., inventory_items ) to store inventory information. It should include at
least columns for item_code (unique identifier, e.g., VARCHAR, PRIMARY
KEY), description (VARCHAR), and quantity (INT, non-negative).
2. Remote Interface ( InventoryService ): Define a Java RMI remote
interface ( [Link] ). Include methods like:
addItem(String itemCode, String description, int
initialQuantity) throws RemoteException,
InventoryException;
addStock(String itemCode, int quantityToAdd) throws
RemoteException, InventoryException;
removeStock(String itemCode, int quantityToRemove)
throws RemoteException, InventoryException;
getItemDetails(String itemCode) throws
RemoteException, InventoryException; // Should return a
Serializable object (e.g., ItemDetails ) containing description and
quantity.
getAllItems() throws RemoteException; // Should return
a [Link] of ItemDetails objects.
(Optional) Define a
custom InventoryException (extending Exception ) to wrap
database or business logic errors (like "Item Not Found", "Insufficient
Stock", "Duplicate Item Code").
3. Serializable Data Class ( ItemDetails ): Create a simple Java class
implementing [Link] to hold item details (code,
description, quantity) for transferring data between server and client.
4. Application Server Implementation
( InventoryServiceImpl ): Implement the InventoryService interface,
extending [Link] .
JDBC Interaction: Implement logic to connect to the MySQL
database using JDBC (include necessary driver). Crucially,
use PreparedStatement for all SQL operations to prevent
injection vulnerabilities. Manage database connections appropriately
(e.g., using try-with-resources or a simple connection pool if desired,
though not strictly required).
Business Logic: Implement the inventory logic (add item,
add/remove stock). For removeStock , you should first query the
current quantity and then perform the update only if sufficient stock
exists. Handle potential SQLException s and business rule violations
(e.g., insufficient stock, duplicate item), potentially wrapping them
in InventoryException .
Concurrency: The RMI server infrastructure handles incoming
requests concurrently. You should rely on the database's inherent
locking mechanisms and the atomicity of individual SQL statements
executed via JDBC. Explicit Java-level transaction management
( setAutoCommit , commit , rollback ) is NOT required for this
assignment.
5. Application Server Main ( InventoryAppServer ): Creates an instance
of InventoryServiceImpl , establishes database connection details, and
registers the service with the RMI registry. Handle exceptions during startup.
6. Client GUI Application ( InventoryClientGUI ):
Implement a user interface using Java Swing (or JavaFX if preferred).
Allow users to input data (item code, description, quantity) and trigger
actions via buttons (Add Item, Add Stock, Remove Stock, Get Details,
List All).
Display results and item lists (e.g., in a JTextArea or JTable ).
On startup, look up the remote InventoryService from the RMI
registry.
Button actions should invoke the corresponding RMI methods on the
remote service.
Display feedback to the user (success messages, error messages
based on caught RemoteException or InventoryException ).
(Consideration) For better GUI responsiveness, long-running RMI
calls could be executed in background threads (e.g.,
using SwingWorker ), but this is optional.
o Deliverables:
SQL script ( [Link] ) to create the necessary MySQL table.
Source code files
( [Link] , [Link] , InventoryServiceImp
[Link] , [Link] , [Link] , Inv
[Link] (if used)).
Clear, step-by-step instructions covering:
MySQL database and table setup.
Including the MySQL JDBC driver JAR during compilation/runtime.
Compiling all Java files.
Starting the RMI registry ( rmiregistry ).
Running the InventoryAppServer (specify database connection
details if not hardcoded).
Running the InventoryClientGUI .
Instructions on how to run multiple instances of the client, potentially
from different machines (mentioning necessary configuration
like [Link] on the server if testing across
machines).
Code comments explaining the RMI implementation, JDBC interaction
(especially the use of PreparedStatement ), and GUI event handling logic.