The Bertha server stores blobs of data. Blobs of data are accessed by their SHA-256 hashes: the key of a blob of data is its SHA-256 hash. All sizes send and received are 64 bit little endian unsigned integers.
After the TCP connection is established, the client sends a single octet. This is the command byte and is one of
- 0 for LIST, lists the keys of the blobs
- 1 for PUT, adds a blob
- 2 for GET, retrieves a blob by its key
- 3 for QUIT, quits the server
- 4 for SPUT, adds a blob and give a hint of its size
- 5 for SGET, retrieves a blob and its size by its key
- 6 for SIZE, retreives the size of a blob by its key
- 7 for STATS, retreives some statistical counters
Used to list all the keys.
- The server sends the keys of all blobs in a unspecified order. The keys are send as 32 byte binary words.
- The server closes the connection.
Used to add a new blob to the server.
- The client sends the blob to the server.
- The client shuts its socket down for writing.
- The server sends the key of the added blob.
- The server closes the connection.
Used to retrieve a blob by its key
- The client sends the key to server.
- The server sends the blob if it exists. Otherwise the server closes the connection.
- The server closes the connection.
Used to quit the server.
- The server closes the connection and shuts itself down.
Similar to PUT. The client additionally sends the probable size of the blob. This allows the server to pre-allocate room for the blob.
- The client sends the probable size of the blob to the server as a little endian 64 bit unsigned integer.
- The client sends the blob to the server.
- The client shuts its socket down for writing.
- The server sends the key of the added blob.
- The server closes the connection.
Similar to GET. The server additionally sends the size of the blob.
- The client sends the key to server.
- The server sends the size of the blob as a little endian 64 bit unsigned integer, if the blob exists. Otherwise the server closes the connection.
- The server sends the blob.
- The server closes the connection.
Used to retrieve the size of a blob by its key. Also useful to check whether a blob exists without having to execute LIST.
- The client sends the key to server.
- The server sends the size of the blob, if it exists.
- The server closes the connection.
Used to retrieve some counter.
- The server sends five little-endian 64bit unsigned integers:
n_cycle
: the number of non-trivial cycles in the mainloop;n_GET_sent
: the total number of bytes sent for (S)GET requests;n_PUT_received
: the total number of bytes received for (S)PUT requests;n_conns_accepted
: the total number of connections accepted andn_conns_active
: the number of currently active connections.
- The server closes the connection.