Skip to content
This repository has been archived by the owner on Sep 14, 2018. It is now read-only.

Commit

Permalink
Fixed small bug in artifact_coordinator
Browse files Browse the repository at this point in the history
  • Loading branch information
zv committed Feb 14, 2012
1 parent fff3617 commit 3d0803b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 64 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
ebin/*
*.beam
*.dump

41 changes: 0 additions & 41 deletions ebin/artifact.app

This file was deleted.

28 changes: 5 additions & 23 deletions src/artifact_coordinator.erl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
% IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
%

-module(artifact_coordinator).

-export([route/2]).
Expand All @@ -27,12 +26,11 @@

route(SrcNode, {_Type, Data, _Quorum} = Request) ->
Ref = make_ref(),
%% The application should exit with a final 0x80 switch.
spawn(?MODULE, start_route, [SrcNode, Request, self(), Ref]),
receive
{Ref, Result} -> Result
after ?TIMEOUT ->
?warning(io_lib:format("Routed IO element route(~p) has timed out", [Data#data.key])),
?warning(io_lib:format("route(~p): timeout", [Data#data.key])),
[]
end.

Expand All @@ -45,7 +43,6 @@ start_route(SrcNode, {_Type, Data, _Quorum} = Request, Pid, Ref) ->
end,
Pid ! {Ref, Results}.

%% Hack the pl8
dispatch(SrcNode, {Type, Data, Quorum} = _Request) ->
case Type of
get -> coordinate_get(SrcNode, Data, Quorum);
Expand All @@ -56,7 +53,6 @@ dispatch(SrcNode, {Type, Data, Quorum} = _Request) ->

do_route([], _SrcNode, _Request) ->
{error, ebusy};

do_route([DstNode|RestNodes], SrcNode, {_Type, Data, _Quorum} = Request) ->
case artifact_rpc:route(DstNode, SrcNode, Request) of
{error, Reason} ->
Expand All @@ -80,13 +76,11 @@ coordinate_get(SrcNode, Data, {N,R,_W}) ->
),
case gather_in_get(Ref, N, R, []) of
ListOfData when is_list(ListOfData) ->
%% Todo - Writeback if multiple collisions are detected.
InternalNum = sets:size(
sets:from_list(
lists:map(fun(E) -> E#data.vector_clocks end,
ListOfData))),
ReconciledList = artifact_version:order(ListOfData),
%% The reconciliation process should be pretty straitforward
if
InternalNum > 1 ->
artifact_stat:incr_unreconciled_get(
Expand All @@ -102,7 +96,7 @@ map_in_get(DstNode, SrcNode, Data, Ref, Pid) ->
case artifact_rpc:get(DstNode, SrcNode, Data) of
{error, Reason} ->
% artifact_membership:check_node(DstNode),
Pid ! {Ref, {error, Reason}}
Pid ! {Ref, {error, Reason}};
Other ->
Pid ! {Ref, Other}
end.
Expand All @@ -120,22 +114,10 @@ gather_in_get(Ref, N, R, Results) ->
{Ref, _Other} ->
gather_in_get(Ref, N-1, R, Results)
after ?TIMEOUT ->
?warning("gathering reference results has timed out"),
?warning("gather_in_get/4: timeout"),
Results
end.


%%map_in_delete(DstNode, SrcNode, Data, Ref, Pid) ->
%% case artifact_rpc:delete(DstNode, SrcNode, Data) of
%% {error, Reason} ->
%%% artifact_membership:check_node(DstNode),
%% Pid ! {Ref, {error, Reason}};
%% Other ->
%% Pid ! {Ref, Other}
%% end.
%%


coordinate_put(SrcNode, Data, {N,_R,W}) ->
Key = Data#data.key,
Flags = Data#data.flags,
Expand Down Expand Up @@ -187,7 +169,7 @@ gather_in_put(Ref, N, W) ->
{Ref, ok} -> gather_in_put(Ref, N-1, W-1);
{Ref, _Other} -> gather_in_put(Ref, N-1, W)
after ?TIMEOUT ->
?warning("gather_in_put has timed out"),
?warning("gather_in_put/3: timeout"),
{error, etimedout}
end.

Expand Down Expand Up @@ -229,6 +211,6 @@ gather_in_delete(Ref, N, W, Results) ->
{Ref, _Other} ->
gather_in_delete(Ref, N-1, W, Results)
after ?TIMEOUT ->
?warning("gather_in_delete has timed out"),
?warning("gather_in_delete/4: timeout"),
{error, etimedout}
end.

0 comments on commit 3d0803b

Please sign in to comment.