Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

2.0.2 commit

  • Loading branch information...
commit 17127f8a5310cb7f3418782fd10b6b809a2a255c 1 parent dedea3a
@erylee authored
View
4 etc/errdb.config
@@ -5,8 +5,8 @@
{errdb,
[{pool_size, 8},
{rrdb, [
- {vnodes, 20}, {cache, 12}, {timeout, 48}, {dir, "./var/data/"},
- {journal, [{dir, "./var/journal/"}, {buffer, 200}]}
+ {vnodes, 20}, {cache, 12}, {timeout, 48}, {dir, "var/data"},
+ {journal, [{dir, "var/journal"}, {buffer, 200}]}
]},
{socket, [{ip, "0.0.0.0"}, {port, 7272}]},
{httpd, [{ip, "0.0.0.0"}, {port, 8080}]}]}
View
4 src/errdb.erl
@@ -117,11 +117,11 @@ init([Id, Opts]) ->
{value, VNodes} = dataset:get_value(vnodes, Opts, 40),
Timeout = get_value(timeout, Opts, 48)*3600*1000,
%start store process
- {ok, Store} = errdb_store:start_link(errdb_store:name(Id), Dir),
+ {ok, Store} = errdb_store:start_link(Id, Dir),
%start journal process
JournalOpts = proplists:get_value(journal, Opts),
- {ok, Journal} = errdb_journal:start_link(errdb_journal:name(Id), [{id, Id} | JournalOpts]),
+ {ok, Journal} = errdb_journal:start_link(Id, JournalOpts),
DbTab = ets:new(dbtab(Id), [set, protected,
named_table, {keypos, 2}]),
View
13 src/errdb_journal.erl
@@ -33,15 +33,15 @@
-record(state, {id, logdir, logfile, thishour, buffer_size = 100, queue = []}).
-name(Id) ->
+name(Id) when is_integer(Id) ->
list_to_atom("errdb_journal_" ++ integer_to_list(Id)).
%%--------------------------------------------------------------------
%% Function: start_link() -> {ok,Pid} | ignore | {error,Error}
%% Description: Starts the server
%%--------------------------------------------------------------------
-start_link(Name, Opts) ->
- gen_server2:start_link({local, Name}, ?MODULE, [Name, Opts], [{spawn_opt, [{min_heap_size, 20480}]}]).
+start_link(Id, Opts) ->
+ gen_server2:start_link({local, name(Id)}, ?MODULE, [Id, Opts], [{spawn_opt, [{min_heap_size, 20480}]}]).
info(Pid) ->
gen_server2:call(Pid, info).
@@ -56,14 +56,13 @@ write(Pid, Key, Time, Metrics) ->
%% {stop, Reason}
%% Description: Initiates the server
%%--------------------------------------------------------------------
-init([Name, Opts]) ->
- Id = proplists:get_value(id, Opts),
+init([Id, Opts]) ->
Dir = proplists:get_value(dir, Opts),
BufferSize = proplists:get_value(buffer, Opts, 100),
State = #state{id = Id, logdir = Dir, buffer_size = BufferSize},
{noreply, NewState} = handle_info(journal_rotation, State),
erlang:send_after(3000, self(), flush_queue),
- io:format("~n~p is started.~n", [Name]),
+ io:format("~n~p is started.~n", [name(Id)]),
{ok, NewState}.
%%--------------------------------------------------------------------
@@ -118,7 +117,7 @@ handle_info(journal_rotation, #state{id = Id, logdir = Dir, logfile = File, queu
close_file(File),
Now = timestamp(),
{Hour,_,_} = time(),
- FilePath = lists:concat([Dir, extbif:strfdate(date()), "/",
+ FilePath = lists:concat([Dir, "/", extbif:strfdate(date()), "/",
zeropad(Hour), "/", integer_to_list(Id), ".journal"]),
filelib:ensure_dir(FilePath),
{ok, NewFile} = file:open(FilePath, [write]),
View
11 src/errdb_store.erl
@@ -63,8 +63,8 @@
%% Function: start_link() -> {ok,Pid} | ignore | {error,Error}
%% Description: Starts the server
%%--------------------------------------------------------------------
-start_link(Name, Dir) ->
- gen_server2:start_link({local, Name}, ?MODULE, [Name, Dir],
+start_link(Id, Dir) ->
+ gen_server2:start_link({local, name(Id)}, ?MODULE, [Id, Dir],
[{spawn_opt, [{min_heap_size, 204800}]}]).
name(Id) ->
@@ -138,9 +138,10 @@ delete(Pid, Key) ->
%% {stop, Reason}
%% Description: Initiates the server
%%--------------------------------------------------------------------
-init([Name, Dir]) ->
- io:format("~n~p is started.~n", [Name]),
- {ok, #state{dbdir = Dir}}.
+init([Id, Dir]) ->
+ io:format("~n~p is started.~n", [name(Id)]),
+ DbDir = Dir ++ "/" ++ integer_to_list(Id),
+ {ok, #state{dbdir = DbDir}}.
%%--------------------------------------------------------------------
%% Function: %% handle_call(Request, From, State) -> {reply, Reply, State} |
View
0  var/data/.placeholder
No changes.
View
0  var/journal/.placeholder
No changes.
Please sign in to comment.
Something went wrong with that request. Please try again.