se.kth.leiflindback.distdb.db
Class DBHandler

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

public class DBHandler
extends org.jgroups.ReceiverAdapter

This class handles all communication betwwen clients and database (that is, the bank account). UDP multicast is used without any form of delivery control or ordering.


Constructor Summary
DBHandler(Account account)
          Creates a new instance that updates the specified account.
 
Method Summary
 byte[] getState()
          Called by the jgroups runtime when som other node needs the groups state.
static void main(java.lang.String[] args)
          Starts a database server.
 void receive(org.jgroups.Message msg)
          Called by the jgroups runtime when a message has arrived.
 void setState(byte[] state)
          Called by the jgroups runtime when this node has requested state info.
 void start(java.lang.String config)
          Starts the database server.
 void stop()
          Stops the database server.
 
Methods inherited from class org.jgroups.ReceiverAdapter
block, suspect, viewAccepted
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DBHandler

public DBHandler(Account account)
Creates a new instance that updates the specified account.

Parameters:
account - The account managed by this instance.
Method Detail

receive

public void receive(org.jgroups.Message msg)
Called by the jgroups runtime when a message has arrived.

Specified by:
receive in interface org.jgroups.MessageListener
Overrides:
receive in class org.jgroups.ReceiverAdapter
Parameters:
msg - The newly arrived message.

getState

public byte[] getState()
Called by the jgroups runtime when som other node needs the groups state.

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

setState

public void setState(byte[] state)
Called by the jgroups runtime when this node has requested state info.

Specified by:
setState in interface org.jgroups.MessageListener
Overrides:
setState in class org.jgroups.ReceiverAdapter
Parameters:
state - The current state of the group.

stop

public void stop()
Stops the database server.


start

public void start(java.lang.String config)
Starts the database server.

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

main

public static void main(java.lang.String[] args)
Starts a database server.