45 lines
1.4 KiB
Plaintext
45 lines
1.4 KiB
Plaintext
@startuml fig_35_sync_merge_algorithm
|
||
scale 2.5
|
||
title Wallenc — алгоритм согласования журналов синхронизации (StorageSyncEngine)
|
||
|
||
skinparam defaultFontName "DejaVu Sans"
|
||
skinparam activity {
|
||
BackgroundColor #F8F8F8
|
||
BorderColor #333333
|
||
DiamondBackgroundColor #E8F4FF
|
||
}
|
||
|
||
start
|
||
|
||
:Группа Storage (≥ 2 UUID из DbStorageSyncGroup);
|
||
:Захват блокировок sync (lease);
|
||
:Параллельно: flush + readSyncJournal\nдля каждого Storage;
|
||
|
||
partition "Слияние (StorageSyncJournalMerge)" {
|
||
:Для каждого пути — запись\nс максимальной ревизией;
|
||
note right
|
||
compare: sequence → actorId → createdAt
|
||
end note
|
||
}
|
||
|
||
while (Есть необработанный путь?) is (да)
|
||
:winnerEntry = победитель по пути;
|
||
:sourceStorage = findSourceStorage(winnerEntry);
|
||
if (operation == UPSERT\nи source == null?) then (да)
|
||
:пропуск пути;
|
||
else (нет)
|
||
while (Есть target Storage?) is (да)
|
||
if (ревизия target ≥ winner?) then (да)
|
||
:пропуск target;
|
||
else (нет)
|
||
:applyEntry:\nUPSERT — copy stream\nDELETE/TRASH — на target\n(recordSyncJournal = false);
|
||
endif
|
||
endwhile (нет)
|
||
endif
|
||
endwhile (нет)
|
||
|
||
:Снятие блокировок;
|
||
stop
|
||
|
||
@enduml
|