reSIProcate/stack  9694
Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes
resip::TuSelector Class Reference

#include <TuSelector.hxx>

Collaboration diagram for resip::TuSelector:
Collaboration graph
[legend]

List of all members.

Classes

struct  Item

Public Member Functions

 TuSelector (TimeLimitFifo< Message > &fallBackFifo)
 ~TuSelector ()
void add (Message *msg, TimeLimitFifo< Message >::DepthUsage usage)
void add (ConnectionTerminated *term)
void add (KeepAlivePong *pong)
unsigned int size () const
bool wouldAccept (TimeLimitFifo< Message >::DepthUsage usage) const
TransactionUserselectTransactionUser (const SipMessage &msg)
bool haveTransactionUsers () const
void registerTransactionUser (TransactionUser &)
void requestTransactionUserShutdown (TransactionUser &)
void unregisterTransactionUser (TransactionUser &)
void process ()
unsigned int getTimeTillNextProcessMS ()
bool isTransactionUserStillRegistered (const TransactionUser *) const
void setFallbackPostNotify (AsyncProcessHandler *handler)
void setCongestionManager (CongestionManager *manager)
CongestionManager::RejectionBehavior getRejectionBehavior (TransactionUser *tu) const
unsigned int getExpectedWait (TransactionUser *tu) const

Private Types

typedef std::vector< ItemTuList

Private Member Functions

void remove (TransactionUser *tu)
void markShuttingDown (TransactionUser *tu)
bool exists (TransactionUser *tu)

Private Attributes

TuList mTuList
TimeLimitFifo< Message > & mFallBackFifo
CongestionManagermCongestionManager
AsyncProcessHandlermFallbackPostNotify
Fifo< TransactionUserMessagemShutdownFifo
bool mTuSelectorMode
StatisticsMessage::Payload mStatsPayload

Detailed Description

Definition at line 19 of file TuSelector.hxx.


Member Typedef Documentation

typedef std::vector<Item> resip::TuSelector::TuList [private]

Definition at line 63 of file TuSelector.hxx.


Constructor & Destructor Documentation

TuSelector::TuSelector ( TimeLimitFifo< Message > &  fallBackFifo)

Definition at line 16 of file TuSelector.cxx.

References mShutdownFifo, and resip::FifoStatsInterface::setDescription().

                                                           :
   mFallBackFifo(fallBackFifo), 
   mCongestionManager(0),
   mFallbackPostNotify(0),
   mTuSelectorMode(false),
   mStatsPayload()
{
   mShutdownFifo.setDescription("TuSelector::mShutdownFifo");
}

Here is the call graph for this function:

TuSelector::~TuSelector ( )

Definition at line 26 of file TuSelector.cxx.

{
   //assert(mTuList.empty());
}

Member Function Documentation

void TuSelector::add ( Message msg,
TimeLimitFifo< Message >::DepthUsage  usage 
)

Definition at line 64 of file TuSelector.cxx.

References resip::TimeLimitFifo< Msg >::add(), DebugLog, exists(), resip::Message::getTransactionUser(), resip::AsyncProcessHandler::handleProcessNotification(), resip::Message::hasTransactionUser(), InfoLog, resip::StatisticsMessage::loadOut(), resip::StatisticsMessage::logStats(), mFallBackFifo, mFallbackPostNotify, mStatsPayload, resip::TransactionUser::postToTransactionUser(), RESIPROCATE_SUBSYSTEM, and WarningLog.

Referenced by resip::SipStack::post(), resip::StatelessHandler::process(), resip::TransactionController::process(), resip::TransactionState::process(), resip::TuSelectorTimerQueue::processTimer(), resip::TransactionController::send(), and resip::TransactionState::sendToTU().

{
   if (msg->hasTransactionUser())
   {
      if (exists(msg->getTransactionUser()))
      {
         DebugLog (<< "Send to TU: " << *(msg->getTransactionUser()) << " " << std::endl << std::endl << *msg);
         msg->getTransactionUser()->postToTransactionUser(msg, usage);
      }
      else
      {
         WarningLog (<< "Send to TU that no longer exists: " << std::endl << std::endl << *msg);
         delete msg;
      }
   }
   else
   {
      StatisticsMessage* stats = dynamic_cast<StatisticsMessage*>(msg);
      if (stats)
      {
         InfoLog(<< "Stats message " );
         stats->loadOut(mStatsPayload);
         stats->logStats(RESIPROCATE_SUBSYSTEM, mStatsPayload);
         delete msg;
      }
      else
      {
         DebugLog(<< "Send to default TU: " << std::endl << std::endl << *msg);
         mFallBackFifo.add(msg, usage);
         if ( mFallbackPostNotify )
            mFallbackPostNotify->handleProcessNotification();
      }
   }
}

Here is the call graph for this function:

void TuSelector::add ( ConnectionTerminated term)

Definition at line 100 of file TuSelector.cxx.

References resip::ConnectionTerminated::clone(), InfoLog, and mTuList.

{
   InfoLog (<< "Sending " << *term << " to TUs");
   
   for(TuList::const_iterator it = mTuList.begin(); it != mTuList.end(); it++)
   {
      if (!it->shuttingDown && it->tu->isRegisteredForConnectionTermination())
      {
         it->tu->post(term->clone());
      }
   }
}

Here is the call graph for this function:

void TuSelector::add ( KeepAlivePong pong)

Definition at line 114 of file TuSelector.cxx.

References resip::KeepAlivePong::clone(), and mTuList.

{
   //InfoLog (<< "Sending " << *pong << " to TUs");
   
   for(TuList::const_iterator it = mTuList.begin(); it != mTuList.end(); it++)
   {
      if (!it->shuttingDown && it->tu->isRegisteredForKeepAlivePongs())
      {
         it->tu->post(pong->clone());
      }
   }
}

Here is the call graph for this function:

bool TuSelector::exists ( TransactionUser tu) [private]

Definition at line 230 of file TuSelector.cxx.

References mTuList.

Referenced by add().

{
   for(TuList::iterator it = mTuList.begin(); it != mTuList.end(); it++)
   {
      if (it->tu == tu)
      {
         return true;
      }
   }
   return false;
}
UInt32 TuSelector::getExpectedWait ( TransactionUser tu) const

Definition at line 303 of file TuSelector.cxx.

References resip::AbstractFifo< T >::expectedWaitTimeMilliSec(), resip::TransactionUser::getExpectedWait(), and mFallBackFifo.

Referenced by resip::TransactionState::sendToTU().

{
   if(tu)
   {
      return tu->getExpectedWait();
   }

   return (UInt32)mFallBackFifo.expectedWaitTimeMilliSec();
}

Here is the call graph for this function:

CongestionManager::RejectionBehavior TuSelector::getRejectionBehavior ( TransactionUser tu) const
unsigned int TuSelector::getTimeTillNextProcessMS ( )

Definition at line 243 of file TuSelector.cxx.

References resip::AbstractFifo< T >::messageAvailable(), and mShutdownFifo.

Referenced by resip::SipStack::getTimeTillNextProcessMS().

{
    if(mShutdownFifo.messageAvailable()) //  || !mFallBackFifo.messageAvailable())  // .slg. fallback fifo is not really used
    {
        return 0;
    }
    else
    {
        return INT_MAX;
    }
} 

Here is the call graph for this function:

bool resip::TuSelector::haveTransactionUsers ( ) const [inline]

Definition at line 33 of file TuSelector.hxx.

References mTuSelectorMode.

Referenced by resip::TransactionState::processSipMessageAsNew().

{ return mTuSelectorMode; }
bool TuSelector::isTransactionUserStillRegistered ( const TransactionUser tu) const

Definition at line 256 of file TuSelector.cxx.

References mTuList, and mTuSelectorMode.

Referenced by resip::TransactionState::terminateClientTransaction(), and resip::TransactionState::terminateServerTransaction().

{
   if (mTuSelectorMode)
   {
      for(TuList::const_iterator it = mTuList.begin(); it != mTuList.end(); it++)
      {
         if (!it->shuttingDown  && it->tu == tu)
         {
            return true;
         }
      }
   }
   return false;
}
void TuSelector::markShuttingDown ( TransactionUser tu) [private]

Definition at line 200 of file TuSelector.cxx.

References mTuList.

Referenced by process().

{
   for(TuList::iterator it = mTuList.begin(); it != mTuList.end(); it++)
   {
      if (it->tu == tu)
      {
         it->shuttingDown = true;
         return;
      }
   }
   assert(0);
}
void TuSelector::process ( )

Definition at line 39 of file TuSelector.cxx.

References resip::Fifo< Msg >::getNext(), resip::Message::getTransactionUser(), InfoLog, markShuttingDown(), resip::AbstractFifo< T >::messageAvailable(), mShutdownFifo, resip::TransactionUserMessage::RemoveTransactionUser, resip::TransactionUserMessage::RequestShutdown, and resip::TransactionUserMessage::type().

Referenced by resip::SipStack::processTimers().

{
   if (mShutdownFifo.messageAvailable())
   {
      TransactionUserMessage* msg = mShutdownFifo.getNext();
      
      switch (msg->type())
      {
         case TransactionUserMessage::RequestShutdown:
            InfoLog (<< "TransactionUserMessage::RequestShutdown " << *(msg->getTransactionUser()));
            markShuttingDown(msg->getTransactionUser());
            break;
         case TransactionUserMessage::RemoveTransactionUser:
            InfoLog (<< "TransactionUserMessage::RemoveTransactionUser " << *(msg->getTransactionUser()));
            remove(msg->getTransactionUser());
            break;
         default:
            assert(0);
            break;
      }
      delete msg;
   }
}

Here is the call graph for this function:

void TuSelector::registerTransactionUser ( TransactionUser tu)

Definition at line 166 of file TuSelector.cxx.

References mTuList, and mTuSelectorMode.

Referenced by resip::SipStack::registerTransactionUser().

{
   mTuSelectorMode = true;
   mTuList.push_back(Item(&tu));
}
void TuSelector::remove ( TransactionUser tu) [private]

Definition at line 214 of file TuSelector.cxx.

References mTuList, resip::TransactionUser::post(), and resip::TransactionUserMessage::TransactionUserRemoved.

{
   for(TuList::iterator it = mTuList.begin(); it != mTuList.end(); it++)
   {
      if (it->tu == tu)
      {
         TransactionUserMessage* done = new TransactionUserMessage(TransactionUserMessage::TransactionUserRemoved, tu);
         tu->post(done);
         mTuList.erase(it);
         return;
      }
   }
   assert(0);
}

Here is the call graph for this function:

void TuSelector::requestTransactionUserShutdown ( TransactionUser tu)
TransactionUser * TuSelector::selectTransactionUser ( const SipMessage msg)

Definition at line 187 of file TuSelector.cxx.

References mTuList.

Referenced by resip::TransactionState::processSipMessageAsNew().

{
   for(TuList::iterator it = mTuList.begin(); it != mTuList.end(); it++)
   {
      if (it->tu->isForMe(msg))
      {
         return it->tu;
      }
   }
   return 0;
}
void TuSelector::setCongestionManager ( CongestionManager manager)

Definition at line 272 of file TuSelector.cxx.

References mTuList.

Referenced by resip::SipStack::setCongestionManager().

{
   for(TuList::iterator i=mTuList.begin(); i!=mTuList.end();++i)
   {
      i->tu->setCongestionManager(manager);
   }
   
   // Note:  We are intentionally not registering the following Fifos
   // mFallbackFifo - this is the same fifo as SipStack::TuFifo (passed in 
   //                 constructor).
   // mShutdownFifo - since it is only used at shutdown time, it doesn need
   //                 congestion management
}
void TuSelector::setFallbackPostNotify ( AsyncProcessHandler handler)

Definition at line 33 of file TuSelector.cxx.

References mFallbackPostNotify.

Referenced by resip::SipStack::setFallbackPostNotify().

{
    mFallbackPostNotify = handler;
}
unsigned int TuSelector::size ( ) const

Definition at line 148 of file TuSelector.cxx.

References mFallBackFifo, mTuList, mTuSelectorMode, and resip::AbstractFifo< T >::size().

Referenced by resip::TransactionController::getTuFifoSize().

{
   if (mTuSelectorMode)
   {
      unsigned int total=0;   
      for(TuList::const_iterator it = mTuList.begin(); it != mTuList.end(); it++)
      {
         total += it->tu->size();
      }
      return total;
   }
   else
   {
      return mFallBackFifo.size();
   }
}

Here is the call graph for this function:

void TuSelector::unregisterTransactionUser ( TransactionUser tu)
bool TuSelector::wouldAccept ( TimeLimitFifo< Message >::DepthUsage  usage) const

Definition at line 128 of file TuSelector.cxx.

References mFallBackFifo, mTuList, mTuSelectorMode, and resip::TimeLimitFifo< Msg >::wouldAccept().

Referenced by resip::TransactionController::isTUOverloaded().

{
   if (mTuSelectorMode)
   {
      for(TuList::const_iterator it = mTuList.begin(); it != mTuList.end(); it++)
      {
         if (!it->shuttingDown  && !it->tu->wouldAccept(usage))
         {
            return false;
         }
      }
      return true;
   }
   else
   {
      return mFallBackFifo.wouldAccept(usage);
   }
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 66 of file TuSelector.hxx.

Referenced by getRejectionBehavior().

Definition at line 65 of file TuSelector.hxx.

Referenced by add(), getExpectedWait(), getRejectionBehavior(), size(), and wouldAccept().

Definition at line 67 of file TuSelector.hxx.

Referenced by add(), and setFallbackPostNotify().

Definition at line 70 of file TuSelector.hxx.

Referenced by add().


The documentation for this class was generated from the following files: