summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad Anderson <brad@cloudant.com>2010-03-30 18:56:25 -0400
committerBrad Anderson <brad@cloudant.com>2010-05-09 22:56:23 -0400
commit70502d9c2ac609a90a427200fccfec747e0b63bd (patch)
treed3cfb296cd830b22122d7612c9858bb4611571d2
parente94e87f219ee898172f060081bca47d62f1908a1 (diff)
change ets to cache in mem3
-rw-r--r--include/common.hrl2
-rw-r--r--src/mem3.erl32
2 files changed, 17 insertions, 17 deletions
diff --git a/include/common.hrl b/include/common.hrl
index b5d4d7ec..69a9e749 100644
--- a/include/common.hrl
+++ b/include/common.hrl
@@ -45,6 +45,6 @@
node,
nodes,
clock,
- ets,
+ cache,
args
}).
diff --git a/src/mem3.erl b/src/mem3.erl
index 5de00826..d7a6b979 100644
--- a/src/mem3.erl
+++ b/src/mem3.erl
@@ -89,13 +89,13 @@ state() ->
%% @doc retrieve the primary partition map. This is a list of partitions and
%% their corresponding primary node, no replication partner nodes.
partitions() ->
- ets_pmap().
+ cache_pmap().
%% @doc retrieve the full partition map, like above, but including replication
%% partner nodes. List should number 2^Q * N
fullmap() ->
- lists:keysort(2, ets_fullmap()).
+ lists:keysort(2, cache_fullmap()).
%%====================================================================
@@ -197,11 +197,11 @@ get_config(Args) ->
handle_init(nil) ->
showroom_log:message(info, "membership: membership server starting...", []),
net_kernel:monitor_nodes(true),
- Table = init_ets_table(),
+ Table = init_cache_table(),
Node = node(),
Nodes = [{0, Node, []}],
Clock = vector_clock:create(Node),
- #mem{node=Node, nodes=Nodes, clock=Clock, ets=Table};
+ #mem{node=Node, nodes=Nodes, clock=Clock, cache=Table};
handle_init(_OldState) ->
?debugHere,
@@ -209,14 +209,14 @@ handle_init(_OldState) ->
% but only if we can compare our old state to all other
% available nodes and get a match... otherwise get a human involved
% TODO implement me
- Table = init_ets_table(),
- #mem{ets=Table}.
+ Table = init_cache_table(),
+ #mem{cache=Table}.
%% handle join activities, return NewState
handle_join(first, ExtNodes, #mem{node=Node, clock=Clock} = State, Config) ->
{Pmap, Fullmap} = create_maps(Config, ExtNodes),
- update_ets(Pmap, Fullmap),
+ update_cache(Pmap, Fullmap),
NewClock = vector_clock:increment(Node, Clock),
State#mem{nodes=ExtNodes, clock=NewClock};
@@ -293,28 +293,28 @@ make_fullmap(PMap, Config) ->
NodeParts.
-%% ets table helper functions
-init_ets_table() ->
+%% cache table helper functions
+init_cache_table() ->
Table = list_to_atom(lists:concat(["mem_", atom_to_list(node())])),
ets:new(Table, [public, set, named_table]),
Table.
-ets_name(Node) ->
+cache_name(Node) ->
list_to_atom(lists:concat(["mem_", atom_to_list(Node)])).
-update_ets(Pmap, Fullmap) ->
- Table = ets_name(node()),
+update_cache(Pmap, Fullmap) ->
+ Table = cache_name(node()),
ets:insert(Table, {pmap, Pmap}),
ets:insert(Table, {fullmap, Fullmap}).
-ets_pmap() ->
- [{pmap, PMap}] = ets:lookup(ets_name(node()), pmap),
+cache_pmap() ->
+ [{pmap, PMap}] = ets:lookup(cache_name(node()), pmap),
PMap.
-ets_fullmap() ->
- [{fullmap, FullMap}] = ets:lookup(ets_name(node()), fullmap),
+cache_fullmap() ->
+ [{fullmap, FullMap}] = ets:lookup(cache_name(node()), fullmap),
FullMap.