Skip to content

Instantly share code, notes, and snippets.

@7-fl
Last active May 3, 2017 20:16
Show Gist options
  • Save 7-fl/6be78c6c381474e8c2c4386726c4f242 to your computer and use it in GitHub Desktop.
Save 7-fl/6be78c6c381474e8c2c4386726c4f242 to your computer and use it in GitHub Desktop.

Start instructions for four distributed servers:

  • First shell (note all shells need to be started in node mode):
$ erl -sname s1
Erlang/OTP 19 [erts-8.2] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]

Eshell V8.2  (abort with ^G)
(s1@MyMBP)1> 
  • Second shell (note all shells need to be started in node mode):
$ erl -sname s2
Erlang/OTP 19 [erts-8.2] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]

Eshell V8.2  (abort with ^G)
(s2@MyMBP)1> 
  • Third shell (note all shells need to be started in node mode):
$ erl -sname s3
Erlang/OTP 19 [erts-8.2] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]

Eshell V8.2  (abort with ^G)
(s3@MyMBP)1> 
  • Fourth shell (note all shells need to be started in node mode):
$ erl -sname s4
Erlang/OTP 19 [erts-8.2] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]

Eshell V8.2  (abort with ^G)
(s4@MyMBP)1> 
  • Finally, in a shell for the router (note all shells need to be started in node mode):
$ erl -sname router
Erlang/OTP 19 [erts-8.2] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]
Eshell V8.2  (abort with ^G)

(router@MyMBP)1> c(fs).
{ok,fs}

(router@MyMBP)2> fs:test_init().

fs.erl:

%% Based on code from 
%%   Erlang Programming
%%   Francecso Cesarini and Simon Thompson
%%   O'Reilly, 2008
%%   http://oreilly.com/catalog/9780596518189/
%%   http://www.erlangprogramming.org/
%%   (c) Francesco Cesarini and Simon Thompson

-module(fs).
-export([start/0,allocate/0,deallocate/1,stop/0]).
-export([server_init/1, router_init/1, router/1]).
-export([test/0, start_router/1]).
-export([client/2, test_init/0, test2/0]).

%%======== TESTS ============

test_init() ->
    timer:sleep(1000), %%Allow shell to finish startup when running the program from the command line.
    spawn(fs, test2, []),
    testing.

test2() ->
    %% Frequencies = [
    %%     [10,11,12,13,14,15], %%The number of sublists in Frequencies
    %%     [20,21,22,23,24,25], %%determines the number of servers that will
    %%     [30,31,32],        %%be started.
    %%     [40,41]
    %% ],
    %%
    %%Frequencies = [ [], [] ],
    %%
    
    %% ****** CHANGE HERE *******
    Frequencies = [
        {'s1@MyMBP', [10,11,12,13,14,15]}, %%The number of sublists in Frequencies
        {'s2@MyMBP', [20,21,22,23,24,25]}, %%determines the number of servers that will
        {'s3@MyMBP', [30,31,32]},          %%be started.
        {'s4@MyMBP', [40,41]}
    ],
    
    start_router(Frequencies),  
                                                 
    timer:sleep(1000), %Make sure the servers start before 
                       %sending them requests.
    Clients =
        lists:map(fun(ClientArgs) ->
                          spawn(fs, client, ClientArgs)
                  end,
                  [[1,1000],[2,2000],[3,3000],[4,4000]] ), %%[Id,Sleep]
    io:format("Clients: ~w~n", [Clients]),

    timer:sleep(7000),  %%Let the clients send requests for awhile.
    stop().

test() ->
    io:format("Client is (~w)~n", [self()]),
    Frequencies = [
        [10,11,12,13,14,15],
        [20,21,22,23,24,25]
    ],
    start_router(Frequencies),  %%The number of sublists in Frequencies
                                %%determines the number of servers that will
                                %%be started.
    loop(14).

loop(0) ->
    done_looping;
loop(N) ->
    timer:sleep(1000),
    io:format("Client (~w) got msg: ~w~n", [self(), allocate()]),
    loop(N-1).

%%========== ROUTER ============

start_router(Frequencies) ->
    Router = spawn(fs, router_init, [Frequencies]),
    io:format("start_router: Router: ~w~n", [Router]),
    register(router, Router). %% spawn(fs, router_init, [Frequencies])).
    
router_init(Frequencies) -> %Frequencies = [ [1,2,3], [10,11] ].
    Servers =  %% A server is a tuple: {ServerPid, Freqs}
        %%lists:map(fun(Freqs) ->
        lists:map(fun({NodeName, Freqs}) ->  %% *********** CHANGE HERE ***********
                      {
		          %%spawn(fs, server_init, [{Freqs, []}] ),
                          spawn(NodeName, fs, server_init, [{Freqs, []}] ),    %% ******* CHANGE HERE ********
                          Freqs,
                          length(Freqs)
                      }  %% => {ServerPid,Freqs}
                  end,
                  Frequencies), %% e.g. [ {'server@s1', [10,11,12]}, {'server@s2', [20,21,22,23]} ] 
    io:format("router_init: Servers: ~lp~n", [Servers]),
    router(Servers).  %% [FreshServers, StaleServers] => All the servers start off as 'Fresh'.
    

router(Servers) ->
    receive
        {request, Client, allocate}=Request ->
            case choose_allocate_server(Servers) of
                no_frequencies_available ->
                    Client ! {error, no_frequency},
                    io:format("router: all frequencies taken~n \t~lp~n client(~w) denied~n",
                              [Servers, Client]),
                    router(Servers);
                {TargetServerPid, _Freqs, _Available}=TargetServer ->
                    io:format("router/allocate: TargetServer: ~w~n", [TargetServer]),
                    TargetServerPid ! Request,
                    io:format("router: sent allocate request to server (~w) from client (~w)~n", 
                              [TargetServer, Client]),
                    io:format("router/allocate: Servers ~lp~n", [Servers]),
                    AdjustedServers = adjust_freq_count(TargetServer, Servers, fun(X) -> X-1 end),
                    io:format("router/allocate: Adjusted Servers: ~lp~n", [AdjustedServers]),
                    router(AdjustedServers)
            end;

        {request, Client, {deallocate,Freq}}=Request ->
            case find_deallocate_server(Freq, Servers) of
                false        ->
                    io:format("router: no servers allocated frequency ~w~n", [Freq]),
                    Client ! {reply, ok}, 
                    router(Servers);
                {TargetServerPid, _, _}=TargetServer ->
                    io:format("router/deallocate: TargetServer ~w~n", [TargetServer]),
                    TargetServerPid ! Request,
                    io:format("router: sent {deallocate,~w} request to server (~w) from client (~w)~n", 
                              [Freq,TargetServerPid,Client]),
                    io:format("router/deallocate: Servers ~lp~n", [Servers]),
                    %%Doesn't handle case where client tries to deallocate a valid freq it doesn't own:
                    AdjustedServers = adjust_freq_count(TargetServer, Servers, fun(X) -> X+1 end),
                    io:format("router/deallocate: Adjusted Servers: ~lp~n", [AdjustedServers]),
                    router(AdjustedServers)
            end;
           
        {request, Client, stop} ->
            io:format("router: stop request: Client is: ~w~n", [Client]),
            stop_servers(Servers),
            
            Client ! {reply, stopped}
        end.

%%----------
choose_allocate_server(Servers) ->
    SortedServers = lists:keysort(3, Servers),
    case lists:last(SortedServers) of
        {_ServerPid, _Freqs, 0} -> no_frequencies_available;
        Server                  -> Server
    end.
%%-----------
adjust_freq_count(TargetServer, Servers, AdjustmentFun) ->
    adjust_freq_count(TargetServer, Servers, AdjustmentFun, []).

adjust_freq_count(_, [], _, Acc) ->
    lists:reverse(Acc);
adjust_freq_count(TargetServer, [TargetServer|Servers], AdjustmentFun, Acc)->
    {ServerPid,Freqs,Available} = TargetServer,
    AdjustedTarget = {ServerPid,Freqs,AdjustmentFun(Available)},
    adjust_freq_count(TargetServer, Servers, AdjustmentFun, [AdjustedTarget|Acc]);
adjust_freq_count(TargetServer, [Server|Servers], AdjustmentFun, Acc) ->
    adjust_freq_count(TargetServer, Servers, AdjustmentFun, [Server|Acc]).
%%-----------
find_deallocate_server(_Freq, []) ->
    false;
find_deallocate_server(Freq, [{_, Freqs, _}=Server|Servers]) ->
    case lists:member(Freq, Freqs) of
        false  -> find_deallocate_server(Freq, Servers);
        true   -> Server
    end.
%%-----------
stop_servers([]) ->
    servers_stopped;
stop_servers([ {ServerPid,_, _}=Server | Servers ]) ->
    ServerPid ! {request, self(), stop},
    receive 
        {reply, _Reply} -> ok
    end,
    io:format("router: sent stop message to server ~w~n", [Server]),
    stop_servers(Servers).
   
%%========= CLIENT ==========

client(Id, Sleep) ->
    handle_allocate_response(allocate(), Id, Sleep).

handle_allocate_response({ok, Freq}, Id, Sleep) ->
    io:format("client~w(~w): got frequency ~w~n", 
              [Id, self(), Freq]),

    timer:sleep(Sleep),
    deallocate(Freq),

    io:format("client~w(~w): called deallocate(~w)~n",
              [Id, self(), Freq]),

    client(Id, Sleep);
handle_allocate_response({error, no_frequency}, Id, Sleep) ->
    io:format("client~w(~w): no frequencies available~n",
              [Id, self()]),

    timer:sleep(500), %Wait small amount of time, then retry.
    client(Id, Sleep).

%%========  SERVER ================

start() ->
    register(fs,
	     spawn(fs, server_init, [])).

server_init(Freqs) ->
    %%Frequencies = {get_frequencies(), []},
    server_loop(Freqs).

%% Hard Coded
%get_frequencies() -> [10,11,12,13,14,15].

%% The Main Loop

server_loop(Freqs) ->
    receive
        {request, Pid, allocate} ->
            {NewFreqs, Reply} = allocate(Freqs, Pid),
            Pid ! {reply, Reply},
            io:format("server(~w): Sent allocate reply to client(~w)~n",[self(),Pid]),
            server_loop(NewFreqs);
        {request, Pid , {deallocate, Freq}} ->
            NewFreqs = deallocate(Freqs, Freq),
            Pid ! {reply, ok},
            server_loop(NewFreqs);
        {request, Pid, stop} ->
            Pid ! {reply, stopped};
        Other ->
            io:format("server(~w): got Other message ~w~n", [self(), Other])     
    end.

%% Functional interface

allocate() -> 
    router ! {request, self(), allocate},
    receive 
        {reply, Reply} -> Reply
    end.

deallocate(Freq) -> 
    router ! {request, self(), {deallocate, Freq}},
    receive 
        {reply, Reply} -> Reply
    end.

stop() -> 
    router ! {request, self(), stop},
    receive 
        {reply, Reply} -> Reply
    end.


%% The Internal Help Functions used to allocate and
%% deallocate frequencies.

allocate({[], Allocated}, _Pid) ->
    {{[], Allocated}, {error, no_frequency}};
allocate({[Freq|Free], Allocated}, Pid) ->
    {{Free, [{Freq, Pid}|Allocated]}, {ok, Freq}}.

deallocate({Free, Allocated}, Freq) ->
    NewAllocated=lists:keydelete(Freq, 1, Allocated),
    {[Freq|Free],  NewAllocated}.

In the router shell:

$ erl -sname router
Erlang/OTP 19 [erts-8.2] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]
Eshell V8.2  (abort with ^G)

(router@MyMBP)1> c(fs).
{ok,fs}

(router@MyMBP)2> fs:test_init().
start_router: Router: <0.46.0>
testing
router_init: Servers: [{<7482.68.0>,[10,11,12,13,14,15],6},
                       {<7483.108.0>,[20,21,22,23,24,25],6},
                       {<7484.105.0>,[30,31,32],3},
                       {<7485.104.0>,[40,41],2}]
Clients: [<0.62.0>,<0.63.0>,<0.64.0>,<0.65.0>]
router/allocate: TargetServer: {<7483.108.0>,[20,21,22,23,24,25],6}
router: sent allocate request to server ({<7483.108.0>,[20,21,22,23,24,25],6}) from client (<0.62.0>)
router/allocate: Servers [{<7482.68.0>,[10,11,12,13,14,15],6},
                          {<7483.108.0>,[20,21,22,23,24,25],6},
                          {<7484.105.0>,[30,31,32],3},
                          {<7485.104.0>,[40,41],2}]
server(<7483.108.0>): Sent allocate reply to client(<0.62.0>)
router/allocate: Adjusted Servers: [{<7482.68.0>,[10,11,12,13,14,15],6},
                                    {<7483.108.0>,[20,21,22,23,24,25],5},
                                    {<7484.105.0>,[30,31,32],3},
                                    {<7485.104.0>,[40,41],2}]
client1(<0.62.0>): got frequency 20
router/allocate: TargetServer: {<7482.68.0>,[10,11,12,13,14,15],6}
router: sent allocate request to server ({<7482.68.0>,[10,11,12,13,14,15],6}) from client (<0.63.0>)
router/allocate: Servers [{<7482.68.0>,[10,11,12,13,14,15],6},
                          {<7483.108.0>,[20,21,22,23,24,25],5},
                          {<7484.105.0>,[30,31,32],3},
                          {<7485.104.0>,[40,41],2}]
server(<7482.68.0>): Sent allocate reply to client(<0.63.0>)
router/allocate: Adjusted Servers: [{<7482.68.0>,[10,11,12,13,14,15],5},
                                    {<7483.108.0>,[20,21,22,23,24,25],5},
                                    {<7484.105.0>,[30,31,32],3},
                                    {<7485.104.0>,[40,41],2}]
client2(<0.63.0>): got frequency 10
router/allocate: TargetServer: {<7483.108.0>,[20,21,22,23,24,25],5}
router: sent allocate request to server ({<7483.108.0>,[20,21,22,23,24,25],5}) from client (<0.64.0>)
router/allocate: Servers [{<7482.68.0>,[10,11,12,13,14,15],5},
                          {<7483.108.0>,[20,21,22,23,24,25],5},
                          {<7484.105.0>,[30,31,32],3},
                          {<7485.104.0>,[40,41],2}]
router/allocate: Adjusted Servers: [{<7482.68.0>,[10,11,12,13,14,15],5},
                                    {<7483.108.0>,[20,21,22,23,24,25],4},
                                    {<7484.105.0>,[30,31,32],3},
                                    {<7485.104.0>,[40,41],2}]
router/allocate: TargetServer: {<7482.68.0>,[10,11,12,13,14,15],5}
server(<7483.108.0>): Sent allocate reply to client(<0.64.0>)
client3(<0.64.0>): got frequency 21
router: sent allocate request to server ({<7482.68.0>,[10,11,12,13,14,15],5}) from client (<0.65.0>)
router/allocate: Servers [{<7482.68.0>,[10,11,12,13,14,15],5},
                          {<7483.108.0>,[20,21,22,23,24,25],4},
                          {<7484.105.0>,[30,31,32],3},
                          {<7485.104.0>,[40,41],2}]
router/allocate: Adjusted Servers: [{<7482.68.0>,[10,11,12,13,14,15],4},
                                    {<7483.108.0>,[20,21,22,23,24,25],4},
                                    {<7484.105.0>,[30,31,32],3},
                                    {<7485.104.0>,[40,41],2}]
client4(<0.65.0>): got frequency 11
server(<7482.68.0>): Sent allocate reply to client(<0.65.0>)
router/deallocate: TargetServer {<7483.108.0>,[20,21,22,23,24,25],4}
router: sent {deallocate,20} request to server (<7483.108.0>) from client (<0.62.0>)
router/deallocate: Servers [{<7482.68.0>,[10,11,12,13,14,15],4},
                            {<7483.108.0>,[20,21,22,23,24,25],4},
                            {<7484.105.0>,[30,31,32],3},
                            {<7485.104.0>,[40,41],2}]
router/deallocate: Adjusted Servers: [{<7482.68.0>,[10,11,12,13,14,15],4},
                                      {<7483.108.0>,[20,21,22,23,24,25],5},
                                      {<7484.105.0>,[30,31,32],3},
                                      {<7485.104.0>,[40,41],2}]
client1(<0.62.0>): called deallocate(20)
router/allocate: TargetServer: {<7483.108.0>,[20,21,22,23,24,25],5}
router: sent allocate request to server ({<7483.108.0>,[20,21,22,23,24,25],5}) from client (<0.62.0>)
router/allocate: Servers [{<7482.68.0>,[10,11,12,13,14,15],4},
                          {<7483.108.0>,[20,21,22,23,24,25],5},
                          {<7484.105.0>,[30,31,32],3},
                          {<7485.104.0>,[40,41],2}]
router/allocate: Adjusted Servers: [{<7482.68.0>,[10,11,12,13,14,15],4},
                                    {<7483.108.0>,[20,21,22,23,24,25],4},
                                    {<7484.105.0>,[30,31,32],3},
                                    {<7485.104.0>,[40,41],2}]
server(<7483.108.0>): Sent allocate reply to client(<0.62.0>)
client1(<0.62.0>): got frequency 20
router/deallocate: TargetServer {<7482.68.0>,[10,11,12,13,14,15],4}
router: sent {deallocate,10} request to server (<7482.68.0>) from client (<0.63.0>)
router/deallocate: Servers [{<7482.68.0>,[10,11,12,13,14,15],4},
                            {<7483.108.0>,[20,21,22,23,24,25],4},
                            {<7484.105.0>,[30,31,32],3},
                            {<7485.104.0>,[40,41],2}]
router/deallocate: Adjusted Servers: [{<7482.68.0>,[10,11,12,13,14,15],5},
                                      {<7483.108.0>,[20,21,22,23,24,25],4},
                                      {<7484.105.0>,[30,31,32],3},
                                      {<7485.104.0>,[40,41],2}]
router/deallocate: TargetServer {<7483.108.0>,[20,21,22,23,24,25],4}
router: sent {deallocate,20} request to server (<7483.108.0>) from client (<0.62.0>)
router/deallocate: Servers [{<7482.68.0>,[10,11,12,13,14,15],5},
                            {<7483.108.0>,[20,21,22,23,24,25],4},
                            {<7484.105.0>,[30,31,32],3},
                            {<7485.104.0>,[40,41],2}]
router/deallocate: Adjusted Servers: [{<7482.68.0>,[10,11,12,13,14,15],5},
                                      {<7483.108.0>,[20,21,22,23,24,25],5},
                                      {<7484.105.0>,[30,31,32],3},
                                      {<7485.104.0>,[40,41],2}]
client2(<0.63.0>): called deallocate(10)
router/allocate: TargetServer: {<7483.108.0>,[20,21,22,23,24,25],5}
router: sent allocate request to server ({<7483.108.0>,[20,21,22,23,24,25],5}) from client (<0.63.0>)
router/allocate: Servers [{<7482.68.0>,[10,11,12,13,14,15],5},
                          {<7483.108.0>,[20,21,22,23,24,25],5},
                          {<7484.105.0>,[30,31,32],3},
                          {<7485.104.0>,[40,41],2}]
client1(<0.62.0>): called deallocate(20)
server(<7483.108.0>): Sent allocate reply to client(<0.63.0>)
router/allocate: Adjusted Servers: [{<7482.68.0>,[10,11,12,13,14,15],5},
                                    {<7483.108.0>,[20,21,22,23,24,25],4},
                                    {<7484.105.0>,[30,31,32],3},
                                    {<7485.104.0>,[40,41],2}]
client2(<0.63.0>): got frequency 20
router/allocate: TargetServer: {<7482.68.0>,[10,11,12,13,14,15],5}
router: sent allocate request to server ({<7482.68.0>,[10,11,12,13,14,15],5}) from client (<0.62.0>)
router/allocate: Servers [{<7482.68.0>,[10,11,12,13,14,15],5},
                          {<7483.108.0>,[20,21,22,23,24,25],4},
                          {<7484.105.0>,[30,31,32],3},
                          {<7485.104.0>,[40,41],2}]
router/allocate: Adjusted Servers: [{<7482.68.0>,[10,11,12,13,14,15],4},
                                    {<7483.108.0>,[20,21,22,23,24,25],4},
                                    {<7484.105.0>,[30,31,32],3},
                                    {<7485.104.0>,[40,41],2}]
client1(<0.62.0>): got frequency 10
server(<7482.68.0>): Sent allocate reply to client(<0.62.0>)
router/deallocate: TargetServer {<7483.108.0>,[20,21,22,23,24,25],4}
router: sent {deallocate,21} request to server (<7483.108.0>) from client (<0.64.0>)
router/deallocate: Servers [{<7482.68.0>,[10,11,12,13,14,15],4},
                            {<7483.108.0>,[20,21,22,23,24,25],4},
                            {<7484.105.0>,[30,31,32],3},
                            {<7485.104.0>,[40,41],2}]
router/deallocate: Adjusted Servers: [{<7482.68.0>,[10,11,12,13,14,15],4},
                                      {<7483.108.0>,[20,21,22,23,24,25],5},
                                      {<7484.105.0>,[30,31,32],3},
                                      {<7485.104.0>,[40,41],2}]
client3(<0.64.0>): called deallocate(21)
router/allocate: TargetServer: {<7483.108.0>,[20,21,22,23,24,25],5}
router: sent allocate request to server ({<7483.108.0>,[20,21,22,23,24,25],5}) from client (<0.64.0>)
router/allocate: Servers [{<7482.68.0>,[10,11,12,13,14,15],4},
                          {<7483.108.0>,[20,21,22,23,24,25],5},
                          {<7484.105.0>,[30,31,32],3},
                          {<7485.104.0>,[40,41],2}]
router/allocate: Adjusted Servers: [{<7482.68.0>,[10,11,12,13,14,15],4},
                                    {<7483.108.0>,[20,21,22,23,24,25],4},
                                    {<7484.105.0>,[30,31,32],3},
                                    {<7485.104.0>,[40,41],2}]
server(<7483.108.0>): Sent allocate reply to client(<0.64.0>)
client3(<0.64.0>): got frequency 21
router/deallocate: TargetServer {<7482.68.0>,[10,11,12,13,14,15],4}
router: sent {deallocate,10} request to server (<7482.68.0>) from client (<0.62.0>)
router/deallocate: Servers [{<7482.68.0>,[10,11,12,13,14,15],4},
                            {<7483.108.0>,[20,21,22,23,24,25],4},
                            {<7484.105.0>,[30,31,32],3},
                            {<7485.104.0>,[40,41],2}]
router/deallocate: Adjusted Servers: [{<7482.68.0>,[10,11,12,13,14,15],5},
                                      {<7483.108.0>,[20,21,22,23,24,25],4},
                                      {<7484.105.0>,[30,31,32],3},
                                      {<7485.104.0>,[40,41],2}]
client1(<0.62.0>): called deallocate(10)
router/allocate: TargetServer: {<7482.68.0>,[10,11,12,13,14,15],5}
router: sent allocate request to server ({<7482.68.0>,[10,11,12,13,14,15],5}) from client (<0.62.0>)
router/allocate: Servers [{<7482.68.0>,[10,11,12,13,14,15],5},
                          {<7483.108.0>,[20,21,22,23,24,25],4},
                          {<7484.105.0>,[30,31,32],3},
                          {<7485.104.0>,[40,41],2}]
router/allocate: Adjusted Servers: [{<7482.68.0>,[10,11,12,13,14,15],4},
                                    {<7483.108.0>,[20,21,22,23,24,25],4},
                                    {<7484.105.0>,[30,31,32],3},
                                    {<7485.104.0>,[40,41],2}]
server(<7482.68.0>): Sent allocate reply to client(<0.62.0>)
client1(<0.62.0>): got frequency 10
router/deallocate: TargetServer {<7482.68.0>,[10,11,12,13,14,15],4}
router: sent {deallocate,11} request to server (<7482.68.0>) from client (<0.65.0>)
router/deallocate: Servers [{<7482.68.0>,[10,11,12,13,14,15],4},
                            {<7483.108.0>,[20,21,22,23,24,25],4},
                            {<7484.105.0>,[30,31,32],3},
                            {<7485.104.0>,[40,41],2}]
router/deallocate: Adjusted Servers: [{<7482.68.0>,[10,11,12,13,14,15],5},
                                      {<7483.108.0>,[20,21,22,23,24,25],4},
                                      {<7484.105.0>,[30,31,32],3},
                                      {<7485.104.0>,[40,41],2}]
client4(<0.65.0>): called deallocate(11)
router/allocate: TargetServer: {<7482.68.0>,[10,11,12,13,14,15],5}
router: sent allocate request to server ({<7482.68.0>,[10,11,12,13,14,15],5}) from client (<0.65.0>)
router/allocate: Servers [{<7482.68.0>,[10,11,12,13,14,15],5},
                          {<7483.108.0>,[20,21,22,23,24,25],4},
                          {<7484.105.0>,[30,31,32],3},
                          {<7485.104.0>,[40,41],2}]
router/allocate: Adjusted Servers: [{<7482.68.0>,[10,11,12,13,14,15],4},
                                    {<7483.108.0>,[20,21,22,23,24,25],4},
                                    {<7484.105.0>,[30,31,32],3},
                                    {<7485.104.0>,[40,41],2}]
server(<7482.68.0>): Sent allocate reply to client(<0.65.0>)
client4(<0.65.0>): got frequency 11
router/deallocate: TargetServer {<7483.108.0>,[20,21,22,23,24,25],4}
router: sent {deallocate,20} request to server (<7483.108.0>) from client (<0.63.0>)
router/deallocate: Servers [{<7482.68.0>,[10,11,12,13,14,15],4},
                            {<7483.108.0>,[20,21,22,23,24,25],4},
                            {<7484.105.0>,[30,31,32],3},
                            {<7485.104.0>,[40,41],2}]
router/deallocate: Adjusted Servers: [{<7482.68.0>,[10,11,12,13,14,15],4},
                                      {<7483.108.0>,[20,21,22,23,24,25],5},
                                      {<7484.105.0>,[30,31,32],3},
                                      {<7485.104.0>,[40,41],2}]
client2(<0.63.0>): called deallocate(20)
router/allocate: TargetServer: {<7483.108.0>,[20,21,22,23,24,25],5}
router: sent allocate request to server ({<7483.108.0>,[20,21,22,23,24,25],5}) from client (<0.63.0>)
router/allocate: Servers [{<7482.68.0>,[10,11,12,13,14,15],4},
                          {<7483.108.0>,[20,21,22,23,24,25],5},
                          {<7484.105.0>,[30,31,32],3},
                          {<7485.104.0>,[40,41],2}]
router/allocate: Adjusted Servers: [{<7482.68.0>,[10,11,12,13,14,15],4},
                                    {<7483.108.0>,[20,21,22,23,24,25],4},
                                    {<7484.105.0>,[30,31,32],3},
                                    {<7485.104.0>,[40,41],2}]
client2(<0.63.0>): got frequency 20
server(<7483.108.0>): Sent allocate reply to client(<0.63.0>)
router/deallocate: TargetServer {<7482.68.0>,[10,11,12,13,14,15],4}
router: sent {deallocate,10} request to server (<7482.68.0>) from client (<0.62.0>)
router/deallocate: Servers [{<7482.68.0>,[10,11,12,13,14,15],4},
                            {<7483.108.0>,[20,21,22,23,24,25],4},
                            {<7484.105.0>,[30,31,32],3},
                            {<7485.104.0>,[40,41],2}]
router/deallocate: Adjusted Servers: [{<7482.68.0>,[10,11,12,13,14,15],5},
                                      {<7483.108.0>,[20,21,22,23,24,25],4},
                                      {<7484.105.0>,[30,31,32],3},
                                      {<7485.104.0>,[40,41],2}]
client1(<0.62.0>): called deallocate(10)
router/allocate: TargetServer: {<7482.68.0>,[10,11,12,13,14,15],5}
router: sent allocate request to server ({<7482.68.0>,[10,11,12,13,14,15],5}) from client (<0.62.0>)
router/allocate: Servers [{<7482.68.0>,[10,11,12,13,14,15],5},
                          {<7483.108.0>,[20,21,22,23,24,25],4},
                          {<7484.105.0>,[30,31,32],3},
                          {<7485.104.0>,[40,41],2}]
router/allocate: Adjusted Servers: [{<7482.68.0>,[10,11,12,13,14,15],4},
                                    {<7483.108.0>,[20,21,22,23,24,25],4},
                                    {<7484.105.0>,[30,31,32],3},
                                    {<7485.104.0>,[40,41],2}]
server(<7482.68.0>): Sent allocate reply to client(<0.62.0>)
client1(<0.62.0>): got frequency 10
router/deallocate: TargetServer {<7482.68.0>,[10,11,12,13,14,15],4}
router: sent {deallocate,10} request to server (<7482.68.0>) from client (<0.62.0>)
router/deallocate: Servers [{<7482.68.0>,[10,11,12,13,14,15],4},
                            {<7483.108.0>,[20,21,22,23,24,25],4},
                            {<7484.105.0>,[30,31,32],3},
                            {<7485.104.0>,[40,41],2}]
router/deallocate: Adjusted Servers: [{<7482.68.0>,[10,11,12,13,14,15],5},
                                      {<7483.108.0>,[20,21,22,23,24,25],4},
                                      {<7484.105.0>,[30,31,32],3},
                                      {<7485.104.0>,[40,41],2}]
client1(<0.62.0>): called deallocate(10)
router/allocate: TargetServer: {<7482.68.0>,[10,11,12,13,14,15],5}
router: sent allocate request to server ({<7482.68.0>,[10,11,12,13,14,15],5}) from client (<0.62.0>)
router/allocate: Servers [{<7482.68.0>,[10,11,12,13,14,15],5},
                          {<7483.108.0>,[20,21,22,23,24,25],4},
                          {<7484.105.0>,[30,31,32],3},
                          {<7485.104.0>,[40,41],2}]
router/allocate: Adjusted Servers: [{<7482.68.0>,[10,11,12,13,14,15],4},
                                    {<7483.108.0>,[20,21,22,23,24,25],4},
                                    {<7484.105.0>,[30,31,32],3},
                                    {<7485.104.0>,[40,41],2}]
client1(<0.62.0>): got frequency 10
server(<7482.68.0>): Sent allocate reply to client(<0.62.0>)
router/deallocate: TargetServer {<7483.108.0>,[20,21,22,23,24,25],4}
router: sent {deallocate,21} request to server (<7483.108.0>) from client (<0.64.0>)
router/deallocate: Servers [{<7482.68.0>,[10,11,12,13,14,15],4},
                            {<7483.108.0>,[20,21,22,23,24,25],4},
                            {<7484.105.0>,[30,31,32],3},
                            {<7485.104.0>,[40,41],2}]
router/deallocate: Adjusted Servers: [{<7482.68.0>,[10,11,12,13,14,15],4},
                                      {<7483.108.0>,[20,21,22,23,24,25],5},
                                      {<7484.105.0>,[30,31,32],3},
                                      {<7485.104.0>,[40,41],2}]
client3(<0.64.0>): called deallocate(21)
router/allocate: TargetServer: {<7483.108.0>,[20,21,22,23,24,25],5}
router: sent allocate request to server ({<7483.108.0>,[20,21,22,23,24,25],5}) from client (<0.64.0>)
router/allocate: Servers [{<7482.68.0>,[10,11,12,13,14,15],4},
                          {<7483.108.0>,[20,21,22,23,24,25],5},
                          {<7484.105.0>,[30,31,32],3},
                          {<7485.104.0>,[40,41],2}]
client3(<0.64.0>): got frequency 21
server(<7483.108.0>): Sent allocate reply to client(<0.64.0>)
router/allocate: Adjusted Servers: [{<7482.68.0>,[10,11,12,13,14,15],4},
                                    {<7483.108.0>,[20,21,22,23,24,25],4},
                                    {<7484.105.0>,[30,31,32],3},
                                    {<7485.104.0>,[40,41],2}]
router/deallocate: TargetServer {<7483.108.0>,[20,21,22,23,24,25],4}
router: sent {deallocate,20} request to server (<7483.108.0>) from client (<0.63.0>)
router/deallocate: Servers [{<7482.68.0>,[10,11,12,13,14,15],4},
                            {<7483.108.0>,[20,21,22,23,24,25],4},
                            {<7484.105.0>,[30,31,32],3},
                            {<7485.104.0>,[40,41],2}]
router/deallocate: Adjusted Servers: [{<7482.68.0>,[10,11,12,13,14,15],4},
                                      {<7483.108.0>,[20,21,22,23,24,25],5},
                                      {<7484.105.0>,[30,31,32],3},
                                      {<7485.104.0>,[40,41],2}]
client2(<0.63.0>): called deallocate(20)
router/allocate: TargetServer: {<7483.108.0>,[20,21,22,23,24,25],5}
router: sent allocate request to server ({<7483.108.0>,[20,21,22,23,24,25],5}) from client (<0.63.0>)
router/allocate: Servers [{<7482.68.0>,[10,11,12,13,14,15],4},
                          {<7483.108.0>,[20,21,22,23,24,25],5},
                          {<7484.105.0>,[30,31,32],3},
                          {<7485.104.0>,[40,41],2}]
router/allocate: Adjusted Servers: [{<7482.68.0>,[10,11,12,13,14,15],4},
                                    {<7483.108.0>,[20,21,22,23,24,25],4},
                                    {<7484.105.0>,[30,31,32],3},
                                    {<7485.104.0>,[40,41],2}]
server(<7483.108.0>): Sent allocate reply to client(<0.63.0>)
client2(<0.63.0>): got frequency 20
router/deallocate: TargetServer {<7482.68.0>,[10,11,12,13,14,15],4}
router: sent {deallocate,10} request to server (<7482.68.0>) from client (<0.62.0>)
router/deallocate: Servers [{<7482.68.0>,[10,11,12,13,14,15],4},
                            {<7483.108.0>,[20,21,22,23,24,25],4},
                            {<7484.105.0>,[30,31,32],3},
                            {<7485.104.0>,[40,41],2}]
router/deallocate: Adjusted Servers: [{<7482.68.0>,[10,11,12,13,14,15],5},
                                      {<7483.108.0>,[20,21,22,23,24,25],4},
                                      {<7484.105.0>,[30,31,32],3},
                                      {<7485.104.0>,[40,41],2}]
client1(<0.62.0>): called deallocate(10)
router/allocate: TargetServer: {<7482.68.0>,[10,11,12,13,14,15],5}
router: sent allocate request to server ({<7482.68.0>,[10,11,12,13,14,15],5}) from client (<0.62.0>)
router/allocate: Servers [{<7482.68.0>,[10,11,12,13,14,15],5},
                          {<7483.108.0>,[20,21,22,23,24,25],4},
                          {<7484.105.0>,[30,31,32],3},
                          {<7485.104.0>,[40,41],2}]
router/allocate: Adjusted Servers: [{<7482.68.0>,[10,11,12,13,14,15],4},
                                    {<7483.108.0>,[20,21,22,23,24,25],4},
                                    {<7484.105.0>,[30,31,32],3},
                                    {<7485.104.0>,[40,41],2}]
server(<7482.68.0>): Sent allocate reply to client(<0.62.0>)
client1(<0.62.0>): got frequency 10
router: stop request: Client is: <0.45.0>
router: sent stop message to server {<7482.68.0>,[10,11,12,13,14,15],4}
router: sent stop message to server {<7483.108.0>,[20,21,22,23,24,25],4}
router: sent stop message to server {<7484.105.0>,[30,31,32],3}
router: sent stop message to server {<7485.104.0>,[40,41],2}
(router@MyMBP)3> 
=ERROR REPORT==== 3-May-2017::07:40:42 ===
Error in process <0.62.0> on node 'router@MyMBP' with exit value: {badarg,[{fs,deallocate,1,[{file,"fs.erl"},{line,243}]},{fs,handle_allocate_response,3,[{file,"fs.erl"},{line,189}]}]}


=ERROR REPORT==== 3-May-2017::07:40:43 ===
Error in process <0.65.0> on node 'router@MyMBP' with exit value: {badarg,[{fs,deallocate,1,[{file,"fs.erl"},{line,243}]},{fs,handle_allocate_response,3,[{file,"fs.erl"},{line,189}]}]}


=ERROR REPORT==== 3-May-2017::07:40:43 ===
Error in process <0.63.0> on node 'router@MyMBP' with exit value: {badarg,[{fs,deallocate,1,[{file,"fs.erl"},{line,243}]},{fs,handle_allocate_response,3,[{file,"fs.erl"},{line,189}]}]}


=ERROR REPORT==== 3-May-2017::07:40:44 ===
Error in process <0.64.0> on node 'router@MyMBP' with exit value: {badarg,[{fs,deallocate,1,[{file,"fs.erl"},{line,243}]},{fs,handle_allocate_response,3,[{file,"fs.erl"},{line,189}]}]}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment