ressync

package
v3.0.0-rc49 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 14, 2026 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	KWMaxDelay = keywords.Keyword{
		Aliases:       []string{"sync_max_delay"},
		Attr:          "MaxDelay",
		Converter:     converters.Duration,
		DefaultOption: "sync_max_delay",
		Option:        "max_delay",
		Text:          keywords.NewText(fs, "text/kw/max_delay"),
	}
	KWSchedule = keywords.Keyword{
		Attr:          "Schedule",
		DefaultOption: "sync_schedule",
		Example:       "00:00-01:00 mon",
		Option:        "schedule",
		Scopable:      true,
		Text:          keywords.NewText(fs, "text/kw/schedule"),
	}

	BaseKeywords = []*keywords.Keyword{
		&KWMaxDelay,
		&KWSchedule,
	}
)

Functions

This section is empty.

Types

type DatasetReplicator

type DatasetReplicator interface {
	RID() string
	ReplicatesDataset(dataset string) bool
	GetMaxDelay(lastSync time.Time) time.Duration
	MaxDelayOrigin() string
}

DatasetReplicator is a sync resource replicating zfs datasets to its peers, as sync.zfs does. It tells the snapshot resources of the object which of their datasets reach the peers, and how fresh the replicas are expected to be.

type Stats

type Stats struct {
	Endpoint      string
	SentBytes     uint64
	ReceivedBytes uint64
	Begin         time.Time
	End           time.Time
}

func NewStats

func NewStats(endpoint string) *Stats

func (*Stats) Close

func (t *Stats) Close()

func (*Stats) Duration

func (t *Stats) Duration() (duration time.Duration)

func (*Stats) SpeedBPS

func (t *Stats) SpeedBPS() (speed float64)

type T

type T struct {
	resource.T
	MaxDelay *time.Duration `json:"max_delay"`
	Schedule string         `json:"schedule"`
	Path     naming.Path    `json:"path"`

	// ObjectEnv and NodeEnv are the env of the object and of this
	// node, for the drivers whose manifest binds them.
	ObjectEnv string `json:"object_env"`
	NodeEnv   string `json:"node_env"`
}

func (*T) CopyWithStats

func (t *T) CopyWithStats(ctx context.Context, dst io.Writer, src io.Reader, stats *Stats) (uint64, error)

func (*T) EnvSkipReason

func (t *T) EnvSkipReason() string

EnvSkipReason returns why a sync from this node is skipped, or "" when it is not.

A PRD object running on a node that is not PRD, as on a DRP node after a failover, does not sync: its copies on the PRD nodes are the data to fall back to, which a sync from here would overwrite. The other envs sync wherever they run, as in v2.

func (*T) GetMaxDelay

func (t *T) GetMaxDelay(lastSync time.Time) time.Duration

GetMaxDelay is how long after lastSync the copy is stale: max_delay when set, or else derived from the schedule, 0 meaning neither is.

func (*T) GetTargetNodenames

func (t *T) GetTargetNodenames(target, nodes, drpNodes []string) []string

func (*T) GetTargetPeernames

func (t *T) GetTargetPeernames(target, nodes, drpNodes []string) []string

func (*T) IsInstanceSufficientlyStarted

func (t *T) IsInstanceSufficientlyStarted(ctx context.Context) (bool, string)

IsInstanceSufficientlyStarted reports whether this node holds the instance the data is replicated from, and why not when it does not. See instance.IsReplicationSource for the rules.

A node where its reference resources are not up is a passive one, which must not send: its copy would replace the one of the active node.

func (*T) MaxDelayOrigin

func (t *T) MaxDelayOrigin() string

MaxDelayOrigin says where GetMaxDelay takes its value from, for the messages to say why a copy is stale.

func (*T) PeerEnvRefusal

func (t *T) PeerEnvRefusal(nodename string) error

PeerEnvRefusal returns why the peer nodename is not sent the data of the resource, or nil when it is.

A node that is not PRD sends nothing to a PRD node, whatever the env of the object: its data would overwrite the production one there. It completes the rule of EnvSkipReason, which is about the object, with the one about the nodes.

func (*T) RunDir

func (t *T) RunDir() runfiles.Dir

RunDir holds a file per sync in progress, as the one of a task: the daemon watches it, and marks the resource and its instance running while a file is there.

func (*T) Running

func (t *T) Running() (resource.RunningInfoList, error)

Running implements resource.Runninger: the syncs in progress, from their run files.

func (*T) SelectPeernames

func (t *T) SelectPeernames(target, configured, nodes, drpNodes []string) ([]string, error)

SelectPeernames is the peers a run asked to sync to target reaches, among the peers of configured, the target of the configuration. An empty target asks all of them. A target is "nodes", "drpnodes", "local", or a node selector expression, so a peer that needs syncing on its own is named.

func (*T) StartRun

func (t *T) StartRun() (func(), error)

StartRun records a sync in progress until the func it returns is called.

func (*T) StatusLastSync

func (t *T) StatusLastSync(nodenames []string, receiving bool) status.T

StatusLastSync judges the freshness of the copies of nodenames. receiving says this node is one of them, a node the data is replicated to, whose copy has a recovery point objective: its max delay.

func (*T) WriteLastSync

func (t *T) WriteLastSync(nodename string) error

func (*T) WritePeerLastSync

func (t *T) WritePeerLastSync(ctx context.Context, peer string) error

WritePeerLastSync records that peer was synced now, and sends it the records it reads: its own last sync, which its status tells the freshness of its copy from, the last syncs of this node and of the other peers, and the last run of the schedule, which keeps its scheduler from syncing again too soon if it becomes the source.

The last syncs of the other peers are what a node that becomes the source tells the freshness of their copies from, until its first sync: a copy is as fresh as the last sync it received, whichever node sent it. v2 sent them all too.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL