org.psepr.jClient
Class SimpleRouterManager

java.lang.Object
  extended by org.psepr.jClient.SimpleRouterManager
All Implemented Interfaces:
RouterManager

public class SimpleRouterManager
extends java.lang.Object
implements RouterManager

Simple router manager that reads the list of routers from the configuration file and keeps connection information information in a file. Routers that have had previous successful connections are preferred next time.

Author:
Robert.Adams@intel.com

Constructor Summary
SimpleRouterManager()
           
 
Method Summary
 PsEPRRouter getNextRouterToTry()
          Get the next router to try.
 PsEPRRouter getNextRouterToTryOld()
           Get the next router to try.
 void routerFailed(PsEPRRouter rtr)
          Called to say that a previously return PsEPRRouter couldn't be connected to.
 java.lang.String toXML()
          output our nodes and status as XML
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleRouterManager

public SimpleRouterManager()
Method Detail

getNextRouterToTry

public PsEPRRouter getNextRouterToTry()
Get the next router to try. This randomizes the list of possible routers and returns the next one from the list.

Specified by:
getNextRouterToTry in interface RouterManager
Returns:
information on a router to try, or null if none
See Also:
RouterManager.getNextRouterToTry()

getNextRouterToTryOld

public PsEPRRouter getNextRouterToTryOld()

Get the next router to try. This uses a 'weight' of each connection that remembers if we've had success here before or not. All routers start out equal. When a router is connected, it gets a positive count. When a router "fails", the weight is decremented. Over time, the good ones count up and the bad count down.

The 'touched' flag is used to keep track of using them all. Once all have been used, we clear touched and start over

See Also:
RouterManager.getNextRouterToTry()

routerFailed

public void routerFailed(PsEPRRouter rtr)
Description copied from interface: RouterManager
Called to say that a previously return PsEPRRouter couldn't be connected to.

Specified by:
routerFailed in interface RouterManager
Parameters:
rtr - previously returned (from getNextRouterToTry) router
See Also:
RouterManager.routerFailed(org.psepr.jClient.PsEPRRouter)

toXML

public java.lang.String toXML()
output our nodes and status as XML