#include <IpcIoFile.h>

Inheritance diagram for IpcIoFile:
Collaboration diagram for IpcIoFile:

Public Types

typedef RefCount< IpcIoFilePointer
 

Public Member Functions

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

Static Public Member Functions

static void HandleOpenResponse (const Ipc::StrandSearchResponse &response)
 handle open response from coordinator More...
 
static void HandleNotification (const Ipc::TypedMsgHdr &msg)
 handle queue push notifications from worker or disker More...
 

Public Attributes

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

Protected Member Functions

void openCompleted (const Ipc::StrandSearchResponse *const response)
 
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 ()
 

Private Attributes

const String dbName
 the name of the file we are managing More...
 
int diskId
 the process 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 60 of file IpcIoFile.h.

Member Typedef Documentation

◆ IpcIoFileList

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

Definition at line 141 of file IpcIoFile.h.

◆ IpcIoFilesMap

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

Definition at line 145 of file IpcIoFile.h.

◆ Pointer

Definition at line 65 of file IpcIoFile.h.

◆ Queue

Definition at line 148 of file IpcIoFile.h.

◆ RequestMap

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

Definition at line 132 of file IpcIoFile.h.

Constructor & Destructor Documentation

◆ IpcIoFile()

IpcIoFile::IpcIoFile ( char const *  aDb)

Definition at line 72 of file IpcIoFile.cc.

◆ ~IpcIoFile()

IpcIoFile::~IpcIoFile ( )
virtual

Definition at line 79 of file IpcIoFile.cc.

References diskId, i, IpcIoFiles, Must, and SWALLOW_EXCEPTIONS.

Member Function Documentation

◆ canRead()

bool IpcIoFile::canRead ( ) const
virtual

Implements DiskFile.

Definition at line 193 of file IpcIoFile.cc.

References canWait(), diskId, and error_.

◆ canWait()

bool IpcIoFile::canWait ( ) const
protected

◆ canWrite()

bool IpcIoFile::canWrite ( ) const
virtual

Reimplemented from DiskFile.

Definition at line 199 of file IpcIoFile.cc.

References canWait(), diskId, and error_.

◆ CBDATA_CLASS()

IpcIoFile::CBDATA_CLASS ( IpcIoFile  )
private

◆ CheckTimeouts()

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

Definition at line 521 of file IpcIoFile.cc.

References debugs, diskId, HERE(), i, IpcIoFiles, and Must.

Referenced by scheduleTimeoutCheck().

◆ checkTimeouts()

◆ close()

void IpcIoFile::close ( )
virtual

◆ configure()

void IpcIoFile::configure ( const Config )
virtual

Reimplemented from DiskFile.

Definition at line 92 of file IpcIoFile.cc.

References config, and DiskFile::configure().

◆ create()

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

Alias for IpcIoFile::open(...)

Implements DiskFile.

Definition at line 173 of file IpcIoFile.cc.

References assert, and open().

◆ dequeueRequest()

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

Definition at line 586 of file IpcIoFile.cc.

References i, Must, NULL, requestMap1, and requestMap2.

Referenced by handleResponse().

◆ DiskerHandleMoreRequests()

void IpcIoFile::DiskerHandleMoreRequests ( void *  source)
staticprivate

Definition at line 748 of file IpcIoFile.cc.

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

Referenced by DiskerHandleRequests(), and WaitBeforePop().

◆ DiskerHandleRequest()

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

◆ DiskerHandleRequests()

void IpcIoFile::DiskerHandleRequests ( )
staticprivate

◆ error()

bool IpcIoFile::error ( ) const
virtual

Implements DiskFile.

Definition at line 205 of file IpcIoFile.cc.

References error_.

◆ getFD()

int IpcIoFile::getFD ( ) const
virtual

During migration only

Reimplemented from DiskFile.

Definition at line 610 of file IpcIoFile.cc.

References assert.

◆ HandleNotification()

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

◆ HandleOpenResponse()

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

called when coordinator responds to worker open request

Definition at line 428 of file IpcIoFile.cc.

References debugs, HERE(), i, Ipc::StrandSearchResponse::strand, Ipc::StrandCoord::tag, and WaitingForOpen.

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

◆ handleResponse()

void IpcIoFile::handleResponse ( IpcIoMsg ipcIo)
private

◆ HandleResponses()

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

Definition at line 446 of file IpcIoFile.cc.

References debugs, diskId, HERE(), i, IpcIoFiles, Must, and queue.

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

◆ ioInProgress()

bool IpcIoFile::ioInProgress ( ) const
virtual

Inform callers if there is IO in progress

Implements DiskFile.

Definition at line 313 of file IpcIoFile.cc.

References newerRequests, and olderRequests.

◆ Notify()

void IpcIoFile::Notify ( const int  peerId)
staticprivate

◆ open()

◆ openCompleted()

void IpcIoFile::openCompleted ( const Ipc::StrandSearchResponse *const  response)
protected

◆ OpenTimeout()

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

Definition at line 503 of file IpcIoFile.cc.

References i, Must, NULL, 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 105 of file IpcIoFile.h.

References checkTimeouts().

Referenced by push().

◆ push()

◆ read()

void IpcIoFile::read ( ReadRequest readRequest)
virtual

◆ readCompleted()

◆ scheduleTimeoutCheck()

void IpcIoFile::scheduleTimeoutCheck ( )
private

Definition at line 576 of file IpcIoFile.cc.

References CheckTimeouts(), diskId, eventAdd(), Timeout, and timeoutCheckScheduled.

Referenced by checkTimeouts(), and trackPendingRequest().

◆ trackPendingRequest()

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

Definition at line 320 of file IpcIoFile.cc.

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

Referenced by push().

◆ WaitBeforePop()

bool IpcIoFile::WaitBeforePop ( )
staticprivate

◆ write()

void IpcIoFile::write ( WriteRequest writeRequest)
virtual

◆ writeCompleted()

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

Friends And Related Function Documentation

◆ IpcIoPendingRequest

friend class IpcIoPendingRequest
friend

Definition at line 92 of file IpcIoFile.h.

Referenced by read(), and write().

Member Data Documentation

◆ config

DiskFile::Config IpcIoFile::config

Definition at line 89 of file IpcIoFile.h.

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

◆ dbName

const String IpcIoFile::dbName
private

Definition at line 123 of file IpcIoFile.h.

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

◆ DiskerHandleMoreRequestsScheduled

bool IpcIoFile::DiskerHandleMoreRequestsScheduled = false
staticprivate

Definition at line 152 of file IpcIoFile.h.

◆ diskId

◆ error_

bool IpcIoFile::error_
private

◆ ioRequestor

RefCount<IORequestor> IpcIoFile::ioRequestor
private

Definition at line 125 of file IpcIoFile.h.

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

◆ IpcIoFiles

IpcIoFile::IpcIoFilesMap IpcIoFile::IpcIoFiles
staticprivate

Definition at line 146 of file IpcIoFile.h.

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

◆ lastRequestId

unsigned int IpcIoFile::lastRequestId
private

Definition at line 129 of file IpcIoFile.h.

Referenced by push().

◆ newerRequests

RequestMap* IpcIoFile::newerRequests
private

Definition at line 136 of file IpcIoFile.h.

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

◆ olderRequests

RequestMap* IpcIoFile::olderRequests
private

Definition at line 135 of file IpcIoFile.h.

Referenced by checkTimeouts(), and ioInProgress().

◆ queue

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

Definition at line 149 of file IpcIoFile.h.

Referenced by canWait(), HandleNotification(), HandleResponses(), open(), and push().

◆ requestMap1

RequestMap IpcIoFile::requestMap1
private

Definition at line 133 of file IpcIoFile.h.

Referenced by dequeueRequest().

◆ requestMap2

RequestMap IpcIoFile::requestMap2
private

Definition at line 134 of file IpcIoFile.h.

Referenced by dequeueRequest().

◆ Timeout

const double IpcIoFile::Timeout = 7
staticprivate

Definition at line 139 of file IpcIoFile.h.

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

◆ timeoutCheckScheduled

bool IpcIoFile::timeoutCheckScheduled
private

Definition at line 137 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 142 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