Documentation ¶
Index ¶
- Constants
- Variables
- type BackupMetadata
- func (b *BackupMetadata) AddReplicaset(clusterID, replName, replUUID, dbBackupName, oplogBackupName string) error
- func (b *BackupMetadata) JSON() ([]byte, error)
- func (b *BackupMetadata) LastOplogTs() int64
- func (b *BackupMetadata) Metadata() *pb.BackupMetadata
- func (b *BackupMetadata) NamePrefix() string
- func (b *BackupMetadata) RemoveReplicaset(replName string) error
- func (b *BackupMetadata) SetLastOplogTs(ts int64)
- func (b *BackupMetadata) WriteMetadataToFile(name string) error
- type Client
- func (c *Client) CanRestoreBackup(backupType pb.BackupType, name, storageName string) (pb.CanRestoreBackupResponse, error)
- func (c *Client) GetBackupSource() (string, error)
- func (c *Client) GetCmdLineOpts() (*pb.CmdLineOpts, error)
- func (c *Client) GetMongoDBVersion() (string, error)
- func (c *Client) GetStatus() (pb.Status, error)
- func (c *Client) GetStoragesInfo() ([]*pb.StorageInfo, error)
- func (c *Client) Status() pb.Status
- type MessagesServer
- func (s *MessagesServer) AddError(err error)
- func (s *MessagesServer) AllServersCmdLineOpts() ([]*pb.Server, error)
- func (s *MessagesServer) BackupSourceByReplicaset() (map[string]*Client, error)
- func (s *MessagesServer) BackupSourceNameByReplicaset() (map[string]string, error)
- func (s *MessagesServer) BalancerStatus() *pb.BalancerStatus
- func (s *MessagesServer) Clients() map[string]Client
- func (s *MessagesServer) ClientsByReplicaset() map[string][]Client
- func (s *MessagesServer) DBBackupFinished(ctx context.Context, msg *pb.DBBackupFinishStatus) (*pb.DBBackupFinishedAck, error)
- func (s *MessagesServer) IsShardedSystem() bool
- func (s *MessagesServer) LastBackupErrors() error
- func (s *MessagesServer) LastBackupMetadata() *BackupMetadata
- func (s *MessagesServer) LastOplogTs() int64
- func (s *MessagesServer) ListBackups() (map[string]pb.BackupMetadata, error)
- func (s *MessagesServer) ListStorages() (map[string]StorageEntry, error)
- func (s *MessagesServer) Logging(stream pb.Messages_LoggingServer) error
- func (s *MessagesServer) MessagesChat(stream pb.Messages_MessagesChatServer) error
- func (s *MessagesServer) OplogBackupFinished(ctx context.Context, msg *pb.OplogBackupFinishStatus) (*pb.OplogBackupFinishedAck, error)
- func (s *MessagesServer) RefreshClients() error
- func (s *MessagesServer) ReplicasetsRunningDBBackup() map[string]*Client
- func (s *MessagesServer) ReplicasetsRunningOplogBackup() map[string]*Client
- func (s *MessagesServer) ReplicasetsRunningRestore() map[string]*Client
- func (s *MessagesServer) RestoreBackUp(bm *pb.BackupMetadata, storageName string, skipUsersAndRoles bool) error
- func (s *MessagesServer) RestoreBackupFromMetadataFile(filename, storageName string, skipUsersAndRoles bool) error
- func (s *MessagesServer) RestoreCompleted(ctx context.Context, msg *pb.RestoreComplete) (*pb.RestoreCompletedAck, error)
- func (s *MessagesServer) RestoreSourcesByReplicaset(bm *pb.BackupMetadata, storageName string) (map[string]RestoreSource, error)
- func (s *MessagesServer) StartBackup(opts *pb.StartBackup) error
- func (s *MessagesServer) StartBalancer() error
- func (s *MessagesServer) Stop()
- func (s *MessagesServer) StopBalancer() error
- func (s *MessagesServer) StopOplogTail() error
- func (s *MessagesServer) ValidateReplicasetAgents() error
- func (s *MessagesServer) WaitBackupFinish() error
- func (s *MessagesServer) WaitForEvent(event int, timeout time.Duration) (interface{}, error)
- func (s *MessagesServer) WaitOplogBackupFinish() error
- func (s *MessagesServer) WaitRestoreFinish() error
- func (s *MessagesServer) WorkDir() string
- func (s *MessagesServer) WriteBackupMetadata() error
- func (s *MessagesServer) WriteServerBackupMetadata(filename string) error
- type RestoreSource
- type StorageEntry
Constants ¶
const ( EventBackupFinish = iota EventOplogFinish EventRestoreFinish // If this list is updated, please also update the isValidEvent and eventName functions BackupFinishedEvent = 0 BackupStartedEvent = 1 BeforeBalancerStartEvent = 2 AfterBalancerStartEvent = 3 BeforeBalancerStopEvent = 4 AfterBalancerStopEvent = 5 WaitForever = -1 )
Variables ¶
Functions ¶
This section is empty.
Types ¶
type BackupMetadata ¶
type BackupMetadata struct {
// contains filtered or unexported fields
}
func LoadMetadataFromFile ¶
func LoadMetadataFromFile(name string) (*BackupMetadata, error)
func NewBackupMetadata ¶
func NewBackupMetadata(opts *pb.StartBackup) *BackupMetadata
func (*BackupMetadata) AddReplicaset ¶
func (b *BackupMetadata) AddReplicaset(clusterID, replName, replUUID, dbBackupName, oplogBackupName string) error
AddReplicaset adds backup info for a replicaset using the replicaset name as the key
func (*BackupMetadata) JSON ¶ added in v0.4.0
func (b *BackupMetadata) JSON() ([]byte, error)
func (*BackupMetadata) LastOplogTs ¶ added in v0.4.0
func (b *BackupMetadata) LastOplogTs() int64
func (*BackupMetadata) Metadata ¶
func (b *BackupMetadata) Metadata() *pb.BackupMetadata
func (*BackupMetadata) NamePrefix ¶ added in v0.4.0
func (b *BackupMetadata) NamePrefix() string
func (*BackupMetadata) RemoveReplicaset ¶
func (b *BackupMetadata) RemoveReplicaset(replName string) error
func (*BackupMetadata) SetLastOplogTs ¶ added in v0.4.0
func (b *BackupMetadata) SetLastOplogTs(ts int64)
func (*BackupMetadata) WriteMetadataToFile ¶
func (b *BackupMetadata) WriteMetadataToFile(name string) error
WriteMetadataToFile writes the backup metadata to a file as JSON
type Client ¶
type Client struct { ID string `json:"id"` NodeType pb.NodeType `json:"node_type"` NodeName string `json:"node_name"` ClusterID string `json:"cluster_id"` ReplicasetName string `json:"replicaset_name"` ReplicasetUUID string `json:"replicaset_uuid"` ReplicasetVersion int32 `json:"replicaset_version"` LastCommandSent string `json:"last_command_sent"` LastSeen time.Time `json:"last_seen"` // contains filtered or unexported fields }
func (*Client) CanRestoreBackup ¶
func (c *Client) CanRestoreBackup(backupType pb.BackupType, name, storageName string) ( pb.CanRestoreBackupResponse, error)
func (*Client) GetBackupSource ¶
func (*Client) GetCmdLineOpts ¶ added in v0.4.0
func (c *Client) GetCmdLineOpts() (*pb.CmdLineOpts, error)
func (*Client) GetMongoDBVersion ¶ added in v0.4.0
func (*Client) GetStoragesInfo ¶ added in v0.3.0
func (c *Client) GetStoragesInfo() ([]*pb.StorageInfo, error)
type MessagesServer ¶
type MessagesServer struct {
// contains filtered or unexported fields
}
func NewMessagesServer ¶
func NewMessagesServer(workDir string) *MessagesServer
func NewMessagesServerWithClientLogging ¶
func NewMessagesServerWithClientLogging(workDir string, logger *logrus.Logger) *MessagesServer
func (*MessagesServer) AddError ¶ added in v0.4.0
func (s *MessagesServer) AddError(err error)
func (*MessagesServer) AllServersCmdLineOpts ¶ added in v0.4.0
func (s *MessagesServer) AllServersCmdLineOpts() ([]*pb.Server, error)
AllServersCmdLineOpts returns CmdLineOpts from all servers. This info will be saved with the backup metadata as extra information that might be needed to rebuild the servers
func (*MessagesServer) BackupSourceByReplicaset ¶
func (s *MessagesServer) BackupSourceByReplicaset() (map[string]*Client, error)
func (*MessagesServer) BackupSourceNameByReplicaset ¶
func (s *MessagesServer) BackupSourceNameByReplicaset() (map[string]string, error)
func (*MessagesServer) BalancerStatus ¶ added in v0.5.0
func (s *MessagesServer) BalancerStatus() *pb.BalancerStatus
func (*MessagesServer) Clients ¶
func (s *MessagesServer) Clients() map[string]Client
func (*MessagesServer) ClientsByReplicaset ¶
func (s *MessagesServer) ClientsByReplicaset() map[string][]Client
func (*MessagesServer) DBBackupFinished ¶
func (s *MessagesServer) DBBackupFinished(ctx context.Context, msg *pb.DBBackupFinishStatus) ( *pb.DBBackupFinishedAck, error)
DBBackupFinished process backup finished message from clients. After the mongodump call finishes, clients should call this method to inform the event to the server Unless the incoming Client ID is invalid, we shouldn't return an error to the clients. If there is an error while processing the incoming message, it is something that should be handled on the server side so, the client shouldn't receive an error.
func (*MessagesServer) IsShardedSystem ¶
func (s *MessagesServer) IsShardedSystem() bool
IsShardedSystem returns if a system is sharded. It check if the Node Type is: - Mongos - Config Server - Shard Server or if the ClusterID is not empty because in a sharded system, the cluster id is never empty.
func (*MessagesServer) LastBackupErrors ¶ added in v0.3.0
func (s *MessagesServer) LastBackupErrors() error
func (*MessagesServer) LastBackupMetadata ¶
func (s *MessagesServer) LastBackupMetadata() *BackupMetadata
func (*MessagesServer) LastOplogTs ¶
func (s *MessagesServer) LastOplogTs() int64
func (*MessagesServer) ListBackups ¶
func (s *MessagesServer) ListBackups() (map[string]pb.BackupMetadata, error)
func (*MessagesServer) ListStorages ¶ added in v0.3.0
func (s *MessagesServer) ListStorages() (map[string]StorageEntry, error)
func (*MessagesServer) Logging ¶
func (s *MessagesServer) Logging(stream pb.Messages_LoggingServer) error
func (*MessagesServer) MessagesChat ¶
func (s *MessagesServer) MessagesChat(stream pb.Messages_MessagesChatServer) error
MessagesChat is the method exposed by gRPC to stream messages between the server and agents
func (*MessagesServer) OplogBackupFinished ¶
func (s *MessagesServer) OplogBackupFinished(ctx context.Context, msg *pb.OplogBackupFinishStatus) ( *pb.OplogBackupFinishedAck, error)
OplogBackupFinished process oplog tailer finished message from clients. After the the oplog tailer has been closed on clients, clients should call this method to inform the event to the server
func (*MessagesServer) RefreshClients ¶
func (s *MessagesServer) RefreshClients() error
func (*MessagesServer) ReplicasetsRunningDBBackup ¶
func (s *MessagesServer) ReplicasetsRunningDBBackup() map[string]*Client
func (*MessagesServer) ReplicasetsRunningOplogBackup ¶
func (s *MessagesServer) ReplicasetsRunningOplogBackup() map[string]*Client
func (*MessagesServer) ReplicasetsRunningRestore ¶
func (s *MessagesServer) ReplicasetsRunningRestore() map[string]*Client
func (*MessagesServer) RestoreBackUp ¶
func (s *MessagesServer) RestoreBackUp(bm *pb.BackupMetadata, storageName string, skipUsersAndRoles bool) error
RestoreBackUp will run a restore on each client, using the provided backup metadata to choose the source for each replicaset.
func (*MessagesServer) RestoreBackupFromMetadataFile ¶
func (s *MessagesServer) RestoreBackupFromMetadataFile(filename, storageName string, skipUsersAndRoles bool) error
RestoreBackupFromMetadataFile is just a wrappwe around RestoreBackUp that receives a metadata filename loads and parse it and then call RestoreBackUp
func (*MessagesServer) RestoreCompleted ¶
func (s *MessagesServer) RestoreCompleted(ctx context.Context, msg *pb.RestoreComplete) ( *pb.RestoreCompletedAck, error)
RestoreCompleted handles a replicaset restore completed messages from clients. After restore is completed or upon errors, each client running the restore will cann this gRPC method to inform the server about the restore status.
func (*MessagesServer) RestoreSourcesByReplicaset ¶
func (s *MessagesServer) RestoreSourcesByReplicaset(bm *pb.BackupMetadata, storageName string) ( map[string]RestoreSource, error)
func (*MessagesServer) StartBackup ¶
func (s *MessagesServer) StartBackup(opts *pb.StartBackup) error
TODO Create an API StartBackup message instead of using pb.StartBackup For example, we don't need DBBackupName & OplogBackupName and having them, here if we use pb.StartBackup message, leads to confusions
func (*MessagesServer) StartBalancer ¶
func (s *MessagesServer) StartBalancer() error
StartBalancer restarts the balancer if this is a sharded system
func (*MessagesServer) Stop ¶
func (s *MessagesServer) Stop()
func (*MessagesServer) StopBalancer ¶
func (s *MessagesServer) StopBalancer() error
StopBalancer stops the balancer if this is a sharded system
func (*MessagesServer) StopOplogTail ¶
func (s *MessagesServer) StopOplogTail() error
StopOplogTail calls every agent StopOplogTail(ts) method using the last oplog timestamp reported by the clients when they call DBBackupFinished after mongodump finish on each client. That way s.lastOplogTs has the last timestamp of the slowest backup
func (*MessagesServer) ValidateReplicasetAgents ¶
func (s *MessagesServer) ValidateReplicasetAgents() error
validateReplicasetAgents will run getShardMap and parse the results on a config server. With that list, we can validate if we have at least one agent connected to each replicaset. Currently it is mandatory to have one agent ON EACH cluster member. Maybe in the future we can relax the requirements because having one agent per replicaset might be enough but it needs more testing.
func (*MessagesServer) WaitBackupFinish ¶
func (s *MessagesServer) WaitBackupFinish() error
func (*MessagesServer) WaitForEvent ¶ added in v0.4.0
func (s *MessagesServer) WaitForEvent(event int, timeout time.Duration) (interface{}, error)
WaitForEvent will wait until the desired event gets fired. timeout = -1 means wait forever
func (*MessagesServer) WaitOplogBackupFinish ¶
func (s *MessagesServer) WaitOplogBackupFinish() error
func (*MessagesServer) WaitRestoreFinish ¶
func (s *MessagesServer) WaitRestoreFinish() error
func (*MessagesServer) WorkDir ¶
func (s *MessagesServer) WorkDir() string
WorkDir returns the server working directory.
func (*MessagesServer) WriteBackupMetadata ¶
func (s *MessagesServer) WriteBackupMetadata() error
WriteBackupMetadata writes the metadata along with the backed up files in the destination storage
func (*MessagesServer) WriteServerBackupMetadata ¶ added in v0.4.0
func (s *MessagesServer) WriteServerBackupMetadata(filename string) error
WriteServerBackupMetadata writes the backup metadata into the coordinator's working dir
type RestoreSource ¶ added in v0.4.0
type StorageEntry ¶ added in v0.3.0
type StorageEntry struct { MatchClients []string DifferClients []string StorageInfo *pb.StorageInfo }