replica

package
v1.24.10 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

func ValidateConfig

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

func ValidateConfigUpdate

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

Types

type Client

type Client interface {
	// contains filtered or unexported methods
}

Client is used to read and write objects on replicas

type ConsistencyLevel

type ConsistencyLevel string

ConsistencyLevel is an enum of all possible consistency level

const (
	One    ConsistencyLevel = "ONE"
	Quorum ConsistencyLevel = "QUORUM"
	All    ConsistencyLevel = "ALL"
)

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 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,
	resolver *resolver,
	client rClient,
	l logrus.FieldLogger,
) *Finder

NewFinder constructs a new finder instance

func (*Finder) CheckConsistency added in v1.19.0

func (f *Finder) CheckConsistency(ctx context.Context,
	l ConsistencyLevel, xs []*storobj.Object,
) (retErr 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) Exists added in v1.18.0

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

Exists checks if an object exists which satisfies the giving consistency

func (*Finder) GetOne added in v1.18.0

GetOne gets object which satisfies the giving consistency

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

type RemoteIncomingRepo added in v1.19.0

type RemoteIncomingRepo interface {
	// Write endpoints
	ReplicateObject(ctx context.Context, indexName, shardName,
		requestID string, object *storobj.Object) SimpleResponse
	ReplicateObjects(ctx context.Context, indexName,
		shardName, requestID string, objects []*storobj.Object) SimpleResponse
	ReplicateUpdate(ctx context.Context, indexName,
		shardName, requestID string, mergeDoc *objects.MergeDocument) SimpleResponse
	ReplicateDeletion(ctx context.Context, indexName,
		shardName, requestID string, uuid strfmt.UUID) SimpleResponse
	ReplicateDeletions(ctx context.Context, indexName,
		shardName, requestID string, uuids []strfmt.UUID, dryRun bool) SimpleResponse
	ReplicateReferences(ctx context.Context, indexName,
		shardName, requestID string, refs []objects.BatchReference) SimpleResponse
	CommitReplication(indexName,
		shardName, requestID string) interface{}
	AbortReplication(indexName,
		shardName, requestID string) interface{}
	OverwriteObjects(ctx context.Context, index, shard string,
		vobjects []*objects.VObject) ([]RepairResponse, error)
	// Read endpoints
	FetchObject(ctx context.Context, indexName,
		shardName string, id strfmt.UUID) (objects.Replica, error)
	FetchObjects(ctx context.Context, class,
		shardName string, ids []strfmt.UUID) ([]objects.Replica, error)
	DigestObjects(ctx context.Context, class, shardName string,
		ids []strfmt.UUID) (result []RepairResponse, err error)
}

type RemoteReplicaIncoming

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

func NewRemoteReplicaIncoming

func NewRemoteReplicaIncoming(repo RemoteIncomingRepo) *RemoteReplicaIncoming

func (*RemoteReplicaIncoming) AbortReplication

func (rri *RemoteReplicaIncoming) AbortReplication(indexName,
	shardName, requestID string,
) interface{}

func (*RemoteReplicaIncoming) CommitReplication

func (rri *RemoteReplicaIncoming) CommitReplication(indexName,
	shardName, requestID string,
) interface{}

func (*RemoteReplicaIncoming) DigestObjects added in v1.18.0

func (rri *RemoteReplicaIncoming) DigestObjects(ctx context.Context,
	indexName, shardName string, ids []strfmt.UUID,
) (result []RepairResponse, err error)

func (*RemoteReplicaIncoming) FetchObject added in v1.18.0

func (rri *RemoteReplicaIncoming) FetchObject(ctx context.Context,
	indexName, shardName string, id strfmt.UUID,
) (objects.Replica, error)

func (*RemoteReplicaIncoming) FetchObjects added in v1.18.0

func (rri *RemoteReplicaIncoming) FetchObjects(ctx context.Context,
	indexName, shardName string, ids []strfmt.UUID,
) ([]objects.Replica, error)

func (*RemoteReplicaIncoming) OverwriteObjects added in v1.18.0

func (rri *RemoteReplicaIncoming) OverwriteObjects(ctx context.Context,
	indexName, shardName string, vobjects []*objects.VObject,
) ([]RepairResponse, error)

func (*RemoteReplicaIncoming) ReplicateDeletion

func (rri *RemoteReplicaIncoming) ReplicateDeletion(ctx context.Context, indexName,
	shardName, requestID string, uuid strfmt.UUID,
) SimpleResponse

func (*RemoteReplicaIncoming) ReplicateDeletions

func (rri *RemoteReplicaIncoming) ReplicateDeletions(ctx context.Context, indexName,
	shardName, requestID string, uuids []strfmt.UUID, dryRun bool,
) SimpleResponse

func (*RemoteReplicaIncoming) ReplicateObject

func (rri *RemoteReplicaIncoming) ReplicateObject(ctx context.Context, indexName,
	shardName, requestID string, object *storobj.Object,
) SimpleResponse

func (*RemoteReplicaIncoming) ReplicateObjects

func (rri *RemoteReplicaIncoming) ReplicateObjects(ctx context.Context, indexName,
	shardName, requestID string, objects []*storobj.Object,
) SimpleResponse

func (*RemoteReplicaIncoming) ReplicateReferences

func (rri *RemoteReplicaIncoming) ReplicateReferences(ctx context.Context, indexName,
	shardName, requestID string, refs []objects.BatchReference,
) SimpleResponse

func (*RemoteReplicaIncoming) ReplicateUpdate

func (rri *RemoteReplicaIncoming) ReplicateUpdate(ctx context.Context, indexName,
	shardName, requestID string, mergeDoc *objects.MergeDocument,
) SimpleResponse

type RepairResponse added in v1.18.0

type RepairResponse struct {
	ID         string // object id
	Version    int64  // sender's current version of the object
	UpdateTime int64  // sender's current update time
	Err        string
	Deleted    bool
}

type Replicator

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

func NewReplicator

func NewReplicator(className string,
	stateGetter shardingState,
	nodeResolver nodeResolver,
	client Client,
	l logrus.FieldLogger,
) *Replicator

func (*Replicator) AddReferences

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

func (*Replicator) DeleteObject

func (r *Replicator) DeleteObject(ctx context.Context,
	shard string,
	id strfmt.UUID,
	l ConsistencyLevel,
) error

func (*Replicator) DeleteObjects

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

func (*Replicator) MergeObject

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

func (*Replicator) PutObject

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

func (*Replicator) PutObjects

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

type ShardDesc added in v1.19.0

type ShardDesc struct {
	Name string
	Node string
}

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"`
}

Jump to

Keyboard shortcuts

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