Skip to content

Commit

Permalink
Update default config values (#182)
Browse files Browse the repository at this point in the history
Co-authored-by: yrizhkov <[email protected]>
  • Loading branch information
filkeith and reugn authored Nov 20, 2024
1 parent 5f20236 commit 8624a86
Show file tree
Hide file tree
Showing 12 changed files with 36 additions and 22 deletions.
6 changes: 3 additions & 3 deletions cmd/asbackup/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,16 @@ Backup Flags:
-L, --records-per-second int Limit total returned records per second (rps).
Do not apply rps limit if records-per-second is zero.
--max-retries int Maximum number of retries before aborting the current transaction. (default 5)
--total-timeout int Total socket timeout in milliseconds. 0 - no timeout.
--socket-timeout int Socket timeout in milliseconds. If this value is 0, its set to total-timeout. If both are 0,
--total-timeout int Total transaction timeout in milliseconds. 0 - no timeout.
--socket-timeout int Socket timeout in milliseconds. If this value is 0, it's set to total-timeout. If both are 0,
there is no socket idle time limit (default 10000)
-N, --nice int The limits for read/write storage bandwidth in MiB/s
-r, --remove-files Remove existing backup file (-o) or files (-d).
--remove-artifacts Remove existing backup file (-o) or files (-d) without performing a backup.
-o, --output-file string Backup to a single backup file. Use - for stdout. Required, unless -d or -e is used.
-q, --output-file-prefix string When using directory parameter, prepend a prefix to the names of the generated files.
-F, --file-limit int Rotate backup files, when their size crosses the given
value (in bytes) Only used when backing up to a Directory.
value (in bytes) Only used when backing up to a Directory. (default 262144000)
-x, --no-bins Do not include bin data in the backup. Use this flag for data sampling or troubleshooting.
On restore all records, that don't contain bin data will be skipped.
--no-ttl-only Only include records that have no ttl set (persistent records).
Expand Down
8 changes: 4 additions & 4 deletions cmd/asrestore/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ Restore Flags:
-R, --no-records Don't restore any records.
-I, --no-indexes Don't restore any secondary indexes.
--no-udfs Don't restore any UDFs.
-w, --parallel int The number of restore threads. (default 1)
-w, --parallel int The number of restore threads. (default - the number of available CPUs)
-L, --records-per-second int Limit total returned records per second (rps).
Do not apply rps limit if records-per-second is zero.
--max-retries int Maximum number of retries before aborting the current transaction. (default 5)
--total-timeout int Total socket timeout in milliseconds. 0 - no timeout.
--socket-timeout int Socket timeout in milliseconds. If this value is 0, its set to total-timeout. If both are 0,
--total-timeout int Total transaction timeout in milliseconds. 0 - no timeout. (default 10000)
--socket-timeout int Socket timeout in milliseconds. If this value is 0, it's set to total-timeout. If both are 0,
there is no socket idle time limit (default 10000)
-N, --nice int The limits for read/write storage bandwidth in MiB/s
-i, --input-file string Restore from a single backup file. Use - for stdin.
Expand Down Expand Up @@ -95,7 +95,7 @@ Restore Flags:
Default is 128 with batch writes enabled, or 16 without batch writes. (default 128)
--extra-ttl int For records with expirable void-times, add N seconds of extra-ttl to the
recorded void-time.
-T, --timeout int Set the timeout (ms) for commands. (default 10000)
-T, --timeout int Set the timeout (ms) for info commands. (default 10000)
--retry-base-timeout int Set the initial delay between retry attempts in milliseconds (default 1000)
--retry-multiplier float retry-multiplier is used to increase the delay between subsequent retry attempts.
The actual delay is calculated as: retry-base-timeout * (retry-multiplier ^ attemptNumber) (default 1)
Expand Down
2 changes: 1 addition & 1 deletion cmd/internal/app/asbackup.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type ASBackup struct {
backupClient *backup.Client
backupConfig *backup.BackupConfig
writer backup.Writer
// reader is used to read state file.
// reader is used to read a state file.
reader backup.StreamingReader
// Additional params.
isEstimate bool
Expand Down
2 changes: 1 addition & 1 deletion cmd/internal/app/reports.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func printRestoreReport(stats *bModels.RestoreStats) {
fmt.Printf("Expired Records: %d\n", stats.GetRecordsExpired())
fmt.Printf("Skipped Records: %d\n", stats.GetRecordsSkipped())
fmt.Printf("Ignored Records: %d\n", stats.GetRecordsIgnored())
fmt.Printf("Freasher Records: %d\n", stats.GetRecordsFresher())
fmt.Printf("Fresher Records: %d\n", stats.GetRecordsFresher())
fmt.Printf("Existed Records: %d\n", stats.GetRecordsExisted())
fmt.Printf("Inserted Records: %d\n", stats.GetRecordsInserted())
fmt.Printf("Total Bytes Read: %d\n", stats.GetTotalBytesRead())
Expand Down
4 changes: 2 additions & 2 deletions cmd/internal/flags/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ func (f *Backup) NewFlagSet() *pflag.FlagSet {
"When using directory parameter, prepend a prefix to the names of the generated files.")

flagSet.Int64VarP(&f.FileLimit, "file-limit", "F",
0,
262144000, // 250 MB
"Rotate backup files, when their size crosses the given\n"+
"value (in bytes) Only used when backing up to a Directory.")
"value (in bytes) Only used when backing up to a Directory. 0 - no limit.")
flagSet.BoolVarP(&f.NoBins, "no-bins", "x",
false,
"Do not include bin data in the backup. Use this flag for data sampling or troubleshooting.\n"+
Expand Down
2 changes: 1 addition & 1 deletion cmd/internal/flags/backup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func TestBackup_NewFlagSet_DefaultValues(t *testing.T) {
result := backup.GetBackup()

assert.Equal(t, "", result.OutputFile, "The default value for output-file should be an empty string")
assert.Equal(t, int64(0), result.FileLimit, "The default value for file-limit should be 0")
assert.Equal(t, int64(262144000), result.FileLimit, "The default value for file-limit should be 0")
assert.Equal(t, "", result.AfterDigest, "The default value for after-digest should be an empty string")
assert.Equal(t, "", result.ModifiedBefore, "The default value for modified-before should be an empty string")
assert.Equal(t, "", result.ModifiedAfter, "The default value for modified-after should be an empty string")
Expand Down
21 changes: 17 additions & 4 deletions cmd/internal/flags/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
package flags

import (
"runtime"

"github.com/aerospike/backup-go/cmd/internal/models"
"github.com/spf13/pflag"
)
Expand Down Expand Up @@ -54,6 +56,9 @@ const (
"filter cannot be parallelized individually, so you may only achieve as much parallelism as there are\n" +
"partition filters."
descParallelRestore = "The number of restore threads."

defaultTotalTimeoutBackup = 0
defaultTotalTimeoutRestore = 10000
)

type Common struct {
Expand All @@ -69,7 +74,11 @@ func NewCommon(operation int) *Common {
func (f *Common) NewFlagSet() *pflag.FlagSet {
flagSet := &pflag.FlagSet{}

var descNamespace, descSetList, descBinList, descNoRecords, descNoIndexes, descNoUDFs, descParallel string
var (
descNamespace, descSetList, descBinList, descNoRecords, descNoIndexes, descNoUDFs, descParallel string
defaultTotalTimeout int64
defaultParallel int
)

switch f.operation {
case OperationBackup:
Expand All @@ -80,6 +89,8 @@ func (f *Common) NewFlagSet() *pflag.FlagSet {
descNoIndexes = descNoIndexesBackup
descNoUDFs = descNoUDFsBackup
descParallel = descParallelBackup
defaultTotalTimeout = defaultTotalTimeoutBackup
defaultParallel = 1
case OperationRestore:
descNamespace = descNamespaceRestore
descSetList = descSetListRestore
Expand All @@ -88,6 +99,8 @@ func (f *Common) NewFlagSet() *pflag.FlagSet {
descNoIndexes = descNoIndexesRestore
descNoUDFs = descNoUDFsRestore
descParallel = descParallelRestore
defaultTotalTimeout = defaultTotalTimeoutRestore
defaultParallel = runtime.NumCPU()
}

flagSet.StringVarP(&f.Directory, "directory", "d",
Expand All @@ -112,7 +125,7 @@ func (f *Common) NewFlagSet() *pflag.FlagSet {
false,
descNoUDFs)
flagSet.IntVarP(&f.Parallel, "parallel", "w",
1,
defaultParallel,
descParallel)
flagSet.IntVarP(&f.RecordsPerSecond, "records-per-second", "L",
0,
Expand All @@ -122,8 +135,8 @@ func (f *Common) NewFlagSet() *pflag.FlagSet {
5,
"Maximum number of retries before aborting the current transaction.")
flagSet.Int64Var(&f.TotalTimeout, "total-timeout",
0,
"Total socket timeout in milliseconds. 0 - no timeout.")
defaultTotalTimeout,
"Total transaction timeout in milliseconds. 0 - no timeout.")
flagSet.Int64Var(&f.SocketTimeout, "socket-timeout",
10000,
"Socket timeout in milliseconds. If this value is 0, its set to total-timeout. If both are 0,\n"+
Expand Down
5 changes: 3 additions & 2 deletions cmd/internal/flags/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package flags

import (
"runtime"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -77,11 +78,11 @@ func TestCommon_NewFlagSet_DefaultValues(t *testing.T) {
assert.Equal(t, "", result.SetList, "The default value for set-list should be nil")
assert.Equal(t, 0, result.RecordsPerSecond, "The default value for records-per-second should be 0")
assert.Equal(t, "", result.BinList, "The default value for bin-list should be nil")
assert.Equal(t, 1, result.Parallel, "The default value for parallel should be 1")
assert.Equal(t, runtime.NumCPU(), result.Parallel, "The default value for parallel should be 1")
assert.False(t, result.NoRecords, "The default value for no-records should be false")
assert.False(t, result.NoIndexes, "The default value for no-indexes should be false")
assert.False(t, result.NoUDFs, "The default value for no-udfs should be false")
assert.Equal(t, 5, result.MaxRetries, "The default value for max-retries should be 5")
assert.Equal(t, int64(0), result.TotalTimeout, "The default value for total-timeout should be 0")
assert.Equal(t, int64(10000), result.TotalTimeout, "The default value for total-timeout should be 0")
assert.Equal(t, int64(10000), result.SocketTimeout, "The default value for socket-timeout should be 10000")
}
2 changes: 1 addition & 1 deletion cmd/internal/flags/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func (f *Restore) NewFlagSet() *pflag.FlagSet {

flagSet.Int64VarP(&f.TimeOut, "timeout", "T",
10000,
"Set the timeout (ms) for commands.")
"Set the timeout (ms) for info commands.")
flagSet.Int64Var(&f.RetryBaseTimeout, "retry-base-timeout",
1000,
"Set the initial delay between retry attempts in milliseconds")
Expand Down
2 changes: 1 addition & 1 deletion internal/asinfo/info_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ func parseInfoKVPair(pair, kvSep string) (key, val string, err error) {
return "", "", fmt.Errorf("invalid key-value pair: %s", pair)
}

// make keys case insensitive
// make keys case-insensitive
// to help with different version compatibility
key = strings.ToLower(kv[0])
val = kv[1]
Expand Down
2 changes: 1 addition & 1 deletion io/encoding/asb/decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ func (r *Decoder) readGlobals() (any, error) {
}

// readSindex is used to read secondary index lines in the global section of the asb file.
// readSindex expects that r has been advanced past the secondary index global line markter '* i'
// readSindex expects that r has been advanced past the secondary index global line marker '* i'
func (r *Decoder) readSIndex() (*models.SIndex, error) {
var res models.SIndex

Expand Down
2 changes: 1 addition & 1 deletion io/sized/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type Writer struct {
saveCommandChan chan int
}

// NewWriter creates a new Writer writer with a size limit.
// NewWriter creates a new Writer with a size limit.
// limit must be greater than 0.
func NewWriter(ctx context.Context, n int, saveCommandChan chan int, limit int64,
open func(context.Context) (io.WriteCloser, error)) (*Writer, error) {
Expand Down

0 comments on commit 8624a86

Please sign in to comment.