Disk Queue Design

zbus file system targets to support Unicast, Multicast and Broadcast messaging model based on the following 5 components.

Both Index and QueueReader share the common format of mapped file for extension and mask/updatedts/createdts

                     Common MappedFile Header(1024)
           +------------------------------------------------+
           |                                            128 |
           +------------------------------------------------+
           |                                            128 |
           +------------------------------------------------+
           |     ...  |Mask(4)|UpdateTs(8)|CreatedTs(8) 128 |
           +------------------------------------------------+
           |                    Creator                 128 | 
           +------------------------------------------------+ 
           |                   128(Ext1)                128 | 
           +------------------------------------------------+ 
           |                   128(Ext2)                128 | 
           +------------------------------------------------+
           |                   128(Ext3)                128 | 
           +------------------------------------------------+  
           |                   128(Ext4)                128 | 
           +------------------------------------------------+     

Index

Index stores an infinite(long sized) array of block metadata, each block metadata item identifies

BlockCount is the number of block available to read in the index.

BlockStart is the start block number which is valid to read/write, initialized as 0, incremented if any history blocks deleted. The real slot in the index file is mapped by blockNumber%MaxBlockCount

MessageNumber is total message counter since Index created.

Mask is used by the application to set special meaning

Extension is managed as key-value pairs, such as storing index's creator information.

Block

Block reads and writes DiskMessage.

DiskMessage's tag is employed to filter on reading message, which is useful for subscriber to filter out uninterested messages.

QueueReader

QueueWriter

A very thin layer on Index, only the last block blockStart+blockCount-1 is writable.

Performance Boost

Index and QueueReader are loaded via MappedFile, the operations on Index itself can be assumed as the speed of memory operation.