Documentation ¶
Index ¶
- Constants
- Variables
- func HandleStatus(mux *http.ServeMux)
- type Agent
- type AgentPool
- type Config
- type DeployMapper
- type Lock
- type LockKeeper
- type RateLimitConfig
- type Server
- func (s *Server) BreakWorkerDDLLock(ctx context.Context, req *pb.BreakWorkerDDLLockRequest) (*pb.BreakWorkerDDLLockResponse, error)
- func (s *Server) CheckTask(ctx context.Context, req *pb.CheckTaskRequest) (*pb.CheckTaskResponse, error)
- func (s *Server) Close()
- func (s *Server) HandleHTTPApis(ctx context.Context, mux *http.ServeMux) error
- func (s *Server) HandleSQLs(ctx context.Context, req *pb.HandleSQLsRequest) (*pb.HandleSQLsResponse, error)
- func (s *Server) MigrateWorkerRelay(ctx context.Context, req *pb.MigrateWorkerRelayRequest) (*pb.CommonWorkerResponse, error)
- func (s *Server) OperateTask(ctx context.Context, req *pb.OperateTaskRequest) (*pb.OperateTaskResponse, error)
- func (s *Server) OperateWorkerRelayTask(ctx context.Context, req *pb.OperateWorkerRelayRequest) (*pb.OperateWorkerRelayResponse, error)
- func (s *Server) PurgeWorkerRelay(ctx context.Context, req *pb.PurgeWorkerRelayRequest) (*pb.PurgeWorkerRelayResponse, error)
- func (s *Server) QueryError(ctx context.Context, req *pb.QueryErrorListRequest) (*pb.QueryErrorListResponse, error)
- func (s *Server) QueryStatus(ctx context.Context, req *pb.QueryStatusListRequest) (*pb.QueryStatusListResponse, error)
- func (s *Server) RefreshWorkerTasks(ctx context.Context, req *pb.RefreshWorkerTasksRequest) (*pb.RefreshWorkerTasksResponse, error)
- func (s *Server) ShowDDLLocks(ctx context.Context, req *pb.ShowDDLLocksRequest) (*pb.ShowDDLLocksResponse, error)
- func (s *Server) Start() error
- func (s *Server) StartTask(ctx context.Context, req *pb.StartTaskRequest) (*pb.StartTaskResponse, error)
- func (s *Server) SwitchWorkerRelayMaster(ctx context.Context, req *pb.SwitchWorkerRelayMasterRequest) (*pb.SwitchWorkerRelayMasterResponse, error)
- func (s *Server) UnlockDDLLock(ctx context.Context, req *pb.UnlockDDLLockRequest) (*pb.UnlockDDLLockResponse, error)
- func (s *Server) UpdateMasterConfig(ctx context.Context, req *pb.UpdateMasterConfigRequest) (*pb.UpdateMasterConfigResponse, error)
- func (s *Server) UpdateTask(ctx context.Context, req *pb.UpdateTaskRequest) (*pb.UpdateTaskResponse, error)
- func (s *Server) UpdateWorkerRelayConfig(ctx context.Context, req *pb.UpdateWorkerRelayConfigRequest) (*pb.CommonWorkerResponse, error)
Constants ¶
const ( DefaultRate float64 = 10 DefaultBurst = 40 ErrorNoEmitToken = "fail to get emit opportunity for %s" )
rate limit related constant value
Variables ¶
var SampleConfigFile string
SampleConfigFile is sample config file of dm-master later we can read it from dm/master/dm-master.toml and assign it to SampleConfigFile while we build dm-master
Functions ¶
func HandleStatus ¶
HandleStatus handles functions for getting status by HTTP request
Types ¶
type AgentPool ¶
type AgentPool struct {
// contains filtered or unexported fields
}
AgentPool is a pool to control communication with dm-workers It provides rate limit control for agent acquire, including dispatch rate r and permits bursts of at most b tokens. caller shouldn't to hold agent to avoid deadlock
func NewAgentPool ¶
func NewAgentPool(cfg *RateLimitConfig) *AgentPool
NewAgentPool returns a agent pool
func (*AgentPool) Apply ¶
Apply applies for a agent if ctx is canceled before we get an agent, returns nil
type Config ¶
type Config struct { *flag.FlagSet `json:"-"` LogLevel string `toml:"log-level" json:"log-level"` LogFile string `toml:"log-file" json:"log-file"` LogRotate string `toml:"log-rotate" json:"log-rotate"` RPCTimeoutStr string `toml:"rpc-timeout" json:"rpc-timeout"` RPCTimeout time.Duration `json:"-"` RPCRateLimit float64 `toml:"rpc-rate-limit" json:"rpc-rate-limit"` RPCRateBurst int `toml:"rpc-rate-burst" json:"rpc-rate-burst"` MasterAddr string `toml:"master-addr" json:"master-addr"` Deploy []*DeployMapper `toml:"deploy" json:"-"` DeployMap map[string]string `json:"deploy"` ConfigFile string `json:"config-file"` // contains filtered or unexported fields }
Config is the configuration for dm-master
func (*Config) UpdateConfigFile ¶
UpdateConfigFile write config to local file if ConfigFile is nil, it will write to dm-master.toml
type DeployMapper ¶
type DeployMapper struct { MySQL string `toml:"mysql-instance" json:"mysql-instance"` // deprecated, use source-id instead Source string `toml:"source-id" json:"source-id"` // represents a MySQL/MariaDB instance or a replica group Worker string `toml:"dm-worker" json:"dm-worker"` }
DeployMapper defines dm-worker's deploy mapper info: source id -> dm-worker ${host:ip}
func (*DeployMapper) Verify ¶
func (d *DeployMapper) Verify() error
Verify verifies deploy configuration
type Lock ¶
type Lock struct { sync.RWMutex ID string // lock's ID, constructed from task's name and SQL statement Task string // lock's corresponding task name Owner string // lock's Owner, a dm-worker Stmts []string // SQL statement AutoRetry sync2.AtomicBool // whether re-try resolve at intervals Resolving sync2.AtomicBool // whether the lock is resolving // contains filtered or unexported fields }
Lock used for process synchronization
type LockKeeper ¶
LockKeeper used to keep and handle DDL lock
func (*LockKeeper) FindLock ¶
func (lk *LockKeeper) FindLock(lockID string) *Lock
FindLock finds a lock
func (*LockKeeper) Locks ¶
func (lk *LockKeeper) Locks() map[string]*Lock
Locks returns a copy of all locks
func (*LockKeeper) RemoveLock ¶
func (lk *LockKeeper) RemoveLock(lockID string) bool
RemoveLock removes a lock
type RateLimitConfig ¶
type RateLimitConfig struct {
// contains filtered or unexported fields
}
RateLimitConfig holds rate limit config
type Server ¶
Server handles RPC requests for dm-master
func (*Server) BreakWorkerDDLLock ¶
func (s *Server) BreakWorkerDDLLock(ctx context.Context, req *pb.BreakWorkerDDLLockRequest) (*pb.BreakWorkerDDLLockResponse, error)
BreakWorkerDDLLock implements MasterServer.BreakWorkerDDLLock
func (*Server) CheckTask ¶
func (s *Server) CheckTask(ctx context.Context, req *pb.CheckTaskRequest) (*pb.CheckTaskResponse, error)
CheckTask checks legality of task configuration
func (*Server) Close ¶
func (s *Server) Close()
Close close the RPC server, this function can be called multiple times
func (*Server) HandleHTTPApis ¶
HandleHTTPApis handles http apis and translate to grpc request
func (*Server) HandleSQLs ¶
func (s *Server) HandleSQLs(ctx context.Context, req *pb.HandleSQLsRequest) (*pb.HandleSQLsResponse, error)
HandleSQLs implements MasterServer.HandleSQLs
func (*Server) MigrateWorkerRelay ¶
func (s *Server) MigrateWorkerRelay(ctx context.Context, req *pb.MigrateWorkerRelayRequest) (*pb.CommonWorkerResponse, error)
MigrateWorkerRelay migrates dm-woker relay unit
func (*Server) OperateTask ¶
func (s *Server) OperateTask(ctx context.Context, req *pb.OperateTaskRequest) (*pb.OperateTaskResponse, error)
OperateTask implements MasterServer.OperateTask
func (*Server) OperateWorkerRelayTask ¶
func (s *Server) OperateWorkerRelayTask(ctx context.Context, req *pb.OperateWorkerRelayRequest) (*pb.OperateWorkerRelayResponse, error)
OperateWorkerRelayTask implements MasterServer.OperateWorkerRelayTask
func (*Server) PurgeWorkerRelay ¶
func (s *Server) PurgeWorkerRelay(ctx context.Context, req *pb.PurgeWorkerRelayRequest) (*pb.PurgeWorkerRelayResponse, error)
PurgeWorkerRelay implements MasterServer.PurgeWorkerRelay
func (*Server) QueryError ¶
func (s *Server) QueryError(ctx context.Context, req *pb.QueryErrorListRequest) (*pb.QueryErrorListResponse, error)
QueryError implements MasterServer.QueryError
func (*Server) QueryStatus ¶
func (s *Server) QueryStatus(ctx context.Context, req *pb.QueryStatusListRequest) (*pb.QueryStatusListResponse, error)
QueryStatus implements MasterServer.QueryStatus
func (*Server) RefreshWorkerTasks ¶
func (s *Server) RefreshWorkerTasks(ctx context.Context, req *pb.RefreshWorkerTasksRequest) (*pb.RefreshWorkerTasksResponse, error)
RefreshWorkerTasks implements MasterServer.RefreshWorkerTasks
func (*Server) ShowDDLLocks ¶
func (s *Server) ShowDDLLocks(ctx context.Context, req *pb.ShowDDLLocksRequest) (*pb.ShowDDLLocksResponse, error)
ShowDDLLocks implements MasterServer.ShowDDLLocks
func (*Server) StartTask ¶
func (s *Server) StartTask(ctx context.Context, req *pb.StartTaskRequest) (*pb.StartTaskResponse, error)
StartTask implements MasterServer.StartTask
func (*Server) SwitchWorkerRelayMaster ¶
func (s *Server) SwitchWorkerRelayMaster(ctx context.Context, req *pb.SwitchWorkerRelayMasterRequest) (*pb.SwitchWorkerRelayMasterResponse, error)
SwitchWorkerRelayMaster implements MasterServer.SwitchWorkerRelayMaster
func (*Server) UnlockDDLLock ¶
func (s *Server) UnlockDDLLock(ctx context.Context, req *pb.UnlockDDLLockRequest) (*pb.UnlockDDLLockResponse, error)
UnlockDDLLock implements MasterServer.UnlockDDLLock
func (*Server) UpdateMasterConfig ¶
func (s *Server) UpdateMasterConfig(ctx context.Context, req *pb.UpdateMasterConfigRequest) (*pb.UpdateMasterConfigResponse, error)
UpdateMasterConfig implements MasterServer.UpdateConfig
func (*Server) UpdateTask ¶
func (s *Server) UpdateTask(ctx context.Context, req *pb.UpdateTaskRequest) (*pb.UpdateTaskResponse, error)
UpdateTask implements MasterServer.UpdateTask
func (*Server) UpdateWorkerRelayConfig ¶
func (s *Server) UpdateWorkerRelayConfig(ctx context.Context, req *pb.UpdateWorkerRelayConfigRequest) (*pb.CommonWorkerResponse, error)
UpdateWorkerRelayConfig updates config for relay and (dm-worker)