|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jgroups.ReceiverAdapter org.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 | |
---|---|
java.util.Hashtable |
getAllStocks()
|
float |
getQuote(java.lang.String stock_name)
|
void |
getState(java.io.OutputStream ostream)
Allows an application to write a state through a provided OutputStream. |
static void |
main(java.lang.String[] args)
|
void |
printAllStocks()
|
void |
setQuote(java.lang.String stock_name,
java.lang.Float value)
|
void |
setState(java.io.InputStream istream)
Allows an application to read a state through a provided InputStream. |
void |
start()
|
void |
viewAccepted(View new_view)
Called when a change in membership has occurred. |
Methods inherited from class org.jgroups.ReceiverAdapter |
---|
block, receive, suspect, unblock |
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)
ReceiverAdapter
Channel.connect(String)
returns.
viewAccepted
in interface MembershipListener
viewAccepted
in class ReceiverAdapter
public 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 getState(java.io.OutputStream ostream) throws java.lang.Exception
ReceiverAdapter
getState
in interface MessageListener
getState
in class ReceiverAdapter
ostream
- the OutputStream
java.lang.Exception
- if the streaming fails, any exceptions should be thrown so that the state requester
can re-throw them and let the caller know what happenedOutputStream.close()
public void setState(java.io.InputStream istream) throws java.lang.Exception
ReceiverAdapter
setState
in interface MessageListener
setState
in class ReceiverAdapter
istream
- the InputStream
java.lang.Exception
- if the streaming fails, any exceptions should be thrown so that the state requester
can catch them and thus know what happenedInputStream.close()
public static void main(java.lang.String[] args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |