Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Distributed Banking System Build a distributed bank system Your bank has branche

ID: 3831982 • Letter: D

Question

Distributed Banking System

Build a distributed bank system Your bank has branches. Each branch manages its accounts. Customers should be able to invoke Deposit, Withdraw, Query and Transfer functions. Implement each branch as two separate applications. The branch server stores account balances and performs operations. The branch GUI manages a window that enables users to invoke the four functions listed above and see the results of their execution;

Each Branch Server is executed by its own Java virtual machine. Each branch GUI, a software-approximation for an ATM machine, is executed by its own Java virtual machine. Each Branch Server receive messages from other branch servers and branch GUI's. The branch GUI is allowed to engage in bi-directional communication with its corresponding Branch Server.

Account numbers should be able to identify the branch and an individual account within that branch. Branch Server receives messages that specify operations to perform on accounts. A Transfer operation can be ignored unless source Account is managed by the current branch and Destination Account is managed by a branch that is directly connected.

Specify an interesting interconnection topology for a multi-branch bank. The topology of your banking network can be accessed by Branch Servers and branch GUI's. Each Java virtual machine is allowed to send messages to another Java virtual machine. Introduce my neighbors operation that returns the names of all directly reachable components from the invoker.

Extend the branchGUI with an additional "button" that allows a user to request an all-bank global snapshot of all non-zero accounts and in-process Transfer operations.

Implement one or more of the following distributed algorithms:

1. Distributed Chandy-Lamport snapshot algorithm that computes the assets of the distributed bank.

a. One snapshot from one branch GUI is in progress at any time in a satisfactory implementation. While that snapshot operation runs, new Deposit, Withdraw, Query, or Transfer operations are delayed and not processed by branch servers. This implementation is satisfactory.

b. Multiple concurrent snapshots from different branch GUI's can be in progress at any time in a good implementation. The snapshots each proceed independently. While the snapshot operation runs, new Deposit, Withdraw, Query, and Transfer operations are not delayed by branch servers. This is a very good implementation.

c. In an excellent implementation the snapshots do not necessarily proceed independently, sharing work when this is possible.

2. Primary back up or any other algorithm for fault tolerance

3. Failure detection.

Explanation / Answer


import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.rmi.UnknownHostException;

public class Client {
public static void main(String[] args) {
ATM atm = null;
try {
ATMFactory factory = (ATMFactory)Naming.lookup("//localhost/atmfactory");
atm = factory.getATM();
} catch (MalformedURLException mue) {
mue.printStackTrace();
} catch (NotBoundException nbe) {
nbe.printStackTrace();
} catch (UnknownHostException uhe) {
uhe.printStackTrace();
} catch (RemoteException re) {
re.printStackTrace();
}
if (atm!=null) {
try {

System.out.println("Initial Balances");
System.out.println("Balance(0000001): "+atm.getBalance(0000001));
System.out.println("Balance(0000002): "+atm.getBalance(0000002));
System.out.println("Balance(0000003): "+atm.getBalance(0000003));
System.out.println();

System.out.println("Depositting(0000001): 1000 ");
atm.deposit(0000001, 1000);
System.out.println("Balance(0000001): "+atm.getBalance(0000001));

System.out.println("Withdrawing(0000002): 100 ");
atm.withdraw(0000002, 100);
System.out.println("Balance(0000002): "+atm.getBalance(0000002));

System.out.println("Depositting(0000003): 500 ");
atm.deposit(0000003, 500);
System.out.println("Balance(0000003): "+atm.getBalance(0000003));

System.out.println();
System.out.println("Final Balances");
System.out.println("Balance(0000001): "+atm.getBalance(0000001));
System.out.println("Balance(0000002): "+atm.getBalance(0000002));
System.out.println("Balance(0000003): "+atm.getBalance(0000003));
} catch (RemoteException re) {
System.out.println("An exception occurred while communicating with the ATM");
re.printStackTrace();
}
}
}
}