nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: basho/riak-nodejs-client
Pull request #50 (2015-04-30 13:55:39)

Ensure that RiakCluster uses a new instance of DefaultNodeManager
Fixes issue #49 (CLIENTS-384)


Patch:
diff --git a/RELNOTES.md b/RELNOTES.md
index fb7e949..823adfb 100644
--- a/RELNOTES.md
+++ b/RELNOTES.md
@@ -1,6 +1,8 @@
 Release Notes
 =============
 
+* 1.1.3 - Following issues / PRs addressed:
+ * [RiakCluster uses a global DefaultNodeManager](https://github.com/basho/riak-nodejs-client/issues/49)
 * 1.1.2 - Following issues / PRs addressed:
  * [On cluster stop only emit state](https://github.com/basho/riak-nodejs-client/pull/46)
  * [vclock buffer issue](https://github.com/basho/riak-nodejs-client/issues/45)
diff --git a/lib/core/riakcluster.js b/lib/core/riakcluster.js
index 913af53..65c2e83 100644
--- a/lib/core/riakcluster.js
+++ b/lib/core/riakcluster.js
@@ -311,12 +311,16 @@ var State = Object.freeze({ CREATED : 0,
 
 var defaultRiakNode = new RiakNode();
 var defaultExecutionAttempts = 3;
-var defaultNodeManager = new DefaultNodeManager();
+
+function createDefaultNodeManager() {
+    return new DefaultNodeManager();
+}
 
 var schema = Joi.object().keys({
     nodes: Joi.array().min(1).default([defaultRiakNode]),
     executionAttempts: Joi.number().min(1).default(defaultExecutionAttempts),
-    nodeManager: Joi.object().default(defaultNodeManager),
+    nodeManager: Joi.object()
+        .default(createDefaultNodeManager, 'default is a new instance of DefaultNodeManager'),
     queueCommands: Joi.boolean().default(false),
     queueMaxDepth: Joi.number().default(0)
 });


Test patch:
diff --git a/test/unit/riakcluster.js b/test/unit/riakcluster.js
new file mode 100644
index 0000000..4152e9f
--- /dev/null
+++ b/test/unit/riakcluster.js
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2014 Basho Technologies, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var RiakCluster = require('../../lib/core/riakcluster');
+var assert = require('assert');
+
+describe('RiakCluster', function() {
+    describe('schema defaults', function() {
+        it('should create new node manager per-cluster', function(done) {
+            var cluster1 = new RiakCluster();
+            var cluster2 = new RiakCluster();
+            assert.notStrictEqual(cluster1.nodeManager, cluster2.nodeManager);
+            done();
+        });
+    });
+});
Repository: basho/riak-nodejs-client
Pull request #67 (2015-06-10 13:33:55)

Resolve issue #64


Patch:
diff --git a/lib/core/riakcluster.js b/lib/core/riakcluster.js
index 9bdf5b0..08754fe 100644
--- a/lib/core/riakcluster.js
+++ b/lib/core/riakcluster.js
@@ -49,7 +49,7 @@ var LinkedList = require('linkedlist');
  *     var nodeTemplate = new RiakNode.Builder().withMinConnections(10);
  *     var nodeAddys = ['192.168.1.1', '192.168.1.2'];
  *     var arrayOfNodes = RiakNode.buildNodes(nodeAddys, nodeTemplate);
- *     var myCluster = new RiakCluster.builder().withNodes(arrayOfNodes).build();
+ *     var myCluster = new RiakCluster.Builder().withRiakNodes(arrayOfNodes).build();
  *     
  * See {{#crossLink "RiakCluster.Builder"}}RiakCluster.Builder{{/crossLink}}
  *
@@ -272,7 +272,7 @@ RiakCluster.prototype.removeNode = function(node) {
             if (this.nodes[i].remoteAddress === split[0]) {
                 var removed;
                 if (split.length === 2) {
-                    if (this.nodes[i].remotePort === split[1]) {
+                    if (this.nodes[i].remotePort === Number(split[1])) {
                         removed = this.nodes.splice(i,1);
                         removed[0].stop();
                         return true;


Test patch:
diff --git a/test/unit/riakcluster.js b/test/unit/riakcluster.js
index 4152e9f..992ff9c 100644
--- a/test/unit/riakcluster.js
+++ b/test/unit/riakcluster.js
@@ -15,6 +15,7 @@
  */
 
 var RiakCluster = require('../../lib/core/riakcluster');
+var RiakNode = require('../../lib/core/riaknode');
 var assert = require('assert');
 
 describe('RiakCluster', function() {
@@ -26,4 +27,21 @@ describe('RiakCluster', function() {
             done();
         });
     });
+    describe('GitHub issues', function() {
+        it('resolves GitHub Issue 64', function(done) {
+            var nodeTemplate = new RiakNode.Builder().withMinConnections(10);
+            var nodeAddys = ['192.168.1.1:8087', '192.168.1.2:8087'];
+            var arrayOfNodes = RiakNode.buildNodes(nodeAddys, nodeTemplate);
+            var myCluster = new RiakCluster.Builder().withRiakNodes(arrayOfNodes).build();
+            assert.equal(myCluster.nodes.length, 2);
+            myCluster.nodes.forEach(function (n) {
+                n.state = RiakNode.State.RUNNING;
+            });
+            assert(myCluster.removeNode('192.168.1.1:8087'));
+            assert.equal(myCluster.nodes.length, 1);
+            assert.equal(myCluster.nodes[0].remoteAddress, '192.168.1.2');
+            assert.equal(myCluster.nodes[0].remotePort, 8087);
+            done();
+        });
+    });
 });