Skip to content
This repository was archived by the owner on Sep 25, 2020. It is now read-only.

Commit 31f615c

Browse files
committed
Merge pull request #23 from uber/ws-show-more-state-of-partition
add # of alive, suspect and faulty to partitions.js
2 parents 5c934c5 + 5381178 commit 31f615c

File tree

6 files changed

+27
-7
lines changed

6 files changed

+27
-7
lines changed

lib/cluster.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
var fs = require('fs');
2323

24+
var _ = require('underscore');
2425
var async = require('async');
2526
var AdminClient = require('./admin-client.js');
2627
var Partition = require('./partition.js');
@@ -231,6 +232,11 @@ Cluster.prototype.parseStats = function parseStats(stats) {
231232
cluster.membershipChecksum = stats.membershipChecksum;
232233
cluster.membership = stats.members;
233234

235+
var membersByStatus = _.groupBy(stats.members, 'status');
236+
cluster.aliveCount = _.size(membersByStatus.alive);
237+
cluster.suspectCount = _.size(membersByStatus.suspect);
238+
cluster.faultyCount = _.size(membersByStatus.faulty);
239+
234240
this.partitions[cluster.membershipChecksum] = cluster;
235241
}
236242

lib/partition.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ function Partition() {
2424
this.membership = null;
2525
this.nodes = [];
2626
this.nodeCount = 0;
27+
this.aliveCount = 0;
28+
this.suspectCount = 0;
29+
this.faultyCount = 0;
2730
}
2831

2932
Partition.prototype.addNode = function addNode(node) {

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
"cli-table": "^0.3.1",
3232
"commander": "^2.6.0",
3333
"ringpop": "^10.0.0",
34-
"tchannel": "2.7.4"
34+
"tchannel": "2.7.4",
35+
"underscore": "^1.8.3"
3536
},
3637
"devDependencies": {
3738
"cli-color": "^0.3.3",

partitions.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,23 @@ function main() {
4545
headers = [
4646
'Checksum',
4747
'# Nodes',
48+
'# Alive',
49+
'# Suspect',
50+
'# Faulty',
4851
'Sample Host'
4952
];
5053
}
5154

5255
var table = createTable(headers);
5356
partitions.forEach(function each(partition) {
54-
table.push([partition.membershipChecksum, partition.nodeCount, String(partition.nodes[0])]);
57+
table.push([
58+
partition.membershipChecksum,
59+
partition.nodeCount,
60+
partition.aliveCount,
61+
partition.suspectCount,
62+
partition.faultyCount,
63+
String(partition.nodes[0])
64+
]);
5565
});
5666
console.log(table.toString());
5767
process.exit();

tests/checksum.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Invalid bootstrap file
2020

2121
$ ringpop-admin checksums QWERTY
2222

23-
assert.js:93
23+
assert.js:* (glob)
2424
throw new assert.AssertionError({
2525
^
2626
AssertionError: invalid destination

tests/partitions.t

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
Partitions command success:
22

33
$ ringpop-admin partitions 127.0.0.1:3000
4-
Checksum # Nodes Sample Host* (glob)
5-
* 5 127.0.0.1:3000* (glob)
4+
Checksum*# Nodes*# Alive*# Suspect*# Faulty*Sample Host* (glob)
5+
*5*5*0*0*127.0.0.1:3000* (glob)
66

77

88
With bootstrap file:
99

1010
$ ringpop-admin partitions $TESTDIR/hosts.json
11-
Checksum # Nodes Sample Host* (glob)
12-
* 5 127.0.0.1:* (glob)
11+
Checksum*# Nodes*# Alive*# Suspect*# Faulty*Sample Host* (glob)
12+
*5*5*0*0*127.0.0.1:* (glob)
1313

1414

1515
Unable to connect to host:

0 commit comments

Comments
 (0)