You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "Glen Geng (Jira)" <ji...@apache.org> on 2021/03/02 11:24:00 UTC
[jira] [Updated] (HDDS-4651) Implement Distributed Sequence ID
Generator
[ https://issues.apache.org/jira/browse/HDDS-4651?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Glen Geng updated HDDS-4651:
----------------------------
Description:
* SCM allocates ids in a batch way. It maintains three fields: firstId, lastId and nextId. It saves the lastId in rocksDB, saves firstId and lastId in memory. The initial value of nextId is firstId.
* When getNextId() is called, if nextId is less than lastId, SCM just returns nextId and increases it, otherwise it calls allocateBatch(expectedLastId, newLastId) to allocate a batch of ids, then serves the request.
* In allocateBatch(expectedLastId, newLastId) , it works in CAS way:
* it reads lastId from rocksDB.
* if lastId equals expectedLastId, it saves newLastId into rocksDB, returns success, otherwise it rejects the allocation request.
* It also provides a getLastId() to read lastId from rocksDB. The allocation works in a loop way:
was:
/**
* SequenceIDGenerator uses higher 30 bits to save the term, and lower 34 bits
* to save a count (increase from 0). Each call of nextID() will increase the
* count on the lower 34 bits by 1, thus SequenceIDGenerator always generates
* unique number within a specific term.
*/
> Implement Distributed Sequence ID Generator
> --------------------------------------------
>
> Key: HDDS-4651
> URL: https://issues.apache.org/jira/browse/HDDS-4651
> Project: Apache Ozone
> Issue Type: Sub-task
> Reporter: Rui Wang
> Assignee: Rui Wang
> Priority: Major
> Labels: pull-request-available
> Fix For: 1.1.0
>
>
>
> * SCM allocates ids in a batch way. It maintains three fields: firstId, lastId and nextId. It saves the lastId in rocksDB, saves firstId and lastId in memory. The initial value of nextId is firstId.
> * When getNextId() is called, if nextId is less than lastId, SCM just returns nextId and increases it, otherwise it calls allocateBatch(expectedLastId, newLastId) to allocate a batch of ids, then serves the request.
> * In allocateBatch(expectedLastId, newLastId) , it works in CAS way:
> * it reads lastId from rocksDB.
> * if lastId equals expectedLastId, it saves newLastId into rocksDB, returns success, otherwise it rejects the allocation request.
> * It also provides a getLastId() to read lastId from rocksDB. The allocation works in a loop way:
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org