couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject [42/48] mem3 commit: updated refs/heads/windsor-merge to ff02b9a
Date Fri, 01 Aug 2014 09:11:28 GMT
Write plan to /tmp/rebalance_plan.txt

Was a request by @mattwhite to help with automation.  I was fairly
sloppy in the implementation here, could leave this off and do a better
job next time.


Project: http://git-wip-us.apache.org/repos/asf/couchdb-mem3/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-mem3/commit/e147621c
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-mem3/tree/e147621c
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-mem3/diff/e147621c

Branch: refs/heads/windsor-merge
Commit: e147621ce9b4703228fc548280503a64eb65750b
Parents: c63fc05
Author: Adam Kocoloski <adam@cloudant.com>
Authored: Thu Oct 31 12:23:49 2013 -0400
Committer: Robert Newson <rnewson@apache.org>
Committed: Wed Jul 23 18:51:01 2014 +0100

----------------------------------------------------------------------
 src/mem3_rebalance.erl | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-mem3/blob/e147621c/src/mem3_rebalance.erl
----------------------------------------------------------------------
diff --git a/src/mem3_rebalance.erl b/src/mem3_rebalance.erl
index d85e8c2..54dcd1c 100644
--- a/src/mem3_rebalance.erl
+++ b/src/mem3_rebalance.erl
@@ -51,10 +51,14 @@ expand() ->
 %% @doc Expands a cluster without requiring each DB to be optimally balanced.
 -spec expand(integer() | global) -> [{atom(), #shard{}, node()}].
 expand(global) ->
+    {ok, FD} = file:open("/tmp/rebalance_plan.txt", [write]),
+    erlang:put(fd, FD),
     global_expand(surviving_nodes(), [], 1000);
 
 %% @doc Expands all databases in the cluster, stopping at Limit operations.
 expand(Limit) when is_integer(Limit), Limit > 0 ->
+    {ok, FD} = file:open("/tmp/rebalance_plan.txt", [write]),
+    erlang:put(fd, FD),
     TargetNodes = surviving_nodes(),
     LocalBalanceFun = fun(Db, Moves) -> expand(Db, TargetNodes, Moves) end,
     LocalBalanceOps = apply_to_cluster(LocalBalanceFun, Limit),
@@ -85,6 +89,8 @@ contract() ->
 %% @doc Computes a plan to remove up to Limit shards from nodes in "decom" zone.
 -spec contract(integer()) -> [{atom(), #shard{}, node()}].
 contract(Limit) when is_integer(Limit), Limit > 0 ->
+    {ok, FD} = file:open("/tmp/rebalance_plan.txt", [write]),
+    erlang:put(fd, FD),
     TargetNodes = surviving_nodes(),
     apply_to_cluster(fun(Db, Moves) -> contract(Db, TargetNodes, Moves) end, Limit);
 
@@ -111,6 +117,8 @@ fix_zoning() ->
 %%      levels and improper zoning.
 -spec fix_zoning(integer()) -> [{atom(), #shard{}, node()}].
 fix_zoning(Limit) when is_integer(Limit), Limit > 0 ->
+    {ok, FD} = file:open("/tmp/rebalance_plan.txt", [write]),
+    erlang:put(fd, FD),
     apply_to_cluster(fun fix_zoning/2, Limit);
 
 fix_zoning(DbName) when is_binary(DbName); is_list(DbName) ->
@@ -485,8 +493,14 @@ print({Op, Shard, TargetNode} = Operation) ->
         [{capture, all_but_first, binary}]
     ),
     OpName = case Op of move -> move2; _ -> Op end,
-    io:format("clou shard ~s ~s ~s ~s ~s ~s ~s~n", [OpName, Cluster, Account, DbName,
-         Range, SourceId, TargetId]),
+    case get(fd) of
+        undefined ->
+            io:format("clou shard ~s ~s ~s ~s ~s ~s ~s~n", [OpName,
+                 Cluster, Account, DbName, Range, SourceId, TargetId]);
+        FD ->
+            io:format(FD, "clou shard ~s ~s ~s ~s ~s ~s ~s~n", [OpName,
+                 Cluster, Account, DbName, Range, SourceId, TargetId])
+    end,
     Operation;
 
 print(Operations) when is_list(Operations) ->


Mime
View raw message