Java Doc for MessageDispatcher.java in  » Net » JGroups-2.4.1-sp3 » org » jgroups » blocks » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Net » JGroups 2.4.1 sp3 » org.jgroups.blocks 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.jgroups.blocks.MessageDispatcher

All known Subclasses:   org.jgroups.blocks.RpcDispatcher,
MessageDispatcher
public class MessageDispatcher implements RequestHandler(Code)
Provides synchronous and asynchronous message sending with request-response correlation; i.e., matching responses with the original request. It also offers push-style message reception (by internally using the PullPushAdapter).

Channels are simple patterns to asynchronously send a receive messages. However, a significant number of communication patterns in group communication require synchronous communication. For example, a sender would like to send a message to the group and wait for all responses. Or another application would like to send a message to the group and wait only until the majority of the receivers have sent a response, or until a timeout occurred. MessageDispatcher offers a combination of the above pattern with other patterns.

Used on top of channel to implement group requests. Client's handle() method is called when request is received. Is the equivalent of RpcProtocol on the application instead of protocol level.
author:
   Bela Ban
version:
   $Id: MessageDispatcher.java,v 1.60.2.3 2007/03/08 10:14:45 belaban Exp $


Inner Class :class ProtocolAdapter extends Protocol implements UpHandler
Inner Class :class TransportAdapter implements Transport
Inner Class :class PullPushHandler implements ExtendedMessageListener,MembershipListener

Field Summary
protected  PullPushAdapteradapter
    
protected  Channelchannel
    
protected  booleanconcurrent_processing
     Process items on the queue concurrently (RequestCorrelator).
protected  RequestCorrelatorcorr
    
protected  booleandeadlock_detection
    
protected  PullPushHandlerhandler
    
protected  Serializableid
    
protected  Addresslocal_addr
    
final protected  Loglog
    
final protected  Collectionmembers
    
protected  MembershipListenermembership_listener
    
protected  MessageListenermsg_listener
    
protected  ProtocolAdapterprot_adapter
    
protected  RequestHandlerreq_handler
    
protected  TransportAdaptertransport_adapter
    

Constructor Summary
public  MessageDispatcher(Channel channel, MessageListener l, MembershipListener l2)
    
public  MessageDispatcher(Channel channel, MessageListener l, MembershipListener l2, boolean deadlock_detection)
    
public  MessageDispatcher(Channel channel, MessageListener l, MembershipListener l2, boolean deadlock_detection, boolean concurrent_processing)
    
public  MessageDispatcher(Channel channel, MessageListener l, MembershipListener l2, RequestHandler req_handler)
    
public  MessageDispatcher(Channel channel, MessageListener l, MembershipListener l2, RequestHandler req_handler, boolean deadlock_detection)
    
public  MessageDispatcher(Channel channel, MessageListener l, MembershipListener l2, RequestHandler req_handler, boolean deadlock_detection, boolean concurrent_processing)
    
public  MessageDispatcher(PullPushAdapter adapter, Serializable id, MessageListener l, MembershipListener l2)
    
public  MessageDispatcher(PullPushAdapter adapter, Serializable id, MessageListener l, MembershipListener l2, RequestHandler req_handler)
    
public  MessageDispatcher(PullPushAdapter adapter, Serializable id, MessageListener l, MembershipListener l2, RequestHandler req_handler, boolean concurrent_processing)
    

Method Summary
public  RspListcastMessage(Vector dests, Message msg, int mode, long timeout)
    
public  RspListcastMessage(Vector dests, Message msg, int mode, long timeout, boolean use_anycasting)
     Cast a message to all members, and wait for mode responses.
public  voidcastMessage(Vector dests, long req_id, Message msg, RspCollector coll)
     Multicast a message request to all members in dests and receive responses via the RspCollector interface.
protected  voidcorrelatorStarted()
    
public  voiddone(long req_id)
    
public  ChannelgetChannel()
     Offers access to the underlying Channel.
protected  CollectiongetMembers()
    
public  MessageListenergetMessageListener()
     Gives access to the currently configured MessageListener.
public  Objecthandle(Message msg)
    
public  voidsend(Message msg)
    
public  ObjectsendMessage(Message msg, int mode, long timeout)
     Sends a message to a single member (destination = msg.dest) and returns the response.
public  voidsetConcurrentProcessing(boolean flag)
    
public  voidsetDeadlockDetection(boolean flag)
    
final public  voidsetMembershipListener(MembershipListener l)
    
final public  voidsetMessageListener(MessageListener l)
    
final public  voidsetRequestHandler(RequestHandler rh)
    
final public  voidstart()
    
public  voidstop()
    

Field Detail
adapter
protected PullPushAdapter adapter(Code)



channel
protected Channel channel(Code)



concurrent_processing
protected boolean concurrent_processing(Code)
Process items on the queue concurrently (RequestCorrelator). The default is to wait until the processing of an item has completed before fetching the next item from the queue. Note that setting this to true may destroy the properties of a protocol stack, e.g total or causal order may not be guaranteed. Set this to true only if you know what you're doing !



corr
protected RequestCorrelator corr(Code)



deadlock_detection
protected boolean deadlock_detection(Code)



handler
protected PullPushHandler handler(Code)



id
protected Serializable id(Code)



local_addr
protected Address local_addr(Code)



log
final protected Log log(Code)



members
final protected Collection members(Code)



membership_listener
protected MembershipListener membership_listener(Code)



msg_listener
protected MessageListener msg_listener(Code)



prot_adapter
protected ProtocolAdapter prot_adapter(Code)



req_handler
protected RequestHandler req_handler(Code)



transport_adapter
protected TransportAdapter transport_adapter(Code)




Constructor Detail
MessageDispatcher
public MessageDispatcher(Channel channel, MessageListener l, MembershipListener l2)(Code)



MessageDispatcher
public MessageDispatcher(Channel channel, MessageListener l, MembershipListener l2, boolean deadlock_detection)(Code)



MessageDispatcher
public MessageDispatcher(Channel channel, MessageListener l, MembershipListener l2, boolean deadlock_detection, boolean concurrent_processing)(Code)



MessageDispatcher
public MessageDispatcher(Channel channel, MessageListener l, MembershipListener l2, RequestHandler req_handler)(Code)



MessageDispatcher
public MessageDispatcher(Channel channel, MessageListener l, MembershipListener l2, RequestHandler req_handler, boolean deadlock_detection)(Code)



MessageDispatcher
public MessageDispatcher(Channel channel, MessageListener l, MembershipListener l2, RequestHandler req_handler, boolean deadlock_detection, boolean concurrent_processing)(Code)



MessageDispatcher
public MessageDispatcher(PullPushAdapter adapter, Serializable id, MessageListener l, MembershipListener l2)(Code)



MessageDispatcher
public MessageDispatcher(PullPushAdapter adapter, Serializable id, MessageListener l, MembershipListener l2, RequestHandler req_handler)(Code)



MessageDispatcher
public MessageDispatcher(PullPushAdapter adapter, Serializable id, MessageListener l, MembershipListener l2, RequestHandler req_handler, boolean concurrent_processing)(Code)




Method Detail
castMessage
public RspList castMessage(Vector dests, Message msg, int mode, long timeout)(Code)



castMessage
public RspList castMessage(Vector dests, Message msg, int mode, long timeout, boolean use_anycasting)(Code)
Cast a message to all members, and wait for mode responses. The responses are returned in a response list, where each response is associated with its sender.

Uses GroupRequest.
Parameters:
  dests - The members to which the message is to be sent. If it is null, then the message is sent to allmembers
Parameters:
  msg - The message to be sent to n members
Parameters:
  mode - Defined in GroupRequest. The number of responses to wait for:

  1. GET_FIRST:return the first response received.
  2. GET_ALL: wait for all responses (minus the ones fromsuspected members)
  3. GET_MAJORITY: wait for a majority of all responses (relative to the grpsize)
  4. GET_ABS_MAJORITY: wait for majority (absolute, computed once)
  5. GET_N: wait for nresponses (may block if n > group size)
  6. GET_NONE: wait for no responses, return immediately(non-blocking)

Parameters:
  timeout - If 0: wait forever. Otherwise, wait for mode responses or timeout time. RspList A list of responses. Each response is an Object and associated to its sender.



castMessage
public void castMessage(Vector dests, long req_id, Message msg, RspCollector coll)(Code)
Multicast a message request to all members in dests and receive responses via the RspCollector interface. When done receiving the required number of responses, the caller has to call done(req_id) on the underlyinh RequestCorrelator, so that the resources allocated to that request can be freed.
Parameters:
  dests - The list of members from which to receive responses. Null means all members
Parameters:
  req_id - The ID of the request. Used by the underlying RequestCorrelator to correlate responses withrequests
Parameters:
  msg - The request to be sent
Parameters:
  coll - The sender needs to provide this interface to collect responses. Call will return immediately ifthis is null



correlatorStarted
protected void correlatorStarted()(Code)



done
public void done(long req_id)(Code)



getChannel
public Channel getChannel()(Code)
Offers access to the underlying Channel. a reference to the underlying Channel.



getMembers
protected Collection getMembers()(Code)
Returns a copy of members



getMessageListener
public MessageListener getMessageListener()(Code)
Gives access to the currently configured MessageListener. Returns null if there is no configured MessageListener.



handle
public Object handle(Message msg)(Code)



send
public void send(Message msg) throws ChannelNotConnectedException, ChannelClosedException(Code)



sendMessage
public Object sendMessage(Message msg, int mode, long timeout) throws TimeoutException, SuspectedException(Code)
Sends a message to a single member (destination = msg.dest) and returns the response. The message's destination must be non-zero !



setConcurrentProcessing
public void setConcurrentProcessing(boolean flag)(Code)



setDeadlockDetection
public void setDeadlockDetection(boolean flag)(Code)



setMembershipListener
final public void setMembershipListener(MembershipListener l)(Code)



setMessageListener
final public void setMessageListener(MessageListener l)(Code)



setRequestHandler
final public void setRequestHandler(RequestHandler rh)(Code)



start
final public void start()(Code)



stop
public void stop()(Code)



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.