You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by iv...@apache.org on 2015/07/01 12:14:13 UTC
[37/39] incubator-ignite git commit: #ignite-964: nodejs code style.
#ignite-964: nodejs code style.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/3807762a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/3807762a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/3807762a
Branch: refs/heads/ignite-964
Commit: 3807762a9c7cb449e82357955b705927474c42ac
Parents: 49f4f91
Author: ivasilinets <iv...@gridgain.com>
Authored: Wed Jul 1 13:01:11 2015 +0300
Committer: ivasilinets <iv...@gridgain.com>
Committed: Wed Jul 1 13:01:11 2015 +0300
----------------------------------------------------------------------
modules/nodejs/src/main/js/cache.js | 4 +-
modules/nodejs/src/main/js/server.js | 57 +++++++++++++-------
.../ignite/internal/NodeJsSqlQuerySelfTest.java | 2 +-
modules/nodejs/src/test/js/test-compute.js | 3 --
4 files changed, 42 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3807762a/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 3eaadb4..eef4039 100644
--- a/modules/nodejs/src/main/js/cache.js
+++ b/modules/nodejs/src/main/js/cache.js
@@ -180,8 +180,8 @@ Cache.prototype._sqlFieldsQuery = function(qry, onQueryExecute) {
Cache.prototype._sqlQuery = function(qry, onQueryExecute) {
if (qry.returnType() == null) {
- qry.error("No type for sql query.");
- qry.end();
+ qry.end("No type for sql query.");
+
return;
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3807762a/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 021fffe..ee1a134 100644
--- a/modules/nodejs/src/main/js/server.js
+++ b/modules/nodejs/src/main/js/server.js
@@ -57,12 +57,10 @@ Server.prototype.host = function() {
* Run http request
*
* @this {Server}
- * @param {string} cmdName command name.
- * @param params Parameters for command.
+ * @param {Command} cmd Command
* @param {onGet} Called on finish
*/
Server.prototype.runCommand = function(cmd, callback) {
-
var requestQry = "cmd=" + cmd.name() + cmd.paramsString();
var http = require('http');
@@ -89,6 +87,7 @@ Server.prototype.runCommand = function(cmd, callback) {
response.on('end', function () {
console.log("fullResponseString:" + fullResponseString);
+
if (response.statusCode !== 200) {
if (response.statusCode === 401) {
callback.call(null, "Authentication failed. Status code 401.");
@@ -181,52 +180,74 @@ Server._escape = function(f) {
return qs.escape(f.toString());
}
+/**
+ * @constructor
+ * @this{Command}
+ * @param{string} name Command name.
+ */
function Command(name) {
this._name = name;
this._params = [];
}
+/**
+ * @this {Command}
+ * @param {string} key Key
+ * @param {string} val Value
+ * @returns this
+ */
Command.prototype.addParam = function(key, value) {
this._params.push({key: key, value: value});
return this;
}
-Command.prototype.addParams = function(prefix, params) {
- for (var i = 1; i <= params.length; ++i) {
- this.addParam(prefix + i, params[i - 1]);
- }
- return this;
-}
-
+/**
+ * @this {Command}
+ * @param{JSONObject} postData Post data.
+ * @returns this
+ */
Command.prototype.setPostData = function(postData) {
this._postData = postData;
return this;
}
+/**
+ * @this {Command}
+ * @returns Post data.
+ */
Command.prototype.postData = function() {
return this._postData;
}
-Command.prototype._method = function() {
- return this._isPost()? "POST" : "GET";
-}
-
-Command.prototype._isPost = function() {
- return !!this._postData;
-}
-
+/**
+ * @this {Command}
+ * @returns Command name.
+ */
Command.prototype.name = function() {
return this._name;
}
+/**
+ * @this {Command}
+ * @returns Http request string.
+ */
Command.prototype.paramsString = function() {
var paramsString = "";
for (var p of this._params) {
paramsString += "&" + Server._escape(p.key) + "=" + Server._escape(p.value);
}
+
return paramsString;
}
+Command.prototype._method = function() {
+ return this._isPost()? "POST" : "GET";
+}
+
+Command.prototype._isPost = function() {
+ return !!this._postData;
+}
+
exports.Server = Server;
exports.Command = Command;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3807762a/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsSqlQuerySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsSqlQuerySelfTest.java b/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsSqlQuerySelfTest.java
index a6891fb..9024b93 100644
--- a/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsSqlQuerySelfTest.java
+++ b/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsSqlQuerySelfTest.java
@@ -91,7 +91,7 @@ public class NodeJsSqlQuerySelfTest extends NodeJsAbstractTest {
personCache.put(p3.getId(), p3);
personCache.put(p4.getId(), p4);
- SqlQuery qry = new SqlQuery(Person.class, "salary > ? and salary <= ?");
+ SqlQuery<Integer, Person> qry = new SqlQuery<>(Person.class, "salary > ? and salary <= ?");
qry.setArgs(1000, 2000);
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3807762a/modules/nodejs/src/test/js/test-compute.js
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/test/js/test-compute.js b/modules/nodejs/src/test/js/test-compute.js
index 6ab738c..943ab02 100644
--- a/modules/nodejs/src/test/js/test-compute.js
+++ b/modules/nodejs/src/test/js/test-compute.js
@@ -164,9 +164,6 @@ function testComputeWithErrors(map) {
var callback = function(err, res) {
assert(err != null, "Do not get error on compute task.");
- console.log("ERROR on Compute: " + err);
- console.log("End of ERROR.");
-
assert(err.indexOf("Function evaluation failed") > -1, "Incorrect error "+
"[expected=function evaluation failed, value=" + err + "]");