Rambo: github.com/Alienero/Rambo/ddl Index | Files

package ddl

import "github.com/Alienero/Rambo/ddl"

Index

Package Files

ddl.go lock.go

Constants

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

type DDL Uses

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 Uses

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

DDLLock is a rambo lock

type Lock Uses

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

Lock include a lock and refer count

func (*Lock) Lock Uses

func (l *Lock) Lock()

Lock lock a write lock

func (*Lock) RLock Uses

func (l *Lock) RLock()

RLock lock a read lock

func (*Lock) RUnlock Uses

func (l *Lock) RUnlock() int64

RUnlock unlock a read lock

func (*Lock) UnLock Uses

func (l *Lock) UnLock() int64

UnLock unlock a write lock

type Manage Uses

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

Manage manage handle all ddl stmt

func NewManage Uses

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

NewManage get a new Manage instance

func (*Manage) BecomeMaster Uses

func (d *Manage) BecomeMaster(key string)

BecomeMaster is election's callback method

func (*Manage) CallLock Uses

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

CallLock will lock key specific source

func (*Manage) CallUnLock Uses

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

CallUnLock will lock key specific source

func (*Manage) CreateDatabase Uses

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 Uses

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 Uses

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

DropDatabase get a DropDatabase task

func (*Manage) DropTable Uses

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

DropTable get a DropTable task

func (*Manage) GetTaskStatus Uses

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

GetTaskStatus will get task's status

func (*Manage) Run Uses

func (d *Manage) Run()

Run bootstrap ddl manage

func (*Manage) SendTask Uses

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

SendTask send task to remote server

type Map Uses

type Map map[string]*Lock

Map mapping key and lock

type Plan Uses

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 Uses

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

Result is the result of rpc

type SubPlan Uses

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 Uses

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

Task is DDL execute plan

func (*Task) ID Uses

func (t *Task) ID() string

ID get task's id

type TaskStatus Uses

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

type TasksStatus Uses

type TasksStatus map[string]*TaskStatus

TasksStatus is task's status

func NewTasksStatus Uses

func NewTasksStatus() TasksStatus

NewTasksStatus return a new TasksStatus instance

type Wait Uses

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

Wait is default Waitter impl

func NewWait Uses

func NewWait() *Wait

NewWait get a default Wait pointer

func (*Wait) Add Uses

func (w *Wait) Add(keys string)

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

func (*Wait) Continue Uses

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

Continue unlock a source use write lock. for rpc

func (*Wait) Done Uses

func (w *Wait) Done(keys string)

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

func (*Wait) GCLock Uses

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

GCLock gc unuseful lock

func (*Wait) Wait Uses

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

Wait lock a source use write lock. for rpc

type Waitter Uses

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]

Package ddl imports 16 packages (graph) and is imported by 1 packages. Updated 2016-09-22. Refresh now. Tools for package owners.