ATS read large files (hits)

Source: Internet
Author: User

Large file storage structure and small files are completely different, small files accounted for a fragment enough, small files accounted for a number of fragment. The first of the small file is doc only some information data, including HTTP headers, the content of the resource exists in several fragment, the default of each fragment show 1048576 bytes, in proxy.config.cache.target_ The fragment_size can be changed. 72 bytes In a fragment are doc, and the rest is the content of the resource. ATS reads the first fragment and then reads several fragment in a circular manner until the client gets all the data it needs.

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/89/B9/wKioL1ga9xLSFYbSAAPvh3sQl3M637.png "title=" ATS large file reads (hits). png "alt=" Wkiol1ga9xlsfybsaapvh3sql3m637.png "/>

Cache::open_read: Calculated to Vol. Run the Dir_probe function to determine the results of the cached query. The dir is obtained and the key and Dir of the Cachevc object are initialized. Generates a Cachevc object, and the next operation is the Cachevc object. set the callback function to Cache::openreadstarthead, and set the callback function to execute do_read_call.

cachevc::handleread: Gets the offset (dir_get_offset). Queries in memory (the Vol->ram_cache->get function points to different functions according to the configuration items in Records.config proxy.config.cache.ram_cache.algorithm). If the query is not hit, generate a Iobufferdata buf (which can be understood as opening a space in memory) and generate a char* variable that points to the BUF data. memcpy the contents of the disk into memory. There will be two cases, one is that Ramhit will execute Cachevc::handlereaddone, the other is memhit, the direct execution of Cachevc::openreadstarthead, the difference is not small, here discusses Memhit situation. The callback function pops out, and the callback function after the pop changes to Cache::open_read set cache::o Penreadstarthead, eventually returning Event_return until cache::open_read

Cachevc::openreadstarthead: The function determines whether it is a large file or a small file. A alternate is selected to assign the selected alternate key to Cache::key to determine whether the alternate key and Doc->key are equal. Because the doc of the large file only has some information, so the alternate key and the first content of the fragment Doc->key. The function finally assigns a value of BUF to NULL, and then sets the callback function to Cachevc::openreadstartearliest and executes.

cachevc::openreadstartearliest: If hit status, it is typically performed two times. However, if the function is being downloaded for several times, the acquisition of the lock will not succeed. In order,Cachevc::openreadstarthead has acquired the first fragment key to store the content. Earliest_dir is obtained by dir_probe function according to key.

CACHEVC::d o_read_call: Initialize doc_pos to 0. Parse dir, get fragment approximate size (dir_approx_size). Decide if it should be written to the SSD (DIR_INSSD), if it is already read from the SSD, it must not be written. Each vol will correspond to its own SSD, and each vol will maintain some historical data used to determine heat-related data. Finally, the callback function is push to cachevc::handleread and executed.

cachevc::handleread: Gets the offset (dir_get_offset). Queries in memory (the Vol->ram_cache->get function points to different functions according to the configuration items in Records.config proxy.config.cache.ram_cache.algorithm). Set the callback function to Cachevc::handlereaddone, return event_cont up to Cache::open_read, and end the event .

Cachevc::handlereaddone: The callback function pops out, then the callback function becomes cachevc::openreadstartearliest, and then the callback function executes.

Cachevc::openreadstartearliest: This time buf is not null, calculate Next_key, set the callback function to Cachevc::openreadmain and execute.

Cachevc::openreadmain: Determines the starting position of the range where the client request is located in which fragment, adjusts the offset and doc_pos to the appropriate position, offset is the entire response offset does not contain 72 bytes of Doc, Doc_pos is a single fragment postion consisting of 72 bytes. This function goes through several times until everything is finished. When the last execution, according to the Cachevc::openreadstartearliest computed key, through the Dir_probe to the corresponding Dir, set the callback function to Cachevc::openreadreaddone, Execute CACHEVC::d O_read_call, and finally return to Event_cont. Here it goes into a loop, a piece of a piece of read file to send the file until the request is over.

Cachevc::handlereaddone: After entering the loop, this function starts from the event, changes the callback function after the pop-out of the callback function into Cachevc::openreadreaddone, and executes the callback function.

Cachevc::openreadreaddone: fragment number plus 1, calculate next_key. Set the callback function to Cachevc::openreadmain and execute.


ATS read large files (hits)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.