UpdatePartitionState changes the state of a partition. Returns true if the state was changed, or false if the update was a no-op.
(id int32, state PartitionState, now time.Time)
| 217 | // UpdatePartitionState changes the state of a partition. Returns true if the state was changed, |
| 218 | // or false if the update was a no-op. |
| 219 | func (m *PartitionRingDesc) UpdatePartitionState(id int32, state PartitionState, now time.Time) (bool, error) { |
| 220 | d, ok := m.Partitions[id] |
| 221 | if !ok { |
| 222 | return false, nil |
| 223 | } |
| 224 | |
| 225 | if d.State == state { |
| 226 | return false, nil |
| 227 | } |
| 228 | |
| 229 | if d.StateChangeLocked { |
| 230 | return false, ErrPartitionStateChangeLocked |
| 231 | } |
| 232 | |
| 233 | d.State = state |
| 234 | d.StateTimestamp = now.Unix() |
| 235 | m.Partitions[id] = d |
| 236 | return true, nil |
| 237 | } |
| 238 | |
| 239 | // UpdatePartitionStateChangeLock changes the state change lock of a partition. Returns true if the lock was changed, |
| 240 | // or false if the update was a no-op. |
no outgoing calls