Switch lang: Русский \ English

DT - Distributed Tree


DT - буквально, Distributed tree. DT - это распределенное дерево, облачный сервис, хранилище - контейнер со сложностью доступа O(log(N))

Hi level Api

insert( TreeID, key, value ) → 
    DT_node_id 
    | nil 
delete( TreeID, key ) → 
    true
    | “error with decription“
setCas(TreeID, key, old, newValue) → true | “error string”
seek(TreeID, key) → [prevkey, nextkey] | “error string”

Insert parameters: TreeID, key and value.

Inserting value to distributed tree.

Return node_id.

Delete parameters TreeID and key.

Return success or error description

set get values of some key in tree. working with CAS (Compare and set).

Seek operation can pos to key sequence from any key and return real existing key near needed.

Low level Api

getRoot(TreeID) → nodeid
getDownNodes(nodeid) → [nodeid, nodeid, …]
getUpNode(nodeid) → nodeid
getMetaProp(nodeid, propName) → just value | nil
casMetaProp(nodeid, propName, old, newValue) → true | false | “error string”

API HTTP "REST"

We Use form encoded data in POST requests.

HTTP status in any case 200, otherwise service or access error.

Code field in answer json coding situation more correctly.

Why ? So, we cant put bad status (not 200) and body in same time to response - "OkHTTP" and other http client libs for Android can't handle this combination.

Insert

  • /dt/insert
    • POST: Insert key-value into tree.

      parameter Type Description
      tree_id str Tree Id
      key str key in tree
      value str string value

      Answer (json)

      Status Code Data
      success - DT_node_id
      fail 801 can't insert, this tree not exist
      fail 802 insertion error, hi load , timeout
      fail 803 we don't know what hapend , but error, sorry

Delete

  • /dt/delete
    • POST: Delete key-value from tree.

      parameter Type Description
      tree_id str Tree Id
      key str key in tree

      Answer (json)

      Status Code Data
      success - deleted
      fail 801 can't delete, this tree not exist
      fail 802 deletion error, hi load ..., timeout
      fail 803 we don't know what hapend , but error, sorry

SetCas

  • /dt/setcas
    • POST: Set value for some key of tree.

      parameter Type Description
      tree_id str Tree Id
      key str key in tree
      old_value str string old value for cas check
      value str string new value

      Answer (json)

      Status Code Data
      success - ok
      fail 801 can't set, this tree not exist
      fail 802 value set error, hi load ..., timeout
      fail 803 we don't know what hapend , but error, sorry
      fail 804 CAS ! old value not equal actual value in tree

Seek

  • /dt/seek
    • POST: orient in tree. get prev and next key near some point

      parameter Type Description
      tree_id str Tree Id
      key str point by some key in tree

      Answer (json)

      Status Code Data
      success - ["", ""]
      fail 801 can't seek, this tree not exist
      fail 802 seek error, hi load ..., timeout
      fail 803 we don't know what hapend , but error, sorry

Комментарии

Comments powered by Disqus
Перейти к главному содержимому