server

package
v7.0.4 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2023 License: Apache-2.0 Imports: 127 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// RunInGoTest represents whether we are run code in test.
	RunInGoTest bool
)

Functions

func NewRPCServer

func NewRPCServer(config *config.Config, dom *domain.Domain, sm util.SessionManager) *grpc.Server

NewRPCServer creates a new rpc server.

Types

type Ballast

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

Ballast try to reduce the GC frequency by using Ballast Object

func (*Ballast) GenHTTPHandler

func (b *Ballast) GenHTTPHandler() func(w http.ResponseWriter, r *http.Request)

GenHTTPHandler generate a HTTP handler to get/set the size of this ballast object

func (*Ballast) GetSize

func (b *Ballast) GetSize() int

GetSize get the size of ballast object

func (*Ballast) SetSize

func (b *Ballast) SetSize(newSz int) error

SetSize set the size of ballast object

type ColumnInfo

type ColumnInfo struct {
	Schema             string
	Table              string
	OrgTable           string
	Name               string
	OrgName            string
	ColumnLength       uint32
	Charset            uint16
	Flag               uint16
	Decimal            uint8
	Type               uint8
	DefaultValueLength uint64
	DefaultValue       []byte
}

ColumnInfo contains information of a column

func (*ColumnInfo) Dump

func (column *ColumnInfo) Dump(buffer []byte, d *resultEncoder) []byte

Dump dumps ColumnInfo to bytes.

type CorsHandler

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

CorsHandler adds Cors Header if `cors` config is set.

func (CorsHandler) ServeHTTP

func (h CorsHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)

type FrameItem

type FrameItem struct {
	DBName      string   `json:"db_name"`
	TableName   string   `json:"table_name"`
	TableID     int64    `json:"table_id"`
	IsRecord    bool     `json:"is_record"`
	RecordID    int64    `json:"record_id,omitempty"`
	IndexName   string   `json:"index_name,omitempty"`
	IndexID     int64    `json:"index_id,omitempty"`
	IndexValues []string `json:"index_values,omitempty"`
}

FrameItem includes a index's or record's meta data with table's info.

type IDriver

type IDriver interface {
	// OpenCtx opens an IContext with connection id, client capability, collation, dbname and optionally the tls state.
	OpenCtx(connID uint64, capability uint32, collation uint8, dbname string, tlsState *tls.ConnectionState, extensions *extension.SessionExtensions) (*TiDBContext, error)
}

IDriver opens IContext.

type IndexRegions

type IndexRegions struct {
	Name    string       `json:"name"`
	ID      int64        `json:"id"`
	Regions []RegionMeta `json:"regions"`
}

IndexRegions is the region info for one index.

type MockConn

type MockConn interface {
	// HandleQuery executes a statement
	HandleQuery(ctx context.Context, sql string) error
	// Context gets the TiDBContext
	Context() *TiDBContext
	// Dispatch executes command according to the command type
	Dispatch(ctx context.Context, data []byte) error
	// Close releases resources
	Close()
	// ID returns the connection ID.
	ID() uint64
}

MockConn is a mock connection.

func CreateMockConn

func CreateMockConn(t *testing.T, server *Server) MockConn

CreateMockConn creates a mock connection together with a session.

type OptimizeTraceHandler

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

OptimizeTraceHandler serve http

func (OptimizeTraceHandler) ServeHTTP

func (oth OptimizeTraceHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)

type PlanReplayerHandler

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

PlanReplayerHandler is the handler for dumping plan replayer file.

func (PlanReplayerHandler) ServeHTTP

func (prh PlanReplayerHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)

type PreparedStatement

type PreparedStatement interface {
	// ID returns statement ID
	ID() int

	// Execute executes the statement.
	Execute(context.Context, []expression.Expression) (ResultSet, error)

	// AppendParam appends parameter to the statement.
	AppendParam(paramID int, data []byte) error

	// NumParams returns number of parameters.
	NumParams() int

	// BoundParams returns bound parameters.
	BoundParams() [][]byte

	// SetParamsType sets type for parameters.
	SetParamsType([]byte)

	// GetParamsType returns the type for parameters.
	GetParamsType() []byte

	// StoreResultSet stores ResultSet for subsequent stmt fetching
	StoreResultSet(rs ResultSet)

	// GetResultSet gets ResultSet associated this statement
	GetResultSet() ResultSet

	// Reset removes all bound parameters.
	Reset()

	// Close closes the statement.
	Close() error
}

PreparedStatement is the interface to use a prepared statement.

type RangeDetail

type RangeDetail struct {
	StartKey    []byte `json:"start_key"`
	EndKey      []byte `json:"end_key"`
	StartKeyHex string `json:"start_key_hex"`
	EndKeyHex   string `json:"end_key_hex"`
}

RangeDetail contains detail information about a particular range

type RegionDetail

type RegionDetail struct {
	RangeDetail `json:",inline"`
	RegionID    uint64              `json:"region_id"`
	Frames      []*helper.FrameItem `json:"frames"`
}

RegionDetail is the response data for get region by ID it includes indices and records detail in current region.

type RegionMeta

type RegionMeta struct {
	ID          uint64              `json:"region_id"`
	Leader      *metapb.Peer        `json:"leader"`
	Peers       []*metapb.Peer      `json:"peers"`
	RegionEpoch *metapb.RegionEpoch `json:"region_epoch"`
}

RegionMeta contains a region's peer detail

type ResultSet

type ResultSet interface {
	Columns() []*ColumnInfo
	NewChunk(chunk.Allocator) *chunk.Chunk
	Next(context.Context, *chunk.Chunk) error
	StoreFetchedRows(rows []chunk.Row)
	GetFetchedRows() []chunk.Row
	Close() error
	// IsClosed checks whether the result set is closed.
	IsClosed() bool
}

ResultSet is the result set of an query.

type Server

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

Server is the MySQL protocol server

func CreateMockServer

func CreateMockServer(t *testing.T, store kv.Storage) *Server

CreateMockServer creates a mock server.

func NewServer

func NewServer(cfg *config.Config, driver IDriver) (*Server, error)

NewServer creates a new Server.

func (*Server) CheckOldRunningTxn

func (s *Server) CheckOldRunningTxn(job2ver map[int64]int64, job2ids map[int64]string)

CheckOldRunningTxn implements SessionManager interface.

func (*Server) Close

func (s *Server) Close()

Close closes the server.

func (*Server) ConnectionCount

func (s *Server) ConnectionCount() int

ConnectionCount gets current connection count.

func (*Server) DeleteInternalSession

func (s *Server) DeleteInternalSession(se interface{})

DeleteInternalSession implements SessionManager interface. @param addr The address of a session.session struct variable

func (*Server) GetInternalSessionStartTSList

func (s *Server) GetInternalSessionStartTSList() []uint64

GetInternalSessionStartTSList implements SessionManager interface.

func (*Server) GetMinStartTS

func (s *Server) GetMinStartTS(lowerBound uint64) (ts uint64)

GetMinStartTS implements SessionManager interface.

func (*Server) GetProcessInfo

func (s *Server) GetProcessInfo(id uint64) (*util.ProcessInfo, bool)

GetProcessInfo implements the SessionManager interface.

func (*Server) GetScope

func (s *Server) GetScope(status string) variable.ScopeFlag

GetScope gets the status variables scope.

func (*Server) GracefulDown

func (s *Server) GracefulDown(ctx context.Context, done chan struct{})

GracefulDown waits all clients to close.

func (*Server) InitGlobalConnID

func (s *Server) InitGlobalConnID(serverIDGetter func() uint64)

InitGlobalConnID initialize global connection id.

func (*Server) InternalSessionExists

func (s *Server) InternalSessionExists(se interface{}) bool

InternalSessionExists is used for test

func (*Server) Kill

func (s *Server) Kill(connectionID uint64, query bool)

Kill implements the SessionManager interface.

func (*Server) KillAllConnections

func (s *Server) KillAllConnections()

KillAllConnections kills all connections when server is not gracefully shutdown.

func (*Server) KillNonFlashbackClusterConn

func (s *Server) KillNonFlashbackClusterConn()

KillNonFlashbackClusterConn implements SessionManager interface.

func (*Server) KillSysProcesses

func (s *Server) KillSysProcesses()

KillSysProcesses kill sys processes such as auto analyze.

func (*Server) Run

func (s *Server) Run() error

Run runs the server.

func (*Server) ServerID

func (s *Server) ServerID() uint64

ServerID implements SessionManager interface.

func (*Server) SetDomain

func (s *Server) SetDomain(dom *domain.Domain)

SetDomain use to set the server domain.

func (*Server) ShowProcessList

func (s *Server) ShowProcessList() map[uint64]*util.ProcessInfo

ShowProcessList implements the SessionManager interface.

func (*Server) ShowTxnList

func (s *Server) ShowTxnList() []*txninfo.TxnInfo

ShowTxnList shows all txn info for displaying in `TIDB_TRX`

func (*Server) Stats

func (s *Server) Stats(vars *variable.SessionVars) (map[string]interface{}, error)

Stats returns the server statistics.

func (*Server) StoreInternalSession

func (s *Server) StoreInternalSession(se interface{})

StoreInternalSession implements SessionManager interface. @param addr The address of a session.session struct variable

func (*Server) TryGracefulDown

func (s *Server) TryGracefulDown()

TryGracefulDown will try to gracefully close all connection first with timeout. if timeout, will close all connection directly.

func (*Server) UpdateTLSConfig

func (s *Server) UpdateTLSConfig(cfg *tls.Config)

UpdateTLSConfig implements the SessionManager interface.

type StatsHandler

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

StatsHandler is the handler for dumping statistics.

func (StatsHandler) ServeHTTP

func (sh StatsHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)

type StatsHistoryHandler

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

StatsHistoryHandler is the handler for dumping statistics.

func (StatsHistoryHandler) ServeHTTP

func (sh StatsHistoryHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)

type TableRanges

type TableRanges struct {
	TableName string                 `json:"name"`
	TableID   int64                  `json:"id"`
	Range     RangeDetail            `json:"table"`
	Record    RangeDetail            `json:"record"`
	Index     RangeDetail            `json:"index"`
	Indices   map[string]RangeDetail `json:"indices,omitempty"`
}

TableRanges is the response data for list table's ranges. It contains ranges list for record and indices as well as the whole table.

type TableRegions

type TableRegions struct {
	TableName     string         `json:"name"`
	TableID       int64          `json:"id"`
	RecordRegions []RegionMeta   `json:"record_regions"`
	Indices       []IndexRegions `json:"indices"`
}

TableRegions is the response data for list table's regions. It contains regions list for record and indices.

type TiDBContext

type TiDBContext struct {
	session.Session
	// contains filtered or unexported fields
}

TiDBContext implements QueryCtx.

func (*TiDBContext) Close

func (tc *TiDBContext) Close() error

Close implements QueryCtx Close method.

func (*TiDBContext) DecodeSessionStates

func (tc *TiDBContext) DecodeSessionStates(ctx context.Context, sctx sessionctx.Context, sessionStates *sessionstates.SessionStates) error

DecodeSessionStates implements SessionStatesHandler.DecodeSessionStates interface.

func (*TiDBContext) EncodeSessionStates

func (tc *TiDBContext) EncodeSessionStates(ctx context.Context, sctx sessionctx.Context, sessionStates *sessionstates.SessionStates) error

EncodeSessionStates implements SessionStatesHandler.EncodeSessionStates interface.

func (*TiDBContext) ExecuteStmt

func (tc *TiDBContext) ExecuteStmt(ctx context.Context, stmt ast.StmtNode) (ResultSet, error)

ExecuteStmt implements QueryCtx interface.

func (*TiDBContext) FieldList

func (tc *TiDBContext) FieldList(table string) (columns []*ColumnInfo, err error)

FieldList implements QueryCtx FieldList method.

func (*TiDBContext) GetStatement

func (tc *TiDBContext) GetStatement(stmtID int) PreparedStatement

GetStatement implements QueryCtx GetStatement method.

func (*TiDBContext) GetStmtStats

func (tc *TiDBContext) GetStmtStats() *stmtstats.StatementStats

GetStmtStats implements the sessionctx.Context interface.

func (*TiDBContext) GetWarnings

func (tc *TiDBContext) GetWarnings() []stmtctx.SQLWarn

GetWarnings implements QueryCtx GetWarnings method.

func (*TiDBContext) Prepare

func (tc *TiDBContext) Prepare(sql string) (statement PreparedStatement, columns, params []*ColumnInfo, err error)

Prepare implements QueryCtx Prepare method.

func (*TiDBContext) WarningCount

func (tc *TiDBContext) WarningCount() uint16

WarningCount implements QueryCtx WarningCount method.

type TiDBDriver

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

TiDBDriver implements IDriver.

func NewTiDBDriver

func NewTiDBDriver(store kv.Storage) *TiDBDriver

NewTiDBDriver creates a new TiDBDriver.

func (*TiDBDriver) OpenCtx

func (qd *TiDBDriver) OpenCtx(connID uint64, capability uint32, collation uint8, dbname string, tlsState *tls.ConnectionState, extensions *extension.SessionExtensions) (*TiDBContext, error)

OpenCtx implements IDriver.

type TiDBStatement

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

TiDBStatement implements PreparedStatement.

func (*TiDBStatement) AppendParam

func (ts *TiDBStatement) AppendParam(paramID int, data []byte) error

AppendParam implements PreparedStatement AppendParam method.

func (*TiDBStatement) BoundParams

func (ts *TiDBStatement) BoundParams() [][]byte

BoundParams implements PreparedStatement BoundParams method.

func (*TiDBStatement) Close

func (ts *TiDBStatement) Close() error

Close implements PreparedStatement Close method.

func (*TiDBStatement) Execute

func (ts *TiDBStatement) Execute(ctx context.Context, args []expression.Expression) (rs ResultSet, err error)

Execute implements PreparedStatement Execute method.

func (*TiDBStatement) GetParamsType

func (ts *TiDBStatement) GetParamsType() []byte

GetParamsType implements PreparedStatement GetParamsType method.

func (*TiDBStatement) GetResultSet

func (ts *TiDBStatement) GetResultSet() ResultSet

GetResultSet gets ResultSet associated this statement

func (*TiDBStatement) ID

func (ts *TiDBStatement) ID() int

ID implements PreparedStatement ID method.

func (*TiDBStatement) NumParams

func (ts *TiDBStatement) NumParams() int

NumParams implements PreparedStatement NumParams method.

func (*TiDBStatement) Reset

func (ts *TiDBStatement) Reset()

Reset implements PreparedStatement Reset method.

func (*TiDBStatement) SetParamsType

func (ts *TiDBStatement) SetParamsType(paramsType []byte)

SetParamsType implements PreparedStatement SetParamsType method.

func (*TiDBStatement) StoreResultSet

func (ts *TiDBStatement) StoreResultSet(rs ResultSet)

StoreResultSet stores ResultSet for stmt fetching

type Token

type Token struct {
}

Token is used as a permission to keep on running.

type TokenLimiter

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

TokenLimiter is used to limit the number of concurrent tasks.

func NewTokenLimiter

func NewTokenLimiter(count uint) *TokenLimiter

NewTokenLimiter creates a TokenLimiter with count tokens.

func (*TokenLimiter) Get

func (tl *TokenLimiter) Get() *Token

Get obtains a token.

func (*TokenLimiter) Put

func (tl *TokenLimiter) Put(tk *Token)

Put releases the token.

Jump to

Keyboard shortcuts

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