se.kth.leiflindback.distdb.client
Class Bank

java.lang.Object
  extended by org.jgroups.ReceiverAdapter
      extended by se.kth.leiflindback.distdb.client.Bank
All Implemented Interfaces:
org.jgroups.MembershipListener, org.jgroups.MessageListener, org.jgroups.Receiver

public class Bank
extends org.jgroups.ReceiverAdapter

The bank deposits, withdraws and adds interest to the account. If communication is reliable all accounts should always have the same balance.


Constructor Summary
Bank(java.lang.String config)
          Constructs a new instance and connects it to a JChannel.
 
Method Summary
 void doSomeBanking()
          Randomly deposits, withdraws and adds interest.
 byte[] getState()
          Called by the jgroups runtime when som other node needs the groups state.
static void main(java.lang.String[] args)
          Starts the bank.
 
Methods inherited from class org.jgroups.ReceiverAdapter
block, receive, setState, suspect, viewAccepted
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Bank

public Bank(java.lang.String config)
Constructs a new instance and connects it to a JChannel.

Parameters:
config - The jgroups configuration. This string is passed to the JChannel constructor.
Method Detail

getState

public byte[] getState()
Called by the jgroups runtime when som other node needs the groups state. Since we do not have the state we return an instance of NullAccount, wich will pass the question to another node.

Specified by:
getState in interface org.jgroups.MessageListener
Overrides:
getState in class org.jgroups.ReceiverAdapter
Returns:
The current state of the group.

doSomeBanking

public void doSomeBanking()
Randomly deposits, withdraws and adds interest.


main

public static void main(java.lang.String[] args)
Starts the bank.