Skip to content
This repository
Browse code

Rework incompatible into the status field.

This prevents us from having to update the record.
  • Loading branch information...
commit e411568ae9664111640c7c03156ffe46bdc54258 1 parent b5c9881
Christopher Meiklejohn authored May 31, 2012
23  include/riak_control.hrl
@@ -20,7 +20,7 @@
20 20
 
21 21
 -type version()       :: integer().
22 22
 -type index()         :: binary().
23  
--type status()        :: valid | invalid | down | leaving.
  23
+-type status()        :: valid | invalid | down | leaving | incompatible.
24 24
 -type home()          :: primary | fallback | undefined.
25 25
 -type service()       :: atom().
26 26
 -type services()      :: [{service(),home()}].
@@ -38,17 +38,16 @@
38 38
         }).
39 39
 
40 40
 -record(member_info,
41  
-        { node          :: atom(),
42  
-          status        :: status(),
43  
-          reachable     :: boolean(),
44  
-          vnodes        :: [vnode()],
45  
-          handoffs      :: [handoff()],
46  
-          ring_pct      :: float(),
47  
-          pending_pct   :: float(),
48  
-          mem_total     :: integer(),
49  
-          mem_used      :: integer(),
50  
-          mem_erlang    :: integer(),
51  
-          incompatible  :: boolean()
  41
+        { node        :: atom(),
  42
+          status      :: status(),
  43
+          reachable   :: boolean(),
  44
+          vnodes      :: [vnode()],
  45
+          handoffs    :: [handoff()],
  46
+          ring_pct    :: float(),
  47
+          pending_pct :: float(),
  48
+          mem_total   :: integer(),
  49
+          mem_used    :: integer(),
  50
+          mem_erlang  :: integer()
52 51
         }).
53 52
 
54 53
 %% These two should always match, in terms of webmachine dispatcher
8  priv/admin/js/cluster.js
@@ -402,7 +402,7 @@ $(document).ready(function () {
402 402
     function set_memory(node, texts, row) {
403 403
         var memdivider, mem_erlang, mem_non_erlang, mem_free;
404 404
 
405  
-        if (node.reachable === false || node.incompatible === true) {
  405
+        if (node.reachable === false || node.status === 'incompatible') {
406 406
             $('.unknown-mem', row).show();
407 407
             $('.mem-color', row).hide();
408 408
             $('.free-memory', row).text('?? Free');
@@ -434,13 +434,13 @@ $(document).ready(function () {
434 434
         } else {
435 435
             // handle colors and operability
436 436
             if (status === 'valid' && !stopping[texts.name]) {
437  
-                if (node.incompatible == true) {
438  
-                    set_valid_incompatible_status(row, texts);
439  
-                } else if (node.reachable === true) {
  437
+                if (node.reachable === true) {
440 438
                     set_valid_reachable_status(row, texts);
441 439
                 } else {
442 440
                     set_valid_unreachable_status(row, texts);
443 441
                 }
  442
+            } else if (status === 'incompatible') {
  443
+                set_valid_incompatible_status(row, texts);
444 444
             } else if (status === 'leaving') {
445 445
                 set_leaving_status(row, texts);
446 446
             } else if (status === 'down') {
4  priv/admin/js/ring.js
@@ -286,7 +286,7 @@ $(document).ready(function () {
286 286
 
287 287
         function deal_with_lights (obj, row) {
288 288
             var i, kind;
289  
-            if (obj.incompatible == true) { 
  289
+            if (obj.status === 'incompatible') { 
290 290
                 set_operability_class($('.owner', row), 'incompatible');
291 291
             } else if (obj.reachable === true) {
292 292
                 set_operability_class($('.owner', row), 'normal');
@@ -296,7 +296,7 @@ $(document).ready(function () {
296 296
             for (i in obj.vnodes) {
297 297
                 if (Object.prototype.hasOwnProperty.call(obj.vnodes, i)) {
298 298
                     kind = i.split('_')[1];
299  
-                    if (obj.incompatible === true) { 
  299
+                    if (obj.status === 'incompatible') { 
300 300
                         set_light_color($('.' + kind + '-light', row), 'red');
301 301
                         $('.' + kind + '-status', row).html('Unknown');
302 302
                     } else if (obj.reachable === true && (obj.vnodes[i] === 'primary')) {
1  src/admin_cluster.erl
@@ -70,7 +70,6 @@ to_json (Req,C=list) ->
70 70
     Status=[{struct,[{"name",Node#member_info.node},
71 71
                      {"status",Node#member_info.status},
72 72
                      {"reachable",Node#member_info.reachable},
73  
-                     {"incompatible",Node#member_info.incompatible},
74 73
                      {"ring_pct",Node#member_info.ring_pct},
75 74
                      {"pending_pct",Node#member_info.pending_pct},
76 75
                      {"mem_total",Node#member_info.mem_total},
2  src/admin_overview.erl
@@ -75,7 +75,7 @@ get_unreachable_nodes (Nodes,Down) ->
75 75
 %% get a list of all the nodes that are currently incompatible with
76 76
 %% control
77 77
 get_incompatible_nodes (Nodes) ->
78  
-    [Node || #member_info{node=Node,incompatible=true} <- Nodes].
  78
+    [Node || #member_info{node=Node,status=incompatible} <- Nodes].
79 79
 
80 80
 %% get a list of all nodes currently marked down
81 81
 get_down_nodes (Nodes) ->
3  src/admin_ring.erl
@@ -122,13 +122,12 @@ paginate_results (Req,XS) ->
122 122
 %% return a proplist of details for a given index
123 123
 node_ring_details (P=#partition_info{index=Index,vnodes=Vnodes},Nodes) ->
124 124
     case lists:keyfind(P#partition_info.owner,2,Nodes) of
125  
-        #member_info{node=Node,status=Status,reachable=Reachable,incompatible=Incompatible} ->
  125
+        #member_info{node=Node,status=Status,reachable=Reachable} ->
126 126
             [{index,list_to_binary(integer_to_list(Index))},
127 127
              {i,P#partition_info.partition},
128 128
              {node,Node},
129 129
              {status,Status},
130 130
              {reachable,Reachable},
131  
-             {incompatible,Incompatible},
132 131
              {vnodes,Vnodes},
133 132
              {handoffs,{struct,vnode_handoffs(P#partition_info.handoffs)}}
134 133
             ];
22  src/riak_control_session.erl
@@ -248,32 +248,23 @@ get_member_info (_Member={Node,Status},Ring) ->
248 248
                         };
249 249
         {badrpc,_Reason} ->
250 250
             #member_info{ node=Node,
251  
-                          status=Status,
  251
+                          status=incompatible,
252 252
                           reachable=true,
253  
-                          incompatible=true,
254 253
                           vnodes=[],
255 254
                           handoffs=[],
256 255
                           ring_pct=PctRing,
257 256
                           pending_pct=PctPending
258 257
                         };
259  
-        %% upgrade nodes using the previous version of the record, to add
260  
-        %% the incompatible state.
261  
-        Member_info when is_record(Member_info, member_info, 11) ->
262  
-            NewMemberInfo = erlang:append_element(Member_info, false),
263  
-            NewMemberInfo#member_info{ status=Status,
264  
-                                       ring_pct=PctRing,
265  
-                                       pending_pct=PctPending
266  
-                                   };
267  
-        Member_info = #member_info{} ->
  258
+        MemberInfo = #member_info{} ->
268 259
             %% there is a race condition here, when a node is stopped
269 260
             %% gracefully (e.g. `riak stop`) the event will reach us
270 261
             %% before the node is actually down and the rpc call will
271 262
             %% succeed, but since it's shutting down it won't have any
272 263
             %% vnode workers running...
273  
-            Member_info#member_info{ status=Status,
274  
-                                     ring_pct=PctRing,
275  
-                                     pending_pct=PctPending
276  
-                                   }
  264
+            MemberInfo#member_info{ status=Status,
  265
+                                    ring_pct=PctRing,
  266
+                                    pending_pct=PctPending
  267
+                                  }
277 268
     end.
278 269
 
279 270
 %% run locally per-node, collects information about this node for the session
@@ -284,7 +275,6 @@ get_my_info () ->
284 275
     %% construct the member information for this node
285 276
     #member_info{ node=node(),
286 277
                   reachable=true,
287  
-                  incompatible=false,
288 278
                   mem_total=Total,
289 279
                   mem_used=Used,
290 280
                   mem_erlang=proplists:get_value(total,erlang:memory()),

0 notes on commit e411568

Please sign in to comment.
Something went wrong with that request. Please try again.