Mixe for Privacy and Anonymity in the Internet
Public Member Functions | Private Attributes
CACacheLoadBalancing Class Reference

This class stores Addresses off different Cache-Proxies. More...

#include <CACacheLoadBalancing.hpp>

Collaboration diagram for CACacheLoadBalancing:
[legend]

List of all members.

Public Member Functions

 CACacheLoadBalancing ()
 ~CACacheLoadBalancing ()
SINT32 clean ()
 Deletes all information.
SINT32 add (CASocketAddr *const pAddr)
CASocketAddrINetget ()
 Gets the 'next' Address according to the Load-Balancing algorithm.
UINT32 getElementCount ()

Private Attributes

CACHE_LB_ENTRYpSelectedEntry
UINT32 m_ElementCount
CAMutex m_csLock

Detailed Description

This class stores Addresses off different Cache-Proxies.

It can be used for Load Balancing between them. Currently a simple Ropund Robin is implemented.

Definition at line 45 of file CACacheLoadBalancing.hpp.


Constructor & Destructor Documentation

Definition at line 48 of file CACacheLoadBalancing.hpp.

References m_ElementCount, and pSelectedEntry.

Definition at line 53 of file CACacheLoadBalancing.hpp.

References clean().

{clean();}

Here is the call graph for this function:


Member Function Documentation

Definition at line 36 of file CACacheLoadBalancing.cpp.

References CASocketAddr::clone(), E_SUCCESS, E_UNKNOWN, CASocketAddr::getType(), CAMutex::lock(), m_csLock, m_ElementCount, t_cachelb_list::next, t_cachelb_list::pAddr, pSelectedEntry, and CAMutex::unlock().

Referenced by CALastMix::setTargets().

  {
    if(pAddr->getType()!=AF_INET)
      return E_UNKNOWN;
    CACHE_LB_ENTRY* pEntry=new CACHE_LB_ENTRY;
    if(pEntry==NULL)
      return E_UNKNOWN;
    pEntry->pAddr=(CASocketAddrINet*)pAddr->clone();
    m_csLock.lock();
    if(pSelectedEntry==NULL)
      {
        pSelectedEntry=pEntry;
        pSelectedEntry->next=pSelectedEntry;
      }
    else
      {
        pEntry->next=pSelectedEntry->next;
        pSelectedEntry->next=pEntry;            
      }
    m_ElementCount++;
    m_csLock.unlock();
    return E_SUCCESS;
  }

Here is the call graph for this function:

Deletes all information.

Definition at line 56 of file CACacheLoadBalancing.hpp.

References E_SUCCESS, CAMutex::lock(), m_csLock, m_ElementCount, t_cachelb_list::next, t_cachelb_list::pAddr, pSelectedEntry, and CAMutex::unlock().

Referenced by CALastMix::setTargets(), and ~CACacheLoadBalancing().

        {
          m_csLock.lock();
          CACHE_LB_ENTRY* pEntry;
          CACHE_LB_ENTRY* pFirst=pSelectedEntry;
          while(pSelectedEntry!=NULL)
            {
              if(pSelectedEntry->next==pFirst)
                pEntry=NULL;
              else 
                pEntry=pSelectedEntry->next;
              delete pSelectedEntry->pAddr;
              pSelectedEntry->pAddr = NULL;
              delete pSelectedEntry;
              pSelectedEntry = NULL;
              pSelectedEntry=pEntry;
            }
          m_ElementCount=0;
          m_csLock.unlock();
          return E_SUCCESS;
        }

Here is the call graph for this function:

Gets the 'next' Address according to the Load-Balancing algorithm.

This is the Address which should be used for a connection to a cache proxy.

Returns:
next Address of a Cache-Proxy

Definition at line 84 of file CACacheLoadBalancing.hpp.

References CAMutex::lock(), m_csLock, t_cachelb_list::next, t_cachelb_list::pAddr, pSelectedEntry, and CAMutex::unlock().

Referenced by CALastMixA::loop(), CALastMixB::loop(), and CALastMix::setTargets().

Here is the call graph for this function:

Definition at line 100 of file CACacheLoadBalancing.hpp.

References m_ElementCount.

Referenced by CALastMixA::loop(), CALastMixB::loop(), and CALastMix::setTargets().

        {
          return m_ElementCount;
        }

Member Data Documentation

Definition at line 108 of file CACacheLoadBalancing.hpp.

Referenced by add(), clean(), and get().

Definition at line 107 of file CACacheLoadBalancing.hpp.

Referenced by add(), CACacheLoadBalancing(), clean(), and getElementCount().

Definition at line 106 of file CACacheLoadBalancing.hpp.

Referenced by add(), CACacheLoadBalancing(), clean(), and get().


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