org.jdiameter.client.impl.router
Class RouterImpl

java.lang.Object
  extended by org.jdiameter.client.impl.router.RouterImpl
All Implemented Interfaces:
IRouter
Direct Known Subclasses:
RouterImpl

public class RouterImpl
extends java.lang.Object
implements IRouter

Diameter Routing Core

Author:
Alexandre Mendonca , Bartosz Baranowski

Nested Class Summary
protected  class RouterImpl.AnswerEntry
           
protected  class RouterImpl.RedirectEntry
           
 
Field Summary
static int ALL_APPLICATION
           
static int ALL_HOST
           
static int ALL_REALM
           
static int ALL_SESSION
           
static int ALL_USER
           
protected  IConcurrentFactory concurrentFactory
           
protected  IContainer container
           
static int DONT_CACHE
           
protected  boolean isStopped
           
protected  MetaData metaData
           
static int REALM_AND_APPLICATION
           
protected  IRealmTable realmTable
           
 int REDIRECT_TABLE_SIZE
           
protected  java.util.List<RouterImpl.RedirectEntry> redirectTable
           
protected  java.util.concurrent.locks.ReadWriteLock redirectTableLock
           
static int REQUEST_TABLE_CLEAR_SIZE
           
static int REQUEST_TABLE_SIZE
           
protected  java.util.Map<java.lang.String,RouterImpl.AnswerEntry> requestEntryMap
           
protected  java.util.concurrent.locks.Lock requestEntryTableLock
           
 
Constructor Summary
RouterImpl(IContainer container, IConcurrentFactory concurrentFactory, IRealmTable realmTable, Configuration config, MetaData aMetaData)
           
 
Method Summary
 void destroy()
          Release all resources
 void garbageCollectRequestRouteInfo(IMessage message)
           
 IPeer getPeer(IMessage message, IPeerTable manager)
          Return peer from inner peer table by predefined parameters.
protected  IPeer getPeerPredProcessing(IMessage message, java.lang.String destRealm, java.lang.String destHost)
           
 IRealmTable getRealmTable()
          Return realm table
 java.lang.String[] getRequestRouteInfo(IMessage message)
          Return Request route info
protected  void loadConfiguration(Configuration config)
           
 void processRedirectAnswer(IRequest request, IAnswer answer, IPeerTable table)
          Called when redirect answer is received for request.
 void registerRequestRouteInfo(IRequest request)
          Register route information by received request.
protected  IPeer selectPeer(java.util.List<IPeer> availablePeers)
           
 void start()
          Start inner time facilities
 void stop()
          Stop inner time facilities
 boolean updateRoute(IRequest message)
          Based on Redirect entries or any other factors, this method changes route information.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DONT_CACHE

public static final int DONT_CACHE
See Also:
Constant Field Values

ALL_SESSION

public static final int ALL_SESSION
See Also:
Constant Field Values

ALL_REALM

public static final int ALL_REALM
See Also:
Constant Field Values

REALM_AND_APPLICATION

public static final int REALM_AND_APPLICATION
See Also:
Constant Field Values

ALL_APPLICATION

public static final int ALL_APPLICATION
See Also:
Constant Field Values

ALL_HOST

public static final int ALL_HOST
See Also:
Constant Field Values

ALL_USER

public static final int ALL_USER
See Also:
Constant Field Values

metaData

protected MetaData metaData

realmTable

protected IRealmTable realmTable

REDIRECT_TABLE_SIZE

public final int REDIRECT_TABLE_SIZE
See Also:
Constant Field Values

redirectTable

protected java.util.List<RouterImpl.RedirectEntry> redirectTable

concurrentFactory

protected IConcurrentFactory concurrentFactory

container

protected IContainer container

REQUEST_TABLE_SIZE

public static int REQUEST_TABLE_SIZE

REQUEST_TABLE_CLEAR_SIZE

public static int REQUEST_TABLE_CLEAR_SIZE

requestEntryTableLock

protected java.util.concurrent.locks.Lock requestEntryTableLock

redirectTableLock

protected java.util.concurrent.locks.ReadWriteLock redirectTableLock

requestEntryMap

protected java.util.Map<java.lang.String,RouterImpl.AnswerEntry> requestEntryMap

isStopped

protected boolean isStopped
Constructor Detail

RouterImpl

public RouterImpl(IContainer container,
                  IConcurrentFactory concurrentFactory,
                  IRealmTable realmTable,
                  Configuration config,
                  MetaData aMetaData)
Method Detail

loadConfiguration

protected void loadConfiguration(Configuration config)

registerRequestRouteInfo

public void registerRequestRouteInfo(IRequest request)
Description copied from interface: IRouter
Register route information by received request. This information will be used during answer routing.

Specified by:
registerRequestRouteInfo in interface IRouter
Parameters:
request - request

getRequestRouteInfo

public java.lang.String[] getRequestRouteInfo(IMessage message)
Description copied from interface: IRouter
Return Request route info

Specified by:
getRequestRouteInfo in interface IRouter
Returns:
Array (host and realm)

garbageCollectRequestRouteInfo

public void garbageCollectRequestRouteInfo(IMessage message)
Specified by:
garbageCollectRequestRouteInfo in interface IRouter

getPeer

public IPeer getPeer(IMessage message,
                     IPeerTable manager)
              throws RouteException,
                     AvpDataException
Description copied from interface: IRouter
Return peer from inner peer table by predefined parameters. Fetches peer based on message content, that is HBH or realm/host avp contents. Takes into consideration ApplicationId present in message to pick correct realm definition from RealmTable. This method should be called after IRouter.updateRoute(org.jdiameter.client.api.IRequest).

Specified by:
getPeer in interface IRouter
Parameters:
message - message with routed avps
manager - instance of peer manager
Returns:
peer instance
Throws:
RouteException
AvpDataException

getRealmTable

public IRealmTable getRealmTable()
Description copied from interface: IRouter
Return realm table

Specified by:
getRealmTable in interface IRouter
Returns:
object representing realm table

processRedirectAnswer

public void processRedirectAnswer(IRequest request,
                                  IAnswer answer,
                                  IPeerTable table)
                           throws InternalException,
                                  RouteException
Description copied from interface: IRouter
Called when redirect answer is received for request. This method update redirect host information and routes to new destination.

Specified by:
processRedirectAnswer in interface IRouter
Throws:
InternalException
RouteException

updateRoute

public boolean updateRoute(IRequest message)
                    throws RouteException,
                           AvpDataException
Description copied from interface: IRouter
Based on Redirect entries or any other factors, this method changes route information.

Specified by:
updateRoute in interface IRouter
Returns:
Throws:
RouteException
AvpDataException

getPeerPredProcessing

protected IPeer getPeerPredProcessing(IMessage message,
                                      java.lang.String destRealm,
                                      java.lang.String destHost)

start

public void start()
Description copied from interface: IRouter
Start inner time facilities

Specified by:
start in interface IRouter

stop

public void stop()
Description copied from interface: IRouter
Stop inner time facilities

Specified by:
stop in interface IRouter

destroy

public void destroy()
Description copied from interface: IRouter
Release all resources

Specified by:
destroy in interface IRouter

selectPeer

protected IPeer selectPeer(java.util.List<IPeer> availablePeers)


Copyright © 2014. All Rights Reserved.