This commit is contained in:
Christian Schwarz 2018-08-16 14:02:33 +02:00
parent bf1e626b9a
commit c7d28fee8f

View File

@ -45,9 +45,9 @@ type replicationQueueItem struct {
// duplicates fsr.state to avoid accessing and locking fsr // duplicates fsr.state to avoid accessing and locking fsr
state FSReplicationState state FSReplicationState
// duplicates fsr.current.nextStepDate to avoid accessing & locking fsr // duplicates fsr.current.nextStepDate to avoid accessing & locking fsr
nextStepDate time.Time nextStepDate time.Time
fsr *FSReplication fsr *FSReplication
} }
type Replication struct { type Replication struct {
@ -57,9 +57,9 @@ type Replication struct {
state ReplicationState state ReplicationState
// Working, WorkingWait, Completed, ContextDone // Working, WorkingWait, Completed, ContextDone
queue *replicationQueue queue *replicationQueue
completed []*FSReplication completed []*FSReplication
active *FSReplication active *FSReplication
// PlanningError // PlanningError
planningError error planningError error
@ -379,19 +379,19 @@ func (b *replicationQueueItemBuilder) AddStep(from, to *FilesystemVersion) *repl
type replicationQueue []*replicationQueueItem type replicationQueue []*replicationQueueItem
func newReplicationQueue() *replicationQueue { func newReplicationQueue() *replicationQueue {
q := make(replicationQueue, 0) q := make(replicationQueue, 0)
return &q return &q
} }
func (q replicationQueue) Len() int { return len(q) } func (q replicationQueue) Len() int { return len(q) }
func (q replicationQueue) Swap(i,j int) { q[i], q[j] = q[j], q[i]} func (q replicationQueue) Swap(i, j int) { q[i], q[j] = q[j], q[i] }
func (q replicationQueue) Less(i,j int) bool { func (q replicationQueue) Less(i, j int) bool {
a, b := q[i], q[j] a, b := q[i], q[j]
statePrio := func(x *replicationQueueItem) int { statePrio := func(x *replicationQueueItem) int {
if x.state&(FSReady|FSRetryWait) == 0 { if x.state&(FSReady|FSRetryWait) == 0 {
panic(x) panic(x)
} }
if x.state== FSReady { if x.state == FSReady {
return 0 return 0
} }
return 1 return 1