server

package
v0.9.4 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2021 License: MIT Imports: 40 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnknownCommand         = errors.New("unknown command")
	ErrWrongNumberOfArguments = errors.New("wrong number of arguments")
	ErrDisabled               = errors.New("disabled")
)

Functions

func GetIPv4ForInterfaceName

func GetIPv4ForInterfaceName(ifname string) string

func GetPKAndHashSum added in v0.8.2

func GetPKAndHashSum(cmdName string, cmd redcon.Command) (string, []byte, int, error)

func SLogger

func SLogger() *common.LevelLogger

func SetLogger

func SetLogger(level int32, logger common.Logger)

Types

type ConfigFile

type ConfigFile struct {
	ServerConf ServerConfig `json:"server_conf"`
}

type CustomRaftStatus added in v0.4.3

type CustomRaftStatus struct {
	ID             uint64                  `json:"id,omitempty"`
	Term           uint64                  `json:"term,omitempty"`
	Vote           uint64                  `json:"vote"`
	Commit         uint64                  `json:"commit"`
	Lead           uint64                  `json:"lead"`
	RaftState      string                  `json:"raft_state"`
	Applied        uint64                  `json:"applied"`
	Progress       map[uint64]RaftProgress `json:"progress,omitempty"`
	LeadTransferee uint64                  `json:"lead_transferee"`
}

raft status in raft can not marshal/unmarshal correctly, we redefine it

func (*CustomRaftStatus) Init added in v0.4.3

func (crs *CustomRaftStatus) Init(s raft.Status)

type NamespaceNodeConfig

type NamespaceNodeConfig struct {
	Name           string `json:"name"`
	LocalReplicaID uint64 `json:"local_replica_id"`
}

type RaftProgress added in v0.4.3

type RaftProgress struct {
	Match uint64 `json:"match"`
	Next  uint64 `json:"next"`
	State string `json:"state"`
}

type RaftStatus

type RaftStatus struct {
	LeaderInfo *common.MemberInfo   `json:"leader_info,omitempty"`
	Members    []*common.MemberInfo `json:"members,omitempty"`
	Learners   []*common.MemberInfo `json:"learners,omitempty"`
	RaftStat   CustomRaftStatus     `json:"raft_stat,omitempty"`
}

type Server

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

func NewServer

func NewServer(conf ServerConfig) (*Server, error)

func (*Server) ApplyRaftReqs

func (s *Server) ApplyRaftReqs(ctx context.Context, reqs *syncerpb.RaftReqs) (*syncerpb.RpcErr, error)

func (*Server) DeleteRange added in v0.3.2

func (s *Server) DeleteRange(ns string, dtr node.DeleteTableRange) error

func (*Server) GetApplySnapStatus

func (*Server) GetCoord

func (s *Server) GetCoord() *datanode_coord.DataCoordinator

func (*Server) GetDBStats

func (s *Server) GetDBStats(leaderOnly bool) map[string]string

func (*Server) GetHandleNode added in v0.8.0

func (s *Server) GetHandleNode(ns string, pk []byte, pkSum int, cmdName string,
	cmd redcon.Command) (*node.KVNode, error)

func (*Server) GetHandler

func (s *Server) GetHandler(cmdName string,
	cmd redcon.Command, kvn *node.KVNode) (common.CommandFunc, redcon.Command, error)

func (*Server) GetLogSyncStats

func (s *Server) GetLogSyncStats(leaderOnly bool, srcClusterName string) []metric.LogSyncStats

func (*Server) GetLogSyncStatsInSyncLearner added in v0.4.0

func (s *Server) GetLogSyncStatsInSyncLearner() ([]metric.LogSyncStats, []metric.LogSyncStats)

func (*Server) GetMergeHandlers

func (s *Server) GetMergeHandlers(cmd redcon.Command) (bool, []common.MergeCommandFunc, []redcon.Command, bool, error)

get merge handlers and return haswrite, handlers, commands, canconcurrency, error

func (*Server) GetNamespace

func (s *Server) GetNamespace(ns string, pk []byte) (*node.NamespaceNode, error)

func (*Server) GetNamespaceFromFullName

func (s *Server) GetNamespaceFromFullName(ns string) *node.NamespaceNode

func (*Server) GetNsMgr added in v0.6.3

func (s *Server) GetNsMgr() *node.NamespaceMgr

func (*Server) GetStats

func (s *Server) GetStats(leaderOnly bool, tableDetail bool) metric.ServerStats

func (*Server) GetSyncedRaft

func (s *Server) GetSyncedRaft(ctx context.Context, req *syncerpb.SyncedRaftReq) (*syncerpb.SyncedRaftRsp, error)

func (*Server) GetTableStats added in v0.4.3

func (s *Server) GetTableStats(leaderOnly bool, table string) map[string]metric.TableStats

func (*Server) GetWALDBStats added in v0.6.0

func (s *Server) GetWALDBStats(leaderOnly bool) map[string]map[string]interface{}

func (*Server) GetWriteHandler added in v0.8.0

func (s *Server) GetWriteHandler(cmdName string,
	cmd redcon.Command, kvn *node.KVNode) (common.WriteCommandFunc, redcon.Command, error)

func (*Server) InitKVNamespace

func (s *Server) InitKVNamespace(id uint64, conf *node.NamespaceConfig, join bool) (*node.NamespaceNode, error)

func (*Server) IsPeerRemoved

func (s *Server) IsPeerRemoved(peerID uint64) bool

func (*Server) NotifyApplySnap

func (s *Server) NotifyApplySnap(ctx context.Context, req *syncerpb.RaftApplySnapReq) (*syncerpb.RpcErr, error)

func (*Server) NotifyTransferSnap

func (s *Server) NotifyTransferSnap(ctx context.Context, req *syncerpb.RaftApplySnapReq) (*syncerpb.RpcErr, error)

func (*Server) Process

func (s *Server) Process(ctx context.Context, m raftpb.Message) error

implement the Raft interface for transport

func (*Server) ReportSnapshot

func (s *Server) ReportSnapshot(id uint64, gp raftpb.Group, status raft.SnapshotStatus)

func (*Server) ReportUnreachable

func (s *Server) ReportUnreachable(id uint64, group raftpb.Group)

func (*Server) RestartAsStandalone

func (s *Server) RestartAsStandalone(fullNamespace string) error

func (*Server) SaveDBFrom

func (s *Server) SaveDBFrom(r io.Reader, msg raftpb.Message) (int64, error)

implement the snapshotter interface for transport

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, req *http.Request)

func (*Server) Start

func (s *Server) Start()

func (*Server) Stop

func (s *Server) Stop()

type ServerConfig

type ServerConfig struct {
	// this cluster id is used for server transport to tell
	// different global cluster
	ClusterID               string            `json:"cluster_id"`
	EtcdClusterAddresses    string            `json:"etcd_cluster_addresses"`
	BroadcastInterface      string            `json:"broadcast_interface"`
	BroadcastAddr           string            `json:"broadcast_addr"`
	MetricAddr              string            `json:"metric_addr"`
	RedisAPIPort            int               `json:"redis_api_port"`
	HttpAPIPort             int               `json:"http_api_port"`
	GrpcAPIPort             int               `json:"grpc_api_port"`
	ProfilePort             int               `json:"profile_port"`
	DataDir                 string            `json:"data_dir"`
	LogDir                  string            `json:"log_dir"`
	RemoteLogAddr           string            `json:"remote_log_addr"`
	DataRsyncModule         string            `json:"data_rsync_module"`
	LocalRaftAddr           string            `json:"local_raft_addr"`
	Tags                    map[string]string `json:"tags"`
	SyncerWriteOnly         bool              `json:"syncer_write_only"`
	SyncerNormalInit        bool              `json:"syncer_normal_init"`
	LearnerRole             string            `json:"learner_role"`
	RemoteSyncCluster       string            `json:"remote_sync_cluster"`
	StateMachineType        string            `json:"state_machine_type"`
	RsyncLimit              int64             `json:"rsync_limit"`
	DefaultSnapCount        int               `json:"default_snap_count"`
	DefaultSnapCatchup      int               `json:"default_snap_catchup"`
	KeepBackup              int               `json:"keep_backup"`
	KeepWAL                 int               `json:"keep_wal"`
	UseRocksWAL             bool              `json:"use_rocks_wal"`
	SharedRocksWAL          bool              `json:"shared_rocks_wal"`
	UseRedisV2              bool              `json:"use_redis_v2"`
	SlowLimiterRefuseCostMs int64             `json:"slow_limiter_refuse_cost_ms"`

	ElectionTick int `json:"election_tick"`
	TickMs       int `json:"tick_ms"`
	// default rocksdb options, can be override by namespace config
	RocksDBOpts    engine.RockOptions    `json:"rocksdb_opts"`
	WALRocksDBOpts engine.RockOptions    `json:"wal_rocksdb_opts"`
	Namespaces     []NamespaceNodeConfig `json:"namespaces"`
	MaxScanJob     int32                 `json:"max_scan_job"`
}

Jump to

Keyboard shortcuts

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