#include <ServiceRep.h>

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


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
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...
 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

◆ Clients

Definition at line 124 of file ServiceRep.h.

◆ Id

typedef String Adaptation::Service::Id

Definition at line 31 of file Service.h.

◆ Pointer

Constructor & Destructor Documentation

◆ ServiceRep()

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

Definition at line 34 of file ServiceRep.cc.

References NULL, setMaxConnections(), and theIdleConns.

◆ ~ServiceRep()

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

Definition at line 50 of file ServiceRep.cc.

References Must, SWALLOW_EXCEPTIONS, theIdleConns, theOptions, and theOptionsFetcher.

Member Function Documentation

◆ allows204()

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

Definition at line 346 of file ServiceRep.cc.

References hasOptions(), and Must.

◆ allows206()

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

◆ announceInitiatorAbort()

◆ announceStatusChange()

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

◆ availableConnections()

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

The available connections slots to the ICAP server

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

Definition at line 200 of file ServiceRep.cc.

References Adaptation::Service::cfg(), connOverloadReported, IdleConnList::count(), DBG_IMPORTANT, debugs, max(), Adaptation::ServiceConfig::onOverload, Adaptation::srvForce, theBusyConns, theIdleConns, and theMaxConnections.

Referenced by availableForNew(), availableForOld(), and busyCheckpoint().

◆ availableForNew()

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

Definition at line 307 of file ServiceRep.cc.

References availableConnections(), Must, theAllWaiters, and up().

◆ availableForOld()

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

Definition at line 317 of file ServiceRep.cc.

References availableConnections(), Must, and up().

◆ broken()

bool Adaptation::Service::broken ( ) const

◆ busyCheckpoint()

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

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

Definition at line 248 of file ServiceRep.cc.

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

Referenced by callWhenAvailable(), noteGoneWaiter(), and putConnection().

◆ callEnd()

void AsyncJob::callEnd ( )

◆ callException()

void Adaptation::Icap::ServiceRep::callException ( const std::exception &  e)

Reimplemented from AsyncJob.

Definition at line 578 of file ServiceRep.cc.

References Adaptation::Initiator::clearAdaptation(), debugs, handleNewOptions(), status(), and theOptionsFetcher.

Referenced by doneAll().

◆ callStart()

void AsyncJob::callStart ( AsyncCall call)

◆ callWhenAvailable()

void Adaptation::Icap::ServiceRep::callWhenAvailable ( AsyncCall::Pointer cb,
bool  priority = false 

◆ callWhenReady()

◆ canBeCalled()

bool AsyncJob::canBeCalled ( AsyncCall call) const

Definition at line 101 of file AsyncJob.cc.

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

Referenced by AsyncJob::swanSong().


Adaptation::Icap::ServiceRep::CBDATA_CLASS ( ServiceRep  )

◆ cfg()

◆ changeOptions()

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

◆ checkOptions()

◆ clearAdaptation()

◆ deleteThis()

void AsyncJob::deleteThis ( const char *  aReason)

◆ detach()

void Adaptation::Icap::ServiceRep::detach ( )

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

Implements Adaptation::Service.

Definition at line 729 of file ServiceRep.cc.

References Adaptation::Service::cfg(), debugs, HERE(), isDetached, and status().

Referenced by doneAll().

◆ detached()

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

Implements Adaptation::Service.

Definition at line 736 of file ServiceRep.cc.

References isDetached.

Referenced by doneAll(), needNewOptions(), noteTimeToUpdate(), and status().

◆ done()

◆ doneAll()

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

◆ excessConnections()

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

Definition at line 224 of file ServiceRep.cc.

References IdleConnList::count(), theBusyConns, theIdleConns, and theMaxConnections.

Referenced by handleNewOptions(), and putConnection().

◆ existWaiters()

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

Definition at line 97 of file ServiceRep.h.

References theAllWaiters.

◆ finalize()

◆ getConnection()

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

◆ handleNewOptions()

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

◆ hasOptions()

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

◆ initiateAdaptation()

◆ initiated()

bool Adaptation::Initiator::initiated ( const CbcPointer< AsyncJob > &  job) const

◆ makeXactLauncher()

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

Implements Adaptation::Service.

Definition at line 682 of file ServiceRep.cc.

◆ mustStop()

void AsyncJob::mustStop ( const char *  aReason)

Definition at line 69 of file AsyncJob.cc.

References debugs, AsyncJob::inCall, Must, NULL, AsyncJob::stopReason, and AsyncJob::typeName.

Referenced by HttpStateData::abortAll(), Ftp::Client::abortAll(), Comm::TcpAcceptor::acceptOne(), Adaptation::Ecap::XactionRep::adaptationAborted(), Adaptation::AccessCheck::callBack(), AsyncJob::callException(), Security::PeerConnector::connectionClosed(), HttpStateData::continueAfterParsingHeader(), Ftp::Client::ctrlClosed(), Adaptation::Iterator::handleAdaptationBlock(), Adaptation::Iterator::handleAdaptationError(), Log::TcpLogger::handleClosure(), Adaptation::Icap::Xaction::handleCommClosed(), Http::Tunneler::handleConnectionClosure(), Mgr::Forwarder::handleError(), Ipc::Forwarder::handleError(), Ipc::Forwarder::handleException(), Ipc::Inquirer::handleException(), HttpStateData::handleMoreRequestBodyAvailable(), Ipc::Inquirer::handleRemoteAck(), Ipc::Forwarder::handleTimeout(), HttpStateData::httpStateConnClosed(), HttpStateData::httpTimeout(), Comm::ConnOpener::noteAbort(), Adaptation::Icap::ModXact::noteBodyConsumerAborted(), Snmp::Forwarder::noteCommClosed(), Snmp::Inquirer::noteCommClosed(), Mgr::Inquirer::noteCommClosed(), Mgr::Forwarder::noteCommClosed(), Mgr::StoreToCommWriter::noteCommClosed(), Adaptation::Icap::Xaction::noteCommRead(), Rock::HeaderUpdater::noteDoneReading(), Adaptation::Iterator::noteInitiatorAborted(), Adaptation::Icap::Xaction::noteInitiatorAborted(), Adaptation::Ecap::XactionRep::noteInitiatorAborted(), HttpStateData::readReply(), Comm::ConnOpener::sendAnswer(), Rock::Rebuild::start(), Security::PeerConnector::start(), HttpStateData::start(), Ipc::UdsSender::timedout(), and HttpStateData::wroteLast().

◆ needNewOptions()

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

Definition at line 460 of file ServiceRep.cc.

References detached(), and up().

Referenced by callWhenReady().

◆ noteAdaptationAclCheckDone()

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

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.

Referenced by Adaptation::Initiator::~Initiator().

◆ noteAdaptationAnswer()

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

◆ noteConnectionFailed()

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

◆ noteConnectionUse()

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

◆ noteFailure()

◆ noteGoneWaiter()

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

Definition at line 239 of file ServiceRep.cc.

References busyCheckpoint(), and theAllWaiters.

Referenced by noteNewWaiter().

◆ noteNewWaiter()

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

Definition at line 95 of file ServiceRep.h.

References noteGoneWaiter(), and theAllWaiters.

◆ noteTimeToNotify()

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

◆ noteTimeToUpdate()

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

◆ optionsFetchTime()

time_t Adaptation::Icap::ServiceRep::optionsFetchTime ( ) const

◆ parseMethod()

ICAP::Method Adaptation::Icap::ServiceRep::parseMethod ( const char *  ) const

◆ parseVectPoint()

ICAP::VectPoint Adaptation::Icap::ServiceRep::parseVectPoint ( const char *  ) const

◆ probed()

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

Implements Adaptation::Service.

Definition at line 292 of file ServiceRep.cc.

References theLastUpdate.

◆ putConnection()

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

◆ scheduleNotification()

void Adaptation::Icap::ServiceRep::scheduleNotification ( )

Definition at line 454 of file ServiceRep.cc.

References CallJobHere, debugs, HERE(), noteTimeToNotify(), and theClients.

Referenced by callWhenReady(), and handleNewOptions().

◆ scheduleUpdate()

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

◆ setMaxConnections()

void Adaptation::Icap::ServiceRep::setMaxConnections ( )

◆ Start()

◆ start()

◆ startGettingOptions()

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

◆ status()

◆ suspend()

void Adaptation::Icap::ServiceRep::suspend ( const char *  reason)

◆ swanSong()

◆ toCbdata()

virtual void* CbdataParent::toCbdata ( )
pure virtualinherited

◆ up()

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

◆ wants()

◆ wantsPreview()

bool Adaptation::Icap::ServiceRep::wantsPreview ( const SBuf urlPath,
size_t wantedSize 
) const

◆ wantsUrl()

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

◆ writeableCfg()

ServiceConfig& Adaptation::Service::writeableCfg ( )

Definition at line 62 of file Service.h.

References Adaptation::Service::theConfig.

Referenced by Adaptation::Ecap::ServiceRep::finalize(), and finalize().

Member Data Documentation

◆ connOverloadReported

bool Adaptation::Icap::ServiceRep::connOverloadReported

Definition at line 141 of file ServiceRep.h.

Referenced by availableConnections().

◆ id

const InstanceId<AsyncJob> AsyncJob::id

Definition at line 72 of file AsyncJob.h.

◆ inCall

◆ isDetached

bool Adaptation::Icap::ServiceRep::isDetached

Definition at line 188 of file ServiceRep.h.

Referenced by detach(), and detached().

◆ isSuspended

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

Definition at line 145 of file ServiceRep.h.

Referenced by changeOptions(), noteFailure(), status(), suspend(), and up().

◆ notifying

bool Adaptation::Icap::ServiceRep::notifying

Definition at line 147 of file ServiceRep.h.

Referenced by callWhenReady(), noteTimeToNotify(), and status().

◆ sslContext

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

Definition at line 113 of file ServiceRep.h.

Referenced by finalize().

◆ sslSession

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

Definition at line 114 of file ServiceRep.h.

◆ stopReason

const char* AsyncJob::stopReason

◆ theAllWaiters

int Adaptation::Icap::ServiceRep::theAllWaiters

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 availableForNew(), busyCheckpoint(), existWaiters(), noteGoneWaiter(), and noteNewWaiter().

◆ theBusyConns

int Adaptation::Icap::ServiceRep::theBusyConns

number of connections given to active transactions

Definition at line 135 of file ServiceRep.h.

Referenced by availableConnections(), excessConnections(), getConnection(), noteConnectionFailed(), and putConnection().

◆ theClients

Clients Adaptation::Icap::ServiceRep::theClients

Definition at line 126 of file ServiceRep.h.

Referenced by callWhenReady(), noteTimeToNotify(), and scheduleNotification().

◆ theIdleConns

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

◆ theLastUpdate

time_t Adaptation::Icap::ServiceRep::theLastUpdate

Definition at line 130 of file ServiceRep.h.

Referenced by changeOptions(), probed(), and scheduleUpdate().

◆ theMaxConnections

int Adaptation::Icap::ServiceRep::theMaxConnections

Definition at line 139 of file ServiceRep.h.

Referenced by availableConnections(), excessConnections(), and setMaxConnections().

◆ theNotificationWaiters

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

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.

Referenced by busyCheckpoint(), and callWhenAvailable().

◆ theOptions

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

◆ theOptionsFetcher

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

◆ theSessionFailures

FadingCounter Adaptation::Icap::ServiceRep::theSessionFailures

Definition at line 144 of file ServiceRep.h.

Referenced by changeOptions(), finalize(), noteFailure(), and status().

◆ typeName

◆ updateScheduled

bool Adaptation::Icap::ServiceRep::updateScheduled

Definition at line 148 of file ServiceRep.h.

Referenced by noteTimeToUpdate(), and scheduleUpdate().

◆ wasAnnouncedUp

bool Adaptation::Icap::ServiceRep::wasAnnouncedUp

Definition at line 187 of file ServiceRep.h.

Referenced by announceStatusChange().

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






Web Site Translations