diff --git a/config/sys.config b/config/sys.config index 7dce0d4..527bd20 100644 --- a/config/sys.config +++ b/config/sys.config @@ -7,10 +7,10 @@ ]}, {distributed_workers, [ generic_tasks_server, - generic_tasks_worker + generic_tasks_worker, + node_benchmark_server % sensor_server_worker, % node_stream_worker, - % node_benchmark_server ]}, {node_sensor_server_worker_measurements, [temp]}, {timed_apps, [lasp]}, @@ -42,18 +42,18 @@ ]}, {logger, [ - {level, notice} + {level, debug} ]}, -{kernel, [ - {logger_level, notice}, - {logger, [{handler, - default, - logger_std_h, - #{level => notice, - formatter => {logger_formatter, #{single_line => true}}} - }]} -]}, +% {kernel, [ +% {logger_level, info}, +% {logger, [{handler, +% default, +% logger_std_h, +% #{level => info, +% formatter => {logger_formatter, #{single_line => true}}} +% }]} +% ]}, {lasp, [{membership, false}, {storage_backend, lasp_ets_storage_backend}, @@ -91,7 +91,7 @@ % {gpio1, pmod_amp2}, % {uart, pmod_maxsonar}, % {spi1, pmod_gyro}, - % {spi1, pmod_nav}, + {spi1, pmod_nav} % {spi2, pmod_als} ]} ]} diff --git a/config/test.config b/config/test.config index f2f36b5..5a74a05 100644 --- a/config/test.config +++ b/config/test.config @@ -7,10 +7,10 @@ ]}, {distributed_workers, [ generic_tasks_server, - generic_tasks_worker + generic_tasks_worker, + node_benchmark_server % sensor_server_worker, % node_stream_worker, - % node_benchmark_server ]}, {node_sensor_server_worker_measurements, [temp]}, {timed_apps, [lasp]}, @@ -51,18 +51,18 @@ % {start_cpu_sup, true}, % {start_disk_sup, false} % ]}, - -{kernel, [ - {logger_level, notice}, - {logger, [{handler, - default, - logger_std_h, - % #{level => error, - % #{level => notice, - #{level => notice, - formatter => {logger_formatter, #{single_line => true}}} - }]} -]}, +% +% {kernel, [ +% {logger_level, notice}, +% {logger, [{handler, +% default, +% logger_std_h, +% % #{level => error, +% % #{level => notice, +% #{level => notice, +% formatter => {logger_formatter, #{single_line => true}}} +% }]} +% ]}, {lasp, [{membership, false}, diff --git a/elixir_libs/testflow/.elixir_ls/build/test/lib/flow/.mix/compile.elixir b/elixir_libs/testflow/.elixir_ls/build/test/lib/flow/.mix/compile.elixir deleted file mode 100644 index 600f6b4..0000000 Binary files a/elixir_libs/testflow/.elixir_ls/build/test/lib/flow/.mix/compile.elixir and /dev/null differ diff --git a/elixir_libs/testflow/.elixir_ls/build/test/lib/flow/.mix/compile.elixir_scm b/elixir_libs/testflow/.elixir_ls/build/test/lib/flow/.mix/compile.elixir_scm deleted file mode 100644 index 02b5b31..0000000 Binary files a/elixir_libs/testflow/.elixir_ls/build/test/lib/flow/.mix/compile.elixir_scm and /dev/null differ diff --git a/elixir_libs/testflow/.elixir_ls/build/test/lib/flow/.mix/compile.fetch b/elixir_libs/testflow/.elixir_ls/build/test/lib/flow/.mix/compile.fetch deleted file mode 100644 index e69de29..0000000 diff --git a/elixir_libs/testflow/.elixir_ls/build/test/lib/flow/.mix/compile.xref b/elixir_libs/testflow/.elixir_ls/build/test/lib/flow/.mix/compile.xref deleted file mode 100644 index 161a155..0000000 --- a/elixir_libs/testflow/.elixir_ls/build/test/lib/flow/.mix/compile.xref +++ /dev/null @@ -1 +0,0 @@ -�haj \ No newline at end of file diff --git a/elixir_libs/testflow/.elixir_ls/build/test/lib/gen_stage/.mix/compile.elixir b/elixir_libs/testflow/.elixir_ls/build/test/lib/gen_stage/.mix/compile.elixir deleted file mode 100644 index 0814269..0000000 Binary files a/elixir_libs/testflow/.elixir_ls/build/test/lib/gen_stage/.mix/compile.elixir and /dev/null differ diff --git a/elixir_libs/testflow/.elixir_ls/build/test/lib/gen_stage/.mix/compile.elixir_scm b/elixir_libs/testflow/.elixir_ls/build/test/lib/gen_stage/.mix/compile.elixir_scm deleted file mode 100644 index 02b5b31..0000000 Binary files a/elixir_libs/testflow/.elixir_ls/build/test/lib/gen_stage/.mix/compile.elixir_scm and /dev/null differ diff --git a/elixir_libs/testflow/.elixir_ls/build/test/lib/gen_stage/.mix/compile.fetch b/elixir_libs/testflow/.elixir_ls/build/test/lib/gen_stage/.mix/compile.fetch deleted file mode 100644 index e69de29..0000000 diff --git a/elixir_libs/testflow/.elixir_ls/build/test/lib/gen_stage/.mix/compile.xref b/elixir_libs/testflow/.elixir_ls/build/test/lib/gen_stage/.mix/compile.xref deleted file mode 100644 index 161a155..0000000 --- a/elixir_libs/testflow/.elixir_ls/build/test/lib/gen_stage/.mix/compile.xref +++ /dev/null @@ -1 +0,0 @@ -�haj \ No newline at end of file diff --git a/elixir_libs/testflow/.elixir_ls/build/test/lib/testflow/.mix/compile.elixir b/elixir_libs/testflow/.elixir_ls/build/test/lib/testflow/.mix/compile.elixir deleted file mode 100644 index f502d00..0000000 Binary files a/elixir_libs/testflow/.elixir_ls/build/test/lib/testflow/.mix/compile.elixir and /dev/null differ diff --git a/elixir_libs/testflow/.elixir_ls/build/test/lib/testflow/.mix/compile.elixir_scm b/elixir_libs/testflow/.elixir_ls/build/test/lib/testflow/.mix/compile.elixir_scm deleted file mode 100644 index f4e70c1..0000000 Binary files a/elixir_libs/testflow/.elixir_ls/build/test/lib/testflow/.mix/compile.elixir_scm and /dev/null differ diff --git a/elixir_libs/testflow/.elixir_ls/build/test/lib/testflow/.mix/compile.lock b/elixir_libs/testflow/.elixir_ls/build/test/lib/testflow/.mix/compile.lock deleted file mode 100644 index e69de29..0000000 diff --git a/elixir_libs/testflow/.elixir_ls/build/test/lib/testflow/.mix/compile.protocols b/elixir_libs/testflow/.elixir_ls/build/test/lib/testflow/.mix/compile.protocols deleted file mode 100644 index 51d52fc..0000000 Binary files a/elixir_libs/testflow/.elixir_ls/build/test/lib/testflow/.mix/compile.protocols and /dev/null differ diff --git a/elixir_libs/testflow/.elixir_ls/build/test/lib/testflow/.mix/compile.xref b/elixir_libs/testflow/.elixir_ls/build/test/lib/testflow/.mix/compile.xref deleted file mode 100644 index 161a155..0000000 --- a/elixir_libs/testflow/.elixir_ls/build/test/lib/testflow/.mix/compile.xref +++ /dev/null @@ -1 +0,0 @@ -�haj \ No newline at end of file diff --git a/elixir_libs/testflow/.formatter.exs b/elixir_libs/testflow/.formatter.exs deleted file mode 100644 index d2cda26..0000000 --- a/elixir_libs/testflow/.formatter.exs +++ /dev/null @@ -1,4 +0,0 @@ -# Used by "mix format" -[ - inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"] -] diff --git a/elixir_libs/testflow/.gitignore b/elixir_libs/testflow/.gitignore deleted file mode 100644 index 6a6d49a..0000000 --- a/elixir_libs/testflow/.gitignore +++ /dev/null @@ -1,24 +0,0 @@ -# The directory Mix will write compiled artifacts to. -/_build/ - -# If you run "mix test --cover", coverage assets end up here. -/cover/ - -# The directory Mix downloads your dependencies sources to. -/deps/ - -# Where 3rd-party dependencies like ExDoc output generated docs. -/doc/ - -# Ignore .fetch files in case you like to edit your project deps locally. -/.fetch - -# If the VM crashes, it generates a dump, let's ignore it too. -erl_crash.dump - -# Also ignore archive artifacts (built via "mix archive.build"). -*.ez - -# Ignore package tarball (built via "mix hex.build"). -testflow-*.tar - diff --git a/elixir_libs/testflow/README.md b/elixir_libs/testflow/README.md deleted file mode 100644 index aace8b6..0000000 --- a/elixir_libs/testflow/README.md +++ /dev/null @@ -1,21 +0,0 @@ -# Testflow - -**TODO: Add description** - -## Installation - -If [available in Hex](https://hex.pm/docs/publish), the package can be installed -by adding `testflow` to your list of dependencies in `mix.exs`: - -```elixir -def deps do - [ - {:testflow, "~> 0.1.0"} - ] -end -``` - -Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc) -and published on [HexDocs](https://hexdocs.pm). Once published, the docs can -be found at [https://hexdocs.pm/testflow](https://hexdocs.pm/testflow). - diff --git a/elixir_libs/testflow/config/config.exs b/elixir_libs/testflow/config/config.exs deleted file mode 100644 index 7a9ba6e..0000000 --- a/elixir_libs/testflow/config/config.exs +++ /dev/null @@ -1,30 +0,0 @@ -# This file is responsible for configuring your application -# and its dependencies with the aid of the Mix.Config module. -use Mix.Config - -# This configuration is loaded before any dependency and is restricted -# to this project. If another project depends on this project, this -# file won't be loaded nor affect the parent project. For this reason, -# if you want to provide default values for your application for -# 3rd-party users, it should be done in your "mix.exs" file. - -# You can configure your application as: -# -# config :testflow, key: :value -# -# and access this configuration in your application as: -# -# Application.get_env(:testflow, :key) -# -# You can also configure a 3rd-party app: -# -# config :logger, level: :info -# - -# It is also possible to import configuration files, relative to this -# directory. For example, you can emulate configuration per environment -# by uncommenting the line below and defining dev.exs, test.exs and such. -# Configuration from the imported file will override the ones defined -# here (which is why it is important to import them last). -# -# import_config "#{Mix.env()}.exs" diff --git a/elixir_libs/testflow/lib/testflow.ex b/elixir_libs/testflow/lib/testflow.ex deleted file mode 100644 index d5740a7..0000000 --- a/elixir_libs/testflow/lib/testflow.ex +++ /dev/null @@ -1,141 +0,0 @@ -defmodule Testflow do - @moduledoc """ - Documentation for Testflow. - """ - - @doc """ - Hello world. - - ## Examples - - iex> Testflow.hello() - :world - - """ - def hello do - :world - end - - def get_key(tup) do - k = cond do - {{{y,mo,d},{h,m,s}},p,tmp} = tup -> - # h*60 + m - h - end - k - end - - def sortfun(x1,x2) do - {t1,c1} = x1 - {t2,c2} = x2 - c1 >= c2 - end - - - def mapreduce do - map = %{:cov => -12.941094631619034, - :measures => - [{{{1988,1,1},{0,9,16}},290.30908203125,31.914583333333336}, - {{{1988,1,1},{0,10,16}},1007.046630859375,31.84166666666667}, - {{{1988,1,1},{0,11,16}},290.30908203125,31.877083333333335}], - :pmean => 529.2215983072917,:pvar => 171237.57130004966, - :tmean => 31.877777777777787,:tvar => 0.0013295717592593033} - # a = %{ - # cov => 12.23156, - # measures =>{:calendar.local_time(), 1020.1324, 33.32094} - # - # } - # first = Enum.to_list(Map.get(map, :measures, nil)) - flow = for index <- 1..1000000 do - hour_offset = Enum.random(1..24) - minute_offset = Enum.random(1..60) - second_offset = Enum.random(1..60) - press_absolute_offset = Enum.random(0..20) * :rand.uniform - temp_absolute_offset = Enum.random(0..6) * :rand.uniform - signs = {Enum.random(0..1), Enum.random(0..1)} - {press_offset, temp_offset} = cond do - signs == {0,0} -> {1000 - press_absolute_offset, 28 - temp_absolute_offset} - signs == {0,1} -> {1000 - press_absolute_offset, 28 + temp_absolute_offset} - signs == {1,1} -> {1000 + press_absolute_offset, 28 + temp_absolute_offset} - signs == {1,0} -> {1000 + press_absolute_offset, 28 - temp_absolute_offset} - end - # else - # 1000 + press_absolute_offset - - # press_offset = unless sing == 0 do - # press_absolute_offset - # end sign == 0, do: - # press_absolute_offset - - # 0 - press_absolute_offset, else 0 + press_absolute_offset - # rand = {index, {hour_offset, minute_offset, second_offset}, press_offset, temp_offset} - # rand = {{{1988,1,1},{hour_offset, minute_offset, second_offset}}, press_offset, temp_offset} - # {{{1988,1,1},{hour_offset, minute_offset, second_offset}}, press_offset, temp_offset} - # {hour_offset*60+minute_offset, press_offset} - {hour_offset, press_offset} - # IO.puts("item = #{inspect(rand)}") - end - # [time, press, temp] - # |> Enum.to_list() - |> Flow.from_enumerable() - # |> Flow.flat_map(fn tup -> Tuple.to_list(tup) end) - |> Flow.partition() - # |> Flow.reduce(fn -> %{} end, fn tup, acc -> - # # {{{day,{h,m,s}},p,t} = tup - # key = get_key(tup) - # # key = h*60 + m - # Map.update(acc, key, 1, &(&1 + 1)) - # end) - |> Flow.group_by_key() - |> Flow.emit(:state) - # |> Flow.on_trigger(fn acc -> {[acc], [acc]} end) - |> Enum.to_list() - - List.foldl(flow, List.first(flow), fn x, acc -> Map.merge(x, acc, fn _k, v1, v2 -> v1 ++ v2 end) end) - # - # list = Enum.sort(flow, &sortfun(&1, &2)) - # |> Flow.from_enumerable() - # |> Flow.group_by_key() - # |> Enum.to_list() - # |> Enum.map(fn tup -> - # {h, sums} = tup - # {h, Enum.sum(sums)} - # end) - # |> Enum.reverse() - # |> Enum.flat_map_reduce(acc, fun) - # Enum.max_by(flow, fn {t,c} -> c end) - # |> List.first() - # range = 1..1000 - # Enum.each(range, fn(num) -> - # - # end) - # |> &List.first(&1) - # |> Stream.map(&IO.inspect(&1)) - # File.stream!("path/to/some/file") - # Flow.from_enumerable(measures) - # |> Flow.flat_map(&String.split(&1, " ")) - # |> Flow.each(fn tup -> - # IO.puts("Tuple = #{inspect(tup)} ~n") - # tup - # end ) - # |> Flow.partition() - # |> Flow.reduce(fn -> %{} end, fn tup, acc -> - # end) - # |> Enum.to_list() - # |> &List.duplicate(List.first(&1), 10) - end -end - - - -# -# {#{cov => -12.941094631619034, -# measures => -# [{{{1988,1,1},{0,9,16}},290.30908203125,31.914583333333336}, -# {{{1988,1,1},{0,10,16}},1007.046630859375,31.84166666666667}, -# {{{1988,1,1},{0,11,16}},290.30908203125,31.877083333333335}], -# pmean => 529.2215983072917,pvar => 171237.57130004966, -# tmean => 31.877777777777787,tvar => 0.0013295717592593033}, -# [{<<166,228,1,82,63,157,221,65,102,136,185,249,206,135, -# 225,110,151,110,...>>, -# true}]}]} diff --git a/elixir_libs/testflow/mix.exs b/elixir_libs/testflow/mix.exs deleted file mode 100644 index 2a3f4d0..0000000 --- a/elixir_libs/testflow/mix.exs +++ /dev/null @@ -1,29 +0,0 @@ -defmodule Testflow.MixProject do - use Mix.Project - - def project do - [ - app: :testflow, - version: "0.1.0", - elixir: "~> 1.7", - start_permanent: Mix.env() == :prod, - deps: deps() - ] - end - - # Run "mix help compile.app" to learn about applications. - def application do - [ - extra_applications: [:logger] - ] - end - - # Run "mix help deps" to learn about dependencies. - defp deps do - [ - # {:dep_from_hexpm, "~> 0.3.0"}, - {:flow, "~> 0.14.2"}, - # {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"}, - ] - end -end diff --git a/elixir_libs/testflow/mix.lock b/elixir_libs/testflow/mix.lock deleted file mode 100644 index 2889213..0000000 --- a/elixir_libs/testflow/mix.lock +++ /dev/null @@ -1,4 +0,0 @@ -%{ - "flow": {:hex, :flow, "0.14.2", "84687153dcd10e321a2b09b5d1db9511ed704337a553a46e8b0758fde0b7e75c", [:mix], [{:gen_stage, "~> 0.14.0", [hex: :gen_stage, repo: "hexpm", optional: false]}], "hexpm"}, - "gen_stage": {:hex, :gen_stage, "0.14.0", "65ae78509f85b59d360690ce3378d5096c3130a0694bab95b0c4ae66f3008fad", [:mix], [], "hexpm"}, -} diff --git a/elixir_libs/testflow/test/test_helper.exs b/elixir_libs/testflow/test/test_helper.exs deleted file mode 100644 index 869559e..0000000 --- a/elixir_libs/testflow/test/test_helper.exs +++ /dev/null @@ -1 +0,0 @@ -ExUnit.start() diff --git a/elixir_libs/testflow/test/testflow_test.exs b/elixir_libs/testflow/test/testflow_test.exs deleted file mode 100644 index 9f0901c..0000000 --- a/elixir_libs/testflow/test/testflow_test.exs +++ /dev/null @@ -1,8 +0,0 @@ -defmodule TestflowTest do - use ExUnit.Case - doctest Testflow - - test "greets the world" do - assert Testflow.hello() == :world - end -end diff --git a/grisp/grisp_base/files/erl_inetrc b/grisp/grisp_base/files/erl_inetrc index 75b43b4..748042f 100644 --- a/grisp/grisp_base/files/erl_inetrc +++ b/grisp/grisp_base/files/erl_inetrc @@ -6,10 +6,10 @@ % {host, {192,168,1,39}, ["Laymer"]}. {host, {192,168,1,59}, ["GrispAdhoc"]}. %--- GRiSP boards -------------------------------------------------------------- -% {host, {169,254,16,1}, ["my_grisp_board_1"]}. -% {host, {169,254,16,2}, ["my_grisp_board_2"]}. -% {host, {169,254,16,3}, ["my_grisp_board_3"]}. -% {host, {169,254,16,4}, ["my_grisp_board_4"]}. +{host, {169,254,16,1}, ["my_grisp_board_1"]}. +{host, {169,254,16,2}, ["my_grisp_board_2"]}. +{host, {169,254,16,3}, ["my_grisp_board_3"]}. +{host, {169,254,16,4}, ["my_grisp_board_4"]}. % {host, {169,254,16,5}, ["my_grisp_board_5"]}. % {host, {169,254,16,6}, ["my_grisp_board_6"]}. % {host, {169,254,16,7}, ["my_grisp_board_7"]}. diff --git a/grisp/grisp_base/files/grisp.ini.mustache b/grisp/grisp_base/files/grisp.ini.mustache index 9129c75..377cb3c 100644 --- a/grisp/grisp_base/files/grisp.ini.mustache +++ b/grisp/grisp_base/files/grisp.ini.mustache @@ -2,10 +2,9 @@ image_path = /media/mmcsd-0-0/{{release_name}}/erts-{{erts_vsn}}/bin/beam.bin [erlang] -args = erl.rtems -- +MHas aobf +MMmcs 5 +MHlmbcs 5240 -mode embedded -home . -pa . -root {{release_name}} -config {{release_name}}/releases/{{release_version}}/sys.config -boot {{release_name}}/releases/{{release_version}}/{{release_name}} -internal_epmd epmd_sup -kernel inetrc "./erl_inetrc" -name {{release_name}}@my_grisp_board_2 -setcookie MyCookie +args = erl.rtems -- +MHas aobf +MMmcs 5 +MHlmbcs 5240 -mode embedded -home . -pa . -root {{release_name}} -config {{release_name}}/releases/{{release_version}}/sys.config -boot {{release_name}}/releases/{{release_version}}/{{release_name}} -internal_epmd epmd_sup -kernel inetrc "./erl_inetrc" -sname {{release_name}} -setcookie MyCookie [network] -ip_self=dhcp +ip_self=169.254.16.4 wlan=enable -hostname=my_grisp_board_2 -wpa=wpa_supplicant.conf +hostname=my_grisp_board_4 diff --git a/rebar.config b/rebar.config index 401d4a6..6da3f2b 100644 --- a/rebar.config +++ b/rebar.config @@ -29,12 +29,12 @@ % {rebar3_elixir_compile, ".*", {git, "https://github.com/barrel-db/rebar3_elixir_compile.git", {branch, "master"}}} {rebar3_elixir_compile, ".*", {git, "https://github.com/GrispLasp/rebar3_elixir_compile.git", {branch, "master"}}} ]}. -% -% {provider_hooks, [ -% {pre, [{compile, {ex, compile}}]}, -% {pre, [{release, {ex, compile}}]} -% ]}. -% + +{provider_hooks, [ + {pre, [{compile, {ex, compile}}]}, + {pre, [{release, {ex, compile}}]} +]}. + @@ -50,16 +50,16 @@ {toolchain, [ % {root, "/home/laymer/NewGRiSP/grisp-software/rtems-install/rtems/5"} % {root, "/Users/Laymer/GRiSP/grisp-software/rtems-install/rtems/5"} - % {root, "/Users/oxynad/Documents/thesis/newGRiSP/grisp-software/rtems-install/rtems/5"} - {root, "/home/laymer/EdgeComputing/NewGRiSP/grisp-software/rtems-install/rtems/5"} % W540 + {root, "/Users/oxynad/Documents/thesis/newGRiSP/grisp-software/rtems-install/rtems/5"} + % {root, "/home/laymer/EdgeComputing/NewGRiSP/grisp-software/rtems-install/rtems/5"} % W540 % {root, "/media/alex/external1/grisp/grisp-software/rtems-install/rtems/5"} ]}, {build, [ {toolchain, [ % {directory,"/home/laymer/NewGRiSP/grisp-software/rtems-install/rtems/5"}]} % {directory,"/Users/Laymer/GRiSP/grisp-software/rtems-install/rtems/5"}]} - {directory,"/home/laymer/EdgeComputing/NewGRiSP/grisp-software/rtems-install/rtems/5"}]} % W540 - % {directory,"/Users/oxynad/Documents/thesis/newGRiSP/grisp-software/rtems-install/rtems/5"}]} % Dan + % {directory,"/home/laymer/EdgeComputing/NewGRiSP/grisp-software/rtems-install/rtems/5"}]} % W540 + {directory,"/Users/oxynad/Documents/thesis/newGRiSP/grisp-software/rtems-install/rtems/5"}]} % Dan % {directory,"/media/alex/external1/grisp/grisp-software/rtems-install/rtems/5"}]} % {directory,"/home/laymer/EdgeComputing/NewGRiSP/grisp-software/rtems-install/rtems/5"}]} ]}, diff --git a/rebar.lock b/rebar.lock index 8772395..c9521b9 100644 --- a/rebar.lock +++ b/rebar.lock @@ -17,6 +17,7 @@ {ref,"102cb1930c6c38861bcd841008d1a2ee203e56c1"}}, 0}, {<<"lasp_support">>,{pkg,<<"lasp_support">>,<<"0.0.3">>},1}, + {<<"mapz">>,{pkg,<<"mapz">>,<<"0.3.0">>},1}, {<<"numerix">>,{elixir,<<"numerix">>,<<"0.5.1">>},0}, {<<"plumtree">>,{pkg,<<"plumtree">>,<<"0.5.0">>},1}, {<<"quickrand">>,{pkg,<<"quickrand">>,<<"1.7.4-rc1">>},2}, @@ -34,6 +35,7 @@ {<<"gen_flow">>, <<"2FF6ABE3ED1C5C9BC41F81BF09364A3F63F96E4D378D45A2A2DDC4FC06F3484A">>}, {<<"goldrush">>, <<"F06E5D5F1277DA5C413E84D5A2924174182FB108DABB39D5EC548B27424CD106">>}, {<<"lasp_support">>, <<"C1B7E1A472037AE82C71D2D16A10B7D644A621B66AE5AFE834CECF170F2E9169">>}, + {<<"mapz">>, <<"438D24746CE5A252101E00B2032EFDF7FC69EB32689D3B805DE5E6DD7F52614F">>}, {<<"plumtree">>, <<"F3521CE631AD22AC00635E79C7F046A163BD1135889CDC1D0B18AB577F76EC70">>}, {<<"quickrand">>, <<"61A9AF693C8B4FC9F838818493BCEE127AA2EE70483BE32BAD20C760C208E8BA">>}, {<<"rand_compat">>, <<"011646BC1F0B0C432FE101B816F25B9BBB74A085713CEE1DAFD2D62E9415EAD3">>}, diff --git a/src/node.hrl b/src/node.hrl index 82e0449..e472bbc 100644 --- a/src/node.hrl +++ b/src/node.hrl @@ -77,7 +77,7 @@ end). -define(ALL, lists:seq(1,12) ). --define(DAN, lists:seq(1,3,1) ). +-define(DAN, lists:seq(1,4,1) ). -define(ALEX, lists:seq(4,9,1) ). -define(IGOR, lists:seq(10,12,1) ). % NEVER FORGET THIS EPIC MACRO : diff --git a/src/node_app.erl b/src/node_app.erl index f60f94b..6d5a9d2 100644 --- a/src/node_app.erl +++ b/src/node_app.erl @@ -36,6 +36,7 @@ % https://github.com/lasp-lang/lasp/pull/295/commits/e2f948f879145a5ff31cf5458201768ca97b406b start(_StartType, _StartArgs) -> + logger:log(notice, "Application Master starting Node app ~n"), {ok, Supervisor} = node:start(node), % application:ensure_all_started(os_mon), @@ -46,7 +47,6 @@ start(_StartType, _StartArgs) -> % logger:log(notice"Where am I going to appear?~n"), start_timed_apps(), - logger:log(notice, "Application Master started Node app ~n"), start_primary_workers(primary_workers), start_primary_workers(distributed_workers), % add_measurements(), @@ -54,7 +54,7 @@ start(_StartType, _StartArgs) -> % logger:log(notice, "Node ~p", [node()]), % logger:log(notice, "Inet getifaddrs ~p", [inet:getifaddrs()]), LEDs = [1, 2], - % [grisp_led:flash(L, aqua, 500) || L <- LEDs], + [grisp_led:flash(L, aqua, 500) || L <- LEDs], PeerConfig = lasp_partisan_peer_service:manager(), logger:log(notice, "The manager used is ~p ~n", [PeerConfig]), diff --git a/src/node_benchmark_server.erl b/src/node_benchmark_server.erl index 97d6239..06de905 100644 --- a/src/node_benchmark_server.erl +++ b/src/node_benchmark_server.erl @@ -6,7 +6,7 @@ %% API -export([start_link/0, terminate/0]). --export([benchmark_meteo_task/0]). +-export([benchmark_meteo_task/1]). %% Gen Server Callbacks -export([code_change/3, handle_call/3, handle_cast/2, @@ -20,7 +20,7 @@ start_link() -> gen_server:start_link({local, ?MODULE}, ?MODULE, [], []). -benchmark_meteo_task() -> gen_server:call(?MODULE, {benchmark_meteo_task}). +benchmark_meteo_task(LoopCount) -> gen_server:call(?MODULE, {benchmark_meteo_task, LoopCount}). terminate() -> gen_server:call(?MODULE, {terminate}). @@ -32,7 +32,7 @@ terminate() -> gen_server:call(?MODULE, {terminate}). init([]) -> logger:log(notice, "Starting a node benchmark server"), - erlang:send_after(60000, self(), {benchmark_meteo_task}), + erlang:send_after(90000, self(), {benchmark_meteo_task, 10}), {ok, {}}. @@ -40,33 +40,29 @@ handle_call(stop, _From, State) -> {stop, normal, ok, State}. -handle_info({benchmark_meteo_task}, State) -> - +handle_info({benchmark_meteo_task, LoopCount}, State) -> EvaluationMode = node_config:get(evaluation_mode, grisplasp), logger:log(notice, "=== Starting meteo task benchmark in mode ~p ===~n", [EvaluationMode]), - SampleCount = 3, - SampleInterval = ?MIN, + SampleCount = 5, + SampleInterval = 5000, node_generic_tasks_server:add_task({tasknav, all, fun () -> case EvaluationMode of grisplasp -> - NodesWithoutMe = lists:delete(node(),?BOARDS(?ALL)), - logger:log(notice, "Node list ~p", [NodesWithoutMe]), + % NodeList = [node@GrispAdhoc,node2@GrispAdhoc], + % NodesWithoutMe = lists:delete(node(),NodeList), + NodesWithoutMe = lists:delete(node(),?BOARDS(?DAN)), + % logger:log(notice, "Node list ~p", [NodesWithoutMe]), lists:foreach(fun (Node) -> - logger:log(notice, "Spawning listener for ~p", [node_util:atom_to_lasp_id(Node)]), + logger:log(notice, "Spawning listener for ~p", [node_util:atom_to_lasp_identifier(Node, state_gset)]), spawn(fun() -> - % {strict, undefined} as the value parameter of lasp:read allows us to - % block until a CRDT's variable is bound. We spawn this in a new process - % as lasp:read is a blocking function. Upon detecting that a CRDT is bound, we know that - % the meteorological stats for the Node X has converged on the currently listening node - % and we call a remote process waiting for convergence acknowledgements on the Node X. - % Node X will detect the time it received an ack and will know approximately how long it took - % for the convergence to happen (minus the remote process call latency time). - ConvergedValue = lasp:read(node_util:atom_to_lasp_id(Node),{strict, undefined}), - logger:log(notice, "Data from node ~p converged on our node! Sending Acknowledgement", [Node]), - {convergence_acknowledgement, Node} ! {ack, node()} + lists:foreach(fun(Cardinality) -> + lasp:read(node_util:atom_to_lasp_identifier(Node, state_gset), {cardinality, Cardinality}), + % logger:log(notice, "CRDT with cardinality ~p from node ~p converged on our node! Sending Acknowledgement", [Cardinality, Node]), + {convergence_acknowledgement, Node} ! {ack, node(), Cardinality} + end, lists:seq(1, LoopCount)) end) end, NodesWithoutMe), - node_generic_tasks_functions_benchmark:meteorological_statistics_grisplasp(SampleCount,SampleInterval); + node_generic_tasks_functions_benchmark:meteorological_statistics_grisplasp(LoopCount, SampleCount, SampleInterval); cloudlasp -> node_generic_tasks_functions_benchmark:meteorological_statistics_cloudlasp(SampleCount,SampleInterval); xcloudlasp -> diff --git a/src/node_generic_tasks_functions.erl b/src/node_generic_tasks_functions.erl index 4e048d2..7e988fa 100644 --- a/src/node_generic_tasks_functions.erl +++ b/src/node_generic_tasks_functions.erl @@ -45,11 +45,15 @@ meteorological_statistics(SampleCount, SampleInterval, Trigger) -> {ok, {ExecId, _, _, _}} = lasp:declare({"<>", state_gset}, state_gset), % {ok, {ExecId, _, _, _}} = lasp:declare({"<>", state_gset}, state_gset). {ok, {NewId, NewT, NewM, NewV}} = lasp:update(Id, {add, Result}, self()), + + % {ok, {NewId, NewT, NewM, NewV}} = lasp:update({<<"test">>, state_gset}, {add, "hello"}, self()), + % lasp:update({<<"executors">>}, {add, NewId}, self()), % {ok, {_, _, _, _}} = lasp:update(ExecId, {add, NewId}, self()), lasp:update(ExecId, {add, NewId}, self()), % lasp:update({"<>", state_gcounter}, increment, self()), % node_app:add_task_meteo(). -% {ok, S3} = lasp:query({<<"node@my_grisp_board_1">>, state_orset}), sets:to_list(S2). + % {ok, Set} = lasp:query({<<"node@GrispAdhoc">>, state_gset}). + % sets:to_list(Set). spawn(fun() -> lasp:read(ExecId, {cardinality, Trigger}), % ExecId = node_util:atom_to_lasp_identifier(executors,state_gset), diff --git a/src/node_generic_tasks_functions_benchmark.erl b/src/node_generic_tasks_functions_benchmark.erl index eaf899b..fdde56f 100644 --- a/src/node_generic_tasks_functions_benchmark.erl +++ b/src/node_generic_tasks_functions_benchmark.erl @@ -14,53 +14,67 @@ average([], Length, Sum) -> % ==> Aggregation, computation and replication with Lasp on Edge -meteorological_statistics_grisplasp(SampleCount, SampleInterval) -> +meteorological_statistics_grisplasp(LoopCount, SampleCount, SampleInterval) -> - logger:log(notice, "Starting Meteo statistics task benchmark with Lasp on GRiSP ~n"), - - % Must check if module is available - {pmod_nav, Pid, _Ref} = node_util:get_nav(), - % meteo = shell:rd(meteo, {press = [], temp = []}), - % State = #{press => [], temp => [], time => []}, - State = maps:new(), - State1 = maps:put(press, [], State), - State2 = maps:put(temp, [], State1), - State3 = maps:put(time, [], State2), - - FoldFun = fun - (Elem, AccIn) when is_integer(Elem) andalso is_map(AccIn) -> - timer:sleep(SampleInterval), - T = node_stream_worker:maybe_get_time(), - % T = calendar:local_time(), - [Pr, Tmp] = gen_server:call(Pid, {read, alt, [press_out, temp_out], #{}}), - logger:log(notice, "Getting data from nav sensor pr: ~p tmp: ~p", [Pr, Tmp]), - % [Pr, Tmp] = [1000.234, 29.55555], - #{press => maps:get(press, AccIn) ++ [Pr], - temp => maps:get(temp, AccIn) ++ [Tmp], - time => maps:get(time, AccIn) ++ [T]} - end, - - M = lists:foldl(FoldFun, State3, lists:seq(1, SampleCount)), - logger:log(notice, "Done Sampling data"), - - T1Computation = erlang:monotonic_time(millisecond), - - [Pressures, Temperatures, Epochs] = maps:values(M), - Result = #{measures => lists:zip3(Epochs, Pressures, Temperatures), - pmean => 'Elixir.Numerix.Statistics':mean(Pressures), - pvar => 'Elixir.Numerix.Statistics':variance(Pressures), - tmean => 'Elixir.Numerix.Statistics':mean(Temperatures), - tvar => 'Elixir.Numerix.Statistics':variance(Temperatures), - cov => 'Elixir.Numerix.Statistics':covariance(Pressures, Temperatures)}, - - T2Computation = erlang:monotonic_time(millisecond), - - {ok, {Id, _, _, _}} = hd(node_util:declare_crdts([node()])), - {ok, {NewId, NewT, NewM, NewV}} = lasp:update(Id, {add, Result}, self()), + % logger:log(notice, "Starting Meteo statistics task benchmark with Lasp on GRiSP ~n"), Self = self(), + MeteorologicalStatisticsFun = fun MSF (LoopCountRemaining, AccComputations) -> + + logger:log(notice, "Meteo Function remaining iterations: ~p", [LoopCountRemaining]), + + % Must check if module is available + {pmod_nav, Pid, _Ref} = node_util:get_nav(), + State = maps:new(), + State1 = maps:put(press, [], State), + State2 = maps:put(temp, [], State1), + State3 = maps:put(time, [], State2), + + FoldFun = fun + (Elem, AccIn) when is_integer(Elem) andalso is_map(AccIn) -> + timer:sleep(SampleInterval), + T = node_stream_worker:maybe_get_time(), + % T = calendar:local_time(), + [Pr, Tmp] = gen_server:call(Pid, {read, alt, [press_out, temp_out], #{}}), + % logger:log(notice, "Getting data from nav sensor pr: ~p tmp: ~p", [Pr, Tmp]), + % [Pr, Tmp] = [1000.234, 29.55555], + #{press => maps:get(press, AccIn) ++ [Pr], + temp => maps:get(temp, AccIn) ++ [Tmp], + time => maps:get(time, AccIn) ++ [T]} + end, + + M = lists:foldl(FoldFun, State3, lists:seq(1, SampleCount)), + % logger:log(notice, "Done Sampling data"), + + + + T1Computation = erlang:monotonic_time(millisecond), + % timer:sleep(1500), + + [Pressures, Temperatures, Epochs] = maps:values(M), + Result = #{measures => lists:zip3(Epochs, Pressures, Temperatures), + pmean => 'Elixir.Numerix.Statistics':mean(Pressures), + pvar => 'Elixir.Numerix.Statistics':variance(Pressures), + tmean => 'Elixir.Numerix.Statistics':mean(Temperatures), + tvar => 'Elixir.Numerix.Statistics':variance(Temperatures), + cov => 'Elixir.Numerix.Statistics':covariance(Pressures, Temperatures)}, + + T2Computation = erlang:monotonic_time(millisecond), + lasp:update(node_util:atom_to_lasp_identifier(node(), state_gset), {add, Result}, self()), + % lasp:update(node_util:atom_to_lasp_identifier(node(), state_gset), {add, {T1Computation, T2Computation}}, self()), + + Cardinality = LoopCount-LoopCountRemaining+1, + ComputationTime = T2Computation - T1Computation, + NewAcc = maps:put(Cardinality, {T2Computation, ComputationTime}, AccComputations), + if LoopCountRemaining > 1 -> + MSF(LoopCountRemaining-1, NewAcc); + true -> + timer:sleep(5000), % Give time to the CA process to finish receiving acks + convergence_acknowledgement ! {done, NewAcc} + end + end, - ConvergenceAcknowledgement = fun CA(Acks) -> + ConvergenceAcknowledgementFun = fun CA(Acks) -> receive % Idea 1: To get the real convergence time, when receiving an ACK, send a response to the caller % in order for him to measure the time it took to call the remote process here. The caller would @@ -69,45 +83,56 @@ meteorological_statistics_grisplasp(SampleCount, SampleInterval) -> % Idea 2: Do a best effort acknowledgements reception. % Add timeouts to the receive block as some nodes might be unavailable. - {ack, From} -> - logger:log(notice, "Received Ack from ~p", [From]), + {ack, From, Cardinality} -> + % logger:log(notice, "Received Ack from ~p with CRDT cardinality ~p", [From, Cardinality]), TConverged = erlang:monotonic_time(millisecond), - NodesWithoutMe = lists:delete(node(),?BOARDS(?ALL)), - NodesCount = length(NodesWithoutMe), - NewAcks = Acks ++ [{From, TConverged}], - if length(NewAcks) == NodesCount -> - logger:log(notice, "Received all acks! Notifying self"), - Self ! {NewAcks}, - exit(self()); - true -> - logger:log(notice, "Didn't receive all acks, continue to listen"), - CA(NewAcks) - end + CA([{From, TConverged, Cardinality} | Acks]); + {done, Computations} -> % Called by the meteo function once it has terminated + Self ! {done, Computations, Acks} end end, logger:log(notice, "Spawning Acknowledgement receiver process"), % https://stackoverflow.com/questions/571339/erlang-spawning-processes-and-passing-arguments - PidCA = spawn(fun () -> ConvergenceAcknowledgement([]) end), - register(convergence_acknowledgement, PidCA), + PidCAF = spawn(fun () -> ConvergenceAcknowledgementFun([]) end), + PidMSF = spawn(fun () -> MeteorologicalStatisticsFun(LoopCount, #{}) end), + register(convergence_acknowledgement, PidCAF), receive - {Acks} -> - logger:log(notice, "Received all acks ~p", [Acks]), - logger:log(notice, "CRDT converged on all nodes"), - ComputationTime = T2Computation - T1Computation, - logger:log(notice, "Computation time: ~p ms", [ComputationTime]), - MapFun = fun(Elem) -> - logger:log(notice, "Elem is ~p", [Elem]), - {From, TConverged} = Elem, - TConvergence = TConverged - T2Computation, - logger:log(notice, "CRDT converged on ~p after ~p ms", [From, TConvergence]), - TConvergence - end, - ListConvergence = lists:map(MapFun, Acks), - AverageConvergenceTime = average(ListConvergence), - logger:log(notice, "Average convergence time: ~p ms", [AverageConvergenceTime]), - exit(PidCA, kill) + % {Acks} -> + % logger:log(notice, "Received all acks ~p", [Acks]), + % logger:log(notice, "CRDT converged on all nodes"), + % MapFun = fun(Elem) -> + % logger:log(notice, "Elem is ~p", [Elem]), + % {From, TConverged} = Elem, + % TConvergence = TConverged - T2Computation, + % logger:log(notice, "CRDT converged on ~p after ~p ms", [From, TConvergence]), + % TConvergence + % end, + % ListConvergence = lists:map(MapFun, Acks), + % AverageConvergenceTime = average(ListConvergence), + % logger:log(notice, "Average convergence time: ~p ms", [AverageConvergenceTime]); + % + {done, Computations, Acks} -> + logger:log(notice, "Meteo task is done, received acks and computations. Calculating computation time + convergence time..."), + % logger:log(notice, "Computations: ~p - Acks: ~p", [Computations, Acks]), + AckMap = lists:foldl( + fun(Ack, Acc) -> + {From, TConverged, Cardinality} = Ack, + {T2Computation, _} = maps:get(Cardinality, Computations), + ConvergenceTime = TConverged - T2Computation, + case maps:find(From, Acc) of + {ok, NodeMap} -> + NewNodeMap = maps:put(Cardinality, ConvergenceTime, NodeMap), + maps:update(From, NewNodeMap, Acc); + error -> + maps:put(From, #{Cardinality => ConvergenceTime}, Acc) + end + end , #{}, Acks), + logger:log(notice, "Ack map is ~p", [AckMap]), + logger:log(notice, "Computations map is ~p", [Computations]), + exit(PidCAF, kill), + exit(PidMSF, kill) end. % ==> Send Aggregated data to the AWS Server. The server will do the computation and replication with Lasp on cloud. diff --git a/src/node_ping_worker.erl b/src/node_ping_worker.erl index 6a209b0..160e6e1 100644 --- a/src/node_ping_worker.erl +++ b/src/node_ping_worker.erl @@ -38,7 +38,7 @@ init({}) -> logger:log(info, "Initializing Node Pinger~n"), process_flag(trap_exit, true), %% Ensure Gen Server gets notified when his supervisor dies - erlang:send_after(5000, self(), + erlang:send_after(30000, self(), {full_ping}), %% Start full pinger after 5 seconds % self() ! {full_ping}, {ok, []}. @@ -52,7 +52,7 @@ handle_call(_Message, _From, CurrentList) -> {reply, {ok, CurrentList}, CurrentList}. handle_info({full_ping}, CurrentList) -> - logger:log(notice, "=== Starting a full ping ===~n"), + logger:log(info, "=== Starting a full ping ===~n"), T1 = os:timestamp(), PingedNodes = ping(), T2 = os:timestamp(), @@ -61,9 +61,9 @@ handle_info({full_ping}, CurrentList) -> [Time / 1000000]), logger:log(notice, "=== Nodes that answered back ~p ===~n", [PingedNodes]), - {noreply, PingedNodes, 30000}; + {noreply, PingedNodes, 60000}; handle_info(timeout, CurrentList) -> - logger:log(notice, "=== Timeout of full ping, restarting " + logger:log(info, "=== Timeout of full ping, restarting " "after 90s ===~n"), T1 = os:timestamp(), PingedNodes = ping(), @@ -73,7 +73,7 @@ handle_info(timeout, CurrentList) -> [Time / 1000000]), logger:log(notice, "=== Nodes that answered back ~p ===~n", [PingedNodes]), - {noreply, PingedNodes, 30000}; + {noreply, PingedNodes, 60000}; handle_info(Msg, CurrentList) -> logger:log(info, "=== Unknown message: ~p~n", [Msg]), {noreply, CurrentList}. @@ -104,11 +104,10 @@ ping() -> end, [], node_config:get(remote_hosts, #{})), % List = (?BOARDS((?IGOR))) ++ ['nodews@Laymer-3'], - List = Remotes, + % List = Remotes, - % List = ['node@GrispAdhoc', 'node2@GrispAdhoc'], - % List = (?BOARDS((?ALL))), - % List = [generic_node_1@GrispAdhoc,generic_node_2@GrispAdhoc], + List = (?BOARDS((?DAN))), + % List = [node@GrispAdhoc,node2@GrispAdhoc], % List = (?BOARDS(?ALL)) ++ Remotes, ListWithoutSelf = lists:delete(node(), List), lists:foldl(fun (Node, Acc) -> @@ -116,15 +115,15 @@ ping() -> pong -> IsARemote = lists:member(Node, Remotes), if IsARemote == true -> - logger:log(notice, "=== Node ~p is an aws server", [Node]), + logger:log(info, "=== Node ~p is an aws server", [Node]), Acc ++ [Node]; true -> - logger:log(notice, "=== Attempting to join the node ~p with lasp", [Node]), + logger:log(info, "=== Attempting to join the node ~p with lasp", [Node]), lasp_peer_service:join(Node), Acc ++ [Node] end; pang -> - logger:log(notice, "=== Node ~p is unreachable", [Node]), + logger:log(info, "=== Node ~p is unreachable", [Node]), Acc end end, [], ListWithoutSelf).