Skip to content

Commit

Permalink
APPS-1159 Use unsigned Integer to store backup and restore statistics (
Browse files Browse the repository at this point in the history
…#155)

replace int with uint64 in BackupMetadata and RestoreResult
  • Loading branch information
korotkov-aerospike authored Feb 25, 2024
1 parent fd99b7c commit 0291a72
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 38 deletions.
15 changes: 15 additions & 0 deletions docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1327,6 +1327,7 @@ const docTemplate = `{
"byte-count": {
"description": "The size of the backup in bytes.",
"type": "integer",
"format": "int64",
"example": 2000
},
"created": {
Expand All @@ -1337,6 +1338,7 @@ const docTemplate = `{
"file-count": {
"description": "The number of backup files created.",
"type": "integer",
"format": "int64",
"example": 1
},
"from": {
Expand All @@ -1357,16 +1359,19 @@ const docTemplate = `{
"record-count": {
"description": "The total number of records backed up.",
"type": "integer",
"format": "int64",
"example": 100
},
"secondary-index-count": {
"description": "The number of secondary indexes backed up.",
"type": "integer",
"format": "int64",
"example": 5
},
"udf-count": {
"description": "The number of UDF files backed up.",
"type": "integer",
"format": "int64",
"example": 2
}
}
Expand Down Expand Up @@ -1864,30 +1869,37 @@ const docTemplate = `{
"error": {},
"existed-records": {
"type": "integer",
"format": "int64",
"example": 15
},
"expired-records": {
"type": "integer",
"format": "int64",
"example": 2
},
"fresher-records": {
"type": "integer",
"format": "int64",
"example": 5
},
"ignored-records": {
"type": "integer",
"format": "int64",
"example": 12
},
"index-count": {
"type": "integer",
"format": "int64",
"example": 3
},
"inserted-records": {
"type": "integer",
"format": "int64",
"example": 8
},
"skipped-records": {
"type": "integer",
"format": "int64",
"example": 4
},
"status": {
Expand All @@ -1904,14 +1916,17 @@ const docTemplate = `{
},
"total-bytes": {
"type": "integer",
"format": "int64",
"example": 2000
},
"total-records": {
"type": "integer",
"format": "int64",
"example": 10
},
"udf-count": {
"type": "integer",
"format": "int64",
"example": 1
}
}
Expand Down
15 changes: 15 additions & 0 deletions docs/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -1450,6 +1450,7 @@
"byte-count" : {
"description" : "The size of the backup in bytes.",
"example" : 2000,
"format" : "int64",
"type" : "integer"
},
"created" : {
Expand All @@ -1460,6 +1461,7 @@
"file-count" : {
"description" : "The number of backup files created.",
"example" : 1,
"format" : "int64",
"type" : "integer"
},
"from" : {
Expand All @@ -1480,16 +1482,19 @@
"record-count" : {
"description" : "The total number of records backed up.",
"example" : 100,
"format" : "int64",
"type" : "integer"
},
"secondary-index-count" : {
"description" : "The number of secondary indexes backed up.",
"example" : 5,
"format" : "int64",
"type" : "integer"
},
"udf-count" : {
"description" : "The number of UDF files backed up.",
"example" : 2,
"format" : "int64",
"type" : "integer"
}
},
Expand Down Expand Up @@ -1920,30 +1925,37 @@
},
"existed-records" : {
"example" : 15,
"format" : "int64",
"type" : "integer"
},
"expired-records" : {
"example" : 2,
"format" : "int64",
"type" : "integer"
},
"fresher-records" : {
"example" : 5,
"format" : "int64",
"type" : "integer"
},
"ignored-records" : {
"example" : 12,
"format" : "int64",
"type" : "integer"
},
"index-count" : {
"example" : 3,
"format" : "int64",
"type" : "integer"
},
"inserted-records" : {
"example" : 8,
"format" : "int64",
"type" : "integer"
},
"skipped-records" : {
"example" : 4,
"format" : "int64",
"type" : "integer"
},
"status" : {
Expand All @@ -1954,14 +1966,17 @@
},
"total-bytes" : {
"example" : 2000,
"format" : "int64",
"type" : "integer"
},
"total-records" : {
"example" : 10,
"format" : "int64",
"type" : "integer"
},
"udf-count" : {
"example" : 1,
"format" : "int64",
"type" : "integer"
}
},
Expand Down
15 changes: 15 additions & 0 deletions docs/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1036,6 +1036,7 @@ components:
byte-count:
description: The size of the backup in bytes.
example: 2000
format: int64
type: integer
created:
description: The backup time in the ISO 8601 format.
Expand All @@ -1044,6 +1045,7 @@ components:
file-count:
description: The number of backup files created.
example: 1
format: int64
type: integer
from:
description: The lower time bound of backup entities in the ISO 8601 format
Expand All @@ -1061,14 +1063,17 @@ components:
record-count:
description: The total number of records backed up.
example: 100
format: int64
type: integer
secondary-index-count:
description: The number of secondary indexes backed up.
example: 5
format: int64
type: integer
udf-count:
description: The number of UDF files backed up.
example: 2
format: int64
type: integer
type: object
model.BackupPolicy:
Expand Down Expand Up @@ -1587,37 +1592,47 @@ components:
type: object
existed-records:
example: 15
format: int64
type: integer
expired-records:
example: 2
format: int64
type: integer
fresher-records:
example: 5
format: int64
type: integer
ignored-records:
example: 12
format: int64
type: integer
index-count:
example: 3
format: int64
type: integer
inserted-records:
example: 8
format: int64
type: integer
skipped-records:
example: 4
format: int64
type: integer
status:
allOf:
- $ref: '#/components/schemas/model.JobStatus'
type: object
total-bytes:
example: 2000
format: int64
type: integer
total-records:
example: 10
format: int64
type: integer
udf-count:
example: 1
format: int64
type: integer
type: object
model.RestoreNamespace:
Expand Down
10 changes: 5 additions & 5 deletions pkg/model/backup_details.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ type BackupMetadata struct {
// The namespace of a backup.
Namespace string `yaml:"namespace,omitempty" json:"namespace,omitempty" example:"testNamespace"`
// The total number of records backed up.
RecordCount int `yaml:"record-count,omitempty" json:"record-count,omitempty" example:"100"`
RecordCount uint64 `yaml:"record-count,omitempty" json:"record-count,omitempty" format:"int64" example:"100"`
// The size of the backup in bytes.
ByteCount int `yaml:"byte-count,omitempty" json:"byte-count,omitempty" example:"2000"`
ByteCount uint64 `yaml:"byte-count,omitempty" json:"byte-count,omitempty" format:"int64" example:"2000"`
// The number of backup files created.
FileCount int `yaml:"file-count,omitempty" json:"file-count,omitempty" example:"1"`
FileCount uint64 `yaml:"file-count,omitempty" json:"file-count,omitempty" format:"int64" example:"1"`
// The number of secondary indexes backed up.
SecondaryIndexCount int `yaml:"secondary-index-count,omitempty" json:"secondary-index-count,omitempty" example:"5"`
SecondaryIndexCount uint64 `yaml:"secondary-index-count,omitempty" json:"secondary-index-count,omitempty" format:"int64" example:"5"`
// The number of UDF files backed up.
UDFCount int `yaml:"udf-count,omitempty" json:"udf-count,omitempty" example:"2"`
UDFCount uint64 `yaml:"udf-count,omitempty" json:"udf-count,omitempty" format:"int64" example:"2"`
}
20 changes: 10 additions & 10 deletions pkg/model/restore_result.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ type RestoreJobStatus struct {

// RestoreResult represents a single restore operation result.
type RestoreResult struct {
TotalRecords int `yaml:"total-records,omitempty" json:"total-records,omitempty" example:"10"`
TotalBytes int `yaml:"total-bytes,omitempty" json:"total-bytes,omitempty" example:"2000"`
ExpiredRecords int `yaml:"expired-records,omitempty" json:"expired-records,omitempty" example:"2"`
SkippedRecords int `yaml:"skipped-records,omitempty" json:"skipped-records,omitempty" example:"4"`
IgnoredRecords int `yaml:"ignored-records,omitempty" json:"ignored-records,omitempty" example:"12"`
InsertedRecords int `yaml:"inserted-records,omitempty" json:"inserted-records,omitempty" example:"8"`
ExistedRecords int `yaml:"existed-records,omitempty" json:"existed-records,omitempty" example:"15"`
FresherRecords int `yaml:"fresher-records,omitempty" json:"fresher-records,omitempty" example:"5"`
IndexCount int `yaml:"index-count,omitempty" json:"index-count,omitempty" example:"3"`
UDFCount int `yaml:"udf-count,omitempty" json:"udf-count,omitempty" example:"1"`
TotalRecords uint64 `yaml:"total-records,omitempty" json:"total-records,omitempty" format:"int64" example:"10"`
TotalBytes uint64 `yaml:"total-bytes,omitempty" json:"total-bytes,omitempty" format:"int64" example:"2000"`
ExpiredRecords uint64 `yaml:"expired-records,omitempty" json:"expired-records,omitempty" format:"int64" example:"2"`
SkippedRecords uint64 `yaml:"skipped-records,omitempty" json:"skipped-records,omitempty" format:"int64" example:"4"`
IgnoredRecords uint64 `yaml:"ignored-records,omitempty" json:"ignored-records,omitempty" format:"int64" example:"12"`
InsertedRecords uint64 `yaml:"inserted-records,omitempty" json:"inserted-records,omitempty" format:"int64" example:"8"`
ExistedRecords uint64 `yaml:"existed-records,omitempty" json:"existed-records,omitempty" format:"int64" example:"15"`
FresherRecords uint64 `yaml:"fresher-records,omitempty" json:"fresher-records,omitempty" format:"int64" example:"5"`
IndexCount uint64 `yaml:"index-count,omitempty" json:"index-count,omitempty" format:"int64" example:"3"`
UDFCount uint64 `yaml:"udf-count,omitempty" json:"udf-count,omitempty" format:"int64" example:"1"`
}

// NewRestoreResult returns a new RestoreResult.
Expand Down
10 changes: 5 additions & 5 deletions pkg/shared/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,11 @@ func (b *BackupShared) BackupRun(backupRoutine *model.BackupRoutine, backupPolic
}

func setStatistics(result *BackupStat, status *C.backup_status_t) {
result.RecordCount = int(status.rec_count_total)
result.ByteCount = int(status.byte_count_total)
result.FileCount = int(status.file_count)
result.IndexCount = int(status.index_count)
result.UDFCount = int(status.udf_count)
result.RecordCount = uint64(status.rec_count_total)
result.ByteCount = uint64(status.byte_count_total)
result.FileCount = uint64(status.file_count)
result.IndexCount = uint64(status.index_count)
result.UDFCount = uint64(status.udf_count)
}

func backupSecretAgent(config *C.backup_config_t, secretsAgent *model.SecretAgent) {
Expand Down
24 changes: 11 additions & 13 deletions pkg/shared/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,20 +130,18 @@ func (r *RestoreShared) RestoreRun(restoreRequest *model.RestoreRequestInternal)
}

func getRestoreResult(status *C.restore_status_t) *model.RestoreResult {
result := &model.RestoreResult{
TotalRecords: int(status.total_records),
TotalBytes: int(status.total_bytes),
ExpiredRecords: int(status.expired_records),
SkippedRecords: int(status.skipped_records),
IgnoredRecords: int(status.ignored_records),
InsertedRecords: int(status.inserted_records),
ExistedRecords: int(status.existed_records),
FresherRecords: int(status.fresher_records),
IndexCount: int(status.index_count),
UDFCount: int(status.udf_count),
return &model.RestoreResult{
TotalRecords: uint64(status.total_records),
TotalBytes: uint64(status.total_bytes),
ExpiredRecords: uint64(status.expired_records),
SkippedRecords: uint64(status.skipped_records),
IgnoredRecords: uint64(status.ignored_records),
InsertedRecords: uint64(status.inserted_records),
ExistedRecords: uint64(status.existed_records),
FresherRecords: uint64(status.fresher_records),
IndexCount: uint64(status.index_count),
UDFCount: uint64(status.udf_count),
}

return result
}

func restoreSecretAgent(config *C.restore_config_t, secretsAgent *model.SecretAgent) {
Expand Down
10 changes: 5 additions & 5 deletions pkg/shared/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ type BackupOptions struct {

// BackupStat represents partial backup result statistics returned from asbackup library.
type BackupStat struct {
RecordCount int
ByteCount int
FileCount int
IndexCount int
UDFCount int
RecordCount uint64
ByteCount uint64
FileCount uint64
IndexCount uint64
UDFCount uint64
}

// IsEmpty indicates whether the backup operation represented by the
Expand Down

0 comments on commit 0291a72

Please sign in to comment.