Skip to content

Commit 2b05530

Browse files
committed
more cleanup
1 parent 3953aef commit 2b05530

4 files changed

Lines changed: 9 additions & 26 deletions

File tree

src/basho_bench.erl

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -283,10 +283,10 @@ get_addr_args() ->
283283
{ok, IfAddrs} = inet:getifaddrs(),
284284
FlattAttrib = lists:flatten([IfAttrib || {_Ifname, IfAttrib} <- IfAddrs]),
285285
Addrs = proplists:get_all_values(addr, FlattAttrib),
286-
StrAddrs = lists:map(fun(X) -> inet:ntoa(X) end, Addrs),
286+
% If inet:ntoa is unavailable, it probably means that you're running <R16
287+
StrAddrs = [inet:ntoa(Addr) || Addr <- Addrs],
287288
string:join(StrAddrs, " ").
288289
setup_distributed_work() ->
289-
io:format("Using cookie: ~p~n", [erlang:get_cookie()]),
290290
case node() of
291291
'nonode@nohost' ->
292292
?STD_ERR("Basho bench not started in distributed mode, and distribute_work = true~n", []),
@@ -301,32 +301,13 @@ setup_distributed_work() ->
301301
RemoteSpec = basho_bench_config:get(remote_nodes, []),
302302
Cookie = lists:flatten(erlang:atom_to_list(erlang:get_cookie())),
303303
Args = "-setcookie " ++ Cookie ++ " -loader inet -hosts " ++ get_addr_args(),
304-
[io:format("Starting slave {~p, ~p, ~p}~n", [Host, Name, Args]) || {Host, Name} <- RemoteSpec],
305304
Slaves = [ slave:start_link(Host, Name, Args) || {Host, Name} <- RemoteSpec],
306305
SlaveNames = [SlaveName || {ok, SlaveName} <- Slaves],
307306
[pool:attach(SlaveName) || SlaveName <- SlaveNames],
308307
CodePaths = code:get_path(),
309308
rpc:multicall(SlaveNames, code, set_path, [CodePaths]),
310309
Apps = [lager, basho_bench, getopt, bear, folsom, ibrowse, riakc, riak_pb, mochiweb, protobuffs, velvet, goldrush],
311310
[distribute_app(App, SlaveNames) || App <- Apps].
312-
% io:format("Running escript: ~p~n", [escript:script_name()]),
313-
%% Assumes I'm running basho_bench from an escript, otherwise the behaviour is undefined
314-
% EscriptFileName = escript:script_name(),
315-
% {ok, Sections} = escript:extract(EscriptFileName, [compile_source]),
316-
% io:format("Sections: ~p~n", [Sections]),
317-
318-
% Libdir = code:lib_dir(basho_bench),
319-
% LibdirLen = string:len(Libdir),
320-
% BashoBenchLibs = lists:filter(fun(X) -> string:substr(X, 1, LibdirLen) == Libdir end, code:get_path()),
321-
% io:format("Basho Bench Library Directoryies: ~p~n", [BashoBenchLibs]),
322-
% io:format("Basho_bench lib dir: ~p~n", [Libdir]),
323-
% io:format("Libdir: ~p~n", [erl_prim_loader:list_dir(Libdir)]),
324-
% io:format("Code Path: ~p~n", [code:get_path()]),
325-
326-
% io:format("Files? ~p~n", [erl_prim_loader:list_dir("/Users/sdhillon/repos/basho_bench/basho_bench/basho_bench/ebin")]),
327-
% io:format("Remote nodes: ~p~n", [nodes()]),
328-
% RemoteFiles = rpc:call('bb25@3c075477e55e-2.local', erl_prim_loader, list_dir, ["/Users/sdhillon/repos/basho_bench/basho_bench/basho_bench/ebin"]),
329-
% io:format("Remote files: ~p~n", [RemoteFiles]),
330311

331312

332313
deploy_module(Module, Nodes) ->
@@ -352,7 +333,7 @@ distribute_app(App, Nodes) ->
352333
EbinDirDistributeFun = fun(EbinDir) ->
353334
{ok, Beams} = erl_prim_loader:list_dir(EbinDir),
354335
Modules = lists:filtermap(StripEndFun, Beams),
355-
ModulesLoaded = lists:map(fun(X) -> code:load_abs(filename:join(EbinDir, X)) end, Modules),
336+
ModulesLoaded = [code:load_abs(filename:join(EbinDir, ModFileName)) || ModFileName <- Modules],
356337
lists:foreach(fun({module, Module}) -> deploy_module(Module, Nodes) end, ModulesLoaded)
357338
end,
358339
lists:foreach(EbinDirDistributeFun, EbinsDir),

src/basho_bench_app.erl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ stop_or_kill() ->
7979
%%===================================================================
8080

8181
start(_StartType, _StartArgs) ->
82+
%% TODO: Move into a proper supervision tree, janky for now
83+
basho_bench_config:start_link(),
8284
{ok, Pid} = basho_bench_sup:start_link(),
8385
application:set_env(basho_bench_app, is_running, true),
8486
ok = basho_bench_stats:run(),

src/basho_bench_config.erl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ terminate(_Reason, _State) ->
129129
ok.
130130

131131
handle_call({load_files, FileNames}, _From, State) ->
132-
TermsList = get_keys_from_files(FileNames),
132+
set_keys_from_files(FileNames),
133133
{reply, ok, State};
134134

135135
handle_call({set, Key, Value}, _From, State) ->
@@ -139,7 +139,7 @@ handle_call({get, Key}, _From, State) ->
139139
Value = application:get_env(basho_bench, Key),
140140
{reply, Value, State}.
141141

142-
get_keys_from_files(Files) ->
142+
set_keys_from_files(Files) ->
143143
KVs = [ case file:consult(File) of
144144
{ok, Terms} ->
145145
Terms;
@@ -148,5 +148,6 @@ get_keys_from_files(Files) ->
148148
throw(invalid_config),
149149
notokay
150150
end || File <- Files ],
151-
[application:set_env(basho_bench, Key, Value) || {Key, Value} <- KVs].
151+
FlatKVs = lists:flatten(KVs),
152+
[application:set_env(basho_bench, Key, Value) || {Key, Value} <- FlatKVs].
152153

src/basho_bench_worker.erl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ start_link(SupChild, Id) ->
6464
end.
6565

6666
start_link_distributed(SupChild, Id) ->
67-
io:format("Bootstrapped pool ~p~n", [pool:get_nodes()]),
6867
Node = pool:get_node(),
6968
rpc:block_call(Node, ?MODULE, start_link_local, [SupChild, Id]).
7069

0 commit comments

Comments
 (0)