ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [5/7] incubator-ignite git commit: #ignite-965: add method name for node js ignite.
Date Thu, 25 Jun 2015 12:33:25 GMT
#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 <ivasilinets@gridgain.com>
Authored: Thu Jun 25 12:44:32 2015 +0300
Committer: ivasilinets <ivasilinets@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();
 


Mime
View raw message