You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2015/06/08 13:20:00 UTC
[1/2] incubator-ignite git commit: #nodejs: npm codestyle.
Repository: incubator-ignite
Updated Branches:
refs/heads/ignite-nodejs a3aa145c3 -> 551b713a3
#nodejs: npm codestyle.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/86ba5d9a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/86ba5d9a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/86ba5d9a
Branch: refs/heads/ignite-nodejs
Commit: 86ba5d9aa8e229380278d3c0f721f60cf1199f32
Parents: a3aa145
Author: ivasilinets <iv...@gridgain.com>
Authored: Mon Jun 8 14:01:38 2015 +0300
Committer: ivasilinets <iv...@gridgain.com>
Committed: Mon Jun 8 14:01:38 2015 +0300
----------------------------------------------------------------------
modules/nodejs/src/main/js/apache_ignite.js | 6 +-
modules/nodejs/src/main/js/cache.js | 14 ++---
modules/nodejs/src/main/js/ignition.js | 38 ++++++------
modules/nodejs/src/main/js/package.json | 6 +-
modules/nodejs/src/main/js/server.js | 79 ++++++++++++------------
5 files changed, 73 insertions(+), 70 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/86ba5d9a/modules/nodejs/src/main/js/apache_ignite.js
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/main/js/apache_ignite.js b/modules/nodejs/src/main/js/apache_ignite.js
index 03bc3a8..c20e3dd 100644
--- a/modules/nodejs/src/main/js/apache_ignite.js
+++ b/modules/nodejs/src/main/js/apache_ignite.js
@@ -16,7 +16,7 @@
*/
module.exports = {
- Cache : require('./cache.js').Cache,
- Ignition : require('./ignition.js').Ignition,
- Server : require('./server.js').Server
+ Cache : require('./cache.js').Cache,
+ Ignition : require('./ignition.js').Ignition,
+ Server : require('./server.js').Server
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/86ba5d9a/modules/nodejs/src/main/js/cache.js
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/main/js/cache.js b/modules/nodejs/src/main/js/cache.js
index 9ee6f9c..e3c5406 100644
--- a/modules/nodejs/src/main/js/cache.js
+++ b/modules/nodejs/src/main/js/cache.js
@@ -24,9 +24,9 @@
* @param {string} cacheName Cache name
*/
function Cache(server, cacheName) {
- this._server = server;
- this._cacheName = cacheName;
- this._cacheNameParam = _pair("cacheName", this._cacheName);
+ this._server = server;
+ this._cacheName = cacheName;
+ this._cacheNameParam = _pair("cacheName", this._cacheName);
}
/**
@@ -37,7 +37,7 @@ function Cache(server, cacheName) {
* @param {Cache~onGet} callback Called on finish
*/
Cache.prototype.get = function(key, callback) {
- this._server.runCommand("get", [this._cacheNameParam, _pair("key", key)], callback);
+ this._server.runCommand("get", [this._cacheNameParam, _pair("key", key)], callback);
};
/**
@@ -56,8 +56,8 @@ Cache.prototype.get = function(key, callback) {
* @param {Cache~onPut} callback Called on finish
*/
Cache.prototype.put = function(key, value, callback) {
- this._server.runCommand("put", [this._cacheNameParam, _pair("key", key), _pair("val", value)],
- callback);
+ this._server.runCommand("put", [this._cacheNameParam, _pair("key", key), _pair("val", value)],
+ callback);
}
/**
@@ -67,7 +67,7 @@ Cache.prototype.put = function(key, value, callback) {
*/
function _pair(key, value) {
- return {key: key, value: value}
+ return {key: key, value: value}
}
exports.Cache = Cache
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/86ba5d9a/modules/nodejs/src/main/js/ignition.js
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/main/js/ignition.js b/modules/nodejs/src/main/js/ignition.js
index 1ac8faa..08398a1 100644
--- a/modules/nodejs/src/main/js/ignition.js
+++ b/modules/nodejs/src/main/js/ignition.js
@@ -38,30 +38,30 @@ function Ignition() {
* @param {Ignition~onStart} callback Called on finish
*/
Ignition.start = function(address, callback) {
- var Server = require("./server").Server;
- var numConn = address.length;
- for (var addr of address) {
- var params = addr.split(":");
- var server = new Server(params[0], params[1]);
- server.checkConnection(onConnect.bind(null, server));
- }
+ var Server = require("./server").Server;
+ var numConn = address.length;
+ for (var addr of address) {
+ var params = addr.split(":");
+ var server = new Server(params[0], params[1]);
+ server.checkConnection(onConnect.bind(null, server));
+ }
- function onConnect(server, error) {
- if (!callback)
- return;
+ function onConnect(server, error) {
+ if (!callback) return;
- numConn--;
- if (!error) {
- callback.call(null, null, server);
- callback = null;
- return;
- }
+ numConn--;
+ if (!error) {
+ callback.call(null, null, server);
+ callback = null;
+ return;
+ }
- console.log("onConnect:" + error);
+ console.log("onConnect:" + error);
- if (!numConn)
- callback.call(null, "Cannot connect to servers.", null);
+ if (!numConn) {
+ callback.call(null, "Cannot connect to servers.", null);
}
+ }
}
exports.Ignition = Ignition;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/86ba5d9a/modules/nodejs/src/main/js/package.json
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/main/js/package.json b/modules/nodejs/src/main/js/package.json
index b88cc22..e4fab0a 100644
--- a/modules/nodejs/src/main/js/package.json
+++ b/modules/nodejs/src/main/js/package.json
@@ -1,11 +1,13 @@
{
"name" : "apache-ignite",
- "version" : "1.0.0",
+ "version" : "1.0.0-SNAPSHOT",
"author" : "Semyon Boikov <sb...@gridgain.com>",
"contributors": [{
"name": "Irina Vasilinets",
"email": "ivasilients@gridgain.com"
}],
"main" : "apache_ignite.js",
- "license" : "Apache License, Version 2.0."
+ "license" : "Apache-2.0",
+ "keywords" : "grid",
+ "homepage" : "https://ignite.incubator.apache.org/"
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/86ba5d9a/modules/nodejs/src/main/js/server.js
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/main/js/server.js b/modules/nodejs/src/main/js/server.js
index f570eef..27256b8 100644
--- a/modules/nodejs/src/main/js/server.js
+++ b/modules/nodejs/src/main/js/server.js
@@ -24,8 +24,8 @@
* @param {number} port Port
*/
function Server(host, port) {
- this._host = host;
- this._port = port;
+ this._host = host;
+ this._port = port;
}
/**
@@ -34,9 +34,8 @@ function Server(host, port) {
* @this {Server}
* @returns {string} Host value
*/
-Server.prototype.host = function()
-{
- return this._host;
+Server.prototype.host = function() {
+ return this._host;
}
/**
@@ -56,49 +55,51 @@ Server.prototype.host = function()
* @param {Server~onRunCommand} Called on finish
*/
Server.prototype.runCommand = function(cmdName, params, callback) {
- var paramsString = "";
+ var paramsString = "";
- for (var p of params)
- //TODO: escape value
- paramsString += "&" + p.key + "=" + p.value;
+ for (var p of params) {
+ paramsString += "&" + p.key + "=" + p.value;
+ }
- var requestQry = "cmd=" + cmdName + paramsString;
+ var requestQry = "cmd=" + cmdName + paramsString;
- var http = require('http');
+ var http = require('http');
- var options = {
- host: this._host,
- port: this._port,
- path: "/ignite?" + requestQry
- };
+ var options = {
+ host: this._host,
+ port: this._port,
+ path: "/ignite?" + requestQry
+ };
- function streamCallback(response) {
- var fullResponseString = '';
+ function streamCallback(response) {
+ var fullResponseString = '';
- response.on('data', function (chunk) {
- fullResponseString += chunk;
- });
+ response.on('data', function (chunk) {
+ fullResponseString += chunk;
+ });
- response.on('end', function () {
- try {
- var response = JSON.parse(fullResponseString);
- if (response.successStatus)
- callback.call(null, response.error, null)
- else
- callback.call(null, null, response.response);
- } catch (e) {
- console.log("fail on json parse: " + fullResponseString)
- callback.call(null, e, null);
- }
- });
- }
+ response.on('end', function () {
+ try {
+ var response = JSON.parse(fullResponseString);
- var request = http.request(options, streamCallback);
+ if (response.successStatus) {
+ callback.call(null, response.error, null)
+ } else {
+ callback.call(null, null, response.response);
+ }
+ } catch (e) {
+ console.log("fail on json parse: " + fullResponseString);
+ callback.call(null, e, null);
+ }
+ });
+ }
- request.setTimeout(5000, callback.bind(null, "Request timeout: >5 sec"));
+ var request = http.request(options, streamCallback);
- request.on('error', callback);
- request.end();
+ request.setTimeout(5000, callback.bind(null, "Request timeout: >5 sec"));
+
+ request.on('error', callback);
+ request.end();
}
/**
@@ -108,7 +109,7 @@ Server.prototype.runCommand = function(cmdName, params, callback) {
* @param {Server~onRunCommand} callback Called on finish
*/
Server.prototype.checkConnection = function(callback) {
- this.runCommand("version", [], callback);
+ this.runCommand("version", [], callback);
}
exports.Server = Server;
\ No newline at end of file
[2/2] incubator-ignite git commit: #nodejs: small fixes
Posted by sb...@apache.org.
#nodejs: small fixes
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/551b713a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/551b713a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/551b713a
Branch: refs/heads/ignite-nodejs
Commit: 551b713a3cae755b501fbf3dceba516cb6c6ff61
Parents: 86ba5d9
Author: ivasilinets <iv...@gridgain.com>
Authored: Mon Jun 8 14:19:47 2015 +0300
Committer: ivasilinets <iv...@gridgain.com>
Committed: Mon Jun 8 14:19:47 2015 +0300
----------------------------------------------------------------------
modules/nodejs/src/main/js/apache-ignite.js | 22 ++++++++++++++++++++++
modules/nodejs/src/main/js/apache_ignite.js | 22 ----------------------
modules/nodejs/src/main/js/package.json | 5 +++--
3 files changed, 25 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/551b713a/modules/nodejs/src/main/js/apache-ignite.js
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/main/js/apache-ignite.js b/modules/nodejs/src/main/js/apache-ignite.js
new file mode 100644
index 0000000..c20e3dd
--- /dev/null
+++ b/modules/nodejs/src/main/js/apache-ignite.js
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
+module.exports = {
+ Cache : require('./cache.js').Cache,
+ Ignition : require('./ignition.js').Ignition,
+ Server : require('./server.js').Server
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/551b713a/modules/nodejs/src/main/js/apache_ignite.js
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/main/js/apache_ignite.js b/modules/nodejs/src/main/js/apache_ignite.js
deleted file mode 100644
index c20e3dd..0000000
--- a/modules/nodejs/src/main/js/apache_ignite.js
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-module.exports = {
- Cache : require('./cache.js').Cache,
- Ignition : require('./ignition.js').Ignition,
- Server : require('./server.js').Server
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/551b713a/modules/nodejs/src/main/js/package.json
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/main/js/package.json b/modules/nodejs/src/main/js/package.json
index e4fab0a..7efc4e2 100644
--- a/modules/nodejs/src/main/js/package.json
+++ b/modules/nodejs/src/main/js/package.json
@@ -6,8 +6,9 @@
"name": "Irina Vasilinets",
"email": "ivasilients@gridgain.com"
}],
- "main" : "apache_ignite.js",
+ "main" : "apache-ignite.js",
"license" : "Apache-2.0",
"keywords" : "grid",
- "homepage" : "https://ignite.incubator.apache.org/"
+ "homepage" : "https://ignite.incubator.apache.org/",
+ "engines" : { "node" : ">=0.12.4" }
}
\ No newline at end of file