|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jgroups.demos.QuoteServer
public class QuoteServer
Example of a replicated quote server. The server maintains state which consists of a list of quotes and their corresponding values. When it is started, it tries to reach other quote servers to get its initial state. If it does not receive any response after 5 seconds, it assumes it is the first server and starts processing requests.
Any updates are multicast across the cluster
| Constructor Summary | |
|---|---|
QuoteServer()
|
|
| Method Summary | |
|---|---|
void |
block()
Called (usually by the FLUSH protocol), as an indication that the member should stop sending messages. |
java.util.Hashtable |
getAllStocks()
|
float |
getQuote(java.lang.String stock_name)
|
byte[] |
getState()
Answers the group state; e.g., when joining. |
static void |
main(java.lang.String[] args)
|
void |
printAllStocks()
|
void |
receive(Message msg)
Called when a message is received. |
void |
setQuote(java.lang.String stock_name,
java.lang.Float value)
|
void |
setState(byte[] state)
Sets the group state; e.g., when joining. |
void |
start()
|
void |
suspect(Address suspected_mbr)
Called whenever a member is suspected of having crashed, but has not yet been excluded. |
void |
viewAccepted(View new_view)
Called when a change in membership has occurred. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public QuoteServer()
| Method Detail |
|---|
public void viewAccepted(View new_view)
MembershipListenerChannel.connect(String) returns.
viewAccepted in interface MembershipListenerpublic void suspect(Address suspected_mbr)
MembershipListener
suspect in interface MembershipListenerpublic void block()
MembershipListenerExtendedMembershipListener.unblock().
Note that block() is the equivalent of reception of a BlockEvent in the pull mode.
block in interface MembershipListenerpublic void start()
public float getQuote(java.lang.String stock_name)
throws java.lang.Exception
java.lang.Exception
public void setQuote(java.lang.String stock_name,
java.lang.Float value)
public java.util.Hashtable getAllStocks()
public void printAllStocks()
public void receive(Message msg)
MessageListener
receive in interface MessageListenerpublic byte[] getState()
MessageListener
getState in interface MessageListenerpublic void setState(byte[] state)
MessageListener
setState in interface MessageListenerpublic static void main(java.lang.String[] args)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||