2020-12-02 23:45:25 +00:00
|
|
|
package getsvc
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2023-04-12 14:35:10 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
|
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"
|
|
|
|
)
|
|
|
|
|
2023-04-24 09:09:43 +00:00
|
|
|
func (r *request) executeOnContainer(ctx context.Context) {
|
|
|
|
if r.isLocal() {
|
|
|
|
r.log.Debug(logs.GetReturnResultDirectly)
|
2020-12-02 23:45:25 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2023-04-24 09:09:43 +00:00
|
|
|
lookupDepth := r.netmapLookupDepth()
|
2020-12-02 23:45:25 +00:00
|
|
|
|
2023-04-24 09:09:43 +00:00
|
|
|
r.log.Debug(logs.TryingToExecuteInContainer,
|
2021-01-12 14:55:02 +00:00
|
|
|
zap.Uint64("netmap lookup depth", lookupDepth),
|
|
|
|
)
|
|
|
|
|
|
|
|
// initialize epoch number
|
2023-04-24 09:09:43 +00:00
|
|
|
ok := r.initEpoch()
|
2020-12-02 23:45:25 +00:00
|
|
|
if !ok {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2024-09-23 12:07:10 +00:00
|
|
|
localStatus := r.status
|
|
|
|
|
2021-01-12 14:55:02 +00:00
|
|
|
for {
|
2024-09-23 12:07:10 +00:00
|
|
|
if r.processCurrentEpoch(ctx, localStatus) {
|
2021-01-12 14:55:02 +00:00
|
|
|
break
|
|
|
|
}
|
|
|
|
|
|
|
|
// check the maximum depth has been reached
|
|
|
|
if lookupDepth == 0 {
|
|
|
|
break
|
|
|
|
}
|
|
|
|
|
|
|
|
lookupDepth--
|
|
|
|
|
|
|
|
// go to the previous epoch
|
2023-04-24 09:09:43 +00:00
|
|
|
r.curProcEpoch--
|
2021-01-12 14:55:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-09-23 12:07:10 +00:00
|
|
|
func (r *request) processCurrentEpoch(ctx context.Context, localStatus int) bool {
|
2023-04-24 09:09:43 +00:00
|
|
|
r.log.Debug(logs.ProcessEpoch,
|
|
|
|
zap.Uint64("number", r.curProcEpoch),
|
2021-01-12 14:55:02 +00:00
|
|
|
)
|
|
|
|
|
2023-04-24 09:09:43 +00:00
|
|
|
traverser, ok := r.generateTraverser(r.address())
|
2021-01-12 14:55:02 +00:00
|
|
|
if !ok {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2023-03-31 11:49:40 +00:00
|
|
|
ctx, cancel := context.WithCancel(ctx)
|
2020-12-02 23:45:25 +00:00
|
|
|
defer cancel()
|
|
|
|
|
2024-09-23 12:07:10 +00:00
|
|
|
if localStatus == statusEC { // possible only for raw == true and local == false
|
|
|
|
r.status = statusEC
|
|
|
|
} else {
|
|
|
|
r.status = statusUndefined
|
|
|
|
}
|
2020-12-02 23:45:25 +00:00
|
|
|
|
|
|
|
for {
|
|
|
|
addrs := traverser.Next()
|
|
|
|
if len(addrs) == 0 {
|
2023-04-24 09:09:43 +00:00
|
|
|
r.log.Debug(logs.NoMoreNodesAbortPlacementIteration)
|
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():
|
2023-04-24 09:09:43 +00:00
|
|
|
r.log.Debug(logs.InterruptPlacementIterationByContext,
|
2023-04-24 10:11:44 +00:00
|
|
|
zap.Error(ctx.Err()),
|
2020-12-02 23:45:25 +00:00
|
|
|
)
|
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
|
|
|
|
2023-04-24 09:09:43 +00:00
|
|
|
if r.processNode(ctx, info) {
|
|
|
|
r.log.Debug(logs.GetCompletingTheOperation)
|
2021-01-12 14:55:02 +00:00
|
|
|
return true
|
2020-12-02 23:45:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|