YUKI Hiroshi
null+****@clear*****
Wed Nov 19 16:37:17 JST 2014
YUKI Hiroshi 2014-11-19 16:37:17 +0900 (Wed, 19 Nov 2014) New Revision: 883b44bde883a7fbce6a6e77c37e175e0fd8cec8 https://github.com/droonga/express-droonga/commit/883b44bde883a7fbce6a6e77c37e175e0fd8cec8 Message: Try to get the list of active engine nodes from all given engine hosts Modified files: lib/droonga-protocol/connection-pool.js Modified: lib/droonga-protocol/connection-pool.js (+27 -4) =================================================================== --- lib/droonga-protocol/connection-pool.js 2014-11-07 14:08:55 +0900 (30969a3) +++ lib/droonga-protocol/connection-pool.js 2014-11-19 16:37:17 +0900 (120f822) @@ -108,15 +108,38 @@ ConnectionPool.prototype = { return this._hostNames.length; }, - getHostNamesFromCluster: function() { + getHostNamesFromCluster: function(retryCount) { + if (this._watching) + return this.getHostNamesFromClusterMember(this._serf.rpcAddress); + + retryCount = retryCount || 0; + var hostName = this._hostNames[retryCount]; + if (!hostName) + return Q.Promise((function(resolve, reject, notify) { + var error = new Error('all cluster members are unaccessible.'); + this._logger.error(error); + reject(error); + }).bind(this)); + + return this.getHostNamesFromClusterMember(hostName) + .then(function(hostNames) { + return hostNames; + }) + .catch((function(error) { + this._logger.error('Failed to get the list of droonga-engine hosts from the cluster member ' + hostName + '.'); + this._logger.error(error); + return this.getHostNamesFromCluster(retryCount + 1); + }).bind(this)); + }, + getHostNamesFromClusterMember: function(rpcAddress) { return Q.Promise((function(resolve, reject, notify) { + if (!rpcAddress) + reject(new Error('no RPC address is given')); + // Because node-rpc has no API to disconnect from the RPC host, // we should use it in a separate expendable process. var commandPath = path.join(__dirname, '..', '..', 'bin', 'express-droonga-report-live-engine-hosts'); - var rpcAddress = this._hostNames[0]; - if (this._watching) - rpcAddress = this._serf.rpcAddress; var commandLine = [ commandPath, '--rpc-address=' + rpcAddress, -------------- next part -------------- HTML����������������������������... 下載