com.sun.enterprise.naming.impl
Class RoundRobinPolicy

java.lang.Object
  extended by com.sun.enterprise.naming.impl.RoundRobinPolicy

public class RoundRobinPolicy
extends java.lang.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 willhave 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 machinehosting 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 theendpoints 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 beprovided back. Then on, whenever there is any change in the clustershape, the listener will get the updated list of endpoints from theserver. 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) Here's the psuedo code for deciding where to send the request: 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 endpointsand perform the above.

Author:
Sheetal Vartak

Constructor Summary
RoundRobinPolicy(java.util.List<java.lang.String> list)
           
 
Method Summary
 java.util.List<java.lang.String> getAddressPortList(java.lang.String host, java.lang.String port)
           
 java.util.List<java.lang.String> getEndpointForProviderURL(java.lang.String providerURLString)
           
 java.util.List<java.lang.String> getHostPortList()
           
 java.util.List<java.lang.String> getNextRotation()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RoundRobinPolicy

public RoundRobinPolicy(java.util.List<java.lang.String> list)
Method Detail

getEndpointForProviderURL

public java.util.List<java.lang.String> getEndpointForProviderURL(java.lang.String providerURLString)

getNextRotation

public java.util.List<java.lang.String> getNextRotation()

getAddressPortList

public java.util.List<java.lang.String> getAddressPortList(java.lang.String host,
                                                           java.lang.String port)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getHostPortList

public java.util.List<java.lang.String> getHostPortList()


Copyright © 2012 GlassFish Community. All Rights Reserved.