[#661] wip
Some checks failed
Vulncheck / Vulncheck (pull_request) Successful in 1m38s
Tests and linters / Lint (pull_request) Failing after 3m38s
Build / Build Components (1.21) (pull_request) Successful in 3m59s
DCO action / DCO (pull_request) Successful in 4m5s
Tests and linters / Tests (1.20) (pull_request) Successful in 6m4s
Tests and linters / Staticcheck (pull_request) Successful in 5m51s
Tests and linters / Tests (1.21) (pull_request) Successful in 6m6s
Tests and linters / Tests with -race (pull_request) Successful in 6m36s
Build / Build Components (1.20) (pull_request) Successful in 8m3s
Some checks failed
Vulncheck / Vulncheck (pull_request) Successful in 1m38s
Tests and linters / Lint (pull_request) Failing after 3m38s
Build / Build Components (1.21) (pull_request) Successful in 3m59s
DCO action / DCO (pull_request) Successful in 4m5s
Tests and linters / Tests (1.20) (pull_request) Successful in 6m4s
Tests and linters / Staticcheck (pull_request) Successful in 5m51s
Tests and linters / Tests (1.21) (pull_request) Successful in 6m6s
Tests and linters / Tests with -race (pull_request) Successful in 6m36s
Build / Build Components (1.20) (pull_request) Successful in 8m3s
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
3e7fdd3e19
commit
624cc263aa
3 changed files with 59 additions and 25 deletions
|
@ -773,31 +773,7 @@ func (c *cfg) getSubstorageOpts(shCfg shardCfg) []blobstor.SubStorage {
|
|||
for _, sRead := range shCfg.subStorages {
|
||||
switch sRead.typ {
|
||||
case blobovniczatree.Type:
|
||||
blobTreeOpts := []blobovniczatree.Option{
|
||||
blobovniczatree.WithRootPath(sRead.path),
|
||||
blobovniczatree.WithPermissions(sRead.perm),
|
||||
blobovniczatree.WithBlobovniczaSize(sRead.size),
|
||||
blobovniczatree.WithBlobovniczaShallowDepth(sRead.depth),
|
||||
blobovniczatree.WithBlobovniczaShallowWidth(sRead.width),
|
||||
blobovniczatree.WithBlobovniczaLeafWidth(sRead.leafWidth),
|
||||
blobovniczatree.WithOpenedCacheSize(sRead.openedCacheSize),
|
||||
blobovniczatree.WithLogger(c.log),
|
||||
}
|
||||
|
||||
if c.metricsCollector != nil {
|
||||
blobTreeOpts = append(blobTreeOpts,
|
||||
blobovniczatree.WithMetrics(
|
||||
lsmetrics.NewBlobovniczaTreeMetrics(sRead.path, c.metricsCollector.BlobobvnizcaTreeMetrics()),
|
||||
),
|
||||
)
|
||||
}
|
||||
ss = append(ss, blobstor.SubStorage{
|
||||
Storage: blobovniczatree.NewBlobovniczaTree(blobTreeOpts...),
|
||||
Policy: func(_ *objectSDK.Object, data []byte) bool {
|
||||
return uint64(len(data)) < shCfg.smallSizeObjectLimit
|
||||
},
|
||||
SupportsStorageID: true,
|
||||
})
|
||||
ss = c.appendBlobovnicza(ss, sRead, shCfg)
|
||||
case fstree.Type:
|
||||
fstreeOpts := []fstree.Option{
|
||||
fstree.WithPath(sRead.path),
|
||||
|
@ -827,6 +803,49 @@ func (c *cfg) getSubstorageOpts(shCfg shardCfg) []blobstor.SubStorage {
|
|||
return ss
|
||||
}
|
||||
|
||||
func (c *cfg) appendBlobovnicza(ss []blobstor.SubStorage, sRead subStorageCfg, shCfg shardCfg) []blobstor.SubStorage {
|
||||
currentCfg, err := blobovniczatree.ReadFromRootPath(sRead.path)
|
||||
if err != nil {
|
||||
c.log.Warn(logs.FailedToReadMigrationConfig, zap.Error(err))
|
||||
}
|
||||
targetCfg := blobovniczatree.NewMigrationConfig(sRead.depth, sRead.width, sRead.leafWidth)
|
||||
if blobovniczatree.MigrationRequired(currentCfg, targetCfg) {
|
||||
|
||||
} else {
|
||||
ss = c.appendBlobovniczaWithConfigValues(ss, sRead, shCfg)
|
||||
}
|
||||
return ss
|
||||
}
|
||||
|
||||
func (c *cfg) appendBlobovniczaWithConfigValues(ss []blobstor.SubStorage, sRead subStorageCfg, shCfg shardCfg) []blobstor.SubStorage {
|
||||
blobTreeOpts := []blobovniczatree.Option{
|
||||
blobovniczatree.WithRootPath(sRead.path),
|
||||
blobovniczatree.WithPermissions(sRead.perm),
|
||||
blobovniczatree.WithBlobovniczaSize(sRead.size),
|
||||
blobovniczatree.WithBlobovniczaShallowDepth(sRead.depth),
|
||||
blobovniczatree.WithBlobovniczaShallowWidth(sRead.width),
|
||||
blobovniczatree.WithBlobovniczaLeafWidth(sRead.leafWidth),
|
||||
blobovniczatree.WithOpenedCacheSize(sRead.openedCacheSize),
|
||||
blobovniczatree.WithLogger(c.log),
|
||||
}
|
||||
|
||||
if c.metricsCollector != nil {
|
||||
blobTreeOpts = append(blobTreeOpts,
|
||||
blobovniczatree.WithMetrics(
|
||||
lsmetrics.NewBlobovniczaTreeMetrics(sRead.path, c.metricsCollector.BlobobvnizcaTreeMetrics()),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
return append(ss, blobstor.SubStorage{
|
||||
Storage: blobovniczatree.NewBlobovniczaTree(blobTreeOpts...),
|
||||
Policy: func(_ *objectSDK.Object, data []byte) bool {
|
||||
return uint64(len(data)) < shCfg.smallSizeObjectLimit
|
||||
},
|
||||
SupportsStorageID: true,
|
||||
})
|
||||
}
|
||||
|
||||
func (c *cfg) getShardOpts(shCfg shardCfg) shardOptsWithID {
|
||||
writeCacheOpts := c.getWriteCacheOpts(shCfg)
|
||||
piloramaOpts := c.getPiloramaOpts(shCfg)
|
||||
|
|
|
@ -512,4 +512,5 @@ const (
|
|||
RuntimeSoftMemoryDefinedWithGOMEMLIMIT = "soft runtime memory defined with GOMEMLIMIT environment variable, config value skipped"
|
||||
FailedToCountWritecacheItems = "failed to count writecache items"
|
||||
AttemtToCloseAlreadyClosedBlobovnicza = "attempt to close an already closed blobovnicza"
|
||||
FailedToReadMigrationConfig = "failed to read migration config"
|
||||
)
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var errInvalidStructureError = errors.New("blobovnicza has invalid structure")
|
||||
|
@ -50,6 +51,19 @@ func MigrationRequired(origin, target MigrationConfig) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
func MigrationPath(cfg MigrationConfig, originalPath string) string {
|
||||
dir := filepath.Base(originalPath)
|
||||
var suffix strings.Builder
|
||||
suffix.WriteString(dir)
|
||||
suffix.WriteString("_0_") //version
|
||||
suffix.WriteString(strconv.FormatUint(cfg.Depth, 10))
|
||||
suffix.WriteString("_")
|
||||
suffix.WriteString(strconv.FormatUint(cfg.Width, 10))
|
||||
suffix.WriteString("_")
|
||||
suffix.WriteString(strconv.FormatUint(cfg.LeafWidth, 10))
|
||||
return filepath.Join(filepath.Dir(originalPath), suffix.String())
|
||||
}
|
||||
|
||||
func ReadFromRootPath(path string) (MigrationConfig, error) {
|
||||
var res MigrationConfig
|
||||
if err := readConfigDFS(path, 0, &res); err != nil {
|
||||
|
|
Loading…
Add table
Reference in a new issue