couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject fabric commit: updated refs/heads/2001-feature-external-size to c68ffdc
Date Tue, 11 Feb 2014 07:22:07 GMT
Updated Branches:
  refs/heads/2001-feature-external-size [created] c68ffdcfd


Add cluster support for new size calculations

This adds the cluster aggregation of database and view size information.
Now that we have three values they're nested under a single "sizes" key.

COUCHDB-2001


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

Branch: refs/heads/2001-feature-external-size
Commit: c68ffdcfd395badc752cadd1eabb3c693e50d0af
Parents: 5518fea
Author: Paul J. Davis <paul.joseph.davis@gmail.com>
Authored: Tue Feb 11 01:21:07 2014 -0600
Committer: Paul J. Davis <paul.joseph.davis@gmail.com>
Committed: Tue Feb 11 01:21:07 2014 -0600

----------------------------------------------------------------------
 src/fabric_db_info.erl    |  2 ++
 src/fabric_group_info.erl |  2 ++
 src/fabric_util.erl       | 23 +++++++++++++++++++++++
 3 files changed, 27 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-fabric/blob/c68ffdcf/src/fabric_db_info.erl
----------------------------------------------------------------------
diff --git a/src/fabric_db_info.erl b/src/fabric_db_info.erl
index 58139e8..24fc44d 100644
--- a/src/fabric_db_info.erl
+++ b/src/fabric_db_info.erl
@@ -84,6 +84,8 @@ merge_results(Info) ->
             [{disk_size, lists:sum(X)} | Acc];
         (other, X, Acc) ->
             [{other, {merge_other_results(X)}} | Acc];
+        (sizes, X, Acc) ->
+            [{sizes, {fabric_util:merge_size_objects(X)}} | Acc];
         (disk_format_version, X, Acc) ->
             [{disk_format_version, lists:max(X)} | Acc];
         (_, _, Acc) ->

http://git-wip-us.apache.org/repos/asf/couchdb-fabric/blob/c68ffdcf/src/fabric_group_info.erl
----------------------------------------------------------------------
diff --git a/src/fabric_group_info.erl b/src/fabric_group_info.erl
index 135090f..5da94fd 100644
--- a/src/fabric_group_info.erl
+++ b/src/fabric_group_info.erl
@@ -81,6 +81,8 @@ merge_results(Info) ->
             [{disk_size, lists:sum(X)} | Acc];
         (data_size, X, Acc) ->
             [{data_size, lists:sum(X)} | Acc];
+        (sizes, X, Acc) ->
+            [{sizes, {fabric_util:merge_size_objects(X)}} | Acc];
         (compact_running, X, Acc) ->
             [{compact_running, lists:member(true, X)} | Acc];
         (updater_running, X, Acc) ->

http://git-wip-us.apache.org/repos/asf/couchdb-fabric/blob/c68ffdcf/src/fabric_util.erl
----------------------------------------------------------------------
diff --git a/src/fabric_util.erl b/src/fabric_util.erl
index a6982f3..e58a321 100644
--- a/src/fabric_util.erl
+++ b/src/fabric_util.erl
@@ -16,6 +16,7 @@
         update_counter/3, remove_ancestors/2, create_monitors/1, kv/2,
         remove_down_workers/2]).
 -export([request_timeout/0]).
+-export([merge_size_objects/1]).
 
 -include_lib("fabric/include/fabric.hrl").
 -include_lib("mem3/include/mem3.hrl").
@@ -141,6 +142,28 @@ create_monitors(Shards) ->
     MonRefs = lists:usort([{rexi_server, N} || #shard{node=N} <- Shards]),
     rexi_monitor:start(MonRefs).
 
+% This is used to merge the new size objects found in database
+% and view info blobs for clustered calls.
+merge_size_objects(SizeObjects) ->
+    Dict = lists:foldl(fun({Props}, D) ->
+        lists:foldl(fun({K, V}, D0) ->
+            orddict:append(K, V, D0)
+        end, D, Props)
+    end, orddict:new(), SizeObjects),
+    orddict:fold(fun
+        (file, X, Acc) ->
+            [{file, lists:sum(X)} | Acc];
+        (active, X, Acc) ->
+            case lists:member(null, X) of
+                true ->
+                    [{active, null} | Acc];
+                false ->
+                    [{active, lists:sum(X)} | Acc]
+            end;
+        (external, X, Acc) ->
+            [{external, lists:sum(X)} | Acc]
+    end, [], Dict).
+
 %% verify only id and rev are used in key.
 update_counter_test() ->
     Reply = {ok, #doc{id = <<"id">>, revs = <<"rev">>,


Mime
View raw message