#include <P_MultiCache.h>
Inherits MultiCacheHeader.
Inherited by MultiCache< C >, and MultiCache< HostDBInfo >.
Public Member Functions | |
int | halfspace_size () |
int | lowest_level_data_size () |
int | lowest_level (int bucket) |
void | set_lowest_level (int bucket, int lowest) |
int | partition_of_bucket (int b) |
int | first_bucket_of_partition (int p) |
int | last_bucket_of_partition (int p) |
int | buckets_of_partition (int p) |
int | open (Store *store, const char *config_filename, char *db_filename=NULL, int db_size=-1, bool reconfigure=false, bool fix=false, bool silent=false) |
int | read_config (const char *config_filename, Store &store, char *fn=NULL, int *pi=NULL, int *pbuckets=NULL) |
int | write_config (const char *config_filename, int nominal_size, int buckets) |
int | initialize (Store *store, char *filename, int elements, int buckets=0, int levels=2, int level0_elements_per_bucket=4, int level1_elements_per_bucket=32, int level2_elements_per_bucket=1) |
int | mmap_data (bool private_flag=false, bool zero_fill=false) |
char * | mmap_region (int blocks, int *fds, char *cur, size_t &total_length, bool private_flag, int zero_fill=0) |
int | blocks_in_level (int level) |
bool | verify_header () |
int | unmap_data () |
void | reset () |
void | clear () |
void | clear_but_heap () |
virtual MultiCacheBase * | dup () |
virtual size_t | estimated_heap_bytes_per_entry () const |
void | print_info (FILE *fp) |
int | rebuild (MultiCacheBase &old, int kind=MC_REBUILD) |
virtual void | rebuild_element (int buck, char *elem, RebuildMC &r) |
int | check (const char *config_filename, bool fix=false) |
ProxyMutex * | lock_for_bucket (int bucket) |
uint64_t | make_tag (uint64_t folded_md5) |
int | sync_all () |
int | sync_heap (int part) |
int | sync_header () |
int | sync_partition (int partition) |
void | sync_partitions (Continuation *cont) |
MultiCacheBase () | |
virtual | ~MultiCacheBase () |
virtual int | get_elementsize () |
int | ptr_to_partition (char *) |
void * | alloc (int *poffset, int size) |
void | update (int *poffset, int *old_poffset) |
void * | ptr (int *poffset, int partition) |
int | valid_offset (int offset) |
int | valid_heap_pointer (char *p) |
void | copy_heap_data (char *src, int s, int *pi, int partition, MultiCacheHeapGC *gc) |
int | halfspace_of (int o) |
UnsunkPtrRegistry * | fixup_heap_offsets (int partition, int before_used, UnsunkPtrRegistry *r=NULL, int base=0) |
virtual void | copy_heap (int partition, MultiCacheHeapGC *gc) |
void | alloc_mutexes () |
Data Fields | |
Store * | store |
char | filename [PATH_NAME_MAX+1] |
MultiCacheHeader * | mapped_header |
MultiCacheHeader | header_snap |
char * | data |
char * | lowest_level_data |
char * | heap |
int | hit_stat [MULTI_CACHE_MAX_LEVELS] |
int | miss_stat |
int | buckets_per_partitionF8 |
UnsunkPtrRegistry | unsunk [MULTI_CACHE_PARTITIONS] |
PtrMutex | locks [MULTI_CACHE_PARTITIONS] |
Definition at line 197 of file P_MultiCache.h.
MultiCacheBase::MultiCacheBase | ( | ) |
Definition at line 40 of file MultiCache.cc.
virtual MultiCacheBase::~MultiCacheBase | ( | ) | [inline, virtual] |
Definition at line 347 of file P_MultiCache.h.
References reset().
void * MultiCacheBase::alloc | ( | int * | poffset, | |
int | size | |||
) |
Definition at line 1279 of file MultiCache.cc.
References UnsunkPtrRegistry::alloc(), data, Debug, halfspace_size(), heap, MultiCacheHeader::heap_halfspace, MultiCacheHeader::heap_used, ink_assert, MULTI_CACHE_HEAP_ALIGNMENT, UnsunkPtr::offset, UnsunkPtr::poffset, ptr_to_partition(), and unsunk.
Referenced by copy_heap_data(), HostDBContinuation::dnsEvent(), and HostDBContinuation::lookup_done().
void MultiCacheBase::alloc_mutexes | ( | ) | [inline] |
Definition at line 401 of file P_MultiCache.h.
References locks, and new_ProxyMutex().
Referenced by HostDBProcessor::start().
int MultiCacheBase::blocks_in_level | ( | int | level | ) | [inline] |
Definition at line 85 of file MultiCache.cc.
References MultiCacheHeader::buckets, MultiCacheHeader::bucketsize, and bytes_to_blocks().
Referenced by mmap_data().
int MultiCacheBase::buckets_of_partition | ( | int | p | ) | [inline] |
Definition at line 257 of file P_MultiCache.h.
References first_bucket_of_partition(), and last_bucket_of_partition().
Referenced by MultiCache< C >::copy_heap(), and sync_partition().
int MultiCacheBase::check | ( | const char * | config_filename, | |
bool | fix = false | |||
) |
Definition at line 910 of file MultiCache.cc.
References MultiCacheHeader::buckets, dup(), filename, initialize(), MC_REBUILD_CHECK, MC_REBUILD_FIX, MultiCacheHeader::nominal_elements, read_config(), and rebuild().
Referenced by cmd_check_internal(), and open().
void MultiCacheBase::clear | ( | ) |
Definition at line 485 of file MultiCache.cc.
References data, MultiCacheHeader::heap_halfspace, MultiCacheHeader::heap_used, mapped_header, and MultiCacheHeader::totalsize.
Referenced by open(), and HostDBProcessor::start().
void MultiCacheBase::clear_but_heap | ( | ) |
Definition at line 495 of file MultiCache.cc.
References data, MultiCacheHeader::elementsize, mapped_header, and MultiCacheHeader::totalelements.
Referenced by rebuild().
virtual void MultiCacheBase::copy_heap | ( | int | partition, | |
MultiCacheHeapGC * | gc | |||
) | [inline, virtual] |
Reimplemented in MultiCache< C >, and MultiCache< HostDBInfo >.
Definition at line 392 of file P_MultiCache.h.
Referenced by MultiCacheHeapGC::startEvent().
void MultiCacheBase::copy_heap_data | ( | char * | src, | |
int | s, | |||
int * | pi, | |||
int | partition, | |||
MultiCacheHeapGC * | gc | |||
) |
Definition at line 1205 of file MultiCache.cc.
References alloc(), Debug, heap, ink_assert, memcpy, MultiCacheHeapGC::n_offsets, OffsetTable::new_offset, UnsunkPtr::offset, MultiCacheHeapGC::offset_table, OffsetTable::poffset, UnsunkPtr::poffset, UnsunkPtrRegistry::ptr(), ptr(), and unsunk.
Referenced by MultiCache< C >::copy_heap().
virtual MultiCacheBase* MultiCacheBase::dup | ( | ) | [inline, virtual] |
Reimplemented in HostDBCache, MultiCache< C >, and MultiCache< HostDBInfo >.
Definition at line 283 of file P_MultiCache.h.
References ink_assert.
virtual size_t MultiCacheBase::estimated_heap_bytes_per_entry | ( | ) | const [inline, virtual] |
Reimplemented in HostDBCache.
Definition at line 289 of file P_MultiCache.h.
Referenced by initialize().
int MultiCacheBase::first_bucket_of_partition | ( | int | p | ) | [inline] |
Definition at line 249 of file P_MultiCache.h.
References buckets_per_partitionF8.
Referenced by buckets_of_partition(), MultiCache< C >::copy_heap(), last_bucket_of_partition(), and sync_partition().
UnsunkPtrRegistry * MultiCacheBase::fixup_heap_offsets | ( | int | partition, | |
int | before_used, | |||
UnsunkPtrRegistry * | r = NULL , |
|||
int | base = 0 | |||
) |
Definition at line 1071 of file MultiCache.cc.
References data, Debug, halfspace_of(), MultiCacheHeader::heap_halfspace, ink_assert, MULTI_CACHE_UNSUNK_PTR_BLOCK_SIZE, UnsunkPtrRegistry::n, UnsunkPtrRegistry::next, UnsunkPtrRegistry::next_free, UnsunkPtr::offset, UnsunkPtr::poffset, UnsunkPtrRegistry::ptrs, MultiCacheHeader::totalelements, and unsunk.
Referenced by MultiCacheSync::mcEvent().
virtual int MultiCacheBase::get_elementsize | ( | ) | [inline, virtual] |
Reimplemented in MultiCache< C >, and MultiCache< HostDBInfo >.
Definition at line 351 of file P_MultiCache.h.
References ink_assert.
Referenced by initialize().
int MultiCacheBase::halfspace_of | ( | int | o | ) | [inline] |
Definition at line 386 of file P_MultiCache.h.
References halfspace_size().
Referenced by fixup_heap_offsets().
int MultiCacheBase::halfspace_size | ( | ) | [inline] |
Definition at line 215 of file P_MultiCache.h.
References MultiCacheHeader::heap_size.
Referenced by alloc(), MultiCache< C >::copy_heap(), halfspace_of(), sync_partitions(), valid_heap_pointer(), and valid_offset().
int MultiCacheBase::initialize | ( | Store * | store, | |
char * | filename, | |||
int | elements, | |||
int | buckets = 0 , |
|||
int | levels = 2 , |
|||
int | level0_elements_per_bucket = 4 , |
|||
int | level1_elements_per_bucket = 32 , |
|||
int | level2_elements_per_bucket = 1 | |||
) |
Definition at line 105 of file MultiCache.cc.
References MultiCacheHeader::buckets, buckets_per_partitionF8, MultiCacheHeader::bucketsize, bytes_to_blocks(), Debug, MultiCacheHeader::elements, MultiCacheHeader::elementsize, estimated_heap_bytes_per_entry(), filename, Store::free(), get_elementsize(), MultiCacheHeader::heap_size, ink_assert, ink_release_assert, ink_strlcpy(), MultiCacheHeader::level_offset, MultiCacheHeader::levels, lowest_level_data, lowest_level_data_size(), MULTI_CACHE_PARTITIONS, MultiCacheHeader::nominal_elements, Store::spread_alloc(), store, STORE_BLOCK_SIZE, Store::total_blocks(), MultiCacheHeader::totalelements, MultiCacheHeader::totalsize, and Warning.
int MultiCacheBase::last_bucket_of_partition | ( | int | p | ) | [inline] |
Definition at line 253 of file P_MultiCache.h.
References first_bucket_of_partition().
Referenced by buckets_of_partition().
ProxyMutex* MultiCacheBase::lock_for_bucket | ( | int | bucket | ) | [inline] |
Definition at line 318 of file P_MultiCache.h.
References locks, and partition_of_bucket().
Referenced by HostDBContinuation::dnsEvent(), HostDBContinuation::dnsPendingEvent(), get_hostinfo_ClusterFunction(), HostDBProcessor::getbyname_imm(), HostDBProcessor::getSRVbyname_imm(), HostDBContinuation::init(), HostDBContinuation::insert(), HostDBContinuation::lookup_done(), probe(), put_hostinfo_ClusterFunction(), HostDBContinuation::refresh_MD5(), and HostDBProcessor::setby().
int MultiCacheBase::lowest_level | ( | int | bucket | ) | [inline] |
Definition at line 229 of file P_MultiCache.h.
References MultiCacheHeader::buckets, and lowest_level_data.
Referenced by MultiCache< C >::flush().
int MultiCacheBase::lowest_level_data_size | ( | ) | [inline] |
Definition at line 225 of file P_MultiCache.h.
References MultiCacheHeader::buckets.
Referenced by initialize().
uint64_t MultiCacheBase::make_tag | ( | uint64_t | folded_md5 | ) | [inline] |
Definition at line 322 of file P_MultiCache.h.
References MultiCacheHeader::buckets, and MultiCacheHeader::tag_bits.
Referenced by MultiCache< C >::insert_block(), MultiCache< C >::lookup_block(), and MultiCache< C >::match().
int MultiCacheBase::mmap_data | ( | bool | private_flag = false , |
|
bool | zero_fill = false | |||
) |
Definition at line 297 of file MultiCache.cc.
References ats_memalign(), Span::blocks, blocks_in_level(), bytes_to_blocks(), SocketManager::close(), data, Store::disk, Store::dup(), Span::file_pathname, filename, heap, MultiCacheHeader::heap_size, ink_assert, ink_file_fd_zerofill(), MultiCacheHeader::levels, MAP_SHARED_MAP_NORESERVE, mapped_header, mmap_region(), Store::n_disks, Span::nth(), SocketManager::open(), Span::path(), PATH_NAME_MAX, Span::paths(), socketManager, store, STORE_BLOCK_SIZE, MultiCacheHeader::totalsize, and Warning.
char * MultiCacheBase::mmap_region | ( | int | blocks, | |
int * | fds, | |||
char * | cur, | |||
size_t & | total_length, | |||
bool | private_flag, | |||
int | zero_fill = 0 | |||
) |
Definition at line 223 of file MultiCache.cc.
References Span::blocks, Store::disk, ink_assert, Span::is_mmapable(), Store::n_disks, Span::nth(), Span::offset, Span::paths(), store, and Store::total_blocks().
Referenced by mmap_data().
int MultiCacheBase::open | ( | Store * | store, | |
const char * | config_filename, | |||
char * | db_filename = NULL , |
|||
int | db_size = -1 , |
|||
bool | reconfigure = false , |
|||
bool | fix = false , |
|||
bool | silent = false | |||
) |
Definition at line 562 of file MultiCache.cc.
References Store::add(), MultiCacheHeader::buckets, check(), Store::clear(), clear(), dup(), Store::dup(), initialize(), ink_assert, mapped_header, mmap_data(), Store::n_disks, read_config(), rebuild(), REC_SIGNAL_CONFIG_ERROR, RecSignalWarning(), Store::sort(), Store::spread_alloc(), stealStore(), store, store_verify(), Store::total_blocks(), Store::try_realloc(), unmap_data(), verify_header(), and write_config().
Referenced by read_config(), HostDBCache::start(), and write_config().
int MultiCacheBase::partition_of_bucket | ( | int | b | ) | [inline] |
Definition at line 245 of file P_MultiCache.h.
References buckets_per_partitionF8.
Referenced by HostDBContinuation::key_partition(), lock_for_bucket(), HostDBCache::pending_dns_for_hash(), ptr_to_partition(), and rebuild().
void MultiCacheBase::print_info | ( | FILE * | fp | ) |
Definition at line 775 of file MultiCache.cc.
References MultiCacheHeader::totalelements, and MultiCacheHeader::totalsize.
Referenced by rebuild().
void * MultiCacheBase::ptr | ( | int * | poffset, | |
int | partition | |||
) |
Definition at line 1323 of file MultiCache.cc.
References data, Debug, heap, ink_assert, UnsunkPtr::offset, UnsunkPtr::poffset, UnsunkPtrRegistry::ptr(), unsunk, and valid_offset().
Referenced by MultiCache< C >::copy_heap(), copy_heap_data(), HostDBInfo::hostname(), HostDBCache::rebuild_callout(), and HostDBInfo::rr().
int MultiCacheBase::ptr_to_partition | ( | char * | ptr | ) |
Definition at line 1377 of file MultiCache.cc.
References MultiCacheHeader::bucketsize, data, MultiCacheHeader::elements, MultiCacheHeader::elementsize, MultiCacheHeader::level_offset, and partition_of_bucket().
Referenced by alloc(), HostDBInfo::hostname(), HostDBInfo::rr(), and update().
int MultiCacheBase::read_config | ( | const char * | config_filename, | |
Store & | store, | |||
char * | fn = NULL , |
|||
int * | pi = NULL , |
|||
int * | pbuckets = NULL | |||
) |
Definition at line 502 of file MultiCache.cc.
References MultiCacheHeader::heap_size, ink_file_fd_readline(), open(), PATH_NAME_MAX, Store::read(), RecConfigReadRuntimeDir(), and Layout::relative_to().
Referenced by check(), open(), and stealStore().
int MultiCacheBase::rebuild | ( | MultiCacheBase & | old, | |
int | kind = MC_REBUILD | |||
) |
Definition at line 789 of file MultiCache.cc.
References RebuildMC::backed, MultiCacheHeader::buckets, MultiCacheHeader::bucketsize, RebuildMC::check, clear_but_heap(), RebuildMC::corrupt, RebuildMC::data, data, RebuildMC::deleted, RebuildMC::duplicates, MultiCacheHeader::elements, MultiCacheHeader::elementsize, RebuildMC::fix, RebuildMC::good, ink_assert, MultiCacheHeader::level_offset, MultiCacheHeader::levels, MC_REBUILD, MC_REBUILD_CHECK, MC_REBUILD_FIX, memcpy, mmap_data(), SocketManager::open(), RebuildMC::partition, partition_of_bucket(), print_info(), RebuildMC::rebuild, rebuild_element(), reset(), socketManager, RebuildMC::stale, store, store_verify(), sync_partition(), RebuildMC::total, MultiCacheHeader::totalsize, unmap_data(), and Warning.
virtual void MultiCacheBase::rebuild_element | ( | int | buck, | |
char * | elem, | |||
RebuildMC & | r | |||
) | [inline, virtual] |
Reimplemented in MultiCache< C >, and MultiCache< HostDBInfo >.
Definition at line 303 of file P_MultiCache.h.
References ink_assert.
Referenced by rebuild().
void MultiCacheBase::reset | ( | ) |
Definition at line 271 of file MultiCache.cc.
References data, lowest_level_data, store, and unmap_data().
Referenced by cmd_check_internal(), cmd_clear(), rebuild(), and ~MultiCacheBase().
void MultiCacheBase::set_lowest_level | ( | int | bucket, | |
int | lowest | |||
) | [inline] |
Definition at line 234 of file P_MultiCache.h.
References MultiCacheHeader::buckets, and lowest_level_data.
Referenced by MultiCache< C >::flush().
int MultiCacheBase::sync_all | ( | ) |
Definition at line 981 of file MultiCache.cc.
References sync_header(), sync_heap(), and sync_partition().
int MultiCacheBase::sync_header | ( | ) |
Definition at line 974 of file MultiCache.cc.
References ats_msync(), mapped_header, and STORE_BLOCK_SIZE.
Referenced by sync_all().
int MultiCacheBase::sync_heap | ( | int | part | ) |
Definition at line 933 of file MultiCache.cc.
References ats_msync(), MultiCacheHeader::buckets, MultiCacheHeader::bucketsize, data, MultiCacheHeader::heap_size, MultiCacheHeader::level_offset, and MultiCacheHeader::totalsize.
Referenced by MultiCacheSync::heapEvent(), and sync_all().
int MultiCacheBase::sync_partition | ( | int | partition | ) |
Definition at line 952 of file MultiCache.cc.
References ats_msync(), buckets_of_partition(), MultiCacheHeader::bucketsize, data, first_bucket_of_partition(), MultiCacheHeader::level_offset, MultiCacheHeader::levels, and MultiCacheHeader::totalsize.
Referenced by MultiCacheSync::mcEvent(), rebuild(), MultiCacheHeapGC::startEvent(), and sync_all().
void MultiCacheBase::sync_partitions | ( | Continuation * | cont | ) |
Definition at line 1193 of file MultiCache.cc.
References data, ET_CALL, eventProcessor, halfspace_size(), MultiCacheHeader::heap_halfspace, MultiCacheHeader::heap_used, mapped_header, MULTI_CACHE_HEAP_HIGH_WATER, and EventProcessor::schedule_imm().
Referenced by HostDBSyncer::sync_event().
int MultiCacheBase::unmap_data | ( | ) |
Definition at line 285 of file MultiCache.cc.
References data, and MultiCacheHeader::totalsize.
void MultiCacheBase::update | ( | int * | poffset, | |
int * | old_poffset | |||
) |
Definition at line 1346 of file MultiCache.cc.
References UnsunkPtrRegistry::alloc(), data, Debug, ink_assert, UnsunkPtr::offset, UnsunkPtr::poffset, UnsunkPtrRegistry::ptr(), ptr_to_partition(), unsunk, and valid_offset().
Referenced by MultiCache< C >::insert_block().
int MultiCacheBase::valid_heap_pointer | ( | char * | p | ) | [inline] |
Definition at line 378 of file P_MultiCache.h.
References halfspace_size(), heap, and MultiCacheHeader::heap_used.
Referenced by HostDBCache::rebuild_callout().
int MultiCacheBase::valid_offset | ( | int | offset | ) | [inline] |
Definition at line 369 of file P_MultiCache.h.
References halfspace_size(), and MultiCacheHeader::heap_used.
Referenced by ptr(), HostDBCache::rebuild_callout(), and update().
bool MultiCacheBase::verify_header | ( | ) |
Definition at line 750 of file MultiCache.cc.
References MultiCacheHeader::buckets, MultiCacheHeader::bucketsize, MultiCacheHeader::elements, MultiCacheHeader::elementsize, VersionNumber::ink_major, VersionNumber::ink_minor, MultiCacheHeader::level_offset, MultiCacheHeader::levels, MultiCacheHeader::magic, mapped_header, MultiCacheHeader::max_hits, MultiCacheHeader::nominal_elements, MultiCacheHeader::tag_bits, MultiCacheHeader::totalelements, MultiCacheHeader::totalsize, and MultiCacheHeader::version.
Referenced by open().
int MultiCacheBase::write_config | ( | const char * | config_filename, | |
int | nominal_size, | |||
int | buckets | |||
) |
Definition at line 539 of file MultiCache.cc.
References filename, MultiCacheHeader::heap_size, ink_file_fd_writestring(), open(), PATH_NAME_MAX, RecConfigReadRuntimeDir(), Layout::relative_to(), store, Warning, and Store::write().
Referenced by open().
Definition at line 243 of file P_MultiCache.h.
Referenced by first_bucket_of_partition(), initialize(), and partition_of_bucket().
char* MultiCacheBase::data |
Definition at line 207 of file P_MultiCache.h.
Referenced by alloc(), MultiCache< C >::cache_bucket(), clear(), clear_but_heap(), MultiCache< C >::copy_heap(), MultiCache< C >::delete_block(), fixup_heap_offsets(), MultiCache< C >::level_of_block(), mmap_data(), ptr(), ptr_to_partition(), rebuild(), reset(), sync_heap(), sync_partition(), sync_partitions(), unmap_data(), and update().
char MultiCacheBase::filename[PATH_NAME_MAX+1] |
Definition at line 200 of file P_MultiCache.h.
Referenced by check(), initialize(), mmap_data(), MultiCacheBase(), and write_config().
Definition at line 203 of file P_MultiCache.h.
Referenced by MultiCacheSync::heapEvent().
char* MultiCacheBase::heap |
Definition at line 211 of file P_MultiCache.h.
Referenced by alloc(), MultiCache< C >::copy_heap(), copy_heap_data(), mmap_data(), ptr(), MultiCacheHeapGC::startEvent(), and valid_heap_pointer().
int MultiCacheBase::hit_stat[MULTI_CACHE_MAX_LEVELS] |
Definition at line 222 of file P_MultiCache.h.
Referenced by MultiCacheBase().
PtrMutex MultiCacheBase::locks[MULTI_CACHE_PARTITIONS] |
Definition at line 406 of file P_MultiCache.h.
Referenced by alloc_mutexes(), lock_for_bucket(), MultiCacheHeapGC::MultiCacheHeapGC(), MultiCacheSync::MultiCacheSync(), MultiCacheSync::pauseEvent(), and MultiCacheHeapGC::startEvent().
Definition at line 208 of file P_MultiCache.h.
Referenced by initialize(), lowest_level(), reset(), and set_lowest_level().
Definition at line 201 of file P_MultiCache.h.
Referenced by clear(), clear_but_heap(), MultiCacheSync::heapEvent(), mmap_data(), open(), MultiCacheHeapGC::startEvent(), sync_header(), sync_partitions(), and verify_header().
Definition at line 223 of file P_MultiCache.h.
Definition at line 199 of file P_MultiCache.h.
Referenced by initialize(), mmap_data(), mmap_region(), open(), rebuild(), reset(), and write_config().
UnsunkPtrRegistry MultiCacheBase::unsunk[MULTI_CACHE_PARTITIONS] |
Definition at line 358 of file P_MultiCache.h.
Referenced by alloc(), copy_heap_data(), fixup_heap_offsets(), MultiCacheBase(), ptr(), and update().