Public Types | Public Member Functions | Static Public Member Functions | Data Fields | Static Public Attributes

CacheProcessor Struct Reference

#include <I_Cache.h>

Inherits Processor.

Collaboration diagram for CacheProcessor:
Collaboration graph
[legend]

Public Types

typedef void(* CALLBACK_FUNC )()
 Type for callback function.

Public Member Functions

 CacheProcessor ()
virtual int start (int n_cache_threads=0, size_t stacksize=DEFAULT_STACKSIZE)
 Starts execution of the processor.
virtual int start_internal (int flags=0)
void stop ()
int dir_check (bool fix)
int db_check (bool fix)
inkcoreapi Actionlookup (Continuation *cont, CacheKey *key, bool cluster_cache_local, bool local_only=false, CacheFragType frag_type=CACHE_FRAG_TYPE_NONE, char *hostname=0, int host_len=0)
inkcoreapi Actionopen_read (Continuation *cont, CacheKey *key, bool cluster_cache_local, CacheFragType frag_type=CACHE_FRAG_TYPE_NONE, char *hostname=0, int host_len=0)
Actionopen_read_buffer (Continuation *cont, MIOBuffer *buf, CacheKey *key, CacheFragType frag_type=CACHE_FRAG_TYPE_NONE, char *hostname=0, int host_len=0)
inkcoreapi Actionopen_write (Continuation *cont, CacheKey *key, bool cluster_cache_local, CacheFragType frag_type=CACHE_FRAG_TYPE_NONE, int expected_size=CACHE_EXPECTED_SIZE, int options=0, time_t pin_in_cache=(time_t) 0, char *hostname=0, int host_len=0)
Actionopen_write_buffer (Continuation *cont, MIOBuffer *buf, CacheKey *key, CacheFragType frag_type=CACHE_FRAG_TYPE_NONE, int options=0, time_t pin_in_cache=(time_t) 0, char *hostname=0, int host_len=0)
inkcoreapi Actionremove (Continuation *cont, CacheKey *key, bool cluster_cache_local, CacheFragType frag_type=CACHE_FRAG_TYPE_NONE, bool rm_user_agents=true, bool rm_link=false, char *hostname=0, int host_len=0)
Actionscan (Continuation *cont, char *hostname=0, int host_len=0, int KB_per_second=SCAN_KB_PER_SECOND)
Actionlink (Continuation *cont, CacheKey *from, CacheKey *to, bool cluster_cache_local, CacheFragType frag_type=CACHE_FRAG_TYPE_HTTP, char *hostname=0, int host_len=0)
Actionderef (Continuation *cont, CacheKey *key, bool cluster_cache_local, CacheFragType frag_type=CACHE_FRAG_TYPE_HTTP, char *hostname=0, int host_len=0)
bool mark_storage_offline (CacheDisk *d)
 Mark physical disk/device/file as offline.
CacheDiskfind_by_path (char const *path, int len=0)
 Find the storage for a path.
bool has_online_storage () const
 Check if there are any online storage devices.
void set_after_init_callback (CALLBACK_FUNC cb)
 Lifecycle callback.
void diskInitialized ()
void cacheInitialized ()

Static Public Member Functions

static int IsCacheEnabled ()
static bool IsCacheReady (CacheFragType type)

Data Fields

VersionNumber min_stripe_version
VersionNumber max_stripe_version
CALLBACK_FUNC cb_after_init

Static Public Attributes

static volatile uint32_t cache_ready = 0
static volatile int initialized = CACHE_INITIALIZING
static volatile int start_done = 0
static int clear = 0
static int fix = 0
static int start_internal_flags = 0
static int auto_clear_flag = 0

Detailed Description

Definition at line 67 of file I_Cache.h.


Member Typedef Documentation

typedef void(* CacheProcessor::CALLBACK_FUNC)()

Type for callback function.

Definition at line 164 of file I_Cache.h.


Constructor & Destructor Documentation

CacheProcessor::CacheProcessor (  )  [inline]

Definition at line 69 of file I_Cache.h.


Member Function Documentation

void CacheProcessor::cacheInitialized (  ) 
int CacheProcessor::db_check ( bool  fix  ) 

Definition at line 1129 of file Cache.cc.

References gnvol.

Referenced by CmdCacheCont::CheckEvent().

Action* CacheProcessor::deref ( Continuation cont,
CacheKey key,
bool  cluster_cache_local,
CacheFragType  frag_type = CACHE_FRAG_TYPE_HTTP,
char *  hostname = 0,
int  host_len = 0 
)
int CacheProcessor::dir_check ( bool  fix  ) 

Definition at line 1121 of file Cache.cc.

References gnvol.

Referenced by CmdCacheCont::CheckEvent().

void CacheProcessor::diskInitialized (  ) 
CacheDisk * CacheProcessor::find_by_path ( char const *  path,
int  len = 0 
)

Find the storage for a path.

If len is 0 then path is presumed null terminated.

Returns:
NULL if the path does not match any defined storage.

Definition at line 3647 of file Cache.cc.

References CACHE_INITIALIZED, gndisks, and initialized.

Referenced by mgmt_storage_device_cmd_callback().

bool CacheProcessor::has_online_storage (  )  const

Check if there are any online storage devices.

If this returns false then the cache should be disabled as there is no storage available.

Definition at line 2203 of file Cache.cc.

References DISK_BAD, and gndisks.

Referenced by mark_storage_offline().

TS_INLINE int CacheProcessor::IsCacheEnabled (  )  [static]
TS_INLINE bool CacheProcessor::IsCacheReady ( CacheFragType  type  )  [static]
Action* CacheProcessor::link ( Continuation cont,
CacheKey from,
CacheKey to,
bool  cluster_cache_local,
CacheFragType  frag_type = CACHE_FRAG_TYPE_HTTP,
char *  hostname = 0,
int  host_len = 0 
)
TS_INLINE Action * CacheProcessor::lookup ( Continuation cont,
CacheKey key,
bool cluster_cache_local  ATS_UNUSED,
bool local_only  ATS_UNUSED = false,
CacheFragType  frag_type = CACHE_FRAG_TYPE_NONE,
char *  hostname = 0,
int  host_len = 0 
)
bool CacheProcessor::mark_storage_offline ( CacheDisk d  ) 

Mark physical disk/device/file as offline.

Set the state of a disk programmatically.

All stripes for this device are disabled.

Returns:
true if there are any storage devices remaining online, false if not.
Note:
This is what is called if a disk is disabled due to I/O errors.
Parameters:
d Target disk

Definition at line 2148 of file Cache.cc.

References Vol::buckets, cache_bytes_total_stat, cache_direntries_total_stat, cache_direntries_used_stat, cache_ready, dir_entries_used(), DISK_BAD, Vol::fd, CacheDisk::fd, CacheHostTable::gen_host_rec, gnvol, has_online_storage(), Cache::hosttable, Vol::len, rebuild_host_table(), RecIncrGlobalRawStat(), Vol::segments, SET_DISK_BAD, vol_dirlen(), CacheHostRecord::vol_hash_table, and Warning.

Referenced by AIO_Callback_handler::handle_disk_failure(), and mgmt_storage_device_cmd_callback().

TS_INLINE inkcoreapi Action * CacheProcessor::open_read ( Continuation cont,
CacheKey key,
bool cluster_cache_local  ATS_UNUSED,
CacheFragType  frag_type = CACHE_FRAG_TYPE_NONE,
char *  hostname = 0,
int  host_len = 0 
)
Action* CacheProcessor::open_read_buffer ( Continuation cont,
MIOBuffer buf,
CacheKey key,
CacheFragType  frag_type = CACHE_FRAG_TYPE_NONE,
char *  hostname = 0,
int  host_len = 0 
)
TS_INLINE inkcoreapi Action * CacheProcessor::open_write ( Continuation cont,
CacheKey key,
bool cluster_cache_local  ATS_UNUSED,
CacheFragType  frag_type = CACHE_FRAG_TYPE_NONE,
int expected_size  ATS_UNUSED = CACHE_EXPECTED_SIZE,
int  options = 0,
time_t  pin_in_cache = (time_t) 0,
char *  hostname = 0,
int  host_len = 0 
)
TS_INLINE Action * CacheProcessor::open_write_buffer ( Continuation cont,
MIOBuffer buf,
CacheKey key,
CacheFragType  frag_type = CACHE_FRAG_TYPE_NONE,
int  options = 0,
time_t  pin_in_cache = (time_t) 0,
char *  hostname = 0,
int  host_len = 0 
)

Definition at line 1189 of file P_CacheInternal.h.

References ink_assert.

TS_INLINE Action * CacheProcessor::remove ( Continuation cont,
CacheKey key,
bool cluster_cache_local  ATS_UNUSED,
CacheFragType  frag_type = CACHE_FRAG_TYPE_NONE,
bool  rm_user_agents = true,
bool  rm_link = false,
char *  hostname = 0,
int  host_len = 0 
)
TS_INLINE Action * CacheProcessor::scan ( Continuation cont,
char *  hostname = 0,
int  host_len = 0,
int  KB_per_second = SCAN_KB_PER_SECOND 
)
void CacheProcessor::set_after_init_callback ( CALLBACK_FUNC  cb  )  [inline]

Lifecycle callback.

The function cb is called after cache initialization has finished and the cache is ready or has failed.

Definition at line 197 of file I_Cache.h.

References cb_after_init.

Referenced by main().

int CacheProcessor::start ( int  number_of_threads = 0,
size_t  stacksize = DEFAULT_STACKSIZE 
) [virtual]

Starts execution of the processor.

Attempts to start the number of threads specified for the processor, initializes their states and sets them running. On failure it returns a negative value.

Parameters:
number_of_threads Positive value indicating the number of threads to spawn for the processor.
stacksize The thread stack size to use for this processor.

Reimplemented from Processor.

Definition at line 579 of file Cache.cc.

References start_internal().

Referenced by cmd_check_internal(), and main().

int CacheProcessor::start_internal ( int  flags = 0  )  [virtual]

Definition at line 587 of file Cache.cc.

References AIOCallback::action, ink_aiocb::aio_fildes, ink_aiocb::aio_reqprio, AIOCallback::aiocb, Span::alignment, ats_malloc(), ats_strdup, auto_clear_flag, Span::blocks, cache_config_force_sector_size, CACHE_EVENT_OPEN_READ, CACHE_EVENT_OPEN_READ_FAILED, CACHE_EVENT_OPEN_WRITE, CACHE_EVENT_OPEN_WRITE_FAILED, CACHE_EVENT_REMOVE, CACHE_EVENT_REMOVE_FAILED, CACHE_EVENT_SCAN, CACHE_EVENT_SCAN_DONE, CACHE_EVENT_SCAN_FAILED, CACHE_EVENT_SCAN_OBJECT, CACHE_EVENT_SCAN_OPERATION_BLOCKED, CACHE_EVENT_SCAN_OPERATION_FAILED, clear, Debug, Store::disk, EThread::diskHandler, eventProcessor, EventProcessor::eventthread, CacheDisk::fd, Span::file_pathname, fix, Span::forced_volume_num, CacheDisk::forced_volume_num, gndisks, CacheDisk::hash_base_string, Span::hash_base_string, CacheDisk::hw_sector_size, Span::hw_sector_size, ink_aio_set_callback(), ink_assert, ink_strlcat(), ink_strlcpy(), CacheDisk::io, CacheDisk::len, Store::n_disks, EventProcessor::n_threads_for_type, ConfigVolumes::num_http_volumes, ConfigVolumes::num_stream_volumes, Span::offset, CacheDisk::open(), CacheDisk::path, Span::pathname, ConfigVolumes::read_config_file(), ROUND_TO_STORE_BLOCK, EventProcessor::schedule_imm(), EThread::schedule_imm(), CacheDisk::skip, skip(), CacheDisk::start, start_done, start_internal_flags, START_POS, STORE_BLOCK_SIZE, AIOCallback::thread, TS_EVENT_CACHE_OPEN_READ, TS_EVENT_CACHE_OPEN_READ_FAILED, TS_EVENT_CACHE_OPEN_WRITE, TS_EVENT_CACHE_OPEN_WRITE_FAILED, TS_EVENT_CACHE_REMOVE, TS_EVENT_CACHE_REMOVE_FAILED, TS_EVENT_CACHE_SCAN, TS_EVENT_CACHE_SCAN_DONE, TS_EVENT_CACHE_SCAN_FAILED, TS_EVENT_CACHE_SCAN_OBJECT, TS_EVENT_CACHE_SCAN_OPERATION_BLOCKED, TS_EVENT_CACHE_SCAN_OPERATION_FAILED, and Warning.

Referenced by cmd_clear(), and start().

void CacheProcessor::stop (  ) 

Definition at line 1116 of file Cache.cc.

Referenced by CmdCacheCont::CheckEvent().


Field Documentation

Definition at line 188 of file I_Cache.h.

Referenced by start_internal().

volatile uint32_t CacheProcessor::cache_ready = 0 [static]

Definition at line 193 of file I_Cache.h.

Referenced by cacheInitialized(), and set_after_init_callback().

int CacheProcessor::clear = 0 [static]

Definition at line 185 of file I_Cache.h.

Referenced by diskInitialized(), and start_internal().

int CacheProcessor::fix = 0 [static]

Definition at line 186 of file I_Cache.h.

Referenced by diskInitialized(), and start_internal().

volatile int CacheProcessor::initialized = CACHE_INITIALIZING [static]

Definition at line 191 of file I_Cache.h.

Referenced by cacheInitialized().

Definition at line 190 of file I_Cache.h.

Referenced by cacheInitialized(), and CB_After_Cache_Init().

volatile int CacheProcessor::start_done = 0 [static]

Definition at line 184 of file I_Cache.h.

Referenced by CacheDisk::openDone(), and start_internal().

Definition at line 187 of file I_Cache.h.

Referenced by cacheInitialized(), and start_internal().


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