Skip to content

Commit

Permalink
feat(restore): index, support metrics init
Browse files Browse the repository at this point in the history
  • Loading branch information
Michal-Leszczynski committed Sep 25, 2024
1 parent 8edd8ab commit eb377a7
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions pkg/service/restore/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"slices"

"github.com/pkg/errors"
"github.com/scylladb/scylla-manager/v3/pkg/metrics"
. "github.com/scylladb/scylla-manager/v3/pkg/service/backup/backupspec"
"github.com/scylladb/scylla-manager/v3/pkg/sstable"
)
Expand Down Expand Up @@ -159,6 +160,43 @@ func (w *tablesWorker) filterPreviouslyRestoredSStables(rawWorkload []RemoteDirW
return filtered, nil
}

func (w *tablesWorker) initMetrics(workload []LocationWorkload) {
// For now, the only persistent across task runs metrics are progress and remaining_bytes.
// The rest: state, view_build_status, batch_size are calculated from scratch.
w.metrics.ResetClusterMetrics(w.run.ClusterID)

// Init remaining bytes
for _, wl := range workload {
for _, twl := range wl.Tables {
for _, rdwl := range twl.RemoteDirs {
w.metrics.SetRemainingBytes(metrics.RestoreBytesLabels{
ClusterID: rdwl.ClusterID.String(),
SnapshotTag: rdwl.SnapshotTag,
Location: rdwl.Location.String(),
DC: rdwl.DC,
Node: rdwl.NodeID,
Keyspace: rdwl.Keyspace,
Table: rdwl.Table,
}, rdwl.Size)
}
}
}

// Init progress
var totalSize int64
for _, u := range w.run.Units {
totalSize += u.Size
}
var workloadSize int64
for _, wl := range workload {
workloadSize += wl.Size
}
w.metrics.SetProgress(metrics.RestoreProgressLabels{
ClusterID: w.run.ClusterID.String(),
SnapshotTag: w.run.SnapshotTag,
}, float64(totalSize-workloadSize)/float64(totalSize)*100)
}

func aggregateLocationWorkload(rawWorkload []RemoteDirWorkload) LocationWorkload {
remoteDirWorkloads := make(map[TableName][]RemoteDirWorkload)
for _, rw := range rawWorkload {
Expand Down

0 comments on commit eb377a7

Please sign in to comment.