You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by se...@apache.org on 2015/07/17 15:05:40 UTC

[01/14] incubator-ignite git commit: #ignite-961: JettyRestProcessorAbstractSelfTest clear cache before test.

Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-1121 0fd8fd8aa -> 91f1fdcc1


#ignite-961: JettyRestProcessorAbstractSelfTest clear cache before test.


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

Branch: refs/heads/ignite-1121
Commit: b893af8ff4d342e1eafdbda50316f22a70f5145a
Parents: 3d4f3b6
Author: ivasilinets <iv...@gridgain.com>
Authored: Fri Jul 17 10:25:37 2015 +0300
Committer: ivasilinets <iv...@gridgain.com>
Committed: Fri Jul 17 10:25:37 2015 +0300

----------------------------------------------------------------------
 .../processors/rest/JettyRestProcessorAbstractSelfTest.java     | 5 +++++
 1 file changed, 5 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b893af8f/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java
index 75468a0..d6af0b7 100644
--- a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java
+++ b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java
@@ -54,6 +54,11 @@ abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestProcessorS
     }
 
     /** {@inheritDoc} */
+    @Override protected void beforeTest() throws Exception {
+        grid(0).cache(null).clear();
+    }
+
+    /** {@inheritDoc} */
     @Override protected int gridCount() {
         return GRID_CNT;
     }


[09/14] incubator-ignite git commit: #ignite-961: add javadoc for JettyRestProcessorAbstractSelfTest.makePostRequest

Posted by se...@apache.org.
#ignite-961: add javadoc for JettyRestProcessorAbstractSelfTest.makePostRequest


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

Branch: refs/heads/ignite-1121
Commit: 3d94e849c118aa89a108dac91c08e20bd9238e96
Parents: e134cd9
Author: ivasilinets <iv...@gridgain.com>
Authored: Fri Jul 17 13:30:02 2015 +0300
Committer: ivasilinets <iv...@gridgain.com>
Committed: Fri Jul 17 13:30:02 2015 +0300

----------------------------------------------------------------------
 .../rest/JettyRestProcessorAbstractSelfTest.java      | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3d94e849/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java
index 04f4a2a..67913e4 100644
--- a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java
+++ b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java
@@ -101,7 +101,15 @@ abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestProcessorS
         return buf.toString();
     }
 
-    private String makePostRequest(Map<String, String> params, String urlParameters) throws Exception {
+    /**
+     * Runs post request.
+     *
+     * @param params Url parameters.
+     * @param postParams Post parameters.
+     * @return Request result.
+     * @throws Exception If failed.
+     */
+    private String makePostRequest(Map<String, String> params, String postParams) throws Exception {
         String addr = "http://" + LOC_HOST + ":" + restPort() + "/ignite?";
 
         for (Map.Entry<String, String> e : params.entrySet())
@@ -109,7 +117,7 @@ abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestProcessorS
 
         URL url = new URL(addr);
 
-        byte[] data = urlParameters.getBytes(Charset.forName("UTF-8"));
+        byte[] data = postParams.getBytes(Charset.forName("UTF-8"));
 
         HttpURLConnection conn = (HttpURLConnection)url.openConnection();
 
@@ -130,7 +138,7 @@ abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestProcessorS
         conn.setDoOutput(true);
 
         try (PrintStream wr = new PrintStream(conn.getOutputStream())) {
-            wr.print(urlParameters);
+            wr.print(postParams);
             wr.flush();
             wr.close();
         }


[08/14] incubator-ignite git commit: Merge branch 'ignite-961' of https://git-wip-us.apache.org/repos/asf/incubator-ignite into ignite-961

Posted by se...@apache.org.
Merge branch 'ignite-961' of https://git-wip-us.apache.org/repos/asf/incubator-ignite into ignite-961


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

Branch: refs/heads/ignite-1121
Commit: e134cd97984424e86aed587a7106519499da44e7
Parents: 8a8b32a c7e7c46
Author: ivasilinets <iv...@gridgain.com>
Authored: Fri Jul 17 13:22:06 2015 +0300
Committer: ivasilinets <iv...@gridgain.com>
Committed: Fri Jul 17 13:22:06 2015 +0300

----------------------------------------------------------------------
 .../apache/ignite/internal/IgniteKernal.java    |  12 ++
 .../processors/cache/GridCacheContext.java      |  45 +++--
 .../processors/cache/GridCacheMvccManager.java  |   6 +-
 .../GridCachePartitionExchangeManager.java      |  53 ++++++
 .../distributed/dht/GridDhtTopologyFuture.java  |  14 --
 .../dht/atomic/GridDhtAtomicCache.java          |   4 +-
 .../dht/atomic/GridNearAtomicUpdateFuture.java  |  11 +-
 .../GridDhtPartitionsExchangeFuture.java        |  31 +---
 .../cache/transactions/IgniteTxManager.java     |   4 +-
 .../distributed/IgniteCache150ClientsTest.java  |   1 +
 .../IgniteCacheClientReconnectTest.java         | 175 +++++++++++++++++++
 .../IgniteCacheServerNodeConcurrentStart.java   |  96 ++++++++++
 .../testframework/junits/GridAbstractTest.java  |   5 +
 .../testsuites/IgniteCacheTestSuite2.java       |   2 +-
 .../testsuites/IgniteCacheTestSuite4.java       |   2 -
 .../testsuites/IgniteClientNodesTestSuite.java  |  42 +++++
 16 files changed, 439 insertions(+), 64 deletions(-)
----------------------------------------------------------------------



[03/14] incubator-ignite git commit: #ignite-961: use glassfish parser for JSON request.

Posted by se...@apache.org.
#ignite-961: use glassfish parser for JSON request.


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

Branch: refs/heads/ignite-1121
Commit: 18a3e05af2ae3886603e705ae6ce469cbb36486f
Parents: e1aca64
Author: ivasilinets <iv...@gridgain.com>
Authored: Fri Jul 17 11:16:24 2015 +0300
Committer: ivasilinets <iv...@gridgain.com>
Committed: Fri Jul 17 11:16:24 2015 +0300

----------------------------------------------------------------------
 .../scripting/IgniteScriptingConverter.java     | 44 ++++++++++++++++++++
 .../scripting/IgniteScriptingProcessor.java     | 41 +++++++++++++++---
 .../org/apache/ignite/json/JSONCacheObject.java |  2 +-
 modules/rest-http/pom.xml                       |  6 +++
 .../http/jetty/GridJettyRestHandler.java        | 31 +++++---------
 5 files changed, 98 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/18a3e05a/modules/core/src/main/java/org/apache/ignite/internal/processors/scripting/IgniteScriptingConverter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/scripting/IgniteScriptingConverter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/scripting/IgniteScriptingConverter.java
new file mode 100644
index 0000000..bc52d58
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/scripting/IgniteScriptingConverter.java
@@ -0,0 +1,44 @@
+/*
+ * 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.scripting;
+
+import org.apache.ignite.json.*;
+
+/**
+ * Convert json object ot java objects.
+ */
+public class IgniteScriptingConverter {
+    /**
+     * @param o Object.
+     * @return  Object for Ignite cache.
+     */
+    public Object toJavaObject(Object o) {
+        return JSONCacheObject.toSimpleObject(o);
+    }
+
+    /**
+     * @param o Object from script.
+     * @return Object to store in cache.
+     */
+    public Object getField(String key, Object o) {
+        if (o instanceof JSONCacheObject)
+            return ((JSONCacheObject)o).getField(key);
+
+        return null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/18a3e05a/modules/core/src/main/java/org/apache/ignite/internal/processors/scripting/IgniteScriptingProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/scripting/IgniteScriptingProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/scripting/IgniteScriptingProcessor.java
index b38c4c3..db283b8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/scripting/IgniteScriptingProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/scripting/IgniteScriptingProcessor.java
@@ -35,9 +35,16 @@ public class IgniteScriptingProcessor extends GridProcessorAdapter {
     /** Javascript engine name. */
     public static final String JAVA_SCRIPT_ENGINE_NAME = "JavaScript";
 
+    /** Rest converter. */
+    private static final String REST_CONV_CLS =
+        "org.apache.ignite.internal.processors.rest.protocols.http.jetty.GlassFishScriptingConverter";
+
     /** Javascript engine. */
     private ScriptEngine jsEngine;
 
+    /** Ignite scripting converter. */
+    IgniteScriptingConverter converter;
+
     /**
      * @param ctx Kernal context.
      */
@@ -47,6 +54,8 @@ public class IgniteScriptingProcessor extends GridProcessorAdapter {
 
     /** {@inheritDoc} */
     @Override public void start() throws IgniteCheckedException {
+        initializeConverter();
+
         ScriptEngineManager factory = new ScriptEngineManager();
 
         jsEngine = factory.getEngineByName(JAVA_SCRIPT_ENGINE_NAME);
@@ -153,7 +162,7 @@ public class IgniteScriptingProcessor extends GridProcessorAdapter {
      * @return  Object for Ignite cache.
      */
     public Object toJavaObject(Object o) {
-        return JSONCacheObject.toSimpleObject(o);
+        return converter.toJavaObject(o);
     }
 
     /**
@@ -161,10 +170,7 @@ public class IgniteScriptingProcessor extends GridProcessorAdapter {
      * @return Object to store in cache.
      */
     public Object getField(String key, Object o) {
-        if (o instanceof JSONCacheObject)
-            return ((JSONCacheObject)o).getField(key);
-
-        return null;
+        return converter.getField(key, o);
     }
 
     /**
@@ -177,6 +183,31 @@ public class IgniteScriptingProcessor extends GridProcessorAdapter {
     }
 
     /**
+     * Initialize rest converter if it is available.
+     *
+     * @throws IgniteCheckedException If no constructor found for converter.
+     */
+    private void initializeConverter() throws IgniteCheckedException {
+        try {
+            Class<?> cls = Class.forName(REST_CONV_CLS);
+
+            Constructor<?> ctor = cls.getConstructor();
+
+            converter = (IgniteScriptingConverter)ctor.newInstance();
+        }
+        catch (ClassNotFoundException ignored) {
+            if (log.isDebugEnabled())
+                log.debug("Failed to initialize HTTP REST protocol (consider adding ignite-rest-http " +
+                    "module to classpath).");
+
+            converter = new IgniteScriptingConverter();
+        }
+        catch (NoSuchMethodException | InvocationTargetException | InstantiationException | IllegalAccessException e) {
+            throw new IgniteCheckedException("Failed to initialize HTTP REST protocol.", e);
+        }
+    }
+
+    /**
      * Scripting cache entry.
      */
     public static class ScriptingCacheEntry {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/18a3e05a/modules/core/src/main/java/org/apache/ignite/json/JSONCacheObject.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/json/JSONCacheObject.java b/modules/core/src/main/java/org/apache/ignite/json/JSONCacheObject.java
index fd4359e..13c9321 100644
--- a/modules/core/src/main/java/org/apache/ignite/json/JSONCacheObject.java
+++ b/modules/core/src/main/java/org/apache/ignite/json/JSONCacheObject.java
@@ -29,7 +29,7 @@ public class JSONCacheObject extends HashMap<Object, Object> {
     /**
      * Empty constructor.
      */
-    private JSONCacheObject() {
+    public JSONCacheObject() {
         // No-op.
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/18a3e05a/modules/rest-http/pom.xml
----------------------------------------------------------------------
diff --git a/modules/rest-http/pom.xml b/modules/rest-http/pom.xml
index 4ce41ae..c301aa6 100644
--- a/modules/rest-http/pom.xml
+++ b/modules/rest-http/pom.xml
@@ -35,6 +35,12 @@
 
     <dependencies>
         <dependency>
+            <groupId>org.glassfish</groupId>
+            <artifactId>javax.json</artifactId>
+            <version>1.0.4</version>
+        </dependency>
+
+        <dependency>
             <groupId>org.apache.ignite</groupId>
             <artifactId>ignite-core</artifactId>
             <version>${project.version}</version>

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/18a3e05a/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 577a5e5..c2e6885 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
@@ -30,6 +30,7 @@ import org.apache.ignite.lang.*;
 import org.apache.ignite.plugin.security.*;
 import org.eclipse.jetty.server.*;
 import org.eclipse.jetty.server.handler.*;
+import org.glassfish.json.*;
 import org.jetbrains.annotations.*;
 
 import javax.servlet.*;
@@ -578,8 +579,8 @@ public class GridJettyRestHandler extends AbstractHandler {
 
                 restReq0.script((String)params.get("func"));
 
-                JSONObject o = parseRequest(req);
-                restReq0.argument(o.get("arg"));
+                Map o = parseRequest(req);
+                restReq0.argument(ctx.scripting().toJavaObject(o.get("arg")));
 
                 restReq = restReq0;
 
@@ -592,8 +593,8 @@ public class GridJettyRestHandler extends AbstractHandler {
                 restReq0.script((String)params.get("func"));
                 restReq0.cacheName((String) params.get("cacheName"));
 
-                JSONObject o = parseRequest(req);
-                restReq0.argument(o.get("arg"));
+                Map o = parseRequest(req);
+                restReq0.argument(ctx.scripting().toJavaObject(o.get("arg")));
 
                 Object cacheObj = ctx.scripting().toJavaObject(o.get("key"));
                 restReq0.affinityKey(cacheObj);
@@ -608,8 +609,8 @@ public class GridJettyRestHandler extends AbstractHandler {
 
                 restReq0.mapFunction((String) params.get("map"));
 
-                JSONObject o = parseRequest(req);
-                restReq0.argument(o.get("arg"));
+                Map o = parseRequest(req);
+                restReq0.argument(ctx.scripting().toJavaObject(o.get("arg")));
 
                 restReq0.reduceFunction((String) params.get("reduce"));
 
@@ -624,9 +625,8 @@ public class GridJettyRestHandler extends AbstractHandler {
 
                 restReq0.sqlQuery((String)params.get("qry"));
 
-                JSONObject o = parseRequest(req);
-
-                List args = (List)o.get("arg");
+                Map o = parseRequest(req);
+                List args = (List)ctx.scripting().toJavaObject(o.get("arg"));
 
                 restReq0.arguments(args.toArray());
                 restReq0.typeName((String)params.get("type"));
@@ -851,21 +851,12 @@ public class GridJettyRestHandler extends AbstractHandler {
      * @return JSON object.
      * @throws IgniteCheckedException If failed.
      */
-    private JSONObject parseRequest(HttpServletRequest req) throws IgniteCheckedException{
-        StringBuilder builder = new StringBuilder();
-
-        Scanner reader;
-
+    private Map parseRequest(HttpServletRequest req) throws IgniteCheckedException{
         try {
-            reader = new Scanner(req.getInputStream());
+            return new JsonProviderImpl().createReader(req.getInputStream()).readObject();
         }
         catch (IOException e) {
             throw new IgniteCheckedException(e);
         }
-
-        while (reader.hasNext())
-            builder.append(reader.nextLine() + "\n");
-
-        return JSONObject.fromObject(builder.toString());
     }
 }


[13/14] incubator-ignite git commit: Merge remote-tracking branch 'remotes/origin/ignite-961' into ignite-1121

Posted by se...@apache.org.
Merge remote-tracking branch 'remotes/origin/ignite-961' into ignite-1121


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

Branch: refs/heads/ignite-1121
Commit: 309a71bb4fda47363c527f0f8f84485de2dfa3d2
Parents: 0fd8fd8 a7f664e
Author: sevdokimov <se...@jetbrains.com>
Authored: Fri Jul 17 16:00:39 2015 +0300
Committer: sevdokimov <se...@jetbrains.com>
Committed: Fri Jul 17 16:00:39 2015 +0300

----------------------------------------------------------------------
 .../JettyRestProcessorAbstractSelfTest.java     |  73 ++++----
 .../apache/ignite/internal/IgniteKernal.java    |  12 ++
 .../processors/cache/GridCacheContext.java      |  45 +++--
 .../processors/cache/GridCacheMvccManager.java  |   6 +-
 .../GridCachePartitionExchangeManager.java      |  53 ++++++
 .../distributed/dht/GridDhtTopologyFuture.java  |  14 --
 .../dht/atomic/GridDhtAtomicCache.java          |   4 +-
 .../dht/atomic/GridNearAtomicUpdateFuture.java  |  11 +-
 .../GridDhtPartitionsExchangeFuture.java        |  31 +---
 .../cache/transactions/IgniteTxManager.java     |   4 +-
 .../scripting/IgniteScriptingConverter.java     |  44 +++++
 .../scripting/IgniteScriptingProcessor.java     |  41 ++++-
 .../org/apache/ignite/json/JSONCacheObject.java |   2 +-
 .../distributed/IgniteCache150ClientsTest.java  |   1 +
 .../IgniteCacheClientReconnectTest.java         | 175 +++++++++++++++++++
 .../IgniteCacheServerNodeConcurrentStart.java   |  96 ++++++++++
 .../testframework/junits/GridAbstractTest.java  |   5 +
 .../testsuites/IgniteCacheTestSuite2.java       |   2 +-
 .../testsuites/IgniteCacheTestSuite4.java       |   2 -
 .../testsuites/IgniteClientNodesTestSuite.java  |  42 +++++
 modules/nodejs/src/main/js/server.js            |   2 +-
 modules/rest-http/pom.xml                       |   6 +
 .../http/jetty/GridJettyRestHandler.java        |  72 ++++----
 .../http/jetty/GridJettyRestProtocol.java       |   2 +-
 .../jetty/RestGlassFishScriptingConverter.java  |  68 +++++++
 25 files changed, 669 insertions(+), 144 deletions(-)
----------------------------------------------------------------------



[10/14] incubator-ignite git commit: #ignite-961: fix class

Posted by se...@apache.org.
#ignite-961: fix class


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

Branch: refs/heads/ignite-1121
Commit: 7b793af9d74593abccb42b62cb5f30930a8079db
Parents: 3d94e84
Author: ivasilinets <iv...@gridgain.com>
Authored: Fri Jul 17 13:39:10 2015 +0300
Committer: ivasilinets <iv...@gridgain.com>
Committed: Fri Jul 17 13:39:10 2015 +0300

----------------------------------------------------------------------
 .../http/jetty/GlassfishScriptingConverter.java | 68 --------------------
 .../jetty/RestGlassFishScriptingConverter.java  | 68 ++++++++++++++++++++
 2 files changed, 68 insertions(+), 68 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7b793af9/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GlassfishScriptingConverter.java
----------------------------------------------------------------------
diff --git a/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GlassfishScriptingConverter.java b/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GlassfishScriptingConverter.java
deleted file mode 100644
index dc56550..0000000
--- a/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GlassfishScriptingConverter.java
+++ /dev/null
@@ -1,68 +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.protocols.http.jetty;
-
-import org.apache.ignite.internal.processors.scripting.*;
-import org.apache.ignite.json.*;
-
-import javax.json.*;
-import java.util.*;
-
-/**
- * Converter for glassfish objects.
- */
-public class GlassFishScriptingConverter extends IgniteScriptingConverter {
-    /** {@inheritDoc} */
-    @Override public Object toJavaObject(Object o) {
-        if (o == null)
-            return null;
-
-        if (o instanceof Map) {
-            Map o1 = (Map)o;
-
-            JSONCacheObject res = new JSONCacheObject();
-
-            for (Object key : o1.keySet())
-                res.put(toJavaObject(key), toJavaObject(o1.get(key)));
-
-            return res;
-        }
-        else if (o instanceof List) {
-            List o1 = (List) o;
-
-            List<Object> val = new ArrayList<>();
-
-            for (Object v : o1)
-                val.add(toJavaObject(v));
-
-            return val;
-        }
-        else if (o instanceof JsonString)
-            return ((JsonString) o).getString();
-        else if (o instanceof JsonNumber)
-            return ((JsonNumber) o).intValue();
-        else if (o.equals(JsonValue.FALSE))
-            return false;
-        else if (o.equals(JsonValue.TRUE))
-            return true;
-        else if (o.equals(JsonValue.NULL))
-            return null;
-
-        return o;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7b793af9/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/RestGlassFishScriptingConverter.java
----------------------------------------------------------------------
diff --git a/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/RestGlassFishScriptingConverter.java b/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/RestGlassFishScriptingConverter.java
new file mode 100644
index 0000000..87e86c0
--- /dev/null
+++ b/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/RestGlassFishScriptingConverter.java
@@ -0,0 +1,68 @@
+/*
+ * 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.protocols.http.jetty;
+
+import org.apache.ignite.internal.processors.scripting.*;
+import org.apache.ignite.json.*;
+
+import javax.json.*;
+import java.util.*;
+
+/**
+ * Converter for glassfish objects.
+ */
+public class RestGlassFishScriptingConverter extends IgniteScriptingConverter {
+    /** {@inheritDoc} */
+    @Override public Object toJavaObject(Object o) {
+        if (o == null)
+            return null;
+
+        if (o instanceof Map) {
+            Map o1 = (Map)o;
+
+            JSONCacheObject res = new JSONCacheObject();
+
+            for (Object key : o1.keySet())
+                res.put(toJavaObject(key), toJavaObject(o1.get(key)));
+
+            return res;
+        }
+        else if (o instanceof List) {
+            List o1 = (List) o;
+
+            List<Object> val = new ArrayList<>();
+
+            for (Object v : o1)
+                val.add(toJavaObject(v));
+
+            return val;
+        }
+        else if (o instanceof JsonString)
+            return ((JsonString) o).getString();
+        else if (o instanceof JsonNumber)
+            return ((JsonNumber) o).intValue();
+        else if (o.equals(JsonValue.FALSE))
+            return false;
+        else if (o.equals(JsonValue.TRUE))
+            return true;
+        else if (o.equals(JsonValue.NULL))
+            return null;
+
+        return o;
+    }
+}


[04/14] incubator-ignite git commit: # ignite-1124 fixes for atomic cache update, more debug info for hanging tests

Posted by se...@apache.org.
# ignite-1124 fixes for atomic cache update, more debug info for hanging tests


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

Branch: refs/heads/ignite-1121
Commit: f0d24f6b64e308de3170d5e7fb2092cb5b1421b7
Parents: 44043fa
Author: sboikov <sb...@gridgain.com>
Authored: Fri Jul 17 12:16:06 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Fri Jul 17 12:16:06 2015 +0300

----------------------------------------------------------------------
 .../apache/ignite/internal/IgniteKernal.java    |  12 ++
 .../processors/cache/GridCacheContext.java      |  45 +++--
 .../processors/cache/GridCacheMvccManager.java  |   6 +-
 .../GridCachePartitionExchangeManager.java      |  53 ++++++
 .../distributed/dht/GridDhtTopologyFuture.java  |  14 --
 .../dht/atomic/GridDhtAtomicCache.java          |   4 +-
 .../dht/atomic/GridNearAtomicUpdateFuture.java  |  11 +-
 .../GridDhtPartitionsExchangeFuture.java        |  31 +---
 .../cache/transactions/IgniteTxManager.java     |   4 +-
 .../distributed/IgniteCache150ClientsTest.java  |   1 +
 .../IgniteCacheClientReconnectTest.java         | 175 +++++++++++++++++++
 .../IgniteCacheServerNodeConcurrentStart.java   |  96 ++++++++++
 .../testframework/junits/GridAbstractTest.java  |   5 +
 .../testsuites/IgniteCacheTestSuite2.java       |   2 +-
 .../testsuites/IgniteCacheTestSuite4.java       |   2 -
 .../testsuites/IgniteClientNodesTestSuite.java  |  42 +++++
 16 files changed, 439 insertions(+), 64 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f0d24f6b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
index 0d4ce32..c411f2e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
@@ -3009,6 +3009,18 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
         return ctx.isDaemon() && U.hasAnnotation(comp.getClass(), SkipDaemon.class);
     }
 
+    /**
+     *
+     */
+    public void dumpDebugInfo() {
+        U.warn(log, "Dumping debug info for node [id=" + ctx.localNodeId() +
+            ", name=" + ctx.gridName() +
+            ", order=" + ctx.discovery().localNode().order() +
+            ", client=" + ctx.clientNode() + ']');
+
+        ctx.cache().context().exchange().dumpDebugInfo();
+    }
+
     /** {@inheritDoc} */
     @Override public String toString() {
         return S.toString(IgniteKernal.class, this);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f0d24f6b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
index aec08c6..5f17746 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
@@ -524,7 +524,21 @@ public class GridCacheContext<K, V> implements Externalizable {
      * @return {@code True} if entries should not be deleted from cache immediately.
      */
     public boolean deferredDelete() {
-        return isDht() || isDhtAtomic() || isColocated() || (isNear() && atomic());
+        GridCacheAdapter<K, V> cache = this.cache;
+
+        if (cache == null)
+            throw new IllegalStateException("Cache stopped: " + cacheName);
+
+        return deferredDelete(cache);
+    }
+
+    /**
+     * @param cache Cache.
+     * @return {@code True} if entries should not be deleted from cache immediately.
+     */
+    public boolean deferredDelete(GridCacheAdapter<?, ?> cache) {
+        return cache.isDht() || cache.isDhtAtomic() || cache.isColocated() ||
+            (cache.isNear() && cache.configuration().getAtomicityMode() == ATOMIC);
     }
 
     /**
@@ -765,26 +779,37 @@ public class GridCacheContext<K, V> implements Externalizable {
      * @return Partition topology.
      */
     public GridDhtPartitionTopology topology() {
-        assert isNear() || isDht() || isColocated() || isDhtAtomic() : cache;
+        GridCacheAdapter<K, V> cache = this.cache;
 
-        return isNear() ? near().dht().topology() : dht().topology();
+        if (cache == null)
+            throw new IllegalStateException("Cache stopped: " + cacheName);
+
+        assert cache.isNear() || cache.isDht() || cache.isColocated() || cache.isDhtAtomic() : cache;
+
+        return topology(cache);
     }
 
     /**
      * @return Topology version future.
      */
     public GridDhtTopologyFuture topologyVersionFuture() {
-        assert isNear() || isDht() || isColocated() || isDhtAtomic() : cache;
+        GridCacheAdapter<K, V> cache = this.cache;
 
-        GridDhtTopologyFuture fut = null;
+        if (cache == null)
+            throw new IllegalStateException("Cache stopped: " + cacheName);
 
-        if (!isDhtAtomic()) {
-            GridDhtCacheAdapter<K, V> cache = isNear() ? near().dht() : colocated();
+        assert cache.isNear() || cache.isDht() || cache.isColocated() || cache.isDhtAtomic() : cache;
 
-            fut = cache.multiUpdateTopologyFuture();
-        }
+        return topology(cache).topologyVersionFuture();
+    }
 
-        return fut == null ? topology().topologyVersionFuture() : fut;
+    /**
+     * @param cache Cache.
+     * @return Partition topology.
+     */
+    private GridDhtPartitionTopology topology(GridCacheAdapter<K, V> cache) {
+        return cache.isNear() ? ((GridNearCacheAdapter<K, V>)cache).dht().topology() :
+            ((GridDhtCacheAdapter<K, V>)cache).topology();
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f0d24f6b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java
index 36e108f..bfb23e8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java
@@ -208,8 +208,12 @@ public class GridCacheMvccManager extends GridCacheSharedManagerAdapter {
         exchLog = cctx.logger(getClass().getName() + ".exchange");
 
         pendingExplicit = GridConcurrentFactory.newMap();
+    }
 
-        cctx.gridEvents().addLocalEventListener(discoLsnr, EVT_NODE_FAILED, EVT_NODE_LEFT);
+    /** {@inheritDoc} */
+    @Override protected void onKernalStart0(boolean reconnect) throws IgniteCheckedException {
+        if (!reconnect)
+            cctx.gridEvents().addLocalEventListener(discoLsnr, EVT_NODE_FAILED, EVT_NODE_LEFT);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f0d24f6b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
index 1f6a8bb..c26f5c3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
@@ -27,6 +27,7 @@ import org.apache.ignite.internal.managers.eventstorage.*;
 import org.apache.ignite.internal.processors.affinity.*;
 import org.apache.ignite.internal.processors.cache.distributed.dht.*;
 import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.*;
+import org.apache.ignite.internal.processors.cache.transactions.*;
 import org.apache.ignite.internal.processors.timeout.*;
 import org.apache.ignite.internal.util.*;
 import org.apache.ignite.internal.util.future.*;
@@ -949,6 +950,58 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
     }
 
     /**
+     *
+     */
+    public void dumpDebugInfo() {
+        U.warn(log, "Ready affinity version: " + readyTopVer.get());
+
+        U.warn(log, "Last exchange future: " + lastInitializedFut);
+
+        U.warn(log, "Pending exchange futures:");
+
+        for (GridDhtPartitionsExchangeFuture fut : pendingExchangeFuts)
+            U.warn(log, ">>> " + fut);
+
+        U.warn(log, "Last 10 exchange futures (total: " + exchFuts.size() + "):");
+
+        int cnt = 0;
+
+        for (GridDhtPartitionsExchangeFuture fut : exchFuts) {
+            U.warn(log, ">>> " + fut);
+
+            if (++cnt == 10)
+                break;
+        }
+
+        dumpPendingObjects();
+    }
+
+    /**
+     *
+     */
+    public void dumpPendingObjects() {
+        U.warn(log, "Pending transactions:");
+
+        for (IgniteInternalTx tx : cctx.tm().activeTransactions())
+            U.warn(log, ">>> " + tx);
+
+        U.warn(log, "Pending explicit locks:");
+
+        for (GridCacheExplicitLockSpan lockSpan : cctx.mvcc().activeExplicitLocks())
+            U.warn(log, ">>> " + lockSpan);
+
+        U.warn(log, "Pending cache futures:");
+
+        for (GridCacheFuture<?> fut : cctx.mvcc().activeFutures())
+            U.warn(log, ">>> " + fut);
+
+        U.warn(log, "Pending atomic cache futures:");
+
+        for (GridCacheFuture<?> fut : cctx.mvcc().atomicFutures())
+            U.warn(log, ">>> " + fut);
+    }
+
+    /**
      * @param deque Deque to poll from.
      * @param time Time to wait.
      * @param w Worker.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f0d24f6b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTopologyFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTopologyFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTopologyFuture.java
index 8a02ff2..57e3e33 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTopologyFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTopologyFuture.java
@@ -17,9 +17,7 @@
 
 package org.apache.ignite.internal.processors.cache.distributed.dht;
 
-import org.apache.ignite.*;
 import org.apache.ignite.internal.*;
-import org.apache.ignite.internal.managers.discovery.*;
 import org.apache.ignite.internal.processors.affinity.*;
 import org.apache.ignite.internal.processors.cache.*;
 
@@ -33,18 +31,6 @@ import org.apache.ignite.internal.processors.cache.*;
  */
 public interface GridDhtTopologyFuture extends IgniteInternalFuture<AffinityTopologyVersion> {
     /**
-     * Gets a topology snapshot for the topology version represented by the future. Note that by the time
-     * partition exchange completes some nodes from the snapshot may leave the grid. One should use discovery
-     * service to check if the node is valid.
-     * <p/>
-     * This method will block until the topology future is ready.
-     *
-     * @return Topology snapshot for particular topology version.
-     * @throws IgniteCheckedException If topology future failed.
-     */
-    public GridDiscoveryTopologySnapshot topologySnapshot() throws IgniteCheckedException;
-
-    /**
      * Gets topology version of this future.
      *
      * @return Topology version.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f0d24f6b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
index 96e6edc..0a21979 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
@@ -1159,7 +1159,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
                 // Enqueue if necessary after locks release.
                 if (deleted != null) {
                     assert !deleted.isEmpty();
-                    assert ctx.deferredDelete();
+                    assert ctx.deferredDelete(this) : this;
 
                     for (IgniteBiTuple<GridDhtCacheEntry, GridCacheVersion> e : deleted)
                         ctx.onDeferredDelete(e.get1(), e.get2());
@@ -2158,7 +2158,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
      */
     private void unlockEntries(Collection<GridDhtCacheEntry> locked, AffinityTopologyVersion topVer) {
         // Process deleted entries before locks release.
-        assert ctx.deferredDelete() : this;
+        assert ctx.deferredDelete(this) : this;
 
         // Entries to skip eviction manager notification for.
         // Enqueue entries while holding locks.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f0d24f6b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java
index 751c9ba..4c8a161 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java
@@ -338,6 +338,8 @@ public class GridNearAtomicUpdateFuture extends GridFutureAdapter<Object>
     /** {@inheritDoc} */
     @Override public IgniteInternalFuture<Void> completeFuture(AffinityTopologyVersion topVer) {
         if (waitForPartitionExchange() && topologyVersion().compareTo(topVer) < 0) {
+            GridFutureAdapter<Void> fut = null;
+
             synchronized (this) {
                 if (this.topVer == AffinityTopologyVersion.ZERO)
                     return null;
@@ -346,9 +348,14 @@ public class GridNearAtomicUpdateFuture extends GridFutureAdapter<Object>
                     if (topCompleteFut == null)
                         topCompleteFut = new GridFutureAdapter<>();
 
-                    return topCompleteFut;
+                    fut = topCompleteFut;
                 }
             }
+
+            if (fut != null && isDone())
+                fut.onDone();
+
+            return fut;
         }
 
         return null;
@@ -582,7 +589,7 @@ public class GridNearAtomicUpdateFuture extends GridFutureAdapter<Object>
                 return;
             }
 
-            GridDhtTopologyFuture fut = cctx.topologyVersionFuture();
+            GridDhtTopologyFuture fut = cache.topology().topologyVersionFuture();
 
             if (fut.isDone()) {
                 if (!fut.isCacheTopologyValid(cctx)) {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f0d24f6b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
index 5701749..b3f19f6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
@@ -244,17 +244,6 @@ public class GridDhtPartitionsExchangeFuture extends GridFutureAdapter<AffinityT
     }
 
     /** {@inheritDoc} */
-    @Override public GridDiscoveryTopologySnapshot topologySnapshot() throws IgniteCheckedException {
-        get();
-
-        if (topSnapshot.get() == null)
-            topSnapshot.compareAndSet(null, new GridDiscoveryTopologySnapshot(discoEvt.topologyVersion(),
-                discoEvt.topologyNodes()));
-
-        return topSnapshot.get();
-    }
-
-    /** {@inheritDoc} */
     @Override public AffinityTopologyVersion topologyVersion() {
         return exchId.topologyVersion();
     }
@@ -853,25 +842,7 @@ public class GridDhtPartitionsExchangeFuture extends GridFutureAdapter<AffinityT
         U.warn(log, "Failed to wait for partition release future. Dumping pending objects that might be the cause: " +
             cctx.localNodeId());
 
-        U.warn(log, "Pending transactions:");
-
-        for (IgniteInternalTx tx : cctx.tm().activeTransactions())
-            U.warn(log, ">>> " + tx);
-
-        U.warn(log, "Pending explicit locks:");
-
-        for (GridCacheExplicitLockSpan lockSpan : cctx.mvcc().activeExplicitLocks())
-            U.warn(log, ">>> " + lockSpan);
-
-        U.warn(log, "Pending cache futures:");
-
-        for (GridCacheFuture<?> fut : cctx.mvcc().activeFutures())
-            U.warn(log, ">>> " + fut);
-
-        U.warn(log, "Pending atomic cache futures:");
-
-        for (GridCacheFuture<?> fut : cctx.mvcc().atomicFutures())
-            U.warn(log, ">>> " + fut);
+        cctx.exchange().dumpPendingObjects();
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f0d24f6b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
index 82543c2..ee634ab 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
@@ -1984,9 +1984,9 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
             try {
                 cctx.kernalContext().gateway().readLock();
             }
-            catch (IllegalStateException ignore) {
+            catch (IllegalStateException | IgniteClientDisconnectedException ignore) {
                 if (log.isDebugEnabled())
-                    log.debug("Failed to acquire kernal gateway (grid is stopping).");
+                    log.debug("Failed to acquire kernal gateway [err=" + ignore + ']');
 
                 return;
             }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f0d24f6b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCache150ClientsTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCache150ClientsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCache150ClientsTest.java
index 282c7c8..3fc44c0 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCache150ClientsTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCache150ClientsTest.java
@@ -51,6 +51,7 @@ public class IgniteCache150ClientsTest extends GridCommonAbstractTest {
     @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
         IgniteConfiguration cfg = super.getConfiguration(gridName);
 
+        cfg.setLocalHost("127.0.0.1");
         cfg.setNetworkTimeout(30_000);
         cfg.setConnectorConfiguration(null);
         cfg.setPeerClassLoadingEnabled(false);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f0d24f6b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientReconnectTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientReconnectTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientReconnectTest.java
new file mode 100644
index 0000000..c438c39
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientReconnectTest.java
@@ -0,0 +1,175 @@
+/*
+ * 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.cache.distributed;
+
+import org.apache.ignite.*;
+import org.apache.ignite.configuration.*;
+import org.apache.ignite.internal.*;
+import org.apache.ignite.spi.discovery.tcp.*;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
+import org.apache.ignite.testframework.*;
+import org.apache.ignite.testframework.junits.common.*;
+
+import java.util.concurrent.*;
+import java.util.concurrent.atomic.*;
+
+import static java.util.concurrent.TimeUnit.*;
+import static org.apache.ignite.cache.CacheAtomicityMode.*;
+import static org.apache.ignite.cache.CacheMode.*;
+
+/**
+ * Test for customer scenario.
+ */
+public class IgniteCacheClientReconnectTest extends GridCommonAbstractTest {
+    /** */
+    private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
+
+    /** */
+    private static final int SRV_CNT = 3;
+
+    /** */
+    private static final int CACHES = 10;
+
+    /** */
+    private static final long TEST_TIME = 60_000;
+
+    /** */
+    private boolean client;
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        cfg.setPeerClassLoadingEnabled(false);
+
+        ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder);
+
+        if (!client) {
+            CacheConfiguration[] ccfgs = new CacheConfiguration[CACHES];
+
+            for (int i = 0; i < CACHES; i++) {
+                CacheConfiguration ccfg = new CacheConfiguration();
+
+                ccfg.setCacheMode(PARTITIONED);
+                ccfg.setAtomicityMode(TRANSACTIONAL);
+                ccfg.setBackups(1);
+                ccfg.setName("cache-" + i);
+
+                ccfgs[i] = ccfg;
+            }
+
+            cfg.setCacheConfiguration(ccfgs);
+        }
+
+        cfg.setClientMode(client);
+
+        return cfg;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTestsStarted() throws Exception {
+        startGrids(SRV_CNT);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTestsStopped() throws Exception {
+        super.afterTestsStopped();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected long getTestTimeout() {
+        return TEST_TIME + 60_000;
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testClientReconnect() throws Exception {
+        client = true;
+
+        final AtomicBoolean stop = new AtomicBoolean(false);
+
+        final AtomicInteger idx = new AtomicInteger(SRV_CNT);
+
+        final CountDownLatch latch = new CountDownLatch(2);
+
+        IgniteInternalFuture<?> fut = GridTestUtils.runMultiThreadedAsync(new Callable<Void>() {
+            @Override public Void call() throws Exception {
+                Ignite ignite = startGrid(idx.getAndIncrement());
+
+                latch.countDown();
+
+                assertTrue(ignite.cluster().localNode().isClient());
+
+                while (!stop.get())
+                    putGet(ignite);
+
+                return null;
+            }
+        }, 2, "client-thread");
+
+        try {
+            assertTrue(latch.await(10_000, MILLISECONDS));
+
+            long end = System.currentTimeMillis() + TEST_TIME;
+
+            int clientIdx = idx.getAndIncrement();
+
+            int cnt = 0;
+
+            while (System.currentTimeMillis() < end) {
+                log.info("Iteration: " + cnt++);
+
+                try (Ignite ignite = startGrid(clientIdx)) {
+                    assertTrue(ignite.cluster().localNode().isClient());
+
+                    assertEquals(6, ignite.cluster().nodes().size());
+
+                    putGet(ignite);
+                }
+            }
+
+            stop.set(true);
+
+            fut.get();
+        }
+        finally {
+            stop.set(true);
+        }
+    }
+
+    /**
+     * @param ignite Ignite.
+     */
+    private void putGet(Ignite ignite) {
+        ThreadLocalRandom rnd = ThreadLocalRandom.current();
+
+        for (int i = 0; i < CACHES; i++) {
+            IgniteCache<Object, Object> cache = ignite.cache("cache-" + i);
+
+            assertNotNull(cache);
+
+            Integer key = rnd.nextInt(0, 100_000);
+
+            cache.put(key, key);
+
+            assertEquals(key, cache.get(key));
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f0d24f6b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheServerNodeConcurrentStart.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheServerNodeConcurrentStart.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheServerNodeConcurrentStart.java
new file mode 100644
index 0000000..6b5d396
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheServerNodeConcurrentStart.java
@@ -0,0 +1,96 @@
+/*
+ * 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.cache.distributed;
+
+import org.apache.ignite.configuration.*;
+import org.apache.ignite.spi.discovery.tcp.*;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
+import org.apache.ignite.testframework.junits.common.*;
+
+import static org.apache.ignite.cache.CacheMode.*;
+import static org.apache.ignite.cache.CacheRebalanceMode.*;
+
+/**
+ *
+ */
+public class IgniteCacheServerNodeConcurrentStart extends GridCommonAbstractTest {
+    /** */
+    private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
+
+    /** */
+    private static final int ITERATIONS = 2;
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder);
+        ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinderCleanFrequency(getTestTimeout() * 2);
+
+        CacheConfiguration ccfg1 = new CacheConfiguration();
+
+        ccfg1.setName("cache-1");
+        ccfg1.setCacheMode(REPLICATED);
+        ccfg1.setRebalanceMode(SYNC);
+
+        CacheConfiguration ccfg2 = new CacheConfiguration();
+
+        ccfg2.setName("cache-2");
+        ccfg2.setCacheMode(PARTITIONED);
+        ccfg2.setRebalanceMode(SYNC);
+        ccfg2.setBackups(2);
+
+        CacheConfiguration ccfg3 = new CacheConfiguration();
+
+        ccfg3.setName("cache-3");
+        ccfg3.setCacheMode(PARTITIONED);
+        ccfg3.setRebalanceMode(SYNC);
+        ccfg3.setBackups(0);
+
+        cfg.setCacheConfiguration(ccfg1, ccfg2, ccfg3);
+
+        return cfg;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected long getTestTimeout() {
+        return ITERATIONS * 3 * 60_000;
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testConcurrentStart() throws Exception {
+        for (int i = 0; i < ITERATIONS; i++) {
+            log.info("Iteration: " + i);
+
+            long start = System.currentTimeMillis();
+
+            startGridsMultiThreaded(10, false);
+
+            startGridsMultiThreaded(10, 10);
+
+            awaitPartitionMapExchange();
+
+            stopAllGrids();
+
+            log.info("Iteration finished, time: " + (System.currentTimeMillis() - start) / 1000f);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f0d24f6b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
index 06a1523..9a55ccf 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
@@ -1577,6 +1577,11 @@ public abstract class GridAbstractTest extends TestCase {
                 "Test has been timed out and will be interrupted (threads dump will be taken before interruption) [" +
                 "test=" + getName() + ", timeout=" + getTestTimeout() + ']');
 
+            List<Ignite> nodes = G.allGrids();
+
+            for (Ignite node : nodes)
+                ((IgniteKernal)node).dumpDebugInfo();
+
             // We dump threads to stdout, because we can loose logs in case
             // the build is cancelled on TeamCity.
             U.dumpThreads(null);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f0d24f6b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite2.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite2.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite2.java
index 6a59826..741da87 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite2.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite2.java
@@ -136,7 +136,7 @@ public class IgniteCacheTestSuite2 extends TestSuite {
         suite.addTest(new TestSuite(IgniteCachePartitionMapUpdateTest.class));
         suite.addTest(new TestSuite(IgniteCacheClientNodePartitionsExchangeTest.class));
         suite.addTest(new TestSuite(IgniteCacheClientNodeChangingTopologyTest.class));
-        suite.addTest(new TestSuite(IgniteCacheClientNodeConcurrentStart.class));
+        suite.addTest(new TestSuite(IgniteCacheServerNodeConcurrentStart.class));
 
         return suite;
     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f0d24f6b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java
index bde3a72..18b2409 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java
@@ -146,8 +146,6 @@ public class IgniteCacheTestSuite4 extends TestSuite {
         suite.addTestSuite(IgniteStartCacheInTransactionSelfTest.class);
         suite.addTestSuite(IgniteStartCacheInTransactionAtomicSelfTest.class);
 
-        suite.addTestSuite(IgniteCacheManyClientsTest.class);
-
         suite.addTestSuite(CacheReadThroughRestartSelfTest.class);
         suite.addTestSuite(CacheReadThroughReplicatedRestartSelfTest.class);
         suite.addTestSuite(CacheReadThroughReplicatedAtomicRestartSelfTest.class);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f0d24f6b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteClientNodesTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteClientNodesTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteClientNodesTestSuite.java
new file mode 100644
index 0000000..5cc4e5a
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteClientNodesTestSuite.java
@@ -0,0 +1,42 @@
+/*
+ * 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.testsuites;
+
+import junit.framework.*;
+import org.apache.ignite.internal.processors.cache.distributed.*;
+
+/**
+ *
+ */
+public class IgniteClientNodesTestSuite extends TestSuite {
+    /**
+     * @return Test suite.
+     * @throws Exception In case of error.
+     */
+    public static TestSuite suite() throws Exception {
+        TestSuite suite = new TestSuite("Ignite Client Nodes Reconnect Test Suite");
+
+        suite.addTest(IgniteClientReconnectTestSuite.suite());
+
+        suite.addTestSuite(IgniteCacheManyClientsTest.class);
+        suite.addTestSuite(IgniteCacheClientNodeConcurrentStart.class);
+        suite.addTestSuite(IgniteCacheClientReconnectTest.class);
+
+        return suite;
+    }
+}


[06/14] incubator-ignite git commit: #ignite-961: fix rest test.

Posted by se...@apache.org.
#ignite-961: fix rest test.


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

Branch: refs/heads/ignite-1121
Commit: 8ebb4413e58eef06c667bf7d8e14cb811f13c221
Parents: 18a3e05
Author: ivasilinets <iv...@gridgain.com>
Authored: Fri Jul 17 13:17:44 2015 +0300
Committer: ivasilinets <iv...@gridgain.com>
Committed: Fri Jul 17 13:17:44 2015 +0300

----------------------------------------------------------------------
 .../JettyRestProcessorAbstractSelfTest.java     | 46 ++++++++++----------
 1 file changed, 22 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8ebb4413/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java
index d6af0b7..04f4a2a 100644
--- a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java
+++ b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java
@@ -126,13 +126,11 @@ abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestProcessorS
 
         conn.setRequestProperty("JSONObject", "true");
 
-        conn.setRequestProperty( "charset", "utf-8");
-
         conn.setUseCaches(false);
         conn.setDoOutput(true);
 
-        try (OutputStream wr = conn.getOutputStream()) {
-            wr.write(data);
+        try (PrintStream wr = new PrintStream(conn.getOutputStream())) {
+            wr.print(urlParameters);
             wr.flush();
             wr.close();
         }
@@ -362,7 +360,7 @@ abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestProcessorS
     public void testGetPost() throws Exception {
         jcache().put("key0", "val0");
 
-        String val = "{'key':'key0'}";
+        String val = "{\"key\":\"key0\"}";
         String ret = makePostRequest(F.asMap("cmd", "get"), val);
 
         assertNotNull(ret);
@@ -379,7 +377,7 @@ abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestProcessorS
     public void testReplacePost() throws Exception {
         jcache().put("key0", "val0");
 
-        String val = "{'key':'key0', 'val':'val2', 'oldVal':'val1'}";
+        String val = "{\"key\":\"key0\", \"val\":\"val2\", \"oldVal\":\"val1\"}";
         String ret = makePostRequest(F.asMap("cmd", "repval"), val);
 
         assertNotNull(ret);
@@ -389,14 +387,14 @@ abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestProcessorS
 
         jsonEquals(ret, cachePattern(false, true));
 
-        val = "{'key':'key0', 'val':'val2'}";
+        val = "{\"key\":\"key0\", \"val\":\"val2\"}";
         ret = makePostRequest(F.asMap("cmd", "getandreplace"), val);
 
         jsonEquals(ret, cachePattern("val0", true));
 
         assertEquals("val2", grid(0).cache(null).get("key0"));
 
-        val = "{'key':'key0', 'val':'val3'}";
+        val = "{\"key\":\"key0\", \"val\":\"val3\"}";
         ret = makePostRequest(F.asMap("cmd", "rep"), val);
 
         assertNotNull(ret);
@@ -413,7 +411,7 @@ abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestProcessorS
     public void testRemovePost() throws Exception {
         jcache().put("key0", "val0");
 
-        String val = "{'key':'key0', 'val':'val2'}";
+        String val = "{\"key\":\"key0\", \"val\":\"val2\"}";
         String ret = makePostRequest(F.asMap("cmd", "rmvvalue"), val);
 
         assertNotNull(ret);
@@ -425,7 +423,7 @@ abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestProcessorS
 
         assertEquals("val0", grid(0).cache(null).get("key0"));
 
-        val = "{'key':'key0'}";
+        val = "{\"key\":\"key0\"}";
         ret = makePostRequest(F.asMap("cmd", "getandrmv"), val);
 
         jsonEquals(ret, cachePattern("val0", true));
@@ -440,7 +438,7 @@ abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestProcessorS
         jcache().put("key0", "val0");
         jcache().put("key1", "val1");
 
-        String val = "{'keys': ['key0', 'key1']}";
+        String val = "{\"keys\": [\"key0\", \"key1\"]}";
         String ret = makePostRequest(F.asMap("cmd", "rmvall"), val);
 
         assertNotNull(ret);
@@ -453,7 +451,7 @@ abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestProcessorS
      * @throws Exception If failed.
      */
     public void testPutPost() throws Exception {
-        String val = "{'key':'key0', 'val':'val0'}";
+        String val = "{\"key\":\"key0\",\"val\":\"val0\"}";
         String ret = makePostRequest(F.asMap("cmd", "put"), val);
 
         assertNotNull(ret);
@@ -461,7 +459,7 @@ abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestProcessorS
 
         assertNotNull(grid(0).cache(null).get("key0"));
 
-        val = "{'key':'key0'}";
+        val = "{\"key\":\"key0\"}";
         ret = makePostRequest(F.asMap("cmd", "containskey"), val);
 
         assertNotNull(ret);
@@ -474,7 +472,7 @@ abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestProcessorS
      * @throws Exception If failed.
      */
     public void testGetAndPut() throws Exception {
-        String val = "{'key':'key0', 'val':'val0'}";
+        String val = "{\"key\":\"key0\", \"val\":\"val0\"}";
         String ret = makePostRequest(F.asMap("cmd", "getandput"), val);
 
         assertNotNull(ret);
@@ -484,7 +482,7 @@ abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestProcessorS
 
         assertNotNull(grid(0).cache(null).get("key0"));
 
-        val = "{'key': 'key0', 'val':'val1'}";
+        val = "{\"key\": \"key0\", \"val\":\"val1\"}";
         ret = makePostRequest(F.asMap("cmd", "getandputifabsent"), val);
 
         assertNotNull(ret);
@@ -494,7 +492,7 @@ abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestProcessorS
 
         assertEquals("val0", grid(0).cache(null).get("key0"));
 
-        val = "{'key': 'key0'}";
+        val = "{\"key\": \"key0\"}";
         ret = makePostRequest(F.asMap("cmd", "rmv"), val);
 
         assertNotNull(ret);
@@ -502,7 +500,7 @@ abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestProcessorS
 
         assertNull(grid(0).cache(null).get("key0"));
 
-        val = "{'key': 'key0', 'val':'val1'}";
+        val = "{\"key\": \"key0\", \"val\":\"val1\"}";
         ret = makePostRequest(F.asMap("cmd", "putifabsent"), val);
 
         assertNotNull(ret);
@@ -517,7 +515,7 @@ abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestProcessorS
      * @throws Exception If failed.
      */
     public void testPutAllPost() throws Exception {
-        String val = "{'entries': [{'key':'key0', 'value': 'val0'}, {'key':'key1', 'value':'val1'}]}";
+        String val = "{\"entries\": [{\"key\":\"key0\", \"value\": \"val0\"}, {\"key\":\"key1\", \"value\":\"val1\"}]}";
         String ret = makePostRequest(F.asMap("cmd", "putAll"), val);
 
         assertNotNull(ret);
@@ -525,7 +523,7 @@ abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestProcessorS
 
         assertNotNull(grid(0).cache(null).get("key0"));
 
-        val = "{'keys': ['key0','key1']}";
+        val = "{\"keys\": [\"key0\",\"key1\"]}";
         ret = makePostRequest(F.asMap("cmd", "containskeys"), val);
 
         assertNotNull(ret);
@@ -1052,7 +1050,7 @@ abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestProcessorS
      */
     public void testRunScript() throws Exception {
         String f = "function(){return ignite.name();}";
-        String ret = makePostRequest(F.asMap("cmd", "runscript", "func", URLEncoder.encode(f)), "{arg:[]}");
+        String ret = makePostRequest(F.asMap("cmd", "runscript", "func", URLEncoder.encode(f)), "{\"arg\":[]}");
 
         assertNotNull(ret);
         assertTrue(!ret.isEmpty());
@@ -1065,7 +1063,7 @@ abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestProcessorS
      */
     public void testRunAffinityScript() throws Exception {
         String f = "function(){return ignite.name();}";
-        String ret = makePostRequest(F.asMap("cmd", "affrun", "func", URLEncoder.encode(f)), "{'arg':[],'key':'key0'}");
+        String ret = makePostRequest(F.asMap("cmd", "affrun", "func", URLEncoder.encode(f)), "{\"arg\":[],\"key\":\"key0\"}");
 
         assertNotNull(ret);
         assertTrue(!ret.isEmpty());
@@ -1089,7 +1087,7 @@ abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestProcessorS
      */
     public void testMapReduceScript() throws Exception {
         String map = "function(nodes, arg) {" +
-            "var words = arg.split(' ');" +
+            "var words = arg.split(\" \");" +
             "for (var i = 0; i < words.length; i++) {" +
             "var f = function (word) {" +
             "return word.length;" +
@@ -1107,7 +1105,7 @@ abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestProcessorS
             "};";
 
         String ret = makePostRequest(F.asMap("cmd", "excmapreduce", "map", URLEncoder.encode(map),
-            "reduce", URLEncoder.encode(reduce)), "{'arg': 'Hello world!'}");
+            "reduce", URLEncoder.encode(reduce)), "{\"arg\": \"Hello world!\"}");
 
         assertNotNull(ret);
         assertTrue(!ret.isEmpty());
@@ -1125,7 +1123,7 @@ abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestProcessorS
 
         String ret = makePostRequest(F.asMap("cmd", "qryexecute", "type", "String", "psz", "1",
                 "qry", URLEncoder.encode("select * from String")),
-            "{'arg': []}");
+            "{\"arg\": []}");
 
         assertNotNull(ret);
         assertTrue(!ret.isEmpty());


[14/14] incubator-ignite git commit: # IGNITE-1131 Fix header

Posted by se...@apache.org.
# IGNITE-1131 Fix header


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

Branch: refs/heads/ignite-1121
Commit: 91f1fdcc11352a776f913f3dcd4fd0be12ed4c6d
Parents: 309a71b
Author: sevdokimov <se...@jetbrains.com>
Authored: Fri Jul 17 16:05:31 2015 +0300
Committer: sevdokimov <se...@jetbrains.com>
Committed: Fri Jul 17 16:05:31 2015 +0300

----------------------------------------------------------------------
 modules/web-control-center/nodejs/agents/agent-server.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/91f1fdcc/modules/web-control-center/nodejs/agents/agent-server.js
----------------------------------------------------------------------
diff --git a/modules/web-control-center/nodejs/agents/agent-server.js b/modules/web-control-center/nodejs/agents/agent-server.js
index 03e550e..31dee5a 100644
--- a/modules/web-control-center/nodejs/agents/agent-server.js
+++ b/modules/web-control-center/nodejs/agents/agent-server.js
@@ -47,7 +47,7 @@ AgentServer.prototype.runCommand = function(cmd, callback) {
     if (cmd._isPost()) {
         body = cmd.postData();
 
-        headers = {'Content-Length': body.length, 'JSONObject': 'true'};
+        headers = {'Content-Length': body.length, 'JSONObject': 'application/json'};
     }
 
     this._client.invokeRest("ignite", params, function(error, code, message) {


[02/14] incubator-ignite git commit: #ignite-961: JettyRestProcessorAbstractSelfTest fix tests.

Posted by se...@apache.org.
#ignite-961: JettyRestProcessorAbstractSelfTest fix tests.


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

Branch: refs/heads/ignite-1121
Commit: e1aca64fcb4db462847076e82b3fb180f2b1a0a3
Parents: b893af8
Author: ivasilinets <iv...@gridgain.com>
Authored: Fri Jul 17 10:30:51 2015 +0300
Committer: ivasilinets <iv...@gridgain.com>
Committed: Fri Jul 17 10:30:51 2015 +0300

----------------------------------------------------------------------
 .../http/jetty/GridJettyRestHandler.java        | 36 ++++++++++----------
 .../http/jetty/GridJettyRestProtocol.java       |  2 +-
 2 files changed, 19 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e1aca64f/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 1d40cbd..577a5e5 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
@@ -20,10 +20,10 @@ package org.apache.ignite.internal.processors.rest.protocols.http.jetty;
 import net.sf.json.*;
 import net.sf.json.processors.*;
 import org.apache.ignite.*;
+import org.apache.ignite.internal.*;
 import org.apache.ignite.internal.processors.rest.*;
 import org.apache.ignite.internal.processors.rest.client.message.*;
 import org.apache.ignite.internal.processors.rest.request.*;
-import org.apache.ignite.internal.processors.scripting.*;
 import org.apache.ignite.internal.util.typedef.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
 import org.apache.ignite.lang.*;
@@ -72,18 +72,18 @@ public class GridJettyRestHandler extends AbstractHandler {
     /** Authentication checker. */
     private final IgniteClosure<String, Boolean> authChecker;
 
-    /** Ignite scripting processor. */
-    IgniteScriptingProcessor proc;
+    /** Grid context. */
+    GridKernalContext ctx;
 
     /**
      * Creates new HTTP requests handler.
      *
-     * @param proc Scripting processor.
+     * @param ctx Grid context.
      * @param hnd Handler.
      * @param authChecker Authentication checking closure.
      * @param log Logger.
      */
-    GridJettyRestHandler(IgniteScriptingProcessor proc, GridRestProtocolHandler hnd,
+    GridJettyRestHandler(GridKernalContext ctx, GridRestProtocolHandler hnd,
         IgniteClosure<String, Boolean> authChecker, IgniteLogger log) {
         assert hnd != null;
         assert log != null;
@@ -91,7 +91,7 @@ public class GridJettyRestHandler extends AbstractHandler {
         this.hnd = hnd;
         this.log = log;
         this.authChecker = authChecker;
-        this.proc = proc;
+        this.ctx = ctx;
 
         // Init default page and favicon.
         try {
@@ -338,7 +338,7 @@ public class GridJettyRestHandler extends AbstractHandler {
             List<Object> res = new ArrayList<>();
 
             for (Object k : o.keySet())
-                res.add(proc.createScriptingEntry(k, o.get(k)));
+                res.add(ctx.scripting().createScriptingEntry(k, o.get(k)));
 
             cmdRes.setResponse(res);
 
@@ -415,17 +415,17 @@ public class GridJettyRestHandler extends AbstractHandler {
                 String cacheName = (String)params.get("cacheName");
 
                 if (req.getHeader("JSONObject") != null) {
-                    Object o = proc.toJavaObject(parseRequest(req));
+                    Object o = ctx.scripting().toJavaObject(parseRequest(req));
 
                     Map<Object, Object> map = new HashMap<>();
 
                     switch (cmd) {
                         case CACHE_PUT_ALL: {
-                            List entries = (List)proc.getField("entries", o);
+                            List entries = (List)ctx.scripting().getField("entries", o);
 
                             for (Object entry : entries) {
-                                Object key = proc.getField("key", entry);
-                                Object val = proc.getField("value", entry);
+                                Object key = ctx.scripting().getField("key", entry);
+                                Object val = ctx.scripting().getField("value", entry);
 
                                 map.put(key, val);
                             }
@@ -440,9 +440,9 @@ public class GridJettyRestHandler extends AbstractHandler {
                         case CACHE_GET_ALL:
                         case CACHE_REMOVE_ALL:
                         case CACHE_CONTAINS_KEYS: {
-                            Object cacheObj = proc.toJavaObject(o);
+                            Object cacheObj = ctx.scripting().toJavaObject(o);
 
-                            List keys = (List)proc.getField("keys", cacheObj);
+                            List keys = (List)ctx.scripting().getField("keys", cacheObj);
 
                             for (Object key : keys)
                                 map.put(key, null);
@@ -466,13 +466,13 @@ public class GridJettyRestHandler extends AbstractHandler {
                         case CACHE_REPLACE:
                         case CACHE_GET_AND_REPLACE:
                         case CACHE_REPLACE_VALUE: {
-                            Object cacheObj = proc.toJavaObject(o);
+                            Object cacheObj = ctx.scripting().toJavaObject(o);
 
                             restReq0.cacheName(F.isEmpty(cacheName) ? null : cacheName);
 
-                            restReq0.key(proc.getField("key", cacheObj));
-                            restReq0.value(proc.getField("val", cacheObj));
-                            restReq0.value2(proc.getField("oldVal", cacheObj));
+                            restReq0.key(ctx.scripting().getField("key", cacheObj));
+                            restReq0.value(ctx.scripting().getField("val", cacheObj));
+                            restReq0.value2(ctx.scripting().getField("oldVal", cacheObj));
                             break;
                         }
 
@@ -595,7 +595,7 @@ public class GridJettyRestHandler extends AbstractHandler {
                 JSONObject o = parseRequest(req);
                 restReq0.argument(o.get("arg"));
 
-                Object cacheObj = proc.toJavaObject(o.get("key"));
+                Object cacheObj = ctx.scripting().toJavaObject(o.get("key"));
                 restReq0.affinityKey(cacheObj);
 
                 restReq = restReq0;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e1aca64f/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestProtocol.java
----------------------------------------------------------------------
diff --git a/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestProtocol.java b/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestProtocol.java
index 7051fb6..15b6342 100644
--- a/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestProtocol.java
+++ b/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestProtocol.java
@@ -116,7 +116,7 @@ public class GridJettyRestProtocol extends GridRestProtocolAdapter {
 
         System.setProperty(IGNITE_JETTY_HOST, locHost.getHostAddress());
 
-        jettyHnd = new GridJettyRestHandler(ctx.scripting(), hnd, new C1<String, Boolean>() {
+        jettyHnd = new GridJettyRestHandler(ctx, hnd, new C1<String, Boolean>() {
             @Override public Boolean apply(String tok) {
                 return F.isEmpty(secretKey) || authenticate(tok);
             }


[11/14] incubator-ignite git commit: #ignite-961: fix class

Posted by se...@apache.org.
#ignite-961: fix class


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

Branch: refs/heads/ignite-1121
Commit: e80010e86e7a627ced958099e5bd8aeeda9a4671
Parents: 7b793af
Author: ivasilinets <iv...@gridgain.com>
Authored: Fri Jul 17 13:53:37 2015 +0300
Committer: ivasilinets <iv...@gridgain.com>
Committed: Fri Jul 17 13:53:37 2015 +0300

----------------------------------------------------------------------
 .../processors/rest/JettyRestProcessorAbstractSelfTest.java     | 4 +---
 .../internal/processors/scripting/IgniteScriptingProcessor.java | 2 +-
 modules/nodejs/src/main/js/server.js                            | 2 +-
 .../rest/protocols/http/jetty/GridJettyRestHandler.java         | 5 +++--
 4 files changed, 6 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e80010e8/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java
index 67913e4..9504dc6 100644
--- a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java
+++ b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java
@@ -123,7 +123,7 @@ abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestProcessorS
 
         conn.setRequestMethod("POST");
 
-        conn.setRequestProperty("Content-Type", "application/POST");
+        conn.setRequestProperty("Content-Type", "application/json");
 
         String signature = signature();
 
@@ -132,8 +132,6 @@ abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestProcessorS
 
         conn.setRequestProperty("Content-Length", Integer.toString(data.length));
 
-        conn.setRequestProperty("JSONObject", "true");
-
         conn.setUseCaches(false);
         conn.setDoOutput(true);
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e80010e8/modules/core/src/main/java/org/apache/ignite/internal/processors/scripting/IgniteScriptingProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/scripting/IgniteScriptingProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/scripting/IgniteScriptingProcessor.java
index db283b8..bf8bbf4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/scripting/IgniteScriptingProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/scripting/IgniteScriptingProcessor.java
@@ -37,7 +37,7 @@ public class IgniteScriptingProcessor extends GridProcessorAdapter {
 
     /** Rest converter. */
     private static final String REST_CONV_CLS =
-        "org.apache.ignite.internal.processors.rest.protocols.http.jetty.GlassFishScriptingConverter";
+        "org.apache.ignite.internal.processors.rest.protocols.http.jetty.RestGlassFishScriptingConverter";
 
     /** Javascript engine. */
     private ScriptEngine jsEngine;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e80010e8/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 f8a98ab..33e1a0d 100644
--- a/modules/nodejs/src/main/js/server.js
+++ b/modules/nodejs/src/main/js/server.js
@@ -75,7 +75,7 @@ Server.prototype.runCommand = function(cmd, callback) {
 
     if (cmd._isPost()) {
         options.headers['Content-Length'] = cmd.postData().length;
-        options.headers['JSONObject'] = "true";
+        options.headers['Content-Type'] = "application/json";
     }
 
     function streamCallback(response) {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e80010e8/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 c2e6885..d0ae096 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
@@ -330,7 +330,8 @@ public class GridJettyRestHandler extends AbstractHandler {
      */
     private void createResponse(HttpServletRequest req, GridRestCommand cmd,
         GridRestResponse cmdRes) {
-        if (cmdRes.getResponse() == null || req.getHeader("JSONObject") == null)
+        if (cmdRes.getResponse() == null || !(req.getHeader("Content-Type") != null &&
+            req.getHeader("Content-Type").contains("json")))
             return;
 
         if (cmd == CACHE_GET_ALL) {
@@ -415,7 +416,7 @@ public class GridJettyRestHandler extends AbstractHandler {
 
                 String cacheName = (String)params.get("cacheName");
 
-                if (req.getHeader("JSONObject") != null) {
+                if (req.getHeader("Content-Type") != null && req.getHeader("Content-Type").contains("json")) {
                     Object o = ctx.scripting().toJavaObject(parseRequest(req));
 
                     Map<Object, Object> map = new HashMap<>();


[05/14] incubator-ignite git commit: Merge remote-tracking branch 'remotes/origin/master' into ignite-961

Posted by se...@apache.org.
Merge remote-tracking branch 'remotes/origin/master' into ignite-961


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

Branch: refs/heads/ignite-1121
Commit: c7e7c4696a00ae33992672cd5fab03d2ce95b6ed
Parents: 18a3e05 f0d24f6
Author: sboikov <sb...@gridgain.com>
Authored: Fri Jul 17 12:45:36 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Fri Jul 17 12:45:36 2015 +0300

----------------------------------------------------------------------
 .../apache/ignite/internal/IgniteKernal.java    |  12 ++
 .../processors/cache/GridCacheContext.java      |  45 +++--
 .../processors/cache/GridCacheMvccManager.java  |   6 +-
 .../GridCachePartitionExchangeManager.java      |  53 ++++++
 .../distributed/dht/GridDhtTopologyFuture.java  |  14 --
 .../dht/atomic/GridDhtAtomicCache.java          |   4 +-
 .../dht/atomic/GridNearAtomicUpdateFuture.java  |  11 +-
 .../GridDhtPartitionsExchangeFuture.java        |  31 +---
 .../cache/transactions/IgniteTxManager.java     |   4 +-
 .../distributed/IgniteCache150ClientsTest.java  |   1 +
 .../IgniteCacheClientReconnectTest.java         | 175 +++++++++++++++++++
 .../IgniteCacheServerNodeConcurrentStart.java   |  96 ++++++++++
 .../testframework/junits/GridAbstractTest.java  |   5 +
 .../testsuites/IgniteCacheTestSuite2.java       |   2 +-
 .../testsuites/IgniteCacheTestSuite4.java       |   2 -
 .../testsuites/IgniteClientNodesTestSuite.java  |  42 +++++
 16 files changed, 439 insertions(+), 64 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c7e7c469/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
----------------------------------------------------------------------


[12/14] incubator-ignite git commit: #ignite-961: fix test for java7

Posted by se...@apache.org.
#ignite-961: fix test for java7


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

Branch: refs/heads/ignite-1121
Commit: a7f664e7f9aa0101c8a7c23ebc7b492884f8194f
Parents: e80010e
Author: ivasilinets <iv...@gridgain.com>
Authored: Fri Jul 17 15:09:58 2015 +0300
Committer: ivasilinets <iv...@gridgain.com>
Committed: Fri Jul 17 15:09:58 2015 +0300

----------------------------------------------------------------------
 .../processors/rest/JettyRestProcessorAbstractSelfTest.java    | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a7f664e7/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java
index 9504dc6..e1425ff 100644
--- a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java
+++ b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java
@@ -1095,7 +1095,7 @@ abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestProcessorS
         String map = "function(nodes, arg) {" +
             "var words = arg.split(\" \");" +
             "for (var i = 0; i < words.length; i++) {" +
-            "var f = function (word) {" +
+            "var f = function(word) {" +
             "return word.length;" +
             "};" +
             "emit(f, words[i], nodes[i %  nodes.length]);" +
@@ -1104,8 +1104,8 @@ abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestProcessorS
 
         String reduce =  "function(results) {"+
             "var sum = 0;"+
-            "for (var i = 0; i < results.length; ++i) {"+
-            "sum += results[i];"+
+            "for (var i = 0; i < results.size(); ++i) {"+
+            "sum += results.get(i).intValue();"+
             "}" +
             "return sum;" +
             "};";


[07/14] incubator-ignite git commit: #ignite-961: fix test.

Posted by se...@apache.org.
#ignite-961: fix test.


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

Branch: refs/heads/ignite-1121
Commit: 8a8b32a891411028b752df4688af23657e05bc05
Parents: 8ebb441
Author: ivasilinets <iv...@gridgain.com>
Authored: Fri Jul 17 13:19:47 2015 +0300
Committer: ivasilinets <iv...@gridgain.com>
Committed: Fri Jul 17 13:19:47 2015 +0300

----------------------------------------------------------------------
 .../http/jetty/GlassfishScriptingConverter.java | 68 ++++++++++++++++++++
 1 file changed, 68 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a8b32a8/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GlassfishScriptingConverter.java
----------------------------------------------------------------------
diff --git a/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GlassfishScriptingConverter.java b/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GlassfishScriptingConverter.java
new file mode 100644
index 0000000..dc56550
--- /dev/null
+++ b/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GlassfishScriptingConverter.java
@@ -0,0 +1,68 @@
+/*
+ * 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.protocols.http.jetty;
+
+import org.apache.ignite.internal.processors.scripting.*;
+import org.apache.ignite.json.*;
+
+import javax.json.*;
+import java.util.*;
+
+/**
+ * Converter for glassfish objects.
+ */
+public class GlassFishScriptingConverter extends IgniteScriptingConverter {
+    /** {@inheritDoc} */
+    @Override public Object toJavaObject(Object o) {
+        if (o == null)
+            return null;
+
+        if (o instanceof Map) {
+            Map o1 = (Map)o;
+
+            JSONCacheObject res = new JSONCacheObject();
+
+            for (Object key : o1.keySet())
+                res.put(toJavaObject(key), toJavaObject(o1.get(key)));
+
+            return res;
+        }
+        else if (o instanceof List) {
+            List o1 = (List) o;
+
+            List<Object> val = new ArrayList<>();
+
+            for (Object v : o1)
+                val.add(toJavaObject(v));
+
+            return val;
+        }
+        else if (o instanceof JsonString)
+            return ((JsonString) o).getString();
+        else if (o instanceof JsonNumber)
+            return ((JsonNumber) o).intValue();
+        else if (o.equals(JsonValue.FALSE))
+            return false;
+        else if (o.equals(JsonValue.TRUE))
+            return true;
+        else if (o.equals(JsonValue.NULL))
+            return null;
+
+        return o;
+    }
+}