You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2014/08/21 10:53:08 UTC

fabric commit: updated refs/heads/windsor-merge to c3b2860

Repository: couchdb-fabric
Updated Branches:
  refs/heads/windsor-merge 7247b7e8f -> c3b2860ca (forced update)


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/c3b2860c
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/tree/c3b2860c
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/diff/c3b2860c

Branch: refs/heads/windsor-merge
Commit: c3b2860ca686db414536a0f0d2502f2b9091b443
Parents: 263afe5
Author: Paul J. Davis <pa...@gmail.com>
Authored: Thu Aug 21 01:22:16 2014 -0500
Committer: Paul J. Davis <pa...@gmail.com>
Committed: Thu Aug 21 03:53:00 2014 -0500

----------------------------------------------------------------------
 priv/stats_descriptions.cfg  | 20 ++++++++++++++++++++
 src/fabric.app.src           |  3 ++-
 src/fabric_doc_open.erl      |  9 ++++++---
 src/fabric_doc_open_revs.erl | 15 ++++++++++-----
 src/fabric_doc_update.erl    | 16 ++++++++++++++--
 5 files changed, 52 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-fabric/blob/c3b2860c/priv/stats_descriptions.cfg
----------------------------------------------------------------------
diff --git a/priv/stats_descriptions.cfg b/priv/stats_descriptions.cfg
new file mode 100644
index 0000000..a65263c
--- /dev/null
+++ b/priv/stats_descriptions.cfg
@@ -0,0 +1,20 @@
+{[fabric, read_repairs, success], [
+    {type, counter},
+    {desc, <<"number of successful read repair operations">>}
+]}.
+{[fabric, read_repairs, failure], [
+    {type, counter},
+    {desc, <<"number of failed read repair operations">>}
+]}.
+{[fabric, doc_update, errors], [
+    {type, counter},
+    {desc, <<"number of document update errors">>}
+]}.
+{[fabric, doc_update, mismatched_errors], [
+    {type, counter},
+    {desc, <<"number of document update errors with multiple error types">>}
+]}.
+{[fabric, doc_update, write_quorum_errors], [
+    {type, counter},
+    {desc, <<"number of write quorum errors">>}
+]}.

http://git-wip-us.apache.org/repos/asf/couchdb-fabric/blob/c3b2860c/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/c3b2860c/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/c3b2860c/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/c3b2860c/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">>]}},