cluster
This commit is contained in:
parent
03806557ef
commit
7a979e2c57
|
@ -33,14 +33,14 @@
|
||||||
-export([init/0, wait/0]).
|
-export([init/0, wait/0]).
|
||||||
|
|
||||||
init() ->
|
init() ->
|
||||||
case mnesia:system_info(extra_db_nodes) of
|
%case mnesia:system_info(extra_db_nodes) of
|
||||||
[] ->
|
% [] ->
|
||||||
mnesia:stop(),
|
% mnesia:stop(),
|
||||||
mnesia:create_schema([node()]);
|
% mnesia:create_schema([node()]);
|
||||||
_ ->
|
% _ ->
|
||||||
ok
|
% ok
|
||||||
end,
|
%end,
|
||||||
ok = mnesia:start(),
|
%ok = mnesia:start(),
|
||||||
create_tables().
|
create_tables().
|
||||||
|
|
||||||
create_tables() ->
|
create_tables() ->
|
||||||
|
|
|
@ -232,22 +232,26 @@ init([]) ->
|
||||||
{ram_copies, [node()]},
|
{ram_copies, [node()]},
|
||||||
{attributes, record_info(fields, topic_trie)}]),
|
{attributes, record_info(fields, topic_trie)}]),
|
||||||
mnesia:add_table_copy(topic_trie, node(), ram_copies),
|
mnesia:add_table_copy(topic_trie, node(), ram_copies),
|
||||||
|
Result =
|
||||||
mnesia:create_table(topic, [
|
mnesia:create_table(topic, [
|
||||||
{type, bag},
|
{type, bag},
|
||||||
{record_name, topic},
|
{record_name, topic},
|
||||||
{ram_copies, [node()]},
|
{ram_copies, [node()]},
|
||||||
{attributes, record_info(fields, topic)}]),
|
{attributes, record_info(fields, topic)}]),
|
||||||
|
io:format("~p~n", [Result]),
|
||||||
mnesia:add_table_copy(topic, node(), ram_copies),
|
mnesia:add_table_copy(topic, node(), ram_copies),
|
||||||
mnesia:subscribe({table, topic, simple}),
|
mnesia:subscribe({table, topic, simple}),
|
||||||
%% local table, not shared with other table
|
%% local table, not shared with other table
|
||||||
|
Result1 =
|
||||||
mnesia:create_table(topic_subscriber, [
|
mnesia:create_table(topic_subscriber, [
|
||||||
{type, bag},
|
{type, bag},
|
||||||
{record_name, topic_subscriber},
|
{record_name, topic_subscriber},
|
||||||
{ram_copies, [node()]},
|
{ram_copies, [node()]},
|
||||||
{attributes, record_info(fields, topic_subscriber)},
|
{attributes, record_info(fields, topic_subscriber)},
|
||||||
{index, [subpid]},
|
{index, [subpid]}]),
|
||||||
{local_content, true}]),
|
%{local_content, true}]),
|
||||||
mnesia:subscribe({table, topic_subscriber, simple}),
|
mnesia:subscribe({table, topic_subscriber, simple}),
|
||||||
|
io:format("~p~n", [Result1]),
|
||||||
{ok, #state{}}.
|
{ok, #state{}}.
|
||||||
|
|
||||||
handle_call(getstats, _From, State = #state{max_subs = Max}) ->
|
handle_call(getstats, _From, State = #state{max_subs = Max}) ->
|
||||||
|
|
|
@ -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
|
|
||||||
%% ------------------------------------------------------------------
|
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
syntax_tools,
|
syntax_tools,
|
||||||
ssl,
|
ssl,
|
||||||
crypto,
|
crypto,
|
||||||
%mnesia,
|
mnesia,
|
||||||
os_mon,
|
os_mon,
|
||||||
inets,
|
inets,
|
||||||
goldrush,
|
goldrush,
|
||||||
|
|
Loading…
Reference in New Issue