Class RoundRobinPolicy
- java.lang.Object
-
- org.glassfish.enterprise.iiop.impl.RoundRobinPolicy
-
public class RoundRobinPolicy extends Object
The list of endpoints are randomized the very first time. This happens only once( when called from the static block of SerialInitContextFactory class).Simple RoundRobin is a special case of Weighted Round Robin where the weight per endpoint is equal.With the dynamic reconfiguration implementation, the endpoints list will have the following structure:
- server_identifier (a stringified name for the machine) - weight- list of SocketInfo {type (type = CLEAR_TEXT or SSL) + IP address + port }
The above structure supports multi-homed machines i.e. one machine hosting multiple IP addresses. The
RoundRobinPolicy
class can be the class that is also implementing the Listener interface for listening to events generated whenever there is a change in the cluster shape. The listener/event design is still under construction.This list of endpoints will have to be created during bootstrapping(i.e. when the client first starts up.) This list will comprise of the endpoints specified by the user in "com.sun.appserv.iiop.endpoints" property. We can assume a default weight for these endpoints (e.g 10).This list will be used to make the first lookup call. During the first lookup call, the actual list of endpoints will be provided back. Then on, whenever there is any change in the clustershape, the listener will get the updated list of endpoints from the server. The implementation for choosing the endpoint from the list of endpoints is as follows: Let's assume 4 endpoints:
A(wt=10)
,B(wt=30)
,C(wt=40)
,D(wt=20)
.Using the Random API, generate a random number between 1 and10+30+40+20. Let's assume that the above list is randomized. Based on the weights, we have intervals as follows:
1-----10 (A's weight) 11----40 (A's weight + B's weight) 41----80 (A's weight + B's weight + C's weight) 81----100(A's weight + B's weight + C's weight + C's weight)
if (random_number between 1 & 10) {send request to A;} else if (random_number between 11 & 40) {send request to B;} else if (random_number between 41 & 80) {send request to C;} else if (random_number between 81 & 100) {send request to D;}
For simple Round Robin, we can assume the same weight for all endpoints and perform the above.
- Author:
- Sheetal Vartak
-
-
Field Summary
Fields Modifier and Type Field Description static String
COULD_NOT_FIND_ENDPOINT
static String
NO_ENDPOINTS_SELECTED_PROVIDER
static String
PROVIDER_EXCEPTION
static String
UNKNOWN_HOST
-
Constructor Summary
Constructors Constructor Description RoundRobinPolicy(List<String> list)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<String>
getAddressPortList(String host, String port)
List<String>
getEndpointForProviderURL(String providerURLString)
List<String>
getHostPortList()
List<String>
getNextRotation()
String
toString()
-
-
-
Field Detail
-
COULD_NOT_FIND_ENDPOINT
public static final String COULD_NOT_FIND_ENDPOINT
- See Also:
- Constant Field Values
-
UNKNOWN_HOST
public static final String UNKNOWN_HOST
- See Also:
- Constant Field Values
-
NO_ENDPOINTS_SELECTED_PROVIDER
public static final String NO_ENDPOINTS_SELECTED_PROVIDER
- See Also:
- Constant Field Values
-
PROVIDER_EXCEPTION
public static final String PROVIDER_EXCEPTION
- See Also:
- Constant Field Values
-
-