This commit is contained in:
Ery Lee 2015-04-08 19:40:22 +08:00
parent 03806557ef
commit 7a979e2c57
4 changed files with 15 additions and 61 deletions

View File

@ -33,14 +33,14 @@
-export([init/0, wait/0]).
init() ->
case mnesia:system_info(extra_db_nodes) of
[] ->
mnesia:stop(),
mnesia:create_schema([node()]);
_ ->
ok
end,
ok = mnesia:start(),
%case mnesia:system_info(extra_db_nodes) of
% [] ->
% mnesia:stop(),
% mnesia:create_schema([node()]);
% _ ->
% ok
%end,
%ok = mnesia:start(),
create_tables().
create_tables() ->

View File

@ -232,22 +232,26 @@ init([]) ->
{ram_copies, [node()]},
{attributes, record_info(fields, topic_trie)}]),
mnesia:add_table_copy(topic_trie, node(), ram_copies),
Result =
mnesia:create_table(topic, [
{type, bag},
{record_name, topic},
{ram_copies, [node()]},
{attributes, record_info(fields, topic)}]),
io:format("~p~n", [Result]),
mnesia:add_table_copy(topic, node(), ram_copies),
mnesia:subscribe({table, topic, simple}),
%% local table, not shared with other table
Result1 =
mnesia:create_table(topic_subscriber, [
{type, bag},
{record_name, topic_subscriber},
{ram_copies, [node()]},
{attributes, record_info(fields, topic_subscriber)},
{index, [subpid]},
{local_content, true}]),
{index, [subpid]}]),
%{local_content, true}]),
mnesia:subscribe({table, topic_subscriber, simple}),
io:format("~p~n", [Result1]),
{ok, #state{}}.
handle_call(getstats, _From, State = #state{max_subs = Max}) ->

View File

@ -1,50 +0,0 @@
-module(x).
-behaviour(gen_server).
-define(SERVER, ?MODULE).
%% ------------------------------------------------------------------
%% API Function Exports
%% ------------------------------------------------------------------
-export([start_link/0]).
%% ------------------------------------------------------------------
%% gen_server Function Exports
%% ------------------------------------------------------------------
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
terminate/2, code_change/3]).
%% ------------------------------------------------------------------
%% API Function Definitions
%% ------------------------------------------------------------------
start_link() ->
gen_server:start_link({local, ?SERVER}, ?MODULE, [], []).
%% ------------------------------------------------------------------
%% gen_server Function Definitions
%% ------------------------------------------------------------------
init(Args) ->
{ok, Args}.
handle_call(_Request, _From, State) ->
{reply, ok, State}.
handle_cast(_Msg, State) ->
{noreply, State}.
handle_info(_Info, State) ->
{noreply, State}.
terminate(_Reason, _State) ->
ok.
code_change(_OldVsn, State, _Extra) ->
{ok, State}.
%% ------------------------------------------------------------------
%% Internal Function Definitions
%% ------------------------------------------------------------------

View File

@ -10,7 +10,7 @@
syntax_tools,
ssl,
crypto,
%mnesia,
mnesia,
os_mon,
inets,
goldrush,