2024-05-16 09:26:49 +00:00
|
|
|
package replicator
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"errors"
|
|
|
|
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
|
2024-10-01 12:27:06 +00:00
|
|
|
containerCore "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/container"
|
2024-05-16 09:26:49 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/engine"
|
|
|
|
tracingPkg "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/tracing"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-observability/tracing"
|
|
|
|
"go.opentelemetry.io/otel/attribute"
|
|
|
|
"go.opentelemetry.io/otel/trace"
|
|
|
|
"go.uber.org/zap"
|
|
|
|
)
|
|
|
|
|
|
|
|
var errObjectNotDefined = errors.New("object is not defined")
|
|
|
|
|
|
|
|
func (p *Replicator) HandleLocalPutTask(ctx context.Context, task Task) {
|
|
|
|
p.metrics.IncInFlightRequest()
|
|
|
|
defer p.metrics.DecInFlightRequest()
|
|
|
|
defer func() {
|
2024-10-21 07:22:54 +00:00
|
|
|
p.log.Debug(ctx, logs.ReplicatorFinishWork, zap.String("type", "pull"))
|
2024-05-16 09:26:49 +00:00
|
|
|
}()
|
|
|
|
|
|
|
|
ctx, span := tracing.StartSpanFromContext(ctx, "Replicator.HandleLocalPutTask",
|
|
|
|
trace.WithAttributes(
|
|
|
|
attribute.Stringer("address", task.Addr),
|
|
|
|
attribute.Int("nodes_count", len(task.Nodes)),
|
|
|
|
))
|
|
|
|
defer span.End()
|
|
|
|
|
|
|
|
if task.Obj == nil {
|
2024-10-21 07:22:54 +00:00
|
|
|
p.log.Error(ctx, logs.ReplicatorCouldNotPutObjectToLocalStorage,
|
2024-05-16 09:26:49 +00:00
|
|
|
zap.Stringer("object", task.Addr),
|
|
|
|
zap.Error(errObjectNotDefined),
|
|
|
|
zap.String("trace_id", tracingPkg.GetTraceID(ctx)))
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2024-10-01 12:27:06 +00:00
|
|
|
err := engine.Put(ctx, p.localStorage, task.Obj, containerCore.IsIndexedContainer(task.Container))
|
2024-05-16 09:26:49 +00:00
|
|
|
if err != nil {
|
2024-10-21 07:22:54 +00:00
|
|
|
p.log.Error(ctx, logs.ReplicatorCouldNotPutObjectToLocalStorage,
|
2024-05-16 09:26:49 +00:00
|
|
|
zap.Stringer("object", task.Addr),
|
|
|
|
zap.Error(err),
|
|
|
|
zap.String("trace_id", tracingPkg.GetTraceID(ctx)))
|
|
|
|
}
|
|
|
|
}
|