From 4f756bf1216ea1c54b4384f4105b86df7d1ed5d2 Mon Sep 17 00:00:00 2001 From: Pavel Karpy Date: Mon, 27 Dec 2021 14:03:15 +0300 Subject: [PATCH] [#1057] shard: Make shard to have only two mode Shard's mode was not used in the Node, so added only two modes whose roles are clear. More modes will be added in the future. Signed-off-by: Pavel Karpy --- pkg/local_object_storage/shard/mode.go | 37 ++++++++++---------------- 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/pkg/local_object_storage/shard/mode.go b/pkg/local_object_storage/shard/mode.go index fcb63255c0..d1e370cf25 100644 --- a/pkg/local_object_storage/shard/mode.go +++ b/pkg/local_object_storage/shard/mode.go @@ -1,50 +1,41 @@ package shard +import "errors" + // Mode represents enumeration of Shard work modes. type Mode uint32 +// ErrReadOnlyMode is returned when it is impossible to apply operation +// that changes shard's memory due to the "read-only" shard's mode. +var ErrReadOnlyMode = errors.New("shard is in read-only mode") + // TODO: more detailed description of shard modes. const ( - _ Mode = iota + // ModeReadWrite is a Mode value for shard that is available + // for read and write operations. Default shard mode. + ModeReadWrite Mode = iota - // ModeActive is a Mode value for active shard. - ModeActive - - // ModeInactive is a Mode value for inactive shard. - ModeInactive - - // ModeReadOnly is a Mode value for read-only shard. + // ModeReadOnly is a Mode value for shard that does not + // accept write operation but is readable. ModeReadOnly - - // ModeFault is a Mode value for faulty shard. - ModeFault - - // ModeEvacuate is a Mode value for evacuating shard. - ModeEvacuate ) func (m Mode) String() string { switch m { default: return "UNDEFINED" - case ModeActive: - return "ACTIVE" - case ModeInactive: - return "INACTIVE" + case ModeReadWrite: + return "READ_WRITE" case ModeReadOnly: return "READ_ONLY" - case ModeFault: - return "FAULT" - case ModeEvacuate: - return "EVACUATE" } } // SetMode sets mode of the shard. // // Returns any error encountered that did not allow -// to set shard mode. +// setting shard mode. func (s *Shard) SetMode(m Mode) error { s.mode.Store(uint32(m))