(lastKnownTableSchemaCache TableSchemaCache, binlogVerifyStore *BinlogVerifyStore)
| 306 | } |
| 307 | |
| 308 | func (s *StateTracker) Serialize(lastKnownTableSchemaCache TableSchemaCache, binlogVerifyStore *BinlogVerifyStore) *SerializableState { |
| 309 | s.BinlogRWMutex.RLock() |
| 310 | defer s.BinlogRWMutex.RUnlock() |
| 311 | |
| 312 | s.CopyRWMutex.RLock() |
| 313 | defer s.CopyRWMutex.RUnlock() |
| 314 | |
| 315 | state := &SerializableState{ |
| 316 | GhostferryVersion: VersionString, |
| 317 | LastKnownTableSchemaCache: lastKnownTableSchemaCache, |
| 318 | LastSuccessfulPaginationKeys: make(map[string]PaginationKey), |
| 319 | CompletedTables: make(map[string]bool), |
| 320 | LastWrittenBinlogPosition: s.lastWrittenBinlogPosition, |
| 321 | LastStoredBinlogPositionForInlineVerifier: s.lastStoredBinlogPositionForInlineVerifier, |
| 322 | LastStoredBinlogPositionForTargetVerifier: s.lastStoredBinlogPositionForTargetVerifier, |
| 323 | } |
| 324 | |
| 325 | if binlogVerifyStore != nil { |
| 326 | state.BinlogVerifyStore = binlogVerifyStore.Serialize() |
| 327 | } |
| 328 | |
| 329 | // Need a copy because lastSuccessfulPaginationKeys may change after Serialize |
| 330 | // returns. This would inaccurately reflect the state of Ghostferry when |
| 331 | // Serialize is called. |
| 332 | for k, v := range s.lastSuccessfulPaginationKeys { |
| 333 | state.LastSuccessfulPaginationKeys[k] = v |
| 334 | } |
| 335 | |
| 336 | for k, v := range s.completedTables { |
| 337 | state.CompletedTables[k] = v |
| 338 | } |
| 339 | |
| 340 | return state |
| 341 | } |
no outgoing calls