Next: , Previous: , Up: Relational schema   [Contents][Index]


4.3 mdtx-COLL.md5

SERVER (see Server) backup its collection’s status into the ~mdtx/md5sums/mdtx-COLL.md5 file. When PUBLISHER or CLIENT want to read the lastest status, they need to ask SERVER the refresh this file.

The Messages the cgiClient (see cgiClient), supp (see supp) and notify (see notify) processes exchange via socket are using the same grammar language. There is type for such messages:

These messages are cyphered using AES algorithm and a key defined into /etc/mediatex/mdtx-COLL/servers.txt (see servers.txt) file.
When loaded into memory, such messages are handled using the following relational schema:

mediatex-figures/mdtx-COLL.md5

All the time cache is loaded, archive objects are never free but eventually marked as deleted. The cache api is thread safe. 3 locks are used in order to allow concurrent access:

  1. MUTEX_ALLOC: when modifying the cache size
  2. MUTEX_COMPUTE: when computing archive state
  3. MUTEX_KEEP: when adjusting the archive time to live into the cache
  4. MUTEX_TARGET: when creating a new target file

Example:

Headers
  Collection hello               
  Type       DISK
  Server     adc2f7b78c43354df5a86efae3dfe562
  DoCypher   FALSE            
Body          
#                date    host    hash   size extra
D 2015-10-04,23:40:13 adc2… 022a…  24075 test@test.org
S 2015-10-04,23:40:28 adc2… 1a16…  20480 logoP1.cat
S 2015-10-04,23:40:24 aed9… 1a16…  20480 logoP1.cat
S 2015-10-04,23:34:30 adc2… 99b8…   1004 2015-10/mediatex.css

Grammar:

file: //empty file 
    | header
    | header lines

header: HEADERS hLines BODY

hLines: hLines hLine
     | hLine

hLine: COLLECTION string
     | SERVER string
     | TYPE msgval
     | DOCYPHER bool

lines: lines newLine
     | newLine

newLine: line

line: type date hash hash [[:digit:]]+ string

msgval: DISK | CGI | HAVE | NOTIFY | UPLOAD
bool: FALSE | TRUE
type: S | D

date:   {year}-{month}-{day},{HOUR}:{min}:{sec}

year:   [[:digit:]]{4}
month:  [[:digit:]]{2}
day:    [[:digit:]]{2}
HOUR:   [[:digit:]]{2}
min:    [[:digit:]]{2}
sec:    [[:digit:]]{2}

hash:   [[:xdigit:]]{32}
string: [^[:blank:]\r\n]{1,511}

Code:

src/misc/cypher.c
src/memory/archiveTree.h
src/memory/archiveTree.c
src/memory/recordTree.h
src/memory/recordTree.c
src/parser/recordFile.l
src/parser/recordFile.y
src/common/openClose.c

This code is use to get the record’s type:

RecordType rc = UNDEF_RECORD;

switch (self->type & 0x3) {
case DEMAND:
  if (!self->server->isLocalhost)  
    rc = REMOTE_DEMAND;
  else if (self->extra[0] != '!')
    rc = FINAL_DEMAND;
  else if (self->extra[1] == 'w')
    rc = LOCAL_DEMAND;
  break;

case SUPPLY:
  if (!self->server->isLocalhost)  
    rc = REMOTE_SUPPLY;
  else if (self->extra[0] == '/')
    rc = FINAL_SUPPLY;
  else if (self->extra[0] != '!')
    rc = LOCAL_SUPPLY;
  else if (self->extra[1] == 'm')
    rc = MALLOC_SUPPLY;
  break;
}

Next: , Previous: , Up: Relational schema   [Contents][Index]