Unified
Split
Showing
with
19 additions
and 5 deletions.
- +16 −3 apps/wiggle/src/wiggle_dataset_handler.erl
- +1 −1 rebar.config
- +2 −1 rel/reltool.config
| @@ -25,6 +25,7 @@ | ||
| raw_body/1, | ||
| content_types_accepted/1]). | ||
|
|
||
| -define(WRETRY, 5). | ||
|
|
||
| allowed_methods(_Version, _Token, []) -> | ||
| [<<"GET">>, <<"POST">>]; | ||
| @@ -257,10 +258,10 @@ transform_dataset(D1) -> | ||
| import_dataset(UUID, Idx, TotalSize, Req, WReq) -> | ||
| case cowboy_req:stream_body(1024*1024, Req) of | ||
| {ok, Data, Req1} -> | ||
| Idx1 = Idx + 1, | ||
| Done = (Idx1 * 1024*1024) / TotalSize, | ||
| case libsniffle:img_create(UUID, Idx, Data, WReq) of | ||
| case do_write(UUID, Idx, Data, WReq, 0) of | ||
| {ok, WReq1} -> | ||
| Idx1 = Idx + 1, | ||
| Done = (Idx1 * 1024*1024) / TotalSize, | ||
| libsniffle:dataset_set(UUID, <<"imported">>, Done), | ||
| libhowl:send(UUID, | ||
| [{<<"event">>, <<"progress">>}, | ||
| @@ -282,6 +283,18 @@ import_dataset(UUID, Idx, TotalSize, Req, WReq) -> | ||
| {false, Req} | ||
| end. | ||
|
|
||
| do_write(_, _, _, _, ?WRETRY) -> | ||
| {error, retry_exceeded}; | ||
| do_write(UUID, Idx, Data, WReq, Retry) -> | ||
| case libsniffle:img_create(UUID, Idx, Data, WReq) of | ||
| {ok, WReq1} -> | ||
| {ok, WReq1}; | ||
| Reason -> | ||
| lager:warning("[~s:~p] Import Error: ~p", | ||
| [UUID, Retry, Reason]), | ||
| do_write(UUID, Idx, Data, WReq, Retry + 1) | ||
| end. | ||
|
|
||
| fail_import(UUID, Reason, Idx) -> | ||
| lager:error("[~s] Could not import dataset: ~p", [UUID, Reason]), | ||
| libhowl:send(UUID, | ||
| @@ -25,7 +25,7 @@ | ||
| {ensq_rpc, ".*", {git, "git://github.com/project-fifo/ensq_rpc.git", {tag, "0.1.0"}}}, | ||
| {uuid, ".*", {git, "https://github.com/project-fifo/erlang-uuid.git", {branch, "master"}}}, | ||
| {fifo_spec, ".*", {git, "https://github.com/project-fifo/fifo_spec.git", {tag, "0.1.3"}}}, | ||
| {libchunter, ".*", {git, "http://github.com/project-fifo/libchunter.git", {tag, "0.1.9"}}}, | ||
| {libchunter, ".*", {git, "http://github.com/project-fifo/libchunter.git", {tag, "0.1.24"}}}, | ||
| {libhowl, ".*", {git, "http://github.com/project-fifo/libhowl.git", {tag, "0.1.15"}}}, | ||
| {libsniffle, ".*", {git, "http://github.com/project-fifo/libsniffle.git", {tag, "0.2.29"}}}, | ||
| {libsnarl, ".*", {git, "http://github.com/project-fifo/libsnarl.git", {tag, "0.2.31"}}} | ||
| @@ -38,7 +38,8 @@ | ||
| {template, "../schema/lager.schema", "share/schema/03-lager.schema"}, | ||
| {template, "../schema/snmp.schema", "share/schema/04-snmp.schema"}, | ||
| {template, "../deps/ensq/priv/ensq.schema", "share/schema/05-ensq.schema"}, | ||
| {template, "../deps/ensq_rpc/priv/ensq_rpc.schema", "share/schema/06-ensq_rpc.schema"}, | ||
| {template, "../deps/mdns_client_lib/priv/mdns_client.schema", "share/schema/06-mdns_client.schema"}, | ||
| {template, "../deps/ensq_rpc/priv/ensq_rpc.schema", "share/schema/07-ensq_rpc.schema"}, | ||
| {copy, "../plugins", "plugins"}, | ||
| {copy, "../snmp", "snmp"}, | ||
| {copy, "../LICENSE", "LICENSE"}, | ||