YUKI Hiroshi
null+****@clear*****
Fri Oct 31 19:20:51 JST 2014
YUKI Hiroshi 2014-10-31 19:20:51 +0900 (Fri, 31 Oct 2014) New Revision: 1d7bf864783e146c31dd29cd4f76fedabc18f802 https://github.com/droonga/express-droonga/commit/1d7bf864783e146c31dd29cd4f76fedabc18f802 Message: Add a method to get live host hosts by command Modified files: lib/droonga-protocol/connection-pool.js Modified: lib/droonga-protocol/connection-pool.js (+30 -0) =================================================================== --- lib/droonga-protocol/connection-pool.js 2014-10-31 19:08:34 +0900 (6336209) +++ lib/droonga-protocol/connection-pool.js 2014-10-31 19:20:51 +0900 (6c3386f) @@ -9,6 +9,8 @@ * }); */ +var path = require('path'); + var Connection = require('./connection').Connection; var ConsoleLogger = require('../console-logger').ConsoleLogger; var Catalog = require('../catalog').Catalog; @@ -133,6 +135,34 @@ ConnectionPool.prototype = { } var catalog = result.response.body; return new Catalog(catalog); + }, + + getHostNamesFromCluster: function() { + return Q.Promise((function(resolve, reject, notify) { + // 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 commandLine = [ + commandPath, + '--droonga-engine-host-name=' + this._hostNames[0], + '--droonga-engine-port=' + this._params.port, + '--tag=' + this._params.tag + ].join(' '); + exec(commandLine, function(error, stdin, stdout) { + if (!error) + return reject(error); + resolve(stdin.trim().split('\n')); + }); + }).bind(this)); + }, + + updateHostNamesFromCluster: function() { + return this.getHostNamesFromCluster() + .then((function(hostNames) { + this.hostNames = hostNames; + return hostNames; + }).bind(this)); } }; -------------- next part -------------- HTML����������������������������...Descargar