Skip to content

Commit 8313e18

Browse files
committed
lets go
0 parents  commit 8313e18

File tree

12 files changed

+1058
-0
lines changed

12 files changed

+1058
-0
lines changed

LICENCE

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
Copyright (c) 2020 Vladimir Solenkov <vladimirsolenkov@yandex.ru>
2+
All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without
5+
modification, are permitted provided that the following conditions are met:
6+
7+
* Redistributions of source code must retain the above copyright notice, this
8+
list of conditions and the following disclaimer.
9+
10+
* Redistributions in binary form must reproduce the above copyright notice,
11+
this list of conditions and the following disclaimer in the documentation
12+
and/or other materials provided with the distribution.
13+
14+
* Neither the name of the copyright holder nor the names of its
15+
contributors may be used to endorse or promote products derived from
16+
this software without specific prior written permission.
17+
18+
NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY
19+
THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
20+
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22+
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
23+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
26+
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
27+
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29+
POSSIBILITY OF SUCH DAMAGE.

include/lru.hrl

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
-define(SERIE_SIZE,10000000).
2+
-define(MAX_COUNTER,1000000000000000).
3+
4+
-define(TIMEOUT_STATE_DELETE,90000).
5+
6+
-define(ETS_KEYS_STORE_TABLE_NAME,lru_key_store).
7+
-define(ETS_KEYS_FETCH_TABLE_NAME,lfu_key_fetch).
8+
-define(ETS_KEYS_FETCH_TABLE_OPTS,[
9+
public,bag,{write_concurrency,true},
10+
{decentralized_counters,true}
11+
]).
12+
13+
-define(MAX_KEY_SIZE,fun() -> application:get_env(lru,max_key_size,72) end).
14+
15+
%%
16+
%% following settings in progress develop
17+
%%
18+
-define(SPAWN_OPT_LRU,[
19+
% {max_heap_size,0},
20+
% {message_queue_data,off_heap},
21+
{fullsweep_after,65535}
22+
]).
23+
24+
-ifdef(support).
25+
-define(SUPPORT,true).
26+
-define(AUXILIARY,any).
27+
-else.
28+
-define(SUPPORT,false).
29+
-define(AUXILIARY,any).
30+
-endif.

lru.app

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{application,lru,[
2+
{description,"Least Recently Used Algorithm"},
3+
{vsn,"1.0.0"},
4+
{modules,[
5+
lru_app,lru_sup,lru,
6+
lru_protocol,lru_utils
7+
]},
8+
{registered,[
9+
lru_sup,lru
10+
]},
11+
{applications,[kernel,stdlib]},
12+
{included_applications,[ranch]},
13+
{mod,{lru_app,[]}},
14+
{start_phases,[]},
15+
{env,[]},
16+
{maintainers,["Vladimir Solenkov"]},
17+
{links,[{"Github","https://github.com/Algorithms-Lab/LRU.git"}]}
18+
]}.

lru.config

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[{lru,[
2+
{ets_dir,"priv"}, %% !!! must be atom string !!!!!
3+
{ets_sync_reset,true}, %% !!! must be atom type !!!!!
4+
{ets_recovery,true}, %% !!! must be atom type !!!!!
5+
{tcp,on}, %% !!! must be atom type !!!!!
6+
{mode,inet}, %% !!! must be atom type !!!!!
7+
{port,7777}, %% !!! must be atom type !!!!!
8+
{ip,{127,0,0,1}}, %% !!! must be tuple type !!!!!
9+
{unix,"/tmp/lru_socket"}, %% !!! must by string type !!!!!
10+
{num_acceptors,100}, %% !!! must by integer type !!!!!
11+
{max_connections,1024}, %% !!! must by integer type !!!!!
12+
{max_size_key,72} %% !!! must by integer type !!!!!
13+
]}].

priv/init

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/bin/bash
2+
3+
NAME="lru"
4+
APP=$NAME"_app"
5+
TNODE=$NAME"@"`hostname -s`
6+
CNODE=$NAME`date +_nodeclt_%H_%M_%S_%N`
7+
8+
export ERL_MAX_ETS_TABLES=140000
9+
10+
ACTION=$1
11+
12+
if [ "" = "$ACTION" ];
13+
then
14+
echo "
15+
USAGE:
16+
$0 <command> [<arg> ...]
17+
MANAGE
18+
start - start up node - 'attached'
19+
startd - start up node - 'detached'
20+
attach - attach to running node
21+
stop - stops application and halts the node
22+
"
23+
else
24+
echo "
25+
INFO:
26+
NAME: $NAME
27+
TNODE: $TNODE
28+
CNODE: $CNODE
29+
PWD: $PWD
30+
APP: $APP
31+
"
32+
cd $PWD
33+
case "$ACTION" in
34+
"start")
35+
bin/start
36+
sleep 3
37+
bin/to_erl pipe/
38+
;;
39+
"startd")
40+
bin/start
41+
;;
42+
"attach")
43+
bin/to_erl pipe/
44+
;;
45+
"stop")
46+
escript "stop" $CNODE $TNODE
47+
;;
48+
*)
49+
echo "UNKNOW COMMAND!"
50+
;;
51+
esac
52+
fi;

priv/lru.rel

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{release,
2+
{"lru","1"},
3+
{erts,"11.1"},
4+
[{kernel,"7.1"},
5+
{stdlib,"3.13.2"},
6+
{sasl, "4.0.1"},
7+
{ranch, "2.0.0"},
8+
{ssl,"10.1"},
9+
{crypto,"4.8"},
10+
{public_key,"1.9"},
11+
{asn1,"5.0.14"},
12+
{lru, "1.0.0"}]
13+
}.

priv/stop

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env escript
2+
%% -*- erlang -*-
3+
4+
main([CNode,TNode]) ->
5+
{ok, _} = net_kernel:start([list_to_atom(CNode),shortnames]),
6+
Res = rpc:call(list_to_atom(TNode),init,stop,[]),
7+
io:fwrite("==> ~p~n",[Res]).
8+

0 commit comments

Comments
 (0)