Squid Web Cache master
Loading...
Searching...
No Matches
Ipc::Coordinator Class Referenceabstract

Coordinates shared activities of Strands (Squid processes or threads) More...

#include <Coordinator.h>

Inheritance diagram for Ipc::Coordinator:
[legend]
Collaboration diagram for Ipc::Coordinator:
[legend]

Public Types

typedef CbcPointer< AsyncJobPointer
 

Public Member Functions

 Coordinator ()
 
void broadcastSignal (int sig) const
 send sig to registered strands
 
const StrandCoordsstrands () const
 currently registered strands
 
bool canBeCalled (AsyncCall &call) const
 whether we can be called
 
void callStart (AsyncCall &call)
 
virtual void callEnd ()
 called right after the called job method
 
virtual void callException (const std::exception &e)
 called when the job throws during an async call
 
void handleStopRequest ()
 process external request to terminate now (i.e. during this async call)
 
virtual void * toCbdata ()=0
 

Static Public Member Functions

static CoordinatorInstance ()
 
static String MakeAddr (const char *proccessLabel, int id)
 calculates IPC message address for strand id of processLabel type
 
static String CoordinatorAddr ()
 get the IPC message address for coordinator process
 
static void Start (const Pointer &job)
 
static void RegisterWithCacheManager ()
 

Public Attributes

struct sockaddr_un address
 UDS address from path; treat as read-only.
 
const InstanceId< AsyncJobid
 job identifier
 

Protected Member Functions

void start () override
 called by AsyncStart; do not call directly
 
void receive (const TypedMsgHdr &message) override
 
StrandCoordfindStrand (int kidId)
 registered strand or NULL
 
void registerStrand (const StrandCoord &)
 adds or updates existing
 
void handleRegistrationRequest (const StrandMessage &)
 register,ACK
 
void notifySearcher (const StrandSearchRequest &request, const StrandCoord &)
 answer the waiting search request
 
void handleSearchRequest (const StrandSearchRequest &request)
 answers or queues the request if the answer is not yet known
 
void handleSharedListenRequest (const SharedListenRequest &request)
 returns cached socket or calls openListenSocket()
 
void handleCacheMgrRequest (const Mgr::Request &request)
 
void handleCacheMgrResponse (const Mgr::Response &response)
 
void handleSnmpRequest (const Snmp::Request &request)
 
void handleSnmpResponse (const Snmp::Response &response)
 
Comm::ConnectionPointer openListenSocket (const SharedListenRequest &request, int &errNo)
 calls comm_open_listener()
 
bool doneAll () const override
 whether positive goal has been reached
 
void doListen ()
 read the next incoming message
 
virtual void timedout ()
 called after setTimeout() if timed out
 
Comm::ConnectionPointerconn ()
 creates if needed and returns raw UDS socket descriptor
 
void setTimeout (time_t seconds, const char *handlerName)
 call timedout() if no UDS messages in a given number of seconds
 
void clearTimeout ()
 remove previously set timeout, if any
 
void setOptions (int newOptions)
 changes socket options
 
void deleteThis (const char *aReason)
 
void mustStop (const char *aReason)
 
bool done () const
 the job is destroyed in callEnd() when done()
 
virtual void swanSong ()
 
virtual const char * status () const
 internal cleanup; do not call directly
 

Static Protected Member Functions

static void ReportAllJobs (StoreEntry *)
 writes a cache manager report about all jobs existing in this worker
 

Protected Attributes

const char * stopReason
 reason for forcing done() to be true
 
const char * typeName
 kid (leaf) class name, for debugging
 
AsyncCall::Pointer inCall
 the asynchronous call being handled, if any
 
bool started_ = false
 Start() has finished successfully.
 
bool swanSang_ = false
 swanSong() was called
 

Private Types

typedef std::list< StrandSearchRequestSearchers
 search requests
 
typedef std::map< OpenListenerParams, Comm::ConnectionPointerListeners
 params:connection map
 

Private Member Functions

 CBDATA_CHILD (Coordinator)
 
 Coordinator (const Coordinator &)
 
Coordinatoroperator= (const Coordinator &)
 
void noteRead (const CommIoCbParams &params)
 
void receiveOrIgnore (const TypedMsgHdr &)
 receive() but ignore any errors
 
void noteTimeout (const CommTimeoutCbParams &p)
 Comm timeout callback; calls timedout()
 
virtual void finalizedInCbdataChild ()=0
 hack: ensure CBDATA_CHILD() after a toCbdata()-defining CBDATA_INTERMEDIATE()
 

Private Attributes

StrandCoords strands_
 registered processes and threads
 
Searchers searchers
 yet unanswered search requests in arrival order
 
Listeners listeners
 cached comm_open_listener() results
 
TypedMsgHdr buf
 msghdr struct filled by Comm
 
int options
 UDS options.
 
Comm::ConnectionPointer conn_
 UDS descriptor.
 

Static Private Attributes

static CoordinatorTheInstance = nullptr
 the only class instance in existence
 

Detailed Description

Definition at line 30 of file Coordinator.h.

Member Typedef Documentation

◆ Listeners

Definition at line 74 of file Coordinator.h.

◆ Pointer

Definition at line 34 of file AsyncJob.h.

◆ Searchers

Definition at line 71 of file Coordinator.h.

Constructor & Destructor Documentation

◆ Coordinator() [1/2]

Ipc::Coordinator::Coordinator ( )

Definition at line 39 of file Coordinator.cc.

◆ Coordinator() [2/2]

Ipc::Coordinator::Coordinator ( const Coordinator )
private

Member Function Documentation

◆ broadcastSignal()

void Ipc::Coordinator::broadcastSignal ( int  sig) const

Definition at line 286 of file Coordinator.cc.

References debugs.

◆ callEnd()

void AsyncJob::callEnd ( )
virtualinherited

◆ callException()

◆ callStart()

void AsyncJob::callStart ( AsyncCall call)
inherited

◆ canBeCalled()

bool AsyncJob::canBeCalled ( AsyncCall call) const
inherited

Definition at line 117 of file AsyncJob.cc.

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

◆ CBDATA_CHILD()

Ipc::Coordinator::CBDATA_CHILD ( Coordinator  )
private

◆ clearTimeout()

void Ipc::UdsOp::clearTimeout ( )
protectedinherited

Definition at line 63 of file UdsOp.cc.

References commUnsetConnTimeout().

◆ conn()

Comm::ConnectionPointer & Ipc::UdsOp::conn ( )
protectedinherited

Definition at line 42 of file UdsOp.cc.

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

◆ CoordinatorAddr()

◆ deleteThis()

void AsyncJob::deleteThis ( const char *  aReason)
protectedinherited

◆ doListen()

void Ipc::Port::doListen ( )
protectedinherited

Definition at line 38 of file Port.cc.

References comm_read(), debugs, JobCallback, MYNAME, and Ipc::Port::noteRead().

◆ done()

bool AsyncJob::done ( ) const
protectedinherited

◆ doneAll()

bool Ipc::Port::doneAll ( ) const
overrideprotectedvirtualinherited

Reimplemented from AsyncJob.

Definition at line 48 of file Port.cc.

◆ finalizedInCbdataChild()

virtual void CbdataParent::finalizedInCbdataChild ( )
privatepure virtualinherited

◆ findStrand()

Ipc::StrandCoord * Ipc::Coordinator::findStrand ( int  kidId)
protected

Definition at line 49 of file Coordinator.cc.

◆ handleCacheMgrRequest()

◆ handleCacheMgrResponse()

void Ipc::Coordinator::handleCacheMgrResponse ( const Mgr::Response response)
protected

Definition at line 198 of file Coordinator.cc.

References Ipc::Inquirer::HandleRemoteAck().

◆ handleRegistrationRequest()

void Ipc::Coordinator::handleRegistrationRequest ( const StrandMessage msg)
protected

◆ handleSearchRequest()

void Ipc::Coordinator::handleSearchRequest ( const StrandSearchRequest request)
protected

◆ handleSharedListenRequest()

◆ handleSnmpRequest()

void Ipc::Coordinator::handleSnmpRequest ( const Snmp::Request request)
protected

◆ handleSnmpResponse()

void Ipc::Coordinator::handleSnmpResponse ( const Snmp::Response response)
protected

Definition at line 251 of file Coordinator.cc.

References debugs, Ipc::Inquirer::HandleRemoteAck(), and MYNAME.

◆ handleStopRequest()

void AsyncJob::handleStopRequest ( )
inlineinherited

Definition at line 73 of file AsyncJob.h.

References AsyncJob::mustStop().

◆ Instance()

Ipc::Coordinator * Ipc::Coordinator::Instance ( )
static

Definition at line 296 of file Coordinator.cc.

Referenced by SquidMain().

◆ MakeAddr()

String Ipc::Port::MakeAddr ( const char *  proccessLabel,
int  id 
)
staticinherited

◆ mustStop()

◆ noteRead()

void Ipc::Port::noteRead ( const CommIoCbParams params)
privateinherited

◆ noteTimeout()

void Ipc::UdsOp::noteTimeout ( const CommTimeoutCbParams p)
privateinherited

Definition at line 68 of file UdsOp.cc.

Referenced by Ipc::UdsOp::setTimeout().

◆ notifySearcher()

◆ openListenSocket()

◆ operator=()

Coordinator & Ipc::Coordinator::operator= ( const Coordinator )
private

◆ receive()

void Ipc::Coordinator::receive ( const TypedMsgHdr message)
overrideprotectedvirtual

◆ receiveOrIgnore()

void Ipc::Port::receiveOrIgnore ( const TypedMsgHdr message)
privateinherited

◆ registerStrand()

void Ipc::Coordinator::registerStrand ( const StrandCoord strand)
protected

Definition at line 59 of file Coordinator.cc.

References debugs, Ipc::StrandCoord::kidId, String::size(), and Ipc::StrandCoord::tag.

◆ RegisterWithCacheManager()

void AsyncJob::RegisterWithCacheManager ( )
staticinherited

Definition at line 215 of file AsyncJob.cc.

References Mgr::RegisterAction(), and AsyncJob::ReportAllJobs().

Referenced by mainInitialize().

◆ ReportAllJobs()

void AsyncJob::ReportAllJobs ( StoreEntry e)
staticprotectedinherited

Definition at line 198 of file AsyncJob.cc.

References AllJobs().

Referenced by AsyncJob::RegisterWithCacheManager().

◆ setOptions()

void Ipc::UdsOp::setOptions ( int  newOptions)
protectedinherited

Definition at line 36 of file UdsOp.cc.

Referenced by Ipc::Port::Port().

◆ setTimeout()

void Ipc::UdsOp::setTimeout ( time_t  seconds,
const char *  handlerName 
)
protectedinherited

Definition at line 55 of file UdsOp.cc.

References asyncCall(), commSetConnTimeout(), and Ipc::UdsOp::noteTimeout().

◆ start()

void Ipc::Coordinator::start ( )
overrideprotectedvirtual

Implements Ipc::Port.

Definition at line 44 of file Coordinator.cc.

References Ipc::Port::start().

◆ Start()

void AsyncJob::Start ( const Pointer job)
staticinherited

◆ status()

◆ strands()

const Ipc::StrandCoords & Ipc::Coordinator::strands ( ) const

Definition at line 307 of file Coordinator.cc.

◆ swanSong()

◆ timedout()

virtual void Ipc::UdsOp::timedout ( )
inlineprotectedvirtualinherited

Reimplemented in Ipc::Strand, and Ipc::UdsSender.

Definition at line 40 of file UdsOp.h.

◆ toCbdata()

virtual void * CbdataParent::toCbdata ( )
pure virtualinherited

Member Data Documentation

◆ address

struct sockaddr_un Ipc::UdsOp::address
inherited

Definition at line 37 of file UdsOp.h.

Referenced by Ipc::UdsSender::UdsSender().

◆ buf

TypedMsgHdr Ipc::Port::buf
privateinherited

Definition at line 47 of file Port.h.

◆ conn_

Comm::ConnectionPointer Ipc::UdsOp::conn_
privateinherited

Definition at line 56 of file UdsOp.h.

◆ id

const InstanceId<AsyncJob> AsyncJob::id
inherited

Definition at line 75 of file AsyncJob.h.

◆ inCall

AsyncCall::Pointer AsyncJob::inCall
protectedinherited

◆ listeners

Listeners Ipc::Coordinator::listeners
private

Definition at line 75 of file Coordinator.h.

◆ options

int Ipc::UdsOp::options
privateinherited

Definition at line 55 of file UdsOp.h.

◆ searchers

Searchers Ipc::Coordinator::searchers
private

Definition at line 72 of file Coordinator.h.

◆ started_

bool AsyncJob::started_ = false
protectedinherited

Definition at line 88 of file AsyncJob.h.

Referenced by AsyncJob::~AsyncJob(), AsyncJob::callEnd(), and AsyncJob::Start().

◆ stopReason

const char* AsyncJob::stopReason
protectedinherited

◆ strands_

StrandCoords Ipc::Coordinator::strands_
private

Definition at line 69 of file Coordinator.h.

◆ swanSang_

bool AsyncJob::swanSang_ = false
protectedinherited

Definition at line 89 of file AsyncJob.h.

Referenced by AsyncJob::~AsyncJob(), and AsyncJob::callEnd().

◆ TheInstance

Ipc::Coordinator * Ipc::Coordinator::TheInstance = nullptr
staticprivate

Definition at line 77 of file Coordinator.h.

◆ typeName


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