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

GroupRequest
public class GroupRequest implements RspCollector,Command(Code)
Sends a message to all members of the group and waits for all responses (or timeout). Returns a boolean value (success or failure). Results (if any) can be retrieved when done.

The supported transport to send requests is currently either a RequestCorrelator or a generic Transport. One of them has to be given in the constructor. It will then be used to send a request. When a message is received by either one, the receiveResponse() of this class has to be called (this class does not actively receive requests/responses itself). Also, when a view change or suspicion is received, the methods viewChange() or suspect() of this class have to be called.

When started, an array of responses, correlating to the membership, is created. Each response is added to the corresponding field in the array. When all fields have been set, the algorithm terminates. This algorithm can optionally use a suspicion service (failure detector) to detect (and exclude from the membership) fauly members. If no suspicion service is available, timeouts can be used instead (see execute()). When done, a list of suspected members can be retrieved.

Because a channel might deliver requests, and responses to different requests, the GroupRequest class cannot itself receive and process requests/responses from the channel. A mechanism outside this class has to do this; it has to determine what the responses are for the message sent by the execute() method and call receiveResponse() to do so.

Requirements: lossless delivery, e.g. acknowledgment-based message confirmation.
author:
   Bela Ban
version:
   $Revision: 1.21.2.2 $



Field Summary
final public static  intGET_ABS_MAJORITY
    
final public static  intGET_ALL
    
final public static  intGET_FIRST
    
final public static  intGET_MAJORITY
    
final public static  intGET_N
    
final public static  intGET_NONE
    
protected  RequestCorrelatorcorr
    
protected  booleandone
    
protected  intexpected_mbrs
    
protected  Messagerequest_msg
    
protected  intrsp_mode
    
protected  longtimeout
    
protected  Transporttransport
    

Constructor Summary
public  GroupRequest(Message m, RequestCorrelator corr, Vector members, int rsp_mode)
    
Parameters:
  m - The message to be sent
Parameters:
  corr - The request correlator to be used.
public  GroupRequest(Message m, RequestCorrelator corr, Vector members, int rsp_mode, long timeout, int expected_mbrs)
    
Parameters:
  timeout - Time to wait for responses (ms).
public  GroupRequest(Message m, Transport transport, Vector members, int rsp_mode)
    
public  GroupRequest(Message m, Transport transport, Vector members, int rsp_mode, long timeout, int expected_mbrs)
    
Parameters:
  timeout - Time to wait for responses (ms).

Method Summary
public  booleanexecute()
    
public  booleanexecute(boolean use_anycasting)
     Sends the message.
public  AddressgetCaller()
    
public  intgetNumSuspects()
    
public  RspListgetResults()
    
public  VectorgetSuspects()
    
public  booleanisDone()
    
public  voidreceiveResponse(Object response_value, Address sender)
     Callback (called by RequestCorrelator or Transport). Adds a response to the response table.
final public  voidreset(Vector mbrs)
     This method sets the membership variable to the value of members.
public  voidsetCaller(Address caller)
    
public  voidsuspect(Address suspected_member)
     Callback (called by RequestCorrelator or Transport). Report to GroupRequest that a member is reported as faulty (suspected). This method would probably be called when getting a suspect message from a failure detector (where available).
public  StringtoString()
    
public  voidviewChange(View new_view)
     Any member of 'membership' that is not in the new view is flagged as SUSPECTED.

Field Detail
GET_ABS_MAJORITY
final public static int GET_ABS_MAJORITY(Code)
return majority (of all members, may block)



GET_ALL
final public static int GET_ALL(Code)
return all responses



GET_FIRST
final public static int GET_FIRST(Code)
return only first response



GET_MAJORITY
final public static int GET_MAJORITY(Code)
return majority (of all non-faulty members)



GET_N
final public static int GET_N(Code)
return n responses (may block)



GET_NONE
final public static int GET_NONE(Code)
return no response (async call)



corr
protected RequestCorrelator corr(Code)



done
protected boolean done(Code)



expected_mbrs
protected int expected_mbrs(Code)



request_msg
protected Message request_msg(Code)



rsp_mode
protected int rsp_mode(Code)



timeout
protected long timeout(Code)



transport
protected Transport transport(Code)




Constructor Detail
GroupRequest
public GroupRequest(Message m, RequestCorrelator corr, Vector members, int rsp_mode)(Code)

Parameters:
  m - The message to be sent
Parameters:
  corr - The request correlator to be used. A request correlator sends requests tagged witha unique ID and notifies the sender when matching responses are received. Thereason GroupRequest uses it instead of a Transport isthat multiple requests/responses might be sent/received concurrently.
Parameters:
  members - The initial membership. This value reflects the membership to which the requestis sent (and from which potential responses are expected). Is reset by reset().
Parameters:
  rsp_mode - How many responses are expected. Can be
  1. GET_ALL: wait for all responses from non-suspected members.A suspicion service might warnus when a member from which a response is outstanding has crashed, so it canbe excluded from the responses. If no suspision service is available, atimeout can be used (a value of 0 means wait forever). If a timeout of0 is used, no suspicion service is available and a member from which weexpect a response has crashed, this methods blocks forever !.
  2. GET_FIRST: wait for the first available response.
  3. GET_MAJORITY: wait for the majority of all responses. Themajority is re-computed when a member is suspected.
  4. GET_ABS_MAJORITY: wait for the majority ofall members.This includes failed members, so it may block if no timeout is specified.
  5. GET_N: wait for N members.Return if n is >= membership+suspects.
  6. GET_NONE: don't wait for any response. Essentially send anasynchronous message to the group members.



GroupRequest
public GroupRequest(Message m, RequestCorrelator corr, Vector members, int rsp_mode, long timeout, int expected_mbrs)(Code)

Parameters:
  timeout - Time to wait for responses (ms). A value of <= 0 means wait indefinitely(e.g. if a suspicion service is available; timeouts are not needed).



GroupRequest
public GroupRequest(Message m, Transport transport, Vector members, int rsp_mode)(Code)



GroupRequest
public GroupRequest(Message m, Transport transport, Vector members, int rsp_mode, long timeout, int expected_mbrs)(Code)

Parameters:
  timeout - Time to wait for responses (ms). A value of <= 0 means wait indefinitely(e.g. if a suspicion service is available; timeouts are not needed).




Method Detail
execute
public boolean execute() throws Exception(Code)



execute
public boolean execute(boolean use_anycasting) throws Exception(Code)
Sends the message. Returns when n responses have been received, or a timeout has occurred. n can be the first response, all responses, or a majority of the responses.



getCaller
public Address getCaller()(Code)



getNumSuspects
public int getNumSuspects()(Code)



getResults
public RspList getResults()(Code)
Returns the results as a RspList



getSuspects
public Vector getSuspects()(Code)



isDone
public boolean isDone()(Code)



receiveResponse
public void receiveResponse(Object response_value, Address sender)(Code)
Callback (called by RequestCorrelator or Transport). Adds a response to the response table. When all responses have been received, execute() returns.



reset
final public void reset(Vector mbrs)(Code)
This method sets the membership variable to the value of members. It requires that the caller already hold the rsp_mutex lock.
Parameters:
  mbrs - The new list of members



setCaller
public void setCaller(Address caller)(Code)



suspect
public void suspect(Address suspected_member)(Code)
Callback (called by RequestCorrelator or Transport). Report to GroupRequest that a member is reported as faulty (suspected). This method would probably be called when getting a suspect message from a failure detector (where available). It is used to exclude faulty members from the response list.



toString
public String toString()(Code)



viewChange
public void viewChange(View new_view)(Code)
Any member of 'membership' that is not in the new view is flagged as SUSPECTED. Any member in the new view that is not in the membership (ie, the set of responses expected for the current RPC) will not be added to it. If we did this we might run into the following problem:
  • Membership is {A,B}
  • A sends a synchronous group RPC (which sleeps for 60 secs in the invocation handler)
  • C joins while A waits for responses from A and B
  • If this would generate a new view {A,B,C} and if this expanded the response set to {A,B,C}, A would wait forever on C's response because C never received the request in the first place, therefore won't send a response.



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.