Permalink
Browse files

Merge branch 'master' of git://github.com/simplereach/helenus

  • Loading branch information...
2 parents 18c466f + e050e04 commit 2646b359b3c24d576719220151f1336f79d218ba @calvinfo calvinfo committed Sep 27, 2012
Showing with 52 additions and 23 deletions.
  1. +2 −0 .gitignore
  2. +4 −2 .travis.yml
  3. +10 −1 History.md
  4. +1 −1 lib/connection.js
  5. +22 −19 lib/pool.js
  6. +13 −0 test/thriftHostPool.js
View
@@ -2,3 +2,5 @@
node_modules
*.sock
lib-cov/
+*.iml
+.idea
View
@@ -5,10 +5,12 @@ node_js:
env:
- CASSANDRA_VERSION=1.0.11
- - CASSANDRA_VERSION=1.1.3
+ - CASSANDRA_VERSION=1.1.5
before_install:
- - sudo apt-get remove -y --purge cassandra
+ - sudo dpkg --purge cassandra
+ - sudo apt-get install libjna-java
+ - sudo apt-get install python-support
- sudo rm -rf /var/log/cassandra
- sudo rm -rf /var/lib/cassandra
View
@@ -167,4 +167,13 @@
0.5.7 / 2012-08-26
==================
- * Fixed issue with deserialization of ReversedType in CQL [ @devdazed #67 ]
+ * Fixed issue with deserialization of ReversedType in CQL [ @devdazed #67 ]
+
+0.5.8 / 2012-9-27
+==================
+
+ * Exposed Consistency Levels [ @calvinfo #73 ]
+ * Adding callback on nodes unavailable exception [ @calvinfo #72 ]
+ * Added hostPoolSize on ConnectionPool [ @hpainter #70 ]
+ * Fixed issue with interpolating array parameters [ @devdazed #68 ]
+
View
@@ -94,7 +94,7 @@ function escapeCQL(val) {
if (Array.isArray(val)) {
var sanitized = val.map( function( v ) { return escapeCQL( v ); } );
- return "'" + sanitized.join( "','" ) + "'";
+ return sanitized.join(',');
}
if (typeof val === 'object') {
View
@@ -31,7 +31,8 @@ var replyNotAvailable = function (callback) {
* user : 'mary',
* pass : 'qwerty',
* timeout : 30000,
- * cqlVersion : '3.0.0'
+ * cqlVersion : '3.0.0',
+ * hostPoolSize : 1
* });
*
* @constructor
@@ -45,11 +46,12 @@ var Pool = function(options){
this.password = options.password;
this.timeout = options.timeout;
this.cqlVersion = options.cqlVersion;
+ this.hostPoolSize = options.hostPoolSize ? options.hostPoolSize : 1;
this.retryInterval = null;
this.closing = false;
if(!options.hosts && options.host){
- this.hosts = [options.hosts];
+ this.hosts = [options.host];
} else {
this.hosts = options.hosts;
}
@@ -67,8 +69,9 @@ util.inherits(Pool, process.EventEmitter);
* @param {Function} callback The callback to invoke when all connections have been made
*/
Pool.prototype.connect = function(callback){
- var i = 0, finished = 0, client, self = this, len = this.hosts.length,
- connected = 0, errored;
+ var i = 0, finished = 0, self = this,
+ len = this.hosts.length * this.hostPoolSize,
+ connected = 0;
function onConnect(err, connection, keyspace, host){
finished += 1;
@@ -78,24 +81,22 @@ Pool.prototype.connect = function(callback){
} else {
connected += 1;
self.clients.push(connection);
-
- //we only want to callback once, after we get a valid connection
- if(connected === 1){
- //set the keyspaces connection to be the pool
- if(keyspace){
- keyspace.connection = self;
- }
- callback(null, keyspace);
-
- //now that we have a connection, lets start monitoring
- self.monitorConnections();
- }
}
-
+
if(finished === len){
if(self.clients.length === 0){
replyNotAvailable(callback);
}
+
+ //set the keyspaces connection to be the pool
+ if(keyspace){
+ keyspace.connection = self;
+ }
+ //we only want to callback once, after we get the final connection
+ callback(null, keyspace);
+
+ //now that we have a connection, lets start monitoring
+ self.monitorConnections();
}
}
@@ -118,8 +119,10 @@ Pool.prototype.connect = function(callback){
});
}
- for(; i < len; i += 1){
- connect(this.hosts[i]);
+ for(; i < this.hosts.length; i += 1){
+ for(var j=0; j < this.hostPoolSize; j +=1){
+ connect(this.hosts[i]);
+ }
}
};
View
@@ -0,0 +1,13 @@
+/**
+ * Runs tests defined in thrift.js, but with ConnectionPool
+ * option hostPoolSize set to 5.
+ */
+var config = require('./helpers/thrift'),
+ system = require('./helpers/connection'),
+ thriftTest = require('./thrift'),
+ Helenus, conn, ks, cf_standard, row_standard, cf_composite, cf_counter;
+
+system.hostPoolSize = 5;
+
+module.exports = thriftTest;
+

0 comments on commit 2646b35

Please sign in to comment.