mock_ms

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2018 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Copyright 2016 PingCAP, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	HTTP_DB_NAME    = "dbName"
	HTTP_DB_ID      = "dbId"
	HTTP_TABLE_NAME = "tableName"
	HTTP_TABLE_ID   = "tableId"
	HTTP_CLUSTER_ID = "clusterId"
	HTTP_RANGE_ID   = "rangeId"
	HTTP_NODE_ID    = "nodeId"
	HTTP_PEER_ID    = "peerId"
	HTTP_NAME       = "name"
	HTTP_PROPERTIES = "properties"
	HTTP_PKDUPCHECK = "pkDupCheck"
)

Variables

View Source
var (
	ErrNotExistDatabase         = errors.New("database not exist")
	ErrNotExistTable            = errors.New("table not exist")
	ErrNotExistRange            = errors.New("range not exist")
	ErrInvalidColumn            = errors.New("invalid column")
	ErrColumnNameTooLong        = errors.New("column name is too long")
	ErrDupColumnName            = errors.New("duplicate column name")
	ErrPkMustNotNull            = errors.New("primary key must be not nullable")
	ErrMissingPk                = errors.New("missing primary key")
	ErrPkMustNotSetDefaultValue = errors.New("primary key should not set defaultvalue")
	ErrNotFound                 = errors.New("entity not found")
)
View Source
var (
	MAX_COLUMN_NAME_LENGTH = 128
)
View Source
var PREFIX_AUTO_FAILOVER_TABLE string = fmt.Sprintf("$auto_failover_table_%d")
View Source
var PREFIX_AUTO_TRANSFER_TABLE string = fmt.Sprintf("$auto_transfer_table_%d")

Functions

func EditProperties

func EditProperties(properties string) ([]*metapb.Column, error)

func ParseProperties

func ParseProperties(properties string) ([]*metapb.Column, []*metapb.Column, error)

func ToTableProperty

func ToTableProperty(cols []*metapb.Column) (string, error)

Types

type ByPrimaryKey

type ByPrimaryKey []*metapb.Column

func (ByPrimaryKey) Len

func (s ByPrimaryKey) Len() int

func (ByPrimaryKey) Less

func (s ByPrimaryKey) Less(i, j int) bool

func (ByPrimaryKey) Swap

func (s ByPrimaryKey) Swap(i, j int)

type Cluster

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

func NewCluster

func NewCluster(rpc, host string) *Cluster

func (*Cluster) AddColumn

func (*Cluster) AskSplit

func (*Cluster) CreateDatabase

func (*Cluster) CreateTable

func (*Cluster) GetColumnById

func (*Cluster) GetColumnByName

func (*Cluster) GetColumns

func (*Cluster) GetDB

func (c *Cluster) GetDB(ctx context.Context, req *mspb.GetDBRequest) (*mspb.GetDBResponse, error)

func (*Cluster) GetMSLeader

func (*Cluster) GetNode

func (c *Cluster) GetNode(ctx context.Context, req *mspb.GetNodeRequest) (*mspb.GetNodeResponse, error)

func (*Cluster) GetNodeId

func (*Cluster) GetRoute

func (*Cluster) GetTable

func (*Cluster) GetTableById

func (*Cluster) NodeHeartbeat

func (*Cluster) NodeLogin

func (*Cluster) RangeHeartbeat

func (*Cluster) ReportSplit

func (*Cluster) SetDb

func (c *Cluster) SetDb(db *metapb.DataBase)

func (*Cluster) SetNode

func (c *Cluster) SetNode(node *metapb.Node)

func (*Cluster) SetRange

func (c *Cluster) SetRange(r *metapb.Range)

func (*Cluster) SetTable

func (c *Cluster) SetTable(t *metapb.Table)

func (*Cluster) Start

func (c *Cluster) Start()

func (*Cluster) Stop

func (c *Cluster) Stop()

type CreateTable

type CreateTable struct {
	*Table
	// contains filtered or unexported fields
}

func NewCreateTable

func NewCreateTable(t *Table, n uint64) *CreateTable

type CreateTableCache

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

func NewCreateTableCache

func NewCreateTableCache() *CreateTableCache

func (*CreateTableCache) Add

func (tc *CreateTableCache) Add(t *CreateTable)

func (*CreateTableCache) Delete

func (tc *CreateTableCache) Delete(id uint64)

func (*CreateTableCache) FindTable

func (tc *CreateTableCache) FindTable(id uint64) (*CreateTable, bool)

func (*CreateTableCache) GetAllTable

func (tc *CreateTableCache) GetAllTable() []*CreateTable

func (*CreateTableCache) Size

func (tc *CreateTableCache) Size() int

type Database

type Database struct {
	*metapb.DataBase
	// contains filtered or unexported fields
}

func NewDatabase

func NewDatabase(db *metapb.DataBase) *Database

func (*Database) AddTable

func (db *Database) AddTable(t *Table)

func (*Database) DeleteTableById

func (db *Database) DeleteTableById(id uint64) error

real delete

func (*Database) DeleteTableByName

func (db *Database) DeleteTableByName(name string) error

仅仅从当前table列表中删除

func (*Database) FindTable

func (db *Database) FindTable(name string) (*Table, bool)

查找当前的table

func (*Database) FindTableById

func (db *Database) FindTableById(id uint64) (*Table, bool)

查找存在的table

func (*Database) GetAllTable

func (db *Database) GetAllTable() []*Table

func (*Database) Lock

func (db *Database) Lock()

func (*Database) Name

func (db *Database) Name() string

func (*Database) UnLock

func (db *Database) UnLock()

type DbCache

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

func NewDbCache

func NewDbCache() *DbCache

func (*DbCache) Add

func (dc *DbCache) Add(d *Database)

func (*DbCache) Delete

func (dc *DbCache) Delete(name string)

func (*DbCache) FindDb

func (dc *DbCache) FindDb(name string) (*Database, bool)

func (*DbCache) FindDbById

func (dc *DbCache) FindDbById(id uint64) (*Database, bool)

func (*DbCache) GetAllDatabase

func (dc *DbCache) GetAllDatabase() []*Database

func (*DbCache) Size

func (dc *DbCache) Size() int

type GlobalTableCache

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

func NewGlobalTableCache

func NewGlobalTableCache() *GlobalTableCache

func (*GlobalTableCache) Add

func (tc *GlobalTableCache) Add(t *Table)

func (*GlobalTableCache) DeleteById

func (tc *GlobalTableCache) DeleteById(id uint64)

func (*GlobalTableCache) FindTableById

func (tc *GlobalTableCache) FindTableById(id uint64) (*Table, bool)

func (*GlobalTableCache) GetAllTable

func (tc *GlobalTableCache) GetAllTable() []*Table

func (*GlobalTableCache) Size

func (tc *GlobalTableCache) Size() int

type HttpReply

type HttpReply httpReply

type Range

type Range struct {
	*metapb.Range
	Leader      *metapb.Peer
	PeersStatus []*mspb.PeerStatus

	State metapb.RangeState
	// contains filtered or unexported fields
}

func NewRange

func NewRange(r *metapb.Range) *Range

func (*Range) GetLeader

func (r *Range) GetLeader() *metapb.Peer

func (*Range) GetPeer

func (r *Range) GetPeer(nodeId uint64) *metapb.Peer

func (*Range) GetPeerById

func (r *Range) GetPeerById(peerId uint64) *metapb.Peer

func (*Range) ID

func (r *Range) ID() uint64

func (*Range) SString

func (r *Range) SString() string

type RangeCache

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

func NewRangeCache

func NewRangeCache() *RangeCache

func (*RangeCache) Add

func (rc *RangeCache) Add(r *Range)

func (*RangeCache) Delete

func (rc *RangeCache) Delete(id uint64)

func (*RangeCache) FindRangeByID

func (rc *RangeCache) FindRangeByID(id uint64) (*Range, bool)

func (*RangeCache) GetAllRange

func (rc *RangeCache) GetAllRange() []*Range

func (*RangeCache) GetRandomRange

func (rc *RangeCache) GetRandomRange() *Range

func (*RangeCache) MultipleSearchRanges

func (rc *RangeCache) MultipleSearchRanges(key []byte, num int) ([]*Range, bool)

func (*RangeCache) SearchRange

func (rc *RangeCache) SearchRange(key []byte) (*Range, bool)

func (*RangeCache) Size

func (rc *RangeCache) Size() int

type Table

type Table struct {
	*metapb.Table
	// contains filtered or unexported fields
}

func NewTable

func NewTable(t *metapb.Table) *Table

func (*Table) AddRange

func (t *Table) AddRange(r *Range)

func (*Table) DeleteRange

func (t *Table) DeleteRange(id uint64)

func (*Table) FindRange

func (t *Table) FindRange(id uint64) (*Range, bool)

func (*Table) GenColId

func (t *Table) GenColId() uint64

func (*Table) GetAllRanges

func (t *Table) GetAllRanges() []*Range

func (*Table) GetColumnById

func (t *Table) GetColumnById(id uint64) (*metapb.Column, bool)

func (*Table) GetColumnByName

func (t *Table) GetColumnByName(name string) (*metapb.Column, bool)

func (*Table) GetColumns

func (t *Table) GetColumns() []*metapb.Column

func (*Table) GetPkColumns

func (t *Table) GetPkColumns() []*metapb.Column

func (*Table) GetRangeNumber

func (t *Table) GetRangeNumber() int

func (*Table) MergeColumn

func (t *Table) MergeColumn(source []*metapb.Column, cluster *Cluster) error

func (*Table) MultipleSearchRanges

func (t *Table) MultipleSearchRanges(key []byte, num int) ([]*Range, bool)

func (*Table) Name

func (t *Table) Name() string

func (*Table) SearchRange

func (t *Table) SearchRange(key []byte) (*Range, bool)

func (*Table) UpdateSchema

func (t *Table) UpdateSchema(columns []*metapb.Column) ([]*metapb.Column, error)

type TableCache

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

func NewTableCache

func NewTableCache() *TableCache

func (*TableCache) Add

func (tc *TableCache) Add(t *Table)

func (*TableCache) DeleteById

func (tc *TableCache) DeleteById(id uint64)

func (*TableCache) DeleteByName

func (tc *TableCache) DeleteByName(name string)

func (*TableCache) FindTableById

func (tc *TableCache) FindTableById(id uint64) (*Table, bool)

func (*TableCache) FindTableByName

func (tc *TableCache) FindTableByName(name string) (*Table, bool)

func (*TableCache) GetAllTable

func (tc *TableCache) GetAllTable() []*Table

func (*TableCache) Size

func (tc *TableCache) Size() int

type TableProperty

type TableProperty struct {
	Columns []*metapb.Column `json:"columns"`
	Regxs   []*metapb.Column `json:"regxs"`
}

Jump to

Keyboard shortcuts

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