ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [05/50] [abbrv] ignite git commit: IGNITE-3277 Replaced outdated json-lib 2.4 to modern Jackson 2.7.5.
Date Tue, 28 Jun 2016 13:06:52 GMT
IGNITE-3277 Replaced outdated json-lib 2.4 to modern Jackson 2.7.5.


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

Branch: refs/heads/ignite-1232
Commit: f177d4312c47cd31e4931c8c1e0f89c2325dedb1
Parents: 106b869
Author: Alexey Kuznetsov <akuznetsov@apache.org>
Authored: Tue Jun 21 11:45:29 2016 +0700
Committer: Alexey Kuznetsov <akuznetsov@apache.org>
Committed: Tue Jun 21 11:45:29 2016 +0700

----------------------------------------------------------------------
 .../client/ClientDefaultCacheSelfTest.java      | 119 ++-
 .../ignite/internal/client/ClientHttpTask.java  |  33 +-
 .../ignite/internal/client/ClientTcpTask.java   |  10 +-
 .../integration/ClientAbstractSelfTest.java     |  92 +-
 .../JettyRestProcessorAbstractSelfTest.java     | 985 ++++++++-----------
 .../internal/processors/rest/SimplePerson.java  |  74 ++
 modules/core/pom.xml                            |  15 +-
 .../apache/ignite/internal/LessNamingBean.java  |  28 +
 .../cache/query/GridCacheSqlIndexMetadata.java  |   3 +-
 .../cache/query/GridCacheSqlMetadata.java       |   3 +-
 .../internal/util/IgniteExceptionRegistry.java  |   5 +-
 .../ignite/internal/visor/cache/VisorCache.java |   4 +-
 .../cache/VisorCacheAffinityConfiguration.java  |   5 +-
 .../cache/VisorCacheAggregatedMetrics.java      |   3 +-
 .../visor/cache/VisorCacheConfiguration.java    |   3 +-
 .../cache/VisorCacheDefaultConfiguration.java   |   5 +-
 .../cache/VisorCacheEvictionConfiguration.java  |   5 +-
 .../internal/visor/cache/VisorCacheMetrics.java |   3 +-
 .../cache/VisorCacheNearConfiguration.java      |   5 +-
 .../visor/cache/VisorCachePartition.java        |   3 +-
 .../visor/cache/VisorCachePartitions.java       |   3 +-
 .../cache/VisorCacheQueryConfiguration.java     |   3 +-
 .../visor/cache/VisorCacheQueryMetrics.java     |   5 +-
 .../cache/VisorCacheRebalanceConfiguration.java |   5 +-
 .../cache/VisorCacheStoreConfiguration.java     |   3 +-
 .../cache/VisorCacheTypeFieldMetadata.java      |   3 +-
 .../visor/cache/VisorCacheTypeMetadata.java     |   3 +-
 .../internal/visor/cache/VisorCacheV4.java      | 124 +++
 .../internal/visor/debug/VisorThreadInfo.java   |   5 +-
 .../visor/debug/VisorThreadLockInfo.java        |   5 +-
 .../internal/visor/event/VisorGridEvent.java    |   5 +-
 .../internal/visor/file/VisorFileBlock.java     |   5 +-
 .../ignite/internal/visor/igfs/VisorIgfs.java   |   5 +-
 .../internal/visor/igfs/VisorIgfsEndpoint.java  |   5 +-
 .../internal/visor/igfs/VisorIgfsMetrics.java   |   5 +-
 .../visor/igfs/VisorIgfsProfilerEntry.java      |   5 +-
 .../VisorIgfsProfilerUniformityCounters.java    |   5 +-
 .../visor/log/VisorLogSearchResult.java         |   5 +-
 .../visor/node/VisorAtomicConfiguration.java    |   5 +-
 .../visor/node/VisorBasicConfiguration.java     |   5 +-
 .../node/VisorExecutorServiceConfiguration.java |   5 +-
 .../visor/node/VisorGridConfiguration.java      |   5 +-
 .../visor/node/VisorIgfsConfiguration.java      |   3 +-
 .../visor/node/VisorLifecycleConfiguration.java |   5 +-
 .../visor/node/VisorMetricsConfiguration.java   |   5 +-
 .../visor/node/VisorNodeDataCollectorJob.java   |  26 +-
 .../node/VisorNodeDataCollectorTaskResult.java  |   5 +-
 .../node/VisorPeerToPeerConfiguration.java      |   5 +-
 .../visor/node/VisorRestConfiguration.java      |   5 +-
 .../node/VisorSegmentationConfiguration.java    |   5 +-
 .../visor/node/VisorSpisConfiguration.java      |   5 +-
 .../node/VisorTransactionConfiguration.java     |   5 +-
 .../internal/visor/query/VisorQueryField.java   |   5 +-
 .../internal/visor/query/VisorQueryResult.java  |   5 +-
 .../plugin/security/SecurityPermissionSet.java  |   5 +-
 .../ignite/plugin/security/SecuritySubject.java |   5 +-
 modules/rest-http/pom.xml                       |  25 +-
 .../http/jetty/GridJettyJsonConfig.java         | 317 ------
 .../http/jetty/GridJettyObjectMapper.java       | 259 +++++
 .../http/jetty/GridJettyRestHandler.java        | 127 ++-
 parent/pom.xml                                  |   1 +
 61 files changed, 1277 insertions(+), 1163 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/f177d431/modules/clients/src/test/java/org/apache/ignite/internal/client/ClientDefaultCacheSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/client/ClientDefaultCacheSelfTest.java
b/modules/clients/src/test/java/org/apache/ignite/internal/client/ClientDefaultCacheSelfTest.java
index f910b7d..09f99fd 100644
--- a/modules/clients/src/test/java/org/apache/ignite/internal/client/ClientDefaultCacheSelfTest.java
+++ b/modules/clients/src/test/java/org/apache/ignite/internal/client/ClientDefaultCacheSelfTest.java
@@ -17,20 +17,26 @@
 
 package org.apache.ignite.internal.client;
 
-import java.io.BufferedReader;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
 import java.io.IOException;
+import java.io.InputStream;
 import java.io.InputStreamReader;
+import java.io.LineNumberReader;
 import java.net.URL;
 import java.net.URLConnection;
+import java.net.URLEncoder;
 import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
-import java.util.Collection;
+import java.util.Map;
 import java.util.UUID;
 import org.apache.ignite.cache.CacheAtomicityMode;
 import org.apache.ignite.cache.CacheMode;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.ConnectorConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.processors.rest.GridRestCommand;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.internal.SB;
 import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
@@ -58,7 +64,7 @@ public class ClientDefaultCacheSelfTest extends GridCommonAbstractTest {
     private static final int HTTP_PORT = 8081;
 
     /** Url address to send HTTP request. */
-    private static final String TEST_URL = "http://" + HOST + ":" + HTTP_PORT + "/ignite";
+    private static final String TEST_URL = "http://" + HOST + ":" + HTTP_PORT + "/ignite?";
 
     /** Used to sent request charset. */
     private static final String CHARSET = StandardCharsets.UTF_8.name();
@@ -66,6 +72,9 @@ public class ClientDefaultCacheSelfTest extends GridCommonAbstractTest {
     /** Name of node local cache. */
     private static final String LOCAL_CACHE = "local";
 
+    /** JSON to java mapper. */
+    private static final ObjectMapper JSON_MAPPER = new ObjectMapper();
+
     /** {@inheritDoc} */
     @Override protected void beforeTestsStarted() throws Exception {
         System.setProperty(IGNITE_JETTY_PORT, String.valueOf(HTTP_PORT));
@@ -103,77 +112,95 @@ public class ClientDefaultCacheSelfTest extends GridCommonAbstractTest
{
 
         cfg.setDiscoverySpi(disco);
 
-        CacheConfiguration cLocal = new CacheConfiguration();
+        CacheConfiguration cLoc = new CacheConfiguration();
 
-        cLocal.setName(LOCAL_CACHE);
+        cLoc.setName(LOCAL_CACHE);
 
-        cLocal.setCacheMode(CacheMode.LOCAL);
+        cLoc.setCacheMode(CacheMode.LOCAL);
 
-        cLocal.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
+        cLoc.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
 
-        cfg.setCacheConfiguration(defaultCacheConfiguration(), cLocal);
+        cfg.setCacheConfiguration(defaultCacheConfiguration(), cLoc);
 
         return cfg;
     }
 
     /**
-     * Builds list of connection strings with few different ports.
-     * Used to avoid possible failures in case of port range active.
-     *
-     * @param startPort Port to start list from.
-     * @return List of client connection strings.
-     */
-    private Collection<String> getServerList(int startPort) {
-        Collection<String> srvs = new ArrayList<>();
-
-        for (int i = startPort; i < startPort + 10; i++)
-            srvs.add(HOST + ":" + i);
-
-        return srvs;
-    }
-
-    /*
      * Send HTTP request to Jetty server of node and process result.
      *
-     * @param query Send query parameters.
+     * @param params Command parameters.
      * @return Processed response string.
+     * @throws IOException If failed.
      */
-    private String sendHttp(String query) {
-        String res = "No result";
+    private String content(Map<String, String> params) throws IOException {
+        SB sb = new SB(TEST_URL);
+
+        for (Map.Entry<String, String> e : params.entrySet())
+            sb.a(e.getKey()).a('=').a(e.getValue()).a('&');
+
+        String qry = sb.toString();
 
         try {
-            URLConnection connection = new URL(TEST_URL + "?" + query).openConnection();
+            URL url = new URL(qry);
 
-            connection.setRequestProperty("Accept-Charset", CHARSET);
+            URLConnection conn = url.openConnection();
 
-            BufferedReader r = new BufferedReader(new InputStreamReader(connection.getInputStream()));
+            conn.setRequestProperty("Accept-Charset", CHARSET);
 
-            res = r.readLine();
+            InputStream in = conn.getInputStream();
 
-            r.close();
+            StringBuilder buf = new StringBuilder(256);
+
+            try (LineNumberReader rdr = new LineNumberReader(new InputStreamReader(in, "UTF-8")))
{
+                for (String line = rdr.readLine(); line != null; line = rdr.readLine())
+                    buf.append(line);
+            }
+
+            return buf.toString();
         }
         catch (IOException e) {
-            error("Failed to send HTTP request: " + TEST_URL + "?" + query, e);
+            error("Failed to send HTTP request: " + TEST_URL + "?" + qry, e);
+
+            throw e;
         }
+    }
+
+    /**
+     * @param content Content to check.
+     */
+    private JsonNode jsonResponse(String content) throws IOException {
+        assertNotNull(content);
+        assertFalse(content.isEmpty());
+
+        JsonNode node = JSON_MAPPER.readTree(content);
+
+        assertFalse(node.get("affinityNodeId").asText().isEmpty());
+        assertEquals(0, node.get("successStatus").asInt());
+        assertTrue(node.get("error").asText().isEmpty());
+        assertTrue(node.get("sessionToken").asText().isEmpty());
 
-        // Cut node id from response.
-        return res.substring(res.indexOf("\"response\""));
+        return node.get("response");
     }
 
     /**
      * Json format string in cache should not transform to Json object on get request.
      */
-    public void testSkipString2JsonTransformation() {
+    public void testSkipString2JsonTransformation() throws Exception {
+        String val = "{\"v\":\"my Value\",\"t\":1422559650154}";
+
         // Put to cache JSON format string value.
-        assertEquals("Incorrect query response", "\"response\":true,\"sessionToken\":\"\",\"successStatus\":0}",
-            sendHttp("cmd=put&cacheName=" + LOCAL_CACHE +
-                "&key=a&val=%7B%22v%22%3A%22my%20Value%22%2C%22t%22%3A1422559650154%7D"));
+        String ret = content(F.asMap("cmd", GridRestCommand.CACHE_PUT.key(), "cacheName",
LOCAL_CACHE,
+            "key", "a", "val", URLEncoder.encode(val, CHARSET)));
+
+        JsonNode res = jsonResponse(ret);
+
+        assertEquals("Incorrect put response", true, res.asBoolean());
 
         // Escape '\' symbols disappear from response string on transformation to JSON object.
-        assertEquals(
-            "Incorrect query response",
-            "\"response\":\"{\\\"v\\\":\\\"my Value\\\",\\\"t\\\":1422559650154}\"," +
-                "\"sessionToken\":\"\",\"successStatus\":0}",
-            sendHttp("cmd=get&cacheName=" + LOCAL_CACHE + "&key=a"));
+        ret = content(F.asMap("cmd", GridRestCommand.CACHE_GET.key(), "cacheName", LOCAL_CACHE,
"key", "a"));
+
+        res = jsonResponse(ret);
+
+        assertEquals("Incorrect get response", val, res.asText());
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f177d431/modules/clients/src/test/java/org/apache/ignite/internal/client/ClientHttpTask.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/client/ClientHttpTask.java
b/modules/clients/src/test/java/org/apache/ignite/internal/client/ClientHttpTask.java
index 9604c29..977a1eb 100644
--- a/modules/clients/src/test/java/org/apache/ignite/internal/client/ClientHttpTask.java
+++ b/modules/clients/src/test/java/org/apache/ignite/internal/client/ClientHttpTask.java
@@ -17,12 +17,13 @@
 
 package org.apache.ignite.internal.client;
 
+import java.io.IOException;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
-import net.sf.json.JSON;
-import net.sf.json.JSONArray;
-import net.sf.json.JSONSerializer;
-import net.sf.json.JsonConfig;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.ignite.IgniteException;
 import org.apache.ignite.compute.ComputeJob;
 import org.apache.ignite.compute.ComputeJobResult;
 import org.apache.ignite.compute.ComputeJobResultPolicy;
@@ -40,14 +41,28 @@ public class ClientHttpTask extends ComputeTaskSplitAdapter<String,
Integer> {
     /** Task delegate. */
     private final ClientTcpTask delegate = new ClientTcpTask();
 
+    /** JSON to java mapper. */
+    private static final ObjectMapper JSON_MAPPER = new ObjectMapper();
+
     /** {@inheritDoc} */
     @Override protected Collection<? extends ComputeJob> split(int gridSize, String
arg) {
-        JSON json = JSONSerializer.toJSON(arg);
+        try {
+            JsonNode json = JSON_MAPPER.readTree(arg);
+
+            List<String> list = null;
+
+            if (json.isArray()) {
+                list = new ArrayList<>();
 
-        List list = json.isArray() ? JSONArray.toList((JSONArray)json, String.class, new
JsonConfig()) : null;
+                for (JsonNode child : json)
+                    list.add(child.asText());
+            }
 
-        //noinspection unchecked
-        return delegate.split(gridSize, list);
+            return delegate.split(gridSize, list);
+        }
+        catch (IOException e) {
+            throw new IgniteException(e);
+        }
     }
 
     /** {@inheritDoc} */
@@ -62,4 +77,4 @@ public class ClientHttpTask extends ComputeTaskSplitAdapter<String, Integer>
{
 
         return WAIT;
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f177d431/modules/clients/src/test/java/org/apache/ignite/internal/client/ClientTcpTask.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/client/ClientTcpTask.java
b/modules/clients/src/test/java/org/apache/ignite/internal/client/ClientTcpTask.java
index 8458c0e..54a58e6 100644
--- a/modules/clients/src/test/java/org/apache/ignite/internal/client/ClientTcpTask.java
+++ b/modules/clients/src/test/java/org/apache/ignite/internal/client/ClientTcpTask.java
@@ -34,13 +34,13 @@ import static org.apache.ignite.compute.ComputeJobResultPolicy.WAIT;
  * <p>
  * The argument of the task is a collection of objects to calculate string length sum of.
  */
-public class ClientTcpTask extends ComputeTaskSplitAdapter<List<Object>, Integer>
{
+public class ClientTcpTask extends ComputeTaskSplitAdapter<List<String>, Integer>
{
     /** {@inheritDoc} */
-    @Override protected Collection<? extends ComputeJob> split(int gridSize, List<Object>
list) {
+    @Override protected Collection<? extends ComputeJob> split(int gridSize, List<String>
list) {
         Collection<ComputeJobAdapter> jobs = new ArrayList<>();
 
         if (list != null)
-            for (final Object val : list)
+            for (final String val : list)
                 jobs.add(new ComputeJobAdapter() {
                     @Override public Object execute() {
                         try {
@@ -50,7 +50,7 @@ public class ClientTcpTask extends ComputeTaskSplitAdapter<List<Object>,
Integer
                             Thread.currentThread().interrupt();
                         }
 
-                        return val == null ? 0 : val.toString().length();
+                        return val == null ? 0 : val.length();
                     }
                 });
 
@@ -74,4 +74,4 @@ public class ClientTcpTask extends ComputeTaskSplitAdapter<List<Object>,
Integer
 
         return WAIT;
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f177d431/modules/clients/src/test/java/org/apache/ignite/internal/client/integration/ClientAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/client/integration/ClientAbstractSelfTest.java
b/modules/clients/src/test/java/org/apache/ignite/internal/client/integration/ClientAbstractSelfTest.java
index 125603e..3fbd570 100644
--- a/modules/clients/src/test/java/org/apache/ignite/internal/client/integration/ClientAbstractSelfTest.java
+++ b/modules/clients/src/test/java/org/apache/ignite/internal/client/integration/ClientAbstractSelfTest.java
@@ -17,9 +17,11 @@
 
 package org.apache.ignite.internal.client.integration;
 
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.List;
@@ -31,12 +33,12 @@ import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.ThreadFactory;
 import java.util.concurrent.atomic.AtomicInteger;
+import javax.cache.Cache;
 import javax.cache.configuration.Factory;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
 import junit.framework.Assert;
-import net.sf.json.JSON;
-import net.sf.json.JSONArray;
-import net.sf.json.JSONSerializer;
-import net.sf.json.JsonConfig;
+import org.apache.ignite.IgniteException;
 import org.apache.ignite.cache.store.CacheStore;
 import org.apache.ignite.cache.store.CacheStoreAdapter;
 import org.apache.ignite.compute.ComputeJob;
@@ -246,8 +248,8 @@ public abstract class ClientAbstractSelfTest extends GridCommonAbstractTest
{
             cacheConfiguration("partitioned"), cacheConfiguration(CACHE_NAME));
 
         clientCfg.setMessageInterceptor(new ConnectorMessageInterceptor() {
-            @Override
-            public Object onReceive(@Nullable Object obj) {
+            /** {@inheritDoc} */
+            @Override public Object onReceive(@Nullable Object obj) {
                 if (obj != null)
                     INTERCEPTED_OBJECTS.put(obj, obj);
 
@@ -255,8 +257,8 @@ public abstract class ClientAbstractSelfTest extends GridCommonAbstractTest
{
                     obj + INTERCEPTED_SUF : obj;
             }
 
-            @Override
-            public Object onSend(Object obj) {
+            /** {@inheritDoc} */
+            @Override public Object onSend(Object obj) {
                 if (obj != null)
                     INTERCEPTED_OBJECTS.put(obj, obj);
 
@@ -332,7 +334,7 @@ public abstract class ClientAbstractSelfTest extends GridCommonAbstractTest
{
         cfg.setDataConfigurations(Arrays.asList(nullCache, cache));
 
         cfg.setProtocol(protocol());
-        cfg.setServers(Arrays.asList(serverAddress()));
+        cfg.setServers(Collections.singleton(serverAddress()));
 
         // Setting custom executor, to avoid failures on client shutdown.
         // And applying custom naming scheme to ease debugging.
@@ -390,9 +392,9 @@ public abstract class ClientAbstractSelfTest extends GridCommonAbstractTest
{
         futs.put("put", data.putAsync("key", "val"));
         futs.put("putAll", data.putAllAsync(F.asMap("key", "val")));
         futs.put("get", data.getAsync("key"));
-        futs.put("getAll", data.getAllAsync(Arrays.asList("key")));
+        futs.put("getAll", data.getAllAsync(Collections.singletonList("key")));
         futs.put("remove", data.removeAsync("key"));
-        futs.put("removeAll", data.removeAllAsync(Arrays.asList("key")));
+        futs.put("removeAll", data.removeAllAsync(Collections.singletonList("key")));
         futs.put("replace", data.replaceAsync("key", "val"));
         futs.put("cas", data.casAsync("key", "val", "val2"));
         futs.put("metrics", data.metricsAsync());
@@ -500,8 +502,8 @@ public abstract class ClientAbstractSelfTest extends GridCommonAbstractTest
{
 
         GridClientCompute compute = client.compute();
 
-        Assert.assertEquals(new Integer(17), compute.execute(taskName, taskArg));
-        Assert.assertEquals(new Integer(17), compute.executeAsync(taskName, taskArg).get());
+        Assert.assertEquals(17, compute.execute(taskName, taskArg));
+        Assert.assertEquals(17, compute.executeAsync(taskName, taskArg).get());
     }
 
     /**
@@ -570,13 +572,13 @@ public abstract class ClientAbstractSelfTest extends GridCommonAbstractTest
{
     /**
      * Test task.
      */
-    private static class TestTask extends ComputeTaskSplitAdapter<List<Object>,
Integer> {
+    private static class TestTask extends ComputeTaskSplitAdapter<List<String>,
Integer> {
         /** {@inheritDoc} */
-        @Override protected Collection<? extends ComputeJob> split(int gridSize, List<Object>
list) {
+        @Override protected Collection<? extends ComputeJob> split(int gridSize, List<String>
list) {
             Collection<ComputeJobAdapter> jobs = new ArrayList<>();
 
             if (list != null)
-                for (final Object val : list)
+                for (final String val : list)
                     jobs.add(new ComputeJobAdapter() {
                         @Override public Object execute() {
                             try {
@@ -586,7 +588,7 @@ public abstract class ClientAbstractSelfTest extends GridCommonAbstractTest
{
                                 Thread.currentThread().interrupt();
                             }
 
-                            return val == null ? 0 : val.toString().length();
+                            return val == null ? 0 : val.length();
                         }
                     });
 
@@ -607,20 +609,20 @@ public abstract class ClientAbstractSelfTest extends GridCommonAbstractTest
{
     /**
      * Test task that sleeps 5 seconds.
      */
-    private static class SleepTestTask extends ComputeTaskSplitAdapter<List<Object>,
Integer> {
+    private static class SleepTestTask extends ComputeTaskSplitAdapter<List<String>,
Integer> {
         /** {@inheritDoc} */
-        @Override protected Collection<? extends ComputeJob> split(int gridSize, List<Object>
list)
+        @Override protected Collection<? extends ComputeJob> split(int gridSize, List<String>
list)
             {
             Collection<ComputeJobAdapter> jobs = new ArrayList<>();
 
             if (list != null)
-                for (final Object val : list)
+                for (final String val : list)
                     jobs.add(new ComputeJobAdapter() {
                         @Override public Object execute() {
                             try {
                                 Thread.sleep(5000);
 
-                                return val == null ? 0 : val.toString().length();
+                                return val == null ? 0 : val.length();
                             }
                             catch (InterruptedException ignored) {
                                 return -1;
@@ -642,10 +644,14 @@ public abstract class ClientAbstractSelfTest extends GridCommonAbstractTest
{
         }
     }
 
+    /** JSON to java mapper. */
+    private static final ObjectMapper JSON_MAPPER = new ObjectMapper();
+
     /**
      * Http test task with restriction to string arguments only.
      */
     protected static class HttpTestTask extends ComputeTaskSplitAdapter<String, Integer>
{
+        /** */
         private final TestTask delegate = new TestTask();
 
         /** {@inheritDoc} */
@@ -654,11 +660,23 @@ public abstract class ClientAbstractSelfTest extends GridCommonAbstractTest
{
             if (arg.endsWith("intercepted"))
                 arg = arg.substring(0, arg.length() - 11);
 
-            JSON json = JSONSerializer.toJSON(arg);
+            try {
+                JsonNode json = JSON_MAPPER.readTree(arg);
+
+                List<String> list = null;
 
-            List list = json.isArray() ? JSONArray.toList((JSONArray)json, String.class,
new JsonConfig()) : null;
+                if (json.isArray()) {
+                    list = new ArrayList<>();
 
-            return delegate.split(gridSize, list);
+                    for (JsonNode child : json)
+                        list.add(child.asText());
+                }
+
+                return delegate.split(gridSize, list);
+            }
+            catch (IOException e) {
+                throw new IgniteException(e);
+            }
         }
 
         /** {@inheritDoc} */
@@ -671,16 +689,29 @@ public abstract class ClientAbstractSelfTest extends GridCommonAbstractTest
{
      * Http wrapper for sleep task.
      */
     protected static class SleepHttpTestTask extends ComputeTaskSplitAdapter<String, Integer>
{
+        /** */
         private final SleepTestTask delegate = new SleepTestTask();
 
         /** {@inheritDoc} */
         @SuppressWarnings("unchecked")
         @Override protected Collection<? extends ComputeJob> split(int gridSize, String
arg) {
-            JSON json = JSONSerializer.toJSON(arg);
+            try {
+                JsonNode json = JSON_MAPPER.readTree(arg);
+
+                List<String> list = null;
 
-            List list = json.isArray() ? JSONArray.toList((JSONArray)json, String.class,
new JsonConfig()) : null;
+                if (json.isArray()) {
+                    list = new ArrayList<>();
+
+                    for (JsonNode child : json)
+                        list.add(child.asText());
+                }
 
-            return delegate.split(gridSize, list);
+                return delegate.split(gridSize, list);
+            }
+            catch (IOException e) {
+                throw new IgniteException(e);
+            }
         }
 
         /** {@inheritDoc} */
@@ -698,9 +729,8 @@ public abstract class ClientAbstractSelfTest extends GridCommonAbstractTest
{
 
         /** {@inheritDoc} */
         @Override public void loadCache(IgniteBiInClosure<Object, Object> clo, Object...
args) {
-            for (Map.Entry e : map.entrySet()) {
+            for (Map.Entry e : map.entrySet())
                 clo.apply(e.getKey(), e.getValue());
-            }
         }
 
         /** {@inheritDoc} */
@@ -709,7 +739,7 @@ public abstract class ClientAbstractSelfTest extends GridCommonAbstractTest
{
         }
 
         /** {@inheritDoc} */
-        @Override public void write(javax.cache.Cache.Entry<? extends Object, ? extends
Object> e) {
+        @Override public void write(Cache.Entry<?, ?> e) {
             map.put(e.getKey(), e.getValue());
         }
 
@@ -718,4 +748,4 @@ public abstract class ClientAbstractSelfTest extends GridCommonAbstractTest
{
             map.remove(key);
         }
     }
-}
\ No newline at end of file
+}


Mime
View raw message