3
3
package one2onerestore
4
4
5
5
import (
6
+ "time"
7
+
6
8
"github.com/pkg/errors"
7
9
"github.com/scylladb/go-set/strset"
10
+ "github.com/scylladb/scylla-manager/v3/pkg/scyllaclient"
8
11
. "github.com/scylladb/scylla-manager/v3/pkg/service/backup/backupspec"
9
12
"github.com/scylladb/scylla-manager/v3/pkg/util/uuid"
10
13
)
@@ -37,9 +40,10 @@ type node struct {
37
40
38
41
// Host contains basic information about Scylla node.
39
42
type Host struct {
40
- ID string
41
- DC string
42
- Addr string
43
+ ID string
44
+ DC string
45
+ Addr string
46
+ ShardCount int
43
47
}
44
48
45
49
// ViewType either Materialized View or Secondary Index.
@@ -53,11 +57,12 @@ const (
53
57
54
58
// View represents statement used for recreating restored (dropped) views.
55
59
type View struct {
56
- Keyspace string `json:"keyspace" db:"keyspace_name"`
57
- View string `json:"view" db:"view_name"`
58
- Type ViewType `json:"type" db:"view_type"`
59
- BaseTable string `json:"base_table"`
60
- CreateStmt string `json:"create_stmt"`
60
+ Keyspace string `json:"keyspace" db:"keyspace_name"`
61
+ View string `json:"view" db:"view_name"`
62
+ Type ViewType `json:"type" db:"view_type"`
63
+ BaseTable string `json:"base_table"`
64
+ CreateStmt string `json:"create_stmt,omitempty"`
65
+ BuildStatus scyllaclient.ViewBuildStatus `json:"status"`
61
66
}
62
67
63
68
// hostWorkload represents what data (manifest) from the backup should be handled
@@ -72,6 +77,10 @@ type hostWorkload struct {
72
77
73
78
type scyllaTable struct { keyspace , table string }
74
79
80
+ func (st scyllaTable ) String () string {
81
+ return st .keyspace + "." + st .table
82
+ }
83
+
75
84
func getTablesToRestore (workload []hostWorkload ) map [scyllaTable ]struct {} {
76
85
tablesToRestore := map [scyllaTable ]struct {}{}
77
86
for _ , wl := range workload {
@@ -185,3 +194,95 @@ func checkHostMapping(hostMap map[string]struct{}, hostID string) error {
185
194
}
186
195
return errors .Errorf ("host is already mapped: %s" , hostID )
187
196
}
197
+
198
+ // RunProgress describes progress of various 1-1-restore stages.
199
+ type RunProgress struct {
200
+ ClusterID uuid.UUID
201
+ TaskID uuid.UUID
202
+ RunID uuid.UUID
203
+
204
+ KeyspaceName string
205
+ TableName string
206
+ TableSize int64
207
+ RemoteSSTableDir string `db:"remote_sstable_dir"`
208
+ TombstoneGC string
209
+
210
+ Host string // IP of the node to which SSTables are downloaded.
211
+ ShardCnt int // Host shard count used for bandwidth per shard calculation.
212
+
213
+ VersionedProgress int64
214
+
215
+ StartedAt * time.Time
216
+ CompletedAt * time.Time
217
+ // RClone job info fields
218
+ AgentJobID int64
219
+ ScyllaTaskID string // reserved for future use
220
+
221
+ Downloaded int64
222
+ Skipped int64
223
+ Failed int64
224
+ Error string
225
+
226
+ ViewName string
227
+ ViewType ViewType
228
+ ViewBuildStatus scyllaclient.ViewBuildStatus
229
+
230
+ Stage Stage
231
+ }
232
+
233
+ // Stage specifies the restore stage.
234
+ type Stage string
235
+
236
+ // Stage enumeration.
237
+ const (
238
+ StageDropViews Stage = "DROP_VIEWS"
239
+ StageAlterTGC Stage = "ALTER_TGC"
240
+ StageData Stage = "DATA"
241
+ StageRecreateViews Stage = "RECREATE_VIEWS"
242
+ StageDone Stage = "DONE"
243
+ )
244
+
245
+ // Progress groups restore progress for all restored keyspaces.
246
+ type Progress struct {
247
+ progress
248
+
249
+ SnapshotTag string `json:"snapshot_tag"`
250
+ Keyspaces []KeyspaceProgress `json:"keyspaces,omitempty"`
251
+ Hosts []HostProgress `json:"hosts,omitempty"`
252
+ Views []View `json:"views,omitempty"`
253
+ Stage Stage `json:"stage"`
254
+ }
255
+
256
+ // KeyspaceProgress groups restore progress for the tables belonging to this keyspace.
257
+ type KeyspaceProgress struct {
258
+ progress
259
+
260
+ Keyspace string `json:"keyspace"`
261
+ Tables []TableProgress `json:"tables,omitempty"`
262
+ }
263
+
264
+ // TableProgress defines restore progress for the table.
265
+ type TableProgress struct {
266
+ progress
267
+
268
+ Table string `json:"table"`
269
+ TombstoneGC tombstoneGCMode `json:"tombstone_gc"`
270
+ Error string `json:"error,omitempty"`
271
+ }
272
+
273
+ // HostProgress groups restore progress for the host.
274
+ type HostProgress struct {
275
+ Host string `json:"host"`
276
+ ShardCnt int `json:"shard_cnt"`
277
+ DownloadedBytes int64 `json:"downloaded_bytes"`
278
+ DownloadDuration int64 `json:"download_duration"`
279
+ }
280
+
281
+ type progress struct {
282
+ Size int64 `json:"size"`
283
+ Restored int64 `json:"restored"`
284
+ Downloaded int64 `json:"downloaded"`
285
+ Failed int64 `json:"failed"`
286
+ StartedAt * time.Time `json:"started_at"`
287
+ CompletedAt * time.Time `json:"completed_at"`
288
+ }
0 commit comments