Skip to content

Commit

Permalink
sdk-fix: replace old dp with the new one
Browse files Browse the repository at this point in the history
Signed-off-by: Shuoran Liu <[email protected]>
  • Loading branch information
shuoranliu authored and liushuoran001 committed Apr 13, 2022
1 parent 8931e1f commit 0927ced
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions sdk/data/wrapper/wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,26 +219,17 @@ func (w *Wrapper) updateDataPartition(isInit bool) (err error) {
}

func (w *Wrapper) replaceOrInsertPartition(dp *DataPartition) {
var (
oldstatus int8
)
w.Lock()
old, ok := w.partitions[dp.PartitionID]
if ok {
oldstatus = old.Status
old.Status = dp.Status
old.ReplicaNum = dp.ReplicaNum
old.Hosts = dp.Hosts
old.NearHosts = dp.Hosts
dp.Metrics = old.Metrics
} else {
dp.Metrics = NewDataPartitionMetrics()
w.partitions[dp.PartitionID] = dp
}

w.partitions[dp.PartitionID] = dp
w.Unlock()

if ok && oldstatus != dp.Status {
if ok && old.Status != dp.Status {
log.LogInfof("partition: status change (%v) -> (%v)", old, dp)
}
}
Expand Down

0 comments on commit 0927ced

Please sign in to comment.