Skip to content

Commit

Permalink
writes tags to s3
Browse files Browse the repository at this point in the history
  • Loading branch information
tsloughter authored and srobertson committed Oct 7, 2012
1 parent 4acc36d commit d2c57b8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
14 changes: 13 additions & 1 deletion master/src/ddfs/ddfs_tag.erl
Expand Up @@ -665,10 +665,22 @@ put_distribute({TagID, _} = Msg) ->
[{node(), binary()}], [node()]) ->
{error, replication_failed} | {ok, [{node(), binary()}]}.
put_distribute({TagID, TagData}, K, OkNodes, _Exclude) when K == length(OkNodes) ->
disco_aws:spawn_put(get(s3_bucket), TagID, TagData),
disco_aws:put(get(s3_bucket), binary_to_list(TagID), TagData),
{ok, OkNodes};

put_distribute({TagID, TagData} = Msg, K, OkNodes, Exclude) ->
case get(use_s3) of
true ->
disco_aws:put(get(s3_bucket), binary_to_list(TagID), TagData),
put_distribute_(Msg, K, OkNodes, Exclude);
false ->
put_distribute_(Msg, K, OkNodes, Exclude)
end.

-spec put_distribute_({tagid(), binary()}, non_neg_integer(),
[{node(), binary()}], [node()]) ->
{error, replication_failed} | {ok, [{node(), binary()}]}.
put_distribute_({TagID, TagData} = Msg, K, OkNodes, Exclude) ->
TagMinK = get(min_tagk),
K0 = K - length(OkNodes),
{ok, Nodes} = ddfs_master:choose_write_nodes(K0, Exclude),
Expand Down
10 changes: 8 additions & 2 deletions master/src/disco_aws.erl
Expand Up @@ -9,18 +9,24 @@
-module(disco_aws).

%% API
-export([spawn_put/3,
-export([put/3,
spawn_put/3,
set_aws_creds/0]).

%%%===================================================================
%%% API
%%%===================================================================

-spec put(string(), string(), binary()) -> term().
put(Bucket, Dir, Contents) ->
Creds = get_config(),
erlcloud_s3:put_object(Bucket, Dir, Contents, Creds).

-spec spawn_put(string(), string(), binary()) -> pid().
spawn_put(Bucket, Dir, Contents) ->
Creds = get_config(),
proc_lib:spawn(fun()->
erlcloud_s3:put_object(Bucket, binary_to_list(Dir), Contents, Creds)
erlcloud_s3:put_object(Bucket, Dir, Contents, Creds)
end).

-spec set_aws_creds() -> record().
Expand Down

0 comments on commit d2c57b8

Please sign in to comment.