#include <I_Cache.h>
Inherits Processor.
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 Action * | lookup (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 Action * | open_read (Continuation *cont, CacheKey *key, bool cluster_cache_local, CacheFragType frag_type=CACHE_FRAG_TYPE_NONE, char *hostname=0, int host_len=0) |
Action * | open_read_buffer (Continuation *cont, MIOBuffer *buf, CacheKey *key, CacheFragType frag_type=CACHE_FRAG_TYPE_NONE, char *hostname=0, int host_len=0) |
inkcoreapi Action * | open_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) |
Action * | 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) |
inkcoreapi Action * | remove (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) |
Action * | scan (Continuation *cont, char *hostname=0, int host_len=0, int KB_per_second=SCAN_KB_PER_SECOND) |
Action * | 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) |
Action * | deref (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. | |
CacheDisk * | find_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 |
Definition at line 67 of file I_Cache.h.
typedef void(* CacheProcessor::CALLBACK_FUNC)() |
void CacheProcessor::cacheInitialized | ( | ) |
Definition at line 893 of file Cache.cc.
References AUTO_SIZE_RAM_CACHE, Vol::buckets, cache(), cache_bytes_total_stat, CACHE_COMPRESSION_FASTLZ, CACHE_COMPRESSION_LIBLZMA, CACHE_COMPRESSION_LIBZ, CACHE_COMPRESSION_NONE, cache_config_ram_cache_algorithm, cache_config_ram_cache_compress, cache_config_ram_cache_cutoff, cache_config_ram_cache_size, cache_direntries_total_stat, cache_direntries_used_stat, CACHE_INIT_FAILED, CACHE_INITIALIZING, cache_ram_cache_bytes_total_stat, cache_ready, Cache::cache_size, CACHE_VOL_SUM_DYN_STAT, cb_after_init, clusterProcessor, Debug, DEFAULT_RAM_CACHE_MULTIPLIER, dir_entries_used(), dir_sync_init(), Fatal, GLOBAL_CACHE_SET_DYN_STAT, gnvol, Vol::header, CacheContinuation::init(), Vol::init(), RamCache::init(), initialized, Vol::len, max_stripe_version, min_stripe_version, Thread::mutex, new_RamCacheCLFUS(), new_RamCacheLRU(), Note, PROCESSOR_RECONFIGURE, Vol::ram_cache, RAM_CACHE_ALGORITHM_CLFUS, RAM_CACHE_ALGORITHM_LRU, Cache::ready, Vol::segments, ClusterProcessor::start(), start_internal_flags, STORE_BLOCK_SIZE, this_ethread(), VolHeaderFooter::version, vol_dirlen(), and Warning.
Referenced by diskInitialized(), and Cache::open_done().
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 | ( | ) |
Definition at line 788 of file Cache.cc.
References ats_free(), ats_malloc(), cache_stat_count, cacheInitialized(), clear, cplist_init(), cplist_reconfigure(), Debug, DISK_BAD, CacheDisk::disk_vols, fix, DiskVolBlock::free, CacheDisk::free_space, gndisks, gnvol, DLL< C, L >::head, CacheDisk::header, initialize_disk, is_debug_tag_set, DiskVolBlock::len, DiskHeader::num_diskvol_blks, ConfigVolumes::num_http_volumes, ConfigVolumes::num_stream_volumes, DiskHeader::num_volumes, ConfigVolumes::num_volumes, DiskVolBlock::number, Cache::open(), RecAllocateRawStatBlock(), register_cache_stats(), Cache::scheme, DiskVol::size, CacheDisk::sync(), DiskHeader::vol_info, DiskVol::vol_number, CacheVol::vol_number, and CacheVol::vol_rsb.
Referenced by CacheDisk::openDone().
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.
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] |
Definition at line 1341 of file P_CacheInternal.h.
References initialized.
Referenced by cache(), Cache_dir(), CmdCacheCont::CheckEvent(), CmdCacheCont::ClearEvent(), IsCacheReady(), RegressionCont::mainEvent(), and ClusterProcessor::start().
TS_INLINE bool CacheProcessor::IsCacheReady | ( | CacheFragType | type | ) | [static] |
Definition at line 1347 of file P_CacheInternal.h.
References CACHE_INITIALIZED, cache_ready, and IsCacheEnabled().
Referenced by Cache::deref(), Cache::link(), Cache::lookup(), Cache::open_read(), Cache::open_write(), Cache::remove(), Cache::scan(), and TSCacheDataTypeReady().
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 | |||
) |
Definition at line 1126 of file P_CacheInternal.h.
References a, cache_clustering_enabled, and Cluster_lookup().
Referenced by cache(), TestProxy::dnsEvent(), and ICPPeerReadCont::ICPPeerQueryCont().
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.
true
if there are any storage devices remaining online, false
if not.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 | |||
) |
Definition at line 1142 of file P_CacheInternal.h.
References cache_clustering_enabled, and CACHE_OPEN_READ.
Referenced by cache(), TestProxy::cacheCheckEvent(), PrefetchBlaster::handleEvent(), ICPPeerReadCont::ICPPeerQueryCont(), ShowCache::lookup_url(), and TSCacheRead().
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 | |||
) |
Definition at line 1171 of file P_CacheInternal.h.
References cache_clustering_enabled, cache_hash(), CACHE_OPEN_WRITE, cluster_machine_at_depth(), and Cluster_write().
Referenced by cache(), TestProxy::cacheCheckEvent(), HttpCacheSM::open_write(), and TSCacheWrite().
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 | |||
) |
Definition at line 1206 of file P_CacheInternal.h.
References cache_clustering_enabled, cache_hash(), cluster_machine_at_depth(), Cluster_remove(), and Debug.
Referenced by cache(), TestProxy::cacheCheckEvent(), ShowCache::delete_url(), HttpSM::do_cache_delete_all_alts(), CacheVC::scanObject(), and TSCacheRemove().
TS_INLINE Action * CacheProcessor::scan | ( | Continuation * | cont, | |
char * | hostname = 0 , |
|||
int | host_len = 0 , |
|||
int | KB_per_second = SCAN_KB_PER_SECOND | |||
) |
Definition at line 1335 of file P_CacheInternal.h.
Referenced by ShowCache::delete_regex(), ShowCache::invalidate_regex(), ShowCache::lookup_regex(), and TSCacheScan().
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.
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().
int CacheProcessor::auto_clear_flag = 0 [static] |
Definition at line 188 of file I_Cache.h.
Referenced by start_internal().
volatile uint32_t CacheProcessor::cache_ready = 0 [static] |
Definition at line 182 of file I_Cache.h.
Referenced by cacheInitialized(), AIO_Callback_handler::handle_disk_failure(), IsCacheReady(), and mark_storage_offline().
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 183 of file I_Cache.h.
Referenced by cache_stats_bytes_used_cb(), cacheInitialized(), find_by_path(), and IsCacheEnabled().
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().
int CacheProcessor::start_internal_flags = 0 [static] |
Definition at line 187 of file I_Cache.h.
Referenced by cacheInitialized(), and start_internal().