-
Notifications
You must be signed in to change notification settings - Fork 10
EGTM Tutorial
ztmr edited this page Dec 30, 2012
·
2 revisions
- Prerequisities
- EGTM installation
- Getting started
- Linux or anothe OS supported by the Erlang/OTP and FIS GT.M
- installed Erlang/OTP
- installed GT.M, according to GT.M Tutorial
/tmp$ git clone http://github.com/ztmr/egtm
Cloning into 'egtm'...
remote: Counting objects: 152, done.
remote: Compressing objects: 100% (80/80), done.
remote: Total 152 (delta 74), reused 137 (delta 59)
Receiving objects: 100% (152/152), 167.68 KiB | 235 KiB/s, done.
Resolving deltas: 100% (74/74), done.
/tmp$
/tmp$
/tmp$ cd egtm
/tmp/egtm$
/tmp/egtm$
/tmp/egtm$ ./rebar get-deps
==> egtm (get-deps)
Pulling lager from {git,"https://github.com/basho/lager.git","master"}
Cloning into 'lager'...
Pulling deepprops from {git,"https://github.com/keynslug/deepprops.git",
"master"}
Cloning into 'deepprops'...
Pulling folsom from {git,"https://github.com/boundary/folsom.git","master"}
Cloning into 'folsom'...
Pulling ecache from {git,"https://github.com/dweldon/ecache.git","master"}
Cloning into 'ecache'...
==> lager (get-deps)
==> deepprops (get-deps)
==> folsom (get-deps)
Pulling bear from {git,"git://github.com/boundary/bear.git",{tag,"0.1.2"}}
Cloning into 'bear'...
Pulling meck from {git,"git://github.com/eproxus/meck","master"}
Cloning into 'meck'...
Branch master set up to track remote branch master from origin.
==> bear (get-deps)
==> meck (get-deps)
==> ecache (get-deps)
/tmp/egtm$
/tmp/egtm$
/tmp/egtm$ ./rebar compile
==> lager (compile)
Compiled src/lager_util.erl
Compiled src/lager_transform.erl
Compiled src/lager_app.erl
Compiled src/lager_crash_log.erl
Compiled src/lager_msg.erl
Compiled src/lager_handler_watcher.erl
Compiled src/lager_trunc_io.erl
Compiled src/lager_stdlib.erl
Compiled src/lager_handler_watcher_sup.erl
Compiled src/lager_config.erl
Compiled src/lager_default_formatter.erl
Compiled src/lager_console_backend.erl
Compiled src/error_logger_lager_h.erl
Compiled src/lager_file_backend.erl
Compiled src/lager.erl
Compiled src/lager_sup.erl
Compiled src/lager_format.erl
==> deepprops (compile)
Compiled src/deepprops.erl
==> bear (compile)
Compiled src/bear.erl
==> meck (compile)
Compiled src/meck_mod.erl
Compiled src/meck_cover.erl
Compiled src/meck.erl
==> folsom (compile)
Compiled src/folsom_sample_slide_sup.erl
Compiled src/folsom.erl
Compiled src/folsom_metrics_histogram.erl
Compiled src/folsom_meter_timer_server.erl
Compiled src/folsom_metrics_meter_reader.erl
Compiled src/folsom_sample_exdec.erl
Compiled src/folsom_sample.erl
Compiled src/folsom_sample_slide_uniform.erl
Compiled src/folsom_ewma.erl
Compiled src/folsom_sample_slide_server.erl
Compiled src/folsom_sample_slide.erl
Compiled src/folsom_sup.erl
Compiled src/folsom_metrics_history.erl
Compiled src/folsom_metrics_spiral.erl
Compiled src/folsom_metrics_counter.erl
Compiled src/folsom_metrics.erl
Compiled src/folsom_metrics_gauge.erl
Compiled src/folsom_metrics_duration.erl
Compiled src/folsom_sample_none.erl
Compiled src/folsom_metrics_histogram_ets.erl
Compiled src/folsom_metrics_meter.erl
Compiled src/folsom_sample_uniform.erl
Compiled src/folsom_vm_metrics.erl
Compiled src/folsom_utils.erl
Compiled src/folsom_ets.erl
==> ecache (compile)
Compiled src/ecache_util.erl
Compiled src/ecache_sup.erl
Compiled src/ecache_app.erl
Compiled src/ecache_purge_server.erl
Compiled src/ecache.erl
==> egtm (compile)
Compiled src/egtm_pool_sup.erl
Compiled src/egtm_admin.erl
Compiled src/egtm_util.erl
Compiled src/egtm_worker.erl
Compiled src/egtm_util_eunit.erl
Compiled src/egtm_util_fmt.erl
Compiled src/egtm_pool.erl
Compiled src/egtm_worker_sup.erl
Compiled src/egtm_string.erl
Compiled src/egtm.erl
Compiled src/egtm_env.erl
Compiled src/egtm_metrics.erl
Compiled src/egtm_config.erl
Compiling c_src/egtm_worker.c
/tmp/egtm$
/tmp/egtm$
/tmp/egtm$ ./priv/egtm_console
Erlang R15B (erts-5.9) [source] [64-bit] [smp:8:8] [async-threads:0] [hipe] [kernel-poll:false]
Eshell V5.9 (abort with ^G)
(egtm_console@gersemi)1>
(egtm_console@gersemi)1>
(egtm_console@gersemi)1> egtm:start ().
16:50:58.845 [info] Application lager started on node egtm_console@gersemi
16:50:58.847 [info] Starting up egtm on node egtm_console@gersemi...
16:50:58.848 [info] Application ecache started on node egtm_console@gersemi
16:50:58.850 [info] Running OS command: ./priv/initdb
16:50:58.895 [info] %GDE-I-GDUSEDEFS, Using defaults for Global Directory
/tmp/egtm/priv/gbls/egtm.gld
GDE>
GDE>
GDE>
GDE>
GDE>
GDE>
GDE>
GDE>
GDE>
GDE>
GDE>
GDE>
GDE>
GDE>
GDE>
GDE>
GDE>
GDE>
GDE>
*** TEMPLATES ***
Std Inst
Def Rec Key Null Null Freeze Qdb
Region Coll Size Size Subs Coll Jnl on Error Rndwn
----------------------------------------------------------------------------------------------------
<default> 0 4080 255 ALWAYS N Y DISABLED DISABLED
Jnl File (def ext: .mjl) Before Buff Alloc Exten AutoSwitch
------------------------------------------------------------------------------------------
<default> <based on DB file-spec> Y 2308 2048 2048 8386560
Segment Active Acc Typ Block Alloc Exten Options
------------------------------------------------------------------------------
<default> * BG DYN 4096 1000 3000 GLOB =4096
LOCK = 40
RES = 0
ENCR = OFF
<default> MM DYN 1024 100 100 DEFER
LOCK = 40
*** NAMES ***
Global Region
------------------------------------------------------------------------------
* EGTM
Big* EGTMBIG
*** REGIONS ***
Std Inst
Dynamic Def Rec Key Null Null Freeze Qdb
Region Segment Coll Size Size Subs Coll Jnl on Error Rndwn
--------------------------------------------------------------------------------------------------------------------------
EGTM EGTM 0 4080 255 ALWAYS N Y DISABLED DISABLED
EGTMBIG EGTMBIG 0 32240 255 ALWAYS N Y DISABLED DISABLED
*** JOURNALING INFORMATION ***
Region Jnl File (def ext: .mjl) Before Buff Alloc Exten AutoSwitch
--------------------------------------------------------------------------------------------------------
EGTM <based on DB file-spec> Y 2308 2048 2048 8386560
EGTMBIG <based on DB file-spec> Y 2308 2048 2048 8386560
*** SEGMENTS ***
Segment File (def ext: .dat)Acc Typ Block Alloc Exten Options
-------------------------------------------------------------------------------------------
EGTM $EGTM_DB_DEFAULT BG DYN 4096 1000 3000 GLOB=4096
LOCK= 40
RES = 0
ENCR=OFF
EGTMBIG $EGTM_DB_BIG BG DYN 32256 1000 3000 GLOB=4096
LOCK= 40
RES = 0
ENCR=OFF
*** MAP ***
- - - - - - - - - - Names - - - - - - - - - -
From Up to Region / Segment / File(def ext: .dat)
--------------------------------------------------------------------------------------------------------------------------
% Big REG = EGTM
SEG = EGTM
FILE = $EGTM_DB_DEFAULT
Big Bih REG = EGTMBIG
SEG = EGTMBIG
FILE = $EGTM_DB_BIG
Bih ... REG = EGTM
SEG = EGTM
FILE = $EGTM_DB_DEFAULT
LOCAL LOCKS REG = EGTM
SEG = EGTM
FILE = $EGTM_DB_DEFAULT
GDE>
%GDE-I-VERIFY, Verification OK
GDE>
%GDE-I-VERIFY, Verification OK
%GDE-I-GDCREATE, Creating Global Directory file
/tmp/egtm/priv/gbls/egtm.gld
Created file /tmp/egtm/priv/gbls/egtm.dat
Created file /tmp/egtm/priv/gbls/egtmbig.dat
16:50:58.920 [info] Starting up egtm_worker on node egtm_console@gersemi...
16:50:58.921 [info] Application egtm started on node egtm_console@gersemi
ok
(egtm_console@gersemi)2>
(egtm_console@gersemi)2>
(egtm_console@gersemi)2> egtm:zversion ().
"GT.M V6.0-000 Linux x86_64"
(egtm_console@gersemi)3>
(egtm_console@gersemi)3>
(egtm_console@gersemi)3> q ().
ok
(egtm_console@gersemi)4> 16:51:15.308 [info] Shutting down egtm on node egtm_console@gersemi...
/tmp/egtm$
/tmp/egtm$
/tmp/egtm$ ./rebar eunit apps=egtm
==> egtm (eunit)
Compiled src/egtm_pool_sup.erl
Compiled src/egtm_admin.erl
Compiled src/egtm.erl
Compiled src/egtm_util_eunit.erl
Compiled src/egtm_worker.erl
Compiled src/egtm_pool.erl
Compiled src/egtm_worker_sup.erl
Compiled src/egtm_util_fmt.erl
Compiled src/egtm_util.erl
Compiled src/egtm_string.erl
Compiled src/egtm_env.erl
Compiled src/egtm_config.erl
Compiled src/egtm_metrics.erl
======================== EUnit ========================
module 'egtm_pool'
module 'egtm_admin'
module 'egtm_pool_sup'
module 'egtm_util_eunit'
module 'egtm_string'
module 'egtm_worker_sup'
module 'egtm'
egtm: basic_test...16:54:47.071 [info] Application lager started on node nonode@nohost
16:54:47.074 [info] Application ecache started on node nonode@nohost
16:54:47.074 [info] Starting up egtm on node nonode@nohost...
16:54:47.074 [info] Running OS command: /tmp/egtm/priv/initdb
16:54:47.093 [info] FORMAT ERROR: [] []
16:54:47.119 [info] Starting up egtm_worker on node nonode@nohost...
16:54:47.120 [info] Application egtm started on node nonode@nohost
16:54:47.133 [info] Shutting down egtm on node nonode@nohost...
16:54:47.134 [info] Application egtm exited with reason: stopped
[0.079 s] ok
egtm: order_direction_test...16:54:47.137 [info] Starting up egtm on node nonode@nohost...
16:54:47.137 [info] Running OS command: /tmp/egtm/priv/initdb
16:54:47.156 [info] FORMAT ERROR: [] []
16:54:47.156 [info] Starting up egtm_worker on node nonode@nohost...
16:54:47.156 [info] Application egtm started on node nonode@nohost
16:54:47.158 [info] Shutting down egtm on node nonode@nohost...
16:54:47.158 [info] Application egtm exited with reason: stopped
[0.022 s] ok
egtm: order_speed_test...16:54:47.161 [info] Starting up egtm on node nonode@nohost...
16:54:47.161 [info] Running OS command: /tmp/egtm/priv/initdb
16:54:47.179 [info] FORMAT ERROR: [] []
16:54:47.180 [info] Starting up egtm_worker on node nonode@nohost...
16:54:47.180 [info] Application egtm started on node nonode@nohost
16:54:49.689 [info] Shutting down egtm on node nonode@nohost...
16:54:49.689 [info] Application egtm exited with reason: stopped
[2.527 s] ok
[done in 2.636 s]
module 'egtm_worker'
module 'egtm_env'
egtm_util_fmt: basic_test (module 'egtm_util_fmt')...ok
module 'egtm_util'
egtm_util: longstring_test...16:54:49.716 [info] Starting up egtm on node nonode@nohost...
16:54:49.717 [info] Running OS command: /tmp/egtm/priv/initdb
16:54:49.735 [info] FORMAT ERROR: [] []
16:54:49.736 [info] Starting up egtm_worker on node nonode@nohost...
16:54:49.736 [info] Application egtm started on node nonode@nohost
16:54:49.757 [info] Shutting down egtm on node nonode@nohost...
16:54:49.757 [info] Application egtm exited with reason: stopped
[0.041 s] ok
egtm_util: foreach_test...ok
[done in 0.046 s]
module 'egtm_config'
module 'egtm_metrics'
=======================================================
All 6 tests passed.
16:54:49.771 [info] Application ecache exited with reason: stopped
=INFO REPORT==== 30-Dec-2012::16:54:49 ===
application: lager
exited: stopped
type: permanent
/tmp/egtm$
/tmp/egtm$ ./priv/egtm_console
Erlang R15B (erts-5.9) [source] [64-bit] [smp:8:8] [async-threads:0] [hipe] [kernel-poll:false]
Eshell V5.9 (abort with ^G)
(egtm_console@gersemi)1>
(egtm_console@gersemi)1>
(egtm_console@gersemi)1> egtm:start ().
16:57:26.999 [info] Application lager started on node egtm_console@gersemi
16:57:27.001 [info] Starting up egtm on node egtm_console@gersemi...
16:57:27.002 [info] Application ecache started on node egtm_console@gersemi
16:57:27.004 [info] Running OS command: ./priv/initdb
16:57:27.024 [info] FORMAT ERROR: [] []
16:57:27.051 [info] Starting up egtm_worker on node egtm_console@gersemi...
16:57:27.052 [info] Application egtm started on node egtm_console@gersemi
ok
(egtm_console@gersemi)2>
(egtm_console@gersemi)2>
> egtm:set ("^Company", ["IDEA"], 1).
ok
> egtm:set ("^Company", ["IDEA", "%BRCD", "HQ"], 1).
ok
> egtm:set ("^Company", ["IDEA", "%BRCD", "HQ", "Address"], "Antala Sta#ka 1859/34|Prague|Czech Republic|Earth").
ok
> egtm:set ("^Company", ["IDEA", "%BRCD", "HQ", "Team", "jsmith"], "John Smith|[email protected]|developer").
ok
> egtm:set ("^Company", ["IDEA", "%BRCD", "HQ", "Team", "nhook"], "Nick Hook|[email protected]|project manager").
ok
> egtm:set ("^Company", ["IDEA", "%BRCD", "HQ", "Team", "jcook"], "Jim Cook|[email protected]|tester").
ok
> egtm:set ("^Company", ["IDEA", "%BRCD", "MARS"], 0).
ok
> egtm:set ("^Company", ["IDEA"], "1991").
ok
> egtm:set ("^Company", ["Google"], 1998).
ok
> egtm:set ("^Company", ["IDEA", "%BRCD", "MARS", "Team", "johnmartian1"], "John the Martian #1|[email protected]|long distance messaging").
ok
> egtm:set ("^Company", ["IDEA", "%BRCD", "MARS", "Team", "davemartian1"], "David the Martian #1|[email protected]|interplanetary billing").
ok
> egtm_util:foreach ("^Company", []).
^Company["Google"]="1998"
^Company["IDEA"]="1991"
{ok,["Google","IDEA"]}
> egtm:kill ("^Company", ["Google"]).
ok
> egtm_util:foreach ("^Company", []).
^Company["IDEA"]="1991"
{ok,["IDEA"]}
> egtm_util:foreach ("^Company", ["IDEA"]).
^Company["IDEA","%BRCD"]=[]
{ok,["%BRCD"]}
> egtm_util:foreach ("^Company", ["IDEA", "%BRCD"]).
^Company["IDEA","%BRCD","HQ"]="1"
^Company["IDEA","%BRCD","MARS"]="0"
{ok,["HQ","MARS"]}
> egtm_util:foreach ("^Company", ["IDEA", "%BRCD", "MARS"]).
^Company["IDEA","%BRCD","MARS","Team"]=[]
{ok,["Team"]}
> egtm_util:foreach ("^Company", ["IDEA", "%BRCD", "MARS", "Team"]).
^Company["IDEA","%BRCD","MARS","Team","davemartian1"]="David the Martian #1|[email protected]|interplanetary billing"
^Company["IDEA","%BRCD","MARS","Team","johnmartian1"]="John the Martian #1|[email protected]|long distance messaging"
{ok,["davemartian1","johnmartian1"]}
> egtm_util:foreach ("^Company", [], fun (G, S, _) -> Name = lists:last (S), Branches = egtm_util:foreach (G, S++["%BRCD"], fun (_, S2, A2) -> [lists:last (S2)|A2] end), io:format ("The company ~s was founded on ~s and has branches: ~s.~n", [Name, egtm:getp (G, S), (fun ({ok, L}) -> string:join (L, ", "); (nomatch) -> "N/A" end) (Branches)]), done end).
The company Google was founded on 1998 and has branches: N/A.
The company IDEA was founded on 1991 and has branches: MARS, HQ.
{ok,done}
> io:format ("IDEA MARS team:~n"), egtm_util:foreach ("^Company", ["IDEA", "%BRCD", "MARS", "Team"], fun (G, S, A) -> Key = lists:last (S), io:format (" ~s, ~s, ~s;~n", [egtm:getp (G, S), egtm:getp (G, S, 2), egtm:getp (G, S, 3)]) end).
IDEA MARS team:
David the Martian #1, dave1@mars.foo.com, interplanetary billing;
John the Martian #1, john1@mars.foo.com, long distance messaging;
{ok,ok}
> q().
ok
17:56:01.126 [info] Shutting down egtm on node egtm_console@gersemi...
/tmp/egtm$