Documentation
¶
Overview ¶
Package logservice implement MO's LogService component.
Index ¶
- Constants
- Variables
- func GetBackendOptions(ctx context.Context) []morpc.BackendOption
- func GetClientOptions(ctx context.Context) []morpc.ClientOption
- func IsTempError(err error) bool
- func MustMarshal(m Marshaller) []byte
- func MustUnmarshal(m Unmarshaler, data []byte)
- func NewTestService(fs vfs.FS) (*Service, ClientConfig, error)
- func RunClientTest(t *testing.T, readOnly bool, cCfgFn func(bool, ...string) ClientConfig, ...)
- func SetBackendOptions(ctx context.Context, opts ...morpc.BackendOption) context.Context
- func SetClientOptions(ctx context.Context, opts ...morpc.ClientOption) context.Context
- type BRHAKeeperClient
- type CNHAKeeperClient
- type ChangeType
- type Client
- type ClientConfig
- type ClientFactory
- type ClusterHAKeeperClient
- type Config
- func (c *Config) Bootstrapping() (uint64, bool)
- func (c *Config) Fill()
- func (c *Config) GetHAKeeperClientConfig() HAKeeperClientConfig
- func (c *Config) GetHAKeeperConfig() hakeeper.Config
- func (c *Config) GetInitHAKeeperMembers() (map[uint64]dragonboat.Target, error)
- func (c *Config) GossipListenAddr() string
- func (c *Config) GossipServiceAddr() string
- func (c *Config) LogServiceListenAddr() string
- func (c *Config) LogServiceServiceAddr() string
- func (c *Config) RaftListenAddr() string
- func (c *Config) RaftServiceAddr() string
- func (c *Config) UpdateAddresses(host string, servicePort int, raftPort int, gossipPort int)
- func (c *Config) Validate() error
- type ContextKey
- type DataSync
- type HAKeeperClientConfig
- type ISnapshotItem
- type ISnapshotManager
- type LogHAKeeperClient
- type LogRecord
- type Lsn
- type Marshaller
- type Option
- type ProxyHAKeeperClient
- type RPCRequest
- type RPCResponse
- type Service
- type ShardInfo
- type StandbyClient
- type TNHAKeeperClient
- type Unmarshaler
- type WrappedService
- func (w *WrappedService) Close() error
- func (w *WrappedService) GetClusterState() (*pb.CheckerState, error)
- func (w *WrappedService) GetTaskService() (taskservice.TaskService, bool)
- func (w *WrappedService) ID() string
- func (w *WrappedService) IsLeaderHakeeper() (bool, error)
- func (w *WrappedService) SetInitialClusterInfo(logShardNum, tnShartnum, logReplicaNum uint64) error
- func (w *WrappedService) Start() error
- func (w *WrappedService) StartHAKeeperReplica(replicaID uint64, replicas map[uint64]dragonboat.Target, join bool) error
Constants ¶
const ( DefaultListenHost = "0.0.0.0" DefaultServiceHost = "127.0.0.1" DefaultLogServicePort = 32001 )
const (
LogServiceRPCName = "logservice-server"
)
Variables ¶
var ( DefaultLogServiceServiceAddress = fmt.Sprintf("%s:%d", DefaultServiceHost, DefaultLogServicePort) DefaultGossipServiceAddress = fmt.Sprintf("%s:%d", DefaultServiceHost, defaultGossipPort) )
var NewLogRecord = pb.NewLogRecord
var NewUserLogRecord = pb.NewUserLogRecord
Functions ¶
func GetBackendOptions ¶ added in v0.6.0
func GetBackendOptions(ctx context.Context) []morpc.BackendOption
func GetClientOptions ¶ added in v0.6.0
func GetClientOptions(ctx context.Context) []morpc.ClientOption
func IsTempError ¶
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 Marshaller) []byte
func MustUnmarshal ¶
func MustUnmarshal(m Unmarshaler, data []byte)
func NewTestService ¶
func NewTestService(fs vfs.FS) (*Service, ClientConfig, error)
func RunClientTest ¶
func SetBackendOptions ¶ added in v0.6.0
func SetClientOptions ¶ added in v0.6.0
Types ¶
type BRHAKeeperClient ¶ added in v1.0.0
BRHAKeeperClient is the HAKeeper client for backup and restore.
type CNHAKeeperClient ¶ added in v0.5.1
type CNHAKeeperClient interface {
BRHAKeeperClient
// SendCNHeartbeat sends the specified heartbeat message to the HAKeeper.
SendCNHeartbeat(ctx context.Context, hb pb.CNStoreHeartbeat) (pb.CommandBatch, error)
// UpdateNonVotingReplicaNum updates the non-voting-replica-num which is stores in HAKeeper.
UpdateNonVotingReplicaNum(ctx context.Context, num uint64) error
// UpdateNonVotingLocality updates the non-voting-locality which is stores in HAKeeper.
UpdateNonVotingLocality(ctx context.Context, locality pb.Locality) error
// contains filtered or unexported methods
}
CNHAKeeperClient is the HAKeeper client used by a CN store.
func NewCNHAKeeperClient ¶ added in v0.5.1
func NewCNHAKeeperClient( ctx context.Context, sid string, cfg HAKeeperClientConfig, ) (CNHAKeeperClient, error)
NewCNHAKeeperClient creates a HAKeeper client to be used by a CN node.
NB: caller could specify options for morpc.Client via ctx.
type Client ¶
type Client interface {
// Close closes the client.
Close() error
// Config returns the specified configuration when creating the client.
Config() ClientConfig
// UpdateLeaseholderID updates the leaseholder ID for the shard.
UpdateLeaseholderID(ctx context.Context, leaseholderID uint64) error
// 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 TN replica ID +
// payloadLength bytes of actual payload.
GetLogRecord(payloadLength int) pb.LogRecord
// Append appends the specified LogRecord 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 reaches 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)
// ReadLsn reads the LSN from the archived log files according to the specified
// timestamp, return the log file's first lsn whose ts is less than the specified one.
// If there are no log files found in the archived storage, an error is returned.
ReadLsn(ctx context.Context, ts time.Time) (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)
// GetLatestLsn returns the latest Lsn.
GetLatestLsn(ctx context.Context) (Lsn, error)
// SetRequiredLsn updates the required Lsn.
SetRequiredLsn(ctx context.Context, lsn Lsn) error
// GetRequiredLsn returns the required Lsn, which is required by other shards or
// module. It is only a mark that other shards will read log entries from this value.
// If the log entries after it are removed, other shards read data from S3 storage.
GetRequiredLsn(ctx context.Context) (Lsn, error)
}
Client is the Log Service Client interface exposed to the DN.
type ClientConfig ¶
type ClientConfig struct {
// Tag client tag
Tag string
// 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
// TNReplicaID is the replica ID of the TN that owns the created client.
TNReplicaID uint64
// DiscoveryAddress is the Log Service discovery address provided by k8s.
DiscoveryAddress string
// LogService nodes service addresses. This field is provided for testing
// purposes only.
ServiceAddresses []string
// MaxMessageSize is the max message size for RPC.
MaxMessageSize int
// EnableCompress enable compress
EnableCompress bool
}
ClientConfig is the configuration for log service clients.
func (*ClientConfig) ValidateClient ¶
func (c *ClientConfig) ValidateClient() error
ValidateClient validates the ClientConfig.
func (*ClientConfig) ValidateStandbyClient ¶
func (c *ClientConfig) ValidateStandbyClient() error
ValidateStandbyClient validates the ClientConfig.
type ClientFactory ¶ added in v0.6.0
type ClusterHAKeeperClient ¶ added in v0.8.0
type ClusterHAKeeperClient interface {
// contains filtered or unexported methods
}
ClusterHAKeeperClient used to get cluster detail
func NewClusterHAKeeperClient ¶
func NewClusterHAKeeperClient( ctx context.Context, sid string, cfg HAKeeperClientConfig, ) (ClusterHAKeeperClient, error)
func NewLogHAKeeperClientWithRetry ¶
func NewLogHAKeeperClientWithRetry( ctx context.Context, sid string, cfg HAKeeperClientConfig, ) ClusterHAKeeperClient
NewLogHAKeeperClientWithRetry creates a HAKeeper client with retry.
type Config ¶
type Config struct {
// FS is the underlying virtual FS used by the log service. Leave it as empty
// in production.
FS vfs.FS
// DeploymentID is basically the Cluster ID, nodes with different DeploymentID
// will not be able to communicate via raft.
DeploymentID uint64 `toml:"deployment-id"`
// UUID is the UUID of the log service node. UUID value must be set.
UUID string `toml:"uuid" user_setting:"basic"`
// RTTMillisecond is the average round trip time between log service nodes in
// milliseconds.
RTTMillisecond uint64 `toml:"rttmillisecond"`
// DataDir is the name of the directory for storing all log service data. It
// should a locally mounted partition with good write and fsync performance.
DataDir string `toml:"data-dir" user_setting:"basic"`
// SnapshotExportDir is the directory where the dragonboat snapshots are
// exported.
SnapshotExportDir string `toml:"snapshot-export-dir"`
// MaxExportedSnapshot is the max count of exported snapshots. If there are
// already MaxExportedSnapshot exported snapshots, no exported snapshot will
// be generated.
MaxExportedSnapshot int `toml:"max-exported-snapshot"`
// ServiceHost is the host name/IP for the service address of RPC request. There is
// no port value in it.
ServiceHost string `toml:"service-host"`
// ServiceAddress is log service's service address that can be reached by
// other nodes such as TN nodes. It is deprecated and will be removed.
ServiceAddress string `toml:"logservice-address" user_setting:"advanced"`
// ServiceListenAddress is the local listen address of the ServiceAddress.
// It is deprecated and will be removed.
ServiceListenAddress string `toml:"logservice-listen-address"`
// ServicePort is log service's service address port that can be reached by
// other nodes such as TN nodes.
LogServicePort int `toml:"logservice-port"`
// RaftAddress is the address that can be reached by other log service nodes
// via their raft layer. It is deprecated and will be removed.
RaftAddress string `toml:"raft-address" user_setting:"advanced"`
// RaftListenAddress is the local listen address of the RaftAddress.
// It is deprecated and will be removed.
RaftListenAddress string `toml:"raft-listen-address"`
// RaftPort is the address port that can be reached by other log service nodes
// via their raft layer.
RaftPort int `toml:"raft-port"`
// UseTeeLogDB enables the log service to use tee based LogDB which is backed
// by both a pebble and a tan based LogDB. This field should only be set to
// true during testing.
UseTeeLogDB bool `toml:"use-tee-logdb"`
// LogDBBufferSize is the size of the logdb buffer in bytes.
LogDBBufferSize uint64 `toml:"logdb-buffer-size"`
// LogDBMaxLogFileSize is the max size of the log db file.
LogDBMaxLogFileSize uint64 `toml:"logdb-max-log-file-size"`
// LogDBDisablePrealloc disables file preallocation using fallocate. This is useful
// when the filesystem (e.g., NFS) does not support fallocate system call.
LogDBDisablePrealloc bool `toml:"logdb-disable-prealloc"`
// GossipAddress is the address used for accepting gossip communication.
// It is deprecated and will be removed.
GossipAddress string `toml:"gossip-address" user_setting:"advanced"`
// GossipAddressV2 is the address used for accepting gossip communication.
// This is for domain name support. It is deprecated and will be removed.
GossipAddressV2 string `toml:"gossip-address-v2"`
// GossipListenAddress is the local listen address of the GossipAddress
// It is deprecated and will be removed.
GossipListenAddress string `toml:"gossip-listen-address"`
// GossipPort is the port address port used for accepting gossip communication.
GossipPort int `toml:"gossip-port"`
// GossipSeedAddresses is list of seed addresses that are used for
// introducing the local node into the gossip network.
GossipSeedAddresses []string `toml:"gossip-seed-addresses" user_setting:"advanced"`
// GossipProbeInterval how often gossip nodes probe each other.
GossipProbeInterval toml.Duration `toml:"gossip-probe-interval"`
// GossipAllowSelfAsSeed allow use self as gossip seed
GossipAllowSelfAsSeed bool `toml:"gossip-allow-self-as-seed"`
// HeartbeatInterval is the interval of how often log service node should be
// sending heartbeat message to the HAKeeper.
HeartbeatInterval toml.Duration `toml:"logservice-heartbeat-interval"`
// HAKeeperTickInterval is the interval of how often log service node should
// tick the HAKeeper.
HAKeeperTickInterval toml.Duration `toml:"hakeeper-tick-interval"`
// HAKeeperCheckInterval is the interval of how often HAKeeper should run
// cluster health checks.
HAKeeperCheckInterval toml.Duration `toml:"hakeeper-check-interval"`
// TruncateInterval is the interval of how often log service should
// process truncate for regular shards.
TruncateInterval toml.Duration `toml:"truncate-interval"`
// HAKeeperTruncateInterval is the interval of how often log service should
// process truncate for HAKeeper shard.
HAKeeperTruncateInterval toml.Duration `toml:"hakeeper-truncate-interval"`
// ExplicitHostname is the hostname used in draogboat.
ExplicitHostname string `toml:"explicit-hostname"`
// Locality sets the locality information of the logservice instance.
// The format is "key1:value1;key2:value2".
// It is mainly used to allocate non-voting replicas.
Locality string `toml:"locality"`
// IsNonVoting indicates if this node is a non-voting node.
// If it is a non-voting node, it can only receive replicated states from leader,
// but it is neither allowed to vote for leader, nor considered as a part of the
// quorum when replicating state.
IsNonVoting bool `toml:"is-non-voting"`
// MembershipImmovable indicates if keep the membership as the one in the
// snapshot. If it is true, all non-voting nodes and witness nodes will
// change to normal nodes when startup, otherwise, keep their roles as
// in snapshot. Default value is true.
MembershipImmovable bool `toml:"membership-immovable"`
RPC struct {
// MaxMessageSize is the max size for RPC message. The default value is 10MiB.
MaxMessageSize toml.ByteSize `toml:"max-message-size"`
// EnableCompress enable compress
EnableCompress bool `toml:"enable-compress"`
}
// BootstrapConfig is the configuration specified for the bootstrapping
// procedure. It only needs to be specified for Log Stores selected to host
// initial HAKeeper replicas during bootstrapping.
BootstrapConfig struct {
// BootstrapCluster indicates whether the cluster should be bootstrapped.
// Note the bootstrapping procedure will only be executed if BootstrapCluster
// is true and Config.UUID is found in Config.BootstrapConfig.InitHAKeeperMembers.
BootstrapCluster bool `toml:"bootstrap-cluster"`
// NumOfLogShards defines the number of Log shards in the initial deployment.
NumOfLogShards uint64 `toml:"num-of-log-shards"`
// NumOfTNShards defines the number of TN shards in the initial deployment.
// The count must be the same as NumOfLogShards in the current implementation.
NumOfTNShards uint64 `toml:"num-of-tn-shards"`
// NumOfLogShardReplicas is the number of replicas for each shard managed by
// Log Stores, including Log Service shards and the HAKeeper.
NumOfLogShardReplicas uint64 `toml:"num-of-log-shard-replicas"`
// InitHAKeeperMembers defines the initial members of the HAKeeper as a list
// of HAKeeper replicaID and UUID pairs. For example,
// when the initial HAKeeper members are
// replica with replica ID 101 running on Log Store uuid1
// replica with replica ID 102 running on Log Store uuid2
// replica with replica ID 103 running on Log Store uuid3
// the InitHAKeeperMembers string value should be
// []string{"101:uuid1", "102:uuid2", "103:uuid3"}
// Note that these initial HAKeeper replica IDs must be assigned by k8s
// from the range [K8SIDRangeStart, K8SIDRangeEnd) as defined in pkg/hakeeper.
// All uuid values are assigned by k8s, they are used to uniquely identify
// CN/DN/Log stores.
// Config.UUID and Config.BootstrapConfig values are considered together to
// figure out what is the replica ID of the initial HAKeeper replica. That
// is when Config.UUID is found in InitHAKeeperMembers, then the corresponding
// replica ID value will be used to launch a HAKeeper replica on the Log
// Service instance.
InitHAKeeperMembers []string `toml:"init-hakeeper-members" user_setting:"advanced"`
// Restore structure is used when the cluster needs to restore data.
Restore struct {
// FilePath is the path of the file, which contains the backup data.
// If is not set, nothing will be done for restore.
FilePath string `toml:"file-path"`
// Force means that we force to do restore even if RESTORED tag file
// already exists.
Force bool `toml:"force"`
} `toml:"restore"`
// NonVotingLocality is the locality for non-voting replicas.
NonVotingLocality string `toml:"non-voting-locality" user_setting:"advanced"`
// StandbyEnabled is true means that the standby cluster is enabled and there will
// be another new shard for the s3 data.
StandbyEnabled bool `toml:"standby-enabled" user_setting:"advanced"`
}
HAKeeperConfig struct {
// TickPerSecond indicates how many ticks every second.
// In HAKeeper, we do not use actual time to measure time elapse.
// Instead, we use ticks.
TickPerSecond int `toml:"tick-per-second"`
// LogStoreTimeout is the actual time limit between a log store's heartbeat.
// If HAKeeper does not receive two heartbeat within LogStoreTimeout,
// it regards the log store as down.
LogStoreTimeout toml.Duration `toml:"log-store-timeout"`
// TNStoreTimeout is the actual time limit between a tn store's heartbeat.
// If HAKeeper does not receive two heartbeat within TNStoreTimeout,
// it regards the tn store as down.
TNStoreTimeout toml.Duration `toml:"tn-store-timeout"`
// CNStoreTimeout is the actual time limit between a cn store's heartbeat.
// If HAKeeper does not receive two heartbeat within CNStoreTimeout,
// it regards the tn store as down.
CNStoreTimeout toml.Duration `toml:"cn-store-timeout"`
}
// HAKeeperClientConfig is the config for HAKeeperClient
HAKeeperClientConfig HAKeeperClientConfig
// DisableWorkers disables the HAKeeper ticker and HAKeeper client in tests.
// Never set this field to true in production
DisableWorkers bool
Ctl struct {
// ListenAddress ctl service listen address for receiving ctl requests
ListenAddress string `toml:"listen-address"`
// ServiceAddress service address for communication, if this address is not set, use
// ListenAddress as the communication address.
ServiceAddress string `toml:"service-address"`
} `toml:"ctl"`
// ArchiveEnabled indicates if the archive log function is enabled, default is false.
ArchiveLogEnabled bool `toml:"archive-log-enabled"`
}
Config defines the Configurations supported by the Log Service.
func DefaultConfig ¶ added in v1.0.0
func DefaultConfig() Config
func (*Config) Bootstrapping ¶ added in v0.6.0
returns replica ID of the HAKeeper replica and a boolean indicating whether we should run the bootstrap procedure.
func (*Config) Fill ¶
func (c *Config) Fill()
Fill just fills the listen addresses. This function is deprecated and will be removed as the configurations are all deprecated.
func (*Config) GetHAKeeperClientConfig ¶ added in v0.6.0
func (c *Config) GetHAKeeperClientConfig() HAKeeperClientConfig
func (*Config) GetHAKeeperConfig ¶ added in v0.6.0
func (*Config) GetInitHAKeeperMembers ¶ added in v0.6.0
func (c *Config) GetInitHAKeeperMembers() (map[uint64]dragonboat.Target, error)
func (*Config) GossipListenAddr ¶ added in v1.0.0
func (*Config) GossipServiceAddr ¶ added in v1.0.0
func (*Config) LogServiceListenAddr ¶ added in v1.0.0
func (*Config) LogServiceServiceAddr ¶ added in v1.0.0
func (*Config) RaftListenAddr ¶ added in v1.0.0
func (*Config) RaftServiceAddr ¶ added in v1.0.0
func (*Config) UpdateAddresses ¶
type ContextKey ¶ added in v0.6.0
type ContextKey string
const ( BackendOption ContextKey = "morpc.BackendOption" ClientOption ContextKey = "morpc.ClientOption" )
type DataSync ¶
type DataSync interface {
// Append appends data to the datasync module, which will sync data
// to another storage.
Append(ctx context.Context, lsn uint64, data []byte)
// NotifyReplicaID notifies the replicaID of shard on this store.
// DataSync is an interface that sync data to another storage.
NotifyReplicaID(shardID uint64, replicaID uint64, typ ChangeType)
// Close closes the datasync module and release the resource.
Close() error
}
type HAKeeperClientConfig ¶ added in v0.5.1
type HAKeeperClientConfig struct {
// DiscoveryAddress is the Log Service discovery address provided by k8s.
DiscoveryAddress string `toml:"discovery-address"`
// ServiceAddresses is a list of well known Log Services' service addresses.
ServiceAddresses []string `toml:"service-addresses"`
// AllocateIDBatch how many IDs are assigned from hakeeper each time. Default is
// 100.
AllocateIDBatch uint64 `toml:"allocate-id-batch"`
// EnableCompress enable compress
EnableCompress bool `toml:"enable-compress"`
}
HAKeeperClientConfig is the config for HAKeeper clients.
func (*HAKeeperClientConfig) Validate ¶ added in v0.6.0
func (c *HAKeeperClientConfig) Validate() error
Validate validates the HAKeeperClientConfig.
type ISnapshotItem ¶ added in v0.6.0
type ISnapshotItem interface {
// Exists returns if the snapshot item exists.
Exists() bool
// Remove removes the snapshot item.
Remove() error
// Valid check the legality of the snapshot item. Only the names of
// the files in it are checked.
Valid() (bool, error)
}
ISnapshotItem is an interface that represents a snapshot item.
type ISnapshotManager ¶ added in v0.6.0
type ISnapshotManager interface {
// Init initialize snapshots by loading exported snapshots.
Init(shardID uint64, replicaID uint64) error
// Count returns the number of snapshots in the manager.
Count(shardID uint64, replicaID uint64) int
// Add adds a new snapshot for specified shard.
Add(shardID uint64, replicaID uint64, index uint64) error
// Remove removes snapshots whose index is LE than index.
Remove(shardID uint64, replicaID uint64, index uint64) error
// EvalImportSnapshot returns the source directory and index of
// the biggest snapshot of the shard.
EvalImportSnapshot(shardID uint64, replicaID uint64, index uint64) (string, uint64)
}
ISnapshotManager is an interface that managers snapshots.
type LogHAKeeperClient ¶ added in v0.5.1
type LogHAKeeperClient interface {
// SendLogHeartbeat sends the specified heartbeat message to the HAKeeper. The
// returned CommandBatch contains Schedule Commands to be executed by the local
// Log store.
SendLogHeartbeat(ctx context.Context, hb pb.LogStoreHeartbeat) (pb.CommandBatch, error)
// contains filtered or unexported methods
}
LogHAKeeperClient is the HAKeeper client used by a Log store.
func NewLogHAKeeperClient ¶ added in v0.5.1
func NewLogHAKeeperClient( ctx context.Context, sid string, cfg HAKeeperClientConfig, ) (LogHAKeeperClient, error)
NewLogHAKeeperClient creates a HAKeeper client to be used by a Log Service node.
NB: caller could specify options for morpc.Client via ctx.
type Marshaller ¶ added in v0.6.0
type Option ¶ added in v0.6.0
type Option func(*Service)
Option is utility that sets callback for Service.
func WithBackendFilter ¶ added in v0.6.0
WithBackendFilter sets filter via which could select remote backend.
func WithConfigData ¶ added in v1.1.0
func WithConfigData(data map[string]*pb.ConfigItem) Option
WithConfigData saves the data from the config file
func WithDataSync ¶
WithDataSync sets the DataSync of service.
func WithRuntime ¶ added in v0.7.0
WithRuntime sets runtime
func WithTaskStorageFactory ¶ added in v0.6.0
func WithTaskStorageFactory(factory taskservice.TaskStorageFactory) Option
WithTaskStorageFactory set up the special task storage factory
type ProxyHAKeeperClient ¶ added in v0.8.0
type ProxyHAKeeperClient interface {
// GetCNState gets CN state from HAKeeper.
GetCNState(ctx context.Context) (pb.CNState, error)
// UpdateCNLabel updates the labels of CN.
UpdateCNLabel(ctx context.Context, label pb.CNStoreLabel) error
// UpdateCNWorkState updates the work state of CN.
UpdateCNWorkState(ctx context.Context, state pb.CNWorkState) error
// PatchCNStore updates the work state and labels of CN.
PatchCNStore(ctx context.Context, stateLabel pb.CNStateLabel) error
// DeleteCNStore deletes a CN store from HAKeeper.
DeleteCNStore(ctx context.Context, cnStore pb.DeleteCNStore) error
// SendProxyHeartbeat sends the heartbeat of proxy to HAKeeper.
SendProxyHeartbeat(ctx context.Context, hb pb.ProxyHeartbeat) (pb.CommandBatch, error)
// contains filtered or unexported methods
}
ProxyHAKeeperClient is the HAKeeper client used by proxy service.
func NewProxyHAKeeperClient ¶ added in v0.8.0
func NewProxyHAKeeperClient( ctx context.Context, sid string, cfg HAKeeperClientConfig, ) (ProxyHAKeeperClient, error)
NewProxyHAKeeperClient creates a HAKeeper client to be used by a proxy service.
NB: caller could specify options for morpc.Client via ctx.
type RPCRequest ¶
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) ProtoSize ¶
func (r *RPCRequest) ProtoSize() int
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 ¶
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 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 TN nodes and the HAKeeper service via network, it can be considered as the interface layer of the LogService.
func NewService ¶
func NewService( cfg Config, fileService fileservice.FileService, shutdownC chan struct{}, opts ...Option, ) (*Service, error)
func NewServiceWithRetry ¶
func NewServiceWithRetry( genCfg func() Config, fileService fileservice.FileService, shutdownC chan struct{}, opts ...Option, ) (*Service, error)
NewServiceWithRetry mainly used in tests which create new service. If an error occurred and the error is syscall.EADDRINUSE, retry to create a new service instance.
func (*Service) BootstrapHAKeeper ¶ added in v0.6.0
type ShardInfo ¶
type ShardInfo struct {
// ReplicaID is the ID of the replica recommended to use
ReplicaID uint64
// Replicas is a map of replica ID to their service addresses
Replicas map[uint64]string
}
func GetShardInfo ¶ added in v0.6.0
GetShardInfo is to be invoked when querying ShardInfo on a Log Service node. address is usually the reverse proxy that randomly redirect the request to a known Log Service node.
Entries without a resolved ServiceAddress (gossip has delivered the membership entry but not yet the owning store's metadata) are stripped from the returned Replicas map. The leader-known filter likewise treats a leader entry with an empty ServiceAddress as "leader unknown" and returns ok=false. Callers that dial Replicas[id] therefore only ever see addresses that are at least potentially reachable, matching the behavior before Service.getShardInfo stopped filtering on meta presence.
type StandbyClient ¶
func NewStandbyClient ¶
func NewStandbyClient(ctx context.Context, sid string, cfg ClientConfig) (StandbyClient, error)
NewStandbyClient creates a Log Service client which is used by standby shard.
func NewStandbyClientWithRetry ¶
func NewStandbyClientWithRetry( ctx context.Context, sid string, cfg ClientConfig, ) StandbyClient
NewStandbyClientWithRetry creates a Log Service client with retry.
type TNHAKeeperClient ¶ added in v1.0.0
type TNHAKeeperClient interface {
// SendTNHeartbeat sends the specified heartbeat message to the HAKeeper. The
// returned CommandBatch contains Schedule Commands to be executed by the local
// TN store.
SendTNHeartbeat(ctx context.Context, hb pb.TNStoreHeartbeat) (pb.CommandBatch, error)
// contains filtered or unexported methods
}
TNHAKeeperClient is the HAKeeper client used by a TN store.
func NewTNHAKeeperClient ¶ added in v1.0.0
func NewTNHAKeeperClient( ctx context.Context, sid string, cfg HAKeeperClientConfig, ) (TNHAKeeperClient, error)
NewTNHAKeeperClient creates a HAKeeper client to be used by a TN node.
NB: caller could specify options for morpc.Client via ctx.
type Unmarshaler ¶
type WrappedService ¶ added in v0.6.0
type WrappedService struct {
// contains filtered or unexported fields
}
func NewWrappedService ¶ added in v0.6.0
func NewWrappedService( c Config, fileService fileservice.FileService, shutdownC chan struct{}, opts ...Option, ) (*WrappedService, error)
func (*WrappedService) Close ¶ added in v0.6.0
func (w *WrappedService) Close() error
func (*WrappedService) GetClusterState ¶ added in v0.6.0
func (w *WrappedService) GetClusterState() (*pb.CheckerState, error)
func (*WrappedService) GetTaskService ¶ added in v0.6.0
func (w *WrappedService) GetTaskService() (taskservice.TaskService, bool)
func (*WrappedService) ID ¶ added in v0.6.0
func (w *WrappedService) ID() string
func (*WrappedService) IsLeaderHakeeper ¶ added in v0.6.0
func (w *WrappedService) IsLeaderHakeeper() (bool, error)
func (*WrappedService) SetInitialClusterInfo ¶ added in v0.6.0
func (w *WrappedService) SetInitialClusterInfo( logShardNum, tnShartnum, logReplicaNum uint64, ) error
func (*WrappedService) Start ¶ added in v0.6.0
func (w *WrappedService) Start() error
func (*WrappedService) StartHAKeeperReplica ¶ added in v0.6.0
func (w *WrappedService) StartHAKeeperReplica( replicaID uint64, replicas map[uint64]dragonboat.Target, join bool, ) error
StartHAKeeperReplica TODO: start hakeeper with specified log store, specified by caller
Source Files
¶
- archive.go
- client.go
- config.go
- data_sync.go
- errors.go
- hakeeper_client.go
- message.go
- netstat_linux.go
- option.go
- rsm.go
- service.go
- service_bootstrap.go
- service_commands.go
- service_task.go
- service_wrap.go
- shardinfo.go
- snapshot.go
- store.go
- store_hakeeper_check.go
- store_metadata.go
- test_utils.go
- testclient.go
- truncation.go
- utils.go