From 674a7ac80dac82addd69d4774e00d84faf97cfeb Mon Sep 17 00:00:00 2001 From: Bohdan Korniyenko Date: Fri, 24 Apr 2015 13:22:13 +0300 Subject: [PATCH 1/2] change client scripts --- start.sh | 11 ----------- start_cluster.sh | 18 ++++++++++++++++++ start_local.sh | 2 +- 3 files changed, 19 insertions(+), 12 deletions(-) delete mode 100755 start.sh create mode 100755 start_cluster.sh diff --git a/start.sh b/start.sh deleted file mode 100755 index 4f6fa67..0000000 --- a/start.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env escript -%% -*- erlang -*- -%%! -pa ebin deps/lager/ebin deps/goldrush/ebin -setcookie secret_gc -name master@localhost -attached - -main([]) -> - process_flag(trap_exit, true), - master:test_cluster(), - receive - stop -> ok; - Error -> lager:error("Error: ~p", [Error]) - end. diff --git a/start_cluster.sh b/start_cluster.sh new file mode 100755 index 0000000..640a077 --- /dev/null +++ b/start_cluster.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env escript +%% -*- erlang -*- +%%! -pa ebin deps/lager/ebin deps/goldrush/ebin -setcookie secret_gc -name client@localhost -attached + +main([MasterIpStr, WorkersNumStr]) -> + lager:start(), + MasterPid = {master, list_to_atom("master@" ++ MasterIpStr)}, + WorkersNum = list_to_integer(WorkersNumStr), + ok = gen_server:call(MasterPid , {run, "bwt_files/SRR770176_1.fastq", "GL000193.1", WorkersNum}), + receive_cigars(). + +receive_cigars() -> + receive + {cigar, SeqName, Chromosome, Pos, CigarValue, CigarRate, SeqValue} -> + io:format("~s ~s ~b ~s ~b ~s~n", [SeqName, Chromosome, Pos, CigarValue, CigarRate, SeqValue]), + receive_cigars(); + _ -> throw(not_a_cigar) + end. \ No newline at end of file diff --git a/start_local.sh b/start_local.sh index 1917a77..452f654 100755 --- a/start_local.sh +++ b/start_local.sh @@ -3,5 +3,5 @@ %%! -pa ebin deps/lager/ebin deps/goldrush/ebin -setcookie secret_gc -name master@localhost -attached main([]) -> - master:test_local(), + master:test(), receive stop -> ok end. From b1b58fb8682f70806d2ef1a75d97de8e242866d2 Mon Sep 17 00:00:00 2001 From: Bohdan Korniyenko Date: Fri, 24 Apr 2015 13:49:44 +0300 Subject: [PATCH 2/2] edit client script; move master --- apps/worker_bwt_app/src/worker_bwt_app_sup.erl | 2 +- start_cluster.sh | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/apps/worker_bwt_app/src/worker_bwt_app_sup.erl b/apps/worker_bwt_app/src/worker_bwt_app_sup.erl index ae807f6..faa9f39 100644 --- a/apps/worker_bwt_app/src/worker_bwt_app_sup.erl +++ b/apps/worker_bwt_app/src/worker_bwt_app_sup.erl @@ -25,7 +25,7 @@ start_link() -> init([]) -> {ok, { {one_for_one, 5, 10}, [ - {worker_bwt, {worker_bwt, start_link, [{master, 'master@45.55.245.10'}]}, permanent, 5000, worker, [worker_bwt]} + {worker_bwt, {worker_bwt, start_link, [{master, 'master@erlangonxen.org'}]}, permanent, 5000, worker, [worker_bwt]} ]} }. diff --git a/start_cluster.sh b/start_cluster.sh index 640a077..ee2d932 100755 --- a/start_cluster.sh +++ b/start_cluster.sh @@ -3,10 +3,14 @@ %%! -pa ebin deps/lager/ebin deps/goldrush/ebin -setcookie secret_gc -name client@localhost -attached main([MasterIpStr, WorkersNumStr]) -> - lager:start(), - MasterPid = {master, list_to_atom("master@" ++ MasterIpStr)}, + main(["GL000193.1", MasterIpStr, WorkersNumStr]); + +main([Chromosome, MasterIpStr, WorkersNumStr]) -> + MasterPid = rpc:call(list_to_atom("master@" ++ MasterIpStr), erlang, whereis,[master]), WorkersNum = list_to_integer(WorkersNumStr), - ok = gen_server:call(MasterPid , {run, "bwt_files/SRR770176_1.fastq", "GL000193.1", WorkersNum}), + process_flag(trap_exit, true), + true = link(MasterPid), + ok = gen_server:call(MasterPid , {run, "bwt_files/SRR770176_1.fastq", Chromosome, WorkersNum}), receive_cigars(). receive_cigars() -> @@ -14,5 +18,6 @@ receive_cigars() -> {cigar, SeqName, Chromosome, Pos, CigarValue, CigarRate, SeqValue} -> io:format("~s ~s ~b ~s ~b ~s~n", [SeqName, Chromosome, Pos, CigarValue, CigarRate, SeqValue]), receive_cigars(); - _ -> throw(not_a_cigar) + + Error -> io:format("Error: ~p~n", [Error]) end. \ No newline at end of file