forked from TrueCloudLab/frostfs-node
[#1559] local_object_storage: Allow to set mode for all components
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
1e786233bf
commit
3df62769c0
16 changed files with 230 additions and 28 deletions
|
@ -835,6 +835,11 @@ func (b *blobovniczas) init() error {
|
|||
return zstdD(data)
|
||||
}
|
||||
|
||||
if b.readOnly {
|
||||
b.log.Debug("read-only mode, skip blobovniczas initialization...")
|
||||
return nil
|
||||
}
|
||||
|
||||
return b.iterateBlobovniczas(false, func(p string, blz *blobovnicza.Blobovnicza) error {
|
||||
if err := blz.Init(); err != nil {
|
||||
return fmt.Errorf("could not initialize blobovnicza structure %s: %w", p, err)
|
||||
|
|
|
@ -4,9 +4,11 @@ import (
|
|||
"encoding/hex"
|
||||
"io/fs"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
|
||||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobovnicza"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/fstree"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard/mode"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
@ -16,6 +18,9 @@ type BlobStor struct {
|
|||
*cfg
|
||||
|
||||
blobovniczas *blobovniczas
|
||||
|
||||
modeMtx sync.RWMutex
|
||||
mode mode.Mode
|
||||
}
|
||||
|
||||
type Info = fstree.Info
|
||||
|
|
35
pkg/local_object_storage/blobstor/mode.go
Normal file
35
pkg/local_object_storage/blobstor/mode.go
Normal file
|
@ -0,0 +1,35 @@
|
|||
package blobstor
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard/mode"
|
||||
)
|
||||
|
||||
// SetMode sets the blobstor mode of operation.
|
||||
func (b *BlobStor) SetMode(m mode.Mode) error {
|
||||
b.modeMtx.Lock()
|
||||
defer b.modeMtx.Unlock()
|
||||
|
||||
if b.mode == m {
|
||||
return nil
|
||||
}
|
||||
|
||||
if b.mode.ReadOnly() == m.ReadOnly() {
|
||||
return nil
|
||||
}
|
||||
|
||||
err := b.Close()
|
||||
if err == nil {
|
||||
if err = b.Open(m.ReadOnly()); err == nil {
|
||||
err = b.Init()
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
return fmt.Errorf("can't set blobstor mode (old=%s, new=%s): %w", b.mode, m, err)
|
||||
}
|
||||
|
||||
b.blobovniczas.readOnly = m.ReadOnly()
|
||||
b.mode = m
|
||||
return nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue