forked from OpenDDS/OpenDDS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPERSISTENCE
88 lines (69 loc) · 2.79 KB
/
PERSISTENCE
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
Filesystem-based persistence for the DataDurabilityCache and the InfoRepo
=========================================================================
Key => {foo} is a variable replaced by an application identifier,
all of these represent collections of application objects
Logical model: DataDurabilityCache
{domain_id}/
{topic_name}/
{type_name}/
{dw_id}/ => arbitrary name assigned per-writer
0001 => [timestamp, data]
000N
Logical model: InfoRepo
topics/
{topic_id}
data => [domainID, topicName, participantID, dataType, QoS]
participants/
{participant_id}/
data => [domainID, owner, QoS]
publications/
{writer_id}/
basic_data => [domainID, topicID, participantID, tport]
pub_qos => [serialized QoS structure]
writer_qos => [serialized QoS structure]
subscriptions/
{reader_id}/
basic_data => [domainID, topicID, participantID, tport]
sub_qos => [serialized QoS structure]
reader_qos => [serialized QoS structure]
Logical -> physical transformation
1. Directory/file name encoding
Base32Hex (RFC 4648) the first 150 characters (240 encoded) of the name
For directories:
write a file named _fullname in the dir, contains the unencoded name
If the length is actually >= 150
append .0000N (counter) to the encoded name
For files:
If the name's length >= 155 this is an error
*NOTE: we don't know of a case where we need arbitrary-length file names
2. Overflowing a directory
Define a compile-time constant for the max. entries per directory
Needs to leave enough headroom to create the overflow directories
Default to 512
Once this limit is reached we will create _overflow.000N directories
Searching must always take this into account: we will need a simple linear
search of the _overflow.* if the entry is not found in the normal location.
API (pseudocode)
class Directory
{
Directory(const char* root_path);
FileIterator begin_files(); //files will be sorted
FileIterator end_files();
File get_file(const char* name); //slash is not a separator
File create_next_file();
DirectoryIterator begin_dirs(); //dirs will be sorted
DirectoryIterator end_dirs();
Directory get_dir(vector<string> path);
Directory get_subdir(const char* name); //slash is not a separator
Directory create_next_dir();
void remove(); //recursive
Directory parent();
};
// *Iterator models the STL InputIterator concept (==, !=, *, ++)
class File
{
bool write(ofstream& stream);
bool read(ifstream& stream);
bool remove();
Directory parent();
};