2020-12-02 23:45:25 +00:00
|
|
|
package getsvc
|
|
|
|
|
|
|
|
import (
|
2023-03-31 11:49:40 +00:00
|
|
|
"context"
|
2021-05-18 08:12:51 +00:00
|
|
|
"errors"
|
|
|
|
|
2023-03-13 11:37:35 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/pkg/tracing"
|
2023-04-12 14:35:10 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
|
2023-03-07 13:38:26 +00:00
|
|
|
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
|
|
|
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
2020-12-02 23:45:25 +00:00
|
|
|
"go.uber.org/zap"
|
|
|
|
)
|
|
|
|
|
2023-03-31 11:49:40 +00:00
|
|
|
func (exec *execCtx) executeLocal(ctx context.Context) {
|
2023-03-13 11:37:35 +00:00
|
|
|
ctx, span := tracing.StartSpanFromContext(ctx, "getService.executeLocal")
|
|
|
|
defer func() {
|
|
|
|
span.End()
|
|
|
|
}()
|
|
|
|
|
2020-12-02 23:45:25 +00:00
|
|
|
var err error
|
|
|
|
|
2023-04-20 10:57:45 +00:00
|
|
|
exec.collectedObject, err = exec.get(ctx)
|
2020-12-02 23:45:25 +00:00
|
|
|
|
|
|
|
var errSplitInfo *objectSDK.SplitInfoError
|
2022-03-17 08:03:58 +00:00
|
|
|
var errRemoved apistatus.ObjectAlreadyRemoved
|
2022-06-29 17:33:48 +00:00
|
|
|
var errOutOfRange apistatus.ObjectOutOfRange
|
2020-12-02 23:45:25 +00:00
|
|
|
|
|
|
|
switch {
|
|
|
|
default:
|
|
|
|
exec.status = statusUndefined
|
|
|
|
exec.err = err
|
|
|
|
|
2023-04-12 14:35:10 +00:00
|
|
|
exec.log.Debug(logs.GetLocalGetFailed,
|
2020-12-02 23:45:25 +00:00
|
|
|
zap.String("error", err.Error()),
|
|
|
|
)
|
|
|
|
case err == nil:
|
|
|
|
exec.status = statusOK
|
|
|
|
exec.err = nil
|
2023-03-31 11:49:40 +00:00
|
|
|
exec.writeCollectedObject(ctx)
|
2022-03-17 08:03:58 +00:00
|
|
|
case errors.As(err, &errRemoved):
|
2020-12-02 23:45:25 +00:00
|
|
|
exec.status = statusINHUMED
|
2022-03-17 08:03:58 +00:00
|
|
|
exec.err = errRemoved
|
2020-12-02 23:45:25 +00:00
|
|
|
case errors.As(err, &errSplitInfo):
|
|
|
|
exec.status = statusVIRTUAL
|
|
|
|
mergeSplitInfo(exec.splitInfo(), errSplitInfo.SplitInfo())
|
|
|
|
exec.err = objectSDK.NewSplitInfoError(exec.infoSplit)
|
2022-06-29 17:33:48 +00:00
|
|
|
case errors.As(err, &errOutOfRange):
|
2020-12-07 17:49:47 +00:00
|
|
|
exec.status = statusOutOfRange
|
2022-06-29 17:33:48 +00:00
|
|
|
exec.err = errOutOfRange
|
2020-12-02 23:45:25 +00:00
|
|
|
}
|
|
|
|
}
|
2023-04-20 10:57:45 +00:00
|
|
|
|
|
|
|
func (exec *execCtx) get(ctx context.Context) (*objectSDK.Object, error) {
|
|
|
|
if exec.headOnly() {
|
|
|
|
return exec.svc.localStorage.Head(ctx, exec.address(), exec.isRaw())
|
|
|
|
}
|
|
|
|
if rng := exec.ctxRange(); rng != nil {
|
|
|
|
return exec.svc.localStorage.Range(ctx, exec.address(), rng)
|
|
|
|
}
|
|
|
|
return exec.svc.localStorage.Get(ctx, exec.address())
|
|
|
|
}
|