Open SiteSearch 4.1.1
Final

ORG.oclc.opserve.opsmanager
Class LoadBalancer

java.lang.Object
  |
  +--java.util.AbstractCollection
        |
        +--java.util.AbstractList
              |
              +--java.util.Vector
                    |
                    +--ORG.oclc.opserve.opsmanager.LoadBalancer

public class LoadBalancer
extends Vector

Provides the API to the load balancing files. These files contain one record per line. Each record is a comma delimited list containing the host id, hostname, server port, operations port and load factor.

See Also:
Serialized Form

Fields inherited from class java.util.Vector
capacityIncrement, elementCount, elementData
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
LoadBalancer()
          Constructor that is used when writing a load balancing file
LoadBalancer(String loadDir, String serverType)
          Reads the load balancing file and initializes a vector of potential servers.
 
Method Summary
 void addServer(String hostID, String hostName, int serverPort, int opPort, int loadFactor)
          Add a server to the load balancer list.
 LoadedServer leastLoadedServer()
          returns the least loaded server giving preference to servers on the local host within each load factor group.
 void reset()
          sets the next server to the lowest loaded server
 void writeLoadFile(String loadDir, String type)
          Generates a load balancing file.
 void writeLoadFile(String loadDir, String type, boolean readFirst)
          Generates a load balancing file.
 
Methods inherited from class java.util.Vector
add, add, addAll, addAll, addElement, capacity, clear, clone, contains, containsAll, copyInto, elementAt, elements, ensureCapacity, equals, firstElement, get, hashCode, indexOf, indexOf, insertElementAt, isEmpty, lastElement, lastIndexOf, lastIndexOf, remove, remove, removeAll, removeAllElements, removeElement, removeElementAt, removeRange, retainAll, set, setElementAt, setSize, size, subList, toArray, toArray, toString, trimToSize
 
Methods inherited from class java.util.AbstractList
iterator, listIterator, listIterator
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LoadBalancer

public LoadBalancer(String loadDir,
                    String serverType)
             throws NoAvailableServerException
Reads the load balancing file and initializes a vector of potential servers.
Parameters:
loadDir - NFS mounted directory where load balancing file is
serverType - Name of load balancing file, less extension & path
Throws:
NoAvailableServerException - Indicates the file doesn't contain any active servers.

LoadBalancer

public LoadBalancer()
Constructor that is used when writing a load balancing file
Method Detail

leastLoadedServer

public LoadedServer leastLoadedServer()
                               throws NoAvailableServerException
returns the least loaded server giving preference to servers on the local host within each load factor group.
Returns:
the least loaded server
Throws:
NoAvailableServerException - Indicates the file doesn't contain any more active servers.

reset

public void reset()
           throws NoAvailableServerException
sets the next server to the lowest loaded server
Throws:
NoAvailableServerException - Indicates the file doesn't contain any active servers.

addServer

public void addServer(String hostID,
                      String hostName,
                      int serverPort,
                      int opPort,
                      int loadFactor)
Add a server to the load balancer list.
Parameters:
hostID - String used as a host id in the JaSSI URL.
hostName - Name of the host corresponding to the hostID
serverPort - Port used by server for normal operation
opPort - Port used by server for operations component
loadFactor - Measure of the load on this server

writeLoadFile

public void writeLoadFile(String loadDir,
                          String type)
Generates a load balancing file.
Parameters:
loadDir - Directory file is created in
type - Names file type.load

writeLoadFile

public void writeLoadFile(String loadDir,
                          String type,
                          boolean readFirst)
Generates a load balancing file.
Parameters:
loadDir - Directory file is created in
type - Names file type.load

Open SiteSearch 4.1.1
Final