[Groonga-commit] droonga/express-droonga at f2f8925 [master] Add codes to start/end watching of cluster changes

Zurück zum Archiv-Index

YUKI Hiroshi null+****@clear*****
Wed Nov 5 12:21:10 JST 2014


YUKI Hiroshi	2014-11-05 12:21:10 +0900 (Wed, 05 Nov 2014)

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

  Message:
    Add codes to start/end watching of cluster changes

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

  Modified: lib/droonga-protocol/connection-pool.js (+24 -0)
===================================================================
--- lib/droonga-protocol/connection-pool.js    2014-11-05 12:00:37 +0900 (8c3eccd)
+++ lib/droonga-protocol/connection-pool.js    2014-11-05 12:21:10 +0900 (e3cc6a1)
@@ -16,6 +16,7 @@ var exec = require('child_process').exec,
 var Connection = require('./connection').Connection;
 var ConsoleLogger = require('../console-logger').ConsoleLogger;
 var Catalog = require('../catalog').Catalog;
+var SerfAgent = require('../serf/agent');
 
 function ConnectionPool(params) {
   this._params = params || {};
@@ -103,6 +104,9 @@ ConnectionPool.prototype = {
       return;
     connection.close();
     delete this._connections[hostName];
+
+    if (Object.keys(this._connections).length == 0)
+      this.endWatchClusterChanges();
   },
 
   get count() {
@@ -165,6 +169,26 @@ ConnectionPool.prototype = {
                    this.hostNames = hostNames;
                    return hostNames;
                  }).bind(this));
+  },
+
+  startWatchClusterChanges: function() {
+    if (this._watching)
+      return;
+    this._serf = new SerfAgent({
+      serf:           this._params.serf,
+      hostName:       this._params.receiveHostName,
+      otherHostNames: this.hostNames
+    });
+    this._serf.start();
+    this._watching = true;
+  },
+
+  endWatchClusterChanges: function() {
+    if (!this._watching)
+      return;
+    this._serf.shutdown();
+    delete this._serf;
+    this._watching = false;
   }
 };
 
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Zurück zum Archiv-Index