2022-09-21 10:43:31 +00:00
|
|
|
package engine
|
|
|
|
|
|
|
|
import (
|
2022-12-23 17:35:35 +00:00
|
|
|
"github.com/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard"
|
2022-09-21 10:43:31 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// FlushWriteCachePrm groups the parameters of FlushWriteCache operation.
|
|
|
|
type FlushWriteCachePrm struct {
|
2022-09-26 08:54:21 +00:00
|
|
|
shardID *shard.ID
|
|
|
|
ignoreErrors bool
|
2022-09-21 10:43:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// SetShardID is an option to set shard ID.
|
|
|
|
//
|
|
|
|
// Option is required.
|
|
|
|
func (p *FlushWriteCachePrm) SetShardID(id *shard.ID) {
|
|
|
|
p.shardID = id
|
|
|
|
}
|
|
|
|
|
2022-09-26 08:54:21 +00:00
|
|
|
// SetIgnoreErrors sets errors ignore flag..
|
|
|
|
func (p *FlushWriteCachePrm) SetIgnoreErrors(ignore bool) {
|
|
|
|
p.ignoreErrors = ignore
|
|
|
|
}
|
|
|
|
|
2022-09-21 10:43:31 +00:00
|
|
|
// FlushWriteCacheRes groups the resulting values of FlushWriteCache operation.
|
|
|
|
type FlushWriteCacheRes struct{}
|
|
|
|
|
|
|
|
// FlushWriteCache flushes write-cache on a single shard.
|
|
|
|
func (e *StorageEngine) FlushWriteCache(p FlushWriteCachePrm) (FlushWriteCacheRes, error) {
|
|
|
|
e.mtx.RLock()
|
|
|
|
sh, ok := e.shards[p.shardID.String()]
|
|
|
|
e.mtx.RUnlock()
|
|
|
|
|
|
|
|
if !ok {
|
|
|
|
return FlushWriteCacheRes{}, errShardNotFound
|
|
|
|
}
|
|
|
|
|
2022-09-26 08:54:21 +00:00
|
|
|
var prm shard.FlushWriteCachePrm
|
|
|
|
prm.SetIgnoreErrors(p.ignoreErrors)
|
|
|
|
|
|
|
|
return FlushWriteCacheRes{}, sh.FlushWriteCache(prm)
|
2022-09-21 10:43:31 +00:00
|
|
|
}
|