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/24 12:06:47 UTC
[1/4] incubator-ignite git commit: #ignite-965: 4 spaces code style.
Repository: incubator-ignite
Updated Branches:
refs/heads/ignite-965 2880a9c58 -> b7f2393e0
#ignite-965: 4 spaces 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/f9f98acb
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/f9f98acb
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/f9f98acb
Branch: refs/heads/ignite-965
Commit: f9f98acb4ae357b9f2a66ce3a0e47b6cf43d089c
Parents: 2880a9c
Author: ivasilinets <iv...@gridgain.com>
Authored: Wed Jun 24 12:25:49 2015 +0300
Committer: ivasilinets <iv...@gridgain.com>
Committed: Wed Jun 24 12:25:49 2015 +0300
----------------------------------------------------------------------
modules/nodejs/src/main/js/apache-ignite.js | 10 +-
modules/nodejs/src/main/js/cache.js | 54 ++++-----
modules/nodejs/src/main/js/compute.js | 24 ++--
modules/nodejs/src/main/js/ignite.js | 8 +-
modules/nodejs/src/main/js/ignition.js | 87 +++++++--------
modules/nodejs/src/main/js/package.json | 24 ++--
modules/nodejs/src/main/js/server.js | 128 +++++++++++-----------
modules/nodejs/src/test/js/test-cache-api.js | 118 ++++++++++----------
modules/nodejs/src/test/js/test-compute.js | 105 +++++++++---------
modules/nodejs/src/test/js/test-ignition.js | 84 +++++++-------
modules/nodejs/src/test/js/test-key.js | 22 ++--
modules/nodejs/src/test/js/test-utils.js | 114 +++++++++----------
12 files changed, 389 insertions(+), 389 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f9f98acb/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 0df6160..e8252fc 100644
--- a/modules/nodejs/src/main/js/apache-ignite.js
+++ b/modules/nodejs/src/main/js/apache-ignite.js
@@ -16,9 +16,9 @@
*/
module.exports = {
- Cache : require('./cache.js').Cache,
- Ignition : require('./ignition.js').Ignition,
- Server : require('./server.js').Server,
- Ignite : require('./ignite.js').Ignite,
- Compute : require('./compute.js').Compute
+ Cache : require('./cache.js').Cache,
+ Ignition : require('./ignition.js').Ignition,
+ Server : require('./server.js').Server,
+ Ignite : require('./ignite.js').Ignite,
+ Compute : require('./compute.js').Compute
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f9f98acb/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 78dd1d8..86eb22a 100644
--- a/modules/nodejs/src/main/js/cache.js
+++ b/modules/nodejs/src/main/js/cache.js
@@ -26,9 +26,9 @@ var Server = require("./server").Server;
* @param {string} cacheName Cache name
*/
function Cache(server, cacheName) {
- this._server = server;
- this._cacheName = cacheName;
- this._cacheNameParam = Server.pair("cacheName", this._cacheName);
+ this._server = server;
+ this._cacheName = cacheName;
+ this._cacheNameParam = Server.pair("cacheName", this._cacheName);
}
/**
@@ -39,7 +39,7 @@ function Cache(server, cacheName) {
* @param {onGet} callback Called on finish
*/
Cache.prototype.get = function(key, callback) {
- this._server.runCommand("get", [this._cacheNameParam, Server.pair("key", key)], callback);
+ this._server.runCommand("get", [this._cacheNameParam, Server.pair("key", key)], callback);
};
/**
@@ -51,8 +51,8 @@ Cache.prototype.get = function(key, callback) {
* @param {noValue} callback Called on finish
*/
Cache.prototype.put = function(key, value, callback) {
- this._server.runCommand("put", [this._cacheNameParam, Server.pair("key", key), Server.pair("val", value)],
- callback);
+ this._server.runCommand("put", [this._cacheNameParam, Server.pair("key", key), Server.pair("val", value)],
+ callback);
}
/**
@@ -63,7 +63,7 @@ Cache.prototype.put = function(key, value, callback) {
* @param {noValue} callback Called on finish
*/
Cache.prototype.remove = function(key, callback) {
- this._server.runCommand("rmv", [this._cacheNameParam, Server.pair("key", key)], callback);
+ this._server.runCommand("rmv", [this._cacheNameParam, Server.pair("key", key)], callback);
}
/**
@@ -74,11 +74,11 @@ Cache.prototype.remove = function(key, callback) {
* @param {noValue} callback Called on finish
*/
Cache.prototype.removeAll = function(keys, callback) {
- var params = [this._cacheNameParam];
+ var params = [this._cacheNameParam];
- params = params.concat(Cache.concatParams("k", keys));
+ params = params.concat(Cache.concatParams("k", keys));
- this._server.runCommand("rmvall", params, callback);
+ this._server.runCommand("rmvall", params, callback);
}
/**
@@ -89,20 +89,20 @@ Cache.prototype.removeAll = function(keys, callback) {
* @param {noValue} callback Called on finish
*/
Cache.prototype.putAll = function(map, callback) {
- var keys = Object.keys(map);
+ var keys = Object.keys(map);
- var values = [];
+ var values = [];
- for (var key of keys) {
- values.push(map[key]);
- }
+ for (var key of keys) {
+ values.push(map[key]);
+ }
- var params = Cache.concatParams("k", keys);
- params = params.concat(Cache.concatParams("v", values));
+ var params = Cache.concatParams("k", keys);
+ params = params.concat(Cache.concatParams("v", values));
- params.push(this._cacheNameParam);
+ params.push(this._cacheNameParam);
- this._server.runCommand("putall", params, callback);
+ this._server.runCommand("putall", params, callback);
}
/**
@@ -121,11 +121,11 @@ Cache.prototype.putAll = function(map, callback) {
* @param {Cache~onGetAll} callback Called on finish
*/
Cache.prototype.getAll = function(keys, callback) {
- var params = Cache.concatParams("k", keys);
+ var params = Cache.concatParams("k", keys);
- params.push(this._cacheNameParam);
+ params.push(this._cacheNameParam);
- this._server.runCommand("getall", params, callback);
+ this._server.runCommand("getall", params, callback);
}
/**
@@ -136,13 +136,13 @@ Cache.prototype.getAll = function(keys, callback) {
* @returns List of parameters.
*/
Cache.concatParams = function(pref, keys) {
- var temp = []
+ var temp = []
- for (var i = 1; i <= keys.length; ++i) {
- temp.push(Server.pair(pref + i, keys[i-1]));
- }
+ for (var i = 1; i <= keys.length; ++i) {
+ temp.push(Server.pair(pref + i, keys[i-1]));
+ }
- return temp;
+ return temp;
}
exports.Cache = Cache
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f9f98acb/modules/nodejs/src/main/js/compute.js
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/main/js/compute.js b/modules/nodejs/src/main/js/compute.js
index f00db69..01361d5 100644
--- a/modules/nodejs/src/main/js/compute.js
+++ b/modules/nodejs/src/main/js/compute.js
@@ -23,7 +23,7 @@ var Server = require("./server").Server;
* @param {Server} server Server
*/
function Compute(server) {
- this._server = server;
+ this._server = server;
}
/**
@@ -34,8 +34,8 @@ function Compute(server) {
* @param {noValue} callback Callback
*/
Compute.prototype.affinityRun = function(cacheName, key, runnable, callback) {
- this._server.runCommand("affscriptrun", [Server.pair("cacheName", cacheName),
- Server.pair("key", key), Server.pair("func", this._escape(runnable))], callback);
+ this._server.runCommand("affscriptrun", [Server.pair("cacheName", cacheName),
+ Server.pair("key", key), Server.pair("func", this._escape(runnable))], callback);
}
/**
@@ -46,8 +46,8 @@ Compute.prototype.affinityRun = function(cacheName, key, runnable, callback) {
* @param {onGet} callback Callback
*/
Compute.prototype.affinityCall = function(cacheName, key, runnable, callback) {
- this._server.runCommand("affscriptcall", [Server.pair("cacheName", cacheName),
- Server.pair("key", key), Server.pair("func", this._escape(runnable))], callback);
+ this._server.runCommand("affscriptcall", [Server.pair("cacheName", cacheName),
+ Server.pair("key", key), Server.pair("func", this._escape(runnable))], callback);
}
/**
@@ -58,13 +58,13 @@ Compute.prototype.affinityCall = function(cacheName, key, runnable, callback) {
* @param {onGet} callback Callback
*/
Compute.prototype.execute = function(map, reduce, arg, callback) {
- var params = [];
+ var params = [];
- params.push(Server.pair("map", this._escape(map)));
- params.push(Server.pair("reduce", this._escape(reduce)));
- params.push(Server.pair("arg", this._escape(arg)));
+ params.push(Server.pair("map", this._escape(map)));
+ params.push(Server.pair("reduce", this._escape(reduce)));
+ params.push(Server.pair("arg", this._escape(arg)));
- this._server.runCommand("execscripttask", params, callback);
+ this._server.runCommand("execscripttask", params, callback);
}
/**
@@ -72,9 +72,9 @@ Compute.prototype.execute = function(map, reduce, arg, callback) {
* @returns {string} Encoding function
*/
Compute.prototype._escape = function(f) {
- var qs = require('querystring');
+ var qs = require('querystring');
- return qs.escape(f.toString());
+ return qs.escape(f.toString());
}
/**
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f9f98acb/modules/nodejs/src/main/js/ignite.js
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/main/js/ignite.js b/modules/nodejs/src/main/js/ignite.js
index dca292e..fb24a19 100644
--- a/modules/nodejs/src/main/js/ignite.js
+++ b/modules/nodejs/src/main/js/ignite.js
@@ -26,7 +26,7 @@ var Compute = require("./compute").Compute
* @param {Server} Server
*/
function Ignite(server) {
- this._server = server;
+ this._server = server;
}
/**
@@ -34,7 +34,7 @@ function Ignite(server) {
* @returns {Server} Server
*/
Ignite.prototype.server = function() {
- return this._server;
+ return this._server;
}
/**
@@ -45,7 +45,7 @@ Ignite.prototype.server = function() {
* @returns {Cache} Cache
*/
Ignite.prototype.cache = function(cacheName) {
- return new Cache(this._server, cacheName);
+ return new Cache(this._server, cacheName);
}
/**
@@ -55,7 +55,7 @@ Ignite.prototype.cache = function(cacheName) {
* @returns {Compute} Compute
*/
Ignite.prototype.compute = function() {
- return new Compute(this._server);
+ return new Compute(this._server);
}
exports.Ignite = Ignite;
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f9f98acb/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 d641d26..e1ecc6c 100644
--- a/modules/nodejs/src/main/js/ignition.js
+++ b/modules/nodejs/src/main/js/ignition.js
@@ -39,69 +39,70 @@ function Ignition() {
* @param {Ignition~onStart} callback Called on finish
*/
Ignition.start = function(address, secretKey, callback) {
- var Server = require("./server").Server;
- var Ignite = require("./ignite").Ignite
+ var Server = require("./server").Server;
+ var Ignite = require("./ignite").Ignite
- var numConn = 0;
+ var numConn = 0;
- for (var addr of address) {
- var params = addr.split(":");
+ for (var addr of address) {
+ var params = addr.split(":");
- var portsRange = params[1].split("..");
+ var portsRange = params[1].split("..");
- var start;
- var end;
+ var start;
+ var end;
- if (portsRange.length === 1) {
- start = parseInt(portsRange[0], 10);
- end = start;
- }
- else if (portsRange.length === 2) {
- start = parseInt(portsRange[0], 10);
- end = parseInt(portsRange[1], 10);
- }
- if (isNaN(start) || isNaN(end)) {
- incorrectAddress();
+ if (portsRange.length === 1) {
+ start = parseInt(portsRange[0], 10);
+ end = start;
+ }
+ else if (portsRange.length === 2) {
+ start = parseInt(portsRange[0], 10);
+ end = parseInt(portsRange[1], 10);
+ }
- return;
- }
+ if (isNaN(start) || isNaN(end)) {
+ incorrectAddress();
+
+ return;
+ }
- for (var i = start; i <= end; i++) {
- checkServer(params[0], i, secretKey);
+ for (var i = start; i <= end; i++) {
+ checkServer(params[0], i, secretKey);
+ }
}
- }
- function checkServer(host, port, secretKey) {
- numConn++;
+ function checkServer(host, port, secretKey) {
+ numConn++;
- var server = new Server(host, port, secretKey);
+ var server = new Server(host, port, secretKey);
- server.checkConnection(onConnect.bind(null, server));
- }
+ server.checkConnection(onConnect.bind(null, server));
+ }
- function incorrectAddress() {
- callback.call(null, "Incorrect address format.", null);
+ function incorrectAddress() {
+ callback.call(null, "Incorrect address format.", null);
- callback = null;
- }
+ callback = null;
+ }
- function onConnect(server, error) {
- if (!callback) return;
+ function onConnect(server, error) {
+ if (!callback) return;
- numConn--;
+ numConn--;
- if (!error) {
- callback.call(null, null, new Ignite(server));
+ if (!error) {
+ callback.call(null, null, new Ignite(server));
- callback = null;
+ callback = null;
- return;
- }
+ return;
+ }
- if (!numConn) {
- callback.call(null, "Cannot connect to servers. " + error, null);
+ if (!numConn) {
+ callback.call(null, "Cannot connect to servers. " + error, null);
+ }
}
- }
}
exports.Ignition = Ignition;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f9f98acb/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 7efc4e2..ae4b911 100644
--- a/modules/nodejs/src/main/js/package.json
+++ b/modules/nodejs/src/main/js/package.json
@@ -1,14 +1,14 @@
{
- "name" : "apache-ignite",
- "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-2.0",
- "keywords" : "grid",
- "homepage" : "https://ignite.incubator.apache.org/",
- "engines" : { "node" : ">=0.12.4" }
+ "name" : "apache-ignite",
+ "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-2.0",
+ "keywords" : "grid",
+ "homepage" : "https://ignite.incubator.apache.org/",
+ "engines" : { "node" : ">=0.12.4" }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f9f98acb/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 f1c9d92..2bd0b4e 100644
--- a/modules/nodejs/src/main/js/server.js
+++ b/modules/nodejs/src/main/js/server.js
@@ -25,9 +25,9 @@
* @param {string} secretKey Secret key for connection
*/
function Server(host, port, secretKey) {
- this._host = host;
- this._port = port;
- this._secretKey = secretKey;
+ this._host = host;
+ this._port = port;
+ this._secretKey = secretKey;
}
/**
@@ -37,7 +37,7 @@ function Server(host, port, secretKey) {
* @returns {string} Host value
*/
Server.prototype.host = function() {
- return this._host;
+ return this._host;
}
/**
@@ -62,68 +62,68 @@ Server.prototype.host = function() {
* @param {onGet} Called on finish
*/
Server.prototype.runCommand = function(cmdName, params, callback) {
- var paramsString = "";
+ var paramsString = "";
- for (var p of params) {
- 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,
- headers: this._signature()
- };
+ var options = {
+ host: this._host,
+ port: this._port,
+ path: "/ignite?" + requestQry,
+ headers: this._signature()
+ };
- 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 () {
- if (response.statusCode !== 200) {
- if (response.statusCode === 401) {
- callback.call(null, "Authentication failed. Status code 401.");
- }
- else {
- callback.call(null, "Request failed. Status code " + response.statusCode);
- }
+ response.on('end', function () {
+ if (response.statusCode !== 200) {
+ if (response.statusCode === 401) {
+ callback.call(null, "Authentication failed. Status code 401.");
+ }
+ else {
+ callback.call(null, "Request failed. Status code " + response.statusCode);
+ }
- return;
- }
+ return;
+ }
- var igniteResponse;
+ var igniteResponse;
- try {
- igniteResponse = JSON.parse(fullResponseString);
- }
- catch (e) {
- callback.call(null, e, null);
- return;
- }
+ try {
+ igniteResponse = JSON.parse(fullResponseString);
+ }
+ catch (e) {
+ callback.call(null, e, null);
+ return;
+ }
- if (igniteResponse.successStatus) {
- callback.call(null, igniteResponse.error, null)
- }
- else {
- callback.call(null, null, igniteResponse.response);
- }
- });
- }
+ if (igniteResponse.successStatus) {
+ callback.call(null, igniteResponse.error, null)
+ }
+ else {
+ callback.call(null, null, igniteResponse.response);
+ }
+ });
+ }
- var request = http.request(options, streamCallback);
+ var request = http.request(options, streamCallback);
- request.setTimeout(5000, callback.bind(null, "Request timeout: >5 sec"));
+ request.setTimeout(5000, callback.bind(null, "Request timeout: >5 sec"));
- request.on('error', callback);
+ request.on('error', callback);
- request.end();
+ request.end();
}
/**
@@ -133,7 +133,7 @@ Server.prototype.runCommand = function(cmdName, params, callback) {
* @param {onGet} callback Called on finish
*/
Server.prototype.checkConnection = function(callback) {
- this.runCommand("version", [], callback);
+ this.runCommand("version", [], callback);
}
/**
@@ -144,7 +144,7 @@ Server.prototype.checkConnection = function(callback) {
* @returns Pair of strings
*/
Server.pair = function(key, value) {
- return {key: key, value: value}
+ return {key: key, value: value}
}
/**
@@ -154,25 +154,25 @@ Server.pair = function(key, value) {
* @returns Signature
*/
Server.prototype._signature = function() {
- if (!this._secretKey) {
- return "";
- }
+ if (!this._secretKey) {
+ return "";
+ }
- var loadTimeInMS = Date.now();
+ var loadTimeInMS = Date.now();
- var baseKey = '' + loadTimeInMS + ":" + this._secretKey;
+ var baseKey = '' + loadTimeInMS + ":" + this._secretKey;
- var crypto = require('crypto')
+ var crypto = require('crypto')
- var shasum = crypto.createHash('sha1');
+ var shasum = crypto.createHash('sha1');
- shasum.update(baseKey, 'binary');
+ shasum.update(baseKey, 'binary');
- var hash = shasum.digest('base64');
+ var hash = shasum.digest('base64');
- var key = loadTimeInMS + ":" + hash;
+ var key = loadTimeInMS + ":" + hash;
- return {"X-Signature" : key};
+ return {"X-Signature" : key};
}
exports.Server = Server;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f9f98acb/modules/nodejs/src/test/js/test-cache-api.js
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/test/js/test-cache-api.js b/modules/nodejs/src/test/js/test-cache-api.js
index 1101493..335f888 100644
--- a/modules/nodejs/src/test/js/test-cache-api.js
+++ b/modules/nodejs/src/test/js/test-cache-api.js
@@ -20,123 +20,123 @@ var TestUtils = require("./test-utils").TestUtils;
var assert = require("assert");
testPutGet = function() {
- startTest("mycache", {trace: [put, getExist], entry: "6"});
+ startTest("mycache", {trace: [put, getExist], entry: "6"});
}
testRemove = function() {
- startTest("mycache", {trace: [put, getExist, remove, getNonExist], entry: "6"});
+ startTest("mycache", {trace: [put, getExist, remove, getNonExist], entry: "6"});
}
testRemoveNoKey = function() {
- startTest("mycache", {trace: [remove, getNonExist], entry: "6"});
+ startTest("mycache", {trace: [remove, getNonExist], entry: "6"});
}
testPutAllGetAll = function() {
- startTest("mycache", {trace: [putAll, getAll], entry: {"key1": "val1", "key2" : "val2"}});
+ startTest("mycache", {trace: [putAll, getAll], entry: {"key1": "val1", "key2" : "val2"}});
}
testRemoveAll = function() {
- startTest("mycache", {trace: [putAll, getAll, removeAll, getNone], entry: {"key1": "val1", "key2" : "val2"}});
+ startTest("mycache", {trace: [putAll, getAll, removeAll, getNone], entry: {"key1": "val1", "key2" : "val2"}});
}
testIncorrectCacheName = function() {
- startTest("mycache1", {trace: [incorrectPut], entry: "6"});
+ startTest("mycache1", {trace: [incorrectPut], entry: "6"});
}
function startTest(cacheName, testDescription) {
- TestUtils.startIgniteNode(onStart.bind(null, cacheName, testDescription));
+ TestUtils.startIgniteNode(onStart.bind(null, cacheName, testDescription));
}
function onStart(cacheName, testDescription, error, ignite) {
- var cache = ignite.cache(cacheName);
- callNext();
-
- function callNext(error) {
- assert(!error);
- var next = testDescription.trace.shift();
- if (next)
- next.call(null, cache, testDescription.entry, callNext);
- else
- TestUtils.testDone();
- }
+ var cache = ignite.cache(cacheName);
+ callNext();
+
+ function callNext(error) {
+ assert(!error);
+ var next = testDescription.trace.shift();
+ if (next)
+ next.call(null, cache, testDescription.entry, callNext);
+ else
+ TestUtils.testDone();
+ }
}
function put(cache, entry, next) {
- cache.put("key", entry, next);
+ cache.put("key", entry, next);
}
function getExist(cache, entry, next) {
- cache.get("key", onGet);
+ cache.get("key", onGet);
- function onGet(error, value) {
- assert(!error);
- assert(value === entry);
- next();
- }
+ function onGet(error, value) {
+ assert(!error);
+ assert(value === entry);
+ next();
+ }
}
function remove(cache, entry, next) {
- cache.remove("key", next);
+ cache.remove("key", next);
}
function getNonExist(cache, entry, next) {
- cache.get("key", onGet);
+ cache.get("key", onGet);
- function onGet(error, value) {
- assert(!error);
- assert(!value);
- next();
- }
+ function onGet(error, value) {
+ assert(!error);
+ assert(!value);
+ next();
+ }
}
function putAll(cache, entries, next) {
- cache.putAll(entries, next);
+ cache.putAll(entries, next);
}
function getAll(cache, entries, next) {
- cache.getAll(Object.keys(entries), onGetAll);
- var expected = entries;
+ cache.getAll(Object.keys(entries), onGetAll);
+ var expected = entries;
- function onGetAll(error, values) {
- assert(!error, error);
+ function onGetAll(error, values) {
+ assert(!error, error);
- var keys = Object.keys(expected);
+ var keys = Object.keys(expected);
- for (var i = 0; i < keys.length; ++i) {
- var key = keys[i];
+ for (var i = 0; i < keys.length; ++i) {
+ var key = keys[i];
- assert(!!values[key], "Cannot find key. [key=" + key + "].");
+ assert(!!values[key], "Cannot find key. [key=" + key + "].");
- assert(values[key] === expected[key], "Incorrect value. [key=" + key +
- ", expected=" + expected[key] + ", val= " + values[key] + "].");
+ assert(values[key] === expected[key], "Incorrect value. [key=" + key +
+ ", expected=" + expected[key] + ", val= " + values[key] + "].");
+ }
+ next();
}
- next();
- }
}
function removeAll(cache, entries, next) {
- cache.removeAll(Object.keys(entries), next)
+ cache.removeAll(Object.keys(entries), next)
}
function getNone(cache, entries, next) {
- cache.getAll(Object.keys(entries), onGetAll);
+ cache.getAll(Object.keys(entries), onGetAll);
- function onGetAll(error, values) {
- assert(!error, error);
- assert(!values || !Object.keys(values).length);
+ function onGetAll(error, values) {
+ assert(!error, error);
+ assert(!values || !Object.keys(values).length);
- next();
- }
+ next();
+ }
}
function incorrectPut(cache, entry, next) {
- cache.put("key", entry, callback);
+ cache.put("key", entry, callback);
- function callback(error) {
- assert(!!error, "Do not get error for not exist cache");
- assert(error.indexOf("Failed to find cache for given cache name") !== -1,
- "Incorrect message on not exist cache. " + error);
+ function callback(error) {
+ assert(!!error, "Do not get error for not exist cache");
+ assert(error.indexOf("Failed to find cache for given cache name") !== -1,
+ "Incorrect message on not exist cache. " + error);
- next();
- }
+ next();
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f9f98acb/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 8c1a7fe..a494f3e 100644
--- a/modules/nodejs/src/test/js/test-compute.js
+++ b/modules/nodejs/src/test/js/test-compute.js
@@ -20,96 +20,95 @@ var TestUtils = require("./test-utils").TestUtils;
var assert = require("assert");
testComputeAffinityRun = function() {
- TestUtils.startIgniteNode(onStart.bind(null, computeAffinityRun));
+ TestUtils.startIgniteNode(onStart.bind(null, computeAffinityRun));
}
testComputeAffinityCall = function() {
- TestUtils.startIgniteNode(onStart.bind(null, computeAffinityCall));
+ TestUtils.startIgniteNode(onStart.bind(null, computeAffinityCall));
}
testComputeExecute = function() {
- TestUtils.startIgniteNode(computeExecute);
+ TestUtils.startIgniteNode(computeExecute);
}
function onStart(onPut, error, ignite) {
- var cache = ignite.cache("mycache");
+ var cache = ignite.cache("mycache");
- var params = {}
+ var params = {}
- for (var i = 900; i < 1000; ++i) {
- params["key" + i] = "val" + i;
- }
+ for (var i = 900; i < 1000; ++i) {
+ params["key" + i] = "val" + i;
+ }
- cache.putAll(params, onPut.bind(null, ignite))
+ cache.putAll(params, onPut.bind(null, ignite))
}
function computeAffinityRun(ignite, error) {
- var comp = ignite.compute();
+ var comp = ignite.compute();
- var f = function () {
- println("Hello world!");
+ var f = function () {
+ println("Hello world!");
- ignite.hello();
- }
+ ignite.hello();
+ }
- function onEnd(error) {
- assert(error == null);
+ function onEnd(error) {
+ assert(error == null);
- TestUtils.testDone();
- }
+ TestUtils.testDone();
+ }
- comp.affinityRun("mycache", "key999", f, onEnd.bind(null));
+ comp.affinityRun("mycache", "key999", f, onEnd.bind(null));
}
function computeAffinityCall(ignite, error) {
- var comp = ignite.compute();
+ var comp = ignite.compute();
- var f = function () {
- return ignite.hello();
- }
-
- function onEnd(err, res) {
- assert(err == null);
+ var f = function () {
+ return ignite.hello();
+ }
- assert(res.indexOf("HAPPY") !== -1, "Incorrect result message. [mes=" + res + "].");
+ function onEnd(err, res) {
+ assert(err == null);
+ assert(res.indexOf("HAPPY") !== -1, "Incorrect result message. [mes=" + res + "].");
- TestUtils.testDone();
- }
+ TestUtils.testDone();
+ }
- comp.affinityCall("mycache", "key999", f, onEnd.bind(null));
+ comp.affinityCall("mycache", "key999", f, onEnd.bind(null));
}
function computeExecute(error, ignite) {
- var map = function(nodes, arg, emit) {
- var words = arg.split(" ");
+ var map = function(nodes, arg, emit) {
+ var words = arg.split(" ");
- for (var i = 0; i < words.length; i++) {
- var f = function (word) {
- println(">>> Printing " + word);
+ for (var i = 0; i < words.length; i++) {
+ var f = function (word) {
+ println(">>> Printing " + word);
- return word.length;
- };
+ return word.length;
+ };
- emit(f, [words[i]], nodes[i % nodes.length]);
- }
- };
+ emit(f, [words[i]], nodes[i % nodes.length]);
+ }
+ };
- var reduce = function(results) {
- var sum = 0;
+ var reduce = function(results) {
+ var sum = 0;
- for (var i = 0; i < results.length; ++i) {
- sum += parseInt(results[i], 10);
- }
+ for (var i = 0; i < results.length; ++i) {
+ sum += parseInt(results[i], 10);
+ }
- return sum;
- };
+ return sum;
+ };
- var callback = function(err, res) {
- assert(err == null, "Get error on compute task. [err=" + err + "].");
- assert(res === 7, "Result is not correct. [expected=7, value=" + res + "].");
+ var callback = function(err, res) {
+ assert(err == null, "Get error on compute task. [err=" + err + "].");
+ assert(res === 7, "Result is not correct. [expected=7, value=" + res + "].");
- TestUtils.testDone();
- }
+ TestUtils.testDone();
+ }
- ignite.compute().execute(map, reduce, "Hi Alice", callback);
+ ignite.compute().execute(map, reduce, "Hi Alice", callback);
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f9f98acb/modules/nodejs/src/test/js/test-ignition.js
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/test/js/test-ignition.js b/modules/nodejs/src/test/js/test-ignition.js
index 3823109..fd80e61 100644
--- a/modules/nodejs/src/test/js/test-ignition.js
+++ b/modules/nodejs/src/test/js/test-ignition.js
@@ -23,70 +23,70 @@ var Ignition = Ignite.Ignition;
var assert = require("assert");
testIgnitionFail = function () {
- Ignition.start(['127.0.0.3:9091', '127.0.0.1:9092'], null, onConnect);
-
- function onConnect(error, server) {
- if (error) {
- if (error.indexOf("Cannot connect to servers.") == -1) {
- TestUtils.testFails("Incorrect error message: " + error);
- }
- else {
- TestUtils.testDone();
- }
+ Ignition.start(['127.0.0.3:9091', '127.0.0.1:9092'], null, onConnect);
- return;
- }
+ function onConnect(error, server) {
+ if (error) {
+ if (error.indexOf("Cannot connect to servers.") == -1) {
+ TestUtils.testFails("Incorrect error message: " + error);
+ }
+ else {
+ TestUtils.testDone();
+ }
+
+ return;
+ }
- TestUtils.testFails("Test should fail.");
- }
+ TestUtils.testFails("Test should fail.");
+ }
}
ignitionStartSuccess = function() {
- Ignition.start(['127.0.0.0:9095', '127.0.0.1:9095'], null, onConnect);
+ Ignition.start(['127.0.0.0:9095', '127.0.0.1:9095'], null, onConnect);
- function onConnect(error, server) {
- if (error) {
- TestUtils.testFails(error);
+ function onConnect(error, server) {
+ if (error) {
+ TestUtils.testFails(error);
- return;
- }
+ return;
+ }
- TestUtils.testDone();
- }
+ TestUtils.testDone();
+ }
}
ignitionStartSuccessWithSeveralPorts = function() {
- Ignition.start(['127.0.0.1:9090..9100'], null, onConnect);
+ Ignition.start(['127.0.0.1:9090..9100'], null, onConnect);
- function onConnect(error, ignite) {
- if (error) {
- TestUtils.testFails(error);
+ function onConnect(error, ignite) {
+ if (error) {
+ TestUtils.testFails(error);
- return;
- }
+ return;
+ }
- var server = ignite.server();
+ var server = ignite.server();
- var host = server.host();
+ var host = server.host();
- assert.ok(host.indexOf('127.0.0.1') !== -1, "Incorrect host.");
+ assert.ok(host.indexOf('127.0.0.1') !== -1, "Incorrect host.");
- TestUtils.testDone();
- }
+ TestUtils.testDone();
+ }
}
ignitionNotStartWithSeveralPorts = function() {
- Ignition.start(['127.0.0.1:9090...9100'], null, onConnect);
+ Ignition.start(['127.0.0.1:9090...9100'], null, onConnect);
- function onConnect(error, ignite) {
- if (error) {
- assert.ok(error.indexOf("Incorrect address format") !== -1, "Incorrect message.")
+ function onConnect(error, ignite) {
+ if (error) {
+ assert.ok(error.indexOf("Incorrect address format") !== -1, "Incorrect message.")
- TestUtils.testDone();
+ TestUtils.testDone();
- return;
- }
+ return;
+ }
- TestUtils.testFails("Exception should be thrown.");
- }
+ TestUtils.testFails("Exception should be thrown.");
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f9f98acb/modules/nodejs/src/test/js/test-key.js
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/test/js/test-key.js b/modules/nodejs/src/test/js/test-key.js
index b02a6b5..be5888e 100644
--- a/modules/nodejs/src/test/js/test-key.js
+++ b/modules/nodejs/src/test/js/test-key.js
@@ -20,35 +20,35 @@ var TestUtils = require("./test-utils").TestUtils;
var assert = require("assert");
testStartWithoutKey = function() {
- TestUtils.startIgniteNode(onIncorrectStart);
+ TestUtils.startIgniteNode(onIncorrectStart);
}
testStartWithKey = function() {
- TestUtils.startIgniteNodeWithKey("secret-key", onStart);
+ TestUtils.startIgniteNodeWithKey("secret-key", onStart);
}
testStartWithIncorrectKey = function() {
- TestUtils.startIgniteNodeWithKey("secret-key1", onIncorrectStart);
+ TestUtils.startIgniteNodeWithKey("secret-key1", onIncorrectStart);
}
function onIncorrectStart(error, ignite) {
- assert(error != null, "Do not get authentication error");
+ assert(error != null, "Do not get authentication error");
- assert(error.indexOf("Authentication failed. Status code 401.") !== -1, "Incorrect error message: " + error);
+ assert(error.indexOf("Authentication failed. Status code 401.") !== -1, "Incorrect error message: " + error);
- TestUtils.testDone();
+ TestUtils.testDone();
}
function onStart(error, ignite) {
- assert(error === null, "Get error: " + error);
+ assert(error === null, "Get error: " + error);
- assert(ignite !== null, "Cannot connect. Get null ignite.");
+ assert(ignite !== null, "Cannot connect. Get null ignite.");
- var cache = ignite.cache("mycache");
+ var cache = ignite.cache("mycache");
- assert(cache !== null, "Cache is null.")
+ assert(cache !== null, "Cache is null.")
- cache.put("key", "6", onPut);
+ cache.put("key", "6", onPut);
}
function onPut(error) {
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f9f98acb/modules/nodejs/src/test/js/test-utils.js
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/test/js/test-utils.js b/modules/nodejs/src/test/js/test-utils.js
index ae2f0f0..0b0aebb 100644
--- a/modules/nodejs/src/test/js/test-utils.js
+++ b/modules/nodejs/src/test/js/test-utils.js
@@ -27,26 +27,26 @@ function TestUtils() {
* @returns {string} Path to script dir
*/
TestUtils.scriptPath = function() {
- return TestUtils.igniteHome() +
- TestUtils.sep() + "modules" +
- TestUtils.sep() + "nodejs" +
- TestUtils.sep() + "src" +
- TestUtils.sep() + "main" +
- TestUtils.sep() + "js" + TestUtils.sep();
+ return TestUtils.igniteHome() +
+ TestUtils.sep() + "modules" +
+ TestUtils.sep() + "nodejs" +
+ TestUtils.sep() + "src" +
+ TestUtils.sep() + "main" +
+ TestUtils.sep() + "js" + TestUtils.sep();
}
/**
* @returns {string} Ignite home path
*/
TestUtils.igniteHome = function() {
- return process.env.IGNITE_HOME;
+ return process.env.IGNITE_HOME;
}
/**
* @returns {string} Path separator
*/
TestUtils.sep = function() {
- return require('path').sep;
+ return require('path').sep;
}
/**
@@ -54,61 +54,61 @@ TestUtils.sep = function() {
* @returns {string} Classpath for ignite node start
*/
TestUtils.classpath = function(dir) {
- var fs = require('fs');
- var path = require('path');
- function walk(dir, done) {
- var results = [];
- var list = fs.readdirSync(dir)
-
- for (var i = 0; i < list.length; ++i) {
- file = path.resolve(dir, list[i]);
-
- var stat = fs.statSync(file);
-
- if (stat && stat.isDirectory()) {
- if (list[i] != "optional" && file.indexOf("optional") !== -1 && file.indexOf("rest") == -1 )
- continue;
-
- var sublist = walk(file);
- results = results.concat(sublist);
- }
- else {
- if (file.indexOf(".jar") !== -1) {
- results.push(file);
+ var fs = require('fs');
+ var path = require('path');
+ function walk(dir, done) {
+ var results = [];
+ var list = fs.readdirSync(dir)
+
+ for (var i = 0; i < list.length; ++i) {
+ file = path.resolve(dir, list[i]);
+
+ var stat = fs.statSync(file);
+
+ if (stat && stat.isDirectory()) {
+ if (list[i] != "optional" && file.indexOf("optional") !== -1 && file.indexOf("rest") == -1 )
+ continue;
+
+ var sublist = walk(file);
+ results = results.concat(sublist);
+ }
+ else {
+ if (file.indexOf(".jar") !== -1) {
+ results.push(file);
+ }
+ }
}
- }
- }
- return results;
- };
+ return results;
+ };
- return walk(dir);
+ return walk(dir);
};
/**
* @returns Process that starts ignite node
*/
TestUtils.startIgniteNode = function() {
- var libs = classpath(igniteHome() + TestUtils.sep() + "target" +
- TestUtils.sep() + "bin" +
- TestUtils.sep() + "apache-ignite-fabric-1.1.1-SNAPSHOT-bin" +
- TestUtils.sep() + "libs");
+ var libs = classpath(igniteHome() + TestUtils.sep() + "target" +
+ TestUtils.sep() + "bin" +
+ TestUtils.sep() + "apache-ignite-fabric-1.1.1-SNAPSHOT-bin" +
+ TestUtils.sep() + "libs");
- var cp = libs.join(require('path').delimiter);
+ var cp = libs.join(require('path').delimiter);
- var spawn = require('child_process').spawn;
+ var spawn = require('child_process').spawn;
- var child = spawn('java',['-classpath', cp, 'org.apache.ignite.startup.cmdline.CommandLineStartup',
- "test-node.xml"]);
+ var child = spawn('java',['-classpath', cp, 'org.apache.ignite.startup.cmdline.CommandLineStartup',
+ "test-node.xml"]);
- child.stdout.on('data', function (data) {
- console.log("" + data);
- });
+ child.stdout.on('data', function (data) {
+ console.log("" + data);
+ });
- child.stderr.on('data', function (data) {
- console.log("" + data);
- });
+ child.stderr.on('data', function (data) {
+ console.log("" + data);
+ });
- return child;
+ return child;
}
/**
@@ -117,14 +117,14 @@ TestUtils.startIgniteNode = function() {
* @param {string} error Error
*/
TestUtils.testFails = function(error) {
- console.log("Node JS test failed: " + error);
+ console.log("Node JS test failed: " + error);
}
/**
* Print ok message to console
*/
TestUtils.testDone = function() {
- console.log("Node JS test finished.")
+ console.log("Node JS test finished.")
}
/**
@@ -133,10 +133,10 @@ TestUtils.testDone = function() {
* @param {Ignition~onStart} callback Called on connect
*/
TestUtils.startIgniteNode = function(callback) {
- var Ignite = require(TestUtils.scriptPath());
- var Ignition = Ignite.Ignition;
+ var Ignite = require(TestUtils.scriptPath());
+ var Ignition = Ignite.Ignition;
- Ignition.start(['127.0.0.1:9095'], null, callback);
+ Ignition.start(['127.0.0.1:9095'], null, callback);
}
/**
@@ -146,10 +146,10 @@ TestUtils.startIgniteNode = function(callback) {
* @param {Ignition~onStart} callback Called on connect
*/
TestUtils.startIgniteNodeWithKey = function(secretKey, callback) {
- var Ignite = require(TestUtils.scriptPath());
- var Ignition = Ignite.Ignition;
+ var Ignite = require(TestUtils.scriptPath());
+ var Ignition = Ignite.Ignition;
- Ignition.start(['127.0.0.1:9095'], secretKey, callback);
+ Ignition.start(['127.0.0.1:9095'], secretKey, callback);
}
exports.TestUtils = TestUtils;
[2/4] incubator-ignite git commit: #ignite-965: one
IgniteScriptingCommandHandler.
Posted by sb...@apache.org.
#ignite-965: one IgniteScriptingCommandHandler.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/39ab970f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/39ab970f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/39ab970f
Branch: refs/heads/ignite-965
Commit: 39ab970f55cfd56c1f4aa622a395b47544f8492a
Parents: f9f98ac
Author: ivasilinets <iv...@gridgain.com>
Authored: Wed Jun 24 12:35:59 2015 +0300
Committer: ivasilinets <iv...@gridgain.com>
Committed: Wed Jun 24 12:35:59 2015 +0300
----------------------------------------------------------------------
.../processors/rest/GridRestProcessor.java | 5 +-
.../compute/IgniteComputeCommandHandler.java | 93 --------
.../IgniteComputeTaskCommandHandler.java | 167 ---------------
.../IgniteScriptingCommandHandler.java | 212 +++++++++++++++++++
4 files changed, 214 insertions(+), 263 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/39ab970f/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java
index 594e592..5d886fc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java
@@ -24,7 +24,7 @@ import org.apache.ignite.internal.processors.*;
import org.apache.ignite.internal.processors.rest.client.message.*;
import org.apache.ignite.internal.processors.rest.handlers.*;
import org.apache.ignite.internal.processors.rest.handlers.cache.*;
-import org.apache.ignite.internal.processors.rest.handlers.compute.*;
+import org.apache.ignite.internal.processors.rest.handlers.scripting.*;
import org.apache.ignite.internal.processors.rest.handlers.datastructures.*;
import org.apache.ignite.internal.processors.rest.handlers.task.*;
import org.apache.ignite.internal.processors.rest.handlers.top.*;
@@ -289,8 +289,7 @@ public class GridRestProcessor extends GridProcessorAdapter {
addHandler(new GridTopologyCommandHandler(ctx));
addHandler(new GridVersionCommandHandler(ctx));
addHandler(new DataStructuresCommandHandler(ctx));
- addHandler(new IgniteComputeCommandHandler(ctx));
- addHandler(new IgniteComputeTaskCommandHandler(ctx));
+ addHandler(new IgniteScriptingCommandHandler(ctx));
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/39ab970f/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/compute/IgniteComputeCommandHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/compute/IgniteComputeCommandHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/compute/IgniteComputeCommandHandler.java
deleted file mode 100644
index 26246f5..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/compute/IgniteComputeCommandHandler.java
+++ /dev/null
@@ -1,93 +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.
- */
-
-package org.apache.ignite.internal.processors.rest.handlers.compute;
-
-import org.apache.ignite.*;
-import org.apache.ignite.internal.*;
-import org.apache.ignite.internal.processors.rest.*;
-import org.apache.ignite.internal.processors.rest.handlers.*;
-import org.apache.ignite.internal.processors.rest.request.*;
-import org.apache.ignite.internal.util.future.*;
-import org.apache.ignite.internal.util.typedef.internal.*;
-import org.apache.ignite.lang.*;
-import org.apache.ignite.resources.*;
-
-import java.util.*;
-
-import static org.apache.ignite.internal.processors.rest.GridRestCommand.*;
-
-/**
- * Compute command handler.
- */
-public class IgniteComputeCommandHandler extends GridRestCommandHandlerAdapter {
- /** Supported commands. */
- private static final Collection<GridRestCommand> SUPPORTED_COMMANDS = U.sealList(
- AFFINITY_RUN,
- AFFINITY_CALL);
-
- /**
- * @param ctx Context.
- */
- public IgniteComputeCommandHandler(GridKernalContext ctx) {
- super(ctx);
- }
-
- /** {@inheritDoc} */
- @Override public Collection<GridRestCommand> supportedCommands() {
- return SUPPORTED_COMMANDS;
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<GridRestResponse> handleAsync(GridRestRequest req) {
- assert req != null;
-
- assert req instanceof RestComputeRequest : "Invalid type of compute request.";
-
- assert SUPPORTED_COMMANDS.contains(req.command());
-
- final RestComputeRequest req0 = (RestComputeRequest) req;
-
- switch (req.command()) {
- case AFFINITY_RUN:
- ctx.grid().compute().affinityRun(req0.cacheName(), req0.key(), new IgniteRunnable() {
- @IgniteInstanceResource
- private Ignite ignite;
-
- @Override public void run() {
- ((IgniteKernal) ignite).context().scripting().invokeFunction(req0.function());
- }
- });
-
- return new GridFinishedFuture<>(new GridRestResponse());
-
- case AFFINITY_CALL:
- Object res = ctx.grid().compute().affinityCall(req0.cacheName(), req0.key(), new IgniteCallable<Object>() {
- @IgniteInstanceResource
- private Ignite ignite;
-
- @Override public Object call() {
- return ((IgniteKernal) ignite).context().scripting().invokeFunction(req0.function());
- }
- });
-
- return new GridFinishedFuture<>(new GridRestResponse(res));
- }
-
- return new GridFinishedFuture<>();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/39ab970f/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/compute/IgniteComputeTaskCommandHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/compute/IgniteComputeTaskCommandHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/compute/IgniteComputeTaskCommandHandler.java
deleted file mode 100644
index cbf113c..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/compute/IgniteComputeTaskCommandHandler.java
+++ /dev/null
@@ -1,167 +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.
- */
-
-package org.apache.ignite.internal.processors.rest.handlers.compute;
-
-import org.apache.ignite.*;
-import org.apache.ignite.cluster.*;
-import org.apache.ignite.compute.*;
-import org.apache.ignite.internal.*;
-import org.apache.ignite.internal.processors.rest.*;
-import org.apache.ignite.internal.processors.rest.handlers.*;
-import org.apache.ignite.internal.processors.rest.request.*;
-import org.apache.ignite.internal.processors.scripting.*;
-import org.apache.ignite.internal.util.future.*;
-import org.apache.ignite.internal.util.typedef.internal.*;
-import org.apache.ignite.resources.*;
-import org.jetbrains.annotations.*;
-
-import java.util.*;
-
-import static org.apache.ignite.internal.processors.rest.GridRestCommand.*;
-
-/**
- * Compute task command handler.
- */
-public class IgniteComputeTaskCommandHandler extends GridRestCommandHandlerAdapter {
- /** Supported commands. */
- private static final Collection<GridRestCommand> SUPPORTED_COMMANDS = U.sealList(EXECUTE_TASK);
-
- /**
- * @param ctx Context.
- */
- public IgniteComputeTaskCommandHandler(GridKernalContext ctx) {
- super(ctx);
-
- IgniteScriptProcessor script = ctx.scripting();
-
- String emitFunction = "function emit(result, f, args, nodeId) {result.push([f.toString(), args, nodeId])}";
-
- String computeFunction = "function __compute(mapFuncSource, ids, args) {" +
- " var res = [];" +
- " var f = __createJSFunction(mapFuncSource);" +
- " f(ids, args, emit.bind(null, res)); " +
- " return res;" +
- " }";
-
- script.addEngineFunction(emitFunction);
- script.addEngineFunction(computeFunction);
- }
-
- /** {@inheritDoc} */
- @Override public Collection<GridRestCommand> supportedCommands() {
- return SUPPORTED_COMMANDS;
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<GridRestResponse> handleAsync(GridRestRequest req) {
- assert req != null;
-
- assert req instanceof RestComputeTaskRequest : "Invalid type of compute task request.";
-
- assert SUPPORTED_COMMANDS.contains(req.command());
-
- final RestComputeTaskRequest req0 = (RestComputeTaskRequest) req;
-
- Object execRes = ctx.grid().compute().execute(
- new JsTask(req0.mapFunction(), req0.argument(), req0.reduceFunction(), ctx), null);
-
- return new GridFinishedFuture<>(new GridRestResponse(execRes));
- }
-
- /**
- * JS Compute Task.
- */
- private static class JsTask extends ComputeTaskAdapter<String, Object> {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** Mapping function. */
- private String mapFunc;
-
- /** Reduce function. */
- private String reduceFunc;
-
- /** Kernal context. */
- private GridKernalContext ctx;
-
- /** Map function argument. */
- private String arg;
-
- /**
- * @param mapFunc Map function.
- * @param arg Map function argument.
- * @param reduceFunc Reduce function.
- * @param ctx Kernal context.
- */
- public JsTask(String mapFunc, String arg, String reduceFunc, GridKernalContext ctx) {
- this.mapFunc = mapFunc;
- this.reduceFunc = reduceFunc;
- this.arg = arg;
- this.ctx = ctx;
- }
-
- /** {@inheritDoc} */
- @Override public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> nodes, String arg) {
- Map<ComputeJob, ClusterNode> map = new HashMap<>();
-
- String[] ids = new String[nodes.size()];
-
- for (int i = 0; i < ids.length; ++i)
- ids[i] = nodes.get(i).id().toString();
-
- List jsMapRes = (List)ctx.scripting().invokeFunctionByName("__compute",
- mapFunc, ids, this.arg);
-
- for (Object jobMapping : jsMapRes) {
- List task = (List)jobMapping;
-
- final String func = (String)task.get(0);
- final List argv = (List)task.get(1);
- String nodeId = (String)task.get(2);
-
- ClusterNode node = ctx.grid().cluster().node(UUID.fromString(nodeId));
-
- map.put(new ComputeJobAdapter() {
- @IgniteInstanceResource
- private Ignite ignite;
-
- @Override public Object execute() throws IgniteException {
- String[] argv1 = new String[argv.size()];
-
- for (int i = 0; i < argv1.length; ++i)
- argv1[i] = argv.get(i).toString();
-
- return ((IgniteKernal)ignite).context().scripting().invokeFunction(func, argv1);
- }
- }, node);
- }
-
- return map;
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public Object reduce(List<ComputeJobResult> results) {
- String[] data = new String[results.size()];
-
- for (int i = 0; i < results.size(); ++i)
- data[i] = results.get(i).getData().toString();
-
- return ctx.scripting().invokeFunction(reduceFunc, (Object)data);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/39ab970f/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/scripting/IgniteScriptingCommandHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/scripting/IgniteScriptingCommandHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/scripting/IgniteScriptingCommandHandler.java
new file mode 100644
index 0000000..b402902
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/scripting/IgniteScriptingCommandHandler.java
@@ -0,0 +1,212 @@
+/*
+ * 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.
+ */
+
+package org.apache.ignite.internal.processors.rest.handlers.scripting;
+
+import org.apache.ignite.*;
+import org.apache.ignite.cluster.*;
+import org.apache.ignite.compute.*;
+import org.apache.ignite.internal.*;
+import org.apache.ignite.internal.processors.rest.*;
+import org.apache.ignite.internal.processors.rest.handlers.*;
+import org.apache.ignite.internal.processors.rest.request.*;
+import org.apache.ignite.internal.processors.scripting.*;
+import org.apache.ignite.internal.util.future.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
+import org.apache.ignite.lang.*;
+import org.apache.ignite.resources.*;
+import org.jetbrains.annotations.*;
+
+import java.util.*;
+
+import static org.apache.ignite.internal.processors.rest.GridRestCommand.*;
+
+/**
+ * Compute task command handler.
+ */
+public class IgniteScriptingCommandHandler extends GridRestCommandHandlerAdapter {
+ /** Supported commands. */
+ private static final Collection<GridRestCommand> SUPPORTED_COMMANDS = U.sealList(EXECUTE_TASK,
+ AFFINITY_RUN,
+ AFFINITY_CALL);
+
+ /**
+ * @param ctx Context.
+ */
+ public IgniteScriptingCommandHandler(GridKernalContext ctx) {
+ super(ctx);
+
+ IgniteScriptProcessor script = ctx.scripting();
+
+ String emitFunction = "function emit(result, f, args, nodeId) {result.push([f.toString(), args, nodeId])}";
+
+ String computeFunction = "function __compute(mapFuncSource, ids, args) {" +
+ " var res = [];" +
+ " var f = __createJSFunction(mapFuncSource);" +
+ " f(ids, args, emit.bind(null, res)); " +
+ " return res;" +
+ " }";
+
+ script.addEngineFunction(emitFunction);
+ script.addEngineFunction(computeFunction);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Collection<GridRestCommand> supportedCommands() {
+ return SUPPORTED_COMMANDS;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteInternalFuture<GridRestResponse> handleAsync(GridRestRequest req) {
+ assert req != null;
+
+ assert SUPPORTED_COMMANDS.contains(req.command());
+
+ switch (req.command()) {
+ case AFFINITY_RUN: {
+ assert req instanceof RestComputeRequest : "Invalid type of compute request.";
+
+ final RestComputeRequest req0 = (RestComputeRequest) req;
+
+ ctx.grid().compute().affinityRun(req0.cacheName(), req0.key(), new IgniteRunnable() {
+ @IgniteInstanceResource
+ private Ignite ignite;
+
+ @Override public void run() {
+ ((IgniteKernal) ignite).context().scripting().invokeFunction(req0.function());
+ }
+ });
+
+ return new GridFinishedFuture<>(new GridRestResponse());
+ }
+
+ case AFFINITY_CALL: {
+ assert req instanceof RestComputeRequest : "Invalid type of compute request.";
+
+ final RestComputeRequest req0 = (RestComputeRequest) req;
+
+ Object callRes = ctx.grid().compute().affinityCall(req0.cacheName(), req0.key(), new IgniteCallable<Object>() {
+ @IgniteInstanceResource
+ private Ignite ignite;
+
+ @Override public Object call() {
+ return ((IgniteKernal) ignite).context().scripting().invokeFunction(req0.function());
+ }
+ });
+
+ return new GridFinishedFuture<>(new GridRestResponse(callRes));
+ }
+
+ case EXECUTE_TASK: {
+ assert req instanceof RestComputeTaskRequest : "Invalid type of compute task request.";
+
+ assert SUPPORTED_COMMANDS.contains(req.command());
+
+ final RestComputeTaskRequest req0 = (RestComputeTaskRequest) req;
+
+ Object execRes = ctx.grid().compute().execute(
+ new JsTask(req0.mapFunction(), req0.argument(), req0.reduceFunction(), ctx), null);
+
+ return new GridFinishedFuture<>(new GridRestResponse(execRes));
+ }
+ }
+
+ return new GridFinishedFuture<>();
+ }
+
+ /**
+ * JS Compute Task.
+ */
+ private static class JsTask extends ComputeTaskAdapter<String, Object> {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** Mapping function. */
+ private String mapFunc;
+
+ /** Reduce function. */
+ private String reduceFunc;
+
+ /** Kernal context. */
+ private GridKernalContext ctx;
+
+ /** Map function argument. */
+ private String arg;
+
+ /**
+ * @param mapFunc Map function.
+ * @param arg Map function argument.
+ * @param reduceFunc Reduce function.
+ * @param ctx Kernal context.
+ */
+ public JsTask(String mapFunc, String arg, String reduceFunc, GridKernalContext ctx) {
+ this.mapFunc = mapFunc;
+ this.reduceFunc = reduceFunc;
+ this.arg = arg;
+ this.ctx = ctx;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> nodes, String arg) {
+ Map<ComputeJob, ClusterNode> map = new HashMap<>();
+
+ String[] ids = new String[nodes.size()];
+
+ for (int i = 0; i < ids.length; ++i)
+ ids[i] = nodes.get(i).id().toString();
+
+ List jsMapRes = (List)ctx.scripting().invokeFunctionByName("__compute",
+ mapFunc, ids, this.arg);
+
+ for (Object jobMapping : jsMapRes) {
+ List task = (List)jobMapping;
+
+ final String func = (String)task.get(0);
+ final List argv = (List)task.get(1);
+ String nodeId = (String)task.get(2);
+
+ ClusterNode node = ctx.grid().cluster().node(UUID.fromString(nodeId));
+
+ map.put(new ComputeJobAdapter() {
+ @IgniteInstanceResource
+ private Ignite ignite;
+
+ @Override public Object execute() throws IgniteException {
+ String[] argv1 = new String[argv.size()];
+
+ for (int i = 0; i < argv1.length; ++i)
+ argv1[i] = argv.get(i).toString();
+
+ return ((IgniteKernal)ignite).context().scripting().invokeFunction(func, argv1);
+ }
+ }, node);
+ }
+
+ return map;
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public Object reduce(List<ComputeJobResult> results) {
+ String[] data = new String[results.size()];
+
+ for (int i = 0; i < results.size(); ++i)
+ data[i] = results.get(i).getData().toString();
+
+ return ctx.scripting().invokeFunction(reduceFunc, (Object)data);
+ }
+ }
+}
[3/4] incubator-ignite git commit: #ignite-965: two commands
EXECUTE_MAP_REDUCE_SCRIPT and RUN_SCRIPT.
Posted by sb...@apache.org.
#ignite-965: two commands EXECUTE_MAP_REDUCE_SCRIPT and RUN_SCRIPT.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/64d11083
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/64d11083
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/64d11083
Branch: refs/heads/ignite-965
Commit: 64d1108375db152c42d6208bb41e89855687c1df
Parents: 39ab970
Author: ivasilinets <iv...@gridgain.com>
Authored: Wed Jun 24 12:48:51 2015 +0300
Committer: ivasilinets <iv...@gridgain.com>
Committed: Wed Jun 24 12:48:51 2015 +0300
----------------------------------------------------------------------
.../processors/rest/GridRestCommand.java | 11 ++-
.../IgniteScriptingCommandHandler.java | 40 ++++-------
.../rest/request/RestComputeRequest.java | 74 --------------------
.../rest/request/RestComputeTaskRequest.java | 74 --------------------
.../request/RestMapReduceScriptRequest.java | 74 ++++++++++++++++++++
.../rest/request/RestRunScriptRequest.java | 40 +++++++++++
modules/nodejs/src/main/js/compute.js | 18 +----
.../ignite/internal/NodeJsComputeSelfTest.java | 11 +--
modules/nodejs/src/test/js/test-compute.js | 30 ++------
.../http/jetty/GridJettyRestHandler.java | 13 ++--
10 files changed, 144 insertions(+), 241 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/64d11083/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestCommand.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestCommand.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestCommand.java
index f964cb4..4ee672d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestCommand.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestCommand.java
@@ -96,14 +96,11 @@ public enum GridRestCommand {
/** Quit. */
QUIT("quit"),
- /** Affinity run. */
- AFFINITY_RUN("affscriptrun"),
+ /** Run script. */
+ RUN_SCRIPT("runscript"),
- /** Affinity call. */
- AFFINITY_CALL("affscriptcall"),
-
- /** Execute task. */
- EXECUTE_TASK("execscripttask");
+ /** Execute map reduce script. */
+ EXECUTE_MAP_REDUCE_SCRIPT("excmapreduce");
/** Enum values. */
private static final GridRestCommand[] VALS = values();
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/64d11083/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/scripting/IgniteScriptingCommandHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/scripting/IgniteScriptingCommandHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/scripting/IgniteScriptingCommandHandler.java
index b402902..687f72a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/scripting/IgniteScriptingCommandHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/scripting/IgniteScriptingCommandHandler.java
@@ -40,9 +40,9 @@ import static org.apache.ignite.internal.processors.rest.GridRestCommand.*;
*/
public class IgniteScriptingCommandHandler extends GridRestCommandHandlerAdapter {
/** Supported commands. */
- private static final Collection<GridRestCommand> SUPPORTED_COMMANDS = U.sealList(EXECUTE_TASK,
- AFFINITY_RUN,
- AFFINITY_CALL);
+ private static final Collection<GridRestCommand> SUPPORTED_COMMANDS = U.sealList(
+ EXECUTE_MAP_REDUCE_SCRIPT,
+ RUN_SCRIPT);
/**
* @param ctx Context.
@@ -77,46 +77,30 @@ public class IgniteScriptingCommandHandler extends GridRestCommandHandlerAdapter
assert SUPPORTED_COMMANDS.contains(req.command());
switch (req.command()) {
- case AFFINITY_RUN: {
- assert req instanceof RestComputeRequest : "Invalid type of compute request.";
+ case RUN_SCRIPT: {
+ assert req instanceof RestRunScriptRequest : "Invalid type of run script request.";
- final RestComputeRequest req0 = (RestComputeRequest) req;
+ final RestRunScriptRequest req0 = (RestRunScriptRequest) req;
- ctx.grid().compute().affinityRun(req0.cacheName(), req0.key(), new IgniteRunnable() {
- @IgniteInstanceResource
- private Ignite ignite;
-
- @Override public void run() {
- ((IgniteKernal) ignite).context().scripting().invokeFunction(req0.function());
- }
- });
-
- return new GridFinishedFuture<>(new GridRestResponse());
- }
-
- case AFFINITY_CALL: {
- assert req instanceof RestComputeRequest : "Invalid type of compute request.";
-
- final RestComputeRequest req0 = (RestComputeRequest) req;
-
- Object callRes = ctx.grid().compute().affinityCall(req0.cacheName(), req0.key(), new IgniteCallable<Object>() {
+ Object callRes = ctx.grid().compute().call(new IgniteCallable<Object>() {
@IgniteInstanceResource
private Ignite ignite;
@Override public Object call() {
- return ((IgniteKernal) ignite).context().scripting().invokeFunction(req0.function());
+ return ((IgniteKernal) ignite).context().scripting().invokeFunction(req0.script());
}
});
return new GridFinishedFuture<>(new GridRestResponse(callRes));
}
- case EXECUTE_TASK: {
- assert req instanceof RestComputeTaskRequest : "Invalid type of compute task request.";
+ case EXECUTE_MAP_REDUCE_SCRIPT: {
+ assert req instanceof RestMapReduceScriptRequest :
+ "Invalid type of execute map reduce script request.";
assert SUPPORTED_COMMANDS.contains(req.command());
- final RestComputeTaskRequest req0 = (RestComputeTaskRequest) req;
+ final RestMapReduceScriptRequest req0 = (RestMapReduceScriptRequest) req;
Object execRes = ctx.grid().compute().execute(
new JsTask(req0.mapFunction(), req0.argument(), req0.reduceFunction(), ctx), null);
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/64d11083/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/RestComputeRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/RestComputeRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/RestComputeRequest.java
deleted file mode 100644
index 809947e..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/RestComputeRequest.java
+++ /dev/null
@@ -1,74 +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.
- */
-
-package org.apache.ignite.internal.processors.rest.request;
-
-/**
- * Compute request.
- */
-public class RestComputeRequest extends GridRestRequest {
- /** Java script function. */
- private String func;
-
- /** Cache name. */
- private String cacheName;
-
- /** Key. */
- private Object key;
-
- /**
- * @return Java script function.
- */
- public String function() {
- return func;
- }
-
- /**
- * @param func Java script function.
- */
- public void function(String func) {
- this.func = func;
- }
-
- /**
- * @return Cache name.
- */
- public String cacheName() {
- return cacheName;
- }
-
- /**
- * @param cacheName Cache name.
- */
- public void cacheName(String cacheName) {
- this.cacheName = cacheName;
- }
-
- /**
- * @param key Key.
- */
- public void key(Object key) {
- this.key = key;
- }
-
- /**
- * @return Key.
- */
- public Object key() {
- return key;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/64d11083/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/RestComputeTaskRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/RestComputeTaskRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/RestComputeTaskRequest.java
deleted file mode 100644
index cf5c7c0..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/RestComputeTaskRequest.java
+++ /dev/null
@@ -1,74 +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.
- */
-
-package org.apache.ignite.internal.processors.rest.request;
-
-/**
- * Compute task request.
- */
-public class RestComputeTaskRequest extends GridRestRequest {
- /** Mapping tasks to nodes. */
- private String mapFunc;
-
- /** Function argument. */
- private String arg;
-
- /** Reduce function. */
- private String reduceFunc;
-
- /**
- * @param reduceFunc Reduce function.
- */
- public void reduceFunction(String reduceFunc) {
- this.reduceFunc = reduceFunc;
- }
-
- /**
- * @return Reduce function.
- */
- public String reduceFunction() {
- return reduceFunc;
- }
-
- /**
- * @param mapFunc Map function.
- */
- public void mapFunction(String mapFunc) {
- this.mapFunc = mapFunc;
- }
-
- /**
- * @return Map function.
- */
- public String mapFunction() {
- return mapFunc;
- }
-
- /**
- * @param arg Argument.
- */
- public void argument(String arg) {
- this.arg = arg;
- }
-
- /**
- * @return Argument.
- */
- public String argument() {
- return arg;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/64d11083/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/RestMapReduceScriptRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/RestMapReduceScriptRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/RestMapReduceScriptRequest.java
new file mode 100644
index 0000000..c21fcf4
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/RestMapReduceScriptRequest.java
@@ -0,0 +1,74 @@
+/*
+ * 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.
+ */
+
+package org.apache.ignite.internal.processors.rest.request;
+
+/**
+ * Execute map reduce script request.
+ */
+public class RestMapReduceScriptRequest extends GridRestRequest {
+ /** Mapping tasks to nodes. */
+ private String mapFunc;
+
+ /** Function argument. */
+ private String arg;
+
+ /** Reduce function. */
+ private String reduceFunc;
+
+ /**
+ * @param reduceFunc Reduce function.
+ */
+ public void reduceFunction(String reduceFunc) {
+ this.reduceFunc = reduceFunc;
+ }
+
+ /**
+ * @return Reduce function.
+ */
+ public String reduceFunction() {
+ return reduceFunc;
+ }
+
+ /**
+ * @param mapFunc Map function.
+ */
+ public void mapFunction(String mapFunc) {
+ this.mapFunc = mapFunc;
+ }
+
+ /**
+ * @return Map function.
+ */
+ public String mapFunction() {
+ return mapFunc;
+ }
+
+ /**
+ * @param arg Argument.
+ */
+ public void argument(String arg) {
+ this.arg = arg;
+ }
+
+ /**
+ * @return Argument.
+ */
+ public String argument() {
+ return arg;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/64d11083/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/RestRunScriptRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/RestRunScriptRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/RestRunScriptRequest.java
new file mode 100644
index 0000000..42aba76
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/RestRunScriptRequest.java
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ */
+
+package org.apache.ignite.internal.processors.rest.request;
+
+/**
+ * Run script request.
+ */
+public class RestRunScriptRequest extends GridRestRequest {
+ /** Java script function. */
+ private String script;
+
+ /**
+ * @return Java script function.
+ */
+ public String script() {
+ return script;
+ }
+
+ /**
+ * @param script Java script function.
+ */
+ public void script(String script) {
+ this.script = script;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/64d11083/modules/nodejs/src/main/js/compute.js
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/main/js/compute.js b/modules/nodejs/src/main/js/compute.js
index 01361d5..c7a386e 100644
--- a/modules/nodejs/src/main/js/compute.js
+++ b/modules/nodejs/src/main/js/compute.js
@@ -30,23 +30,11 @@ function Compute(server) {
* @this {Compute}
* @param {string} cacheName Cache name
* @param {string} key Key
- * @param runnable Function without parameters and return value
- * @param {noValue} callback Callback
- */
-Compute.prototype.affinityRun = function(cacheName, key, runnable, callback) {
- this._server.runCommand("affscriptrun", [Server.pair("cacheName", cacheName),
- Server.pair("key", key), Server.pair("func", this._escape(runnable))], callback);
-}
-
-/**
- * @this {Compute}
- * @param {string} cacheName Cache name
- * @param {string} key Key
* @param runnable Function without parameters
* @param {onGet} callback Callback
*/
-Compute.prototype.affinityCall = function(cacheName, key, runnable, callback) {
- this._server.runCommand("affscriptcall", [Server.pair("cacheName", cacheName),
+Compute.prototype.runScript = function(cacheName, key, runnable, callback) {
+ this._server.runCommand("runscript", [Server.pair("cacheName", cacheName),
Server.pair("key", key), Server.pair("func", this._escape(runnable))], callback);
}
@@ -64,7 +52,7 @@ Compute.prototype.execute = function(map, reduce, arg, callback) {
params.push(Server.pair("reduce", this._escape(reduce)));
params.push(Server.pair("arg", this._escape(arg)));
- this._server.runCommand("execscripttask", params, callback);
+ this._server.runCommand("excmapreduce", params, callback);
}
/**
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/64d11083/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsComputeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsComputeSelfTest.java b/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsComputeSelfTest.java
index 5c4635d..82afe9b 100644
--- a/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsComputeSelfTest.java
+++ b/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsComputeSelfTest.java
@@ -41,15 +41,8 @@ public class NodeJsComputeSelfTest extends NodeJsAbstractTest {
/**
* @throws Exception If failed.
*/
- public void testComputeAffinityRun() throws Exception {
- runJsScript("testComputeAffinityRun");
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testComputeAffinityCall() throws Exception {
- runJsScript("testComputeAffinityCall");
+ public void testComputeRunScript() throws Exception {
+ runJsScript("testComputeRunScript");
}
/**
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/64d11083/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 a494f3e..13b2ecf 100644
--- a/modules/nodejs/src/test/js/test-compute.js
+++ b/modules/nodejs/src/test/js/test-compute.js
@@ -19,12 +19,8 @@ var TestUtils = require("./test-utils").TestUtils;
var assert = require("assert");
-testComputeAffinityRun = function() {
- TestUtils.startIgniteNode(onStart.bind(null, computeAffinityRun));
-}
-
-testComputeAffinityCall = function() {
- TestUtils.startIgniteNode(onStart.bind(null, computeAffinityCall));
+testComputeRunScript = function() {
+ TestUtils.startIgniteNode(onStart.bind(null, computeRunScript));
}
testComputeExecute = function() {
@@ -43,25 +39,7 @@ function onStart(onPut, error, ignite) {
cache.putAll(params, onPut.bind(null, ignite))
}
-function computeAffinityRun(ignite, error) {
- var comp = ignite.compute();
-
- var f = function () {
- println("Hello world!");
-
- ignite.hello();
- }
-
- function onEnd(error) {
- assert(error == null);
-
- TestUtils.testDone();
- }
-
- comp.affinityRun("mycache", "key999", f, onEnd.bind(null));
-}
-
-function computeAffinityCall(ignite, error) {
+function computeRunScript(ignite, error) {
var comp = ignite.compute();
var f = function () {
@@ -75,7 +53,7 @@ function computeAffinityCall(ignite, error) {
TestUtils.testDone();
}
- comp.affinityCall("mycache", "key999", f, onEnd.bind(null));
+ comp.runScript("mycache", "key999", f, onEnd.bind(null));
}
function computeExecute(error, ignite) {
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/64d11083/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestHandler.java
----------------------------------------------------------------------
diff --git a/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestHandler.java b/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestHandler.java
index 0d961be..faffbf1 100644
--- a/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestHandler.java
+++ b/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestHandler.java
@@ -447,21 +447,18 @@ public class GridJettyRestHandler extends AbstractHandler {
break;
}
- case AFFINITY_RUN:
- case AFFINITY_CALL: {
- RestComputeRequest restReq0 = new RestComputeRequest();
+ case RUN_SCRIPT: {
+ RestRunScriptRequest restReq0 = new RestRunScriptRequest();
- restReq0.function((String)params.get("func"));
- restReq0.cacheName((String)params.get("cacheName"));
- restReq0.key(params.get("key"));
+ restReq0.script((String) params.get("func"));
restReq = restReq0;
break;
}
- case EXECUTE_TASK: {
- RestComputeTaskRequest restReq0 = new RestComputeTaskRequest();
+ case EXECUTE_MAP_REDUCE_SCRIPT: {
+ RestMapReduceScriptRequest restReq0 = new RestMapReduceScriptRequest();
restReq0.mapFunction((String) params.get("map"));
restReq0.argument((String)params.get("arg"));
[4/4] incubator-ignite git commit: #ignite-965: processor throws
ignite-checked exception.
Posted by sb...@apache.org.
#ignite-965: processor throws ignite-checked exception.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/b7f2393e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/b7f2393e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/b7f2393e
Branch: refs/heads/ignite-965
Commit: b7f2393e0d4bb4700b9d563295c85f2b122d4460
Parents: 64d1108
Author: ivasilinets <iv...@gridgain.com>
Authored: Wed Jun 24 13:06:32 2015 +0300
Committer: ivasilinets <iv...@gridgain.com>
Committed: Wed Jun 24 13:06:32 2015 +0300
----------------------------------------------------------------------
.../IgniteScriptingCommandHandler.java | 119 ++++++++++++-------
.../scripting/IgniteScriptProcessor.java | 15 ++-
2 files changed, 82 insertions(+), 52 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b7f2393e/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/scripting/IgniteScriptingCommandHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/scripting/IgniteScriptingCommandHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/scripting/IgniteScriptingCommandHandler.java
index 687f72a..839f412 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/scripting/IgniteScriptingCommandHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/scripting/IgniteScriptingCommandHandler.java
@@ -50,19 +50,24 @@ public class IgniteScriptingCommandHandler extends GridRestCommandHandlerAdapter
public IgniteScriptingCommandHandler(GridKernalContext ctx) {
super(ctx);
- IgniteScriptProcessor script = ctx.scripting();
+ try {
+ IgniteScriptProcessor script = ctx.scripting();
- String emitFunction = "function emit(result, f, args, nodeId) {result.push([f.toString(), args, nodeId])}";
+ String emitFunction = "function emit(result, f, args, nodeId) {result.push([f.toString(), args, nodeId])}";
- String computeFunction = "function __compute(mapFuncSource, ids, args) {" +
- " var res = [];" +
- " var f = __createJSFunction(mapFuncSource);" +
- " f(ids, args, emit.bind(null, res)); " +
- " return res;" +
- " }";
+ String computeFunction = "function __compute(mapFuncSource, ids, args) {" +
+ " var res = [];" +
+ " var f = __createJSFunction(mapFuncSource);" +
+ " f(ids, args, emit.bind(null, res)); " +
+ " return res;" +
+ " }";
- script.addEngineFunction(emitFunction);
- script.addEngineFunction(computeFunction);
+ script.addEngineFunction(emitFunction);
+ script.addEngineFunction(computeFunction);
+ }
+ catch (IgniteCheckedException e) {
+ ctx.log().error(e.getMessage());
+ }
}
/** {@inheritDoc} */
@@ -82,16 +87,22 @@ public class IgniteScriptingCommandHandler extends GridRestCommandHandlerAdapter
final RestRunScriptRequest req0 = (RestRunScriptRequest) req;
- Object callRes = ctx.grid().compute().call(new IgniteCallable<Object>() {
+ GridRestResponse res = ctx.grid().compute().call(new IgniteCallable<GridRestResponse>() {
@IgniteInstanceResource
private Ignite ignite;
- @Override public Object call() {
- return ((IgniteKernal) ignite).context().scripting().invokeFunction(req0.script());
+ @Override public GridRestResponse call() {
+ try {
+ return new GridRestResponse(((IgniteKernal)ignite).
+ context().scripting().invokeFunction(req0.script()));
+ }
+ catch (IgniteCheckedException e) {
+ return new GridRestResponse(GridRestResponse.STATUS_FAILED, e.getMessage());
+ }
}
});
- return new GridFinishedFuture<>(new GridRestResponse(callRes));
+ return new GridFinishedFuture<>(res);
}
case EXECUTE_MAP_REDUCE_SCRIPT: {
@@ -102,10 +113,10 @@ public class IgniteScriptingCommandHandler extends GridRestCommandHandlerAdapter
final RestMapReduceScriptRequest req0 = (RestMapReduceScriptRequest) req;
- Object execRes = ctx.grid().compute().execute(
+ GridRestResponse execRes = ctx.grid().compute().execute(
new JsTask(req0.mapFunction(), req0.argument(), req0.reduceFunction(), ctx), null);
- return new GridFinishedFuture<>(new GridRestResponse(execRes));
+ return new GridFinishedFuture<>(execRes);
}
}
@@ -115,7 +126,7 @@ public class IgniteScriptingCommandHandler extends GridRestCommandHandlerAdapter
/**
* JS Compute Task.
*/
- private static class JsTask extends ComputeTaskAdapter<String, Object> {
+ private static class JsTask extends ComputeTaskAdapter<String, GridRestResponse> {
/** */
private static final long serialVersionUID = 0L;
@@ -146,51 +157,67 @@ public class IgniteScriptingCommandHandler extends GridRestCommandHandlerAdapter
/** {@inheritDoc} */
@Override public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> nodes, String arg) {
- Map<ComputeJob, ClusterNode> map = new HashMap<>();
+ try {
+ Map<ComputeJob, ClusterNode> map = new HashMap<>();
- String[] ids = new String[nodes.size()];
+ String[] ids = new String[nodes.size()];
- for (int i = 0; i < ids.length; ++i)
- ids[i] = nodes.get(i).id().toString();
+ for (int i = 0; i < ids.length; ++i)
+ ids[i] = nodes.get(i).id().toString();
- List jsMapRes = (List)ctx.scripting().invokeFunctionByName("__compute",
- mapFunc, ids, this.arg);
+ List jsMapRes = (List)ctx.scripting().invokeFunctionByName("__compute",
+ mapFunc, ids, this.arg);
- for (Object jobMapping : jsMapRes) {
- List task = (List)jobMapping;
+ for (Object jobMapping : jsMapRes) {
+ List task = (List)jobMapping;
- final String func = (String)task.get(0);
- final List argv = (List)task.get(1);
- String nodeId = (String)task.get(2);
+ final String func = (String)task.get(0);
+ final List argv = (List)task.get(1);
+ String nodeId = (String)task.get(2);
- ClusterNode node = ctx.grid().cluster().node(UUID.fromString(nodeId));
+ ClusterNode node = ctx.grid().cluster().node(UUID.fromString(nodeId));
- map.put(new ComputeJobAdapter() {
- @IgniteInstanceResource
- private Ignite ignite;
+ map.put(new ComputeJobAdapter() {
+ @IgniteInstanceResource
+ private Ignite ignite;
- @Override public Object execute() throws IgniteException {
- String[] argv1 = new String[argv.size()];
+ @Override public Object execute() throws IgniteException {
+ try {
+ String[] argv1 = new String[argv.size()];
- for (int i = 0; i < argv1.length; ++i)
- argv1[i] = argv.get(i).toString();
+ for (int i = 0; i < argv1.length; ++i)
+ argv1[i] = argv.get(i).toString();
- return ((IgniteKernal)ignite).context().scripting().invokeFunction(func, argv1);
- }
- }, node);
- }
- return map;
+ return ((IgniteKernal)ignite).context().scripting().invokeFunction(func, argv1);
+ }
+ catch (IgniteCheckedException e) {
+ throw U.convertException(e);
+ }
+ }
+ }, node);
+ }
+
+ return map;
+ }
+ catch (IgniteCheckedException e) {
+ throw U.convertException(e);
+ }
}
/** {@inheritDoc} */
- @Nullable @Override public Object reduce(List<ComputeJobResult> results) {
- String[] data = new String[results.size()];
+ @Nullable @Override public GridRestResponse reduce(List<ComputeJobResult> results) {
+ try {
+ String[] data = new String[results.size()];
- for (int i = 0; i < results.size(); ++i)
- data[i] = results.get(i).getData().toString();
+ for (int i = 0; i < results.size(); ++i)
+ data[i] = results.get(i).getData().toString();
- return ctx.scripting().invokeFunction(reduceFunc, (Object)data);
+ return new GridRestResponse(ctx.scripting().invokeFunction(reduceFunc, (Object)data));
+ }
+ catch (IgniteCheckedException e) {
+ return new GridRestResponse(GridRestResponse.STATUS_FAILED, e.getMessage());
+ }
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b7f2393e/modules/core/src/main/java/org/apache/ignite/internal/processors/scripting/IgniteScriptProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/scripting/IgniteScriptProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/scripting/IgniteScriptProcessor.java
index 9c8a94e..b6f29ed 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/scripting/IgniteScriptProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/scripting/IgniteScriptProcessor.java
@@ -72,13 +72,14 @@ public class IgniteScriptProcessor extends GridProcessorAdapter {
* Add function to scope.
*
* @param script Function script.
+ * @throws IgniteCheckedException If script failed.
*/
- public void addEngineFunction(String script) {
+ public void addEngineFunction(String script) throws IgniteCheckedException {
try {
jsEngine.eval(script);
}
catch (ScriptException e) {
- throw new IgniteException("Script Engine does not work.", e);
+ throw new IgniteCheckedException("Script evaluation failed [script=" + script + "].", e);
}
}
@@ -86,8 +87,9 @@ public class IgniteScriptProcessor extends GridProcessorAdapter {
* @param source Script source.
* @param args Arguments.
* @return Result of the function.
+ * @throws IgniteCheckedException If script failed.
*/
- public Object invokeFunction(String source, Object... args) {
+ public Object invokeFunction(String source, Object... args) throws IgniteCheckedException {
Object[] newArgs = new Object[args.length + 1];
newArgs[0] = source;
@@ -103,18 +105,19 @@ public class IgniteScriptProcessor extends GridProcessorAdapter {
* @param nameFunc Function name.
* @param args Function arguments.
* @return Result of the function.
+ * @throws IgniteCheckedException If script failed.
*/
- public Object invokeFunctionByName(String nameFunc, Object... args) {
+ public Object invokeFunctionByName(String nameFunc, Object... args) throws IgniteCheckedException {
Invocable invocable = (Invocable) jsEngine;
try {
return invocable.invokeFunction(nameFunc, args);
}
catch (ScriptException e) {
- throw new IgniteException("Script Engine does not work.", e);
+ throw new IgniteCheckedException("Function evaluation failed [funcName=" + nameFunc + "].", e);
}
catch (NoSuchMethodException e) {
- throw new IgniteException("Script Engine does not work.", e);
+ throw new IgniteCheckedException("Cannot find function [funcName=" + nameFunc + "].", e);
}
}
}