[Groonga-commit] droonga/express-droonga at 65cd771 [master] Allow to specify RPC port number of the self-hosting Serf agent

Back to archive index

YUKI Hiroshi null+****@clear*****
Wed Nov 5 12:46:56 JST 2014


YUKI Hiroshi	2014-11-05 12:46:56 +0900 (Wed, 05 Nov 2014)

  New Revision: 65cd7713e775c45af5100ab2264deea3a0fbbd57
  https://github.com/droonga/express-droonga/commit/65cd7713e775c45af5100ab2264deea3a0fbbd57

  Message:
    Allow to specify RPC port number of the self-hosting Serf agent

  Modified files:
    lib/droonga-protocol/connection-pool.js
    lib/serf/agent.js

  Modified: lib/droonga-protocol/connection-pool.js (+6 -6)
===================================================================
--- lib/droonga-protocol/connection-pool.js    2014-11-05 12:23:47 +0900 (1e13cd6)
+++ lib/droonga-protocol/connection-pool.js    2014-11-05 12:46:56 +0900 (8ca6551)
@@ -149,12 +149,12 @@ ConnectionPool.prototype = {
       // we should use it in a separate expendable process.
       var commandPath = path.join(__dirname, '..', '..', 'bin',
                           'express-droonga-report-live-engine-hosts');
-      var hostName = this._hostNames[0];
+      var rpcAddress = this._hostNames[0];
       if (this._watching)
-        hostName = this._params.receiveHostName;
+        rpcAddress = this._serf.rpcAddress;
       var commandLine = [
         commandPath,
-          '--rpc-host-name=' + hostName,
+          '--rpc-address=' + hostName,
           '--droonga-engine-port=' + this._params.port,
           '--tag=' + this._params.tag
       ].join(' ');
@@ -178,9 +178,9 @@ ConnectionPool.prototype = {
     if (this._watching)
       return;
     this._serf = new SerfAgent({
-      serf:           this._params.serf,
-      hostName:       this._params.receiveHostName,
-      otherHostNames: this.hostNames
+      serf:         this._params.serf,
+      hostName:     this._params.receiveHostName,
+      otherMembers: this.hostNames
     });
     this._serf.start();
     this._watching = true;

  Modified: lib/serf/agent.js (+19 -11)
===================================================================
--- lib/serf/agent.js    2014-11-05 12:23:47 +0900 (5fc6ff6)
+++ lib/serf/agent.js    2014-11-05 12:46:56 +0900 (b1d25b6)
@@ -2,9 +2,9 @@
  * usage:
  *   var Agent = require('lib/serf/agent');
  *   var serf = new Agent({
- *                serf: '/path/to/serf',
- *                hostName: 'node0',
- *                otherHostNames: ['node0:7946', 'node1:8946', 'node2', ...]
+ *                serf:         '/path/to/serf',
+ *                hostName:     'node0',
+ *                otherMembers: ['node0:7946', 'node1:8946', 'node2', ...]
  *              });
  *   serf.start()
  *     .then(function() { ... })
@@ -22,6 +22,9 @@ var ConsoleLogger = require('../console-logger').ConsoleLogger,
     Downloader    = require('./downloader');
 
 var NODE_NAME_PATTERN = /^([^:]+):(\d+)\/(.+)$/;
+var DEFAULT_BIND_PORT = 7946;
+var BIND_PORT         = 8946;
+var RPC_PORT          = 8373;
 
 function Agent(options) {
   options = options || {};
@@ -33,14 +36,18 @@ function Agent(options) {
   if (this._serf.charAt(0) == '.')
     this._serf = path.resolve(this._serf);
 
-  this._otherHostNames = options.otherHostNames || options.otherHostName || [];
-  if (!Array.isArray(this._otherHostNames))
-    this._otherHostNames = [this._otherHostNames];
+  this._otherMembers = options.otherMembers || options.otherMember || [];
+  if (!Array.isArray(this._otherMembers))
+    this._otherMembers = [this._otherMembers];
 
   this._agentProcess = null;
   this.shutdown = this.shutdown.bind(this);
 }
 Agent.prototype = {
+  get rpcAddress() {
+    return this._hostName + ':' + RPC_PORT;
+  },
+
   start: function() {
     this._logger.debug('Starting Serf agent (' + this._serf + ')');
     return Q.Promise((function(resolve, reject, notify) {
@@ -77,16 +84,17 @@ Agent.prototype = {
     var agentArgs = [
       'agent',
       '-node', this._hostName + '/protocol-adapter',
-      '-bind', this._hostName + ':8946',
+      '-bind', this._hostName + ':' + BIND_PORT,
+      '-rpc-addr', this._hostName + ':' + RPC_PORT,
       // '-event-handler', eventHandlerPath,
       // '-log-level', this._logLevel,
       '-tag', 'role=protocol-adapter'
     ];
-    this._otherHostNames.forEach(function(hostName) {
+    this._otherMembers.forEach(function(address) {
+      if (address.indexOf(':') < 0)
+        address = address + ':' + DEFAULT_BIND_PORT;
       agentArgs.push('-retry-join');
-      if (!/^[^:]+:\d+$/.test(hostName))
-        hostName = hostName + ':7946';
-      agentArgs.push(hostName);
+      agentArgs.push(address);
     });
     try {
       this._logger.info('Starting Serf agent: ' + this._serf + ' ' + agentArgs.join(' '));
-------------- next part --------------
HTML����������������������������...
下載 



More information about the Groonga-commit mailing list
Back to archive index