Java Doc for RequestCorrelator.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.RequestCorrelator

RequestCorrelator
public class RequestCorrelator (Code)
Framework to send requests and receive matching responses (matching on request ID). Multiple requests can be sent at a time. Whenever a response is received, the correct RspCollector is looked up (key = id) and its method receiveResponse() invoked. A caller may use done() to signal that no more responses are expected, and that the corresponding entry may be removed.

RequestCorrelator can be installed at both client and server sides, it can also switch roles dynamically; i.e., send a request and at the same time process an incoming request (when local delivery is enabled, this is actually the default).


author:
   Bela Ban


Inner Class :final public static class Header extends org.jgroups.Header implements Streamable

Field Summary
protected  ThreadLocalcall_stack
     This field is used only if deadlock detection is enabled.
protected  booleanconcurrent_processing
     Process items on the queue concurrently (Scheduler).
protected  booleandeadlock_detection
     Whether or not to perform deadlock detection for synchronous (potentially recursive) group method invocations.
protected  Addresslocal_addr
    
final protected static  Loglog
    
protected  RpcDispatcher.Marshallermarshaller
    
protected  Stringname
    
protected  RequestHandlerrequest_handler
     The handler for the incoming requests.
final protected  Maprequests
    
protected  Schedulerscheduler
    
protected  booleanstarted
    
protected  Objecttransport
     The protocol layer to use to pass up/down messages.

Constructor Summary
public  RequestCorrelator(String name, Object transport, RequestHandler handler)
     Constructor.
public  RequestCorrelator(String name, Object transport, RequestHandler handler, Address local_addr)
    
public  RequestCorrelator(String name, Object transport, RequestHandler handler, boolean deadlock_detection)
     Constructor.
public  RequestCorrelator(String name, Object transport, RequestHandler handler, boolean deadlock_detection, boolean concurrent_processing)
    
public  RequestCorrelator(String name, Object transport, RequestHandler handler, boolean deadlock_detection, Address local_addr)
    
public  RequestCorrelator(String name, Object transport, RequestHandler handler, boolean deadlock_detection, Address local_addr, boolean concurrent_processing)
    

Method Summary
public  voiddone(long id)
     Used to signal that a certain request may be garbage collected as all responses have been received.
public  AddressgetLocalAddress()
    
public  RpcDispatcher.MarshallergetMarshaller()
    
public  voidreceive(Event evt)
     Callback.

Called by the protocol below when a message has been received.

public  booleanreceiveMessage(Message msg)
    
public  voidreceiveSuspect(Address mbr)
     Event.SUSPECT event received from a layer below.
public  voidreceiveView(View new_view)
     Event.VIEW_CHANGE event received from a layer below.
public  voidsendRequest(long id, Message msg, RspCollector coll)
     Helper method for RequestCorrelator.sendRequest(long,List,Message,RspCollector) .
public  voidsendRequest(long id, List dest_mbrs, Message msg, RspCollector coll)
    
public  voidsendRequest(long id, List dest_mbrs, Message msg, RspCollector coll, boolean use_anycasting)
     Send a request to a group.
public  voidsetConcurrentProcessing(boolean flag)
    
public  voidsetDeadlockDetection(boolean flag)
    
public  voidsetLocalAddress(Address local_addr)
    
public  voidsetMarshaller(RpcDispatcher.Marshaller marshaller)
    
public  voidsetRequestHandler(RequestHandler handler)
    
final public  voidstart()
    
 voidstartScheduler()
    
public  voidstop()
    
 voidstopScheduler()
    

Field Detail
call_stack
protected ThreadLocal call_stack(Code)
This field is used only if deadlock detection is enabled. In case of nested synchronous requests, it holds a list of the addreses of the senders with the address at the bottom being the address of the first caller



concurrent_processing
protected boolean concurrent_processing(Code)
Process items on the queue concurrently (Scheduler). 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 !



deadlock_detection
protected boolean deadlock_detection(Code)
Whether or not to perform deadlock detection for synchronous (potentially recursive) group method invocations. If on, we use a scheduler (handling a priority queue), otherwise we don't and call handleRequest() directly.



local_addr
protected Address local_addr(Code)
The address of this group member



log
final protected static Log log(Code)



marshaller
protected RpcDispatcher.Marshaller marshaller(Code)
Possibility for an external marshaller to marshal/unmarshal responses



name
protected String name(Code)
makes the instance unique (together with IDs)



request_handler
protected RequestHandler request_handler(Code)
The handler for the incoming requests. It is called from inside the dispatcher thread



requests
final protected Map requests(Code)
The table of pending requests (keys=Long (request IDs), values=RequestEntry)



scheduler
protected Scheduler scheduler(Code)
The dispatching thread pool



started
protected boolean started(Code)



transport
protected Object transport(Code)
The protocol layer to use to pass up/down messages. Can be either a Protocol or a Transport




Constructor Detail
RequestCorrelator
public RequestCorrelator(String name, Object transport, RequestHandler handler)(Code)
Constructor. Uses transport to send messages. If handler is not null, all incoming requests will be dispatched to it (via handle(Message)).
Parameters:
  name - Used to differentiate between different RequestCorrelators(e.g. in different protocol layers). Has to be unique if multiplerequest correlators are used.
Parameters:
  transport - Used to send/pass up requests. Can be either a Transport (only send() will beused then), or a Protocol (passUp()/passDown() will be used)
Parameters:
  handler - Request handler. Method handle(Message)will be called when a request is received.



RequestCorrelator
public RequestCorrelator(String name, Object transport, RequestHandler handler, Address local_addr)(Code)



RequestCorrelator
public RequestCorrelator(String name, Object transport, RequestHandler handler, boolean deadlock_detection)(Code)
Constructor. Uses transport to send messages. If handler is not null, all incoming requests will be dispatched to it (via handle(Message)).
Parameters:
  name - Used to differentiate between different RequestCorrelators(e.g. in different protocol layers). Has to be unique if multiplerequest correlators are used.
Parameters:
  transport - Used to send/pass up requests. Can be either a Transport (only send() will beused then), or a Protocol (passUp()/passDown() will be used)
Parameters:
  handler - Request handler. Method handle(Message)will be called when a request is received.
Parameters:
  deadlock_detection - When enabled (true) recursive synchronousmessage calls will be detected and processed with higher priority inorder to solve deadlocks. Slows down processing a little bit whenenabled due to runtime checks involved.



RequestCorrelator
public RequestCorrelator(String name, Object transport, RequestHandler handler, boolean deadlock_detection, boolean concurrent_processing)(Code)



RequestCorrelator
public RequestCorrelator(String name, Object transport, RequestHandler handler, boolean deadlock_detection, Address local_addr)(Code)



RequestCorrelator
public RequestCorrelator(String name, Object transport, RequestHandler handler, boolean deadlock_detection, Address local_addr, boolean concurrent_processing)(Code)




Method Detail
done
public void done(long id)(Code)
Used to signal that a certain request may be garbage collected as all responses have been received.



getLocalAddress
public Address getLocalAddress()(Code)



getMarshaller
public RpcDispatcher.Marshaller getMarshaller()(Code)



receive
public void receive(Event evt)(Code)
Callback.

Called by the protocol below when a message has been received. The algorithm should test whether the message is destined for us and, if not, pass it up to the next layer. Otherwise, it should remove the header and check whether the message is a request or response. In the first case, the message will be delivered to the request handler registered (calling its handle() method), in the second case, the corresponding response collector is looked up and the message delivered.




receiveMessage
public boolean receiveMessage(Message msg)(Code)
Handles a message coming from a layer below true if the event should be forwarded further up, otherwise false (message was consumed)



receiveSuspect
public void receiveSuspect(Address mbr)(Code)
Event.SUSPECT event received from a layer below.

All response collectors currently registered will be notified that mbr may have crashed, so they won't wait for its response.




receiveView
public void receiveView(View new_view)(Code)
Event.VIEW_CHANGE event received from a layer below.

Mark all responses from members that are not in new_view as NOT_RECEIVED.




sendRequest
public void sendRequest(long id, Message msg, RspCollector coll) throws Exception(Code)
Helper method for RequestCorrelator.sendRequest(long,List,Message,RspCollector) .



sendRequest
public void sendRequest(long id, List dest_mbrs, Message msg, RspCollector coll) throws Exception(Code)



sendRequest
public void sendRequest(long id, List dest_mbrs, Message msg, RspCollector coll, boolean use_anycasting) throws Exception(Code)
Send a request to a group. If no response collector is given, no responses are expected (making the call asynchronous).
Parameters:
  id - The request ID. Must be unique for this JVM (e.g. currenttime in millisecs)
Parameters:
  dest_mbrs - The list of members who should receive the call. Usually a group RPCis sent via multicast, but a receiver drops the request if its own addressis not in this list. Will not be used if it is null.
Parameters:
  msg - The request to be sent. The body of the message carriesthe request data
Parameters:
  coll - A response collector (usually the object that invokesthis method). Its methods receiveResponse() andsuspect() will be invoked when a message has been receivedor a member is suspected, respectively.



setConcurrentProcessing
public void setConcurrentProcessing(boolean flag)(Code)



setDeadlockDetection
public void setDeadlockDetection(boolean flag)(Code)
Switch the deadlock detection mechanism on/off
Parameters:
  flag - the deadlock detection flag



setLocalAddress
public void setLocalAddress(Address local_addr)(Code)



setMarshaller
public void setMarshaller(RpcDispatcher.Marshaller marshaller)(Code)



setRequestHandler
public void setRequestHandler(RequestHandler handler)(Code)



start
final public void start()(Code)



startScheduler
void startScheduler()(Code)



stop
public void stop()(Code)



stopScheduler
void stopScheduler()(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.