#include <IpcIoFile.h>

Inheritance diagram for IpcIoFile:
Collaboration diagram for IpcIoFile:

Public Types

typedef RefCount< IpcIoFilePointer
 

Public Member Functions

 IpcIoFile (char const *aDb)
 
 ~IpcIoFile () override
 
void configure (const Config &cfg) override
 notes supported configuration options; kids must call this first More...
 
void open (int flags, mode_t mode, RefCount< IORequestor > callback) override
 
void create (int flags, mode_t mode, RefCount< IORequestor > callback) override
 
void read (ReadRequest *) override
 
void write (WriteRequest *) override
 
void close () override
 
bool error () const override
 
int getFD () const override
 
bool canRead () const override
 
bool canWrite () const override
 
bool ioInProgress () const override
 

Static Public Member Functions

static void HandleOpenResponse (const Ipc::StrandMessage &)
 handle open response from coordinator More...
 
static void HandleNotification (const Ipc::TypedMsgHdr &msg)
 handle queue push notifications from worker or disker More...
 
static void StatQueue (std::ostream &)
 prints IPC message queue state; suitable for cache manager reports More...
 

Public Attributes

DiskFile::Config config
 supported configuration options More...
 

Protected Member Functions

void openCompleted (const Ipc::StrandMessage *)
 
void readCompleted (ReadRequest *readRequest, IpcIoMsg *const response)
 
void writeCompleted (WriteRequest *writeRequest, const IpcIoMsg *const response)
 
bool canWait () const
 whether we think there is enough time to complete the I/O More...
 

Private Types

typedef std::map< unsigned int, IpcIoPendingRequest * > RequestMap
 maps requestId to the handleResponse callback More...
 
typedef std::list< PointerIpcIoFileList
 
typedef std::map< int, IpcIoFile * > IpcIoFilesMap
 
typedef Ipc::FewToFewBiQueue Queue
 

Private Member Functions

 CBDATA_CLASS (IpcIoFile)
 
void trackPendingRequest (const unsigned int id, IpcIoPendingRequest *const pending)
 track a new pending request More...
 
void push (IpcIoPendingRequest *const pending)
 push an I/O request to disker More...
 
IpcIoPendingRequestdequeueRequest (const unsigned int requestId)
 returns and forgets the right IpcIoFile pending request More...
 
size_t pendingRequests () const
 
void checkTimeouts ()
 
void scheduleTimeoutCheck ()
 prepare to check for timeouts in a little while More...
 
void handleResponse (IpcIoMsg &ipcIo)
 

Static Private Member Functions

static void Notify (const int peerId)
 
static void OpenTimeout (void *const param)
 handles open request timeout More...
 
static void CheckTimeouts (void *const param)
 IpcIoFile::checkTimeouts wrapper. More...
 
static void HandleResponses (const char *const when)
 
static void DiskerHandleMoreRequests (void *)
 
static void DiskerHandleRequests ()
 
static void DiskerHandleRequest (const int workerId, IpcIoMsg &ipcIo)
 called when disker receives an I/O request More...
 
static bool WaitBeforePop ()
 
static void HandleMessagesAtStart ()
 

Private Attributes

const String dbName
 the name of the file we are managing More...
 
const pid_t myPid
 optimization: cached process ID of our process More...
 
int diskId
 the kid ID of the disker we talk to More...
 
RefCount< IORequestorioRequestor
 
bool error_
 whether we have seen at least one I/O error (XXX) More...
 
unsigned int lastRequestId
 last requestId used More...
 
RequestMap requestMap1
 older (or newer) pending requests More...
 
RequestMap requestMap2
 newer (or older) pending requests More...
 
RequestMapolderRequests
 older requests (map1 or map2) More...
 
RequestMapnewerRequests
 newer requests (map2 or map1) More...
 
bool timeoutCheckScheduled
 we expect a CheckTimeouts() call More...
 

Static Private Attributes

static const double Timeout = 7
 timeout value in seconds More...
 
static IpcIoFileList WaitingForOpen
 pending open requests More...
 
static IpcIoFilesMap IpcIoFiles
 
static std::unique_ptr< Queuequeue
 IPC queue. More...
 
static bool DiskerHandleMoreRequestsScheduled = false
 whether we are waiting for an event to handle still queued I/O requests More...
 

Friends

class IpcIoPendingRequest
 

Detailed Description

In a worker process, represents a single (remote) cache_dir disker file. In a disker process, used as a bunch of static methods handling that file.

Definition at line 66 of file IpcIoFile.h.

Member Typedef Documentation

◆ IpcIoFileList

typedef std::list<Pointer> IpcIoFile::IpcIoFileList
private

Definition at line 153 of file IpcIoFile.h.

◆ IpcIoFilesMap

typedef std::map<int, IpcIoFile*> IpcIoFile::IpcIoFilesMap
private

Definition at line 157 of file IpcIoFile.h.

◆ Pointer

Definition at line 71 of file IpcIoFile.h.

◆ Queue

Definition at line 160 of file IpcIoFile.h.

◆ RequestMap

typedef std::map<unsigned int, IpcIoPendingRequest*> IpcIoFile::RequestMap
private

Definition at line 144 of file IpcIoFile.h.

Constructor & Destructor Documentation

◆ IpcIoFile()

IpcIoFile::IpcIoFile ( char const *  aDb)

Definition at line 95 of file IpcIoFile.cc.

References assert, and myPid.

◆ ~IpcIoFile()

IpcIoFile::~IpcIoFile ( )
override

Definition at line 107 of file IpcIoFile.cc.

References diskId, IpcIoFiles, Must, and SWALLOW_EXCEPTIONS.

Member Function Documentation

◆ canRead()

bool IpcIoFile::canRead ( ) const
overridevirtual

Implements DiskFile.

Definition at line 218 of file IpcIoFile.cc.

References canWait(), diskId, and error_.

◆ canWait()

bool IpcIoFile::canWait ( ) const
protected

◆ canWrite()

bool IpcIoFile::canWrite ( ) const
overridevirtual

Reimplemented from DiskFile.

Definition at line 224 of file IpcIoFile.cc.

References canWait(), diskId, and error_.

◆ CBDATA_CLASS()

IpcIoFile::CBDATA_CLASS ( IpcIoFile  )
private

◆ checkTimeouts()

◆ CheckTimeouts()

void IpcIoFile::CheckTimeouts ( void *const  param)
staticprivate

Definition at line 576 of file IpcIoFile.cc.

References debugs, diskId, IpcIoFiles, and Must.

Referenced by scheduleTimeoutCheck().

◆ close()

void IpcIoFile::close ( )
overridevirtual

◆ configure()

void IpcIoFile::configure ( const Config )
overridevirtual

Reimplemented from DiskFile.

Definition at line 120 of file IpcIoFile.cc.

References config, and DiskFile::configure().

◆ create()

void IpcIoFile::create ( int  flags,
mode_t  mode,
RefCount< IORequestor callback 
)
overridevirtual

Alias for IpcIoFile::open(...)

Implements DiskFile.

Definition at line 198 of file IpcIoFile.cc.

References assert, and open().

◆ dequeueRequest()

IpcIoPendingRequest * IpcIoFile::dequeueRequest ( const unsigned int  requestId)
private

Definition at line 644 of file IpcIoFile.cc.

References Must, requestMap1, and requestMap2.

Referenced by handleResponse().

◆ DiskerHandleMoreRequests()

void IpcIoFile::DiskerHandleMoreRequests ( void *  source)
staticprivate

◆ DiskerHandleRequest()

void IpcIoFile::DiskerHandleRequest ( const int  workerId,
IpcIoMsg ipcIo 
)
staticprivate

◆ DiskerHandleRequests()

◆ error()

bool IpcIoFile::error ( ) const
overridevirtual

Implements DiskFile.

Definition at line 230 of file IpcIoFile.cc.

References error_.

◆ getFD()

int IpcIoFile::getFD ( ) const
overridevirtual

During migration only

Reimplemented from DiskFile.

Definition at line 668 of file IpcIoFile.cc.

References assert.

◆ HandleMessagesAtStart()

void IpcIoFile::HandleMessagesAtStart ( )
staticprivate

Handle queued IPC messages for the first time in this process lifetime, when the queue may be reflecting the state of our killed predecessor.

See also
CollapsedForwarding::HandleNewDataAtStart() – duplicates this logic

Definition at line 537 of file IpcIoFile.cc.

References DiskerHandleRequests(), HandleResponses(), IamDiskProcess(), and queue.

Referenced by open().

◆ HandleNotification()

void IpcIoFile::HandleNotification ( const Ipc::TypedMsgHdr msg)
static

◆ HandleOpenResponse()

void IpcIoFile::HandleOpenResponse ( const Ipc::StrandMessage response)
static

called when coordinator responds to worker open request

Definition at line 456 of file IpcIoFile.cc.

References debugs, Ipc::StrandMessage::strand, Ipc::StrandCoord::tag, and WaitingForOpen.

Referenced by Ipc::Strand::receive().

◆ handleResponse()

void IpcIoFile::handleResponse ( IpcIoMsg ipcIo)
private

Definition at line 491 of file IpcIoFile.cc.

References CallBack(), debugs, dequeueRequest(), diskId, KidIdentifier, Must, and IpcIoMsg::requestId.

◆ HandleResponses()

void IpcIoFile::HandleResponses ( const char *const  when)
staticprivate

Definition at line 474 of file IpcIoFile.cc.

References debugs, diskId, IpcIoFiles, KidIdentifier, and queue.

Referenced by checkTimeouts(), HandleMessagesAtStart(), HandleNotification(), and push().

◆ ioInProgress()

bool IpcIoFile::ioInProgress ( ) const
overridevirtual

Inform callers if there is IO in progress

Implements DiskFile.

Definition at line 338 of file IpcIoFile.cc.

References newerRequests, and olderRequests.

◆ Notify()

void IpcIoFile::Notify ( const int  peerId)
staticprivate

◆ open()

◆ openCompleted()

void IpcIoFile::openCompleted ( const Ipc::StrandMessage response)
protected

◆ OpenTimeout()

void IpcIoFile::OpenTimeout ( void *const  param)
staticprivate

Definition at line 558 of file IpcIoFile.cc.

References Must, openCompleted(), and WaitingForOpen.

Referenced by open().

◆ pendingRequests()

size_t IpcIoFile::pendingRequests ( ) const
inlineprivate

the total number of I/O requests in push queue and pop queue (but no, the implementation does not add push and pop queue sizes)

Definition at line 114 of file IpcIoFile.h.

References newerRequests, and olderRequests.

Referenced by push().

◆ push()

◆ read()

void IpcIoFile::read ( ReadRequest readRequest)
overridevirtual

◆ readCompleted()

◆ scheduleTimeoutCheck()

void IpcIoFile::scheduleTimeoutCheck ( )
private

◆ StatQueue()

void IpcIoFile::StatQueue ( std::ostream &  os)
static

Definition at line 548 of file IpcIoFile.cc.

References queue.

Referenced by StatQueues().

◆ trackPendingRequest()

void IpcIoFile::trackPendingRequest ( const unsigned int  id,
IpcIoPendingRequest *const  pending 
)
private

Definition at line 345 of file IpcIoFile.cc.

References Must, newerRequests, scheduleTimeoutCheck(), and timeoutCheckScheduled.

Referenced by push().

◆ WaitBeforePop()

bool IpcIoFile::WaitBeforePop ( )
staticprivate

◆ write()

void IpcIoFile::write ( WriteRequest writeRequest)
overridevirtual

◆ writeCompleted()

void IpcIoFile::writeCompleted ( WriteRequest writeRequest,
const IpcIoMsg *const  response 
)
protected

Friends And Related Function Documentation

◆ IpcIoPendingRequest

friend class IpcIoPendingRequest
friend

Definition at line 101 of file IpcIoFile.h.

Referenced by read(), and write().

Member Data Documentation

◆ config

DiskFile::Config IpcIoFile::config

Definition at line 98 of file IpcIoFile.h.

Referenced by canWait(), configure(), and open().

◆ dbName

const String IpcIoFile::dbName
private

Definition at line 134 of file IpcIoFile.h.

Referenced by checkTimeouts(), close(), open(), openCompleted(), push(), readCompleted(), and writeCompleted().

◆ DiskerHandleMoreRequestsScheduled

bool IpcIoFile::DiskerHandleMoreRequestsScheduled = false
staticprivate

Definition at line 164 of file IpcIoFile.h.

Referenced by DiskerHandleMoreRequests(), DiskerHandleRequests(), and WaitBeforePop().

◆ diskId

◆ error_

bool IpcIoFile::error_
private

◆ ioRequestor

RefCount<IORequestor> IpcIoFile::ioRequestor
private

Definition at line 137 of file IpcIoFile.h.

Referenced by close(), open(), openCompleted(), read(), readCompleted(), write(), and writeCompleted().

◆ IpcIoFiles

IpcIoFile::IpcIoFilesMap IpcIoFile::IpcIoFiles
staticprivate

Definition at line 158 of file IpcIoFile.h.

Referenced by ~IpcIoFile(), CheckTimeouts(), HandleResponses(), open(), and openCompleted().

◆ lastRequestId

unsigned int IpcIoFile::lastRequestId
private

Definition at line 141 of file IpcIoFile.h.

Referenced by push().

◆ myPid

const pid_t IpcIoFile::myPid
private

Definition at line 135 of file IpcIoFile.h.

Referenced by IpcIoFile(), and push().

◆ newerRequests

RequestMap* IpcIoFile::newerRequests
private

Definition at line 148 of file IpcIoFile.h.

Referenced by checkTimeouts(), ioInProgress(), pendingRequests(), and trackPendingRequest().

◆ olderRequests

RequestMap* IpcIoFile::olderRequests
private

Definition at line 147 of file IpcIoFile.h.

Referenced by checkTimeouts(), ioInProgress(), and pendingRequests().

◆ queue

std::unique_ptr< IpcIoFile::Queue > IpcIoFile::queue
staticprivate

◆ requestMap1

RequestMap IpcIoFile::requestMap1
private

Definition at line 145 of file IpcIoFile.h.

Referenced by dequeueRequest().

◆ requestMap2

RequestMap IpcIoFile::requestMap2
private

Definition at line 146 of file IpcIoFile.h.

Referenced by dequeueRequest().

◆ Timeout

const double IpcIoFile::Timeout = 7
staticprivate

Definition at line 151 of file IpcIoFile.h.

Referenced by checkTimeouts(), open(), scheduleTimeoutCheck(), and WaitBeforePop().

◆ timeoutCheckScheduled

bool IpcIoFile::timeoutCheckScheduled
private

Definition at line 149 of file IpcIoFile.h.

Referenced by checkTimeouts(), scheduleTimeoutCheck(), and trackPendingRequest().

◆ WaitingForOpen

IpcIoFile::IpcIoFileList IpcIoFile::WaitingForOpen
staticprivate

maps diskerId to IpcIoFile, cleared in destructor

Definition at line 154 of file IpcIoFile.h.

Referenced by HandleOpenResponse(), open(), and OpenTimeout().


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

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors