logservice

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2022 License: Apache-2.0 Imports: 22 Imported by: 2

README

About

Log Service provides reliable logging for MatrixOne.

Documentation

Index

Constants

View Source
const (
	LogServiceRPCName = "logservice-rpc"
)

Variables

View Source
var (
	// ErrDeadlineNotSet is returned when deadline is not set in the context.
	ErrDeadlineNotSet = moerr.NewError(moerr.INVALID_INPUT, "deadline not set")
	// ErrInvalidDeadline is returned when the specified deadline is invalid, e.g.
	// deadline is in the past.
	ErrInvalidDeadline = moerr.NewError(moerr.INVALID_INPUT, "invalid deadline")
	// ErrIncompatibleClient is returned when write requests are made on read-only clients.
	ErrIncompatibleClient = moerr.NewError(moerr.INVALID_INPUT, "incompatible client")
)
View Source
var (
	ErrInvalidTruncateLsn = moerr.NewError(moerr.INVALID_INPUT, "invalid input")
	ErrNotLeaseHolder     = moerr.NewError(moerr.INVALID_STATE, "not lease holder")
	ErrInvalidShardID     = moerr.NewError(moerr.INVALID_INPUT, "invalid shard ID")

	ErrOutOfRange = dragonboat.ErrInvalidRange
)
View Source
var (
	ErrInvalidConfig = moerr.NewError(moerr.BAD_CONFIGURATION, "invalid log service configuration")
)
View Source
var (
	ErrUnknownError = moerr.NewError(moerr.INVALID_STATE, "unknown error")
)

Functions

func IsTempError

func IsTempError(err error) bool

IsTempError returns a boolean value indicating whether the specified error is a temp error that worth to be retried, e.g. timeouts, temp network issues. Non-temp error caused by program logics rather than some external factors.

func MustMarshal

func MustMarshal(m Marshaler) []byte

func MustUnmarshal

func MustUnmarshal(m Unmarshaler, data []byte)

func NewTestService

func NewTestService(fs vfs.FS) (*Service, ClientConfig, error)

Types

type Client

type Client interface {
	// Close closes the client.
	Close() error
	// Config returns the specified configuration when creating the client.
	Config() ClientConfig
	// GetLogRecord returns a new LogRecord instance with its Data field enough
	// to hold payloadLength bytes of payload. The layout of the Data field is
	// 4 bytes of record type (pb.UserEntryUpdate) + 8 bytes DN replica ID +
	// payloadLength bytes of actual payload.
	GetLogRecord(payloadLength int) pb.LogRecord
	// Append appends the specified LogRecrd into the Log Service. On success, the
	// assigned Lsn will be returned. For the specified LogRecord, only its Data
	// field is used with all other fields ignored by Append(). Once returned, the
	// pb.LogRecord can be reused.
	Append(ctx context.Context, rec pb.LogRecord) (Lsn, error)
	// Read reads the Log Service from the specified Lsn position until the
	// returned LogRecord set reachs the specified maxSize in bytes. The returned
	// Lsn indicates the next Lsn to use to resume the read, or it means
	// everything available has been read when it equals to the specified Lsn.
	// The returned pb.LogRecord records will have their Lsn and Type fields set,
	// the Lsn field is the Lsn assigned to the record while the Type field tells
	// whether the record is an internal record generated by the Log Service itself
	// or appended by the user.
	Read(ctx context.Context, firstLsn Lsn, maxSize uint64) ([]pb.LogRecord, Lsn, error)
	// Truncate truncates the Log Service log at the specified Lsn with Lsn
	// itself included. This allows the Log Service to free up storage capacities
	// for future appends, all future reads must start after the specified Lsn
	// position.
	Truncate(ctx context.Context, lsn Lsn) error
	// GetTruncatedLsn returns the largest Lsn value that has been specified for
	// truncation.
	GetTruncatedLsn(ctx context.Context) (Lsn, error)
	// GetTSOTimestamp requests a total of count unique timestamps from the TSO and
	// return the first assigned such timestamp, that is TSO timestamps
	// [returned value, returned value + count] will be owned by the caller.
	GetTSOTimestamp(ctx context.Context, count uint64) (uint64, error)
}

Client is the Log Service Client interface exposed to the DN.

func NewClient

func NewClient(ctx context.Context,
	cfg ClientConfig) (Client, error)

NewClient creates a Log Service client. Each returned client can be used to synchronously issue requests to the Log Service. To send multiple requests to the Log Service in parallel, multiple clients should be created and used to do so.

type ClientConfig

type ClientConfig struct {
	// ReadOnly indicates whether this is a read-only client.
	ReadOnly bool
	// LogShardID is the shard ID of the log service shard to be used.
	LogShardID uint64
	// DNReplicaID is the replica ID of the DN that owns the created client.
	DNReplicaID uint64
	// LogService nodes service addresses. This field is provided for testing
	// purposes only.
	ServiceAddresses []string
}

ClientConfig is the configuration for log service clients.

type Config

type Config struct {
	FS                   vfs.FS
	DeploymentID         uint64
	NodeHostID           string
	RTTMillisecond       uint64
	DataDir              string
	ServiceAddress       string
	ServiceListenAddress string
	RaftAddress          string
	RaftListenAddress    string
	GossipAddress        string
	GossipListenAddress  string
	GossipSeedAddresses  []string
}

TODO: add toml or json support Config defines the Configurations supported by the Log Service.

func (*Config) Fill

func (c *Config) Fill()

func (*Config) Validate

func (c *Config) Validate() error

Validate validates the configuration.

type LogRecord

type LogRecord = pb.LogRecord

type Lsn

type Lsn = uint64

type Marshaler

type Marshaler interface {
	Marshal() ([]byte, error)
}

type RPCRequest

type RPCRequest struct {
	pb.Request
	// contains filtered or unexported fields
}

RPCRequest is request message type used in morpc

func (*RPCRequest) DebugString

func (r *RPCRequest) DebugString() string

func (*RPCRequest) GetID

func (r *RPCRequest) GetID() uint64

func (*RPCRequest) GetPayloadField

func (r *RPCRequest) GetPayloadField() []byte

func (*RPCRequest) Release

func (r *RPCRequest) Release()

func (*RPCRequest) SetID

func (r *RPCRequest) SetID(id uint64)

func (*RPCRequest) SetPayloadField

func (r *RPCRequest) SetPayloadField(data []byte)

type RPCResponse

type RPCResponse struct {
	pb.Response
	// contains filtered or unexported fields
}

RPCResponse is response message type used in morpc

func (*RPCResponse) DebugString

func (r *RPCResponse) DebugString() string

func (*RPCResponse) GetID

func (r *RPCResponse) GetID() uint64

func (*RPCResponse) GetPayloadField

func (r *RPCResponse) GetPayloadField() []byte

func (*RPCResponse) Release

func (r *RPCResponse) Release()

func (*RPCResponse) SetID

func (r *RPCResponse) SetID(id uint64)

func (*RPCResponse) SetPayloadField

func (r *RPCResponse) SetPayloadField(data []byte)

type ReplicaInfo

type ReplicaInfo struct {
	UUID           string
	ServiceAddress string
}

type Service

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

Service is the top layer component of a log service node. It manages the underlying log store which in turn manages all log shards including the HAKeeper shard. The Log Service component communicates with LogService clients owned by DN nodes and the HAKeeper service via network, it can be considered as the interface layer of the LogService.

func NewService

func NewService(cfg Config) (*Service, error)

func (*Service) Close

func (s *Service) Close() (err error)

func (*Service) GetShardInfo

func (s *Service) GetShardInfo(shardID uint64) (ShardInfo, bool)

func (*Service) ID

func (s *Service) ID() string

type ShardInfo

type ShardInfo struct {
	ShardID  uint64
	Replicas map[uint64]ReplicaInfo
	Epoch    uint64
	LeaderID uint64
	Term     uint64
}

type Unmarshaler

type Unmarshaler interface {
	Unmarshal([]byte) error
}

Jump to

Keyboard shortcuts

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