Skip to content

Instantly share code, notes, and snippets.

@kocolosk
Created July 31, 2009 02:47
Show Gist options
  • Save kocolosk/159055 to your computer and use it in GitHub Desktop.
Save kocolosk/159055 to your computer and use it in GitHub Desktop.
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