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-04-12 14:35:10 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
|
2024-04-22 06:43:42 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/util"
|
2023-05-31 09:24:04 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-observability/tracing"
|
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-04-24 09:09:43 +00:00
|
|
|
func (r *request) 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-24 09:09:43 +00:00
|
|
|
r.collectedObject, err = r.get(ctx)
|
2020-12-02 23:45:25 +00:00
|
|
|
|
|
|
|
var errSplitInfo *objectSDK.SplitInfoError
|
2024-04-22 06:43:42 +00:00
|
|
|
var errECInfo *objectSDK.ECInfoError
|
2023-08-04 11:14:07 +00:00
|
|
|
var errRemoved *apistatus.ObjectAlreadyRemoved
|
|
|
|
var errOutOfRange *apistatus.ObjectOutOfRange
|
2020-12-02 23:45:25 +00:00
|
|
|
|
|
|
|
switch {
|
|
|
|
default:
|
2023-04-24 09:09:43 +00:00
|
|
|
r.status = statusUndefined
|
|
|
|
r.err = err
|
2020-12-02 23:45:25 +00:00
|
|
|
|
2023-04-24 10:11:44 +00:00
|
|
|
r.log.Debug(logs.GetLocalGetFailed, zap.Error(err))
|
2020-12-02 23:45:25 +00:00
|
|
|
case err == nil:
|
2023-04-24 09:09:43 +00:00
|
|
|
r.status = statusOK
|
|
|
|
r.err = nil
|
|
|
|
r.writeCollectedObject(ctx)
|
2022-03-17 08:03:58 +00:00
|
|
|
case errors.As(err, &errRemoved):
|
2023-04-24 09:09:43 +00:00
|
|
|
r.status = statusINHUMED
|
|
|
|
r.err = errRemoved
|
2020-12-02 23:45:25 +00:00
|
|
|
case errors.As(err, &errSplitInfo):
|
2023-04-24 09:09:43 +00:00
|
|
|
r.status = statusVIRTUAL
|
|
|
|
mergeSplitInfo(r.splitInfo(), errSplitInfo.SplitInfo())
|
|
|
|
r.err = objectSDK.NewSplitInfoError(r.infoSplit)
|
2024-04-22 06:43:42 +00:00
|
|
|
case errors.As(err, &errECInfo):
|
|
|
|
r.status = statusEC
|
|
|
|
util.MergeECInfo(errECInfo.ECInfo(), r.infoEC)
|
|
|
|
r.err = objectSDK.NewECInfoError(r.infoEC)
|
2022-06-29 17:33:48 +00:00
|
|
|
case errors.As(err, &errOutOfRange):
|
2023-04-24 09:09:43 +00:00
|
|
|
r.status = statusOutOfRange
|
|
|
|
r.err = errOutOfRange
|
2020-12-02 23:45:25 +00:00
|
|
|
}
|
|
|
|
}
|
2023-04-20 10:57:45 +00:00
|
|
|
|
2023-04-24 09:09:43 +00:00
|
|
|
func (r *request) get(ctx context.Context) (*objectSDK.Object, error) {
|
|
|
|
if r.headOnly() {
|
|
|
|
return r.localStorage.Head(ctx, r.address(), r.isRaw())
|
2023-04-20 10:57:45 +00:00
|
|
|
}
|
2023-04-24 09:09:43 +00:00
|
|
|
if rng := r.ctxRange(); rng != nil {
|
|
|
|
return r.localStorage.Range(ctx, r.address(), rng)
|
2023-04-20 10:57:45 +00:00
|
|
|
}
|
2023-04-24 09:09:43 +00:00
|
|
|
return r.localStorage.Get(ctx, r.address())
|
2023-04-20 10:57:45 +00:00
|
|
|
}
|