Skip to content

Commit

Permalink
Do not use fixed port number
Browse files Browse the repository at this point in the history
Modify RiakConnection so that health check command is executed the same way as other commands.

Implement socket timeout, default of 5 seconds. Ensure correct events are raised on timeout.

Fix issues in socket timeout, improve logging

Add RiakCluster test to demonstrate handling of read timeouts.

Make data buffer private in RiakConnection

Make expiration routine private in RiakNode

add backoff to shutdown

Remove use of linkedlist module due to this bug: kilianc/node-linkedlist#1

Standardize on "health check" verbiage in logging, improve RiakNode state management, make _stateCheck functions protected

clarify debug log message

Fix connection count
  • Loading branch information
Luke Bakken committed Mar 17, 2016
1 parent 45eeb3c commit 94e4c83
Show file tree
Hide file tree
Showing 9 changed files with 753 additions and 428 deletions.
19 changes: 9 additions & 10 deletions lib/core/riakcluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
var async = require('async');
var events = require('events');
var Joi = require('joi');
var LinkedList = require('linkedlist');
var logger = require('winston');
var util = require('util');

Expand Down Expand Up @@ -73,7 +72,13 @@ function RiakCluster(options) {
self.queueSubmitInterval = options.queueSubmitInterval;
});

this._commandQueue = new LinkedList();
this._commandQueue = [];

this._stateCheck = function(allowedStates) {
if (allowedStates.indexOf(this.state) === -1) {
throw new Error('RiakCluster: Illegal State; required: ' + allowedStates + ' current: ' + this.state);
}
};
}

util.inherits(RiakCluster, events.EventEmitter);
Expand Down Expand Up @@ -353,21 +358,15 @@ RiakCluster.prototype._onRetryCommand = function(command, lastNode) {
var i = this.executionAttempts - command.remainingTries;
// NB: only "immediately" re-try if there's another node on which to re-try
if ((this.nodes.length > 1) && (i === 0 || i === 1)) {
logger.debug('[RiakCluster] scheduling immediate re-try for: ', command.name);
logger.debug('[RiakCluster] scheduling immediate re-try for:', command.name);
setImmediate(this.execute.bind(this, command, lastNode));
} else {
var delay_ms = 100 * i;
logger.debug('[RiakCluster] scheduling re-try with %d ms delay for: ', delay_ms, command.name);
logger.debug('[RiakCluster] scheduling re-try with %d ms delay for:', delay_ms, command.name);
setTimeout(this.execute.bind(this, command, lastNode), delay_ms);
}
};

RiakCluster.prototype._stateCheck = function(allowedStates) {
if (allowedStates.indexOf(this.state) === -1) {
throw new Error('RiakCluster: Illegal State; required: ' + allowedStates + ' current: ' + this.state);
}
};

/**
* The state of this cluster.
*
Expand Down
Loading

0 comments on commit 94e4c83

Please sign in to comment.