4
%% Copyright Ericsson AB 1998-2009. All Rights Reserved.
4
%% Copyright Ericsson AB 1998-2011. All Rights Reserved.
6
6
%% The contents of this file are subject to the Erlang Public License,
7
7
%% Version 1.1, (the "License"); you may not use this file except in
212
search_first(ActivityId, Opaque, Tab, N, FH) when N =< FH#frag_state.n_fragments ->
212
search_first(ActivityId, Opaque, Tab, N, FH) when N < FH#frag_state.n_fragments ->
214
214
NextFrag = n_to_frag_name(Tab, NextN),
215
215
case mnesia:first(ActivityId, Opaque, NextFrag) of
449
449
local_collect(Ref, Pid, Type, LocalMatch, OldSelectFun) ->
451
{local_select, Ref, LocalRes} ->
452
remote_collect(Ref, Type, LocalRes, LocalMatch, OldSelectFun);
451
{local_select, Ref, ok} ->
452
remote_collect_ok(Ref, Type, LocalMatch, OldSelectFun);
453
{local_select, Ref, {error, Reason}} ->
454
remote_collect_error(Ref, Type, Reason, OldSelectFun);
453
455
{'EXIT', Pid, Reason} ->
454
remote_collect(Ref, Type, {error, Reason}, [], OldSelectFun)
456
remote_collect_error(Ref, Type, Reason, OldSelectFun)
457
remote_collect(Ref, Type, LocalRes = ok, Acc, OldSelectFun) ->
459
remote_collect_ok(Ref, Type, Acc, OldSelectFun) ->
459
461
{remote_select, Ref, Node, RemoteRes} ->
460
462
case RemoteRes of
463
465
ordered_set -> lists:merge(RemoteMatch, Acc);
464
466
_ -> RemoteMatch ++ Acc
466
remote_collect(Ref, Type, LocalRes, Matches, OldSelectFun);
468
remote_collect_ok(Ref, Type, Matches, OldSelectFun);
468
remote_collect(Ref, Type, {error, {node_not_running, Node}}, [], OldSelectFun)
470
Reason = {node_not_running, Node},
471
remote_collect_error(Ref, Type, Reason, OldSelectFun)
473
remote_collect(Ref, Type, LocalRes = {error, Reason}, _Acc, OldSelectFun) ->
477
remote_collect_error(Ref, Type, Reason, OldSelectFun) ->
475
479
{remote_select, Ref, _Node, _RemoteRes} ->
476
remote_collect(Ref, Type, LocalRes, [], OldSelectFun)
480
remote_collect_error(Ref, Type, Reason, OldSelectFun)
482
mnesia:abort({error, Reason})
481
485
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
755
759
Cs2 = Cs#cstruct{frag_properties = Props},
756
760
[Cs3] = expand_cstruct(Cs2, activate),
757
TabDef = mnesia_schema:cs2list(Cs3),
761
TabDef = mnesia_schema:vsn_cs2list(Cs3),
758
762
Op = {op, change_table_frag, activate, TabDef},
779
783
mnesia:abort({combine_error, Tab, "Too many fragments"});
781
785
Cs2 = Cs#cstruct{frag_properties = []},
782
TabDef = mnesia_schema:cs2list(Cs2),
786
TabDef = mnesia_schema:vsn_cs2list(Cs2),
783
787
Op = {op, change_table_frag, deactivate, TabDef},
846
850
SplitOps = split(Tab, FH2, FromIndecies, FragNames, []),
848
852
Cs2 = replace_frag_hash(Cs, FH2),
849
TabDef = mnesia_schema:cs2list(Cs2),
853
TabDef = mnesia_schema:vsn_cs2list(Cs2),
850
854
BaseOp = {op, change_table_frag, {add_frag, SortedNs}, TabDef},
852
856
[BaseOp, NewOp | SplitOps].
958
962
LastFrag = element(N, FragNames),
959
963
[LastOp] = mnesia_schema:make_delete_table(LastFrag, single_frag),
960
964
Cs2 = replace_frag_hash(Cs, FH2),
961
TabDef = mnesia_schema:cs2list(Cs2),
965
TabDef = mnesia_schema:vsn_cs2list(Cs2),
962
966
BaseOp = {op, change_table_frag, del_frag, TabDef},
963
967
[BaseOp, LastOp | MergeOps];
1071
1075
Props = Cs#cstruct.frag_properties,
1072
1076
Props2 = lists:keyreplace(node_pool, 1, Props, {node_pool, Pool2}),
1073
1077
Cs2 = Cs#cstruct{frag_properties = Props2},
1074
TabDef = mnesia_schema:cs2list(Cs2),
1078
TabDef = mnesia_schema:vsn_cs2list(Cs2),
1075
1079
Op = {op, change_table_frag, {add_node, Node}, TabDef},
1100
1104
Pool2 = Pool -- [Node],
1101
1105
Props = lists:keyreplace(node_pool, 1, Cs#cstruct.frag_properties, {node_pool, Pool2}),
1102
1106
Cs2 = Cs#cstruct{frag_properties = Props},
1103
TabDef = mnesia_schema:cs2list(Cs2),
1107
TabDef = mnesia_schema:vsn_cs2list(Cs2),
1104
1108
Op = {op, change_table_frag, {del_node, Node}, TabDef},