51 lines
1.4 KiB
Plaintext
51 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
|
||
для каждого Storage;
|
||
|
||
partition "Слияние (StorageSyncJournalMerge)" {
|
||
:Для каждого пути — запись
|
||
с максимальной ревизией;
|
||
note right
|
||
compare: sequence → actorId → createdAt
|
||
end note
|
||
}
|
||
|
||
while (Есть необработанный путь?) is (да)
|
||
:winnerEntry = победитель по пути;
|
||
:sourceStorage = findSourceStorage(winnerEntry);
|
||
if (operation == UPSERT
|
||
и source == null?) then (да)
|
||
:пропуск пути;
|
||
else (нет)
|
||
while (Есть target Storage?) is (да)
|
||
if (ревизия target ≥ winner?) then (да)
|
||
:пропуск target;
|
||
else (нет)
|
||
:applyEntry:
|
||
UPSERT — copy stream
|
||
DELETE/TRASH — на target
|
||
(recordSyncJournal = false);
|
||
endif
|
||
endwhile (нет)
|
||
endif
|
||
endwhile (нет)
|
||
|
||
:Снятие блокировок;
|
||
stop
|
||
|
||
@enduml
|