Remote file access system Cage


4. Using the system on the client side

The methods of the Cage class replace the usual, "routine" operations of the file system: creating, opening, closing, deleting files, as well as reading/writing data in binary format (specifying the position and size of the data). Conceptually, these methods are close to the file functions of the C language, where opening/closing files is done "on the channels" of input/output.

In other words, the programmer does not work with methods of "file" objects (class _io in Python), but with methods of class Cage.

When you create a Cage object, it establishes an initial connection to the server (or multiple servers), is authorized by the client Id, and receives a confirmation with a dedicated port number for all file operations. When you delete a Cage object, it issues a command to the server to terminate the connection and close the files. Termination of communication can initiate and the servers themselves.

The system improves read/write performance by buffering frequently used file fragments from client programs in the cache (buffer) of RAM.Client's software can use any number of Cage objects with different settings (buffer memory size, block size when communicating with the server, etc.).

A single Cage object can communicate with multiple files on multiple servers. Parameters for communication (IP address or DNS server, primary port for authorization, path and file name) are set when creating the object.

Since each Cage object can handle multiple files at the same time, a common memory space is used for buffering. Cache size – the number of pages and their size is set dynamically when creating a Cage object. For example, a 1 GB cache is 1,000 pages of 1 MB, or 10,000 pages of 100 KB, or 1 million pages of 1 KB. Choosing the size and number of pages is a specific task for each application.

You can use multiple Cage objects at the same time to define different buffer memory settings depending on how you access information in different files. As a basic, the simplest buffering algorithm is used: after exhausting a given amount of memory, new pages displace old ones on the principle of disposal with a minimum number of hits. Buffering is especially effective in the case of uneven (in a statistical sense) sharing, first, to different files, and, secondly, to fragments of each file.

Cage class supports input/output not only by data addresses (specifying the position and length of the array, "replacing" file system operations), but also at a lower, "physical" level - by page numbers in buffer memory.

For Cage objects, the original hibernation (sleep) function is supported – they can be "minimized" (for example, in case of disconnection with servers, or when the application is stopped, etc.) to a local dump file on the client side and quickly restored from this file (after resuming communication, when the application is restarted). This makes it possible to significantly reduce traffic when activating the client program after a temporary departure "offline", as often used fragments of files will already be in the cache.

Cage is about 3600 lines of code.