org.jdiameter.client.impl.controller
Class PeerImpl

java.lang.Object
  extended by org.jdiameter.common.impl.controller.AbstractPeer
      extended by org.jdiameter.client.impl.controller.PeerImpl
All Implemented Interfaces:
java.lang.Comparable<Peer>, Peer, IPeer
Direct Known Subclasses:
PeerImpl

public class PeerImpl
extends AbstractPeer
implements IPeer

Client Peer implementation

Author:
erick.svenson@yahoo.com, Bartosz Baranowski , Alexandre Mendonca

Nested Class Summary
protected  class PeerImpl.ActionContext
           
 
Field Summary
protected  java.net.InetAddress[] addresses
           
protected  java.util.Set<ApplicationId> commonApplications
           
protected  IConnection connection
           
protected  IConnectionListener connListener
           
protected  Dictionary dictionary
           
protected  int firmWare
           
protected  IStateMachine fsm
           
protected  java.util.concurrent.atomic.AtomicLong hopByHopId
           
protected  IMetaData metaData
           
protected  IMessageParser parser
           
protected  java.util.Map<java.lang.Long,IMessage> peerRequests
           
protected  java.lang.String productName
           
protected  int rating
           
protected  java.lang.String realmName
           
protected  IRouter router
           
protected  ISessionDatasource sessionDataSource
           
protected  boolean stopping
           
protected  PeerTableImpl table
           
protected  boolean useUriAsFQDN
           
protected  long vendorID
           
 
Fields inherited from class org.jdiameter.common.impl.controller.AbstractPeer
INT_COMMON_APP_ID, perSecondRecords, statistic, statisticFactory, uid, uri
 
Constructor Summary
protected PeerImpl(PeerTableImpl table, int rating, URI remotePeer, java.lang.String ip, java.lang.String portRange, IMetaData metaData, Configuration config, Configuration peerConfig, IFsmFactory fsmFactory, ITransportLayerFactory trFactory, IMessageParser parser, IStatisticManager statisticFactory, IConcurrentFactory concurrentFactory, IConnection connection, ISessionDatasource sessionDataSource)
           
  PeerImpl(PeerTableImpl table, int rating, URI remotePeer, java.lang.String ip, java.lang.String portRange, IMetaData metaData, Configuration config, Configuration peerConfig, IFsmFactory fsmFactory, ITransportLayerFactory trFactory, IStatisticManager statisticFactory, IConcurrentFactory concurrentFactory, IMessageParser parser, ISessionDatasource sessionDataSource)
           
 
Method Summary
 void addConnectionListener(IConnectionListener listener)
          Add connection state change listener
 void addMessage(IMessage message)
          Append request to peer request storage map
 void addPeerStateListener(PeerStateListener listener)
           
 void addStateChangeListener(StateChangeListener listener)
          Add state change listener
 void connect()
           
 void disconnect(int disconnectCause)
           
protected  void fillIPAddressTable(IMessage message)
           
protected  java.util.Set<ApplicationId> getCommonApplicationIds(IMessage message)
           
 java.util.Set<ApplicationId> getCommonApplications()
           
 IContext getContext()
           
 long getFirmware()
           
 long getHopByHopIdentifier()
          Return new hop by hop id for new message
 java.net.InetAddress[] getIPAddresses()
           
 java.lang.String getProductName()
           
 int getRating()
          Return rating of peer
 java.lang.String getRealmName()
           
<E> E
getState(java.lang.Class<E> enumc)
           
 IStatistic getStatistic()
          Return peer statistic
 URI getUri()
           
 long getVendorId()
           
 boolean handleMessage(EventTypes type, IMessage message, java.lang.String key)
          Put message to peer fsm
 boolean hasValidConnection()
          Return true if peer has valid connection
 boolean isConnected()
          Return if peer is connected
 IMessage[] remAllMessage()
          Clear request storage map
 void remConnectionListener(IConnectionListener listener)
          Remove connection state change listener
 void remMessage(IMessage message)
          Remove request from request storage map
 void removePeerStateListener(PeerStateListener listener)
           
 void remStateChangeListener(StateChangeListener listener)
          Remove state change listener
protected  void sendErrorAnswer(IRequest request, java.lang.String errorMessage, int resultCode, Avp... avpsToAdd)
           
 boolean sendMessage(IMessage message)
          Send message to diameter network
 void setRealm(java.lang.String realm)
          Attach peer to realm
 java.lang.String toString()
           
 
Methods inherited from class org.jdiameter.common.impl.controller.AbstractPeer
compareTo, createPeerStatistics, removePeerStatistics
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

addresses

protected java.net.InetAddress[] addresses

realmName

protected java.lang.String realmName

vendorID

protected long vendorID

productName

protected java.lang.String productName

firmWare

protected int firmWare

commonApplications

protected java.util.Set<ApplicationId> commonApplications

hopByHopId

protected java.util.concurrent.atomic.AtomicLong hopByHopId

rating

protected int rating

stopping

protected boolean stopping

metaData

protected IMetaData metaData

table

protected PeerTableImpl table

router

protected IRouter router

peerRequests

protected final java.util.Map<java.lang.Long,IMessage> peerRequests

dictionary

protected final Dictionary dictionary

fsm

protected IStateMachine fsm

parser

protected IMessageParser parser

useUriAsFQDN

protected boolean useUriAsFQDN

sessionDataSource

protected ISessionDatasource sessionDataSource

connection

protected IConnection connection

connListener

protected IConnectionListener connListener
Constructor Detail

PeerImpl

public PeerImpl(PeerTableImpl table,
                int rating,
                URI remotePeer,
                java.lang.String ip,
                java.lang.String portRange,
                IMetaData metaData,
                Configuration config,
                Configuration peerConfig,
                IFsmFactory fsmFactory,
                ITransportLayerFactory trFactory,
                IStatisticManager statisticFactory,
                IConcurrentFactory concurrentFactory,
                IMessageParser parser,
                ISessionDatasource sessionDataSource)
         throws InternalException,
                TransportException
Throws:
InternalException
TransportException

PeerImpl

protected PeerImpl(PeerTableImpl table,
                   int rating,
                   URI remotePeer,
                   java.lang.String ip,
                   java.lang.String portRange,
                   IMetaData metaData,
                   Configuration config,
                   Configuration peerConfig,
                   IFsmFactory fsmFactory,
                   ITransportLayerFactory trFactory,
                   IMessageParser parser,
                   IStatisticManager statisticFactory,
                   IConcurrentFactory concurrentFactory,
                   IConnection connection,
                   ISessionDatasource sessionDataSource)
            throws InternalException,
                   TransportException
Throws:
InternalException
TransportException
Method Detail

getContext

public IContext getContext()

getStatistic

public IStatistic getStatistic()
Description copied from interface: IPeer
Return peer statistic

Specified by:
getStatistic in interface IPeer
Returns:
peer statistic

addPeerStateListener

public void addPeerStateListener(PeerStateListener listener)
Specified by:
addPeerStateListener in interface Peer

removePeerStateListener

public void removePeerStateListener(PeerStateListener listener)
Specified by:
removePeerStateListener in interface Peer

connect

public void connect()
             throws InternalException,
                    java.io.IOException,
                    IllegalDiameterStateException
Specified by:
connect in interface Peer
Throws:
InternalException
java.io.IOException
IllegalDiameterStateException

disconnect

public void disconnect(int disconnectCause)
                throws InternalException,
                       IllegalDiameterStateException
Specified by:
disconnect in interface Peer
Overrides:
disconnect in class AbstractPeer
Throws:
InternalException
IllegalDiameterStateException

getState

public <E> E getState(java.lang.Class<E> enumc)
Specified by:
getState in interface Peer

getUri

public URI getUri()
Specified by:
getUri in interface Peer

getIPAddresses

public java.net.InetAddress[] getIPAddresses()
Specified by:
getIPAddresses in interface Peer

getRealmName

public java.lang.String getRealmName()
Specified by:
getRealmName in interface Peer

getVendorId

public long getVendorId()
Specified by:
getVendorId in interface Peer

getProductName

public java.lang.String getProductName()
Specified by:
getProductName in interface Peer

getFirmware

public long getFirmware()
Specified by:
getFirmware in interface Peer

getCommonApplications

public java.util.Set<ApplicationId> getCommonApplications()
Specified by:
getCommonApplications in interface Peer

getHopByHopIdentifier

public long getHopByHopIdentifier()
Description copied from interface: IPeer
Return new hop by hop id for new message

Specified by:
getHopByHopIdentifier in interface IPeer
Returns:
new hop by hop id

addMessage

public void addMessage(IMessage message)
Description copied from interface: IPeer
Append request to peer request storage map

Specified by:
addMessage in interface IPeer
Parameters:
message - request instance

remMessage

public void remMessage(IMessage message)
Description copied from interface: IPeer
Remove request from request storage map

Specified by:
remMessage in interface IPeer
Parameters:
message - request instance

remAllMessage

public IMessage[] remAllMessage()
Description copied from interface: IPeer
Clear request storage map

Specified by:
remAllMessage in interface IPeer

handleMessage

public boolean handleMessage(EventTypes type,
                             IMessage message,
                             java.lang.String key)
                      throws TransportException,
                             OverloadException,
                             InternalException
Description copied from interface: IPeer
Put message to peer fsm

Specified by:
handleMessage in interface IPeer
message - request instance
Returns:
true if message will be set to FSM
Throws:
TransportException
OverloadException
InternalException

sendMessage

public boolean sendMessage(IMessage message)
                    throws TransportException,
                           OverloadException,
                           InternalException
Description copied from interface: IPeer
Send message to diameter network

Specified by:
sendMessage in interface IPeer
Parameters:
message - request instance
Returns:
true if message will be set to FSM
Throws:
TransportException
OverloadException
InternalException

hasValidConnection

public boolean hasValidConnection()
Description copied from interface: IPeer
Return true if peer has valid connection

Specified by:
hasValidConnection in interface IPeer
Returns:
true if peer has valid connection

setRealm

public void setRealm(java.lang.String realm)
Description copied from interface: IPeer
Attach peer to realm

Specified by:
setRealm in interface IPeer
Parameters:
realm - realm name

addStateChangeListener

public void addStateChangeListener(StateChangeListener listener)
Description copied from interface: IPeer
Add state change listener

Specified by:
addStateChangeListener in interface IPeer
Parameters:
listener - listener instance

remStateChangeListener

public void remStateChangeListener(StateChangeListener listener)
Description copied from interface: IPeer
Remove state change listener

Specified by:
remStateChangeListener in interface IPeer
Parameters:
listener - listener instance

addConnectionListener

public void addConnectionListener(IConnectionListener listener)
Description copied from interface: IPeer
Add connection state change listener

Specified by:
addConnectionListener in interface IPeer
Parameters:
listener - listener instance

remConnectionListener

public void remConnectionListener(IConnectionListener listener)
Description copied from interface: IPeer
Remove connection state change listener

Specified by:
remConnectionListener in interface IPeer
Parameters:
listener - listener instance

getRating

public int getRating()
Description copied from interface: IPeer
Return rating of peer

Specified by:
getRating in interface IPeer
Returns:
int value

isConnected

public boolean isConnected()
Description copied from interface: IPeer
Return if peer is connected

Specified by:
isConnected in interface IPeer
Returns:
is peer connected

toString

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

fillIPAddressTable

protected void fillIPAddressTable(IMessage message)

getCommonApplicationIds

protected java.util.Set<ApplicationId> getCommonApplicationIds(IMessage message)

sendErrorAnswer

protected void sendErrorAnswer(IRequest request,
                               java.lang.String errorMessage,
                               int resultCode,
                               Avp... avpsToAdd)


Copyright © 2014. All Rights Reserved.