2020-12-02 23:45:25 +00:00
|
|
|
package getsvc
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2023-03-07 13:38:26 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/client"
|
2020-12-02 23:45:25 +00:00
|
|
|
"go.uber.org/zap"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (exec *execCtx) executeOnContainer() {
|
2022-12-30 11:00:01 +00:00
|
|
|
if exec.prm.common.LocalOnly() {
|
2020-12-02 23:45:25 +00:00
|
|
|
exec.log.Debug("return result directly")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-12-30 11:00:01 +00:00
|
|
|
lookupDepth := exec.prm.common.NetmapLookupDepth()
|
2020-12-02 23:45:25 +00:00
|
|
|
|
2021-01-12 14:55:02 +00:00
|
|
|
exec.log.Debug("trying to execute in container...",
|
|
|
|
zap.Uint64("netmap lookup depth", lookupDepth),
|
|
|
|
)
|
|
|
|
|
|
|
|
// initialize epoch number
|
|
|
|
ok := exec.initEpoch()
|
2020-12-02 23:45:25 +00:00
|
|
|
if !ok {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-01-12 14:55:02 +00:00
|
|
|
for {
|
|
|
|
if exec.processCurrentEpoch() {
|
|
|
|
break
|
|
|
|
}
|
|
|
|
|
|
|
|
// check the maximum depth has been reached
|
|
|
|
if lookupDepth == 0 {
|
|
|
|
break
|
|
|
|
}
|
|
|
|
|
|
|
|
lookupDepth--
|
|
|
|
|
|
|
|
// go to the previous epoch
|
|
|
|
exec.curProcEpoch--
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (exec *execCtx) processCurrentEpoch() bool {
|
|
|
|
exec.log.Debug("process epoch",
|
|
|
|
zap.Uint64("number", exec.curProcEpoch),
|
|
|
|
)
|
|
|
|
|
2022-12-30 11:00:01 +00:00
|
|
|
traverser, ok := exec.generateTraverser(exec.prm.addr)
|
2021-01-12 14:55:02 +00:00
|
|
|
if !ok {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2022-12-30 11:00:01 +00:00
|
|
|
ctx, cancel := context.WithCancel(exec.ctx)
|
2020-12-02 23:45:25 +00:00
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
exec.status = statusUndefined
|
|
|
|
|
|
|
|
for {
|
|
|
|
addrs := traverser.Next()
|
|
|
|
if len(addrs) == 0 {
|
|
|
|
exec.log.Debug("no more nodes, abort placement iteration")
|
2021-01-12 14:55:02 +00:00
|
|
|
|
|
|
|
return false
|
2020-12-02 23:45:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for i := range addrs {
|
|
|
|
select {
|
|
|
|
case <-ctx.Done():
|
|
|
|
exec.log.Debug("interrupt placement iteration by context",
|
|
|
|
zap.String("error", ctx.Err().Error()),
|
|
|
|
)
|
2021-01-12 14:55:02 +00:00
|
|
|
|
|
|
|
return true
|
2020-12-02 23:45:25 +00:00
|
|
|
default:
|
|
|
|
}
|
|
|
|
|
2022-02-07 13:34:02 +00:00
|
|
|
// TODO: #1142 consider parallel execution
|
|
|
|
// TODO: #1142 consider optimization: if status == SPLIT we can continue until
|
2020-12-02 23:45:25 +00:00
|
|
|
// we reach the best result - split info with linking object ID.
|
2021-09-28 04:46:10 +00:00
|
|
|
var info client.NodeInfo
|
|
|
|
|
2021-09-28 05:32:30 +00:00
|
|
|
client.NodeInfoFromNetmapElement(&info, addrs[i])
|
2021-09-28 04:46:10 +00:00
|
|
|
|
|
|
|
if exec.processNode(ctx, info) {
|
2020-12-02 23:45:25 +00:00
|
|
|
exec.log.Debug("completing the operation")
|
2021-01-12 14:55:02 +00:00
|
|
|
return true
|
2020-12-02 23:45:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|