[#188] shard: Implement SetMode method

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2020-11-19 15:56:10 +03:00 committed by Alex Vanin
parent 2fb379b7dd
commit 3fa3661cad
2 changed files with 16 additions and 0 deletions

View file

@ -40,3 +40,15 @@ func (m Mode) String() string {
return "EVACUATE" return "EVACUATE"
} }
} }
// SetMode sets mode of the shard.
//
// Returns any error encountered that did not allow
// to set shard mode.
func (s *Shard) SetMode(m Mode) error {
s.mode.Store(uint32(m))
}
func (s *Shard) getMode() Mode {
return Mode(s.mode.Load())
}

View file

@ -4,12 +4,15 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor"
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase" meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
"github.com/nspcc-dev/neofs-node/pkg/util/logger" "github.com/nspcc-dev/neofs-node/pkg/util/logger"
"go.uber.org/atomic"
) )
// Shard represents single shard of NeoFS Local Storage Engine. // Shard represents single shard of NeoFS Local Storage Engine.
type Shard struct { type Shard struct {
*cfg *cfg
mode *atomic.Uint32
weight WeightValues weight WeightValues
blobStor *blobstor.BlobStor blobStor *blobstor.BlobStor
@ -44,6 +47,7 @@ func New(opts ...Option) *Shard {
return &Shard{ return &Shard{
cfg: c, cfg: c,
mode: atomic.NewUint32(0), // TODO: init with particular mode
blobStor: blobstor.New(c.blobOpts...), blobStor: blobstor.New(c.blobOpts...),
metaBase: meta.NewDB(c.metaOpts...), metaBase: meta.NewDB(c.metaOpts...),
} }