forked from TrueCloudLab/frostfs-node
[#220] localstorage: Implement Open/Init/Close methods
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
2963473c08
commit
e758c246b7
1 changed files with 51 additions and 0 deletions
51
pkg/local_object_storage/engine/control.go
Normal file
51
pkg/local_object_storage/engine/control.go
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
package engine
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
"go.uber.org/zap"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Open opens all StorageEngine's components.
|
||||||
|
func (e *StorageEngine) Open() error {
|
||||||
|
e.mtx.RLock()
|
||||||
|
defer e.mtx.RUnlock()
|
||||||
|
|
||||||
|
for id, sh := range e.shards {
|
||||||
|
if err := sh.Open(); err != nil {
|
||||||
|
return errors.Wrapf(err, "could not initialize shard %s", id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Init initializes all StorageEngine's components.
|
||||||
|
func (e *StorageEngine) Init() error {
|
||||||
|
e.mtx.RLock()
|
||||||
|
defer e.mtx.RUnlock()
|
||||||
|
|
||||||
|
for id, sh := range e.shards {
|
||||||
|
if err := sh.Init(); err != nil {
|
||||||
|
return errors.Wrapf(err, "could not initialize shard %s", id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close releases all StorageEngine's components.
|
||||||
|
func (e *StorageEngine) Close() error {
|
||||||
|
e.mtx.RLock()
|
||||||
|
defer e.mtx.RUnlock()
|
||||||
|
|
||||||
|
for id, sh := range e.shards {
|
||||||
|
if err := sh.Close(); err != nil {
|
||||||
|
e.log.Debug("could not close shard",
|
||||||
|
zap.String("id", id),
|
||||||
|
zap.String("error", err.Error()),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
Loading…
Reference in a new issue