Created
July 31, 2009 02:47
-
-
Save kocolosk/159055 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case vector_clock:compare(RemoteVersion, LocalVersion) of | |
equal -> % TODO assert that info is the same on both remote and local | |
{equal, State}; | |
less -> | |
{equal, State}; | |
greater -> | |
server_list_into_table(RemoteServerList, Servers), | |
NewState = State#membership{ | |
nodes = RemoteNodes, | |
version = RemoteVersion, | |
partitions = RemotePMap | |
}, | |
{merged, NewState}; | |
concurrent -> % this is a mess | |
MergedClocks = vector_clock:merge(RemoteVersion, LocalVersion), | |
?infoFmt("Discovered concurrent vector clocks!!! World is f**ed~n" ++ | |
"Remote: ~p~nLocal: ~p~nMerged: ~p~n", [RemoteVersion, LocalVersion, | |
MergedClocks]), | |
ServerList = servers_to_list(Servers), | |
?infoFmt("Server Lists Equal: ~p~nLocal: ~p~nRemote: ~p~n", | |
[ServerList=:=RemoteServerList, ServerList, RemoteServerList]), | |
server_list_into_table(RemoteServerList, Servers), | |
NewState = State#membership{ | |
nodes = lists:usort(RemoteNodes ++ Nodes), | |
version = MergedClocks, | |
partitions = RemotePMap % eh? | |
}, | |
{merged, NewState} | |
end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment