utils

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2023 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BackupPreventedByGpexpandMessage GpexpandFailureMessage = `Greenplum expansion currently in process, please re-run gpbackup when the expansion has completed`

	RestorePreventedByGpexpandMessage GpexpandFailureMessage = `` /* 268-byte string literal not displayed */

	CoordinatorDataDirQuery           = `select datadir from gp_segment_configuration where content=-1 and role='p'`
	GpexpandTemporaryTableStatusQuery = `SELECT status FROM gpexpand.status ORDER BY updated DESC LIMIT 1`
	GpexpandStatusTableExistsQuery    = `` /* 156-byte string literal not displayed */

	GpexpandStatusFilename = "gpexpand.status"
)
View Source
const (
	PB_NONE = iota
	PB_INFO
	PB_VERBOSE

	//Verbose progress bar logs every 10 percent
	INCR_PERCENT = 10
)

* The following constants are used for determining when to display a progress bar * * PB_INFO only shows in info mode because some methods have a different way of * logging in verbose mode and we don't want them to conflict * PB_VERBOSE show a progress bar in INFO and VERBOSE mode * * A simple incremental progress tracker will be shown in info mode and * in verbose mode we will log progress at increments of 10%

View Source
const MINIMUM_GPDB4_VERSION = "1.1.0"
View Source
const MINIMUM_GPDB5_VERSION = "1.1.0"
View Source
const RequiredPluginVersion = "0.3.0"
View Source
const SecretKeyFile = ".encrypt"

Variables

This section is empty.

Functions

func CheckAgentErrorsOnSegments

func CheckAgentErrorsOnSegments(c *cluster.Cluster, fpInfo filepath.FilePathInfo) error

func CheckGpexpandRunning

func CheckGpexpandRunning(errMsg GpexpandFailureMessage)

func CleanUpHelperFilesOnAllHosts

func CleanUpHelperFilesOnAllHosts(c *cluster.Cluster, fpInfo filepath.FilePathInfo)

func CleanUpSegmentHelperProcesses

func CleanUpSegmentHelperProcesses(c *cluster.Cluster, fpInfo filepath.FilePathInfo, operation string)

func CommandExists

func CommandExists(cmd string) bool

func CopyFile

func CopyFile(src, dest string) error

func CreateSegmentPipeOnAllHosts

func CreateSegmentPipeOnAllHosts(oid string, c *cluster.Cluster, fpInfo filepath.FilePathInfo)

* The reason that gprestore is in charge of creating the first pipe to ensure * that the first pipe is created before the first COPY FROM is issued. If * gpbackup_helper was in charge of creating the first pipe, there is a * possibility that the COPY FROM commands start before gpbackup_helper is done * starting up and setting up the first pipe.

func CreateSkipFileOnSegments

func CreateSkipFileOnSegments(oid string, tableName string, c *cluster.Cluster, fpInfo filepath.FilePathInfo)

func DollarQuoteString

func DollarQuoteString(literal string) string

Dollar-quoting logic is based on appendStringLiteralDQ() in pg_dump.

func EscapeSingleQuotes

func EscapeSingleQuotes(str string) string

func Exists

func Exists(slice []string, val string) bool

func FileExists

func FileExists(filename string) bool

func GetFileHash

func GetFileHash(filename string) ([32]byte, error)

func GetSecretKey

func GetSecretKey(pluginName string, mdd string) (string, error)

func InitializePipeThroughParameters

func InitializePipeThroughParameters(compress bool, compressionType string, compressionLevel int)

func InitializeSignalHandler

func InitializeSignalHandler(cleanupFunc func(bool), procDesc string, termFlag *bool)

func LogExecutionTime

func LogExecutionTime(start time.Time, name string)

func MakeFQN

func MakeFQN(schema string, object string) string

This function assumes that all identifiers are already appropriately quoted

func MustPrintf

func MustPrintf(file io.Writer, s string, v ...interface{}) uint64

func MustPrintln

func MustPrintln(file io.Writer, v ...interface{}) uint64

func OpenFileForWrite

func OpenFileForWrite(filename string) (*os.File, error)

func QuoteIdent

func QuoteIdent(connectionPool *dbconn.DBConn, ident string) string

func RelationIsExcludedByUser

func RelationIsExcludedByUser(inRelationsUserInput []string, exRelationsUserInput []string, tableFQN string) bool

func RemoveFileIfExists

func RemoveFileIfExists(filename string) error

func SchemaIsExcludedByUser

func SchemaIsExcludedByUser(inSchemasUserInput []string, exSchemasUserInput []string, schemaName string) bool

func SetPipeThroughProgram

func SetPipeThroughProgram(compression PipeThroughProgram)

func SliceToQuotedString

func SliceToQuotedString(slice []string) string

func StartGpbackupHelpers

func StartGpbackupHelpers(c *cluster.Cluster, fpInfo filepath.FilePathInfo, operation string, pluginConfigFile string, compressStr string, onErrorContinue bool, isFilter bool, wasTerminated *bool, copyQueue int, isSingleDataFile bool, resizeCluster bool, origSize int, destSize int)

func TerminateHangingCopySessions

func TerminateHangingCopySessions(connectionPool *dbconn.DBConn, fpInfo filepath.FilePathInfo, appName string)

TODO: Uniquely identify COPY commands in the multiple data file case to allow terminating sessions

func UnquoteIdent

func UnquoteIdent(ident string) string

func ValidateCompressionTypeAndLevel

func ValidateCompressionTypeAndLevel(compressionType string, compressionLevel int) error

func ValidateFQNs

func ValidateFQNs(tableList []string) error

Since we currently split schema and table on the dot (.), we can't allow users to filter backup or restore tables with dots in the schema or table.

func ValidateFullPath

func ValidateFullPath(path string) error

func ValidateGPDBVersionCompatibility

func ValidateGPDBVersionCompatibility(connectionPool *dbconn.DBConn)

func VerifyHelperVersionOnSegments

func VerifyHelperVersionOnSegments(version string, c *cluster.Cluster)

func WriteOidListToSegments

func WriteOidListToSegments(oidList []string, c *cluster.Cluster, fpInfo filepath.FilePathInfo, fileSuffix string)

func WriteOids

func WriteOids(writer io.Writer, oidList []string) error

func WriteOidsToFile

func WriteOidsToFile(filename string, oidList []string)

func WriteToFileAndMakeReadOnly

func WriteToFileAndMakeReadOnly(filename string, contents []byte) error

Types

type CompressionLevelsDescription

type CompressionLevelsDescription struct {
	Min int
	Max int
}

A description of compression levels for some compression type

type FileWithByteCount

type FileWithByteCount struct {
	Filename  string
	Writer    io.Writer
	File      *os.File
	ByteCount uint64
}

func NewFileWithByteCount

func NewFileWithByteCount(writer io.Writer) *FileWithByteCount

func NewFileWithByteCountFromFile

func NewFileWithByteCountFromFile(filename string) *FileWithByteCount

func (*FileWithByteCount) Close

func (file *FileWithByteCount) Close()

func (*FileWithByteCount) MustPrint

func (file *FileWithByteCount) MustPrint(s string)

func (*FileWithByteCount) MustPrintf

func (file *FileWithByteCount) MustPrintf(s string, v ...interface{})

func (*FileWithByteCount) MustPrintln

func (file *FileWithByteCount) MustPrintln(v ...interface{})

type FilterSet

type FilterSet struct {
	Set                 map[string]bool
	IsExclude           bool
	AlwaysMatchesFilter bool
}

* This set implementation can be used in one of two ways. An "include" set * returns true if an item is in the map and false otherwise, while an "exclude" * set returns false if an item is in the map and true otherwise, so that the * set can be used for filtering on items in lists. * * The alwaysMatchesFilter variable causes MatchesFilter() to always return true * if an empty list is passed, so that it doesn't attempt to filter on anything * The isExclude variable controls whether a set is an include set or an exclude * set.

func NewExcludeSet

func NewExcludeSet(list []string) *FilterSet

func NewIncludeSet

func NewIncludeSet(list []string) *FilterSet

func NewSet

func NewSet(list []string) *FilterSet

func (*FilterSet) Equals

func (s *FilterSet) Equals(s1 *FilterSet) bool

func (*FilterSet) Length

func (s *FilterSet) Length() int

func (*FilterSet) MatchesFilter

func (s *FilterSet) MatchesFilter(item string) bool

type GpexpandFailureMessage

type GpexpandFailureMessage string

type GpexpandSensor

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

func NewGpexpandSensor

func NewGpexpandSensor(myfs vfs.Filesystem, conn *dbconn.DBConn) GpexpandSensor

func (GpexpandSensor) IsGpexpandRunning

func (sensor GpexpandSensor) IsGpexpandRunning() (bool, error)

type PipeThroughProgram

type PipeThroughProgram struct {
	Name          string
	OutputCommand string
	InputCommand  string
	Extension     string
}

func GetPipeThroughProgram

func GetPipeThroughProgram() PipeThroughProgram

type PluginConfig

type PluginConfig struct {
	ExecutablePath string            `yaml:"executablepath"`
	ConfigPath     string            `yaml:"-"`
	Options        map[string]string `yaml:"options"`
	// contains filtered or unexported fields
}

func ReadPluginConfig

func ReadPluginConfig(configFile string) (*PluginConfig, error)

func (*PluginConfig) BackupFile

func (plugin *PluginConfig) BackupFile(filenamePath string) error

func (*PluginConfig) BackupPluginVersion

func (plugin *PluginConfig) BackupPluginVersion() string

func (*PluginConfig) BackupSegmentTOCs

func (plugin *PluginConfig) BackupSegmentTOCs(c *cluster.Cluster, fpInfo filepath.FilePathInfo)

func (*PluginConfig) CanRestoreSubset

func (plugin *PluginConfig) CanRestoreSubset() bool

func (*PluginConfig) CheckPluginExistsOnAllHosts

func (plugin *PluginConfig) CheckPluginExistsOnAllHosts(c *cluster.Cluster) string

func (*PluginConfig) CleanupPluginForBackup

func (plugin *PluginConfig) CleanupPluginForBackup(c *cluster.Cluster, fpInfo filepath.FilePathInfo)

func (*PluginConfig) CleanupPluginForRestore

func (plugin *PluginConfig) CleanupPluginForRestore(c *cluster.Cluster, fpInfo filepath.FilePathInfo)

func (*PluginConfig) CopyPluginConfigToAllHosts

func (plugin *PluginConfig) CopyPluginConfigToAllHosts(c *cluster.Cluster)

func (*PluginConfig) DeletePluginConfigWhenEncrypting

func (plugin *PluginConfig) DeletePluginConfigWhenEncrypting(c *cluster.Cluster)

func (*PluginConfig) GetPluginName

func (plugin *PluginConfig) GetPluginName(c *cluster.Cluster) (pluginName string, err error)

func (*PluginConfig) MustBackupFile

func (plugin *PluginConfig) MustBackupFile(filenamePath string)

func (*PluginConfig) MustRestoreFile

func (plugin *PluginConfig) MustRestoreFile(filenamePath string)

func (*PluginConfig) RestoreSegmentTOCs

func (plugin *PluginConfig) RestoreSegmentTOCs(c *cluster.Cluster, fpInfo filepath.FilePathInfo, isResizeRestore bool, origSize int, destSize int)

func (*PluginConfig) SetBackupPluginVersion

func (plugin *PluginConfig) SetBackupPluginVersion(timestamp string, historicalPluginVersion string)

func (*PluginConfig) SetupPluginForBackup

func (plugin *PluginConfig) SetupPluginForBackup(c *cluster.Cluster, fpInfo filepath.FilePathInfo)

func (*PluginConfig) SetupPluginForRestore

func (plugin *PluginConfig) SetupPluginForRestore(c *cluster.Cluster, fpInfo filepath.FilePathInfo)

func (*PluginConfig) UsesEncryption

func (plugin *PluginConfig) UsesEncryption() bool

type PluginScope

type PluginScope string
const (
	COORDINATOR  PluginScope = "coordinator"
	MASTER       PluginScope = "master"
	SEGMENT_HOST PluginScope = "segment_host"
	SEGMENT      PluginScope = "segment"
)

The COORDINATOR and MASTER scopes are identical in function, we just support both so that creators of existing plugins as of GPDB 6 need not (re)write them to support the GPDB 7 verbiage. Plugin code should use COORDINATOR when carrying out internal functionality, but check for both COORDINATOR and MASTER when expecting external input.

type ProgressBar

type ProgressBar interface {
	Start() *pb.ProgressBar
	Finish()
	Increment() int
	Add(int) int
}

func NewProgressBar

func NewProgressBar(count int, prefix string, showProgressBar int) ProgressBar

type VerboseProgressBar

type VerboseProgressBar struct {
	*pb.ProgressBar
	// contains filtered or unexported fields
}

func NewVerboseProgressBar

func NewVerboseProgressBar(count int, prefix string) *VerboseProgressBar

func (*VerboseProgressBar) Increment

func (vpb *VerboseProgressBar) Increment() int

Jump to

Keyboard shortcuts

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