[Groonga-commit] droonga/express-droonga at 0070273 [master] Ignore engine nodes with cluster id differnt from the one of the node initially connected

Back to archive index

YUKI Hiroshi null+****@clear*****
Sun Nov 30 18:04:47 JST 2014


YUKI Hiroshi	2014-11-30 18:04:47 +0900 (Sun, 30 Nov 2014)

  New Revision: 00702732ee0f1e6473904e1c58464542ca539914
  https://github.com/droonga/express-droonga/commit/00702732ee0f1e6473904e1c58464542ca539914

  Message:
    Ignore engine nodes with cluster id differnt from the one of the node initially connected

  Modified files:
    lib/serf/client.js

  Modified: lib/serf/client.js (+17 -2)
===================================================================
--- lib/serf/client.js    2014-11-30 03:56:11 +0900 (8f7e189)
+++ lib/serf/client.js    2014-11-30 18:04:47 +0900 (06c4a06)
@@ -33,11 +33,12 @@ function Client(options) {
   options = options || {};
   options.rpcAddress = options.rpcAddress || '127.0.0.1';
 
+  this._droongaEngineHost = options.rpcAddress.split(':')[0];
   this._droongaEnginePort = options.enginePort || 10031;
   this._droongaTag        = options.tag || 'droonga';
 
   this._connectionOptions = {
-    rpc_host: options.rpcAddress.split(':')[0],
+    rpc_host: this._droongaEngineHost,
     rpc_port: parseInt(options.rpcAddress.split(':')[1] || DEFAULT_RPC_PORT)
   };
   this._client = new SerfRPC();
@@ -72,15 +73,29 @@ Client.prototype = {
 
   getLiveEngineNodes: function() {
     return this.getAllMembers().then((function(members) {
-      return members.filter(function(member) {
+      var clusterId;
+      var liveEngineNodes = members.filter(function(member) {
+        if (member.Tags.role != 'engine')
+          return false;
+
         var matched = String(member.Name).match(ENGINE_NODE_NAME_PATTERN);
         if (matched)
           member.HostName = matched[1];
+
+        if (member.HostName == this._droongaEngineHost ||
+            member.Addr.join('.') == this._droongaEngineHost)
+          clusterId = member.Tags.cluster_id;
+
         return matched &&
                  matched[2] == this._droongaEnginePort &&
                  matched[3] == this._droongaTag &&
                  member.Status == 'alive';
       }, this);
+      if (clusterId)
+        liveEngineNodes = liveEngineNodes.filter(function(member) {
+          return member.Tags.cluster_id == clusterId;
+        });
+      return liveEngineNodes;
     }).bind(this));
   },
 
-------------- next part --------------
HTML����������������������������...
Download 



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