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

Commit 76f8979

Browse files
committed
Merge pull request #24 from uber/ws-remove-bloated-error-output
remove the printing of connection errors. Errors are expected because…
2 parents 61ae6da + ef349f3 commit 76f8979

File tree

11 files changed

+26
-31
lines changed

11 files changed

+26
-31
lines changed

checksums.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ function main() {
5252
var checksums = reduceStatsToChecksums(clusterManager.allStats);
5353
var checksumsTable = createChecksumsTable(checksums);
5454
console.log(checksumsTable.toString());
55+
56+
clusterManager.printConnectionErrorMsg();
5557
process.exit();
5658
});
5759
}

count.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ function main() {
5959
var partitionCount = clusterManager.getPartitionCount();
6060
if (program.partitions) {
6161
console.log(partitionCount);
62+
clusterManager.printConnectionErrorMsg();
6263
process.exit(0);
6364
}
6465

@@ -76,11 +77,13 @@ function main() {
7677

7778
if (program.members) {
7879
console.log(cluster.getNodeCount());
80+
clusterManager.printConnectionErrorMsg();
7981
process.exit();
8082
}
8183

8284
if (program.hosts) {
8385
console.log(cluster.getHostCount());
86+
clusterManager.printConnectionErrorMsg();
8487
process.exit();
8588
}
8689
});

dump.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ function main() {
7373
process.exit(1);
7474
}
7575

76+
clusterManager.printConnectionErrorMsg();
7677
process.exit();
7778
}
7879
}

lib/cluster.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ function Cluster(opts) {
4747
this.lastDownloadTime = null;
4848
this.lastFetchTime = null;
4949
this.dumpTo = opts.dumpTo;
50+
this.connectionErrorCount = 0;
5051
}
5152

5253
Cluster.prototype.getPartitionAt = function getPartitionAt(index) {
@@ -90,14 +91,21 @@ Cluster.prototype.getSeedList = function getSeedList(callback) {
9091
discover(this.discoveryUri, callback);
9192
};
9293

94+
Cluster.prototype.printConnectionErrorMsg = function printConnectionErrorMsg() {
95+
var count = this.connectionErrorCount;
96+
if (count > 0) {
97+
console.error('Failed to connect to %d nodes.', count);
98+
}
99+
};
100+
93101
Cluster.prototype.fetchStats = function fetchStats(callback) {
94102
var self = this;
95103

96104
// Reset with every fetch
97105
this.partitions = {};
98-
99106
this.lastFetchTime = new Date().toISOString();
100107
var downloadTime = Date.now();
108+
this.connectionErrorCount = 0;
101109

102110
var foundMembers = {};
103111
var allStats = [];
@@ -191,7 +199,7 @@ Cluster.prototype.fetchStats = function fetchStats(callback) {
191199
foundMembers[memberAddr] = true;
192200
fetchQueue.push(memberAddr, function onStatsFetched(err, stats) {
193201
if (err) {
194-
console.error('Error while fetching node stats:', err);
202+
self.connectionErrorCount++;
195203
return;
196204
}
197205

list.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,13 @@ function main() {
6969

7070
if (program.members) {
7171
printSorted(cluster.getMemberAddrs());
72+
clusterManager.printConnectionErrorMsg();
7273
process.exit();
7374
}
7475

7576
if (program.hosts) {
7677
printSorted(cluster.getHostAddrs());
78+
clusterManager.printConnectionErrorMsg();
7779
process.exit();
7880
}
7981
});

lookup.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ function main() {
6060
}
6161

6262
console.log(res.dest);
63+
clusterManager.printConnectionErrorMsg();
6364
process.exit();
6465
});
6566
}

partitions.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ function main() {
6464
]);
6565
});
6666
console.log(table.toString());
67+
68+
clusterManager.printConnectionErrorMsg();
6769
process.exit();
6870
});
6971
}

status.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ function main() {
7878
getDampScoreRange(cluster.allStats, member)]);
7979
});
8080
});
81+
cluster.printConnectionErrorMsg();
8182
process.exit();
8283
});
8384
}

tests/count.t

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ Test count success:
22

33
$ ringpop-admin count -m 127.0.0.1:3000
44
5
5+
56
$ ringpop-admin count -h 127.0.0.1:3000
67
1
8+
79
$ ringpop-admin count -p 127.0.0.1:3000
810
1
911

tests/list.t

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ Test list command success:
22

33
$ ringpop-admin list -h 127.0.0.1:3000
44
127.0.0.1
5+
56
$ ringpop-admin list -m 127.0.0.1:3000
67
127.0.0.1:3000
78
127.0.0.1:3001
@@ -29,4 +30,4 @@ With bootstrap file:
2930
127.0.0.1:3001
3031
127.0.0.1:3002
3132
127.0.0.1:3003
32-
127.0.0.1:3004
33+
127.0.0.1:3004

0 commit comments

Comments
 (0)