forked from TrueCloudLab/frostfs-node
[#922] storage engine: Support operation blocking
There is a need to disable execution of local data operation on storage engine in runtime. If storage engine ops are blocked, node will act like always but all local object operations will be denied. Implement `BlockExecution` / `ResumeExecution` methods on `StorageEngine` which blocks / resumes the execution of data ops. Wait for the completion of all operations executed at the time of the call. Return error passed to `BlockExecution` from all data-related methods until `ResumeExecution` call. Make `Close` to block operations as well. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
cea1de3a27
commit
ec04e787aa
10 changed files with 237 additions and 29 deletions
|
@ -47,7 +47,18 @@ func (r *SelectRes) AddressList() []*object.Address {
|
|||
// Select selects the objects from local storage that match select parameters.
|
||||
//
|
||||
// Returns any error encountered that did not allow to completely select the objects.
|
||||
func (e *StorageEngine) Select(prm *SelectPrm) (*SelectRes, error) {
|
||||
//
|
||||
// Returns an error if executions are blocked (see BlockExecution).
|
||||
func (e *StorageEngine) Select(prm *SelectPrm) (res *SelectRes, err error) {
|
||||
err = e.exec(func() error {
|
||||
res, err = e._select(prm)
|
||||
return err
|
||||
})
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (e *StorageEngine) _select(prm *SelectPrm) (*SelectRes, error) {
|
||||
if e.metrics != nil {
|
||||
defer elapsed(e.metrics.AddSearchDuration)()
|
||||
}
|
||||
|
@ -97,7 +108,18 @@ func (e *StorageEngine) Select(prm *SelectPrm) (*SelectRes, error) {
|
|||
|
||||
// List returns `limit` available physically storage object addresses in engine.
|
||||
// If limit is zero, then returns all available object addresses.
|
||||
func (e *StorageEngine) List(limit uint64) (*SelectRes, error) {
|
||||
//
|
||||
// Returns an error if executions are blocked (see BlockExecution).
|
||||
func (e *StorageEngine) List(limit uint64) (res *SelectRes, err error) {
|
||||
err = e.exec(func() error {
|
||||
res, err = e.list(limit)
|
||||
return err
|
||||
})
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (e *StorageEngine) list(limit uint64) (*SelectRes, error) {
|
||||
if e.metrics != nil {
|
||||
defer elapsed(e.metrics.AddListObjectsDuration)()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue