Skip to content

Commit b745e57

Browse files
hairyhumlukebakken
authored andcommitted
WIP. Fixed startup
1 parent eb9b71d commit b745e57

File tree

2 files changed

+22
-21
lines changed

2 files changed

+22
-21
lines changed

src/rabbit_mnesia.erl

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,13 @@ init() ->
7777
ensure_mnesia_running(),
7878
ensure_mnesia_dir(),
7979

80+
%% TODO mnevis: node start
81+
mnevis_node:start(),
82+
8083
%% Create schema on all nodes
8184
ok = create_schema(),
8285

83-
%% TODO mnevis: node start
84-
mnevis_node:start(),
85-
mnevis_node:trigger_election(),
86+
8687

8788
{ok, _, _} = ra:members(mnevis_node:node_id()),
8889

@@ -841,10 +842,10 @@ schema_ok_or_move() ->
841842
%% We only care about disc nodes since ram nodes are supposed to catch
842843
%% up only
843844
create_schema() ->
844-
io:format("Create schema ~n"),
845-
stop_mnesia(),
846-
rabbit_misc:ensure_ok(mnesia:create_schema([node()]), cannot_create_schema),
847-
start_mnesia(),
845+
% io:format("Create schema ~n"),
846+
% stop_mnesia(),
847+
% rabbit_misc:ensure_ok(mnesia:create_schema([node()]), cannot_create_schema),
848+
% start_mnesia(),
848849

849850
io:format("Create tables ~n"),
850851
ok = rabbit_table:create(),

src/rabbit_table.erl

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
create() ->
4040
lists:foreach(fun ({Tab, TabDef}) ->
4141
TabDef1 = proplists:delete(match, TabDef),
42-
case mnesia:create_table(Tab, TabDef1) of
42+
case mnevis:create_table(Tab, TabDef1) of
4343
{atomic, ok} -> ok;
4444
{aborted, Reason} ->
4545
throw({error, {table_creation_failed,
@@ -69,7 +69,7 @@ ensure_secondary_index(Table, Field) ->
6969
-spec create_local_copy('disc' | 'ram') -> 'ok'.
7070

7171
create_local_copy(disc) ->
72-
create_local_copy(schema, disc_copies),
72+
create_local_copy(schema, ram_copies),
7373
create_local_copies(disc);
7474
create_local_copy(ram) ->
7575
create_local_copies(ram),
@@ -194,14 +194,14 @@ clear_ram_only_tables() ->
194194
create_local_copies(Type) ->
195195
lists:foreach(
196196
fun ({Tab, TabDef}) ->
197-
HasDiscCopies = has_copy_type(TabDef, disc_copies),
197+
HasDiscCopies = has_copy_type(TabDef, ram_copies),
198198
HasDiscOnlyCopies = has_copy_type(TabDef, disc_only_copies),
199199
LocalTab = proplists:get_bool(local_content, TabDef),
200200
StorageType =
201201
if
202202
Type =:= disc orelse LocalTab ->
203203
if
204-
HasDiscCopies -> disc_copies;
204+
HasDiscCopies -> ram_copies;
205205
HasDiscOnlyCopies -> disc_only_copies;
206206
true -> ram_copies
207207
end;
@@ -271,35 +271,35 @@ names() -> [Tab || {Tab, _} <- definitions()].
271271
definitions(disc) ->
272272
definitions();
273273
definitions(ram) ->
274-
[{Tab, [{disc_copies, []}, {ram_copies, [node()]} |
274+
[{Tab, [{ram_copies, []}, {ram_copies, [node()]} |
275275
proplists:delete(
276-
ram_copies, proplists:delete(disc_copies, TabDef))]} ||
276+
ram_copies, proplists:delete(ram_copies, TabDef))]} ||
277277
{Tab, TabDef} <- definitions()].
278278

279279
definitions() ->
280280
[{rabbit_user,
281281
[{record_name, internal_user},
282282
{attributes, record_info(fields, internal_user)},
283-
{disc_copies, [node()]},
283+
{ram_copies, [node()]},
284284
{match, #internal_user{_='_'}}]},
285285
{rabbit_user_permission,
286286
[{record_name, user_permission},
287287
{attributes, record_info(fields, user_permission)},
288-
{disc_copies, [node()]},
288+
{ram_copies, [node()]},
289289
{match, #user_permission{user_vhost = #user_vhost{_='_'},
290290
permission = #permission{_='_'},
291291
_='_'}}]},
292292
{rabbit_topic_permission,
293293
[{record_name, topic_permission},
294294
{attributes, record_info(fields, topic_permission)},
295-
{disc_copies, [node()]},
295+
{ram_copies, [node()]},
296296
{match, #topic_permission{topic_permission_key = #topic_permission_key{_='_'},
297297
permission = #permission{_='_'},
298298
_='_'}}]},
299299
{rabbit_vhost,
300300
[{record_name, vhost},
301301
{attributes, record_info(fields, vhost)},
302-
{disc_copies, [node()]},
302+
{ram_copies, [node()]},
303303
{match, #vhost{_='_'}}]},
304304
{rabbit_listener,
305305
[{record_name, listener},
@@ -309,7 +309,7 @@ definitions() ->
309309
{rabbit_durable_route,
310310
[{record_name, route},
311311
{attributes, record_info(fields, route)},
312-
{disc_copies, [node()]},
312+
{ram_copies, [node()]},
313313
{match, #route{binding = binding_match(), _='_'}}]},
314314
{rabbit_semi_durable_route,
315315
[{record_name, route},
@@ -346,7 +346,7 @@ definitions() ->
346346
{rabbit_durable_exchange,
347347
[{record_name, exchange},
348348
{attributes, record_info(fields, exchange)},
349-
{disc_copies, [node()]},
349+
{ram_copies, [node()]},
350350
{match, #exchange{name = exchange_name_match(), _='_'}}]},
351351
{rabbit_exchange,
352352
[{record_name, exchange},
@@ -359,12 +359,12 @@ definitions() ->
359359
{rabbit_runtime_parameters,
360360
[{record_name, runtime_parameters},
361361
{attributes, record_info(fields, runtime_parameters)},
362-
{disc_copies, [node()]},
362+
{ram_copies, [node()]},
363363
{match, #runtime_parameters{_='_'}}]},
364364
{rabbit_durable_queue,
365365
[{record_name, amqqueue},
366366
{attributes, amqqueue:fields()},
367-
{disc_copies, [node()]},
367+
{ram_copies, [node()]},
368368
{match, amqqueue:pattern_match_on_name(queue_name_match())}]},
369369
{rabbit_queue,
370370
[{record_name, amqqueue},

0 commit comments

Comments
 (0)