mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-09-18 22:14:33 +00:00
Make the first V2 core owner explicit in sw-block by freezing Phase 14 docs, mode/readiness/publication semantics, and bounded command emission rules. This turns accepted Phase 13 constraints into executable core behavior without overclaiming live runtime cutover. Made-with: Cursor
122 lines
3.3 KiB
Go
122 lines
3.3 KiB
Go
package replication
|
|
|
|
// RuntimeAuthority names which runtime currently owns the integrated path.
|
|
// Phase 14 starts by making the V2 core explicit, but integrated tests still
|
|
// evaluate the constrained current runtime until a live cutover exists.
|
|
type RuntimeAuthority string
|
|
|
|
const (
|
|
RuntimeAuthorityConstrainedV1 RuntimeAuthority = "constrained_v1"
|
|
RuntimeAuthorityV2Core RuntimeAuthority = "v2_core"
|
|
)
|
|
|
|
// VolumeRole tracks the local role the core is normalizing.
|
|
type VolumeRole string
|
|
|
|
const (
|
|
RoleUnknown VolumeRole = "unknown"
|
|
RolePrimary VolumeRole = "primary"
|
|
RoleReplica VolumeRole = "replica"
|
|
)
|
|
|
|
// ModeName is the normalized outward mode vocabulary for the bounded chosen path.
|
|
type ModeName string
|
|
|
|
const (
|
|
ModeAllocatedOnly ModeName = "allocated_only"
|
|
ModeBootstrapPending ModeName = "bootstrap_pending"
|
|
ModeReplicaReady ModeName = "replica_ready"
|
|
ModePublishHealthy ModeName = "publish_healthy"
|
|
ModeDegraded ModeName = "degraded"
|
|
ModeNeedsRebuild ModeName = "needs_rebuild"
|
|
)
|
|
|
|
// ReadinessView captures bounded readiness truth for the current chosen path.
|
|
type ReadinessView struct {
|
|
Assigned bool
|
|
RoleApplied bool
|
|
ReceiverReady bool
|
|
ShipperConfigured bool
|
|
ShipperConnected bool
|
|
ReplicaReady bool
|
|
PublishHealthy bool
|
|
}
|
|
|
|
// BoundaryView captures durable/publication boundary truth. DurableLSN is the
|
|
// authority for replicated durability; diagnostic shipped progress is separate.
|
|
type BoundaryView struct {
|
|
DurableLSN uint64
|
|
CheckpointLSN uint64
|
|
DiagnosticShippedLSN uint64
|
|
LastBarrierOK bool
|
|
LastBarrierReason string
|
|
}
|
|
|
|
// ModeView is the bounded external mode meaning derived from the current state.
|
|
type ModeView struct {
|
|
Name ModeName
|
|
Reason string
|
|
Authority RuntimeAuthority
|
|
}
|
|
|
|
// PublicationView is the outward publication truth derived from the same core
|
|
// state. It is kept separate from readiness so the publication automaton stays
|
|
// explicit in Phase 14A.
|
|
type PublicationView struct {
|
|
Healthy bool
|
|
Reason string
|
|
}
|
|
|
|
type commandState struct {
|
|
RoleEpoch uint64
|
|
Role VolumeRole
|
|
ReceiverStartEpoch uint64
|
|
ShipperConfigEpoch uint64
|
|
ShipperConfigReplicas []ReplicaAssignment
|
|
InvalidationIssued bool
|
|
InvalidationReason string
|
|
}
|
|
|
|
// VolumeState is the minimal V2-core-owned state for one volume on the bounded
|
|
// current path.
|
|
type VolumeState struct {
|
|
VolumeID string
|
|
Epoch uint64
|
|
Role VolumeRole
|
|
|
|
DesiredReplicas []ReplicaAssignment
|
|
Readiness ReadinessView
|
|
Boundary BoundaryView
|
|
Mode ModeView
|
|
Publication PublicationView
|
|
|
|
degraded bool
|
|
degradeReason string
|
|
needsRebuild bool
|
|
rebuildReason string
|
|
commands commandState
|
|
}
|
|
|
|
func newVolumeState(volumeID string) *VolumeState {
|
|
return &VolumeState{
|
|
VolumeID: volumeID,
|
|
Role: RoleUnknown,
|
|
Mode: ModeView{
|
|
Name: ModeAllocatedOnly,
|
|
Authority: RuntimeAuthorityConstrainedV1,
|
|
},
|
|
}
|
|
}
|
|
|
|
// Snapshot returns a detached copy of the state for external inspection/tests.
|
|
func (s *VolumeState) Snapshot() VolumeState {
|
|
out := *s
|
|
if s.DesiredReplicas != nil {
|
|
out.DesiredReplicas = append([]ReplicaAssignment(nil), s.DesiredReplicas...)
|
|
}
|
|
if s.commands.ShipperConfigReplicas != nil {
|
|
out.commands.ShipperConfigReplicas = append([]ReplicaAssignment(nil), s.commands.ShipperConfigReplicas...)
|
|
}
|
|
return out
|
|
}
|