# Data Structures¶

size_t STORE_BLOCK_SIZE = 8192

The storage unit for span and stripe metadata.

class CacheHostTable

A container that maps from a FQDN to a CacheHostRecord. This is constructed from the contents of hosting.config.

void Match(char const *fqdn, int len, CacheHostResult *result)

Search the table for a match for the hostname fqdn, a string of length len. If found the result is placed in result.

class CacheHostResult

A wrapper for CacheHostRecord used by CacheHostTable::Match(). This contains the set of cache volumes for the cache host record and is used to perform stripe assignment.

class CacheHostRecord

A cache hosting record from hosting.config.

CacheVol **cp

The cache volumes that are part of this cache host record.

Vol **vols

The stripes that are part of the cache volumes. This is the union over the stripes of CacheHostRecord::cp

unsigned short *vol_hash_table

The stripe assignment table. This is an array of indices in to CacheHostRecord::vols.

class OpenDir

An open directory entry. It contains all the information of a Dir plus additional information from the first Doc.

class CacheVC

A virtual connection class which accepts input for writing to cache.

int openReadStartHead(int event, Event *e)

Performs the initial read for a cached object.

int openReadStartEarliest(int event, Event *e)

Performs the initial read for an alternate of an object.

class HttpTunnel

Data transfer driver. This contains a set of producers. Each producer is connected to one or more consumers. The tunnel handles events and buffers so that data moves from producers to consumers. The data, as much as possible, is kept in reference counted buffers so that copies are done only when the data is modified or for sources (which acquire data from outside Traffic Server) and sinks (which move data to outside Traffic Server).

class CacheControlResult

Holds the data from a line in cache.config.

class CacheHTTPInfoVector

Defined in iocore/cache/P_CacheHttp.h. This is an array of HTTPInfo objects and serves as the respository of information about alternates of an object. It is marshaled as part of the metadata for an object in the cache.

class HTTPInfo

Defined in proxy/hdrs/HTTP.h.

This class is a wrapper for HTTPCacheAlt. It provides the external API for accessing data in the wrapped class. It contains only a pointer (possibly NULL) to an instance of the wrapped class.

class CacheHTTPInfo

A typedef for HTTPInfo.

class HTTPCacheAlt

Defined in proxy/hdrs/HTTP.h.

This is the metadata for a single alternate for a cached object. It contains, among other data, the following:

• The key for the earliest Doc of the alternate.
• The request and response headers.
• The fragment offset table.[#fragment-offset-table]_
• Timestamps for request and response from origin server.
class Vol

This represents a storage unit inside a cache volume.

off_t data_blocks

The number of blocks of storage in the stripe.

int aggWrite(int event, void *e)

Schedule the aggregation buffer to be written to disk.

off_t segments

The number of segments in the volume. This will be roughly the total number of entries divided by the number of entries in a segment. It will be rounded up to cover all entries.

off_t buckets

The number of buckets in the volume. This will be roughly the number of entries in a segment divided by DIR_DEPTH. For currently defined values this is around 16,384 (2^16 / 4). Buckets are used as the targets of the index hash.

DLL<EvacuationBlock> evacuate

Array of of EvacuationBlock buckets. This is sized so there is one bucket for every evacuation span.

off_t len

Length of stripe in bytes.

int evac_range(off_t low, off_t high, int evac_phase)

Start an evacuation if there is any EvacuationBlock in the range from low to high. Return 0 if no evacuation was started, non-zero otherwise.

class Doc

Defined in iocore/cache/P_CacheVol.h.

uint32_t magic

Validity check value. Set to DOC_MAGIC for a valid document.

uint32_t len

The length of this segment including the header length, fragment table, and this structure.

uint64_t total_len

Total length of the entire document not including meta data but including headers.

INK_MD5 first_key

First index key in the document (the index key used to locate this object in the volume index).

INK_MD5 key

The index key for this fragment. Fragment keys are computationally chained so that the key for the next and previous fragments can be computed from this key.

uint32_t hlen

uint8_t ftype

Fragment type. Currently only CACHE_FRAG_TYPE_HTTP is used. Other types may be used for cache extensions if those are ever implemented.

uint24_t flen

Fragment table length, if any. Only the first Doc in an object should contain a fragment table.

The fragment table is a list of offsets relative to the HTTP content (not counting metadata or HTTP headers). Each offset is the byte offset of the first byte in the fragment. The first element in the table is the second fragment (what would be index 1 for an array). The offset for the first fragment is of course always zero and so not stored. The purpose of this is to enable a fast seek for range requests. Given the first Doc the fragment containing the first byte in the range can be computed and loaded directly without further disk access.

Removed as of version 3.3.0. [1]

uint32_t sync_serial

Unknown.

uint32_t write_serial

Unknown.

uint32_t pinned

Flag and timer for pinned objects.

uint32_t checksum

Unknown.

class DiskHeader

Header for a span. This is a serialized data structure.

unsigned int magic

Holds a magic value :code:DISK_HEADER_MAGIC to indicate the span is valid and initialized.

unsigned int num_volumes

Number of cache volumes containing stripes in this span.

unsigned int num_free

The number of span blocks defined but not in use.

unsigned int num_used

The number of span blocks in use by stripes.

unsigned int num_diskvol_blks

The number of span blocks.

uint64_t num_blocks

The number of volume blocks in the span.

DiskVolBlock vol_info[1]

A flexible array. The actual length of this array is num_diskvol_blks and each element describes a span block.

class DiskVolBlock

A description of a span stripe (Vol) block . This is a serialized data structure.

uint64_t offset

Offset in the span of the start of the span stripe (Vol) block, in bytes.

uint64_t len

Length of the span block in store blocks.

int number

The cache volume index for this span block.

unsigned int __attribute__((bitfield_3)) type

Type of the span block.

unsigned int __attribute__((bitfield_1)) free

In use or free flag - set if the span block is not in use by a cache volume.

class VolHeaderFooter
unsigned int magic

Container for a magic value, VOL_MAGIC, to indicate the instance is valid.

VersionNumber version

Version of the instance.

time_t create_time

Epoch time when the stripe was created.

off_t write_pos

Position of the write cursor, as a byte offset in the stripe.

off_t last_write_pos

Location of the write cursor of the most recently completed disk write.

off_t agg_pos

The byte offset in the stripe where the current aggregation buffer will be written.

uint32_t generation

Generation of this instance.

uint32_t phase
uint32_t cycle
uint32_t sync_serial
uint32_t write_serial
uint32_t dirty
uint32_t unused
uint16_t freelist[1]

An array of directory entry indices. Each element is the directory entry of the start of the free list for a segment, in the same order as the segments in the directory.

class DiskVolBlockQueue
DiskVolBlock *b
int new_block

Indicates if this is a new stripe rather than an existing one. In case a stripe is new ATS decides to clear that stripe(Vol)

LINK<DiskVolBlockQueue> link
class DiskVol

Describes the Disk that contains the stripe identified by vol_number. This class also contains the queue containing all the DiskVolBlock

int num_volblocks

Number of blocks in the stripe identified by vol_number

int vol_number

Identification number of the stripe (Vol)

uint64_t size

Size of the stripe

CacheDisk *disk

The disk containing the stripe

Queue<DiskVolBlockQueue> dpb_queue
enum CacheType
enumerator HTTP
enumerator Stream
class CacheVol

A cache volume as described in volume.config. This class represents a single volume. CacheVol comprises of stripes spread across Spans(disks)

int volume_number

indentification number of this volume

int scheme

An enumeration of value CacheType::HTTP or CacheType::Stream.

off_t size
int num_vols

Number of stripes(Vol) contained in this volume

Vol **vols

Vol represents a single stripe in the disk. vols contains all the stripes this volume is made up of

DiskVol **disk_vols

disk_vols contain references to the disks of all the stripes in this volume

LINK<CacheVol> link
RecRawStatBlock vol_rsb

per volume stat

class ConfigVol

This class represents an individual volume.

int number

Identification number of the volume

CacheType scheme
off_t size
bool in_percent

Used as an indicator if the volume is part of the overall volumes created by ATS

int percent
CacheVol *cachep
LINK<ConfigVol> link
class ConfigVolumes
int num_volumes

Total number of volumes specified in volume.config

int num_http_volumes

Total number of volumes scpecified in volume.config for HTTP scheme

Queue<ConfigVol> cp_queue
class Cache

Base object for a cache.

CacheHostRecord hosttable

A generic class:CacheHostRecord that contains all cache volumes that are not explicitly assigned in hosting.config.

Vol *key_to_vol(const char *key, const char *host, int host_len)

Compute the stripe (Vol*) for a cache key and host. The host is used to find the appropriate CacheHostRecord instance. From there the stripe assignment slot is determined by taking bits 64..83 (20 bits) of the cache key modulo the stripe assignment array count (VOL_HASH_TABLE_SIZE). These bits are the third 32 bit slice of the key less the bottom DIR_TAG_WIDTH (12) bits.

Footnotes

 [1] Changed in version 3.2.0. This previously resided in the first Doc but that caused different alternates to share the same fragment table.