metautil

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2023 License: Apache-2.0, Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// LockFile represents file name
	LockFile = "backup.lock"
	// MetaFile represents file name
	MetaFile = "backupmeta"
	// MetaJSONFile represents backup meta json file name
	MetaJSONFile = "backupmeta.json"
	// MaxBatchSize represents the internal channel buffer size of MetaWriter and MetaReader.
	MaxBatchSize = 1024

	// MetaFileSize represents the limit size of one MetaFile
	MetaFileSize = 128 * units.MiB

	// CrypterIvLen represents the length of iv of crypter method
	CrypterIvLen = 16
)
View Source
const (
	// MetaV1 represents the old version of backupmeta.
	// because the old version doesn't have version field, so set it to 0 for compatibility.
	MetaV1 = iota
	// MetaV2 represents the new version of backupmeta.
	MetaV2
)

Variables

This section is empty.

Functions

func CreateMetaFileName

func CreateMetaFileName(ts uint64) string

CreateMetaFileName is the name of meta file.

func Decrypt

func Decrypt(content []byte, cipher *backuppb.CipherInfo, iv []byte) ([]byte, error)

Decrypt decrypts the content according to CipherInfo and IV.

func Encrypt

func Encrypt(content []byte, cipher *backuppb.CipherInfo) (encryptedContent, iv []byte, err error)

Encrypt encrypts the content according to CipherInfo.

func NewSizedMetaFile

func NewSizedMetaFile(sizeLimit int) *sizedMetaFile

NewSizedMetaFile represents the sizedMetaFile.

Types

type AppendOp

type AppendOp int

AppendOp represents the operation type of meta.

const (
	// AppendMetaFile represents the MetaFile type.
	AppendMetaFile AppendOp = 0
	// AppendDataFile represents the DataFile type.
	// it records the file meta from tikv.
	AppendDataFile AppendOp = 1
	// AppendSchema represents the schema from tidb.
	AppendSchema AppendOp = 2
	// AppendDDL represents the ddls before last backup.
	AppendDDL AppendOp = 3
)

type MetaReader

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

MetaReader wraps a reader to read both old and new version of backupmeta.

func NewMetaReader

func NewMetaReader(
	backpMeta *backuppb.BackupMeta,
	storage storage.ExternalStorage,
	cipher *backuppb.CipherInfo) *MetaReader

NewMetaReader creates MetaReader.

func (*MetaReader) ArchiveSize

func (*MetaReader) ArchiveSize(_ context.Context, files []*backuppb.File) uint64

ArchiveSize return the size of Archive data

func (*MetaReader) ReadDDLs

func (reader *MetaReader) ReadDDLs(ctx context.Context) ([]byte, error)

ReadDDLs reads the ddls from the backupmeta. This function is compatible with the old backupmeta.

func (*MetaReader) ReadSchemasFiles

func (reader *MetaReader) ReadSchemasFiles(ctx context.Context, output chan<- *Table) error

ReadSchemasFiles reads the schema and datafiles from the backupmeta. This function is compatible with the old backupmeta.

type MetaWriter

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

MetaWriter represents wraps a writer, and the MetaWriter should be compatible with old version of backupmeta.

func NewMetaWriter

func NewMetaWriter(
	storage storage.ExternalStorage,
	metafileSizeLimit int,
	useV2Meta bool,
	metaFileName string,
	cipher *backuppb.CipherInfo,
) *MetaWriter

NewMetaWriter creates MetaWriter.

func (*MetaWriter) ArchiveSize

func (writer *MetaWriter) ArchiveSize() uint64

ArchiveSize represents the size of ArchiveSize.

func (*MetaWriter) Backupmeta

func (writer *MetaWriter) Backupmeta() *backuppb.BackupMeta

Backupmeta clones a backupmeta.

func (*MetaWriter) FinishWriteMetas

func (writer *MetaWriter) FinishWriteMetas(ctx context.Context, op AppendOp) error

FinishWriteMetas close the channel in StartWriteMetasAsync and flush the buffered data.

func (*MetaWriter) FlushBackupMeta

func (writer *MetaWriter) FlushBackupMeta(ctx context.Context) error

FlushBackupMeta flush the `backupMeta` to `ExternalStorage`

func (*MetaWriter) Send

func (writer *MetaWriter) Send(m interface{}, _ AppendOp) error

Send sends the item to buffer.

func (*MetaWriter) StartWriteMetasAsync

func (writer *MetaWriter) StartWriteMetasAsync(ctx context.Context, op AppendOp)

StartWriteMetasAsync writes four kind of meta into backupmeta. 1. file 2. schema 3. ddl 4. rawRange( raw kv ) when useBackupMetaV2 enabled, it will generate multi-level index backupmetav2. else it will generate backupmeta as before for compatibility. User should call FinishWriteMetas after StartWriterMetasAsync.

func (*MetaWriter) Update

func (writer *MetaWriter) Update(f func(m *backuppb.BackupMeta))

Update updates some property of backupmeta.

type Table

type Table struct {
	DB              *model.DBInfo
	Info            *model.TableInfo
	Crc64Xor        uint64
	TotalKvs        uint64
	TotalBytes      uint64
	Files           []*backuppb.File
	TiFlashReplicas int
	Stats           *handle.JSONTable
}

Table wraps the schema and files of a table.

func (*Table) NoChecksum

func (tbl *Table) NoChecksum() bool

NoChecksum checks whether the table has a calculated checksum.

Jump to

Keyboard shortcuts

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