2020-12-02 23:45:25 +00:00
|
|
|
package getsvc
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2021-05-18 08:12:51 +00:00
|
|
|
"errors"
|
2020-12-02 23:45:25 +00:00
|
|
|
|
2021-09-28 04:46:10 +00:00
|
|
|
"github.com/nspcc-dev/neofs-node/pkg/core/client"
|
2022-03-17 08:03:58 +00:00
|
|
|
apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status"
|
2021-11-10 07:08:33 +00:00
|
|
|
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
|
2020-12-02 23:45:25 +00:00
|
|
|
"go.uber.org/zap"
|
|
|
|
)
|
|
|
|
|
2021-09-28 04:46:10 +00:00
|
|
|
func (exec *execCtx) processNode(ctx context.Context, info client.NodeInfo) bool {
|
2021-06-22 12:08:17 +00:00
|
|
|
exec.log.Debug("processing node...")
|
2020-12-02 23:45:25 +00:00
|
|
|
|
2021-09-28 04:46:10 +00:00
|
|
|
client, ok := exec.remoteClient(info)
|
2020-12-02 23:45:25 +00:00
|
|
|
if !ok {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2021-09-28 04:46:10 +00:00
|
|
|
obj, err := client.getObject(exec, info)
|
2020-12-02 23:45:25 +00:00
|
|
|
|
|
|
|
var errSplitInfo *objectSDK.SplitInfoError
|
2022-03-17 08:03:58 +00:00
|
|
|
var errRemoved *apistatus.ObjectAlreadyRemoved
|
2020-12-02 23:45:25 +00:00
|
|
|
|
|
|
|
switch {
|
|
|
|
default:
|
2022-03-17 08:03:58 +00:00
|
|
|
var errNotFound apistatus.ObjectNotFound
|
|
|
|
|
2020-12-02 23:45:25 +00:00
|
|
|
exec.status = statusUndefined
|
2022-03-17 08:03:58 +00:00
|
|
|
exec.err = errNotFound
|
2020-12-02 23:45:25 +00:00
|
|
|
|
2021-06-22 12:08:17 +00:00
|
|
|
exec.log.Debug("remote call failed",
|
2020-12-02 23:45:25 +00:00
|
|
|
zap.String("error", err.Error()),
|
|
|
|
)
|
|
|
|
case err == nil:
|
|
|
|
exec.status = statusOK
|
|
|
|
exec.err = nil
|
2022-03-03 14:19:05 +00:00
|
|
|
exec.collectedObject = obj
|
2020-12-02 23:45:25 +00:00
|
|
|
exec.writeCollectedObject()
|
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)
|
|
|
|
}
|
|
|
|
|
|
|
|
return exec.status != statusUndefined
|
|
|
|
}
|