mirror of
https://github.com/zrepl/zrepl.git
synced 2024-11-28 19:34:58 +01:00
30cdc1430e
This commit - adds a configuration in which no step holds, replication cursors, etc. are created - removes the send.step_holds.disable_incremental setting - creates a new config option `replication` for active-side jobs - adds the replication.protection.{initial,incremental} settings, each of which can have values - `guarantee_resumability` - `guarantee_incremental` - `guarantee_nothing` (refer to docs/configuration/replication.rst for semantics) The `replication` config from an active side is sent to both endpoint.Sender and endpoint.Receiver for each replication step. Sender and Receiver then act accordingly. For `guarantee_incremental`, we add the new `tentative-replication-cursor` abstraction. The necessity for that abstraction is outlined in https://github.com/zrepl/zrepl/issues/340. fixes https://github.com/zrepl/zrepl/issues/340
93 lines
1.9 KiB
Go
93 lines
1.9 KiB
Go
package pdu
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
|
|
"github.com/zrepl/zrepl/zfs"
|
|
)
|
|
|
|
func (v *FilesystemVersion) GetRelName() string {
|
|
zv, err := v.ZFSFilesystemVersion()
|
|
if err != nil {
|
|
return ""
|
|
}
|
|
return zv.String()
|
|
}
|
|
|
|
func (v *FilesystemVersion) RelName() string {
|
|
zv, err := v.ZFSFilesystemVersion()
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return zv.String()
|
|
}
|
|
|
|
func (v FilesystemVersion_VersionType) ZFSVersionType() zfs.VersionType {
|
|
switch v {
|
|
case FilesystemVersion_Snapshot:
|
|
return zfs.Snapshot
|
|
case FilesystemVersion_Bookmark:
|
|
return zfs.Bookmark
|
|
default:
|
|
panic(fmt.Sprintf("unexpected v.Type %#v", v))
|
|
}
|
|
}
|
|
|
|
func FilesystemVersionFromZFS(fsv *zfs.FilesystemVersion) *FilesystemVersion {
|
|
var t FilesystemVersion_VersionType
|
|
switch fsv.Type {
|
|
case zfs.Bookmark:
|
|
t = FilesystemVersion_Bookmark
|
|
case zfs.Snapshot:
|
|
t = FilesystemVersion_Snapshot
|
|
default:
|
|
panic("unknown fsv.Type: " + fsv.Type)
|
|
}
|
|
return &FilesystemVersion{
|
|
Type: t,
|
|
Name: fsv.Name,
|
|
Guid: fsv.Guid,
|
|
CreateTXG: fsv.CreateTXG,
|
|
Creation: fsv.Creation.Format(time.RFC3339),
|
|
}
|
|
}
|
|
|
|
func FilesystemVersionCreation(t time.Time) string {
|
|
return t.Format(time.RFC3339)
|
|
}
|
|
|
|
func (v *FilesystemVersion) CreationAsTime() (time.Time, error) {
|
|
return time.Parse(time.RFC3339, v.Creation)
|
|
}
|
|
|
|
// implement fsfsm.FilesystemVersion
|
|
func (v *FilesystemVersion) SnapshotTime() time.Time {
|
|
t, err := v.CreationAsTime()
|
|
if err != nil {
|
|
panic(err) // FIXME
|
|
}
|
|
return t
|
|
}
|
|
|
|
func (v *FilesystemVersion) ZFSFilesystemVersion() (*zfs.FilesystemVersion, error) {
|
|
ct, err := v.CreationAsTime()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &zfs.FilesystemVersion{
|
|
Type: v.Type.ZFSVersionType(),
|
|
Name: v.Name,
|
|
Guid: v.Guid,
|
|
CreateTXG: v.CreateTXG,
|
|
Creation: ct,
|
|
}, nil
|
|
}
|
|
|
|
func ReplicationConfigProtectionWithKind(both ReplicationGuaranteeKind) *ReplicationConfigProtection {
|
|
return &ReplicationConfigProtection{
|
|
Initial: both,
|
|
Incremental: both,
|
|
}
|
|
}
|