ddl

package
v0.0.0-...-b26f8fd Latest Latest
Warning

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

Go to latest
Published: May 24, 2016 License: Apache-2.0 Imports: 16 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// CreateDB is the type of the create database plan
	CreateDB = "CreateDB"
	// CreateTable is the type of the create table plan
	CreateTable = "CreateTable"
)
View Source
const (
	Pending = "wait"
	Doing   = "doing"
	Done    = "done"
	Fail    = "fail"
)
View Source
const (
	StatusLock   = "lock"
	StatusUnlock = "unlock"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DDL

type DDL interface {
	CreateDatabase(uname, database string, num int) (id string, rows uint64, err error)
	CreateTable(user, db, sql string, t *meta.Table) (id string, rows uint64, err error)
	DropTable(user, db string, t *meta.Table) (id string, rows uint64, err error)
	DropDatabase(uname, database string) (id string, rows uint64, err error)
}

DDL is responsible for schema change.

type DDLLock

type DDLLock struct {
	Key     string
	Version int64
	ID      string
	// contains filtered or unexported fields
}

DDLLock is a rambo lock

type Lock

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

Lock include a lock and refer count

func (*Lock) Lock

func (l *Lock) Lock()

Lock lock a write lock

func (*Lock) RLock

func (l *Lock) RLock()

RLock lock a read lock

func (*Lock) RUnlock

func (l *Lock) RUnlock() int64

RUnlock unlock a read lock

func (*Lock) UnLock

func (l *Lock) UnLock() int64

UnLock unlock a write lock

type Manage

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

Manage manage handle all ddl stmt

func NewManage

func NewManage(machines []string, localAddr string, info *meta.Info) *Manage

NewManage get a new Manage instance

func (*Manage) BecomeMaster

func (d *Manage) BecomeMaster(key string)

BecomeMaster is election's callback method

func (*Manage) CallLock

func (d *Manage) CallLock(l *DDLLock, result *Result)

CallLock will lock key specific source

func (*Manage) CallUnLock

func (d *Manage) CallUnLock(l *DDLLock, result *Result)

CallUnLock will lock key specific source

func (*Manage) CreateDatabase

func (d *Manage) CreateDatabase(uname, database string, num int) (string, uint64, error)

CreateDatabase will create a new database for the uname's user

func (*Manage) CreateTable

func (d *Manage) CreateTable(user, db, sql string, table *meta.Table) (id string, rows uint64, err error)

CreateTable get a CreateTable task IMPORTANT: only support hash type yet!!!

func (*Manage) DropDatabase

func (d *Manage) DropDatabase(uname, database string) (id string, rows uint64, err error)

DropDatabase get a DropDatabase task

func (*Manage) DropTable

func (d *Manage) DropTable(user, db string, t *meta.Table) (id string, rows uint64, err error)

DropTable get a DropTable task

func (*Manage) GetTaskStatus

func (d *Manage) GetTaskStatus(uname, id string) (TasksStatus, error)

GetTaskStatus will get task's status

func (*Manage) Run

func (d *Manage) Run()

Run bootstrap ddl manage

func (*Manage) SendTask

func (d *Manage) SendTask(t *Task, result *Result) error

SendTask send task to remote server

type Map

type Map map[string]*Lock

Map mapping key and lock

type Plan

type Plan struct {
	SubPlans    []*SubPlan      `json:"sub-plans"`
	LockVersion int64           `json:"lock-version"`
	ID          string          `json:"id"` // uuid
	LockKey     string          `json:"lock-key"`
	DBName      string          `json:"db-name"`
	UserName    string          `json:"user-name"`
	Table       *meta.Table     `json:"table"`
	FinishNodes []*meta.Backend `json:"finish-nodes"`
}

Plan is ddl execute plan

type Result

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

Result is the result of rpc

type SubPlan

type SubPlan struct {
	SubDatabase *meta.Backend `json:"backend"`
	IsDB        bool          `json:"is-db"`
	SQL         string        `json:"sql"`
}

SubPlan is one of ddl's sub plans

type Task

type Task struct {
	Plan *Plan
	Type string
	Seq  string
	// contains filtered or unexported fields
}

Task is DDL execute plan

func (*Task) ID

func (t *Task) ID() string

ID get task's id

type TaskStatus

type TaskStatus struct {
	Status  string   `json:"node-status"`
	Info    string   `json:"info"`
	SubPlan *SubPlan `json:"sub-plan"`
}

type TasksStatus

type TasksStatus map[string]*TaskStatus

TasksStatus is task's status

func NewTasksStatus

func NewTasksStatus() TasksStatus

NewTasksStatus return a new TasksStatus instance

type Wait

type Wait struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Wait is default Waitter impl

func NewWait

func NewWait() *Wait

NewWait get a default Wait pointer

func (*Wait) Add

func (w *Wait) Add(keys string)

Add a source lock. Should first lock big lock, then lock smaller.

func (*Wait) Continue

func (w *Wait) Continue(dl *DDLLock)

Continue unlock a source use write lock. for rpc

func (*Wait) Done

func (w *Wait) Done(keys string)

Done release a lock source. Should first release small source then release bigger.

func (*Wait) GCLock

func (w *Wait) GCLock(inter time.Duration)

GCLock gc unuseful lock

func (*Wait) Wait

func (w *Wait) Wait(dl *DDLLock)

Wait lock a source use write lock. for rpc

type Waitter

type Waitter interface {
	Wait(dl *DDLLock)
	Continue(dl *DDLLock)

	Add(key string)
	Done(key string)
}

Waitter is a Lock manage interface. key is [User]/[DataBase]/[Table]

Jump to

Keyboard shortcuts

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