ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ivasilin...@apache.org
Subject [11/39] incubator-ignite git commit: #ignite-964: remove postPutAll
Date Wed, 01 Jul 2015 10:13:47 GMT
#ignite-964: remove postPutAll


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/2bf2b69e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/2bf2b69e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/2bf2b69e

Branch: refs/heads/ignite-964
Commit: 2bf2b69e4f18eacd79072c762a9d4a14bfca11ae
Parents: 913a5d4
Author: ivasilinets <ivasilinets@gridgain.com>
Authored: Tue Jun 30 14:40:38 2015 +0300
Committer: ivasilinets <ivasilinets@gridgain.com>
Committed: Tue Jun 30 14:40:38 2015 +0300

----------------------------------------------------------------------
 .../processors/rest/GridRestCommand.java        |   3 -
 .../handlers/cache/GridCacheCommandHandler.java |   2 -
 modules/nodejs/src/main/js/cache.js             |   2 +-
 modules/nodejs/src/main/js/server.js            |  10 +-
 .../http/jetty/GridJettyRestHandler.java        | 108 +++++++++----------
 5 files changed, 61 insertions(+), 64 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2bf2b69e/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 375a079..0afefb6 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
@@ -45,9 +45,6 @@ public enum GridRestCommand {
     /** Store several values in cache. */
     CACHE_PUT_ALL("putall"),
 
-    /** Store several values in cache. */
-    CACHE_PUT_ALL2("putall2"),
-
     /** Remove value from cache. */
     CACHE_REMOVE("rmv"),
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2bf2b69e/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheCommandHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheCommandHandler.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheCommandHandler.java
index ef0391e..1f24023 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheCommandHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheCommandHandler.java
@@ -58,7 +58,6 @@ public class GridCacheCommandHandler extends GridRestCommandHandlerAdapter
{
         CACHE_PUT,
         CACHE_ADD,
         CACHE_PUT_ALL,
-        CACHE_PUT_ALL2,
         CACHE_REMOVE,
         CACHE_REMOVE_ALL,
         CACHE_REPLACE,
@@ -191,7 +190,6 @@ public class GridCacheCommandHandler extends GridRestCommandHandlerAdapter
{
                     break;
                 }
 
-                case CACHE_PUT_ALL2:
                 case CACHE_PUT_ALL: {
                     Map<Object, Object> map = req0.values();
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2bf2b69e/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 4333389..b19367c 100644
--- a/modules/nodejs/src/main/js/cache.js
+++ b/modules/nodejs/src/main/js/cache.js
@@ -106,7 +106,7 @@ Cache.prototype.putAll = function(map, callback) {
  * @param {noValue} callback Called on finish
  */
 Cache.prototype.postPutAll = function(map, callback) {
-    this._server.runCommand(this._createCommand("putall2").setPostData(JSON.stringify(map)),
callback);
+    this._server.runCommand(this._createCommand("putall").setPostData(JSON.stringify(map)),
callback);
 }
 
 /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2bf2b69e/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 2714ae5..3cb98c1 100644
--- a/modules/nodejs/src/main/js/server.js
+++ b/modules/nodejs/src/main/js/server.js
@@ -67,12 +67,18 @@ Server.prototype.runCommand = function(cmd, callback) {
 
     var http = require('http');
 
+    var commHeaders = this._signature();
+
+    if (cmd._isPost()) {
+        commHeaders["JSONObject"] = "true";
+    }
+
     var options = {
         host: this._host,
         port: this._port,
         method : cmd._method(),
         path: "/ignite?" + requestQry,
-        headers: this._signature()
+        headers: commHeaders
     };
 
     if (cmd._isPost()) {
@@ -149,7 +155,7 @@ Server.prototype.checkConnection = function(callback) {
  */
 Server.prototype._signature = function() {
     if (!this._secretKey) {
-        return "";
+        return {};
     }
 
     var loadTimeInMS = Date.now();

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2bf2b69e/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 7e650d3..0af9bf7 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
@@ -323,8 +323,7 @@ public class GridJettyRestHandler extends AbstractHandler {
      * @throws IgniteCheckedException If creation failed.
      */
     @Nullable private GridRestRequest createRequest(GridRestCommand cmd,
-        Map<String, Object> params,
-        ServletRequest req) throws IgniteCheckedException {
+        Map<String, Object> params, HttpServletRequest req) throws IgniteCheckedException
{
         GridRestRequest restReq;
 
         switch (cmd) {
@@ -341,40 +340,6 @@ public class GridJettyRestHandler extends AbstractHandler {
                 break;
             }
 
-            case CACHE_PUT_ALL2: {
-                StringBuilder builder = new StringBuilder();
-
-                Scanner reader = null;
-
-                try {
-                    reader = new Scanner(req.getReader());
-                } catch (IOException e) {
-                    throw new IgniteCheckedException(e);
-                }
-
-                while (reader.hasNext())
-                    builder.append(reader.next() + "\n");
-
-                JSONObject o = JSONObject.fromObject(builder.toString());
-
-                GridRestCacheRequest restReq0 = new GridRestCacheRequest();
-
-                String cacheName = (String) params.get("cacheName");
-
-                restReq0.cacheName(F.isEmpty(cacheName) ? null : cacheName);
-
-                Map<Object, Object> map = U.newHashMap(o.keySet().size());
-
-                for (Object k : o.keySet())
-                    map.put(k, o.get(k));
-
-                restReq0.values(map);
-
-                restReq = restReq0;
-
-                break;
-            }
-
             case CACHE_GET:
             case CACHE_GET_ALL:
             case CACHE_PUT:
@@ -391,35 +356,66 @@ public class GridJettyRestHandler extends AbstractHandler {
 
                 String cacheName = (String)params.get("cacheName");
 
-                restReq0.cacheName(F.isEmpty(cacheName) ? null : cacheName);
-                restReq0.key(params.get("key"));
-                restReq0.value(params.get("val"));
-                restReq0.value2(params.get("val2"));
+                if (req.getHeader("JSONObject") != null) {
+                    if (cmd == CACHE_PUT_ALL) {
+                        StringBuilder builder = new StringBuilder();
+
+                        Scanner reader = null;
+
+                        try {
+                            reader = new Scanner(req.getReader());
+                        }
+                        catch (IOException e) {
+                            throw new IgniteCheckedException(e);
+                        }
+
+                        while (reader.hasNext())
+                            builder.append(reader.next() + "\n");
+
+                        JSONObject o = JSONObject.fromObject(builder.toString());
+
+                        restReq0.cacheName(F.isEmpty(cacheName) ? null : cacheName);
+
+                        Map<Object, Object> map = U.newHashMap(o.keySet().size());
+
+                        for (Object k : o.keySet())
+                            map.put(k, o.get(k));
+
+                        restReq0.values(map);
+                    }
+                }
+                else {
+
+                    restReq0.cacheName(F.isEmpty(cacheName) ? null : cacheName);
+                    restReq0.key(params.get("key"));
+                    restReq0.value(params.get("val"));
+                    restReq0.value2(params.get("val2"));
 
-                Object val1 = params.get("val1");
+                    Object val1 = params.get("val1");
 
-                if (val1 != null)
-                    restReq0.value(val1);
+                    if (val1 != null)
+                        restReq0.value(val1);
 
-                restReq0.cacheFlags(intValue("cacheFlags", params, 0));
-                restReq0.ttl(longValue("exp", params, null));
+                    restReq0.cacheFlags(intValue("cacheFlags", params, 0));
+                    restReq0.ttl(longValue("exp", params, null));
 
-                if (cmd == CACHE_GET_ALL || cmd == CACHE_PUT_ALL || cmd == CACHE_REMOVE_ALL)
{
-                    List<Object> keys = values("k", params);
-                    List<Object> vals = values("v", params);
+                    if (cmd == CACHE_GET_ALL || cmd == CACHE_PUT_ALL || cmd == CACHE_REMOVE_ALL)
{
+                        List<Object> keys = values("k", params);
+                        List<Object> vals = values("v", params);
 
-                    if (keys.size() < vals.size())
-                        throw new IgniteCheckedException("Number of keys must be greater
or equals to number of values.");
+                        if (keys.size() < vals.size())
+                            throw new IgniteCheckedException("Number of keys must be greater
or equals to number of values.");
 
-                    Map<Object, Object> map = U.newHashMap(keys.size());
+                        Map<Object, Object> map = U.newHashMap(keys.size());
 
-                    Iterator<Object> keyIt = keys.iterator();
-                    Iterator<Object> valIt = vals.iterator();
+                        Iterator<Object> keyIt = keys.iterator();
+                        Iterator<Object> valIt = vals.iterator();
 
-                    while (keyIt.hasNext())
-                        map.put(keyIt.next(), valIt.hasNext() ? valIt.next() : null);
+                        while (keyIt.hasNext())
+                            map.put(keyIt.next(), valIt.hasNext() ? valIt.next() : null);
 
-                    restReq0.values(map);
+                        restReq0.values(map);
+                    }
                 }
 
                 restReq = restReq0;


Mime
View raw message