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/windsor-merge to 7247b7e
Date Thu, 21 Aug 2014 06:22:28 GMT
Repository: couchdb-fabric
Updated Branches:
  refs/heads/windsor-merge 263afe567 -> 7247b7e8f


Update fabric to use couch_stats


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

Branch: refs/heads/windsor-merge
Commit: 7247b7e8f94e793c7cccce80861c1a19bd0003a8
Parents: 263afe5
Author: Paul J. Davis <paul.joseph.davis@gmail.com>
Authored: Thu Aug 21 01:22:16 2014 -0500
Committer: Paul J. Davis <paul.joseph.davis@gmail.com>
Committed: Thu Aug 21 01:22:16 2014 -0500

----------------------------------------------------------------------
 src/fabric.app.src           |  3 ++-
 src/fabric_doc_open.erl      |  9 ++++++---
 src/fabric_doc_open_revs.erl | 15 ++++++++++-----
 src/fabric_doc_update.erl    | 16 ++++++++++++++--
 4 files changed, 32 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-fabric/blob/7247b7e8/src/fabric.app.src
----------------------------------------------------------------------
diff --git a/src/fabric.app.src b/src/fabric.app.src
index f18fcc3..3c6a280 100644
--- a/src/fabric.app.src
+++ b/src/fabric.app.src
@@ -44,6 +44,7 @@
         couch,
         rexi,
         mem3,
-        couch_log
+        couch_log,
+        couch_stats
     ]}
 ]}.

http://git-wip-us.apache.org/repos/asf/couchdb-fabric/blob/7247b7e8/src/fabric_doc_open.erl
----------------------------------------------------------------------
diff --git a/src/fabric_doc_open.erl b/src/fabric_doc_open.erl
index 1805c80..ce9e5ff 100644
--- a/src/fabric_doc_open.erl
+++ b/src/fabric_doc_open.erl
@@ -125,8 +125,9 @@ read_repair(#acc{dbname=DbName, replies=Replies}) ->
         Res = fabric:update_docs(DbName, Docs, Opts),
         case Res of
             {ok, []} ->
-                ok;
+                couch_stats:increment_counter([fabric, read_repairs, success]);
             _ ->
+                couch_stats:increment_counter([fabric, read_repairs, failure]),
                 couch_log:notice("read_repair ~s ~s ~p", [DbName, Id, Res])
         end,
         choose_reply(Docs);
@@ -388,6 +389,7 @@ handle_message_reply_test() ->
 read_repair_test() ->
     start_meck_(),
     meck:expect(couch_log, notice, fun(_, _) -> ok end),
+    meck:expect(couch_stats, increment_counter, fun(_) -> ok end),
 
     Foo1 = {ok, #doc{revs = {1,[<<"foo">>]}}},
     Foo2 = {ok, #doc{revs = {2,[<<"foo2">>,<<"foo">>]}}},
@@ -427,6 +429,7 @@ handle_response_quorum_met_test() ->
     start_meck_(),
     meck:expect(couch_log, notice, fun(_, _) -> ok end),
     meck:expect(fabric, update_docs, fun(_, _, _) -> {ok, []} end),
+    meck:expect(couch_stats, increment_counter, fun(_) -> ok end),
 
     Foo1 = {ok, #doc{revs = {1,[<<"foo">>]}}},
     Foo2 = {ok, #doc{revs = {2,[<<"foo2">>,<<"foo">>]}}},
@@ -472,7 +475,7 @@ handle_response_quorum_met_test() ->
 
 
 start_meck_() ->
-    meck:new([couch_log, rexi, fabric]).
+    meck:new([couch_log, rexi, fabric, couch_stats]).
 
 stop_meck_() ->
-    meck:unload([couch_log, rexi, fabric]).
+    meck:unload([couch_log, rexi, fabric, couch_stats]).

http://git-wip-us.apache.org/repos/asf/couchdb-fabric/blob/7247b7e8/src/fabric_doc_open_revs.erl
----------------------------------------------------------------------
diff --git a/src/fabric_doc_open_revs.erl b/src/fabric_doc_open_revs.erl
index b24924d..4fc7cd5 100644
--- a/src/fabric_doc_open_revs.erl
+++ b/src/fabric_doc_open_revs.erl
@@ -172,8 +172,9 @@ maybe_execute_read_repair(Db, Docs) ->
     Res = fabric:update_docs(Db, Docs, [replicated_changes, {user_ctx,Ctx}]),
     case Res of
         {ok, []} ->
-            ok;
+            couch_stats:increment_counter([fabric, read_repairs, success]);
         _ ->
+            couch_stats:increment_counter([fabric, read_repairs, failure]),
             couch_log:notice("read_repair ~s ~s ~p", [Db, Id, Res])
     end.
 
@@ -194,8 +195,10 @@ unstrip_not_found_missing([Else | Rest]) ->
 
 all_revs_test() ->
     config:start_link([]),
-    meck:new(fabric),
+    meck:new([fabric, couch_stats]),
     meck:expect(fabric, update_docs, fun(_, _, _) -> {ok, nil} end),
+    meck:expect(couch_stats, increment_counter, fun(_) -> ok end),
+
     State0 = #state{worker_count = 3, workers=[nil,nil,nil], r = 2, revs = all},
     Foo1 = {ok, #doc{revs = {1, [<<"foo">>]}}},
     Foo2 = {ok, #doc{revs = {2, [<<"foo2">>, <<"foo">>]}}},
@@ -239,13 +242,15 @@ all_revs_test() ->
         {stop, [Bar1, Foo1]},
         handle_message({ok, [Bar1]}, nil, State2)
       ),
-    meck:unload(fabric),
+    meck:unload([fabric, couch_stats]),
     config:stop().
 
 specific_revs_test() ->
     config:start_link([]),
-    meck:new(fabric),
+    meck:new([fabric, couch_stats]),
     meck:expect(fabric, update_docs, fun(_, _, _) -> {ok, nil} end),
+    meck:expect(couch_stats, increment_counter, fun(_) -> ok end),
+
     Revs = [{1,<<"foo">>}, {1,<<"bar">>}, {1,<<"baz">>}],
     State0 = #state{
         worker_count = 3,
@@ -307,5 +312,5 @@ specific_revs_test() ->
         {stop, [Foo2, Bar1, Baz2]},
         handle_message({ok, [Foo2, Bar1, Baz2]}, nil, State2L)
       ),
-    meck:unload(fabric),
+    meck:unload([fabric, couch_stats]),
     config:stop().

http://git-wip-us.apache.org/repos/asf/couchdb-fabric/blob/7247b7e8/src/fabric_doc_update.erl
----------------------------------------------------------------------
diff --git a/src/fabric_doc_update.erl b/src/fabric_doc_update.erl
index da8eeed..3c1d068 100644
--- a/src/fabric_doc_update.erl
+++ b/src/fabric_doc_update.erl
@@ -120,8 +120,12 @@ force_reply(Doc, [FirstReply|_] = Replies, {Health, W, Acc}) ->
             % check if all errors are identical, if so inherit health
             case lists:all(fun(E) -> E =:= FirstReply end, Replies) of
             true ->
+                CounterKey = [fabric, doc_update, errors],
+                couch_stats:increment_counter(CounterKey),
                 {Health, W, [{Doc, FirstReply} | Acc]};
             false ->
+                CounterKey = [fabric, doc_update, mismatched_errors],
+                couch_stats:increment_counter(CounterKey),
                 {error, W, [{Doc, FirstReply} | Acc]}
             end;
         [AcceptedRev | _] ->
@@ -196,6 +200,9 @@ validate_atomic_update(_DbName, AllDocs, true) ->
 
 % eunits
 doc_update1_test() ->
+    meck:new(couch_stats),
+    meck:expect(couch_stats, incrememnt_counter, fun(_) -> ok end),
+
     Doc1 = #doc{revs = {1,[<<"foo">>]}},
     Doc2 = #doc{revs = {1,[<<"bar">>]}},
     Docs = [Doc1],
@@ -264,10 +271,14 @@ doc_update1_test() ->
     ?assertEqual(
         {error, [{Doc1,{accepted,"A"}},{Doc2,{error,internal_server_error}}]},
         ReplyW5
-    ).
+    ),
+    meck:unload(couch_stats).
 
 
 doc_update2_test() ->
+    meck:new(couch_stats),
+    meck:expect(couch_stats, increment_counter, fun(_) -> ok end),
+
     Doc1 = #doc{revs = {1,[<<"foo">>]}},
     Doc2 = #doc{revs = {1,[<<"bar">>]}},
     Docs = [Doc2, Doc1],
@@ -289,7 +300,8 @@ doc_update2_test() ->
         handle_message({rexi_EXIT, 1},lists:nth(3,Shards),Acc2),
 
     ?assertEqual({accepted, [{Doc1,{accepted,Doc2}}, {Doc2,{accepted,Doc1}}]},
-        Reply).
+        Reply),
+    meck:unload(couch_stats).
 
 doc_update3_test() ->
     Doc1 = #doc{revs = {1,[<<"foo">>]}},


Mime
View raw message