#include <ServiceRep.h>

Inheritance diagram for Adaptation::Icap::ServiceRep:
Collaboration diagram for Adaptation::Icap::ServiceRep:

Classes

struct  Client
 

Public Types

typedef RefCount< ServiceRepPointer
 
typedef String Id
 

Public Member Functions

 ServiceRep (const ServiceConfigPointer &aConfig)
 
virtual ~ServiceRep ()
 
virtual void finalize ()
 
virtual bool probed () const
 
virtual bool up () const
 
bool availableForNew () const
 a new transaction may start communicating with the service More...
 
bool availableForOld () const
 a transaction notified about connection slot availability may start communicating with the service More...
 
virtual InitiatemakeXactLauncher (Http::Message *virginHeader, HttpRequest *virginCause, AccessLogEntry::Pointer &alp)
 
void callWhenAvailable (AsyncCall::Pointer &cb, bool priority=false)
 
void callWhenReady (AsyncCall::Pointer &cb)
 
bool wantsUrl (const SBuf &urlPath) const
 
bool wantsPreview (const SBuf &urlPath, size_t &wantedSize) const
 
bool allows204 () const
 
bool allows206 () const
 
Comm::ConnectionPointer getConnection (bool isRetriable, bool &isReused)
 
void putConnection (const Comm::ConnectionPointer &conn, bool isReusable, bool sendReset, const char *comment)
 
void noteConnectionUse (const Comm::ConnectionPointer &conn)
 
void noteConnectionFailed (const char *comment)
 
void noteFailure ()
 
void noteNewWaiter ()
 New xaction waiting for service to be up or available. More...
 
void noteGoneWaiter ()
 An xaction is not waiting any more for service to be available. More...
 
bool existWaiters () const
 if there are xactions waiting for the service to be available More...
 
virtual bool doneAll () const
 whether positive goal has been reached More...
 
virtual void callException (const std::exception &e)
 called when the job throws during an async call More...
 
virtual void detach ()
 
virtual bool detached () const
 whether detached() was called More...
 
void noteTimeToUpdate ()
 
void noteTimeToNotify ()
 
virtual void noteAdaptationAnswer (const Answer &answer)
 
virtual bool broken () const
 
bool wants (const ServiceFilter &filter) const
 
const ServiceConfigcfg () const
 
virtual void noteAdaptationAclCheckDone (Adaptation::ServiceGroupPointer group)
 
bool canBeCalled (AsyncCall &call) const
 whether we can be called More...
 
void callStart (AsyncCall &call)
 
virtual void callEnd ()
 called right after the called job method More...
 
virtual void * toCbdata ()=0
 

Static Public Member Functions

static Pointer Start (AsyncJob *job)
 starts a freshly created job (i.e., makes the job asynchronous) More...
 

Public Attributes

Security::ContextPointer sslContext
 
Security::SessionStatePointer sslSession
 

Protected Member Functions

ServiceConfigwriteableCfg ()
 
CbcPointer< InitiateinitiateAdaptation (Initiate *x)
 < starts freshly created initiate and returns a safe pointer to it More...
 
void clearAdaptation (CbcPointer< Initiate > &x)
 clears the pointer (does not call announceInitiatorAbort) More...
 
void announceInitiatorAbort (CbcPointer< Initiate > &x)
 inform the transaction about abnormal termination and clear the pointer More...
 
bool initiated (const CbcPointer< AsyncJob > &job) const
 Must(initiated(initiate)) instead of Must(initiate.set()), for clarity. More...
 
void deleteThis (const char *aReason)
 
void mustStop (const char *aReason)
 
bool done () const
 the job is destroyed in callEnd() when done() More...
 
virtual void start ()
 called by AsyncStart; do not call directly More...
 
virtual void swanSong ()
 

Protected Attributes

const char * stopReason
 reason for forcing done() to be true More...
 
const char * typeName
 kid (leaf) class name, for debugging More...
 
AsyncCall::Pointer inCall
 the asynchronous call being handled, if any More...
 
const InstanceId< AsyncJobid
 job identifier More...
 

Private Types

typedef std::vector< ClientClients
 

Private Member Functions

 CBDATA_CLASS (ServiceRep)
 
ICAP::Method parseMethod (const char *) const
 
ICAP::VectPoint parseVectPoint (const char *) const
 
void suspend (const char *reason)
 
bool hasOptions () const
 
bool needNewOptions () const
 
time_t optionsFetchTime () const
 
void scheduleUpdate (time_t when)
 
void scheduleNotification ()
 
void startGettingOptions ()
 
void handleNewOptions (Options *newOptions)
 
void changeOptions (Options *newOptions)
 
void checkOptions ()
 
void announceStatusChange (const char *downPhrase, bool important) const
 
void setMaxConnections ()
 Set the maximum allowed connections for the service. More...
 
int excessConnections () const
 The number of connections which excess the Max-Connections limit. More...
 
int availableConnections () const
 
void busyCheckpoint ()
 
const char * status () const
 internal cleanup; do not call directly More...
 

Private Attributes

Clients theClients
 
OptionstheOptions
 
CbcPointer< Adaptation::InitiatetheOptionsFetcher
 
time_t theLastUpdate
 
std::deque< ClienttheNotificationWaiters
 
int theBusyConns
 
int theAllWaiters
 
int theMaxConnections
 the maximum allowed connections to the service More...
 
bool connOverloadReported
 whether we reported exceeding theMaxConnections More...
 
IdleConnListtheIdleConns
 idle persistent connection pool More...
 
FadingCounter theSessionFailures
 
const char * isSuspended
 
bool notifying
 
bool updateScheduled
 
bool wasAnnouncedUp
 
bool isDetached
 

Detailed Description

Definition at line 59 of file ServiceRep.h.

Member Typedef Documentation

Definition at line 124 of file ServiceRep.h.

typedef String Adaptation::Service::Id
inherited

Definition at line 31 of file Service.h.

Constructor & Destructor Documentation

Adaptation::Icap::ServiceRep::ServiceRep ( const ServiceConfigPointer aConfig)
explicit

Definition at line 34 of file ServiceRep.cc.

References NULL, setMaxConnections(), and theIdleConns.

Adaptation::Icap::ServiceRep::~ServiceRep ( )
virtual

Definition at line 50 of file ServiceRep.cc.

References Must.

Member Function Documentation

bool Adaptation::Icap::ServiceRep::allows204 ( ) const

Definition at line 344 of file ServiceRep.cc.

References Must.

bool Adaptation::Icap::ServiceRep::allows206 ( ) const

Definition at line 350 of file ServiceRep.cc.

References Must.

void Adaptation::Initiator::announceInitiatorAbort ( CbcPointer< Initiate > &  x)
protectedinherited

Definition at line 38 of file Initiator.cc.

References CallJobHere.

Referenced by Client::cleanAdaptation(), and ClientHttpRequest::~ClientHttpRequest().

void Adaptation::Icap::ServiceRep::announceStatusChange ( const char *  downPhrase,
bool  important 
) const
private

Definition at line 531 of file ServiceRep.cc.

References debugs.

int Adaptation::Icap::ServiceRep::availableConnections ( ) const
private

The available connections slots to the ICAP server

Returns
the available slots, or -1 if there is no limit on allowed connections

Definition at line 198 of file ServiceRep.cc.

References DBG_IMPORTANT, debugs, max(), and Adaptation::srvForce.

bool Adaptation::Icap::ServiceRep::availableForNew ( ) const

Definition at line 305 of file ServiceRep.cc.

References Must.

bool Adaptation::Icap::ServiceRep::availableForOld ( ) const

Definition at line 315 of file ServiceRep.cc.

References Must.

bool Adaptation::Service::broken ( ) const
virtualinherited

Definition at line 30 of file Service.cc.

void Adaptation::Icap::ServiceRep::busyCheckpoint ( )
private

If there are xactions waiting for the service to be available, notify as many xactions as the available connections slots.

Definition at line 246 of file ServiceRep.cc.

References Adaptation::Icap::ServiceRep::Client::callback, debugs, HERE(), i, NULL, and ScheduleCallHere.

void AsyncJob::callEnd ( )
virtualinherited
void Adaptation::Icap::ServiceRep::callException ( const std::exception &  e)
virtual

Reimplemented from AsyncJob.

Definition at line 576 of file ServiceRep.cc.

References debugs.

void AsyncJob::callStart ( AsyncCall call)
inherited
void Adaptation::Icap::ServiceRep::callWhenAvailable ( AsyncCall::Pointer cb,
bool  priority = false 
)

Definition at line 411 of file ServiceRep.cc.

References debugs, i, Must, and NULL.

void Adaptation::Icap::ServiceRep::callWhenReady ( AsyncCall::Pointer cb)
bool AsyncJob::canBeCalled ( AsyncCall call) const
inherited

Definition at line 101 of file AsyncJob.cc.

References AsyncCall::cancel(), debugs, HERE(), AsyncJob::inCall, and NULL.

Adaptation::Icap::ServiceRep::CBDATA_CLASS ( ServiceRep  )
private
void Adaptation::Icap::ServiceRep::changeOptions ( Options newOptions)
private

Definition at line 463 of file ServiceRep.cc.

References debugs, HERE(), and squid_curtime.

void Adaptation::Icap::ServiceRep::checkOptions ( )
private
void Adaptation::Initiator::clearAdaptation ( CbcPointer< Initiate > &  x)
protectedinherited
void AsyncJob::deleteThis ( const char *  aReason)
protectedinherited
void Adaptation::Icap::ServiceRep::detach ( )
virtual

called when removed from the config; the service will be auto-destroyed when the last refcounting user leaves

Implements Adaptation::Service.

Definition at line 727 of file ServiceRep.cc.

References debugs, and HERE().

bool Adaptation::Icap::ServiceRep::detached ( ) const
virtual

Implements Adaptation::Service.

Definition at line 734 of file ServiceRep.cc.

bool AsyncJob::done ( ) const
protectedinherited

Definition at line 90 of file AsyncJob.cc.

References AsyncJob::doneAll(), NULL, and AsyncJob::stopReason.

Referenced by AsyncJob::callEnd(), and Downloader::downloadFinished().

virtual bool Adaptation::Icap::ServiceRep::doneAll ( ) const
inlinevirtual

Reimplemented from AsyncJob.

Definition at line 100 of file ServiceRep.h.

References AsyncJob::doneAll().

int Adaptation::Icap::ServiceRep::excessConnections ( ) const
private

Definition at line 222 of file ServiceRep.cc.

bool Adaptation::Icap::ServiceRep::existWaiters ( ) const
inline

Definition at line 97 of file ServiceRep.h.

References theAllWaiters.

Comm::ConnectionPointer Adaptation::Icap::ServiceRep::getConnection ( bool  isRetriable,
bool &  isReused 
)

Definition at line 115 of file ServiceRep.cc.

References debugs, HERE(), and Comm::IsConnOpen().

Referenced by Adaptation::Icap::Xaction::openConnection().

void Adaptation::Icap::ServiceRep::handleNewOptions ( Options newOptions)
private

Definition at line 584 of file ServiceRep.cc.

References debugs, HERE(), and min().

bool Adaptation::Icap::ServiceRep::hasOptions ( ) const
private

Definition at line 295 of file ServiceRep.cc.

CbcPointer< Adaptation::Initiate > Adaptation::Initiator::initiateAdaptation ( Initiate x)
protectedinherited
bool Adaptation::Initiator::initiated ( const CbcPointer< AsyncJob > &  job) const
inlineprotectedinherited

Definition at line 52 of file Initiator.h.

References CbcPointer< Cbc >::set().

Referenced by Client::startAdaptation(), and ClientHttpRequest::startAdaptation().

Adaptation::Initiate * Adaptation::Icap::ServiceRep::makeXactLauncher ( Http::Message virginHeader,
HttpRequest virginCause,
AccessLogEntry::Pointer alp 
)
virtual

Implements Adaptation::Service.

Definition at line 680 of file ServiceRep.cc.

bool Adaptation::Icap::ServiceRep::needNewOptions ( ) const
private

Definition at line 458 of file ServiceRep.cc.

void Adaptation::Initiator::noteAdaptationAclCheckDone ( Adaptation::ServiceGroupPointer  group)
virtualinherited

AccessCheck calls this back with a possibly nil service group to signal whether adaptation is needed and where it should start.

Reimplemented in ClientHttpRequest, and Client.

Definition at line 17 of file Initiator.cc.

References Must.

void Adaptation::Icap::ServiceRep::noteAdaptationAnswer ( const Answer answer)
virtual

called with the initial adaptation decision (adapt, block, error); virgin and/or adapted body transmission may continue after this

Implements Adaptation::Initiator.

Definition at line 546 of file ServiceRep.cc.

References Adaptation::Answer::akError, Adaptation::Answer::akForward, Adaptation::Icap::Options::configure(), DBG_IMPORTANT, debugs, RefCount< C >::getRaw(), HERE(), Adaptation::Answer::kind, Adaptation::Answer::message, Must, and NULL.

void Adaptation::Icap::ServiceRep::noteConnectionFailed ( const char *  comment)

Definition at line 177 of file ServiceRep.cc.

References debugs, and HERE().

void Adaptation::Icap::ServiceRep::noteConnectionUse ( const Comm::ConnectionPointer conn)

Definition at line 171 of file ServiceRep.cc.

References Comm::Connection::fd, fd_table, Comm::IsConnOpen(), and Must.

void Adaptation::Icap::ServiceRep::noteFailure ( )
virtual
void Adaptation::Icap::ServiceRep::noteGoneWaiter ( )

Definition at line 237 of file ServiceRep.cc.

void Adaptation::Icap::ServiceRep::noteNewWaiter ( )
inline

Definition at line 95 of file ServiceRep.h.

References theAllWaiters.

void Adaptation::Icap::ServiceRep::noteTimeToNotify ( )
void Adaptation::Icap::ServiceRep::noteTimeToUpdate ( )

Definition at line 366 of file ServiceRep.cc.

References debugs, and HERE().

Referenced by ServiceRep_noteTimeToUpdate().

time_t Adaptation::Icap::ServiceRep::optionsFetchTime ( ) const
private
ICAP::Method Adaptation::Icap::ServiceRep::parseMethod ( const char *  ) const
private
ICAP::VectPoint Adaptation::Icap::ServiceRep::parseVectPoint ( const char *  ) const
private
bool Adaptation::Icap::ServiceRep::probed ( ) const
virtual

Implements Adaptation::Service.

Definition at line 290 of file ServiceRep.cc.

void Adaptation::Icap::ServiceRep::putConnection ( const Comm::ConnectionPointer conn,
bool  isReusable,
bool  sendReset,
const char *  comment 
)
void Adaptation::Icap::ServiceRep::scheduleNotification ( )
private

Definition at line 452 of file ServiceRep.cc.

References CallJobHere, debugs, and HERE().

void Adaptation::Icap::ServiceRep::scheduleUpdate ( time_t  when)
private
void Adaptation::Icap::ServiceRep::setMaxConnections ( )
private

Definition at line 183 of file ServiceRep.cc.

Referenced by ServiceRep().

void Adaptation::Icap::ServiceRep::startGettingOptions ( )
private

Definition at line 606 of file ServiceRep.cc.

References debugs, HERE(), and Must.

const char * Adaptation::Icap::ServiceRep::status ( ) const
privatevirtual

for debugging, starts with space

Reimplemented from AsyncJob.

Definition at line 687 of file ServiceRep.cc.

References MemBuf::append(), Packable::appendf(), buf, MemBuf::content(), MemBuf::reset(), and MemBuf::terminate().

void Adaptation::Icap::ServiceRep::suspend ( const char *  reason)
private
virtual void* CbdataParent::toCbdata ( )
pure virtualinherited
bool Adaptation::Icap::ServiceRep::up ( ) const
virtual

Implements Adaptation::Service.

Definition at line 300 of file ServiceRep.cc.

bool Adaptation::Service::wants ( const ServiceFilter filter) const
inherited
bool Adaptation::Icap::ServiceRep::wantsPreview ( const SBuf urlPath,
size_t wantedSize 
) const

Definition at line 329 of file ServiceRep.cc.

References Must, and Adaptation::Icap::Options::xferPreview.

bool Adaptation::Icap::ServiceRep::wantsUrl ( const SBuf urlPath) const
virtual

Implements Adaptation::Service.

Definition at line 323 of file ServiceRep.cc.

References Must, and Adaptation::Icap::Options::xferIgnore.

ServiceConfig& Adaptation::Service::writeableCfg ( )
inlineprotectedinherited

Definition at line 62 of file Service.h.

References Adaptation::Service::theConfig.

Member Data Documentation

bool Adaptation::Icap::ServiceRep::connOverloadReported
mutableprivate

Definition at line 141 of file ServiceRep.h.

const InstanceId<AsyncJob> AsyncJob::id
protectedinherited

Definition at line 70 of file AsyncJob.h.

AsyncCall::Pointer AsyncJob::inCall
protectedinherited
bool Adaptation::Icap::ServiceRep::isDetached
private

Definition at line 188 of file ServiceRep.h.

const char* Adaptation::Icap::ServiceRep::isSuspended
private

Definition at line 145 of file ServiceRep.h.

bool Adaptation::Icap::ServiceRep::notifying
private

Definition at line 147 of file ServiceRep.h.

Security::ContextPointer Adaptation::Icap::ServiceRep::sslContext

Definition at line 113 of file ServiceRep.h.

Security::SessionStatePointer Adaptation::Icap::ServiceRep::sslSession

Definition at line 114 of file ServiceRep.h.

const char* AsyncJob::stopReason
protectedinherited
int Adaptation::Icap::ServiceRep::theAllWaiters
private

number of xactions waiting for a connection slot (notified and not) the number is decreased after the xaction receives notification

Definition at line 138 of file ServiceRep.h.

Referenced by existWaiters(), and noteNewWaiter().

int Adaptation::Icap::ServiceRep::theBusyConns
private

number of connections given to active transactions

Definition at line 135 of file ServiceRep.h.

Clients Adaptation::Icap::ServiceRep::theClients
private

Definition at line 126 of file ServiceRep.h.

IdleConnList* Adaptation::Icap::ServiceRep::theIdleConns
private

Definition at line 142 of file ServiceRep.h.

Referenced by ServiceRep().

time_t Adaptation::Icap::ServiceRep::theLastUpdate
private

Definition at line 130 of file ServiceRep.h.

int Adaptation::Icap::ServiceRep::theMaxConnections
private

Definition at line 139 of file ServiceRep.h.

std::deque<Client> Adaptation::Icap::ServiceRep::theNotificationWaiters
private

FIFO queue of xactions waiting for a connection slot and not yet notified about it; xaction is removed when notification is scheduled

Definition at line 134 of file ServiceRep.h.

Options* Adaptation::Icap::ServiceRep::theOptions
private

Definition at line 128 of file ServiceRep.h.

CbcPointer<Adaptation::Initiate> Adaptation::Icap::ServiceRep::theOptionsFetcher
private

Definition at line 129 of file ServiceRep.h.

FadingCounter Adaptation::Icap::ServiceRep::theSessionFailures
private

Definition at line 144 of file ServiceRep.h.

bool Adaptation::Icap::ServiceRep::updateScheduled
private

Definition at line 148 of file ServiceRep.h.

bool Adaptation::Icap::ServiceRep::wasAnnouncedUp
mutableprivate

Definition at line 187 of file ServiceRep.h.


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

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors