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/25 14:33:21 UTC
[1/7] incubator-ignite git commit: #ignite-965:
IgniteScriptProcessor.invokeFunction without arguments call js engine eval
instead of invokeFunction.
Repository: incubator-ignite
Updated Branches:
refs/heads/ignite-965 e1c097fa2 -> d603238c6
#ignite-965: IgniteScriptProcessor.invokeFunction without arguments call js engine eval instead of invokeFunction.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/14dcb145
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/14dcb145
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/14dcb145
Branch: refs/heads/ignite-965
Commit: 14dcb145efacc27569768df641afc52a2e25091f
Parents: e1c097f
Author: ivasilinets <iv...@gridgain.com>
Authored: Thu Jun 25 11:31:09 2015 +0300
Committer: ivasilinets <iv...@gridgain.com>
Committed: Thu Jun 25 11:31:09 2015 +0300
----------------------------------------------------------------------
.../internal/processors/scripting/IgniteScriptProcessor.java | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/14dcb145/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 046b8aa..d9fa8d7 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
@@ -100,7 +100,12 @@ public class IgniteScriptProcessor extends GridProcessorAdapter {
* @throws IgniteCheckedException If script failed.
*/
public Object invokeFunction(String src) throws IgniteCheckedException {
- return invokeFunction(src, null, null);
+ try {
+ return jsEngine.eval("(" + src + ")()");
+ }
+ catch (ScriptException e) {
+ throw new IgniteCheckedException("Function evaluation failed [funcName=" + src + "].");
+ }
}
/**
[5/7] incubator-ignite git commit: #ignite-965: add method name for
node js ignite.
Posted by sb...@apache.org.
#ignite-965: add method name for node js ignite.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/a07b61f2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/a07b61f2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/a07b61f2
Branch: refs/heads/ignite-965
Commit: a07b61f2bbbd92a8a5d6913ed347b642066b219f
Parents: b4938d9
Author: ivasilinets <iv...@gridgain.com>
Authored: Thu Jun 25 12:44:32 2015 +0300
Committer: ivasilinets <iv...@gridgain.com>
Committed: Thu Jun 25 12:44:32 2015 +0300
----------------------------------------------------------------------
.../internal/processors/rest/GridRestCommand.java | 3 +++
.../version/GridVersionCommandHandler.java | 12 ++++++++++--
modules/nodejs/src/main/js/ignite.js | 14 ++++++++++++++
.../ignite/internal/NodeJsIgniteSelfTest.java | 7 +++++++
modules/nodejs/src/test/js/test-ignite.js | 17 +++++++++++++++++
.../protocols/http/jetty/GridJettyRestHandler.java | 1 +
6 files changed, 52 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a07b61f2/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 4ee672d..f4d92b7 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
@@ -87,6 +87,9 @@ public enum GridRestCommand {
/** Version. */
VERSION("version"),
+ /** Name. */
+ NAME("name"),
+
/** Log. */
LOG("log"),
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a07b61f2/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/version/GridVersionCommandHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/version/GridVersionCommandHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/version/GridVersionCommandHandler.java
index 2bfb704..9597ab3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/version/GridVersionCommandHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/version/GridVersionCommandHandler.java
@@ -34,7 +34,7 @@ import static org.apache.ignite.internal.processors.rest.GridRestCommand.*;
*/
public class GridVersionCommandHandler extends GridRestCommandHandlerAdapter {
/** Supported commands. */
- private static final Collection<GridRestCommand> SUPPORTED_COMMANDS = U.sealList(VERSION);
+ private static final Collection<GridRestCommand> SUPPORTED_COMMANDS = U.sealList(VERSION, NAME);
/**
* @param ctx Context.
@@ -54,6 +54,14 @@ public class GridVersionCommandHandler extends GridRestCommandHandlerAdapter {
assert SUPPORTED_COMMANDS.contains(req.command());
- return new GridFinishedFuture<>(new GridRestResponse(VER_STR));
+ switch (req.command()){
+ case VERSION:
+ return new GridFinishedFuture<>(new GridRestResponse(VER_STR));
+
+ case NAME:
+ return new GridFinishedFuture<>(new GridRestResponse(ctx.gridName()));
+ }
+
+ return new GridFinishedFuture<>();
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a07b61f2/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 2df2493..6ae13e1 100644
--- a/modules/nodejs/src/main/js/ignite.js
+++ b/modules/nodejs/src/main/js/ignite.js
@@ -59,9 +59,23 @@ Ignite.prototype.compute = function() {
}
/**
+ * Ignite version
+ *
+ * @this {Ignite}
* @param {onGet} callback Result in callback contains string with Ignite version.
*/
Ignite.prototype.version = function(callback) {
this._server.runCommand("version", [], callback);
}
+
+/**
+ * Connected ignite name
+ *
+ * @this {Ignite}
+ * @param {onGet} callback Result in callback contains string with Ignite name.
+ */
+Ignite.prototype.name = function(callback) {
+ this._server.runCommand("name", [], callback);
+}
+
exports.Ignite = Ignite;
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a07b61f2/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsIgniteSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsIgniteSelfTest.java b/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsIgniteSelfTest.java
index 6c17218..db4a2b4 100644
--- a/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsIgniteSelfTest.java
+++ b/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsIgniteSelfTest.java
@@ -44,4 +44,11 @@ public class NodeJsIgniteSelfTest extends NodeJsAbstractTest {
public void testIgniteVersion() throws Exception {
runJsScript("testIgniteVersion");
}
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testIgniteName() throws Exception {
+ runJsScript("testIgniteName");
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a07b61f2/modules/nodejs/src/test/js/test-ignite.js
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/test/js/test-ignite.js b/modules/nodejs/src/test/js/test-ignite.js
index af42086..bf73664 100644
--- a/modules/nodejs/src/test/js/test-ignite.js
+++ b/modules/nodejs/src/test/js/test-ignite.js
@@ -37,4 +37,21 @@ testIgniteVersion = function() {
}
TestUtils.startIgniteNode(onStart.bind(null));
+}
+
+testIgniteName = function() {
+ function igniteName(err, res) {
+ assert.equal(err, null);
+ assert(res.indexOf("NodeJsIgniteSelfTest") > -1, "Incorrect ignite name [ver=" + res + "]");
+
+ TestUtils.testDone();
+ }
+
+ function onStart(err, ignite) {
+ assert.equal(err, null);
+
+ ignite.name(igniteName.bind(null));
+ }
+
+ TestUtils.startIgniteNode(onStart.bind(null));
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a07b61f2/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 4729549..b669bdd 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
@@ -441,6 +441,7 @@ public class GridJettyRestHandler extends AbstractHandler {
break;
}
+ case NAME:
case VERSION: {
restReq = new GridRestRequest();
[6/7] incubator-ignite git commit: #ignite-965: add method cluster
for node js ignite.
Posted by sb...@apache.org.
#ignite-965: add method cluster for node js ignite.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/4bf86c97
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/4bf86c97
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/4bf86c97
Branch: refs/heads/ignite-965
Commit: 4bf86c97af3196189df01935d91a626ec8f7df68
Parents: a07b61f
Author: ivasilinets <iv...@gridgain.com>
Authored: Thu Jun 25 13:20:41 2015 +0300
Committer: ivasilinets <iv...@gridgain.com>
Committed: Thu Jun 25 13:20:41 2015 +0300
----------------------------------------------------------------------
modules/nodejs/src/main/js/cluster-node.js | 43 ++++++++++++++++++++
modules/nodejs/src/main/js/ignite.js | 35 +++++++++++++++-
.../ignite/internal/NodeJsIgniteSelfTest.java | 7 ++++
modules/nodejs/src/test/js/test-ignite.js | 24 +++++++++++
4 files changed, 108 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4bf86c97/modules/nodejs/src/main/js/cluster-node.js
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/main/js/cluster-node.js b/modules/nodejs/src/main/js/cluster-node.js
new file mode 100644
index 0000000..940f123
--- /dev/null
+++ b/modules/nodejs/src/main/js/cluster-node.js
@@ -0,0 +1,43 @@
+/*
+ * 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.
+ */
+
+ /**
+ * @constructor
+ * @this{ClusterNode}
+ * @param {string} nodeId Node id
+ * @param {Object.<string,string>} attr Node Attributes
+ */
+function ClusterNode(nodeId, attr) {
+ this._nodeId = nodeId;
+ this._attr = attr;
+}
+
+/**
+ * @returns {string} Node id
+ */
+ClusterNode.prototype.nodeId = function() {
+ return this._nodeId;
+}
+
+/**
+ * @returns {Object.<string,string>} Node Attributes
+ */
+ClusterNode.prototype.attributes = function() {
+ return this._attr;
+}
+
+exports.ClusterNode = ClusterNode
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4bf86c97/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 6ae13e1..d7203e4 100644
--- a/modules/nodejs/src/main/js/ignite.js
+++ b/modules/nodejs/src/main/js/ignite.js
@@ -16,7 +16,9 @@
*/
var Cache = require("./cache").Cache;
-var Compute = require("./compute").Compute
+var Compute = require("./compute").Compute;
+var ClusterNode = require("./cluster-node").ClusterNode;
+var Server = require("./server").Server;
/**
* Create an instance of Ignite
@@ -78,4 +80,35 @@ Ignite.prototype.name = function(callback) {
this._server.runCommand("name", [], callback);
}
+/**
+ * @this {Ignite}
+ * @param {onGet} callback Result in callback contains list of ClusterNodes
+ */
+Ignite.prototype.cluster = function(callback) {
+ function onTop(callback, err, res) {
+ if (err) {
+ callback.call(null, err, null);
+
+ return;
+ }
+
+ if (!res || res.length == 0) {
+ callback.call(null, "Empty topology cluster.", null);
+
+ return;
+ }
+
+ var nodes = [];
+
+ for (var node of res) {
+ nodes.push(new ClusterNode(node.nodeId, node.attributes));
+ }
+
+ callback.call(null, null, nodes);
+ }
+
+ this._server.runCommand("top", [Server.pair("attr", "true"), Server.pair("mtr", "false")],
+ onTop.bind(null, callback));
+}
+
exports.Ignite = Ignite;
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4bf86c97/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsIgniteSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsIgniteSelfTest.java b/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsIgniteSelfTest.java
index db4a2b4..293409b 100644
--- a/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsIgniteSelfTest.java
+++ b/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsIgniteSelfTest.java
@@ -51,4 +51,11 @@ public class NodeJsIgniteSelfTest extends NodeJsAbstractTest {
public void testIgniteName() throws Exception {
runJsScript("testIgniteName");
}
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testCluster() throws Exception {
+ runJsScript("testCluster");
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4bf86c97/modules/nodejs/src/test/js/test-ignite.js
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/test/js/test-ignite.js b/modules/nodejs/src/test/js/test-ignite.js
index bf73664..99c5242 100644
--- a/modules/nodejs/src/test/js/test-ignite.js
+++ b/modules/nodejs/src/test/js/test-ignite.js
@@ -54,4 +54,28 @@ testIgniteName = function() {
}
TestUtils.startIgniteNode(onStart.bind(null));
+}
+
+testCluster = function() {
+ function igniteCluster(err, res) {
+ assert.equal(err, null);
+ assert(res.length > 0);
+
+ assert(res[0].nodeId() !== null)
+
+ var attrs = res[0].attributes();
+
+ assert(attrs !== null);
+ assert(attrs["os.version"] !== null, "Not correct node attributes [attr=" + res[0].attributes() + "]");
+
+ TestUtils.testDone();
+ }
+
+ function onStart(err, ignite) {
+ assert.equal(err, null);
+
+ ignite.cluster(igniteCluster.bind(null));
+ }
+
+ TestUtils.startIgniteNode(onStart.bind(null));
}
\ No newline at end of file
[3/7] incubator-ignite git commit: #ignite-965: Implement node js
ignite method version.
Posted by sb...@apache.org.
#ignite-965: Implement node js ignite method version.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/54d92739
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/54d92739
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/54d92739
Branch: refs/heads/ignite-965
Commit: 54d92739a8b15b06262c0dc1c6caf69c7600d086
Parents: 710c2fa
Author: ivasilinets <iv...@gridgain.com>
Authored: Thu Jun 25 12:29:43 2015 +0300
Committer: ivasilinets <iv...@gridgain.com>
Committed: Thu Jun 25 12:29:43 2015 +0300
----------------------------------------------------------------------
modules/nodejs/src/main/js/ignite.js | 6 +++
.../ignite/internal/NodeJsIgniteSelfTest.java | 47 ++++++++++++++++++++
modules/nodejs/src/test/js/test-ignite.js | 40 +++++++++++++++++
3 files changed, 93 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/54d92739/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 fb24a19..2df2493 100644
--- a/modules/nodejs/src/main/js/ignite.js
+++ b/modules/nodejs/src/main/js/ignite.js
@@ -58,4 +58,10 @@ Ignite.prototype.compute = function() {
return new Compute(this._server);
}
+/**
+ * @param {onGet} callback Result in callback contains string with Ignite version.
+ */
+Ignite.prototype.version = function(callback) {
+ this._server.runCommand("version", [], callback);
+}
exports.Ignite = Ignite;
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/54d92739/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsIgniteSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsIgniteSelfTest.java b/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsIgniteSelfTest.java
new file mode 100644
index 0000000..6c17218
--- /dev/null
+++ b/modules/nodejs/src/test/java/org/apache/ignite/internal/NodeJsIgniteSelfTest.java
@@ -0,0 +1,47 @@
+/*
+ * 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;
+
+/**
+ * Test for node js ignite.
+ */
+public class NodeJsIgniteSelfTest extends NodeJsAbstractTest {
+ /**
+ * Constructor.
+ */
+ public NodeJsIgniteSelfTest() {
+ super("test-ignite.js");
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTestsStarted() throws Exception {
+ startGrid(0);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ stopAllGrids();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testIgniteVersion() throws Exception {
+ runJsScript("testIgniteVersion");
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/54d92739/modules/nodejs/src/test/js/test-ignite.js
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/test/js/test-ignite.js b/modules/nodejs/src/test/js/test-ignite.js
new file mode 100644
index 0000000..af42086
--- /dev/null
+++ b/modules/nodejs/src/test/js/test-ignite.js
@@ -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.
+ */
+
+var TestUtils = require("./test-utils").TestUtils;
+
+var assert = require("assert");
+
+testIgniteVersion = function() {
+ function igniteVer(err, res) {
+ assert.equal(err, null);
+
+ var verRegex = /([0-9]+)\.([0-9]+)\.([0-9]+)/;
+
+ assert(verRegex.exec(res) !== null, "Incorrect ignite version [ver=" + res + "]");
+
+ TestUtils.testDone();
+ }
+
+ function onStart(err, ignite) {
+ assert.equal(err, null);
+
+ ignite.version(igniteVer.bind(null));
+ }
+
+ TestUtils.startIgniteNode(onStart.bind(null));
+}
\ No newline at end of file
[7/7] incubator-ignite git commit: #ignite-965: add tests for
incorrect function map/reduce.
Posted by sb...@apache.org.
#ignite-965: add tests for incorrect function map/reduce.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/d603238c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/d603238c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/d603238c
Branch: refs/heads/ignite-965
Commit: d603238c6840361801ab5dbc5c9651ecbf91a29a
Parents: 4bf86c9
Author: ivasilinets <iv...@gridgain.com>
Authored: Thu Jun 25 15:33:01 2015 +0300
Committer: ivasilinets <iv...@gridgain.com>
Committed: Thu Jun 25 15:33:01 2015 +0300
----------------------------------------------------------------------
.../ignite/internal/NodeJsComputeSelfTest.java | 18 +++++-
modules/nodejs/src/test/js/test-compute.js | 62 ++++++++++++++++----
2 files changed, 65 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d603238c/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 2ba5e63..3a00231 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
@@ -62,8 +62,22 @@ public class NodeJsComputeSelfTest extends NodeJsAbstractTest {
/**
* @throws Exception If failed.
*/
- public void testComputeErrorExecute() throws Exception {
- runJsScript("testComputeErrorExecute");
+ public void testComputeFuncWithErrorExecute() throws Exception {
+ runJsScript("testComputeFuncWithErrorExecute");
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testComputeIncorrectFuncExecute() throws Exception {
+ runJsScript("testComputeIncorrectFuncExecute");
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testComputeIncorrectMapExecute() throws Exception {
+ runJsScript("testComputeIncorrectMapExecute");
}
/**
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d603238c/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 187e54c..c069d97 100644
--- a/modules/nodejs/src/test/js/test-compute.js
+++ b/modules/nodejs/src/test/js/test-compute.js
@@ -27,10 +27,6 @@ testComputeExecute = function() {
TestUtils.startIgniteNode(computeExecute);
}
-testComputeErrorExecute = function() {
- TestUtils.startIgniteNode(computeErrorExecute);
-}
-
testComputeAllNodeExecute = function() {
TestUtils.startIgniteNode(computeAllNodeExecute);
}
@@ -123,22 +119,62 @@ function computeAllNodeExecute(error, ignite) {
ignite.compute().execute(map, reduce, "", callback);
}
-function computeErrorExecute(error, ignite) {
+testComputeFuncWithErrorExecute = function() {
var map = function(nodes, arg) {
- var f = [function (args) {}, function(args){throw "Bad function";}];
+ var f = function(args){throw "Bad function";};
+
for (var i = 0; i < nodes.length; i++) {
- emit(f[i % f.length], "", nodes[i % nodes.length]);
+ emit(f, "", nodes[i % nodes.length]);
}
};
- var callback = function(err, res) {
- assert(err != null, "Do not get error on compute task.");
+ testComputeWithErrors(map);
+}
+
+testComputeIncorrectFuncExecute = function() {
+ var map = function(nodes, arg) {
+ var f = function() {
+ prin("hi");
+ };
- assert(err.indexOf("Function evaluation failed") > -1, "Incorrect error "+
- "[expected=function evaluation failed, value=" + err + "]");
+ for (var i = 0; i < nodes.length; i++) {
+ emit(f, "", nodes[i % nodes.length]);
+ }
+ };
- TestUtils.testDone();
+ testComputeWithErrors(map);
+}
+
+testComputeIncorrectMapExecute = function() {
+ var map = function(nodes, arg) {
+ var f = function() {
+ print("hi");
+ };
+
+ for (i = 0; i < nodes.length; i++) {
+ emit(f, "", nodes[a % nodes.length]);
+ }
+ };
+
+ testComputeWithErrors(map);
+}
+
+function testComputeWithErrors(map) {
+ function computeErrorExecute(error, ignite) {
+ 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 + "]");
+
+ TestUtils.testDone();
+ }
+
+ ignite.compute().execute(map, function (args) {}, "Hi Alice", callback);
}
- ignite.compute().execute(map, function (args) {}, "Hi Alice", callback);
+ TestUtils.startIgniteNode(computeErrorExecute);
}
[4/7] incubator-ignite git commit: #ignite-965: add test for node js
ignite to node js suite.
Posted by sb...@apache.org.
#ignite-965: add test for node js ignite to node js suite.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/b4938d9f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/b4938d9f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/b4938d9f
Branch: refs/heads/ignite-965
Commit: b4938d9fb8d290f038381176627cdbe3ef045f65
Parents: 54d9273
Author: ivasilinets <iv...@gridgain.com>
Authored: Thu Jun 25 12:31:11 2015 +0300
Committer: ivasilinets <iv...@gridgain.com>
Committed: Thu Jun 25 12:31:11 2015 +0300
----------------------------------------------------------------------
.../java/org/apache/ignite/testsuites/IgniteNodeJsTestSuite.java | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b4938d9f/modules/nodejs/src/test/java/org/apache/ignite/testsuites/IgniteNodeJsTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/nodejs/src/test/java/org/apache/ignite/testsuites/IgniteNodeJsTestSuite.java b/modules/nodejs/src/test/java/org/apache/ignite/testsuites/IgniteNodeJsTestSuite.java
index eb69d7f..62360f2 100644
--- a/modules/nodejs/src/test/java/org/apache/ignite/testsuites/IgniteNodeJsTestSuite.java
+++ b/modules/nodejs/src/test/java/org/apache/ignite/testsuites/IgniteNodeJsTestSuite.java
@@ -35,6 +35,7 @@ public class IgniteNodeJsTestSuite extends TestSuite {
suite.addTest(new TestSuite(NodeJsCacheApiSelfTest.class));
suite.addTest(new TestSuite(NodeJsSecretKeySelfTest.class));
suite.addTest(new TestSuite(NodeJsComputeSelfTest.class));
+ suite.addTest(new TestSuite(NodeJsIgniteSelfTest.class));
return suite;
}
[2/7] incubator-ignite git commit: #ignite-965: Node js run script
function can have parameters.
Posted by sb...@apache.org.
#ignite-965: Node js run script function can have parameters.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/710c2fa4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/710c2fa4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/710c2fa4
Branch: refs/heads/ignite-965
Commit: 710c2fa42d920711e2e6352083664ef65ba97516
Parents: 14dcb14
Author: ivasilinets <iv...@gridgain.com>
Authored: Thu Jun 25 12:02:40 2015 +0300
Committer: ivasilinets <iv...@gridgain.com>
Committed: Thu Jun 25 12:02:40 2015 +0300
----------------------------------------------------------------------
.../scripting/IgniteScriptingCommandHandler.java | 18 ++++++++++++------
.../rest/request/RestRunScriptRequest.java | 17 +++++++++++++++++
modules/nodejs/src/main/js/compute.js | 6 ++++--
modules/nodejs/src/test/js/test-compute.js | 7 ++++---
.../http/jetty/GridJettyRestHandler.java | 3 ++-
5 files changed, 39 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/710c2fa4/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 38e4b9c..98ca7b1 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
@@ -86,16 +86,17 @@ public class IgniteScriptingCommandHandler extends GridRestCommandHandlerAdapter
case RUN_SCRIPT: {
assert req instanceof RestRunScriptRequest : "Invalid type of run script request.";
- return ctx.closure().callAsync(new IgniteClosure<String, GridRestResponse>() {
- @Override public GridRestResponse apply(String o) {
+ return ctx.closure().callAsync(new IgniteClosure<RestRunScriptRequest, GridRestResponse>() {
+ @Override public GridRestResponse apply(RestRunScriptRequest req) {
try {
- return new GridRestResponse(ctx.grid().compute().call(new JsFunctionCallable(o)));
+ return new GridRestResponse(ctx.grid().compute().call(
+ new JsFunctionCallable(req.script(), req.argument())));
}
catch (Exception e) {
return new GridRestResponse(GridRestResponse.STATUS_FAILED, e.getMessage());
}
}
- }, ((RestRunScriptRequest) req).script(), Collections.singleton(ctx.grid().localNode()));
+ }, (RestRunScriptRequest)req, Collections.singleton(ctx.grid().localNode()));
}
case EXECUTE_MAP_REDUCE_SCRIPT: {
@@ -249,21 +250,26 @@ public class IgniteScriptingCommandHandler extends GridRestCommandHandlerAdapter
/** Function to call. */
private String func;
+ /** Function argument. */
+ private Object arg;
+
/** Ignite instance. */
@IgniteInstanceResource
private Ignite ignite;
/**
* @param func Function to call.
+ * @param arg Function argument.
*/
- public JsFunctionCallable(String func) {
+ public JsFunctionCallable(String func, Object arg) {
this.func = func;
+ this.arg = arg;
}
/** {@inheritDoc} */
@Override public Object call() {
try {
- return ((IgniteKernal)ignite).context().scripting().invokeFunction(func);
+ return ((IgniteKernal)ignite).context().scripting().invokeFunction(func, arg);
}
catch (IgniteCheckedException e) {
throw U.convertException(e);
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/710c2fa4/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
index 42aba76..cf74802 100644
--- 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
@@ -24,6 +24,9 @@ public class RestRunScriptRequest extends GridRestRequest {
/** Java script function. */
private String script;
+ /** Function arguments. */
+ private Object arg;
+
/**
* @return Java script function.
*/
@@ -37,4 +40,18 @@ public class RestRunScriptRequest extends GridRestRequest {
public void script(String script) {
this.script = script;
}
+
+ /**
+ * @return Function argument.
+ */
+ public Object argument() {
+ return arg;
+ }
+
+ /**
+ * @param arg Function argument.
+ */
+ public void argument(Object arg) {
+ this.arg = arg;
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/710c2fa4/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 0f932e7..9aef39e 100644
--- a/modules/nodejs/src/main/js/compute.js
+++ b/modules/nodejs/src/main/js/compute.js
@@ -29,10 +29,12 @@ function Compute(server) {
/**
* @this {Compute}
* @param runnable Function without parameters
+ * @param args Function arguments
* @param {onGet} callback Callback
*/
-Compute.prototype.runScript = function(runnable, callback) {
- this._server.runCommand("runscript", [Server.pair("func", this._escape(runnable))], callback);
+Compute.prototype.runScript = function(runnable, args, callback) {
+ this._server.runCommand("runscript", [Server.pair("func", this._escape(runnable)),
+ Server.pair("arg", this._escape(args))], callback);
}
/**
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/710c2fa4/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 fec5914..187e54c 100644
--- a/modules/nodejs/src/test/js/test-compute.js
+++ b/modules/nodejs/src/test/js/test-compute.js
@@ -50,18 +50,19 @@ function onStart(onPut, error, ignite) {
function computeRunScript(ignite, error) {
var comp = ignite.compute();
- var f = function () {
- return ignite.hello();
+ var f = function (args) {
+ return args + " " + ignite.hello();
}
function onEnd(err, res) {
assert(err == null);
assert(res.indexOf("HAPPY") !== -1, "Incorrect result message. [mes=" + res + "].");
+ assert(res.indexOf("GridGain") !== -1, "Incorrect result message. [mes=" + res + "].");
TestUtils.testDone();
}
- comp.runScript(f, onEnd.bind(null));
+ comp.runScript(f, "GridGain", onEnd.bind(null));
}
function computeExecute(error, ignite) {
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/710c2fa4/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 b650554..4729549 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
@@ -450,7 +450,8 @@ public class GridJettyRestHandler extends AbstractHandler {
case RUN_SCRIPT: {
RestRunScriptRequest restReq0 = new RestRunScriptRequest();
- restReq0.script((String) params.get("func"));
+ restReq0.script((String)params.get("func"));
+ restReq0.argument(params.get("arg"));
restReq = restReq0;