replica

package
v1.36.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 23, 2026 License: BSD-3-Clause Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// RequestKey is used to marshalling request IDs
	RequestKey       = "request_id"
	SchemaVersionKey = "schema_version"
)
View Source
const (
	StatusOK            = 0
	StatusClassNotFound = iota + 200
	StatusShardNotFound
	StatusNotFound
	StatusAlreadyExisted
	StatusNotReady
	StatusConflict = iota + 300
	StatusPreconditionFailed
	StatusReadOnly
	StatusObjectNotFound
)

Variables

View Source
var (
	// MsgCLevel consistency level cannot be achieved
	MsgCLevel = "cannot achieve consistency level"

	ErrReplicas = errors.New("cannot reach enough replicas")
	ErrRepair   = errors.New("read repair error")
	ErrRead     = errors.New("read error")

	ErrNoDiffFound = errors.New("no diff found")
)
View Source
var (
	ErrConflictExistOrDeleted = errors.New("conflict: object has been deleted on another replica")

	// ErrConflictObjectChanged object changed since last time and cannot be repaired
	ErrConflictObjectChanged = errors.New("source object changed during repair")
)

Functions

func NewReadCoordinator added in v1.36.0

func NewReadCoordinator[T any](router types.Router,
	metrics *Metrics,
	className, shard, deletionStrategy string,
	log logrus.FieldLogger,
) *coordinator[T, any]

NewReadCoordinator used by the Finder to read objects from replicas

func NewWriteCoordinator added in v1.36.0

func NewWriteCoordinator[T, R any](client Client,
	router types.Router,
	metrics *Metrics,
	className, shard, requestID string,
	l logrus.FieldLogger,
) *coordinator[T, R]

NewWriteCoordinator used by the replicator to write objects to replicas

func StatusText added in v1.31.1

func StatusText(code StatusCode) string

StatusText returns a text for the status code. It returns the empty string if the code is unknown.

func ValidateConfig

func ValidateConfig(class *models.Class, globalCfg replication.GlobalConfig) error

func ValidateConfigUpdate

func ValidateConfigUpdate(old, updated *models.Class, nodeCounter nodeCounter) error

Types

type BatchReply added in v1.31.1

type BatchReply struct {
	// Sender hostname of the Sender
	Sender string
	// IsDigest is this reply from a digest read?
	IsDigest bool
	// FullData returned from a full read request
	FullData []Replica
	// DigestData returned from a digest read request
	DigestData []types.RepairResponse
}

BatchReply is a container of the batch received from a replica The returned data may result from a full or digest read request

func (BatchReply) UpdateTimeAt added in v1.31.1

func (r BatchReply) UpdateTimeAt(idx int) int64

UpdateTimeAt gets update time from reply

type BoolTuple added in v1.31.1

type BoolTuple tuple[types.RepairResponse]

type Client

type Client interface {
	RClient
	WClient
}

Client is used to read and write objects on replicas

type DeleteBatchResponse

type DeleteBatchResponse struct {
	Batch []UUID2Error `json:"batch,omitempty"`
}

DeleteBatchResponse represents the response returned by DeleteObjects

func (*DeleteBatchResponse) FirstError

func (r *DeleteBatchResponse) FirstError() error

FirstError returns the first found error

type DigestObjectsInRangeReq added in v1.28.5

type DigestObjectsInRangeReq struct {
	InitialUUID strfmt.UUID `json:"initialUUID,omitempty"`
	FinalUUID   strfmt.UUID `json:"finalUUID,omitempty"`
	Limit       int         `json:"limit,omitempty"`
}

type DigestObjectsInRangeResp added in v1.28.5

type DigestObjectsInRangeResp struct {
	Digests []types.RepairResponse `json:"digests,omitempty"`
}

type Error

type Error struct {
	Code StatusCode `json:"code"`
	Msg  string     `json:"msg,omitempty"`
	Err  error      `json:"-"`
}

Error reports error happening during replication

func NewError

func NewError(code StatusCode, msg string) *Error

NewError create new replication error

func (*Error) Clone

func (e *Error) Clone() *Error

func (*Error) Empty

func (e *Error) Empty() bool

Empty checks whether e is an empty error which equivalent to e == nil

func (*Error) Error

func (e *Error) Error() string

func (*Error) IsStatusCode

func (e *Error) IsStatusCode(sc StatusCode) bool

func (*Error) Timeout

func (e *Error) Timeout() bool

func (*Error) Unwrap

func (e *Error) Unwrap() error

Unwrap underlying error

type Finder

type Finder struct {
	// contains filtered or unexported fields
}

Finder finds replicated objects

func NewFinder

func NewFinder(className string,
	router types.Router,
	nodeResolver cluster.NodeResolver,
	nodeName string,
	client RClient,
	metrics *Metrics,
	l logrus.FieldLogger,
	getDeletionStrategy func() string,
) *Finder

NewFinder constructs a new finder instance

func (*Finder) CheckConsistency added in v1.19.0

func (f *Finder) CheckConsistency(ctx context.Context,
	l types.ConsistencyLevel, xs []*storobj.Object,
) error

CheckConsistency for objects belonging to different physical shards.

For each x in xs the fields BelongsToNode and BelongsToShard must be set non empty

func (*Finder) CollectShardDifferences added in v1.26.0

func (f *Finder) CollectShardDifferences(ctx context.Context,
	shardName string, ht hashtree.AggregatedHashTree, diffTimeoutPerNode time.Duration,
	targetNodeOverrides []additional.AsyncReplicationTargetNodeOverride,
) (diffReader *ShardDifferenceReader, err error)

CollectShardDifferences collects the differences between the local node and the target nodes. It returns a ShardDifferenceReader that contains the differences and the target node name/address. If no differences are found, it returns ErrNoDiffFound. When ErrNoDiffFound is returned as the error, the returned *ShardDifferenceReader may exist and have some (but not all) of its fields set.

func (*Finder) DigestObjectsInRange added in v1.28.5

func (f *Finder) DigestObjectsInRange(ctx context.Context,
	shardName string, host string, initialUUID, finalUUID strfmt.UUID, limit int,
) (ds []types.RepairResponse, err error)

func (*Finder) Exists added in v1.18.0

func (f *Finder) Exists(ctx context.Context,
	l types.ConsistencyLevel,
	shard string,
	id strfmt.UUID,
) (bool, error)

Exists checks if an object exists which satisfies the giving consistency

func (*Finder) FindUUIDs added in v1.24.18

func (f *Finder) FindUUIDs(ctx context.Context, className, shard string,
	filters *filters.LocalFilter, l types.ConsistencyLevel, limit int,
) (uuids []strfmt.UUID, err error)

func (*Finder) GetOne added in v1.18.0

GetOne gets object which satisfies the giving consistency

func (*Finder) LocalNodeName added in v1.31.0

func (f *Finder) LocalNodeName() string

func (*Finder) NodeObject

func (f *Finder) NodeObject(ctx context.Context,
	nodeName,
	shard string,
	id strfmt.UUID,
	props search.SelectProperties, adds additional.Properties,
) (*storobj.Object, error)

NodeObject gets object from a specific node. it is used mainly for debugging purposes

func (*Finder) Overwrite added in v1.26.0

func (f *Finder) Overwrite(ctx context.Context,
	host, index, shard string, xs []*objects.VObject,
) ([]types.RepairResponse, error)

Overwrite specified object with most recent contents

type FinderClient added in v1.31.1

type FinderClient struct {
	// contains filtered or unexported fields
}

FinderClient extends RClient with consistency checks

func NewFinderClient added in v1.36.0

func NewFinderClient(cl RClient) FinderClient

func (FinderClient) DigestObjectsInRange added in v1.31.1

func (fc FinderClient) DigestObjectsInRange(ctx context.Context,
	host, index, shard string,
	initialUUID, finalUUID strfmt.UUID, limit int,
) ([]types.RepairResponse, error)

func (FinderClient) DigestReads added in v1.31.1

func (fc FinderClient) DigestReads(ctx context.Context,
	host, index, shard string,
	ids []strfmt.UUID, numRetries int,
) ([]types.RepairResponse, error)

DigestReads reads digests of all specified objects

func (FinderClient) FindUUIDs added in v1.31.1

func (fc FinderClient) FindUUIDs(ctx context.Context,
	host, class, shard string, filters *filters.LocalFilter, limit int,
) ([]strfmt.UUID, error)

func (FinderClient) FullRead added in v1.31.1

func (fc FinderClient) FullRead(ctx context.Context,
	host, index, shard string,
	id strfmt.UUID,
	props search.SelectProperties,
	additional additional.Properties,
	numRetries int,
) (Replica, error)

FullRead reads full object

func (FinderClient) FullReads added in v1.31.1

func (fc FinderClient) FullReads(ctx context.Context,
	host, index, shard string,
	ids []strfmt.UUID,
) ([]Replica, error)

FullReads read full objects

func (FinderClient) HashTreeLevel added in v1.31.1

func (fc FinderClient) HashTreeLevel(ctx context.Context,
	host, index, shard string, level int, discriminant *hashtree.Bitset,
) (digests []hashtree.Digest, err error)

func (FinderClient) Overwrite added in v1.31.1

func (fc FinderClient) Overwrite(ctx context.Context,
	host, index, shard string,
	xs []*objects.VObject,
) ([]types.RepairResponse, error)

Overwrite specified object with most recent contents

type IndexedBatch added in v1.31.1

type IndexedBatch struct {
	Data []*storobj.Object
	// Index is z-index used to maintain object's order
	Index []int
}

IndexedBatch holds an indexed list of objects

type Metrics added in v1.31.16

type Metrics struct {
	// contains filtered or unexported fields
}

func NewMetrics added in v1.31.16

func NewMetrics(prom *monitoring.PrometheusMetrics) (*Metrics, error)

func (*Metrics) IncReadRepairCount added in v1.31.16

func (m *Metrics) IncReadRepairCount()

func (*Metrics) IncReadRepairFailure added in v1.31.16

func (m *Metrics) IncReadRepairFailure()

func (*Metrics) IncReadsFailed added in v1.31.16

func (m *Metrics) IncReadsFailed()

func (*Metrics) IncReadsSucceedAll added in v1.31.16

func (m *Metrics) IncReadsSucceedAll()

func (*Metrics) IncReadsSucceedSome added in v1.31.16

func (m *Metrics) IncReadsSucceedSome()

func (*Metrics) IncWritesFailed added in v1.31.16

func (m *Metrics) IncWritesFailed()

func (*Metrics) IncWritesSucceedAll added in v1.31.16

func (m *Metrics) IncWritesSucceedAll()

func (*Metrics) IncWritesSucceedSome added in v1.31.16

func (m *Metrics) IncWritesSucceedSome()

func (*Metrics) ObserveReadDuration added in v1.31.16

func (m *Metrics) ObserveReadDuration(d time.Duration)

func (*Metrics) ObserveReadRepairDuration added in v1.31.16

func (m *Metrics) ObserveReadRepairDuration(d time.Duration)

func (*Metrics) ObserveWriteDuration added in v1.31.16

func (m *Metrics) ObserveWriteDuration(d time.Duration)

type MockRClient added in v1.36.0

type MockRClient struct {
	mock.Mock
}

MockRClient is an autogenerated mock type for the RClient type

func NewMockRClient added in v1.36.0

func NewMockRClient(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockRClient

NewMockRClient creates a new instance of MockRClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockRClient) DigestObjects added in v1.36.0

func (_m *MockRClient) DigestObjects(ctx context.Context, host string, index string, shard string, ids []strfmt.UUID, numRetries int) ([]types.RepairResponse, error)

DigestObjects provides a mock function with given fields: ctx, host, index, shard, ids, numRetries

func (*MockRClient) DigestObjectsInRange added in v1.36.0

func (_m *MockRClient) DigestObjectsInRange(ctx context.Context, host string, index string, shard string, initialUUID strfmt.UUID, finalUUID strfmt.UUID, limit int) ([]types.RepairResponse, error)

DigestObjectsInRange provides a mock function with given fields: ctx, host, index, shard, initialUUID, finalUUID, limit

func (*MockRClient) EXPECT added in v1.36.0

func (_m *MockRClient) EXPECT() *MockRClient_Expecter

func (*MockRClient) FetchObject added in v1.36.0

func (_m *MockRClient) FetchObject(_a0 context.Context, host string, index string, shard string, id strfmt.UUID, props search.SelectProperties, _a6 additional.Properties, numRetries int) (Replica, error)

FetchObject provides a mock function with given fields: _a0, host, index, shard, id, props, _a6, numRetries

func (*MockRClient) FetchObjects added in v1.36.0

func (_m *MockRClient) FetchObjects(_a0 context.Context, host string, index string, shard string, ids []strfmt.UUID) ([]Replica, error)

FetchObjects provides a mock function with given fields: _a0, host, index, shard, ids

func (*MockRClient) FindUUIDs added in v1.36.0

func (_m *MockRClient) FindUUIDs(ctx context.Context, host string, index string, shard string, _a4 *filters.LocalFilter, limit int) ([]strfmt.UUID, error)

FindUUIDs provides a mock function with given fields: ctx, host, index, shard, _a4, limit

func (*MockRClient) HashTreeLevel added in v1.36.0

func (_m *MockRClient) HashTreeLevel(ctx context.Context, host string, index string, shard string, level int, discriminant *hashtree.Bitset) ([]hashtree.Digest, error)

HashTreeLevel provides a mock function with given fields: ctx, host, index, shard, level, discriminant

func (*MockRClient) OverwriteObjects added in v1.36.0

func (_m *MockRClient) OverwriteObjects(_a0 context.Context, host string, index string, shard string, _a4 []*objects.VObject) ([]types.RepairResponse, error)

OverwriteObjects provides a mock function with given fields: _a0, host, index, shard, _a4

type MockRClient_DigestObjectsInRange_Call added in v1.36.0

type MockRClient_DigestObjectsInRange_Call struct {
	*mock.Call
}

MockRClient_DigestObjectsInRange_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DigestObjectsInRange'

func (*MockRClient_DigestObjectsInRange_Call) Return added in v1.36.0

func (*MockRClient_DigestObjectsInRange_Call) Run added in v1.36.0

func (_c *MockRClient_DigestObjectsInRange_Call) Run(run func(ctx context.Context, host string, index string, shard string, initialUUID strfmt.UUID, finalUUID strfmt.UUID, limit int)) *MockRClient_DigestObjectsInRange_Call

func (*MockRClient_DigestObjectsInRange_Call) RunAndReturn added in v1.36.0

type MockRClient_DigestObjects_Call added in v1.36.0

type MockRClient_DigestObjects_Call struct {
	*mock.Call
}

MockRClient_DigestObjects_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DigestObjects'

func (*MockRClient_DigestObjects_Call) Return added in v1.36.0

func (*MockRClient_DigestObjects_Call) Run added in v1.36.0

func (_c *MockRClient_DigestObjects_Call) Run(run func(ctx context.Context, host string, index string, shard string, ids []strfmt.UUID, numRetries int)) *MockRClient_DigestObjects_Call

func (*MockRClient_DigestObjects_Call) RunAndReturn added in v1.36.0

type MockRClient_Expecter added in v1.36.0

type MockRClient_Expecter struct {
	// contains filtered or unexported fields
}

func (*MockRClient_Expecter) DigestObjects added in v1.36.0

func (_e *MockRClient_Expecter) DigestObjects(ctx interface{}, host interface{}, index interface{}, shard interface{}, ids interface{}, numRetries interface{}) *MockRClient_DigestObjects_Call

DigestObjects is a helper method to define mock.On call

  • ctx context.Context
  • host string
  • index string
  • shard string
  • ids []strfmt.UUID
  • numRetries int

func (*MockRClient_Expecter) DigestObjectsInRange added in v1.36.0

func (_e *MockRClient_Expecter) DigestObjectsInRange(ctx interface{}, host interface{}, index interface{}, shard interface{}, initialUUID interface{}, finalUUID interface{}, limit interface{}) *MockRClient_DigestObjectsInRange_Call

DigestObjectsInRange is a helper method to define mock.On call

  • ctx context.Context
  • host string
  • index string
  • shard string
  • initialUUID strfmt.UUID
  • finalUUID strfmt.UUID
  • limit int

func (*MockRClient_Expecter) FetchObject added in v1.36.0

func (_e *MockRClient_Expecter) FetchObject(_a0 interface{}, host interface{}, index interface{}, shard interface{}, id interface{}, props interface{}, _a6 interface{}, numRetries interface{}) *MockRClient_FetchObject_Call

FetchObject is a helper method to define mock.On call

  • _a0 context.Context
  • host string
  • index string
  • shard string
  • id strfmt.UUID
  • props search.SelectProperties
  • _a6 additional.Properties
  • numRetries int

func (*MockRClient_Expecter) FetchObjects added in v1.36.0

func (_e *MockRClient_Expecter) FetchObjects(_a0 interface{}, host interface{}, index interface{}, shard interface{}, ids interface{}) *MockRClient_FetchObjects_Call

FetchObjects is a helper method to define mock.On call

  • _a0 context.Context
  • host string
  • index string
  • shard string
  • ids []strfmt.UUID

func (*MockRClient_Expecter) FindUUIDs added in v1.36.0

func (_e *MockRClient_Expecter) FindUUIDs(ctx interface{}, host interface{}, index interface{}, shard interface{}, _a4 interface{}, limit interface{}) *MockRClient_FindUUIDs_Call

FindUUIDs is a helper method to define mock.On call

  • ctx context.Context
  • host string
  • index string
  • shard string
  • _a4 *filters.LocalFilter
  • limit int

func (*MockRClient_Expecter) HashTreeLevel added in v1.36.0

func (_e *MockRClient_Expecter) HashTreeLevel(ctx interface{}, host interface{}, index interface{}, shard interface{}, level interface{}, discriminant interface{}) *MockRClient_HashTreeLevel_Call

HashTreeLevel is a helper method to define mock.On call

  • ctx context.Context
  • host string
  • index string
  • shard string
  • level int
  • discriminant *hashtree.Bitset

func (*MockRClient_Expecter) OverwriteObjects added in v1.36.0

func (_e *MockRClient_Expecter) OverwriteObjects(_a0 interface{}, host interface{}, index interface{}, shard interface{}, _a4 interface{}) *MockRClient_OverwriteObjects_Call

OverwriteObjects is a helper method to define mock.On call

  • _a0 context.Context
  • host string
  • index string
  • shard string
  • _a4 []*objects.VObject

type MockRClient_FetchObject_Call added in v1.36.0

type MockRClient_FetchObject_Call struct {
	*mock.Call
}

MockRClient_FetchObject_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'FetchObject'

func (*MockRClient_FetchObject_Call) Return added in v1.36.0

func (*MockRClient_FetchObject_Call) Run added in v1.36.0

func (*MockRClient_FetchObject_Call) RunAndReturn added in v1.36.0

type MockRClient_FetchObjects_Call added in v1.36.0

type MockRClient_FetchObjects_Call struct {
	*mock.Call
}

MockRClient_FetchObjects_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'FetchObjects'

func (*MockRClient_FetchObjects_Call) Return added in v1.36.0

func (*MockRClient_FetchObjects_Call) Run added in v1.36.0

func (_c *MockRClient_FetchObjects_Call) Run(run func(_a0 context.Context, host string, index string, shard string, ids []strfmt.UUID)) *MockRClient_FetchObjects_Call

func (*MockRClient_FetchObjects_Call) RunAndReturn added in v1.36.0

type MockRClient_FindUUIDs_Call added in v1.36.0

type MockRClient_FindUUIDs_Call struct {
	*mock.Call
}

MockRClient_FindUUIDs_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'FindUUIDs'

func (*MockRClient_FindUUIDs_Call) Return added in v1.36.0

func (*MockRClient_FindUUIDs_Call) Run added in v1.36.0

func (_c *MockRClient_FindUUIDs_Call) Run(run func(ctx context.Context, host string, index string, shard string, _a4 *filters.LocalFilter, limit int)) *MockRClient_FindUUIDs_Call

func (*MockRClient_FindUUIDs_Call) RunAndReturn added in v1.36.0

type MockRClient_HashTreeLevel_Call added in v1.36.0

type MockRClient_HashTreeLevel_Call struct {
	*mock.Call
}

MockRClient_HashTreeLevel_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'HashTreeLevel'

func (*MockRClient_HashTreeLevel_Call) Return added in v1.36.0

func (*MockRClient_HashTreeLevel_Call) Run added in v1.36.0

func (_c *MockRClient_HashTreeLevel_Call) Run(run func(ctx context.Context, host string, index string, shard string, level int, discriminant *hashtree.Bitset)) *MockRClient_HashTreeLevel_Call

func (*MockRClient_HashTreeLevel_Call) RunAndReturn added in v1.36.0

type MockRClient_OverwriteObjects_Call added in v1.36.0

type MockRClient_OverwriteObjects_Call struct {
	*mock.Call
}

MockRClient_OverwriteObjects_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'OverwriteObjects'

func (*MockRClient_OverwriteObjects_Call) Return added in v1.36.0

func (*MockRClient_OverwriteObjects_Call) Run added in v1.36.0

func (*MockRClient_OverwriteObjects_Call) RunAndReturn added in v1.36.0

type MockWClient added in v1.36.0

type MockWClient struct {
	mock.Mock
}

MockWClient is an autogenerated mock type for the WClient type

func NewMockWClient added in v1.36.0

func NewMockWClient(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockWClient

NewMockWClient creates a new instance of MockWClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockWClient) Abort added in v1.36.0

func (_m *MockWClient) Abort(ctx context.Context, host string, index string, shard string, requestID string) (SimpleResponse, error)

Abort provides a mock function with given fields: ctx, host, index, shard, requestID

func (*MockWClient) AddReferences added in v1.36.0

func (_m *MockWClient) AddReferences(ctx context.Context, host string, index string, shard string, requestID string, refs []objects.BatchReference, schemaVersion uint64) (SimpleResponse, error)

AddReferences provides a mock function with given fields: ctx, host, index, shard, requestID, refs, schemaVersion

func (*MockWClient) Commit added in v1.36.0

func (_m *MockWClient) Commit(ctx context.Context, host string, index string, shard string, requestID string, resp interface{}) error

Commit provides a mock function with given fields: ctx, host, index, shard, requestID, resp

func (*MockWClient) DeleteObject added in v1.36.0

func (_m *MockWClient) DeleteObject(ctx context.Context, host string, index string, shard string, requestID string, id strfmt.UUID, deletionTime time.Time, schemaVersion uint64) (SimpleResponse, error)

DeleteObject provides a mock function with given fields: ctx, host, index, shard, requestID, id, deletionTime, schemaVersion

func (*MockWClient) DeleteObjects added in v1.36.0

func (_m *MockWClient) DeleteObjects(ctx context.Context, host string, index string, shard string, requestID string, uuids []strfmt.UUID, deletionTime time.Time, dryRun bool, schemaVersion uint64) (SimpleResponse, error)

DeleteObjects provides a mock function with given fields: ctx, host, index, shard, requestID, uuids, deletionTime, dryRun, schemaVersion

func (*MockWClient) EXPECT added in v1.36.0

func (_m *MockWClient) EXPECT() *MockWClient_Expecter

func (*MockWClient) MergeObject added in v1.36.0

func (_m *MockWClient) MergeObject(ctx context.Context, host string, index string, shard string, requestID string, mergeDoc *objects.MergeDocument, schemaVersion uint64) (SimpleResponse, error)

MergeObject provides a mock function with given fields: ctx, host, index, shard, requestID, mergeDoc, schemaVersion

func (*MockWClient) PutObject added in v1.36.0

func (_m *MockWClient) PutObject(ctx context.Context, host string, index string, shard string, requestID string, obj *storobj.Object, schemaVersion uint64) (SimpleResponse, error)

PutObject provides a mock function with given fields: ctx, host, index, shard, requestID, obj, schemaVersion

func (*MockWClient) PutObjects added in v1.36.0

func (_m *MockWClient) PutObjects(ctx context.Context, host string, index string, shard string, requestID string, objs []*storobj.Object, schemaVersion uint64) (SimpleResponse, error)

PutObjects provides a mock function with given fields: ctx, host, index, shard, requestID, objs, schemaVersion

type MockWClient_Abort_Call added in v1.36.0

type MockWClient_Abort_Call struct {
	*mock.Call
}

MockWClient_Abort_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Abort'

func (*MockWClient_Abort_Call) Return added in v1.36.0

func (*MockWClient_Abort_Call) Run added in v1.36.0

func (_c *MockWClient_Abort_Call) Run(run func(ctx context.Context, host string, index string, shard string, requestID string)) *MockWClient_Abort_Call

func (*MockWClient_Abort_Call) RunAndReturn added in v1.36.0

type MockWClient_AddReferences_Call added in v1.36.0

type MockWClient_AddReferences_Call struct {
	*mock.Call
}

MockWClient_AddReferences_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddReferences'

func (*MockWClient_AddReferences_Call) Return added in v1.36.0

func (*MockWClient_AddReferences_Call) Run added in v1.36.0

func (_c *MockWClient_AddReferences_Call) Run(run func(ctx context.Context, host string, index string, shard string, requestID string, refs []objects.BatchReference, schemaVersion uint64)) *MockWClient_AddReferences_Call

func (*MockWClient_AddReferences_Call) RunAndReturn added in v1.36.0

type MockWClient_Commit_Call added in v1.36.0

type MockWClient_Commit_Call struct {
	*mock.Call
}

MockWClient_Commit_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Commit'

func (*MockWClient_Commit_Call) Return added in v1.36.0

func (*MockWClient_Commit_Call) Run added in v1.36.0

func (_c *MockWClient_Commit_Call) Run(run func(ctx context.Context, host string, index string, shard string, requestID string, resp interface{})) *MockWClient_Commit_Call

func (*MockWClient_Commit_Call) RunAndReturn added in v1.36.0

func (_c *MockWClient_Commit_Call) RunAndReturn(run func(context.Context, string, string, string, string, interface{}) error) *MockWClient_Commit_Call

type MockWClient_DeleteObject_Call added in v1.36.0

type MockWClient_DeleteObject_Call struct {
	*mock.Call
}

MockWClient_DeleteObject_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteObject'

func (*MockWClient_DeleteObject_Call) Return added in v1.36.0

func (*MockWClient_DeleteObject_Call) Run added in v1.36.0

func (_c *MockWClient_DeleteObject_Call) Run(run func(ctx context.Context, host string, index string, shard string, requestID string, id strfmt.UUID, deletionTime time.Time, schemaVersion uint64)) *MockWClient_DeleteObject_Call

func (*MockWClient_DeleteObject_Call) RunAndReturn added in v1.36.0

type MockWClient_DeleteObjects_Call added in v1.36.0

type MockWClient_DeleteObjects_Call struct {
	*mock.Call
}

MockWClient_DeleteObjects_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteObjects'

func (*MockWClient_DeleteObjects_Call) Return added in v1.36.0

func (*MockWClient_DeleteObjects_Call) Run added in v1.36.0

func (_c *MockWClient_DeleteObjects_Call) Run(run func(ctx context.Context, host string, index string, shard string, requestID string, uuids []strfmt.UUID, deletionTime time.Time, dryRun bool, schemaVersion uint64)) *MockWClient_DeleteObjects_Call

func (*MockWClient_DeleteObjects_Call) RunAndReturn added in v1.36.0

type MockWClient_Expecter added in v1.36.0

type MockWClient_Expecter struct {
	// contains filtered or unexported fields
}

func (*MockWClient_Expecter) Abort added in v1.36.0

func (_e *MockWClient_Expecter) Abort(ctx interface{}, host interface{}, index interface{}, shard interface{}, requestID interface{}) *MockWClient_Abort_Call

Abort is a helper method to define mock.On call

  • ctx context.Context
  • host string
  • index string
  • shard string
  • requestID string

func (*MockWClient_Expecter) AddReferences added in v1.36.0

func (_e *MockWClient_Expecter) AddReferences(ctx interface{}, host interface{}, index interface{}, shard interface{}, requestID interface{}, refs interface{}, schemaVersion interface{}) *MockWClient_AddReferences_Call

AddReferences is a helper method to define mock.On call

  • ctx context.Context
  • host string
  • index string
  • shard string
  • requestID string
  • refs []objects.BatchReference
  • schemaVersion uint64

func (*MockWClient_Expecter) Commit added in v1.36.0

func (_e *MockWClient_Expecter) Commit(ctx interface{}, host interface{}, index interface{}, shard interface{}, requestID interface{}, resp interface{}) *MockWClient_Commit_Call

Commit is a helper method to define mock.On call

  • ctx context.Context
  • host string
  • index string
  • shard string
  • requestID string
  • resp interface{}

func (*MockWClient_Expecter) DeleteObject added in v1.36.0

func (_e *MockWClient_Expecter) DeleteObject(ctx interface{}, host interface{}, index interface{}, shard interface{}, requestID interface{}, id interface{}, deletionTime interface{}, schemaVersion interface{}) *MockWClient_DeleteObject_Call

DeleteObject is a helper method to define mock.On call

  • ctx context.Context
  • host string
  • index string
  • shard string
  • requestID string
  • id strfmt.UUID
  • deletionTime time.Time
  • schemaVersion uint64

func (*MockWClient_Expecter) DeleteObjects added in v1.36.0

func (_e *MockWClient_Expecter) DeleteObjects(ctx interface{}, host interface{}, index interface{}, shard interface{}, requestID interface{}, uuids interface{}, deletionTime interface{}, dryRun interface{}, schemaVersion interface{}) *MockWClient_DeleteObjects_Call

DeleteObjects is a helper method to define mock.On call

  • ctx context.Context
  • host string
  • index string
  • shard string
  • requestID string
  • uuids []strfmt.UUID
  • deletionTime time.Time
  • dryRun bool
  • schemaVersion uint64

func (*MockWClient_Expecter) MergeObject added in v1.36.0

func (_e *MockWClient_Expecter) MergeObject(ctx interface{}, host interface{}, index interface{}, shard interface{}, requestID interface{}, mergeDoc interface{}, schemaVersion interface{}) *MockWClient_MergeObject_Call

MergeObject is a helper method to define mock.On call

  • ctx context.Context
  • host string
  • index string
  • shard string
  • requestID string
  • mergeDoc *objects.MergeDocument
  • schemaVersion uint64

func (*MockWClient_Expecter) PutObject added in v1.36.0

func (_e *MockWClient_Expecter) PutObject(ctx interface{}, host interface{}, index interface{}, shard interface{}, requestID interface{}, obj interface{}, schemaVersion interface{}) *MockWClient_PutObject_Call

PutObject is a helper method to define mock.On call

  • ctx context.Context
  • host string
  • index string
  • shard string
  • requestID string
  • obj *storobj.Object
  • schemaVersion uint64

func (*MockWClient_Expecter) PutObjects added in v1.36.0

func (_e *MockWClient_Expecter) PutObjects(ctx interface{}, host interface{}, index interface{}, shard interface{}, requestID interface{}, objs interface{}, schemaVersion interface{}) *MockWClient_PutObjects_Call

PutObjects is a helper method to define mock.On call

  • ctx context.Context
  • host string
  • index string
  • shard string
  • requestID string
  • objs []*storobj.Object
  • schemaVersion uint64

type MockWClient_MergeObject_Call added in v1.36.0

type MockWClient_MergeObject_Call struct {
	*mock.Call
}

MockWClient_MergeObject_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'MergeObject'

func (*MockWClient_MergeObject_Call) Return added in v1.36.0

func (*MockWClient_MergeObject_Call) Run added in v1.36.0

func (_c *MockWClient_MergeObject_Call) Run(run func(ctx context.Context, host string, index string, shard string, requestID string, mergeDoc *objects.MergeDocument, schemaVersion uint64)) *MockWClient_MergeObject_Call

func (*MockWClient_MergeObject_Call) RunAndReturn added in v1.36.0

type MockWClient_PutObject_Call added in v1.36.0

type MockWClient_PutObject_Call struct {
	*mock.Call
}

MockWClient_PutObject_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'PutObject'

func (*MockWClient_PutObject_Call) Return added in v1.36.0

func (*MockWClient_PutObject_Call) Run added in v1.36.0

func (_c *MockWClient_PutObject_Call) Run(run func(ctx context.Context, host string, index string, shard string, requestID string, obj *storobj.Object, schemaVersion uint64)) *MockWClient_PutObject_Call

func (*MockWClient_PutObject_Call) RunAndReturn added in v1.36.0

type MockWClient_PutObjects_Call added in v1.36.0

type MockWClient_PutObjects_Call struct {
	*mock.Call
}

MockWClient_PutObjects_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'PutObjects'

func (*MockWClient_PutObjects_Call) Return added in v1.36.0

func (*MockWClient_PutObjects_Call) Run added in v1.36.0

func (_c *MockWClient_PutObjects_Call) Run(run func(ctx context.Context, host string, index string, shard string, requestID string, objs []*storobj.Object, schemaVersion uint64)) *MockWClient_PutObjects_Call

func (*MockWClient_PutObjects_Call) RunAndReturn added in v1.36.0

type ObjResult added in v1.31.1

type ObjResult = Result[*storobj.Object]

type ObjTuple added in v1.31.1

type ObjTuple tuple[Replica]

type RClient

type RClient interface {
	// FetchObject fetches one object
	FetchObject(_ context.Context, host, index, shard string,
		id strfmt.UUID, props search.SelectProperties,
		additional additional.Properties, numRetries int) (Replica, error)

	// FetchObjects fetches objects specified in ids list.
	FetchObjects(_ context.Context, host, index, shard string,
		ids []strfmt.UUID) ([]Replica, error)

	// OverwriteObjects conditionally updates existing objects.
	OverwriteObjects(_ context.Context, host, index, shard string,
		_ []*objects.VObject) ([]types.RepairResponse, error)

	// DigestObjects finds a list of objects and returns a compact representation
	// of a list of the objects. This is used by the replicator to optimize the
	// number of bytes transferred over the network when fetching a replicated
	// object
	DigestObjects(ctx context.Context, host, index, shard string,
		ids []strfmt.UUID, numRetries int) ([]types.RepairResponse, error)

	FindUUIDs(ctx context.Context, host, index, shard string,
		filters *filters.LocalFilter, limit int) ([]strfmt.UUID, error)

	DigestObjectsInRange(ctx context.Context, host, index, shard string,
		initialUUID, finalUUID strfmt.UUID, limit int) ([]types.RepairResponse, error)

	HashTreeLevel(ctx context.Context, host, index, shard string, level int,
		discriminant *hashtree.Bitset) (digests []hashtree.Digest, err error)
}

RClient is the client used to read from remote replicas

type Replica added in v1.31.1

type Replica struct {
	ID                      strfmt.UUID     `json:"id,omitempty"`
	Deleted                 bool            `json:"deleted"`
	Object                  *storobj.Object `json:"object,omitempty"`
	LastUpdateTimeUnixMilli int64           `json:"lastUpdateTimeUnixMilli"`
}

Replica represents a replicated data item

func (*Replica) MarshalBinary added in v1.31.1

func (r *Replica) MarshalBinary() ([]byte, error)

func (*Replica) UnmarshalBinary added in v1.31.1

func (r *Replica) UnmarshalBinary(data []byte) error

func (Replica) UpdateTime added in v1.31.1

func (r Replica) UpdateTime() int64

UpdateTime return update time if it exists and 0 otherwise

type Replicas added in v1.31.1

type Replicas []Replica

func (Replicas) MarshalBinary added in v1.31.1

func (ro Replicas) MarshalBinary() ([]byte, error)

func (*Replicas) UnmarshalBinary added in v1.31.1

func (ro *Replicas) UnmarshalBinary(data []byte) error

type Replicator

type Replicator struct {
	*Finder
	// contains filtered or unexported fields
}

func NewReplicator

func NewReplicator(className string,
	router types.Router,
	nodeResolver cluster.NodeResolver,
	nodeName string,
	getDeletionStrategy func() string,
	client Client,
	promMetrics *monitoring.PrometheusMetrics,
	l logrus.FieldLogger,
) (*Replicator, error)

func (*Replicator) AddReferences

func (r *Replicator) AddReferences(ctx context.Context,
	shard string,
	refs []objects.BatchReference,
	l types.ConsistencyLevel,
	schemaVersion uint64,
) []error

func (*Replicator) DeleteObject

func (r *Replicator) DeleteObject(ctx context.Context,
	shard string,
	id strfmt.UUID,
	deletionTime time.Time,
	l types.ConsistencyLevel,
	schemaVersion uint64,
) error

func (*Replicator) DeleteObjects

func (r *Replicator) DeleteObjects(ctx context.Context,
	shard string,
	uuids []strfmt.UUID,
	deletionTime time.Time,
	dryRun bool,
	l types.ConsistencyLevel,
	schemaVersion uint64,
) []objects.BatchSimpleObject

func (*Replicator) MergeObject

func (r *Replicator) MergeObject(ctx context.Context,
	shard string,
	doc *objects.MergeDocument,
	l types.ConsistencyLevel,
	schemaVersion uint64,
) error

func (*Replicator) PutObject

func (r *Replicator) PutObject(ctx context.Context,
	shard string,
	obj *storobj.Object,
	l types.ConsistencyLevel,
	schemaVersion uint64,
) error

func (*Replicator) PutObjects

func (r *Replicator) PutObjects(ctx context.Context,
	shard string,
	objs []*storobj.Object,
	l types.ConsistencyLevel,
	schemaVersion uint64,
) []error

type Result added in v1.36.0

type Result[T any] struct {
	Value T
	Err   error
}

Result represents a valid value or an error.

type ShardDesc added in v1.19.0

type ShardDesc struct {
	Name string
	Node string
}

type ShardDifferenceReader added in v1.26.0

type ShardDifferenceReader struct {
	TargetNodeName    string
	TargetNodeAddress string
	RangeReader       hashtree.AggregatedHashTreeRangeReader
}

type ShardPart added in v1.31.1

type ShardPart struct {
	Shard string // one-to-one mapping between Shard and Node
	Node  string

	Data  []*storobj.Object
	Index []int // index for data
}

ShardPart represents a data partition belonging to a physical shard

func (*ShardPart) Extract added in v1.31.1

func (b *ShardPart) Extract() ([]Replica, []strfmt.UUID)

func (*ShardPart) ObjectIDs added in v1.31.1

func (b *ShardPart) ObjectIDs() []strfmt.UUID

type SimpleResponse

type SimpleResponse struct {
	Errors []Error `json:"errors,omitempty"`
}

func (*SimpleResponse) FirstError

func (r *SimpleResponse) FirstError() error

type StatusCode

type StatusCode int

StatusCode is communicate the cause of failure during replication

type UUID2Error

type UUID2Error struct {
	UUID  string `json:"uuid,omitempty"`
	Error Error  `json:"error,omitempty"`
}

type Vote added in v1.31.1

type Vote struct {
	BatchReply       // reply from a replica
	Count      []int // number of votes per object
	Err        error
}

Vote represents objects received from a specific replica and the number of votes per object.

type WClient added in v1.18.0

type WClient interface {
	PutObject(ctx context.Context, host, index, shard, requestID string,
		obj *storobj.Object, schemaVersion uint64) (SimpleResponse, error)
	DeleteObject(ctx context.Context, host, index, shard, requestID string,
		id strfmt.UUID, deletionTime time.Time, schemaVersion uint64) (SimpleResponse, error)
	PutObjects(ctx context.Context, host, index, shard, requestID string,
		objs []*storobj.Object, schemaVersion uint64) (SimpleResponse, error)
	MergeObject(ctx context.Context, host, index, shard, requestID string,
		mergeDoc *objects.MergeDocument, schemaVersion uint64) (SimpleResponse, error)
	DeleteObjects(ctx context.Context, host, index, shard, requestID string,
		uuids []strfmt.UUID, deletionTime time.Time, dryRun bool, schemaVersion uint64) (SimpleResponse, error)
	AddReferences(ctx context.Context, host, index, shard, requestID string,
		refs []objects.BatchReference, schemaVersion uint64) (SimpleResponse, error)
	Commit(ctx context.Context, host, index, shard, requestID string, resp interface{}) error
	Abort(ctx context.Context, host, index, shard, requestID string) (SimpleResponse, error)
}

WClient is the client used to write to replicas

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL