summaryrefslogtreecommitdiff
path: root/components/schedule
diff options
context:
space:
mode:
authorUlf Wiger <ulf@feuerlabs.com>2015-10-28 21:23:05 +0100
committerUlf Wiger <ulf@feuerlabs.com>2015-11-20 13:46:13 -0800
commit1b44c2448344a10ae63904a796b6211c40a3f212 (patch)
treece8f7dda870a5c454ffbe9e2c0bc7035b34f0f4b /components/schedule
parent34aa86b5a2e97650fe6299ccf794d5eb5d052d91 (diff)
downloadrvi_core-1b44c2448344a10ae63904a796b6211c40a3f212.tar.gz
Lots of changes to make dlink_bt (simulated) and dlink_tls runtime tests pass
* Introduced high-level logging (rvi_log) * Upgraded to new lager version, customized debug output * Thread rvi_log IDs between nodes and components * Introduce simplified protocol for dlink_tls * Use msgpack encoding for dlink_tls * dlink_bt can use TCP instead of Bluetooth for testing purposes * Bug fixes and additions to the test suite
Diffstat (limited to 'components/schedule')
-rw-r--r--components/schedule/src/rvi_routing.erl26
-rw-r--r--components/schedule/src/schedule_rpc.erl2
2 files changed, 14 insertions, 14 deletions
diff --git a/components/schedule/src/rvi_routing.erl b/components/schedule/src/rvi_routing.erl
index a27fb49..67b68eb 100644
--- a/components/schedule/src/rvi_routing.erl
+++ b/components/schedule/src/rvi_routing.erl
@@ -2,7 +2,7 @@
%% Copyright (C) 2015, Jaguar Land Rover
%%
%% This program is licensed under the terms and conditions of the
-%% Mozilla Public License, version 2.0. The full text of the
+%% Mozilla Public License, version 2.0. The full text of the
%% Mozilla Public License is at https://www.mozilla.org/MPL/2.0/
%%
-module(rvi_routing).
@@ -28,7 +28,7 @@
service_prefix = ""::string(),
proto_link_pairs = []:: list(tuple())
}).
-
+
-record(st, {
routes= []:: list(#route{})
}).
@@ -173,7 +173,7 @@ prefix_match_(_Service, [], Len) ->
prefix_match_([], _Prefix, _Len ) ->
-1;
-%%
+%%
prefix_match_([ ServiceH | ServiceT], [ PrefixH | PrefixT ], Len)
when ServiceH =:= PrefixH ->
@@ -181,7 +181,7 @@ prefix_match_([ ServiceH | ServiceT], [ PrefixH | PrefixT ], Len)
%% Mismatch between the the service and candidate. No match
prefix_match_(_Service, _Prefix, _Len) ->
- -1.
+ -1.
find_routes_([], _Service, CurRoutes, CurMatchLen ) ->
{ CurRoutes, CurMatchLen };
@@ -191,7 +191,7 @@ find_routes_([ { ServicePrefix, Routes } | T], Service, CurRoutes, CurMatchLen )
%% Do we have a better match than previosly recorded?
case MatchLen >= CurMatchLen of
- true ->
+ true ->
%% Continue with the new routes and matching len installed
find_routes_(T, Service, Routes, MatchLen);
@@ -203,9 +203,10 @@ find_routes_([ { ServicePrefix, Routes } | T], Service, CurRoutes, CurMatchLen )
find_routes_(Rt, _Svc, CurRoutes, CurMatchLen) ->
?warning("rvi_routing(): Incorrect route entry: ~p", [Rt]),
{ CurRoutes, CurMatchLen }.
-
+
find_routes(Routes, Service) ->
+ ?debug("find_routes(~p, ~p)", [Routes, Service]),
case find_routes_(Routes, Service, undefined, 0) of
{ undefined, 0 } ->
?debug("rvi_routing(): ~p -> unknown", [ Service]),
@@ -213,7 +214,7 @@ find_routes(Routes, Service) ->
{ MatchRoutes, _MatchLen } ->
?debug("rvi_routing(): ~p -> ~p", [ Service, MatchRoutes ]),
- normalize_routes_(MatchRoutes, [])
+ normalize_routes_(MatchRoutes, [])
end.
@@ -225,13 +226,13 @@ normalize_routes_([], Acc) ->
lists:reverse(Acc);
normalize_routes_([ {{ Pr, PrOp }, { DL, DLOp }} | Rem ], Acc) ->
- normalize_routes_( Rem, [ {{Pr, PrOp}, { DL, DLOp } } | Acc]);
+ normalize_routes_( Rem, [ {{Pr, PrOp}, { DL, DLOp } } | Acc]);
normalize_routes_([ { Pr, { DL, DLOp }} | Rem ], Acc) ->
- normalize_routes_(Rem, [ { {Pr, []}, { DL, DLOp } } | Acc]);
+ normalize_routes_(Rem, [ { {Pr, []}, { DL, DLOp } } | Acc]);
normalize_routes_([ {{ Pr, PrOp}, DL } | Rem ], Acc) ->
- normalize_routes_(Rem, [ { {Pr, PrOp}, { DL, [] } } | Acc]);
+ normalize_routes_(Rem, [ { {Pr, PrOp}, { DL, [] } } | Acc]);
normalize_routes_([ {Pr, DL} | Rem ], Acc) ->
normalize_routes_(Rem, [ { {Pr, []}, { DL, [] } } | Acc]).
@@ -242,11 +243,11 @@ find_protocols_(_DataLink, [], Acc ) ->
%% Matching data link. This is an allowed protocol
-find_protocols_(DataLink, [ {{ Pr, PrOp }, { DL, DLOp }} | T],
+find_protocols_(DataLink, [ {{ Pr, PrOp }, { DL, DLOp }} | T],
Acc) when DataLink =:= DL ->
find_protocols_(DataLink, T, [ { Pr, PrOp, DLOp } | Acc ]);
-
+
%% No match
find_protocols_(DataLink, [ {{ _Pr, _PrOp }, { _DL, _DLOp }} | T], Acc) ->
@@ -258,4 +259,3 @@ find_protocols(AllRoutes, Service, DataLink) ->
Res = find_protocols_(DataLink, SvcRoutes, []),
?debug("find_protocols(~p:~p): -> ~p", [ DataLink, Service, Res]),
Res.
-
diff --git a/components/schedule/src/schedule_rpc.erl b/components/schedule/src/schedule_rpc.erl
index bf19dda..b66bdd1 100644
--- a/components/schedule/src/schedule_rpc.erl
+++ b/components/schedule/src/schedule_rpc.erl
@@ -153,7 +153,7 @@ service_unavailable(CompSpec, SvcName, DataLinkModule) ->
%% JSON-RPC entry point
%% CAlled by local exo http server
-handle_rpc("schedule_message", Args) ->
+handle_rpc(<<"schedule_message">>, Args) ->
{ok, SvcName} = rvi_common:get_json_element(["service"], Args),
{ok, Timeout} = rvi_common:get_json_element(["timeout"], Args),