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/20 13:39:11 UTC
[01/21] incubator-ignite git commit: GG-10559 - Improvements.
Repository: incubator-ignite
Updated Branches:
refs/heads/ignite-1121 8fd577d3f -> aef4919a9
GG-10559 - Improvements.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/692dd041
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/692dd041
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/692dd041
Branch: refs/heads/ignite-1121
Commit: 692dd041af8c45347f193ce6c70bfeff59e1e178
Parents: c559692
Author: Alexey Goncharuk <ag...@gridgain.com>
Authored: Thu Jul 16 18:18:26 2015 -0700
Committer: Alexey Goncharuk <ag...@gridgain.com>
Committed: Thu Jul 16 18:18:26 2015 -0700
----------------------------------------------------------------------
.../org/apache/ignite/plugin/security/SecurityPermission.java | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/692dd041/modules/core/src/main/java/org/apache/ignite/plugin/security/SecurityPermission.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/security/SecurityPermission.java b/modules/core/src/main/java/org/apache/ignite/plugin/security/SecurityPermission.java
index 3cab511..0e660d2 100644
--- a/modules/core/src/main/java/org/apache/ignite/plugin/security/SecurityPermission.java
+++ b/modules/core/src/main/java/org/apache/ignite/plugin/security/SecurityPermission.java
@@ -45,14 +45,17 @@ public enum SecurityPermission {
/** Events {@code disable} permission. */
EVENTS_DISABLE,
- /** Common visor tasks permission. */
+ /** Common visor view tasks permission. */
ADMIN_VIEW,
/** Visor cache read (query) permission. */
ADMIN_QUERY,
/** Visor cache load permission. */
- ADMIN_CACHE;
+ ADMIN_CACHE,
+
+ /** Visor admin operations permissions. */
+ ADMIN_OPS;
/** Enumerated values. */
private static final SecurityPermission[] VALS = values();
[09/21] incubator-ignite git commit: # ignite-961 fixed header
Posted by se...@apache.org.
# ignite-961 fixed 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/bb489d5b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/bb489d5b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/bb489d5b
Branch: refs/heads/ignite-1121
Commit: bb489d5ba0c098834a7d6e15664a1f4ace2e9904
Parents: 488ba59
Author: sboikov <sb...@gridgain.com>
Authored: Fri Jul 17 17:24:15 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Fri Jul 17 17:24:15 2015 +0300
----------------------------------------------------------------------
.../ignite/internal/processors/json/IgniteJsonCacheTest.java | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bb489d5b/modules/json/src/test/java/org/apache/ignite/internal/processors/json/IgniteJsonCacheTest.java
----------------------------------------------------------------------
diff --git a/modules/json/src/test/java/org/apache/ignite/internal/processors/json/IgniteJsonCacheTest.java b/modules/json/src/test/java/org/apache/ignite/internal/processors/json/IgniteJsonCacheTest.java
index 6f710fc..49682cd 100644
--- a/modules/json/src/test/java/org/apache/ignite/internal/processors/json/IgniteJsonCacheTest.java
+++ b/modules/json/src/test/java/org/apache/ignite/internal/processors/json/IgniteJsonCacheTest.java
@@ -1,4 +1,4 @@
-package org.apache.ignite.internal.processors.json;/*
+/*
* 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.
@@ -15,6 +15,8 @@ package org.apache.ignite.internal.processors.json;/*
* limitations under the License.
*/
+package org.apache.ignite.internal.processors.json;
+
import org.apache.ignite.*;
import org.apache.ignite.cache.*;
import org.apache.ignite.cache.query.*;
[10/21] incubator-ignite git commit: #ignite-961: fix qry tests.
Posted by se...@apache.org.
#ignite-961: fix qry 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/f8516dcf
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/f8516dcf
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/f8516dcf
Branch: refs/heads/ignite-1121
Commit: f8516dcf3adf96d3b6d85d1924c830cf98039f06
Parents: f7bb17c
Author: ivasilinets <iv...@gridgain.com>
Authored: Fri Jul 17 17:41:09 2015 +0300
Committer: ivasilinets <iv...@gridgain.com>
Committed: Fri Jul 17 17:41:09 2015 +0300
----------------------------------------------------------------------
.../JettyRestProcessorAbstractSelfTest.java | 23 ++++++++++----------
.../rendezvous/RendezvousAffinityFunction.java | 4 ++++
.../affinity/GridAffinityAssignmentCache.java | 8 +++++++
3 files changed, 23 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f8516dcf/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 09c0e13..9aab6f5 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
@@ -26,6 +26,7 @@ import org.apache.ignite.cluster.*;
import org.apache.ignite.configuration.*;
import org.apache.ignite.internal.processors.rest.handlers.*;
import org.apache.ignite.internal.util.typedef.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
import org.apache.ignite.testframework.*;
import java.io.*;
@@ -50,6 +51,8 @@ abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestProcessorS
System.setProperty(IGNITE_JETTY_PORT, Integer.toString(restPort()));
super.beforeTestsStarted();
+
+ initCache();
}
/** {@inheritDoc} */
@@ -1256,13 +1259,13 @@ abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestProcessorS
assertNotNull(ignite);
String f = "function(expName){"+
- "if (expName.toString() !== ignite.name().toString()) {" +
- "throw \"Not correct name.\"" +
+ "if (expName !== \"hello\") {" +
+ "throw \"Not correct arg.\"" +
"}" +
"return ignite.name();}";
String ret = makePostRequest(F.asMap("cmd", "affrun", "func", URLEncoder.encode(f)),
- "{\"arg\":\"" + ignite.name() + "\",\"key\":\"key0\"}");
+ "{\"arg\":\"" + "hello" + "\",\"key\":\"key0\"}");
assertNotNull(ret);
assertTrue(!ret.isEmpty());
@@ -1286,13 +1289,13 @@ abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestProcessorS
assertNotNull(ignite);
String f = "function(expName){"+
- "if (expName != ignite.name()) {" +
- "throw \"Not correct name.\"" +
+ "if (expName !== \"hello\") {" +
+ "throw \"Not correct arg.\"" +
"}" +
"return ignite.name();}";
String ret = content(F.asMap("cmd", "affrun", "func", URLEncoder.encode(f),
- "key", "key0", "arg", ignite.name()));
+ "key", "key0", "arg", "hello"));
assertNotNull(ret);
assertTrue(!ret.isEmpty());
@@ -1390,14 +1393,14 @@ abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestProcessorS
Integer qryId0 = (Integer)((Map)json.get("response")).get("queryId");
assertEquals(qryId0, qryId);
+
+ ret = content(F.asMap("cmd", "qryclose", "qryId", String.valueOf(qryId)));
}
/**
* @throws Exception If failed.
*/
public void testQueryArgsPost() throws Exception {
- initCache();
-
String qry = "salary > ? and salary <= ?";
String ret = makePostRequest(F.asMap("cmd", "qryexecute", "type", "Person", "psz", "10", "cacheName", "person",
@@ -1429,8 +1432,6 @@ abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestProcessorS
* @throws Exception If failed.
*/
public void testQueryArgs() throws Exception {
- initCache();
-
String qry = "salary > ? and salary <= ?";
Map<String, String> params = new HashMap<>();
@@ -1469,8 +1470,6 @@ abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestProcessorS
* @throws Exception If failed.
*/
public void testQueryClose() throws Exception {
- initCache();
-
String qry = "salary > ? and salary <= ?";
String ret = makePostRequest(F.asMap("cmd", "qryexecute", "type", "Person", "psz", "1", "cacheName", "person",
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f8516dcf/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunction.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunction.java b/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunction.java
index 2b26630..81472f0 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunction.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunction.java
@@ -290,6 +290,10 @@ public class RendezvousAffinityFunction implements AffinityFunction, Externaliza
try {
ByteArrayOutputStream out = new ByteArrayOutputStream();
+ if (ignite == null)
+ System.out.println("IGNITE IS NULL!!!");
+
+
byte[] nodeHashBytes = ignite.configuration().getMarshaller().marshal(nodeHash);
out.write(U.intToBytes(part), 0, 4); // Avoid IOException.
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f8516dcf/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java
index d40128c..281c153 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java
@@ -25,6 +25,7 @@ import org.apache.ignite.internal.*;
import org.apache.ignite.internal.processors.cache.*;
import org.apache.ignite.internal.util.future.*;
import org.apache.ignite.internal.util.typedef.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
import org.jetbrains.annotations.*;
import org.jsr166.*;
@@ -185,6 +186,13 @@ public class GridAffinityAssignmentCache {
Collections.sort(sorted, GridNodeOrderComparator.INSTANCE);
}
+ /*try {
+ ctx.grid().context().resource().injectGeneric(aff);
+ }
+ catch (IgniteCheckedException e) {
+ U.convertException(e);
+ }*/
+
List<List<ClusterNode>> prevAssignment = prev == null ? null : prev.assignment();
List<List<ClusterNode>> assignment;
[19/21] incubator-ignite git commit: #ignite-1087: AffinityRun runs
job on not primary nodes.
Posted by se...@apache.org.
#ignite-1087: AffinityRun runs job on not primary nodes.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/f9d2a2ef
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/f9d2a2ef
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/f9d2a2ef
Branch: refs/heads/ignite-1121
Commit: f9d2a2ef4424bf166912594791b6414b9a9e8457
Parents: ede9612
Author: ivasilinets <iv...@gridgain.com>
Authored: Mon Jul 20 11:25:00 2015 +0300
Committer: ivasilinets <iv...@gridgain.com>
Committed: Mon Jul 20 11:25:00 2015 +0300
----------------------------------------------------------------------
.../ignite/compute/ComputeJobResultPolicy.java | 3 +-
.../failover/GridFailoverContextImpl.java | 28 ++-
.../managers/failover/GridFailoverManager.java | 13 +-
.../processors/closure/AffinityTask.java | 35 ++++
.../closure/GridClosureProcessor.java | 63 ++++++-
.../processors/task/GridTaskWorker.java | 24 ++-
.../ignite/spi/failover/FailoverContext.java | 18 ++
.../spi/failover/always/AlwaysFailoverSpi.java | 25 +++
.../cache/CacheAffinityCallSelfTest.java | 172 +++++++++++++++++++
.../cache/GridCacheAffinityRoutingSelfTest.java | 157 ++++++++++++++++-
.../spi/failover/GridFailoverTestContext.java | 10 ++
.../ignite/testsuites/IgniteCacheTestSuite.java | 1 +
12 files changed, 533 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f9d2a2ef/modules/core/src/main/java/org/apache/ignite/compute/ComputeJobResultPolicy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/compute/ComputeJobResultPolicy.java b/modules/core/src/main/java/org/apache/ignite/compute/ComputeJobResultPolicy.java
index 37aba91..26eb542 100644
--- a/modules/core/src/main/java/org/apache/ignite/compute/ComputeJobResultPolicy.java
+++ b/modules/core/src/main/java/org/apache/ignite/compute/ComputeJobResultPolicy.java
@@ -50,8 +50,7 @@ public enum ComputeJobResultPolicy {
* @param ord Ordinal value.
* @return Enumerated value.
*/
- @Nullable
- public static ComputeJobResultPolicy fromOrdinal(byte ord) {
+ @Nullable public static ComputeJobResultPolicy fromOrdinal(byte ord) {
return ord >= 0 && ord < VALS.length ? VALS[ord] : null;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f9d2a2ef/modules/core/src/main/java/org/apache/ignite/internal/managers/failover/GridFailoverContextImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/failover/GridFailoverContextImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/failover/GridFailoverContextImpl.java
index a3f8e44..c2b104e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/failover/GridFailoverContextImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/failover/GridFailoverContextImpl.java
@@ -24,6 +24,7 @@ import org.apache.ignite.internal.managers.loadbalancer.*;
import org.apache.ignite.internal.util.tostring.*;
import org.apache.ignite.internal.util.typedef.internal.*;
import org.apache.ignite.spi.failover.*;
+import org.jetbrains.annotations.*;
import java.util.*;
@@ -41,15 +42,26 @@ public class GridFailoverContextImpl implements FailoverContext {
@GridToStringExclude
private final GridLoadBalancerManager loadMgr;
+ /** Affinity key for affinityCall. */
+ private final Object affKey;
+
+ /** Affinity cache name for affinityCall. */
+ private final String affCacheName;
+
/**
* Initializes failover context.
*
* @param taskSes Grid task session.
* @param jobRes Failed job result.
* @param loadMgr Load manager.
+ * @param affKey Affinity key.
+ * @param affCacheName Affinity cache name.
*/
- public GridFailoverContextImpl(GridTaskSessionImpl taskSes, ComputeJobResult jobRes,
- GridLoadBalancerManager loadMgr) {
+ public GridFailoverContextImpl(GridTaskSessionImpl taskSes,
+ ComputeJobResult jobRes,
+ GridLoadBalancerManager loadMgr,
+ @Nullable Object affKey,
+ @Nullable String affCacheName) {
assert taskSes != null;
assert jobRes != null;
assert loadMgr != null;
@@ -57,6 +69,8 @@ public class GridFailoverContextImpl implements FailoverContext {
this.taskSes = taskSes;
this.jobRes = jobRes;
this.loadMgr = loadMgr;
+ this.affKey = affKey;
+ this.affCacheName = affCacheName;
}
/** {@inheritDoc} */
@@ -75,6 +89,16 @@ public class GridFailoverContextImpl implements FailoverContext {
}
/** {@inheritDoc} */
+ @Nullable @Override public Object affinityKey() {
+ return affKey;
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public String affinityCacheName() {
+ return affCacheName;
+ }
+
+ /** {@inheritDoc} */
@Override public String toString() {
return S.toString(GridFailoverContextImpl.class, this);
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f9d2a2ef/modules/core/src/main/java/org/apache/ignite/internal/managers/failover/GridFailoverManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/failover/GridFailoverManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/failover/GridFailoverManager.java
index 714cccb..dffc965 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/failover/GridFailoverManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/failover/GridFailoverManager.java
@@ -23,6 +23,7 @@ import org.apache.ignite.compute.*;
import org.apache.ignite.internal.*;
import org.apache.ignite.internal.managers.*;
import org.apache.ignite.spi.failover.*;
+import org.jetbrains.annotations.*;
import java.util.*;
@@ -56,11 +57,17 @@ public class GridFailoverManager extends GridManagerAdapter<FailoverSpi> {
/**
* @param taskSes Task session.
* @param jobRes Job result.
- * @param top Collection of all top nodes that does not include the failed node.
+ * @param top Collection of all topology nodes.
+ * @param affKey Affinity key.
+ * @param affCacheName Affinity cache name.
* @return New node to route this job to.
*/
- public ClusterNode failover(GridTaskSessionImpl taskSes, ComputeJobResult jobRes, List<ClusterNode> top) {
+ public ClusterNode failover(GridTaskSessionImpl taskSes,
+ ComputeJobResult jobRes,
+ List<ClusterNode> top,
+ @Nullable Object affKey,
+ @Nullable String affCacheName) {
return getSpi(taskSes.getFailoverSpi()).failover(new GridFailoverContextImpl(taskSes, jobRes,
- ctx.loadBalancing()), top);
+ ctx.loadBalancing(), affKey, affCacheName), top);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f9d2a2ef/modules/core/src/main/java/org/apache/ignite/internal/processors/closure/AffinityTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/closure/AffinityTask.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/closure/AffinityTask.java
new file mode 100644
index 0000000..1b32444
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/closure/AffinityTask.java
@@ -0,0 +1,35 @@
+/*
+ * 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.closure;
+
+import org.jetbrains.annotations.*;
+
+/**
+ * Affinity mapped task.
+ */
+public interface AffinityTask {
+ /**
+ * @return Affinity key.
+ */
+ public Object affinityKey();
+
+ /**
+ * @return Affinity cache name.
+ */
+ @Nullable public String affinityCacheName();
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f9d2a2ef/modules/core/src/main/java/org/apache/ignite/internal/processors/closure/GridClosureProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/closure/GridClosureProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/closure/GridClosureProcessor.java
index 658557e..21bfc11 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/closure/GridClosureProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/closure/GridClosureProcessor.java
@@ -413,9 +413,12 @@ public class GridClosureProcessor extends GridProcessorAdapter {
final ClusterNode node = ctx.affinity().mapKeyToNode(cacheName, affKey0);
+ if (node == null)
+ return ComputeTaskInternalFuture.finishedFuture(ctx, T5.class, U.emptyTopologyException());
+
ctx.task().setThreadContext(TC_SUBGRID, nodes);
- return ctx.task().execute(new T5(node, job), null, false);
+ return ctx.task().execute(new T5(node, job, affKey0, cacheName), null, false);
}
catch (IgniteCheckedException e) {
return ComputeTaskInternalFuture.finishedFuture(ctx, T5.class, e);
@@ -445,9 +448,12 @@ public class GridClosureProcessor extends GridProcessorAdapter {
final ClusterNode node = ctx.affinity().mapKeyToNode(cacheName, affKey0);
+ if (node == null)
+ return ComputeTaskInternalFuture.finishedFuture(ctx, T4.class, U.emptyTopologyException());
+
ctx.task().setThreadContext(TC_SUBGRID, nodes);
- return ctx.task().execute(new T4(node, job), null, false);
+ return ctx.task().execute(new T4(node, job, affKey0, cacheName), null, false);
}
catch (IgniteCheckedException e) {
return ComputeTaskInternalFuture.finishedFuture(ctx, T4.class, e);
@@ -1223,7 +1229,7 @@ public class GridClosureProcessor extends GridProcessorAdapter {
/**
*/
- private static class T4 extends TaskNoReduceAdapter<Void> implements GridNoImplicitInjection {
+ private static class T4 extends TaskNoReduceAdapter<Void> implements GridNoImplicitInjection, AffinityTask {
/** */
private static final long serialVersionUID = 0L;
@@ -1233,15 +1239,27 @@ public class GridClosureProcessor extends GridProcessorAdapter {
/** */
private Runnable job;
+ /** */
+ private Object affKey;
+
+ /** */
+ private String affCacheName;
+
/**
* @param node Cluster node.
* @param job Job.
+ * @param affKey Affinity key.
+ * @param affCacheName Affinity cache name.
*/
- private T4(ClusterNode node, Runnable job) {
+ private T4(ClusterNode node, Runnable job, Object affKey, String affCacheName) {
super(U.peerDeployAware0(job));
+ assert affKey != null;
+
this.node = node;
this.job = job;
+ this.affKey = affKey;
+ this.affCacheName = affCacheName;
}
/** {@inheritDoc} */
@@ -1250,11 +1268,22 @@ public class GridClosureProcessor extends GridProcessorAdapter {
return Collections.singletonMap(job, node);
}
+
+ /** {@inheritDoc} */
+ @Override public Object affinityKey() {
+ return affKey;
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public String affinityCacheName() {
+ return affCacheName;
+ }
}
/**
*/
- private static class T5<R> extends GridPeerDeployAwareTaskAdapter<Void, R> implements GridNoImplicitInjection {
+ private static class T5<R> extends GridPeerDeployAwareTaskAdapter<Void, R> implements
+ GridNoImplicitInjection, AffinityTask {
/** */
private static final long serialVersionUID = 0L;
@@ -1264,15 +1293,27 @@ public class GridClosureProcessor extends GridProcessorAdapter {
/** */
private Callable<R> job;
+ /** */
+ private Object affKey;
+
+ /** */
+ private String affCacheName;
+
/**
* @param node Cluster node.
* @param job Job.
+ * @param affKey Affinity key.
+ * @param affCacheName Affinity cache name.
*/
- private T5(ClusterNode node, Callable<R> job) {
+ private T5(ClusterNode node, Callable<R> job, Object affKey, String affCacheName) {
super(U.peerDeployAware0(job));
+ assert affKey != null;
+
this.node = node;
this.job = job;
+ this.affKey = affKey;
+ this.affCacheName = affCacheName;
}
/** {@inheritDoc} */
@@ -1291,6 +1332,16 @@ public class GridClosureProcessor extends GridProcessorAdapter {
throw new IgniteException("Failed to find successful job result: " + res);
}
+
+ /** {@inheritDoc} */
+ @Override public Object affinityKey() {
+ return affKey;
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public String affinityCacheName() {
+ return affCacheName;
+ }
}
/**
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f9d2a2ef/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskWorker.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskWorker.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskWorker.java
index 133a31f..f241bcc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskWorker.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskWorker.java
@@ -26,6 +26,7 @@ import org.apache.ignite.internal.*;
import org.apache.ignite.internal.cluster.*;
import org.apache.ignite.internal.compute.*;
import org.apache.ignite.internal.managers.deployment.*;
+import org.apache.ignite.internal.processors.closure.*;
import org.apache.ignite.internal.processors.timeout.*;
import org.apache.ignite.internal.util.typedef.*;
import org.apache.ignite.internal.util.typedef.internal.*;
@@ -136,6 +137,12 @@ class GridTaskWorker<T, R> extends GridWorker implements GridTimeoutObject {
private final boolean noFailover;
/** */
+ private final Object affKey;
+
+ /** */
+ private final String affCache;
+
+ /** */
private final UUID subjId;
/** Continuous mapper. */
@@ -245,6 +252,17 @@ class GridTaskWorker<T, R> extends GridWorker implements GridTimeoutObject {
Boolean noFailover = getThreadContext(TC_NO_FAILOVER);
this.noFailover = noFailover != null ? noFailover : false;
+
+ if (task instanceof AffinityTask) {
+ AffinityTask affTask = (AffinityTask)task;
+
+ affKey = affTask.affinityKey();
+ affCache = affTask.affinityCacheName();
+ }
+ else {
+ affKey = null;
+ affCache = null;
+ }
}
/**
@@ -397,7 +415,9 @@ class GridTaskWorker<T, R> extends GridWorker implements GridTimeoutObject {
ses.setClassLoader(dep.classLoader());
- final List<ClusterNode> shuffledNodes = getTaskTopology();
+ // Nodes are ignored by affinity tasks.
+ final List<ClusterNode> shuffledNodes =
+ affKey == null ? getTaskTopology() : Collections.<ClusterNode>emptyList();
// Load balancer.
ComputeLoadBalancer balancer = ctx.loadBalancing().getLoadBalancer(ses, shuffledNodes);
@@ -968,7 +988,7 @@ class GridTaskWorker<T, R> extends GridWorker implements GridTimeoutObject {
ctx.resource().invokeAnnotated(dep, jobRes.getJob(), ComputeJobBeforeFailover.class);
// Map to a new node.
- ClusterNode node = ctx.failover().failover(ses, jobRes, new ArrayList<>(top));
+ ClusterNode node = ctx.failover().failover(ses, jobRes, new ArrayList<>(top), affKey, affCache);
if (node == null) {
String msg = "Failed to failover a job to another node (failover SPI returned null) [job=" +
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f9d2a2ef/modules/core/src/main/java/org/apache/ignite/spi/failover/FailoverContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/failover/FailoverContext.java b/modules/core/src/main/java/org/apache/ignite/spi/failover/FailoverContext.java
index b0cae92..865f1a2 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/failover/FailoverContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/failover/FailoverContext.java
@@ -20,6 +20,8 @@ package org.apache.ignite.spi.failover;
import org.apache.ignite.*;
import org.apache.ignite.cluster.*;
import org.apache.ignite.compute.*;
+import org.apache.ignite.lang.*;
+import org.jetbrains.annotations.*;
import java.util.*;
@@ -52,4 +54,20 @@ public interface FailoverContext {
* @throws IgniteException If anything failed.
*/
public ClusterNode getBalancedNode(List<ClusterNode> top) throws IgniteException;
+
+ /**
+ * Gets affinity key for {@link IgniteCompute#affinityRun(String, Object, IgniteRunnable)}
+ * and {@link IgniteCompute#affinityCall(String, Object, IgniteCallable)}.
+ *
+ * @return Affinity key.
+ */
+ @Nullable public Object affinityKey();
+
+ /**
+ * Returns affinity cache name {@link IgniteCompute#affinityRun(String, Object, IgniteRunnable)}
+ * and {@link IgniteCompute#affinityCall(String, Object, IgniteCallable)}.
+ *
+ * @return Cache name.
+ */
+ @Nullable public String affinityCacheName();
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f9d2a2ef/modules/core/src/main/java/org/apache/ignite/spi/failover/always/AlwaysFailoverSpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/failover/always/AlwaysFailoverSpi.java b/modules/core/src/main/java/org/apache/ignite/spi/failover/always/AlwaysFailoverSpi.java
index e075d3e..e925995 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/failover/always/AlwaysFailoverSpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/failover/always/AlwaysFailoverSpi.java
@@ -92,6 +92,11 @@ public class AlwaysFailoverSpi extends IgniteSpiAdapter implements FailoverSpi,
*/
public static final String FAILED_NODE_LIST_ATTR = "gg:failover:failednodelist";
+ /**
+ * Name of job context attribute containing number of affinity call attempts.
+ */
+ public static final String AFFINITY_CALL_ATTEMPT = "ignite:failover:affinitycallattempt";
+
/** Maximum attempts attribute key should be the same on all nodes. */
public static final String MAX_FAILOVER_ATTEMPT_ATTR = "gg:failover:maxattempts";
@@ -173,6 +178,26 @@ public class AlwaysFailoverSpi extends IgniteSpiAdapter implements FailoverSpi,
return null;
}
+ if (ctx.affinityKey() != null) {
+ Integer affCallAttempt = ctx.getJobResult().getJobContext().getAttribute(AFFINITY_CALL_ATTEMPT);
+
+ if (affCallAttempt == null)
+ affCallAttempt = 1;
+
+ if (maxFailoverAttempts <= affCallAttempt) {
+ U.warn(log, "Job failover failed because number of maximum failover attempts for affinity call" +
+ " is exceeded [failedJob=" + ctx.getJobResult().getJob() + ", maxFailoverAttempts=" +
+ maxFailoverAttempts + ']');
+
+ return null;
+ }
+ else {
+ ctx.getJobResult().getJobContext().setAttribute(AFFINITY_CALL_ATTEMPT, affCallAttempt + 1);
+
+ return ignite.affinity(ctx.affinityCacheName()).mapKeyToNode(ctx.affinityKey());
+ }
+ }
+
Collection<UUID> failedNodes = ctx.getJobResult().getJobContext().getAttribute(FAILED_NODE_LIST_ATTR);
if (failedNodes == null)
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f9d2a2ef/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheAffinityCallSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheAffinityCallSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheAffinityCallSelfTest.java
new file mode 100644
index 0000000..c4436ca
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheAffinityCallSelfTest.java
@@ -0,0 +1,172 @@
+/*
+ * 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;
+
+import org.apache.ignite.*;
+import org.apache.ignite.cluster.*;
+import org.apache.ignite.compute.*;
+import org.apache.ignite.configuration.*;
+import org.apache.ignite.internal.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
+import org.apache.ignite.lang.*;
+import org.apache.ignite.resources.*;
+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.spi.failover.always.*;
+import org.apache.ignite.testframework.*;
+import org.apache.ignite.testframework.junits.common.*;
+
+import java.util.concurrent.*;
+
+import static org.apache.ignite.cache.CacheMode.*;
+
+/**
+ * Test for {@link IgniteCompute#affinityCall(String, Object, IgniteCallable)} and
+ * {@link IgniteCompute#affinityRun(String, Object, IgniteRunnable)}.
+ */
+public class CacheAffinityCallSelfTest extends GridCommonAbstractTest {
+ /** */
+ private static final String CACHE_NAME = "myCache";
+
+ /** */
+ private static final int MAX_FAILOVER_ATTEMPTS = 5;
+
+ /** */
+ private static final int SERVERS_COUNT = 4;
+
+ /** */
+ private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ TcpDiscoverySpi spi = new TcpDiscoverySpi();
+
+ spi.setIpFinder(IP_FINDER);
+
+ cfg.setDiscoverySpi(spi);
+
+ AlwaysFailoverSpi failSpi = new AlwaysFailoverSpi();
+ failSpi.setMaximumFailoverAttempts(MAX_FAILOVER_ATTEMPTS);
+ cfg.setFailoverSpi(failSpi);
+
+ CacheConfiguration ccfg = defaultCacheConfiguration();
+ ccfg.setName(CACHE_NAME);
+ ccfg.setCacheMode(PARTITIONED);
+ ccfg.setBackups(1);
+
+ cfg.setCacheConfiguration(ccfg);
+
+ if (gridName.equals(getTestGridName(SERVERS_COUNT)))
+ cfg.setClientMode(true);
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ stopAllGrids();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testAffinityCallRestartNode() throws Exception {
+ startGrids(4);
+
+ Integer key = primaryKey(grid(0).cache(CACHE_NAME));
+
+ IgniteInternalFuture<Object> fut = GridTestUtils.runAsync(new Callable<Object>() {
+ @Override public Object call() throws Exception {
+ U.sleep(500);
+ stopGrid(0);
+
+ return null;
+ }
+ });
+
+ while (!fut.isDone())
+ grid(1).compute().affinityCall(CACHE_NAME, key, new CheckCallable(key));
+
+ stopAllGrids();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testAffinityCallNoServerNode() throws Exception {
+ startGrids(SERVERS_COUNT + 1);
+
+ final Integer key = 1;
+
+ final Ignite client = grid(SERVERS_COUNT);
+
+ final IgniteInternalFuture<Object> fut = GridTestUtils.runAsync(new Callable<Object>() {
+ @Override public Object call() throws Exception {
+ for (int i = 0; i < SERVERS_COUNT; ++i)
+ stopGrid(i);
+
+ return null;
+ }
+ });
+
+ try {
+ while (!fut.isDone())
+ client.compute().affinityCall(CACHE_NAME, key, new CheckCallable(key));
+ }
+ catch (ComputeTaskCancelledException e) {
+ assertTrue(e.getMessage().contains("stopping"));
+ }
+ catch(ClusterGroupEmptyException e) {
+ assertTrue(e.getMessage().contains("Topology projection is empty"));
+ }
+ catch(IgniteException e) {
+ assertTrue(e.getMessage().contains("cache (or node) is stopping"));
+ }
+
+ stopGrid(SERVERS_COUNT);
+ }
+
+ /**
+ * Test callable.
+ */
+ public static class CheckCallable implements IgniteCallable<Object> {
+ /** Key. */
+ private final Object key;
+
+ /** */
+ @IgniteInstanceResource
+ private Ignite ignite;
+
+ /**
+ * @param key Key.
+ */
+ public CheckCallable(Object key) {
+ this.key = key;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Object call() throws IgniteCheckedException {
+ assert ignite.cluster().localNode().id().equals(ignite.cluster().mapKeyToNode(CACHE_NAME, key).id());
+
+ return null;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f9d2a2ef/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityRoutingSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityRoutingSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityRoutingSelfTest.java
index 78ecf08..a56ab9f 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityRoutingSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityRoutingSelfTest.java
@@ -19,17 +19,21 @@ package org.apache.ignite.internal.processors.cache;
import org.apache.ignite.*;
import org.apache.ignite.cache.affinity.*;
+import org.apache.ignite.cluster.*;
import org.apache.ignite.compute.*;
import org.apache.ignite.configuration.*;
import org.apache.ignite.internal.util.typedef.*;
import org.apache.ignite.lang.*;
-import org.apache.ignite.marshaller.optimized.*;
import org.apache.ignite.resources.*;
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.spi.failover.always.*;
+import org.apache.ignite.testframework.*;
import org.apache.ignite.testframework.junits.common.*;
+import java.util.concurrent.*;
+
import static org.apache.ignite.cache.CacheMode.*;
import static org.apache.ignite.cache.CacheWriteSynchronizationMode.*;
@@ -47,6 +51,9 @@ public class GridCacheAffinityRoutingSelfTest extends GridCommonAbstractTest {
private static final int KEY_CNT = 50;
/** */
+ private static final int MAX_FAILOVER_ATTEMPTS = 5;
+
+ /** */
private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
/**
@@ -66,6 +73,10 @@ public class GridCacheAffinityRoutingSelfTest extends GridCommonAbstractTest {
cfg.setDiscoverySpi(spi);
+ AlwaysFailoverSpi failSpi = new AlwaysFailoverSpi();
+ failSpi.setMaximumFailoverAttempts(MAX_FAILOVER_ATTEMPTS);
+ cfg.setFailoverSpi(failSpi);
+
if (!gridName.equals(getTestGridName(GRID_CNT))) {
// Default cache configuration.
CacheConfiguration dfltCacheCfg = defaultCacheConfiguration();
@@ -129,6 +140,48 @@ public class GridCacheAffinityRoutingSelfTest extends GridCommonAbstractTest {
}
/**
+ * @throws Exception If failed.
+ */
+ public void testAffinityCallRestartFails() throws Exception {
+ GridTestUtils.assertThrows(log, new Callable<Object>() {
+ @Override public Object call() throws Exception {
+ grid(0).compute().affinityCall(NON_DFLT_CACHE_NAME, "key",
+ new FailedCallable("key", MAX_FAILOVER_ATTEMPTS + 1));
+ return null;
+ }
+ }, ClusterTopologyException.class, "Failed to failover a job to another node");
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testAffinityCallRestart() throws Exception {
+ assertEquals(MAX_FAILOVER_ATTEMPTS,
+ grid(0).compute().affinityCall(NON_DFLT_CACHE_NAME, "key",
+ new FailedCallable("key", MAX_FAILOVER_ATTEMPTS)));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testAffinityRunRestartFails() throws Exception {
+ GridTestUtils.assertThrows(log, new Callable<Object>() {
+ @Override public Object call() throws Exception {
+ grid(0).compute().affinityRun(NON_DFLT_CACHE_NAME, "key",
+ new FailedRunnable("key", MAX_FAILOVER_ATTEMPTS + 1));
+ return null;
+ }
+ }, ClusterTopologyException.class, "Failed to failover a job to another node");
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testAffinityRunRestart() throws Exception {
+ grid(0).compute().affinityRun(NON_DFLT_CACHE_NAME, "key", new FailedRunnable("key", MAX_FAILOVER_ATTEMPTS));
+ }
+
+ /**
* JUnit.
*
* @throws Exception If failed.
@@ -224,6 +277,108 @@ public class GridCacheAffinityRoutingSelfTest extends GridCommonAbstractTest {
}
/**
+ * Test runnable.
+ */
+ private static class FailedCallable implements IgniteCallable<Object> {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** */
+ private static final String ATTR_ATTEMPT = "Attempt";
+
+ /** */
+ @IgniteInstanceResource
+ private Ignite ignite;
+
+ /** */
+ @JobContextResource
+ private ComputeJobContext jobCtx;
+
+ /** Key. */
+ private final Object key;
+
+ /** Call attempts. */
+ private final Integer callAttempt;
+
+ /**
+ * @param key Key.
+ * @param callAttempt Call attempts.
+ */
+ public FailedCallable(Object key, Integer callAttempt) {
+ this.key = key;
+ this.callAttempt = callAttempt;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Object call() throws IgniteCheckedException {
+ Integer attempt = jobCtx.getAttribute(ATTR_ATTEMPT);
+
+ if (attempt == null)
+ attempt = 1;
+
+ assertEquals(ignite.affinity(NON_DFLT_CACHE_NAME).mapKeyToNode(key), ignite.cluster().localNode());
+
+ jobCtx.setAttribute(ATTR_ATTEMPT, attempt + 1);
+
+ if (attempt < callAttempt)
+ throw new ComputeJobFailoverException("Failover exception.");
+ else
+ return attempt;
+ }
+ }
+
+ /**
+ * Test runnable.
+ */
+ private static class FailedRunnable implements IgniteRunnable {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** */
+ private static final String ATTR_ATTEMPT = "Attempt";
+
+ /** */
+ @IgniteInstanceResource
+ private Ignite ignite;
+
+ /** */
+ @JobContextResource
+ private ComputeJobContext jobCtx;
+
+ /** Key. */
+ private final Object key;
+
+ /** Call attempts. */
+ private final Integer callAttempt;
+
+ /**
+ * @param key Key.
+ * @param callAttempt Call attempts.
+ */
+ public FailedRunnable(Object key, Integer callAttempt) {
+ this.key = key;
+ this.callAttempt = callAttempt;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void run() {
+ Integer attempt = jobCtx.getAttribute(ATTR_ATTEMPT);
+
+ if (attempt == null)
+ attempt = 1;
+
+ assertEquals(ignite.affinity(NON_DFLT_CACHE_NAME).mapKeyToNode(key), ignite.cluster().localNode());
+
+ jobCtx.setAttribute(ATTR_ATTEMPT, attempt + 1);
+
+ if (attempt < callAttempt)
+ throw new ComputeJobFailoverException("Failover exception.");
+ else
+ assertEquals(callAttempt, attempt);
+ }
+ }
+
+ /**
* Test callable.
*/
private static class CheckCallable implements IgniteCallable<Object> {
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f9d2a2ef/modules/core/src/test/java/org/apache/ignite/spi/failover/GridFailoverTestContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/failover/GridFailoverTestContext.java b/modules/core/src/test/java/org/apache/ignite/spi/failover/GridFailoverTestContext.java
index db64475..bfca83d 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/failover/GridFailoverTestContext.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/failover/GridFailoverTestContext.java
@@ -66,4 +66,14 @@ public class GridFailoverTestContext implements FailoverContext {
@Override public ClusterNode getBalancedNode(List<ClusterNode> grid) {
return grid.get(RAND.nextInt(grid.size()));
}
+
+ /** {@inheritDoc} */
+ @Override public Object affinityKey() {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String affinityCacheName() {
+ return null;
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f9d2a2ef/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
index 39702a3..bafdfef 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
@@ -109,6 +109,7 @@ public class IgniteCacheTestSuite extends TestSuite {
// Common tests.
suite.addTestSuite(GridCacheConcurrentMapSelfTest.class);
suite.addTestSuite(GridCacheAffinityMapperSelfTest.class);
+ suite.addTestSuite(CacheAffinityCallSelfTest.class);
GridTestUtils.addTestIfNeeded(suite, GridCacheAffinityRoutingSelfTest.class, ignoredTests);
GridTestUtils.addTestIfNeeded(suite, GridCacheMvccSelfTest.class, ignoredTests);
suite.addTestSuite(GridCacheMvccPartitionedSelfTest.class);
[11/21] 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/a2ab1897
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/a2ab1897
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/a2ab1897
Branch: refs/heads/ignite-1121
Commit: a2ab1897615e6e7f2b921fd07ca5c54f46c7395f
Parents: f8516dc bb489d5
Author: ivasilinets <iv...@gridgain.com>
Authored: Fri Jul 17 17:41:56 2015 +0300
Committer: ivasilinets <iv...@gridgain.com>
Committed: Fri Jul 17 17:41:56 2015 +0300
----------------------------------------------------------------------
.../ignite/internal/GridKernalContext.java | 6 +
.../ignite/internal/GridKernalContextImpl.java | 14 +-
.../ignite/internal/IgniteComponentType.java | 8 +
.../apache/ignite/internal/IgniteKernal.java | 1 +
.../IgniteCacheObjectProcessorImpl.java | 10 +
.../json/IgniteJsonNoopProcessor.java | 67 +++
.../processors/json/IgniteJsonProcessor.java | 71 +++
.../processors/query/GridQueryProcessor.java | 235 ++++++++-
.../org/apache/ignite/JsonArrayBuilderImpl.java | 130 -----
.../java/org/apache/ignite/JsonArrayImpl.java | 131 -----
.../org/apache/ignite/JsonGeneratorImpl.java | 500 -------------------
.../org/apache/ignite/JsonLocationImpl.java | 60 ---
.../java/org/apache/ignite/JsonNumberImpl.java | 116 -----
.../apache/ignite/JsonObjectBuilderImpl.java | 141 ------
.../java/org/apache/ignite/JsonObjectImpl.java | 116 -----
.../org/apache/ignite/JsonProviderImpl.java | 104 ----
.../java/org/apache/ignite/JsonStringImpl.java | 71 ---
.../processors/json/IgniteJsonArray.java | 132 +++++
.../processors/json/IgniteJsonArrayBuilder.java | 130 +++++
.../processors/json/IgniteJsonGenerator.java | 500 +++++++++++++++++++
.../processors/json/IgniteJsonLocation.java | 60 +++
.../json/IgniteJsonMessageFactory.java | 36 ++
.../processors/json/IgniteJsonNumber.java | 116 +++++
.../processors/json/IgniteJsonObject.java | 117 +++++
.../json/IgniteJsonObjectBuilder.java | 141 ++++++
.../json/IgniteJsonProcessorImpl.java | 115 +++++
.../processors/json/IgniteJsonProvider.java | 104 ++++
.../processors/json/IgniteJsonString.java | 77 +++
.../processors/json/JsonCacheObject.java | 103 ++++
.../java/org/apache/ignite/json/IgniteJson.java | 36 ++
.../processors/json/IgniteJsonCacheTest.java | 196 ++++++++
31 files changed, 2251 insertions(+), 1393 deletions(-)
----------------------------------------------------------------------
[20/21] 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/72b91c18
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/72b91c18
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/72b91c18
Branch: refs/heads/ignite-1121
Commit: 72b91c180e52ca1cf962bc1344335d1282d9a060
Parents: 9fdb28c f9d2a2e
Author: ivasilinets <iv...@gridgain.com>
Authored: Mon Jul 20 11:40:22 2015 +0300
Committer: ivasilinets <iv...@gridgain.com>
Committed: Mon Jul 20 11:40:22 2015 +0300
----------------------------------------------------------------------
.../ignite/compute/ComputeJobResultPolicy.java | 3 +-
.../failover/GridFailoverContextImpl.java | 28 ++-
.../managers/failover/GridFailoverManager.java | 13 +-
.../processors/cache/GridCacheUtils.java | 4 +-
.../processors/closure/AffinityTask.java | 35 ++++
.../closure/GridClosureProcessor.java | 63 ++++++-
.../processors/task/GridTaskWorker.java | 24 ++-
.../ignite/internal/util/IgniteUtils.java | 4 +-
.../ignite/spi/failover/FailoverContext.java | 18 ++
.../spi/failover/always/AlwaysFailoverSpi.java | 25 +++
.../IgniteClientReconnectFailoverTest.java | 47 +++--
.../cache/CacheAffinityCallSelfTest.java | 172 +++++++++++++++++++
.../cache/GridCacheAffinityRoutingSelfTest.java | 157 ++++++++++++++++-
.../cache/IgniteCacheNearLockValueSelfTest.java | 2 +
.../spi/failover/GridFailoverTestContext.java | 10 ++
.../ignite/testsuites/IgniteCacheTestSuite.java | 1 +
.../ignite/schema/ui/SchemaImportApp.java | 36 +++-
17 files changed, 594 insertions(+), 48 deletions(-)
----------------------------------------------------------------------
[14/21] incubator-ignite git commit: # master fix tests
Posted by se...@apache.org.
# master 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/192fefc2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/192fefc2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/192fefc2
Branch: refs/heads/ignite-1121
Commit: 192fefc2382d479a62504517cf3ddc8d5188657c
Parents: f557728
Author: sboikov <sb...@gridgain.com>
Authored: Mon Jul 20 10:09:24 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Mon Jul 20 10:09:24 2015 +0300
----------------------------------------------------------------------
.../processors/cache/GridCacheUtils.java | 4 +-
.../ignite/internal/util/IgniteUtils.java | 4 +-
.../IgniteClientReconnectFailoverTest.java | 47 ++++++++++++--------
.../cache/IgniteCacheNearLockValueSelfTest.java | 2 +
4 files changed, 32 insertions(+), 25 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/192fefc2/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
index bd2623d..e16e30d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
@@ -1561,9 +1561,7 @@ public class GridCacheUtils {
*/
@NotNull public static RuntimeException convertToCacheException(IgniteCheckedException e) {
IgniteClientDisconnectedCheckedException disconnectedErr =
- e instanceof IgniteClientDisconnectedCheckedException ?
- (IgniteClientDisconnectedCheckedException)e
- : e.getCause(IgniteClientDisconnectedCheckedException.class);
+ e.getCause(IgniteClientDisconnectedCheckedException.class);
if (disconnectedErr != null) {
assert disconnectedErr.reconnectFuture() != null : disconnectedErr;
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/192fefc2/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
index 66eb596..42982b9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
@@ -691,9 +691,7 @@ public abstract class IgniteUtils {
}
IgniteClientDisconnectedCheckedException disconnectedErr =
- e instanceof IgniteClientDisconnectedCheckedException ?
- (IgniteClientDisconnectedCheckedException)e
- : e.getCause(IgniteClientDisconnectedCheckedException.class);
+ e.getCause(IgniteClientDisconnectedCheckedException.class);
if (disconnectedErr != null) {
assert disconnectedErr.reconnectFuture() != null : disconnectedErr;
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/192fefc2/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectFailoverTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectFailoverTest.java b/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectFailoverTest.java
index 7cfc329..b7de3eb 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectFailoverTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectFailoverTest.java
@@ -22,6 +22,7 @@ import org.apache.ignite.configuration.*;
import org.apache.ignite.lang.*;
import org.apache.ignite.transactions.*;
+import javax.cache.*;
import java.util.*;
import java.util.concurrent.*;
@@ -114,37 +115,45 @@ public class IgniteClientReconnectFailoverTest extends IgniteClientReconnectFail
reconnectFailover(new Callable<Void>() {
@Override public Void call() throws Exception {
- TreeMap<Integer, Integer> map = new TreeMap<>();
+ try {
+ TreeMap<Integer, Integer> map = new TreeMap<>();
- ThreadLocalRandom rnd = ThreadLocalRandom.current();
+ ThreadLocalRandom rnd = ThreadLocalRandom.current();
- for (int i = 0; i < 5; i++) {
- Integer key = rnd.nextInt(0, 100_000);
+ for (int i = 0; i < 5; i++) {
+ Integer key = rnd.nextInt(0, 100_000);
- cache.put(key, key);
+ cache.put(key, key);
- assertEquals(key, cache.get(key));
+ assertEquals(key, cache.get(key));
- map.put(key, key);
- }
+ map.put(key, key);
+ }
- for (TransactionConcurrency txConcurrency : TransactionConcurrency.values()) {
- try (Transaction tx = txs.txStart(txConcurrency, REPEATABLE_READ)) {
- for (Map.Entry<Integer, Integer> e : map.entrySet()) {
- cache.put(e.getKey(), e.getValue());
+ for (TransactionConcurrency txConcurrency : TransactionConcurrency.values()) {
+ try (Transaction tx = txs.txStart(txConcurrency, REPEATABLE_READ)) {
+ for (Map.Entry<Integer, Integer> e : map.entrySet()) {
+ cache.put(e.getKey(), e.getValue());
- assertNotNull(cache.get(e.getKey()));
- }
+ assertNotNull(cache.get(e.getKey()));
+ }
- tx.commit();
+ tx.commit();
+ }
}
- }
- cache.putAll(map);
+ cache.putAll(map);
- Map<Integer, Integer> res = cache.getAll(map.keySet());
+ Map<Integer, Integer> res = cache.getAll(map.keySet());
- assertEquals(map, res);
+ assertEquals(map, res);
+ }
+ catch (CacheException e) {
+ if (e.getCause() instanceof IgniteClientDisconnectedException)
+ throw e;
+ else
+ log.info("Ignore error: " + e);
+ }
return null;
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/192fefc2/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheNearLockValueSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheNearLockValueSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheNearLockValueSelfTest.java
index cd04433..c500bbf 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheNearLockValueSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheNearLockValueSelfTest.java
@@ -49,6 +49,8 @@ public class IgniteCacheNearLockValueSelfTest extends GridCommonAbstractTest {
/** {@inheritDoc} */
@Override protected void afterTestsStopped() throws Exception {
super.afterTestsStopped();
+
+ stopAllGrids();
}
/** {@inheritDoc} */
[13/21] incubator-ignite git commit: Merge branch ignite-1.3.2 into
master.
Posted by se...@apache.org.
Merge branch ignite-1.3.2 into master.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/f557728b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/f557728b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/f557728b
Branch: refs/heads/ignite-1121
Commit: f557728b3108ccd3b5f8ecd1190a8591de27bbca
Parents: f0d24f6 6711d2c
Author: Alexey Goncharuk <ag...@gridgain.com>
Authored: Fri Jul 17 11:00:53 2015 -0700
Committer: Alexey Goncharuk <ag...@gridgain.com>
Committed: Fri Jul 17 11:00:53 2015 -0700
----------------------------------------------------------------------
.../apache/ignite/plugin/security/SecurityPermission.java | 7 +++++--
.../java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java | 8 +++-----
2 files changed, 8 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f557728b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
----------------------------------------------------------------------
[06/21] incubator-ignite git commit: # ignite-962 simple json object
implementation
Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e6ba441d/modules/json/src/main/java/org/apache/ignite/internal/processors/json/IgniteJsonGenerator.java
----------------------------------------------------------------------
diff --git a/modules/json/src/main/java/org/apache/ignite/internal/processors/json/IgniteJsonGenerator.java b/modules/json/src/main/java/org/apache/ignite/internal/processors/json/IgniteJsonGenerator.java
new file mode 100644
index 0000000..3a90d38
--- /dev/null
+++ b/modules/json/src/main/java/org/apache/ignite/internal/processors/json/IgniteJsonGenerator.java
@@ -0,0 +1,500 @@
+/*
+ * 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.json;
+
+import javax.json.*;
+import javax.json.stream.*;
+import java.io.*;
+import java.math.*;
+import java.util.*;
+
+/**
+ * Json generator implementation.
+ */
+public class IgniteJsonGenerator implements JsonGenerator {
+ /** Writer. */
+ private final BufferedWriter writer;
+
+ private LinkedList<Element> ctx = new LinkedList();
+
+ /**
+ * @param writer Writer.
+ */
+ public IgniteJsonGenerator(Writer writer) {
+ this.writer = new BufferedWriter(writer);
+
+ ctx.push(new Element(Context.NONE, true));
+ }
+
+ /** {@inheritDoc} */
+ @Override public JsonGenerator writeStartObject() {
+ try {
+ if (ctx.getLast().context() == Context.OBJECT ||
+ (ctx.getLast().context() == Context.NONE && !ctx.getLast().isFirst()))
+ throw new JsonGenerationException("No name for object field.");
+
+ writeComma();
+ writer.write('{');
+
+ ctx.addLast(new Element(Context.OBJECT, true));
+
+ return this;
+ }
+ catch (IOException e) {
+ throw new JsonException("Writer fails.", e);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public JsonGenerator writeStartObject(String name) {
+ try {
+ if (ctx.getLast().context() != Context.OBJECT)
+ throw new JsonGenerationException("Object with name in not object scope.");
+
+ writeComma();
+ writeString(name);
+ writer.write(":");
+ writer.write('{');
+
+ ctx.addLast(new Element(Context.OBJECT, true));
+
+ return this;
+ }
+ catch (IOException e) {
+ throw new JsonException("Writer fails.", e);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public JsonGenerator writeStartArray() {
+ try {
+ if (ctx.getLast().context() == Context.OBJECT ||
+ (ctx.getLast().context() == Context.NONE && !ctx.getLast().isFirst()))
+ throw new JsonGenerationException("Array in object scope.");
+
+ writeComma();
+ writer.write("[");
+
+ ctx.addLast(new Element(Context.ARRAY, true));
+
+ return this;
+ }
+ catch (IOException e) {
+ throw new JsonException("Writer fails.", e);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public JsonGenerator writeStartArray(String name) {
+ try {
+ if (ctx.getLast().context() != Context.OBJECT)
+ throw new JsonGenerationException("Array with name in not object scope.");
+
+ writeComma();
+ writeString(name);
+ writer.write(":");
+ writer.write('[');
+
+ ctx.addLast(new Element(Context.ARRAY, true));
+
+ return this;
+ }
+ catch (IOException e) {
+ throw new JsonException("Writer fails.", e);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public JsonGenerator write(String name, JsonValue val) {
+ if (ctx.getLast().context() != Context.OBJECT)
+ throw new JsonGenerationException("Json value with name in not object scope.");
+
+ try {
+ switch (val.getValueType()) {
+ case ARRAY: {
+ JsonArray arr = (JsonArray) val;
+
+ writeStartArray(name);
+
+ for (JsonValue el : arr)
+ write(el);
+
+ writeEnd();
+
+ break;
+ }
+
+ case OBJECT: {
+ IgniteJsonObject o = (IgniteJsonObject) val;
+
+ writeStartObject(name);
+
+ for (Map.Entry<String, JsonValue> member : o.entrySet())
+ write(member.getKey(), member.getValue());
+
+ writeEnd();
+
+ break;
+ }
+
+ case STRING: {
+ JsonString str = (JsonString) val;
+
+ write(name, str.getString());
+
+ break;
+ }
+
+ case NUMBER: {
+ JsonNumber n = (JsonNumber) val;
+
+ writeComma();
+ writeString(name);
+ writer.write(":");
+ writeString(n.toString());
+
+ break;
+ }
+ case TRUE: {
+ write(name, true);
+
+ break;
+ }
+
+ case FALSE: {
+ write(name, false);
+
+ break;
+ }
+
+ case NULL: {
+ writeNull(name);
+
+ break;
+ }
+ }
+ return this;
+ }
+ catch (IOException e) {
+ throw new JsonException("Writer fails.", e);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public JsonGenerator write(String name, String val) {
+ return writeSimpleField(name, val);
+ }
+
+ /** {@inheritDoc} */
+ @Override public JsonGenerator write(String name, BigInteger val) {
+ return writeSimpleField(name, String.valueOf(val));
+ }
+
+ /** {@inheritDoc} */
+ @Override public JsonGenerator write(String name, BigDecimal val) {
+ return writeSimpleField(name, String.valueOf(val));
+ }
+
+ /** {@inheritDoc} */
+ @Override public JsonGenerator write(String name, int val) {
+ return writeSimpleField(name, String.valueOf(val));
+ }
+
+ /** {@inheritDoc} */
+ @Override public JsonGenerator write(String name, long val) {
+ return writeSimpleField(name, String.valueOf(val));
+ }
+
+ /** {@inheritDoc} */
+ @Override public JsonGenerator write(String name, double val) {
+ return writeSimpleField(name, String.valueOf(val));
+ }
+
+ /** {@inheritDoc} */
+ @Override public JsonGenerator write(String name, boolean val) {
+ return writeSimpleField(name, String.valueOf(val));
+ }
+
+ /** {@inheritDoc} */
+ @Override public JsonGenerator writeNull(String name) {
+ return writeSimpleField(name, "null");
+ }
+
+ /** {@inheritDoc} */
+ @Override public JsonGenerator writeEnd() {
+ if (ctx.getLast().context() == Context.NONE)
+ throw new JsonGenerationException("Cannot call writeEnd in none context.");
+
+ try {
+ if (ctx.getLast().context() == Context.ARRAY)
+ writer.write("]");
+
+ if (ctx.getLast().context() == Context.OBJECT)
+ writer.write("}");
+
+ ctx.removeLast();
+
+ return this;
+ }
+ catch(IOException e) {
+ throw new JsonException("Writer fails.", e);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public JsonGenerator write(JsonValue val) {
+ if (ctx.getLast().context() != Context.ARRAY)
+ throw new JsonGenerationException("Json value without name in not array scope.");
+
+ try {
+ switch (val.getValueType()) {
+ case ARRAY: {
+ JsonArray arr = (JsonArray) val;
+
+ writeStartArray();
+
+ for (JsonValue el : arr)
+ write(el);
+
+ writeEnd();
+
+ break;
+ }
+
+ case OBJECT: {
+ IgniteJsonObject o = (IgniteJsonObject) val;
+
+ writeStartObject();
+
+ for (Map.Entry<String, JsonValue> member : o.entrySet())
+ write(member.getKey(), member.getValue());
+
+ writeEnd();
+
+ break;
+ }
+
+ case STRING: {
+ JsonString str = (JsonString) val;
+
+ write(str.getString());
+
+ break;
+ }
+
+ case NUMBER: {
+ JsonNumber n = (JsonNumber) val;
+
+ writeComma();
+ writeString(n.toString());
+
+ break;
+ }
+ case TRUE: {
+ write(true);
+
+ break;
+ }
+
+ case FALSE: {
+ write(false);
+
+ break;
+ }
+
+ case NULL: {
+ writeNull();
+
+ break;
+ }
+ }
+ return this;
+ }
+ catch (IOException e) {
+ throw new JsonException("Writer fails.", e);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public JsonGenerator write(String val) {
+ return writeSimpleArrayElement(val);
+ }
+
+ /** {@inheritDoc} */
+ @Override public JsonGenerator write(BigDecimal val) {
+ return writeSimpleArrayElement(String.valueOf(val));
+ }
+
+ /** {@inheritDoc} */
+ @Override public JsonGenerator write(BigInteger val) {
+ return writeSimpleArrayElement(String.valueOf(val));
+ }
+
+ /** {@inheritDoc} */
+ @Override public JsonGenerator write(int val) {
+ return writeSimpleArrayElement(String.valueOf(val));
+ }
+
+ /** {@inheritDoc} */
+ @Override public JsonGenerator write(long val) {
+ return writeSimpleArrayElement(String.valueOf(val));
+ }
+
+ /** {@inheritDoc} */
+ @Override public JsonGenerator write(double val) {
+ return writeSimpleArrayElement(String.valueOf(val));
+ }
+
+ /** {@inheritDoc} */
+ @Override public JsonGenerator write(boolean val) {
+ return writeSimpleArrayElement(String.valueOf(val));
+ }
+
+ /** {@inheritDoc} */
+ @Override public JsonGenerator writeNull() {
+ return writeSimpleArrayElement("null");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void close() {
+ try {
+ writer.close();
+ }
+ catch (IOException e) {
+ throw new JsonException("Could not close writer.", e);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public void flush() {
+ try {
+ writer.flush();
+ }
+ catch (IOException e) {
+ throw new JsonException("Could not flush buffer to writer.", e);
+ }
+ }
+
+ /**
+ * Write comma if object is not first.
+ *
+ * @throws IOException If failed.
+ */
+ private void writeComma() throws IOException{
+ if (!ctx.getLast().isFirst())
+ writer.write(",");
+
+ ctx.getLast().isFirst = false;
+ }
+
+ /**
+ * @param name Field name.
+ * @param val Field value.
+ */
+ private JsonGenerator writeSimpleField(String name, String val) {
+ if (ctx.getLast().context() != Context.OBJECT)
+ throw new JsonGenerationException("String with name in not object scope.");
+
+ try {
+ writeComma();
+ writeString(name);
+ writer.write(":");
+ writeString(val);
+
+ return this;
+ }
+ catch (IOException e) {
+ throw new JsonException("Writer fails.", e);
+ }
+ }
+
+
+ /**
+ * @param val Field value.
+ */
+ private JsonGenerator writeSimpleArrayElement(String val) {
+ if (ctx.getLast().context() != Context.ARRAY)
+ throw new JsonGenerationException("String without name in not array scope.");
+
+ try {
+ writeComma();
+ writeString(val);
+
+ return this;
+ }
+ catch (IOException e) {
+ throw new JsonException("Writer fails.", e);
+ }
+ }
+
+ /**
+ * @param str String to write.
+ * @throws IOException If failed.
+ * //TODO: escape string.
+ */
+ private void writeString(String str) throws IOException {
+ writer.write(str);
+ }
+
+ /**
+ * Generator element.
+ */
+ private static class Element {
+ /** Context. */
+ private Context ctx;
+
+ /** First element flag. */
+ private boolean isFirst;
+
+ /**
+ * @param ctx Context.
+ * @param isFirst First element flag.
+ */
+ public Element(Context ctx, boolean isFirst) {
+ this.ctx = ctx;
+ this.isFirst = isFirst;
+ }
+
+ /**
+ * @return First element flag.
+ */
+ public boolean isFirst() {
+ return isFirst;
+ }
+
+ /**
+ * @return Context.
+ */
+ public Context context() {
+ return ctx;
+ }
+ }
+ /**
+ * Context for writer.
+ */
+ private enum Context {
+ /** Writing object. */
+ OBJECT,
+
+ /** Writing array. */
+ ARRAY,
+
+ /** Not in object or in array. */
+ NONE
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e6ba441d/modules/json/src/main/java/org/apache/ignite/internal/processors/json/IgniteJsonLocation.java
----------------------------------------------------------------------
diff --git a/modules/json/src/main/java/org/apache/ignite/internal/processors/json/IgniteJsonLocation.java b/modules/json/src/main/java/org/apache/ignite/internal/processors/json/IgniteJsonLocation.java
new file mode 100644
index 0000000..feb5a4d
--- /dev/null
+++ b/modules/json/src/main/java/org/apache/ignite/internal/processors/json/IgniteJsonLocation.java
@@ -0,0 +1,60 @@
+/*
+ * 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.json;
+
+import javax.json.stream.*;
+
+/**
+ * Json location implementation.
+ */
+public class IgniteJsonLocation implements JsonLocation {
+ /** Column number. */
+ private final long col;
+
+ /** Line number. */
+ private final long line;
+
+ /** Stream offset. */
+ private final long off;
+
+ /**
+ * @param line Line number.
+ * @param col Column number.
+ * @param streamOff Stream offset.
+ */
+ IgniteJsonLocation(long line, long col, long streamOff) {
+ this.line = line;
+ this.col = col;
+ this.off = streamOff;
+ }
+
+ /** {@inheritDoc} */
+ @Override public long getLineNumber() {
+ return line;
+ }
+
+ /** {@inheritDoc} */
+ @Override public long getColumnNumber() {
+ return col;
+ }
+
+ /** {@inheritDoc} */
+ @Override public long getStreamOffset() {
+ return off;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e6ba441d/modules/json/src/main/java/org/apache/ignite/internal/processors/json/IgniteJsonMessageFactory.java
----------------------------------------------------------------------
diff --git a/modules/json/src/main/java/org/apache/ignite/internal/processors/json/IgniteJsonMessageFactory.java b/modules/json/src/main/java/org/apache/ignite/internal/processors/json/IgniteJsonMessageFactory.java
new file mode 100644
index 0000000..ff9f228
--- /dev/null
+++ b/modules/json/src/main/java/org/apache/ignite/internal/processors/json/IgniteJsonMessageFactory.java
@@ -0,0 +1,36 @@
+/*
+ * 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.json;
+
+import org.apache.ignite.plugin.extensions.communication.*;
+import org.jetbrains.annotations.*;
+
+/**
+ *
+ */
+public class IgniteJsonMessageFactory implements MessageFactory {
+ /** {@inheritDoc} */
+ @Nullable @Override public Message create(byte type) {
+ switch (type) {
+ case -23:
+ return new JsonCacheObject();
+ }
+
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e6ba441d/modules/json/src/main/java/org/apache/ignite/internal/processors/json/IgniteJsonNumber.java
----------------------------------------------------------------------
diff --git a/modules/json/src/main/java/org/apache/ignite/internal/processors/json/IgniteJsonNumber.java b/modules/json/src/main/java/org/apache/ignite/internal/processors/json/IgniteJsonNumber.java
new file mode 100644
index 0000000..acbd50c
--- /dev/null
+++ b/modules/json/src/main/java/org/apache/ignite/internal/processors/json/IgniteJsonNumber.java
@@ -0,0 +1,116 @@
+/*
+ * 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.json;
+
+import javax.json.*;
+import java.io.*;
+import java.math.*;
+
+/**
+ * Json number implementation.
+ *
+ * TODO IGNITE-962: optimize for int, long, double.
+ */
+public class IgniteJsonNumber implements JsonNumber, Serializable {
+ /** Value. */
+ private final BigDecimal val;
+
+ /**
+ * @param val Value.
+ */
+ public IgniteJsonNumber(BigDecimal val){
+ this.val = val;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isIntegral() {
+ return val != null && val.scale() == 0;
+
+ }
+
+ /** {@inheritDoc} */
+ @Override public int intValue() {
+ return val.intValue();
+ }
+
+ /** {@inheritDoc} */
+ @Override public int intValueExact() {
+ return val.intValueExact();
+ }
+
+ /** {@inheritDoc} */
+ @Override public long longValue() {
+ return val.longValue();
+ }
+
+ /** {@inheritDoc} */
+ @Override public long longValueExact() {
+ return val.longValueExact();
+ }
+
+ /** {@inheritDoc} */
+ @Override public BigInteger bigIntegerValue() {
+ return val.toBigInteger();
+ }
+
+ /** {@inheritDoc} */
+ @Override public BigInteger bigIntegerValueExact() {
+ return val.toBigIntegerExact();
+ }
+
+ /** {@inheritDoc} */
+ @Override public double doubleValue() {
+ return val.doubleValue();
+ }
+
+ /** {@inheritDoc} */
+ @Override public BigDecimal bigDecimalValue() {
+ return val;
+ }
+
+ /** {@inheritDoc} */
+ @Override public ValueType getValueType() {
+ return ValueType.NUMBER;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return val.toString();
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ if (val == null)
+ return 0;
+
+ return val.hashCode();
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object obj) {
+ if (obj == null || !(obj instanceof IgniteJsonNumber))
+ return false;
+
+ BigDecimal val0 = ((IgniteJsonNumber)obj).val;
+
+ if (val == null)
+ return val0 == null;
+
+ return val.equals(val0);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e6ba441d/modules/json/src/main/java/org/apache/ignite/internal/processors/json/IgniteJsonObject.java
----------------------------------------------------------------------
diff --git a/modules/json/src/main/java/org/apache/ignite/internal/processors/json/IgniteJsonObject.java b/modules/json/src/main/java/org/apache/ignite/internal/processors/json/IgniteJsonObject.java
new file mode 100644
index 0000000..283b396
--- /dev/null
+++ b/modules/json/src/main/java/org/apache/ignite/internal/processors/json/IgniteJsonObject.java
@@ -0,0 +1,117 @@
+/*
+ * 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.json;
+
+import javax.json.*;
+import java.io.*;
+import java.util.*;
+
+/**
+ * IgniteJsonObject implementation.
+ */
+public class IgniteJsonObject extends HashMap<String, JsonValue> implements javax.json.JsonObject, Serializable {
+ /**
+ * @param val Map to store.
+ */
+ public IgniteJsonObject(Map<String, JsonValue> val) {
+ super(val);
+ }
+
+ /** {@inheritDoc} */
+ @Override public JsonArray getJsonArray(String name) {
+ return (JsonArray)get(name);
+ }
+
+ /** {@inheritDoc} */
+ @Override public javax.json.JsonObject getJsonObject(String name) {
+ return (javax.json.JsonObject)get(name);
+ }
+
+ /** {@inheritDoc} */
+ @Override public JsonNumber getJsonNumber(String name) {
+ return (JsonNumber)get(name);
+ }
+
+ /** {@inheritDoc} */
+ @Override public JsonString getJsonString(String name) {
+ return (JsonString)get(name);
+ }
+
+ /** {@inheritDoc} */
+ @Override public String getString(String name) {
+ return getJsonString(name).getString();
+ }
+
+ /** {@inheritDoc} */
+ @Override public String getString(String name, String dfltVal) {
+ try {
+ return getString(name);
+ }
+ catch (Exception e) {
+ return dfltVal;
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public int getInt(String name) {
+ return getJsonNumber(name).intValue();
+ }
+
+ /** {@inheritDoc} */
+ @Override public int getInt(String name, int dfltVal) {
+ try {
+ return getInt(name);
+ }
+ catch (Exception e) {
+ return dfltVal;
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean getBoolean(String name) {
+ JsonValue val = get(name);
+
+ if (val.equals(JsonValue.TRUE))
+ return true;
+
+ if (val.equals(JsonValue.FALSE))
+ return false;
+
+ throw new ClassCastException();
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean getBoolean(String name, boolean dfltVal) {
+ try {
+ return getBoolean(name);
+ }
+ catch (Exception e) {
+ return dfltVal;
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isNull(String name) {
+ return get(name).equals(JsonValue.NULL);
+ }
+
+ /** {@inheritDoc} */
+ @Override public ValueType getValueType() {
+ return ValueType.OBJECT;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e6ba441d/modules/json/src/main/java/org/apache/ignite/internal/processors/json/IgniteJsonObjectBuilder.java
----------------------------------------------------------------------
diff --git a/modules/json/src/main/java/org/apache/ignite/internal/processors/json/IgniteJsonObjectBuilder.java b/modules/json/src/main/java/org/apache/ignite/internal/processors/json/IgniteJsonObjectBuilder.java
new file mode 100644
index 0000000..c5006fc
--- /dev/null
+++ b/modules/json/src/main/java/org/apache/ignite/internal/processors/json/IgniteJsonObjectBuilder.java
@@ -0,0 +1,141 @@
+/*
+ * 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.json;
+
+import org.apache.ignite.internal.util.typedef.internal.*;
+
+import javax.json.*;
+import java.math.*;
+import java.util.*;
+
+/**
+ * Json object builder implementation.
+ */
+public class IgniteJsonObjectBuilder implements JsonObjectBuilder {
+ /** Json object map. */
+ private Map<String, JsonValue> jsonMap = new HashMap<>();
+
+ /** {@inheritDoc} */
+ @Override public JsonObjectBuilder add(String name, JsonValue val) {
+ A.notNull(name, "key", val, "value");
+
+ jsonMap.put(name, val);
+
+ return this;
+ }
+
+ /** {@inheritDoc} */
+ @Override public JsonObjectBuilder add(String name, String val) {
+ A.notNull(name, "key", val, "value");
+
+ jsonMap.put(name, new IgniteJsonString(val));
+
+ return this;
+ }
+
+ /** {@inheritDoc} */
+ @Override public JsonObjectBuilder add(String name, BigInteger val) {
+ A.notNull(name, "key", val, "value");
+
+ //TODO: optimize for value
+ jsonMap.put(name, new IgniteJsonNumber(new BigDecimal(val)));
+
+ return this;
+ }
+
+ /** {@inheritDoc} */
+ @Override public JsonObjectBuilder add(String name, BigDecimal val) {
+ A.notNull(name, "key", val, "value");
+
+ //TODO: optimize for value
+ jsonMap.put(name, new IgniteJsonNumber(val));
+
+ return this;
+ }
+
+ /** {@inheritDoc} */
+ @Override public JsonObjectBuilder add(String name, int val) {
+ A.notNull(name, "key");
+
+ //TODO: optimize for value
+ jsonMap.put(name, new IgniteJsonNumber(new BigDecimal(val)));
+
+ return this;
+ }
+
+ /** {@inheritDoc} */
+ @Override public JsonObjectBuilder add(String name, long val) {
+ A.notNull(name, "key");
+
+ //TODO: optimize for value
+ jsonMap.put(name, new IgniteJsonNumber(new BigDecimal(val)));
+
+ return this;
+ }
+
+ /** {@inheritDoc} */
+ @Override public JsonObjectBuilder add(String name, double val) {
+ A.notNull(name, "key");
+
+ //TODO: optimize for value
+ jsonMap.put(name, new IgniteJsonNumber(new BigDecimal(val)));
+
+ return this;
+ }
+
+ /** {@inheritDoc} */
+ @Override public JsonObjectBuilder add(String name, boolean val) {
+ A.notNull(name, "key");
+
+ jsonMap.put(name, val ? JsonValue.TRUE : JsonValue.FALSE);
+
+ return this;
+ }
+
+ /** {@inheritDoc} */
+ @Override public JsonObjectBuilder addNull(String name) {
+ A.notNull(name, "key");
+
+ jsonMap.put(name, JsonValue.NULL);
+
+ return this;
+ }
+
+ /** {@inheritDoc} */
+ @Override public JsonObjectBuilder add(String name, JsonObjectBuilder bld) {
+ A.notNull(name, "key", bld, "value");
+
+ jsonMap.put(name, bld.build());
+
+ return this;
+ }
+
+ /** {@inheritDoc} */
+ @Override public JsonObjectBuilder add(String name, JsonArrayBuilder bld) {
+ A.notNull(name, "key", bld, "value");
+
+ jsonMap.put(name, bld.build());
+
+ return this;
+ }
+
+ /** {@inheritDoc} */
+ @Override public javax.json.JsonObject build() {
+ return new IgniteJsonObject(jsonMap);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e6ba441d/modules/json/src/main/java/org/apache/ignite/internal/processors/json/IgniteJsonProcessorImpl.java
----------------------------------------------------------------------
diff --git a/modules/json/src/main/java/org/apache/ignite/internal/processors/json/IgniteJsonProcessorImpl.java b/modules/json/src/main/java/org/apache/ignite/internal/processors/json/IgniteJsonProcessorImpl.java
new file mode 100644
index 0000000..3e23b83
--- /dev/null
+++ b/modules/json/src/main/java/org/apache/ignite/internal/processors/json/IgniteJsonProcessorImpl.java
@@ -0,0 +1,115 @@
+/*
+ * 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.json;
+
+import org.apache.ignite.*;
+import org.apache.ignite.internal.*;
+import org.apache.ignite.internal.processors.*;
+import org.apache.ignite.internal.processors.cache.*;
+import org.jetbrains.annotations.*;
+
+import javax.json.*;
+
+/**
+ *
+ */
+public class IgniteJsonProcessorImpl extends GridProcessorAdapter implements IgniteJsonProcessor {
+ /**
+ * @param ctx Context.
+ */
+ public IgniteJsonProcessorImpl(GridKernalContext ctx) {
+ super(ctx);
+ }
+
+ /** {@inheritDoc} */
+ @Override public KeyCacheObject toCacheKeyObject(CacheObjectContext ctx, Object obj, boolean userObj) {
+ if (obj instanceof JsonObject)
+ return new JsonCacheObject((JsonObject)obj);
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public CacheObject toCacheObject(CacheObjectContext ctx,
+ @Nullable Object obj,
+ boolean userObj) {
+ if (obj instanceof JsonObject)
+ return new JsonCacheObject((JsonObject)obj);
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean jsonType(Class<?> cls) {
+ return cls.equals(JsonObject.class);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean jsonObject(Object obj) {
+ return obj instanceof JsonCacheObject || obj instanceof JsonObject;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean hasField(Object obj, String fieldName) {
+ if (obj instanceof JsonObject)
+ return ((JsonObject)obj).containsKey(fieldName);
+
+ return ((JsonCacheObject)obj).hasField(fieldName);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Object field(Object obj, String fieldName) {
+ if (obj instanceof JsonObject)
+ return value((JsonObject) obj, fieldName);
+
+ return ((JsonCacheObject)obj).field(fieldName);
+ }
+
+ /**
+ * @param obj Object.
+ * @param fieldName Field name.
+ * @return Field value.
+ */
+ static Object value(JsonObject obj, String fieldName) {
+ JsonValue jsonVal = obj.get(fieldName);
+
+ if (jsonVal == null)
+ return null;
+
+ switch (jsonVal.getValueType()) {
+ case FALSE:
+ return Boolean.FALSE;
+
+ case TRUE:
+ return Boolean.TRUE;
+
+ case STRING:
+ return ((JsonString)jsonVal).getString();
+
+ case NUMBER:
+ return ((JsonNumber)jsonVal).intValue();
+
+ case OBJECT:
+ return jsonVal;
+
+ default:
+ throw new IgniteException("Unsupported type [field=" + fieldName +
+ ", type=" + jsonVal.getValueType() + ']');
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e6ba441d/modules/json/src/main/java/org/apache/ignite/internal/processors/json/IgniteJsonProvider.java
----------------------------------------------------------------------
diff --git a/modules/json/src/main/java/org/apache/ignite/internal/processors/json/IgniteJsonProvider.java b/modules/json/src/main/java/org/apache/ignite/internal/processors/json/IgniteJsonProvider.java
new file mode 100644
index 0000000..dbcd8b8
--- /dev/null
+++ b/modules/json/src/main/java/org/apache/ignite/internal/processors/json/IgniteJsonProvider.java
@@ -0,0 +1,104 @@
+/*
+ * 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.json;
+
+import javax.json.*;
+import javax.json.spi.*;
+import javax.json.stream.*;
+import java.io.*;
+import java.util.*;
+
+/**
+ * Json provider implementation.
+ */
+public class IgniteJsonProvider extends JsonProvider {
+ /** {@inheritDoc} */
+ @Override public JsonParser createParser(Reader reader) {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public JsonParser createParser(InputStream in) {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public JsonParserFactory createParserFactory(Map<String, ?> config) {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public JsonGenerator createGenerator(Writer writer) {
+ return new IgniteJsonGenerator(writer);
+ }
+
+ /** {@inheritDoc} */
+ @Override public JsonGenerator createGenerator(OutputStream out) {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public JsonGeneratorFactory createGeneratorFactory(Map<String, ?> config) {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public JsonReader createReader(Reader reader) {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public JsonReader createReader(InputStream in) {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public JsonWriter createWriter(Writer writer) {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public JsonWriter createWriter(OutputStream out) {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public JsonWriterFactory createWriterFactory(Map<String, ?> config) {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public JsonReaderFactory createReaderFactory(Map<String, ?> config) {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public JsonObjectBuilder createObjectBuilder() {
+ return new IgniteJsonObjectBuilder();
+ }
+
+ /** {@inheritDoc} */
+ @Override public JsonArrayBuilder createArrayBuilder() {
+ return new IgniteJsonArrayBuilder();
+ }
+
+ /** {@inheritDoc} */
+ @Override public JsonBuilderFactory createBuilderFactory(Map<String, ?> config) {
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e6ba441d/modules/json/src/main/java/org/apache/ignite/internal/processors/json/IgniteJsonString.java
----------------------------------------------------------------------
diff --git a/modules/json/src/main/java/org/apache/ignite/internal/processors/json/IgniteJsonString.java b/modules/json/src/main/java/org/apache/ignite/internal/processors/json/IgniteJsonString.java
new file mode 100644
index 0000000..3adeb6b
--- /dev/null
+++ b/modules/json/src/main/java/org/apache/ignite/internal/processors/json/IgniteJsonString.java
@@ -0,0 +1,77 @@
+/*
+ * 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.json;
+
+import javax.json.*;
+import java.io.*;
+
+/**
+ * Json string implementation.
+ */
+public class IgniteJsonString implements JsonString, Serializable {
+ /** Value. */
+ private final String val;
+
+ /**
+ * @param val Value.
+ */
+ public IgniteJsonString(String val) {
+ this.val = val;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String getString() {
+ return val;
+ }
+
+ /** {@inheritDoc} */
+ @Override public CharSequence getChars() {
+ return val;
+ }
+
+ /** {@inheritDoc} */
+ @Override public ValueType getValueType() {
+ return ValueType.STRING;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ if (val == null)
+ return 0;
+
+ return val.hashCode();
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object obj) {
+ if (obj == null || !(obj instanceof JsonString))
+ return false;
+
+ JsonString other = (JsonString)obj;
+
+ if (val == null)
+ return other.getString() == null;
+
+ return val.equals(other.getString());
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return val;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e6ba441d/modules/json/src/main/java/org/apache/ignite/internal/processors/json/JsonCacheObject.java
----------------------------------------------------------------------
diff --git a/modules/json/src/main/java/org/apache/ignite/internal/processors/json/JsonCacheObject.java b/modules/json/src/main/java/org/apache/ignite/internal/processors/json/JsonCacheObject.java
new file mode 100644
index 0000000..9d631f5
--- /dev/null
+++ b/modules/json/src/main/java/org/apache/ignite/internal/processors/json/JsonCacheObject.java
@@ -0,0 +1,103 @@
+/*
+ * 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.json;
+
+import org.apache.ignite.*;
+import org.apache.ignite.internal.processors.cache.*;
+import org.jetbrains.annotations.*;
+
+import javax.json.*;
+
+/**
+ *
+ */
+public class JsonCacheObject extends CacheObjectAdapter implements KeyCacheObject {
+ /**
+ *
+ */
+ public JsonCacheObject() {
+ // No-op.
+ }
+
+ /**
+ * @param obj Object.
+ */
+ public JsonCacheObject(JsonObject obj) {
+ this.val = obj;
+ }
+
+ /** {@inheritDoc} */
+ @Override public byte type() {
+ return 10;
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public <T> T value(CacheObjectContext ctx, boolean cpy) {
+ return (T)val;
+ }
+
+ /** {@inheritDoc} */
+ @Override public byte[] valueBytes(CacheObjectContext ctx) throws IgniteCheckedException {
+ return valBytes;
+ }
+
+ /** {@inheritDoc} */
+ @Override public CacheObject prepareForCache(CacheObjectContext ctx) {
+ return this;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void finishUnmarshal(CacheObjectContext ctx, ClassLoader ldr) throws IgniteCheckedException {
+ assert val != null || valBytes != null;
+
+ if (val == null)
+ val = ctx.processor().unmarshal(ctx, valBytes, ldr);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void prepareMarshal(CacheObjectContext ctx) throws IgniteCheckedException {
+ if (valBytes == null)
+ valBytes = ctx.processor().marshal(ctx, val);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean internal() {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public byte directType() {
+ return -23;
+ }
+
+ /**
+ * @param fieldName Field name.
+ * @return {@code True} if has field.
+ */
+ boolean hasField(String fieldName) {
+ return ((IgniteJsonObject)val).containsKey(fieldName);
+ }
+
+ /**
+ * @param fieldName Field name.
+ * @return Field value.
+ */
+ Object field(String fieldName) {
+ return IgniteJsonProcessorImpl.value((JsonObject)val, fieldName);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e6ba441d/modules/json/src/main/java/org/apache/ignite/json/IgniteJson.java
----------------------------------------------------------------------
diff --git a/modules/json/src/main/java/org/apache/ignite/json/IgniteJson.java b/modules/json/src/main/java/org/apache/ignite/json/IgniteJson.java
new file mode 100644
index 0000000..f55f06d
--- /dev/null
+++ b/modules/json/src/main/java/org/apache/ignite/json/IgniteJson.java
@@ -0,0 +1,36 @@
+/*
+ * 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.json;
+
+import org.apache.ignite.*;
+import org.apache.ignite.internal.processors.json.*;
+
+import javax.json.spi.*;
+
+/**
+ *
+ */
+public class IgniteJson {
+ /**
+ * @param ignite Ignite.
+ * @return Ignite JSON API provider.
+ */
+ public static JsonProvider jsonProvider(Ignite ignite) {
+ return new IgniteJsonProvider();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e6ba441d/modules/json/src/test/java/org/apache/ignite/internal/processors/json/IgniteJsonCacheTest.java
----------------------------------------------------------------------
diff --git a/modules/json/src/test/java/org/apache/ignite/internal/processors/json/IgniteJsonCacheTest.java b/modules/json/src/test/java/org/apache/ignite/internal/processors/json/IgniteJsonCacheTest.java
new file mode 100644
index 0000000..6f710fc
--- /dev/null
+++ b/modules/json/src/test/java/org/apache/ignite/internal/processors/json/IgniteJsonCacheTest.java
@@ -0,0 +1,194 @@
+package org.apache.ignite.internal.processors.json;/*
+ * 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.
+ */
+
+import org.apache.ignite.*;
+import org.apache.ignite.cache.*;
+import org.apache.ignite.cache.query.*;
+import org.apache.ignite.configuration.*;
+import org.apache.ignite.json.*;
+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 javax.cache.*;
+import javax.json.*;
+import javax.json.spi.*;
+import java.util.*;
+
+/**
+ *
+ */
+public class IgniteJsonCacheTest extends GridCommonAbstractTest {
+ /** */
+ protected static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
+
+ /** */
+ private boolean client;
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder);
+
+ CacheConfiguration ccfg = new CacheConfiguration();
+
+ CacheTypeMetadata meta = new CacheTypeMetadata();
+
+ meta.setValueType(JsonObject.class);
+
+ Map<String, Class<?>> ascFields = new HashMap<>();
+
+ ascFields.put("name", String.class);
+ ascFields.put("id", Integer.class);
+ ascFields.put("address.street", String.class);
+
+ meta.setAscendingFields(ascFields);
+
+ Map<String, Class<?>> qryFields = new HashMap<>();
+
+ qryFields.put("salary", Integer.class);
+ qryFields.put("address", JsonObject.class);
+
+ meta.setQueryFields(qryFields);
+
+ ccfg.setTypeMetadata(Collections.singleton(meta));
+
+ cfg.setCacheConfiguration(ccfg);
+
+ cfg.setClientMode(client);
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTestsStarted() throws Exception {
+ super.beforeTestsStarted();
+
+ startGrid(0);
+
+ client = true;
+
+ startGrid(1);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ super.afterTestsStopped();
+
+ stopAllGrids();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testQuery() throws Exception {
+ IgniteCache<Integer, JsonObject> cache = ignite(1).cache(null);
+
+ assertNotNull(cache);
+
+ JsonProvider provider = IgniteJson.jsonProvider(ignite(1));
+
+ for (int i = 0; i < 10; i++) {
+ JsonObjectBuilder person = provider.createObjectBuilder();
+
+ person.add("name", "n-" + i);
+ person.add("salary", (i + 1) * 1000);
+ person.add("id", i);
+
+ JsonObjectBuilder addr = provider.createObjectBuilder();
+
+ addr.add("street", "s-" + i);
+
+ person.add("address", addr);
+
+ JsonObject obj = person.build();
+
+ cache.put(i, obj);
+ }
+
+ SqlQuery<Integer, JsonObject> nameQry = new SqlQuery<>(JsonObject.class, "name = ?");
+
+ nameQry.setArgs("n-5");
+
+ List<Cache.Entry<Integer, JsonObject>> res = cache.query(nameQry).getAll();
+
+ log.info("Res: " + res);
+
+ assertEquals(1, res.size());
+
+ SqlQuery<Integer, JsonObject> idQry = new SqlQuery<>(JsonObject.class, "id > ?");
+
+ idQry.setArgs(5);
+
+ res = cache.query(idQry).getAll();
+
+ log.info("Res: " + res);
+
+ assertEquals(4, res.size());
+
+ SqlFieldsQuery avgQry = new SqlFieldsQuery("select avg(salary) from JsonObject");
+
+ log.info("Res: " + cache.query(avgQry).getAll());
+
+ SqlFieldsQuery fieldsQry = new SqlFieldsQuery("select name, salary from JsonObject where street = 's-3'");
+
+ log.info("Res: " + cache.query(fieldsQry).getAll());
+
+ fieldsQry = new SqlFieldsQuery("select address from JsonObject where street = 's-3'");
+
+ List<List<?>> fieldsRes = cache.query(fieldsQry).getAll();
+
+ assertEquals(1, fieldsRes.size());
+
+ List<?> fields = fieldsRes.get(0);
+
+ assertEquals(1, fields.size());
+
+ JsonObject obj = (JsonObject)fields.get(0);
+
+ log.info("Res: " + obj);
+
+ assertEquals("s-3", obj.getString("street"));
+
+ log.info("Res: " +
+ cache.query(new SqlFieldsQuery("select street from JsonObject where street = 's-3'")).getAll());
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testJson() throws Exception {
+ IgniteCache<Integer, JsonObject> clientCache = ignite(1).cache(null);
+
+ JsonProvider provider = IgniteJson.jsonProvider(ignite(1));
+
+ JsonObjectBuilder builder = provider.createObjectBuilder();
+
+ builder.add("name", "n1");
+ builder.add("id", 1);
+
+ JsonObject obj = builder.build();
+
+ clientCache.put(1, obj);
+
+ obj = clientCache.get(1);
+
+ log.info("Get: " + obj);
+ }
+}
[05/21] incubator-ignite git commit: #ignite-961: query rest tests.
Posted by se...@apache.org.
#ignite-961: query rest 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/f7bb17cf
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/f7bb17cf
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/f7bb17cf
Branch: refs/heads/ignite-1121
Commit: f7bb17cf5ddbd19b1c2bda51b176bdccc6677941
Parents: b6c68eb
Author: ivasilinets <iv...@gridgain.com>
Authored: Fri Jul 17 16:37:43 2015 +0300
Committer: ivasilinets <iv...@gridgain.com>
Committed: Fri Jul 17 16:37:43 2015 +0300
----------------------------------------------------------------------
.../JettyRestProcessorAbstractSelfTest.java | 263 +++++++++++++++++++
.../handlers/query/QueryCommandHandler.java | 3 +
.../http/jetty/GridJettyRestHandler.java | 12 +-
3 files changed, 274 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f7bb17cf/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 38bfef5..09c0e13 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
@@ -20,13 +20,19 @@ package org.apache.ignite.internal.processors.rest;
import net.sf.json.*;
import org.apache.ignite.*;
import org.apache.ignite.cache.*;
+import org.apache.ignite.cache.query.*;
+import org.apache.ignite.cache.query.annotations.*;
import org.apache.ignite.cluster.*;
+import org.apache.ignite.configuration.*;
+import org.apache.ignite.internal.processors.rest.handlers.*;
import org.apache.ignite.internal.util.typedef.*;
+import org.apache.ignite.testframework.*;
import java.io.*;
import java.net.*;
import java.nio.charset.*;
import java.util.*;
+import java.util.concurrent.*;
import java.util.regex.*;
import static org.apache.ignite.IgniteSystemProperties.*;
@@ -1386,5 +1392,262 @@ abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestProcessorS
assertEquals(qryId0, qryId);
}
+ /**
+ * @throws Exception If failed.
+ */
+ public void testQueryArgsPost() throws Exception {
+ initCache();
+
+ String qry = "salary > ? and salary <= ?";
+
+ String ret = makePostRequest(F.asMap("cmd", "qryexecute", "type", "Person", "psz", "10", "cacheName", "person",
+ "qry", URLEncoder.encode(qry)),
+ "{\"arg\": [1000, 2000]}");
+
+ assertNotNull(ret);
+ assertTrue(!ret.isEmpty());
+
+ JSONObject json = JSONObject.fromObject(ret);
+
+ List items = (List)((Map)json.get("response")).get("items");
+
+ assertEquals(2, items.size());
+
+ for (int i = 0; i < GRID_CNT; ++i) {
+ Map<GridRestCommand, GridRestCommandHandler> handlers =
+ GridTestUtils.getFieldValue(grid(i).context().rest(), "handlers");
+
+ GridRestCommandHandler qryHnd = handlers.get(GridRestCommand.CLOSE_SQL_QUERY);
+
+ ConcurrentHashMap<Long, Iterator> its = GridTestUtils.getFieldValue(qryHnd, "curs");
+
+ assertEquals(0, its.size());
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testQueryArgs() throws Exception {
+ initCache();
+
+ String qry = "salary > ? and salary <= ?";
+
+ Map<String, String> params = new HashMap<>();
+ params.put("cmd", "qryexecute");
+ params.put("type", "Person");
+ params.put("psz", "10");
+ params.put("cacheName", "person");
+ params.put("qry", URLEncoder.encode(qry));
+ params.put("arg1", "1000");
+ params.put("arg2", "2000");
+
+ String ret = content(params);
+
+ assertNotNull(ret);
+ assertTrue(!ret.isEmpty());
+
+ JSONObject json = JSONObject.fromObject(ret);
+
+ List items = (List)((Map)json.get("response")).get("items");
+
+ assertEquals(2, items.size());
+
+ for (int i = 0; i < GRID_CNT; ++i) {
+ Map<GridRestCommand, GridRestCommandHandler> handlers =
+ GridTestUtils.getFieldValue(grid(i).context().rest(), "handlers");
+
+ GridRestCommandHandler qryHnd = handlers.get(GridRestCommand.CLOSE_SQL_QUERY);
+
+ ConcurrentHashMap<Long, Iterator> its = GridTestUtils.getFieldValue(qryHnd, "curs");
+
+ assertEquals(0, its.size());
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testQueryClose() throws Exception {
+ initCache();
+
+ String qry = "salary > ? and salary <= ?";
+
+ String ret = makePostRequest(F.asMap("cmd", "qryexecute", "type", "Person", "psz", "1", "cacheName", "person",
+ "qry", URLEncoder.encode(qry)),
+ "{\"arg\": [1000, 2000]}");
+
+ assertNotNull(ret);
+ assertTrue(!ret.isEmpty());
+
+ JSONObject json = JSONObject.fromObject(ret);
+
+ List items = (List)((Map)json.get("response")).get("items");
+
+ assertEquals(1, items.size());
+
+ boolean found = false;
+
+ for (int i = 0; i < GRID_CNT; ++i) {
+ Map<GridRestCommand, GridRestCommandHandler> handlers =
+ GridTestUtils.getFieldValue(grid(i).context().rest(), "handlers");
+
+ GridRestCommandHandler qryHnd = handlers.get(GridRestCommand.CLOSE_SQL_QUERY);
+
+ ConcurrentHashMap<Long, Iterator> its = GridTestUtils.getFieldValue(qryHnd, "curs");
+
+ found |= its.size() != 0;
+ }
+
+ assertTrue(found);
+
+ Integer qryId = (Integer)((Map)json.get("response")).get("queryId");
+
+ assertNotNull(qryId);
+
+ ret = content(F.asMap("cmd", "qryclose", "cacheName", "person", "qryId", String.valueOf(qryId)));
+
+ assertNotNull(ret);
+ assertTrue(!ret.isEmpty());
+
+ found = false;
+
+ for (int i = 0; i < GRID_CNT; ++i) {
+ Map<GridRestCommand, GridRestCommandHandler> handlers =
+ GridTestUtils.getFieldValue(grid(i).context().rest(), "handlers");
+
+ GridRestCommandHandler qryHnd = handlers.get(GridRestCommand.CLOSE_SQL_QUERY);
+
+ ConcurrentHashMap<Long, Iterator> its = GridTestUtils.getFieldValue(qryHnd, "curs");
+
+ found |= its.size() != 0;
+ }
+
+ assertFalse(found);
+ }
+
protected abstract String signature() throws Exception;
+
+
+ /**
+ * Init cache.
+ */
+ private void initCache() {
+ CacheConfiguration<Integer, Person> personCacheCfg = new CacheConfiguration<>("person");
+ personCacheCfg.setIndexedTypes(Integer.class, Person.class);
+
+ IgniteCache<Integer, Person> personCache = grid(0).getOrCreateCache(personCacheCfg);
+
+ personCache.clear();
+
+ Person p1 = new Person("John", "Doe", 2000);
+ Person p2 = new Person("Jane", "Doe", 1000);
+ Person p3 = new Person("John", "Smith", 1000);
+ Person p4 = new Person("Jane", "Smith", 2000);
+
+ personCache.put(p1.getId(), p1);
+ personCache.put(p2.getId(), p2);
+ personCache.put(p3.getId(), p3);
+ personCache.put(p4.getId(), p4);
+
+ SqlQuery<Integer, Person> qry = new SqlQuery<>(Person.class, "salary > ? and salary <= ?");
+
+ qry.setArgs(1000, 2000);
+
+ assertEquals(2, personCache.query(qry).getAll().size());
+ }
+
+ /**
+ * Person class.
+ */
+ public static class Person implements Serializable {
+ /** Person id. */
+ private static int PERSON_ID = 0;
+
+ /** Person ID (indexed). */
+ @QuerySqlField(index = true)
+ private Integer id;
+
+ /** First name (not-indexed). */
+ @QuerySqlField
+ private String firstName;
+
+ /** Last name (not indexed). */
+ @QuerySqlField
+ private String lastName;
+
+ /** Salary (indexed). */
+ @QuerySqlField(index = true)
+ private double salary;
+
+ /**
+ * @param firstName First name.
+ * @param lastName Last name.
+ * @param salary Salary.
+ */
+ Person(String firstName, String lastName, double salary) {
+ id = PERSON_ID++;
+
+ this.firstName = firstName;
+ this.lastName = lastName;
+ this.salary = salary;
+ }
+
+ /**
+ * @param firstName First name.
+ */
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ /**
+ * @return First name.
+ */
+ public String getFirstName() {
+ return firstName;
+ }
+
+ /**
+ * @param lastName Last name.
+ */
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+ /**
+ * @return Last name.
+ */
+ public String getLastName() {
+ return lastName;
+ }
+
+ /**
+ * @param id Id.
+ */
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ /**
+ * @param salary Salary.
+ */
+ public void setSalary(double salary) {
+ this.salary = salary;
+ }
+
+ /**
+ * @return Salary.
+ */
+ public double getSalary() {
+
+ return salary;
+ }
+
+ /**
+ * @return Id.
+ */
+ public Integer getId() {
+ return id;
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f7bb17cf/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/query/QueryCommandHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/query/QueryCommandHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/query/QueryCommandHandler.java
index e2118b6..6eb2e20 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/query/QueryCommandHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/query/QueryCommandHandler.java
@@ -197,6 +197,9 @@ public class QueryCommandHandler extends GridRestCommandHandlerAdapter {
cur.close();
+ qryCurs.remove(req.queryId());
+ curs.remove(req.queryId());
+
return new GridRestResponse(true);
}
catch (Exception e) {
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f7bb17cf/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 1acab51..2d8fa3e 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
@@ -640,12 +640,16 @@ public class GridJettyRestHandler extends AbstractHandler {
case EXECUTE_SQL_FIELDS_QUERY: {
RestSqlQueryRequest restReq0 = new RestSqlQueryRequest();
- restReq0.sqlQuery((String)params.get("qry"));
+ restReq0.sqlQuery((String) params.get("qry"));
- Map o = parseRequest(req);
- List args = (List)ctx.scripting().toJavaObject(o.get("arg"));
+ if (req.getHeader("Content-Type") != null && req.getHeader("Content-Type").contains("json")) {
+ Map o = parseRequest(req);
+ List args = (List) ctx.scripting().toJavaObject(o.get("arg"));
+ restReq0.arguments(args.toArray());
+ }
+ else
+ restReq0.arguments(values("arg", params).toArray());
- restReq0.arguments(args.toArray());
restReq0.typeName((String)params.get("type"));
restReq0.pageSize(Integer.parseInt((String) params.get("psz")));
restReq0.cacheName((String)params.get("cacheName"));
[07/21] incubator-ignite git commit: # ignite-962 simple json object
implementation
Posted by se...@apache.org.
# ignite-962 simple json object implementation
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/e6ba441d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/e6ba441d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/e6ba441d
Branch: refs/heads/ignite-1121
Commit: e6ba441dc4c16464c4fa6f8af26edcdd4f72607f
Parents: c7e7c46
Author: sboikov <sb...@gridgain.com>
Authored: Fri Jul 17 17:10:52 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Fri Jul 17 17:10:52 2015 +0300
----------------------------------------------------------------------
.../ignite/internal/GridKernalContext.java | 6 +
.../ignite/internal/GridKernalContextImpl.java | 14 +-
.../ignite/internal/IgniteComponentType.java | 8 +
.../apache/ignite/internal/IgniteKernal.java | 1 +
.../IgniteCacheObjectProcessorImpl.java | 10 +
.../json/IgniteJsonNoopProcessor.java | 67 +++
.../processors/json/IgniteJsonProcessor.java | 71 +++
.../processors/query/GridQueryProcessor.java | 235 ++++++++-
.../org/apache/ignite/JsonArrayBuilderImpl.java | 130 -----
.../java/org/apache/ignite/JsonArrayImpl.java | 131 -----
.../org/apache/ignite/JsonGeneratorImpl.java | 500 -------------------
.../org/apache/ignite/JsonLocationImpl.java | 60 ---
.../java/org/apache/ignite/JsonNumberImpl.java | 116 -----
.../apache/ignite/JsonObjectBuilderImpl.java | 141 ------
.../java/org/apache/ignite/JsonObjectImpl.java | 116 -----
.../org/apache/ignite/JsonProviderImpl.java | 104 ----
.../java/org/apache/ignite/JsonStringImpl.java | 71 ---
.../processors/json/IgniteJsonArray.java | 132 +++++
.../processors/json/IgniteJsonArrayBuilder.java | 130 +++++
.../processors/json/IgniteJsonGenerator.java | 500 +++++++++++++++++++
.../processors/json/IgniteJsonLocation.java | 60 +++
.../json/IgniteJsonMessageFactory.java | 36 ++
.../processors/json/IgniteJsonNumber.java | 116 +++++
.../processors/json/IgniteJsonObject.java | 117 +++++
.../json/IgniteJsonObjectBuilder.java | 141 ++++++
.../json/IgniteJsonProcessorImpl.java | 115 +++++
.../processors/json/IgniteJsonProvider.java | 104 ++++
.../processors/json/IgniteJsonString.java | 77 +++
.../processors/json/JsonCacheObject.java | 103 ++++
.../java/org/apache/ignite/json/IgniteJson.java | 36 ++
.../processors/json/IgniteJsonCacheTest.java | 194 +++++++
31 files changed, 2249 insertions(+), 1393 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e6ba441d/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java
index addc808..bf0ba65 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java
@@ -19,6 +19,7 @@ package org.apache.ignite.internal;
import org.apache.ignite.*;
import org.apache.ignite.configuration.*;
+import org.apache.ignite.internal.processors.json.*;
import org.apache.ignite.internal.managers.checkpoint.*;
import org.apache.ignite.internal.managers.collision.*;
import org.apache.ignite.internal.managers.communication.*;
@@ -555,6 +556,11 @@ public interface GridKernalContext extends Iterable<GridComponent> {
public ClusterProcessor cluster();
/**
+ * @return Json processor.
+ */
+ public IgniteJsonProcessor json();
+
+ /**
* Gets marshaller context.
*
* @return Marshaller context.
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e6ba441d/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java
index 5c3da6a..36b263c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java
@@ -20,6 +20,7 @@ package org.apache.ignite.internal;
import org.apache.ignite.*;
import org.apache.ignite.cluster.*;
import org.apache.ignite.configuration.*;
+import org.apache.ignite.internal.processors.json.*;
import org.apache.ignite.internal.managers.checkpoint.*;
import org.apache.ignite.internal.managers.collision.*;
import org.apache.ignite.internal.managers.communication.*;
@@ -248,6 +249,10 @@ public class GridKernalContextImpl implements GridKernalContext, Externalizable
/** */
@GridToStringExclude
+ private IgniteJsonProcessor json;
+
+ /** */
+ @GridToStringExclude
private DataStructuresProcessor dataStructuresProc;
/** */
@@ -491,7 +496,9 @@ public class GridKernalContextImpl implements GridKernalContext, Externalizable
else if (comp instanceof ClusterProcessor)
cluster = (ClusterProcessor)comp;
else if (comp instanceof IgniteScriptingProcessor)
- scriptProc = (IgniteScriptingProcessor) comp;
+ scriptProc = (IgniteScriptingProcessor)comp;
+ else if (comp instanceof IgniteJsonProcessor)
+ json = (IgniteJsonProcessor)comp;
else if (!(comp instanceof DiscoveryNodeValidationProcessor))
assert (comp instanceof GridPluginComponent) : "Unknown manager class: " + comp.getClass();
@@ -919,6 +926,11 @@ public class GridKernalContextImpl implements GridKernalContext, Externalizable
}
/** {@inheritDoc} */
+ @Override public IgniteJsonProcessor json() {
+ return json;
+ }
+
+ /** {@inheritDoc} */
@Override public MarshallerContextImpl marshallerContext() {
return marshCtx;
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e6ba441d/modules/core/src/main/java/org/apache/ignite/internal/IgniteComponentType.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteComponentType.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteComponentType.java
index 4b937b1..1e91c88 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteComponentType.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteComponentType.java
@@ -83,6 +83,14 @@ public enum IgniteComponentType {
"org.apache.ignite.internal.processors.schedule.IgniteNoopScheduleProcessor",
"org.apache.ignite.internal.processors.schedule.IgniteScheduleProcessor",
"ignite-schedule"
+ ),
+
+ /** JSON API. */
+ JSON(
+ "org.apache.ignite.internal.processors.json.IgniteJsonNoopProcessor",
+ "org.apache.ignite.internal.processors.json.IgniteJsonProcessorImpl",
+ "ignite-json",
+ "org.apache.ignite.internal.processors.json.IgniteJsonMessageFactory"
);
/** No-op class name. */
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e6ba441d/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 081ccf0..3118242 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
@@ -786,6 +786,7 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
IgniteComponentType.HADOOP.createIfInClassPath(ctx, cfg.getHadoopConfiguration() != null)));
startProcessor(new GridServiceProcessor(ctx));
startProcessor(new DataStructuresProcessor(ctx));
+ startProcessor((GridProcessor)IgniteComponentType.JSON.createIfInClassPath(ctx, false));
// Start plugins.
for (PluginProvider provider : ctx.plugins().allProviders()) {
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e6ba441d/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
index 3e59b10..c6ab6f6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
@@ -94,6 +94,11 @@ public class IgniteCacheObjectProcessorImpl extends GridProcessorAdapter impleme
if (obj instanceof KeyCacheObject)
return (KeyCacheObject)obj;
+ KeyCacheObject key = this.ctx.json().toCacheKeyObject(ctx, obj, userObj);
+
+ if (key != null)
+ return key;
+
return toCacheKeyObject0(obj, userObj);
}
@@ -158,6 +163,11 @@ public class IgniteCacheObjectProcessorImpl extends GridProcessorAdapter impleme
if (obj == null || obj instanceof CacheObject)
return (CacheObject)obj;
+ CacheObject cacheObj = this.ctx.json().toCacheKeyObject(ctx, obj, userObj);
+
+ if (cacheObj != null)
+ return cacheObj;
+
return toCacheObject0(obj, userObj);
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e6ba441d/modules/core/src/main/java/org/apache/ignite/internal/processors/json/IgniteJsonNoopProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/json/IgniteJsonNoopProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/json/IgniteJsonNoopProcessor.java
new file mode 100644
index 0000000..ff1762d
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/json/IgniteJsonNoopProcessor.java
@@ -0,0 +1,67 @@
+/*
+ * 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.json;
+
+import org.apache.ignite.internal.*;
+import org.apache.ignite.internal.processors.*;
+import org.apache.ignite.internal.processors.cache.*;
+import org.jetbrains.annotations.*;
+
+/**
+ *
+ */
+public class IgniteJsonNoopProcessor extends GridProcessorAdapter implements IgniteJsonProcessor {
+ /**
+ * @param ctx Context.
+ */
+ public IgniteJsonNoopProcessor(GridKernalContext ctx) {
+ super(ctx);
+ }
+
+ /** {@inheritDoc} */
+ @Override public KeyCacheObject toCacheKeyObject(CacheObjectContext ctx, Object obj, boolean userObj) {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public CacheObject toCacheObject(CacheObjectContext ctx,
+ @Nullable Object obj,
+ boolean userObj) {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean jsonType(Class<?> cls) {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean jsonObject(Object obj) {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean hasField(Object obj, String fieldName) {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Object field(Object obj, String fieldName) {
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e6ba441d/modules/core/src/main/java/org/apache/ignite/internal/processors/json/IgniteJsonProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/json/IgniteJsonProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/json/IgniteJsonProcessor.java
new file mode 100644
index 0000000..92db316
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/json/IgniteJsonProcessor.java
@@ -0,0 +1,71 @@
+/*
+ * 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.json;
+
+import org.apache.ignite.internal.processors.*;
+import org.apache.ignite.internal.processors.cache.*;
+import org.jetbrains.annotations.*;
+
+/**
+ *
+ */
+public interface IgniteJsonProcessor extends GridProcessor {
+ /**
+ * @param ctx Cache context.
+ * @param obj Key value.
+ * @param userObj If {@code true} then given object is object provided by user and should be copied
+ * before stored in cache.
+ * @return Cache key object.
+ */
+ public KeyCacheObject toCacheKeyObject(CacheObjectContext ctx, Object obj, boolean userObj);
+
+ /**
+ * @param ctx Cache context.
+ * @param obj Object.
+ * @param userObj If {@code true} then given object is object provided by user and should be copied
+ * before stored in cache.
+ * @return Cache object.
+ */
+ @Nullable public CacheObject toCacheObject(CacheObjectContext ctx, @Nullable Object obj, boolean userObj);
+
+ /**
+ * @param cls Class.
+ * @return {@code True} if given type is json object type.
+ */
+ public boolean jsonType(Class<?> cls);
+
+ /**
+ * @param obj Object.
+ * @return {@code True} if given object is JSON object.
+ */
+ public boolean jsonObject(Object obj);
+
+ /**
+ * @param obj Object.
+ * @param fieldName Field name.
+ * @return {@code True} if field is set.
+ */
+ public boolean hasField(Object obj, String fieldName);
+
+ /**
+ * @param obj Object.
+ * @param fieldName Field name.
+ * @return Field value.
+ */
+ public Object field(Object obj, String fieldName);
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e6ba441d/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
index f3ad4b2..ea57a12 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
@@ -70,6 +70,9 @@ public class GridQueryProcessor extends GridProcessorAdapter {
/** */
private final GridQueryIndexing idx;
+ /** */
+ private TypeId jsonTypeId;
+
/**
* @param ctx Kernal context.
*/
@@ -145,6 +148,13 @@ public class GridQueryProcessor extends GridProcessorAdapter {
typeId = new TypeId(ccfg.getName(), ctx.cacheObjects().typeId(meta.getValueType()));
}
+ else if (ctx.json().jsonType(desc.keyClass()) || ctx.json().jsonType(desc.valueClass())) {
+ processJsonMeta(meta, desc);
+
+ typeId = new TypeId(ccfg.getName(), valCls);
+
+ jsonTypeId = typeId;
+ }
else {
processClassMeta(meta, desc);
@@ -455,39 +465,48 @@ public class GridQueryProcessor extends GridProcessorAdapter {
if (coctx == null)
coctx = cacheObjectContext(space);
- Class<?> valCls = null;
+ TypeDescriptor desc;
- TypeId id;
+ if (ctx.json().jsonObject(val)) {
+ desc = types.get(jsonTypeId);
- boolean portableVal = ctx.cacheObjects().isPortableObject(val);
-
- if (portableVal) {
- int typeId = ctx.cacheObjects().typeId(val);
-
- id = new TypeId(space, typeId);
+ assert desc != null && desc.registered() : desc;
}
else {
- valCls = val.value(coctx, false).getClass();
+ Class<?> valCls = null;
- id = new TypeId(space, valCls);
- }
+ TypeId id;
- TypeDescriptor desc = types.get(id);
+ boolean portableVal = ctx.cacheObjects().isPortableObject(val);
- if (desc == null || !desc.registered())
- return;
+ if (portableVal) {
+ int typeId = ctx.cacheObjects().typeId(val);
+
+ id = new TypeId(space, typeId);
+ }
+ else {
+ valCls = val.value(coctx, false).getClass();
+
+ id = new TypeId(space, valCls);
+ }
- if (!portableVal && !desc.valueClass().isAssignableFrom(valCls))
- throw new IgniteCheckedException("Failed to update index due to class name conflict" +
- "(multiple classes with same simple name are stored in the same cache) " +
- "[expCls=" + desc.valueClass().getName() + ", actualCls=" + valCls.getName() + ']');
+ desc = types.get(id);
- if (!ctx.cacheObjects().isPortableObject(key)) {
- Class<?> keyCls = key.value(coctx, false).getClass();
+ if (desc == null || !desc.registered())
+ return;
- if (!desc.keyClass().isAssignableFrom(keyCls))
- throw new IgniteCheckedException("Failed to update index, incorrect key class [expCls=" +
- desc.keyClass().getName() + ", actualCls=" + keyCls.getName() + "]");
+ if (!portableVal && !desc.valueClass().isAssignableFrom(valCls))
+ throw new IgniteCheckedException("Failed to update index due to class name conflict" +
+ "(multiple classes with same simple name are stored in the same cache) " +
+ "[expCls=" + desc.valueClass().getName() + ", actualCls=" + valCls.getName() + ']');
+
+ if (!ctx.cacheObjects().isPortableObject(key)) {
+ Class<?> keyCls = key.value(coctx, false).getClass();
+
+ if (!desc.keyClass().isAssignableFrom(keyCls))
+ throw new IgniteCheckedException("Failed to update index, incorrect key class [expCls=" +
+ desc.keyClass().getName() + ", actualCls=" + keyCls.getName() + "]");
+ }
}
idx.store(space, desc, key, val, ver, expirationTime);
@@ -1236,6 +1255,98 @@ public class GridQueryProcessor extends GridProcessorAdapter {
}
/**
+ * Processes declarative metadata for json object.
+ *
+ * @param meta Declared metadata.
+ * @param d Type descriptor.
+ * @throws IgniteCheckedException If failed.
+ */
+ private void processJsonMeta(CacheTypeMetadata meta, TypeDescriptor d)
+ throws IgniteCheckedException {
+ for (Map.Entry<String, Class<?>> entry : meta.getAscendingFields().entrySet()) {
+ JsonProperty prop = buildJsonProperty(entry.getKey(), entry.getValue());
+
+ d.addProperty(prop, false);
+
+ String idxName = prop.name() + "_idx";
+
+ d.addIndex(idxName, idx.isGeometryClass(prop.type()) ? GEO_SPATIAL : SORTED);
+
+ d.addFieldToIndex(idxName, prop.name(), 0, false);
+ }
+
+ for (Map.Entry<String, Class<?>> entry : meta.getDescendingFields().entrySet()) {
+ JsonProperty prop = buildJsonProperty(entry.getKey(), entry.getValue());
+
+ d.addProperty(prop, false);
+
+ String idxName = prop.name() + "_idx";
+
+ d.addIndex(idxName, idx.isGeometryClass(prop.type()) ? GEO_SPATIAL : SORTED);
+
+ d.addFieldToIndex(idxName, prop.name(), 0, true);
+ }
+
+ for (String txtIdx : meta.getTextFields()) {
+ JsonProperty prop = buildJsonProperty(txtIdx, String.class);
+
+ d.addProperty(prop, false);
+
+ d.addFieldToTextIndex(prop.name());
+ }
+
+ Map<String, LinkedHashMap<String, IgniteBiTuple<Class<?>, Boolean>>> grps = meta.getGroups();
+
+ if (grps != null) {
+ for (Map.Entry<String, LinkedHashMap<String, IgniteBiTuple<Class<?>, Boolean>>> entry : grps.entrySet()) {
+ String idxName = entry.getKey();
+
+ LinkedHashMap<String, IgniteBiTuple<Class<?>, Boolean>> idxFields = entry.getValue();
+
+ int order = 0;
+
+ for (Map.Entry<String, IgniteBiTuple<Class<?>, Boolean>> idxField : idxFields.entrySet()) {
+ JsonProperty prop = buildJsonProperty(idxField.getKey(), idxField.getValue().get1());
+
+ d.addProperty(prop, false);
+
+ Boolean descending = idxField.getValue().get2();
+
+ d.addFieldToIndex(idxName, prop.name(), order, descending != null && descending);
+
+ order++;
+ }
+ }
+ }
+
+ for (Map.Entry<String, Class<?>> entry : meta.getQueryFields().entrySet()) {
+ JsonProperty prop = buildJsonProperty(entry.getKey(), entry.getValue());
+
+ if (!d.props.containsKey(prop.name()))
+ d.addProperty(prop, false);
+ }
+ }
+
+ /**
+ * Builds portable object property.
+ *
+ * @param pathStr String representing path to the property. May contains dots '.' to identify
+ * nested fields.
+ * @param resType Result type.
+ * @return Portable property.
+ */
+ private JsonProperty buildJsonProperty(String pathStr, Class<?> resType) {
+ String[] path = pathStr.split("\\.");
+
+ JsonProperty res = null;
+
+ for (String prop : path)
+ res = new JsonProperty(prop, res, resType);
+
+ return res;
+ }
+
+ /**
* Processes declarative metadata for portable object.
*
* @param meta Declared metadata.
@@ -1626,6 +1737,84 @@ public class GridQueryProcessor extends GridProcessorAdapter {
/**
*
*/
+ private class JsonProperty extends Property {
+ /** Property name. */
+ private String propName;
+
+ /** Parent property. */
+ private JsonProperty parent;
+
+ /** Result class. */
+ private Class<?> type;
+
+ /** */
+ private volatile int isKeyProp;
+
+ /**
+ * Constructor.
+ *
+ * @param propName Property name.
+ * @param parent Parent property.
+ * @param type Result type.
+ */
+ private JsonProperty(String propName, JsonProperty parent, Class<?> type) {
+ this.propName = propName;
+ this.parent = parent;
+ this.type = type;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Object value(Object key, Object val) throws IgniteCheckedException {
+ Object obj;
+
+ if (parent != null) {
+ obj = parent.value(key, val);
+
+ if (obj == null)
+ return null;
+
+ if (!ctx.json().jsonObject(obj))
+ throw new IgniteCheckedException("Non-json object received as a result of property extraction " +
+ "[parent=" + parent + ", propName=" + propName + ", obj=" + obj + ']');
+ }
+ else {
+ int isKeyProp0 = isKeyProp;
+
+ if (isKeyProp0 == 0) {
+ // Key is allowed to be a non-portable object here.
+ // We check key before value consistently with ClassProperty.
+ if (ctx.json().jsonObject(key) && ctx.json().hasField(key, propName))
+ isKeyProp = isKeyProp0 = 1;
+ else if (ctx.json().hasField(val, propName))
+ isKeyProp = isKeyProp0 = -1;
+ else {
+ U.warn(log, "Neither key nor value have property " +
+ "[propName=" + propName + ", key=" + key + ", val=" + val + "]");
+
+ return null;
+ }
+ }
+
+ obj = isKeyProp0 == 1 ? key : val;
+ }
+
+ return ctx.json().field(obj, propName);
+ }
+
+ /** {@inheritDoc} */
+ @Override public String name() {
+ return propName;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Class<?> type() {
+ return type;
+ }
+ }
+
+ /**
+ *
+ */
private class PortableProperty extends Property {
/** Property name. */
private String propName;
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e6ba441d/modules/json/src/main/java/org/apache/ignite/JsonArrayBuilderImpl.java
----------------------------------------------------------------------
diff --git a/modules/json/src/main/java/org/apache/ignite/JsonArrayBuilderImpl.java b/modules/json/src/main/java/org/apache/ignite/JsonArrayBuilderImpl.java
deleted file mode 100644
index 97b3e9a..0000000
--- a/modules/json/src/main/java/org/apache/ignite/JsonArrayBuilderImpl.java
+++ /dev/null
@@ -1,130 +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;
-
-import org.apache.ignite.internal.util.typedef.internal.*;
-
-import javax.json.*;
-import java.math.*;
-import java.util.*;
-
-/**
- * Json array builder.
- */
-public class JsonArrayBuilderImpl implements JsonArrayBuilder {
- /** Json array list. */
- private List<JsonValue> jsonList = new ArrayList<>();
-
- /** {@inheritDoc} */
- @Override public JsonArrayBuilder add(JsonValue val) {
- A.notNull(val, "value");
-
- jsonList.add(val);
-
- return this;
- }
-
- /** {@inheritDoc} */
- @Override public JsonArrayBuilder add(String val) {
- A.notNull(val, "value");
-
- jsonList.add(new JsonStringImpl(val));
-
- return this;
- }
-
- /** {@inheritDoc} */
- @Override public JsonArrayBuilder add(BigDecimal val) {
- A.notNull(val, "value");
-
- jsonList.add(new JsonNumberImpl(val));
-
- return this;
- }
-
- /** {@inheritDoc} */
- @Override public JsonArrayBuilder add(BigInteger val) {
- A.notNull(val, "value");
-
- //TODO: optimize for value
- jsonList.add(new JsonNumberImpl(new BigDecimal(val)));
-
- return this;
- }
-
- /** {@inheritDoc} */
- @Override public JsonArrayBuilder add(int val) {
- //TODO: optimize for value
- jsonList.add(new JsonNumberImpl(new BigDecimal(val)));
-
- return this;
- }
-
- /** {@inheritDoc} */
- @Override public JsonArrayBuilder add(long val) {
- //TODO: optimize for value
- jsonList.add(new JsonNumberImpl(new BigDecimal(val)));
-
- return this;
- }
-
- /** {@inheritDoc} */
- @Override public JsonArrayBuilder add(double val) {
- //TODO: optimize for value
- jsonList.add(new JsonNumberImpl(new BigDecimal(val)));
-
- return this;
- }
-
- /** {@inheritDoc} */
- @Override public JsonArrayBuilder add(boolean val) {
- jsonList.add(val ? JsonValue.TRUE : JsonValue.FALSE);
-
- return this;
- }
-
- /** {@inheritDoc} */
- @Override public JsonArrayBuilder addNull() {
- jsonList.add(JsonValue.NULL);
-
- return this;
- }
-
- /** {@inheritDoc} */
- @Override public JsonArrayBuilder add(JsonObjectBuilder bld) {
- A.notNull(bld, "value");
-
- jsonList.add(bld.build());
-
- return this;
- }
-
- /** {@inheritDoc} */
- @Override public JsonArrayBuilder add(JsonArrayBuilder bld) {
- A.notNull(bld, "value");
-
- jsonList.add(bld.build());
-
- return this;
- }
-
- /** {@inheritDoc} */
- @Override public JsonArray build() {
- return new JsonArrayImpl(jsonList);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e6ba441d/modules/json/src/main/java/org/apache/ignite/JsonArrayImpl.java
----------------------------------------------------------------------
diff --git a/modules/json/src/main/java/org/apache/ignite/JsonArrayImpl.java b/modules/json/src/main/java/org/apache/ignite/JsonArrayImpl.java
deleted file mode 100644
index 9005c22..0000000
--- a/modules/json/src/main/java/org/apache/ignite/JsonArrayImpl.java
+++ /dev/null
@@ -1,131 +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;
-
-import javax.json.*;
-import java.util.*;
-
-/**
- * Implementation of JsonArray
- */
-public class JsonArrayImpl extends ArrayList<JsonValue> implements JsonArray {
- /** Values for getValueAs. */
- private List<JsonValue> val;
-
- /**
- * @param val List json values.
- */
- public JsonArrayImpl(List<JsonValue> val) {
- super(val);
- }
-
- /** {@inheritDoc} */
- @Override public JsonObject getJsonObject(int idx) {
- return (JsonObject)get(idx);
- }
-
- /** {@inheritDoc} */
- @Override public JsonArray getJsonArray(int idx) {
- return (JsonArray)get(idx);
- }
-
- /** {@inheritDoc} */
- @Override public JsonNumber getJsonNumber(int idx) {
- return (JsonNumber)get(idx);
- }
-
- /** {@inheritDoc} */
- @Override public JsonString getJsonString(int idx) {
- return (JsonString)get(idx);
- }
-
- /** {@inheritDoc} */
- @SuppressWarnings("unchecked")
- @Override public <T extends JsonValue> List<T> getValuesAs(Class<T> clazz) {
- if (val == null) {
- val = new ArrayList(this.size());
-
- for (int i = 0; i < size(); ++i)
- val.add(get(i));
-
- val = Collections.unmodifiableList(val);
- }
- return (List<T>) val;
- }
-
- /** {@inheritDoc} */
- @Override public String getString(int idx) {
- return getJsonString(idx).getString();
- }
-
- /** {@inheritDoc} */
- @Override public String getString(int idx, String dfltVal) {
- try {
- return getString(idx);
- }
- catch (Exception e) {
- return dfltVal;
- }
- }
-
- /** {@inheritDoc} */
- @Override public int getInt(int idx) {
- return getJsonNumber(idx).intValue();
- }
-
- /** {@inheritDoc} */
- @Override public int getInt(int idx, int dfltVal) {
- try {
- return getInt(idx);
- } catch (Exception e) {
- return dfltVal;
- }
- }
-
- /** {@inheritDoc} */
- @Override public boolean getBoolean(int idx) {
- JsonValue val = get(idx);
-
- if (val.equals(JsonValue.TRUE))
- return true;
-
- if (val.equals(JsonValue.FALSE))
- return false;
-
- throw new ClassCastException();
- }
-
- /** {@inheritDoc} */
- @Override public boolean getBoolean(int idx, boolean dfltVal) {
- try {
- return getBoolean(idx);
- } catch (Exception e) {
- return dfltVal;
- }
- }
-
- /** {@inheritDoc} */
- @Override public boolean isNull(int idx) {
- return get(idx).equals(JsonValue.NULL);
- }
-
- /** {@inheritDoc} */
- @Override public ValueType getValueType() {
- return ValueType.ARRAY;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e6ba441d/modules/json/src/main/java/org/apache/ignite/JsonGeneratorImpl.java
----------------------------------------------------------------------
diff --git a/modules/json/src/main/java/org/apache/ignite/JsonGeneratorImpl.java b/modules/json/src/main/java/org/apache/ignite/JsonGeneratorImpl.java
deleted file mode 100644
index 95b336f..0000000
--- a/modules/json/src/main/java/org/apache/ignite/JsonGeneratorImpl.java
+++ /dev/null
@@ -1,500 +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;
-
-import javax.json.*;
-import javax.json.stream.*;
-import java.io.*;
-import java.math.*;
-import java.util.*;
-
-/**
- * Json generator implementation.
- */
-public class JsonGeneratorImpl implements JsonGenerator {
- /** Writer. */
- private final BufferedWriter writer;
-
- private LinkedList<Element> ctx = new LinkedList();
-
- /**
- * @param writer Writer.
- */
- public JsonGeneratorImpl(Writer writer) {
- this.writer = new BufferedWriter(writer);
-
- ctx.push(new Element(Context.NONE, true));
- }
-
- /** {@inheritDoc} */
- @Override public JsonGenerator writeStartObject() {
- try {
- if (ctx.getLast().context() == Context.OBJECT ||
- (ctx.getLast().context() == Context.NONE && !ctx.getLast().isFirst()))
- throw new JsonGenerationException("No name for object field.");
-
- writeComma();
- writer.write('{');
-
- ctx.addLast(new Element(Context.OBJECT, true));
-
- return this;
- }
- catch (IOException e) {
- throw new JsonException("Writer fails.", e);
- }
- }
-
- /** {@inheritDoc} */
- @Override public JsonGenerator writeStartObject(String name) {
- try {
- if (ctx.getLast().context() != Context.OBJECT)
- throw new JsonGenerationException("Object with name in not object scope.");
-
- writeComma();
- writeString(name);
- writer.write(":");
- writer.write('{');
-
- ctx.addLast(new Element(Context.OBJECT, true));
-
- return this;
- }
- catch (IOException e) {
- throw new JsonException("Writer fails.", e);
- }
- }
-
- /** {@inheritDoc} */
- @Override public JsonGenerator writeStartArray() {
- try {
- if (ctx.getLast().context() == Context.OBJECT ||
- (ctx.getLast().context() == Context.NONE && !ctx.getLast().isFirst()))
- throw new JsonGenerationException("Array in object scope.");
-
- writeComma();
- writer.write("[");
-
- ctx.addLast(new Element(Context.ARRAY, true));
-
- return this;
- }
- catch (IOException e) {
- throw new JsonException("Writer fails.", e);
- }
- }
-
- /** {@inheritDoc} */
- @Override public JsonGenerator writeStartArray(String name) {
- try {
- if (ctx.getLast().context() != Context.OBJECT)
- throw new JsonGenerationException("Array with name in not object scope.");
-
- writeComma();
- writeString(name);
- writer.write(":");
- writer.write('[');
-
- ctx.addLast(new Element(Context.ARRAY, true));
-
- return this;
- }
- catch (IOException e) {
- throw new JsonException("Writer fails.", e);
- }
- }
-
- /** {@inheritDoc} */
- @Override public JsonGenerator write(String name, JsonValue val) {
- if (ctx.getLast().context() != Context.OBJECT)
- throw new JsonGenerationException("Json value with name in not object scope.");
-
- try {
- switch (val.getValueType()) {
- case ARRAY: {
- JsonArray arr = (JsonArray) val;
-
- writeStartArray(name);
-
- for (JsonValue el : arr)
- write(el);
-
- writeEnd();
-
- break;
- }
-
- case OBJECT: {
- JsonObject o = (JsonObject) val;
-
- writeStartObject(name);
-
- for (Map.Entry<String, JsonValue> member : o.entrySet())
- write(member.getKey(), member.getValue());
-
- writeEnd();
-
- break;
- }
-
- case STRING: {
- JsonString str = (JsonString) val;
-
- write(name, str.getString());
-
- break;
- }
-
- case NUMBER: {
- JsonNumber n = (JsonNumber) val;
-
- writeComma();
- writeString(name);
- writer.write(":");
- writeString(n.toString());
-
- break;
- }
- case TRUE: {
- write(name, true);
-
- break;
- }
-
- case FALSE: {
- write(name, false);
-
- break;
- }
-
- case NULL: {
- writeNull(name);
-
- break;
- }
- }
- return this;
- }
- catch (IOException e) {
- throw new JsonException("Writer fails.", e);
- }
- }
-
- /** {@inheritDoc} */
- @Override public JsonGenerator write(String name, String val) {
- return writeSimpleField(name, val);
- }
-
- /** {@inheritDoc} */
- @Override public JsonGenerator write(String name, BigInteger val) {
- return writeSimpleField(name, String.valueOf(val));
- }
-
- /** {@inheritDoc} */
- @Override public JsonGenerator write(String name, BigDecimal val) {
- return writeSimpleField(name, String.valueOf(val));
- }
-
- /** {@inheritDoc} */
- @Override public JsonGenerator write(String name, int val) {
- return writeSimpleField(name, String.valueOf(val));
- }
-
- /** {@inheritDoc} */
- @Override public JsonGenerator write(String name, long val) {
- return writeSimpleField(name, String.valueOf(val));
- }
-
- /** {@inheritDoc} */
- @Override public JsonGenerator write(String name, double val) {
- return writeSimpleField(name, String.valueOf(val));
- }
-
- /** {@inheritDoc} */
- @Override public JsonGenerator write(String name, boolean val) {
- return writeSimpleField(name, String.valueOf(val));
- }
-
- /** {@inheritDoc} */
- @Override public JsonGenerator writeNull(String name) {
- return writeSimpleField(name, "null");
- }
-
- /** {@inheritDoc} */
- @Override public JsonGenerator writeEnd() {
- if (ctx.getLast().context() == Context.NONE)
- throw new JsonGenerationException("Cannot call writeEnd in none context.");
-
- try {
- if (ctx.getLast().context() == Context.ARRAY)
- writer.write("]");
-
- if (ctx.getLast().context() == Context.OBJECT)
- writer.write("}");
-
- ctx.removeLast();
-
- return this;
- }
- catch(IOException e) {
- throw new JsonException("Writer fails.", e);
- }
- }
-
- /** {@inheritDoc} */
- @Override public JsonGenerator write(JsonValue val) {
- if (ctx.getLast().context() != Context.ARRAY)
- throw new JsonGenerationException("Json value without name in not array scope.");
-
- try {
- switch (val.getValueType()) {
- case ARRAY: {
- JsonArray arr = (JsonArray) val;
-
- writeStartArray();
-
- for (JsonValue el : arr)
- write(el);
-
- writeEnd();
-
- break;
- }
-
- case OBJECT: {
- JsonObject o = (JsonObject) val;
-
- writeStartObject();
-
- for (Map.Entry<String, JsonValue> member : o.entrySet())
- write(member.getKey(), member.getValue());
-
- writeEnd();
-
- break;
- }
-
- case STRING: {
- JsonString str = (JsonString) val;
-
- write(str.getString());
-
- break;
- }
-
- case NUMBER: {
- JsonNumber n = (JsonNumber) val;
-
- writeComma();
- writeString(n.toString());
-
- break;
- }
- case TRUE: {
- write(true);
-
- break;
- }
-
- case FALSE: {
- write(false);
-
- break;
- }
-
- case NULL: {
- writeNull();
-
- break;
- }
- }
- return this;
- }
- catch (IOException e) {
- throw new JsonException("Writer fails.", e);
- }
- }
-
- /** {@inheritDoc} */
- @Override public JsonGenerator write(String val) {
- return writeSimpleArrayElement(val);
- }
-
- /** {@inheritDoc} */
- @Override public JsonGenerator write(BigDecimal val) {
- return writeSimpleArrayElement(String.valueOf(val));
- }
-
- /** {@inheritDoc} */
- @Override public JsonGenerator write(BigInteger val) {
- return writeSimpleArrayElement(String.valueOf(val));
- }
-
- /** {@inheritDoc} */
- @Override public JsonGenerator write(int val) {
- return writeSimpleArrayElement(String.valueOf(val));
- }
-
- /** {@inheritDoc} */
- @Override public JsonGenerator write(long val) {
- return writeSimpleArrayElement(String.valueOf(val));
- }
-
- /** {@inheritDoc} */
- @Override public JsonGenerator write(double val) {
- return writeSimpleArrayElement(String.valueOf(val));
- }
-
- /** {@inheritDoc} */
- @Override public JsonGenerator write(boolean val) {
- return writeSimpleArrayElement(String.valueOf(val));
- }
-
- /** {@inheritDoc} */
- @Override public JsonGenerator writeNull() {
- return writeSimpleArrayElement("null");
- }
-
- /** {@inheritDoc} */
- @Override public void close() {
- try {
- writer.close();
- }
- catch (IOException e) {
- throw new JsonException("Could not close writer.", e);
- }
- }
-
- /** {@inheritDoc} */
- @Override public void flush() {
- try {
- writer.flush();
- }
- catch (IOException e) {
- throw new JsonException("Could not flush buffer to writer.", e);
- }
- }
-
- /**
- * Write comma if object is not first.
- *
- * @throws IOException If failed.
- */
- private void writeComma() throws IOException{
- if (!ctx.getLast().isFirst())
- writer.write(",");
-
- ctx.getLast().isFirst = false;
- }
-
- /**
- * @param name Field name.
- * @param val Field value.
- */
- private JsonGenerator writeSimpleField(String name, String val) {
- if (ctx.getLast().context() != Context.OBJECT)
- throw new JsonGenerationException("String with name in not object scope.");
-
- try {
- writeComma();
- writeString(name);
- writer.write(":");
- writeString(val);
-
- return this;
- }
- catch (IOException e) {
- throw new JsonException("Writer fails.", e);
- }
- }
-
-
- /**
- * @param val Field value.
- */
- private JsonGenerator writeSimpleArrayElement(String val) {
- if (ctx.getLast().context() != Context.ARRAY)
- throw new JsonGenerationException("String without name in not array scope.");
-
- try {
- writeComma();
- writeString(val);
-
- return this;
- }
- catch (IOException e) {
- throw new JsonException("Writer fails.", e);
- }
- }
-
- /**
- * @param str String to write.
- * @throws IOException If failed.
- * //TODO: escape string.
- */
- private void writeString(String str) throws IOException {
- writer.write(str);
- }
-
- /**
- * Generator element.
- */
- private static class Element {
- /** Context. */
- private Context ctx;
-
- /** First element flag. */
- private boolean isFirst;
-
- /**
- * @param ctx Context.
- * @param isFirst First element flag.
- */
- public Element(Context ctx, boolean isFirst) {
- this.ctx = ctx;
- this.isFirst = isFirst;
- }
-
- /**
- * @return First element flag.
- */
- public boolean isFirst() {
- return isFirst;
- }
-
- /**
- * @return Context.
- */
- public Context context() {
- return ctx;
- }
- }
- /**
- * Context for writer.
- */
- private enum Context {
- /** Writing object. */
- OBJECT,
-
- /** Writing array. */
- ARRAY,
-
- /** Not in object or in array. */
- NONE
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e6ba441d/modules/json/src/main/java/org/apache/ignite/JsonLocationImpl.java
----------------------------------------------------------------------
diff --git a/modules/json/src/main/java/org/apache/ignite/JsonLocationImpl.java b/modules/json/src/main/java/org/apache/ignite/JsonLocationImpl.java
deleted file mode 100644
index 078c16f..0000000
--- a/modules/json/src/main/java/org/apache/ignite/JsonLocationImpl.java
+++ /dev/null
@@ -1,60 +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;
-
-import javax.json.stream.*;
-
-/**
- * Json location implementation.
- */
-public class JsonLocationImpl implements JsonLocation {
- /** Column number. */
- private final long col;
-
- /** Line number. */
- private final long line;
-
- /** Stream offset. */
- private final long off;
-
- /**
- * @param line Line number.
- * @param col Column number.
- * @param streamOff Stream offset.
- */
- JsonLocationImpl(long line, long col, long streamOff) {
- this.line = line;
- this.col = col;
- this.off = streamOff;
- }
-
- /** {@inheritDoc} */
- @Override public long getLineNumber() {
- return line;
- }
-
- /** {@inheritDoc} */
- @Override public long getColumnNumber() {
- return col;
- }
-
- /** {@inheritDoc} */
- @Override public long getStreamOffset() {
- return off;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e6ba441d/modules/json/src/main/java/org/apache/ignite/JsonNumberImpl.java
----------------------------------------------------------------------
diff --git a/modules/json/src/main/java/org/apache/ignite/JsonNumberImpl.java b/modules/json/src/main/java/org/apache/ignite/JsonNumberImpl.java
deleted file mode 100644
index 7cd0a68..0000000
--- a/modules/json/src/main/java/org/apache/ignite/JsonNumberImpl.java
+++ /dev/null
@@ -1,116 +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;
-
-import javax.json.*;
-import java.math.*;
-
-/**
- * Json number implementation.
- * //TODO: optimize for int, long, double...
- */
-public class JsonNumberImpl implements JsonNumber {
- /** Value. */
- private final BigDecimal val;
-
- /**
- * @param val Value.
- */
- public JsonNumberImpl(BigDecimal val){
- this.val = val;
- }
-
- /** {@inheritDoc} */
- @Override public boolean isIntegral() {
- if (val == null)
- return false;
-
- return val.scale() == 0;
- }
-
- /** {@inheritDoc} */
- @Override public int intValue() {
- return val.intValue();
- }
-
- /** {@inheritDoc} */
- @Override public int intValueExact() {
- return val.intValueExact();
- }
-
- /** {@inheritDoc} */
- @Override public long longValue() {
- return val.longValue();
- }
-
- /** {@inheritDoc} */
- @Override public long longValueExact() {
- return val.longValueExact();
- }
-
- /** {@inheritDoc} */
- @Override public BigInteger bigIntegerValue() {
- return val.toBigInteger();
- }
-
- /** {@inheritDoc} */
- @Override public BigInteger bigIntegerValueExact() {
- return val.toBigIntegerExact();
- }
-
- /** {@inheritDoc} */
- @Override public double doubleValue() {
- return val.doubleValue();
- }
-
- /** {@inheritDoc} */
- @Override public BigDecimal bigDecimalValue() {
- return val;
- }
-
- /** {@inheritDoc} */
- @Override public ValueType getValueType() {
- return ValueType.NUMBER;
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return val.toString();
- }
-
- /** {@inheritDoc} */
- @Override public int hashCode() {
- if (val == null)
- return 0;
-
- return val.hashCode();
- }
-
- /** {@inheritDoc} */
- @Override public boolean equals(Object obj) {
- if (obj == null || !(obj instanceof JsonNumberImpl))
- return false;
-
- BigDecimal val0 = ((JsonNumberImpl)obj).val;
-
- if (val == null)
- return val0 == null;
-
- return val.equals(val0);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e6ba441d/modules/json/src/main/java/org/apache/ignite/JsonObjectBuilderImpl.java
----------------------------------------------------------------------
diff --git a/modules/json/src/main/java/org/apache/ignite/JsonObjectBuilderImpl.java b/modules/json/src/main/java/org/apache/ignite/JsonObjectBuilderImpl.java
deleted file mode 100644
index 6246794..0000000
--- a/modules/json/src/main/java/org/apache/ignite/JsonObjectBuilderImpl.java
+++ /dev/null
@@ -1,141 +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;
-
-import org.apache.ignite.internal.util.typedef.internal.*;
-
-import javax.json.*;
-import java.math.*;
-import java.util.*;
-
-/**
- * Json object builder implementation.
- */
-public class JsonObjectBuilderImpl implements JsonObjectBuilder {
- /** Json object map. */
- private Map<String, JsonValue> jsonMap = new HashMap<>();
-
- /** {@inheritDoc} */
- @Override public JsonObjectBuilder add(String name, JsonValue val) {
- A.notNull(name, "key", val, "value");
-
- jsonMap.put(name, val);
-
- return this;
- }
-
- /** {@inheritDoc} */
- @Override public JsonObjectBuilder add(String name, String val) {
- A.notNull(name, "key", val, "value");
-
- jsonMap.put(name, new JsonStringImpl(val));
-
- return this;
- }
-
- /** {@inheritDoc} */
- @Override public JsonObjectBuilder add(String name, BigInteger val) {
- A.notNull(name, "key", val, "value");
-
- //TODO: optimize for value
- jsonMap.put(name, new JsonNumberImpl(new BigDecimal(val)));
-
- return this;
- }
-
- /** {@inheritDoc} */
- @Override public JsonObjectBuilder add(String name, BigDecimal val) {
- A.notNull(name, "key", val, "value");
-
- //TODO: optimize for value
- jsonMap.put(name, new JsonNumberImpl(val));
-
- return this;
- }
-
- /** {@inheritDoc} */
- @Override public JsonObjectBuilder add(String name, int val) {
- A.notNull(name, "key");
-
- //TODO: optimize for value
- jsonMap.put(name, new JsonNumberImpl(new BigDecimal(val)));
-
- return this;
- }
-
- /** {@inheritDoc} */
- @Override public JsonObjectBuilder add(String name, long val) {
- A.notNull(name, "key");
-
- //TODO: optimize for value
- jsonMap.put(name, new JsonNumberImpl(new BigDecimal(val)));
-
- return this;
- }
-
- /** {@inheritDoc} */
- @Override public JsonObjectBuilder add(String name, double val) {
- A.notNull(name, "key");
-
- //TODO: optimize for value
- jsonMap.put(name, new JsonNumberImpl(new BigDecimal(val)));
-
- return this;
- }
-
- /** {@inheritDoc} */
- @Override public JsonObjectBuilder add(String name, boolean val) {
- A.notNull(name, "key");
-
- jsonMap.put(name, val ? JsonValue.TRUE : JsonValue.FALSE);
-
- return this;
- }
-
- /** {@inheritDoc} */
- @Override public JsonObjectBuilder addNull(String name) {
- A.notNull(name, "key");
-
- jsonMap.put(name, JsonValue.NULL);
-
- return this;
- }
-
- /** {@inheritDoc} */
- @Override public JsonObjectBuilder add(String name, JsonObjectBuilder bld) {
- A.notNull(name, "key", bld, "value");
-
- jsonMap.put(name, bld.build());
-
- return this;
- }
-
- /** {@inheritDoc} */
- @Override public JsonObjectBuilder add(String name, JsonArrayBuilder bld) {
- A.notNull(name, "key", bld, "value");
-
- jsonMap.put(name, bld.build());
-
- return this;
- }
-
- /** {@inheritDoc} */
- @Override public JsonObject build() {
- return new JsonObjectImpl(jsonMap);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e6ba441d/modules/json/src/main/java/org/apache/ignite/JsonObjectImpl.java
----------------------------------------------------------------------
diff --git a/modules/json/src/main/java/org/apache/ignite/JsonObjectImpl.java b/modules/json/src/main/java/org/apache/ignite/JsonObjectImpl.java
deleted file mode 100644
index 8cb7637..0000000
--- a/modules/json/src/main/java/org/apache/ignite/JsonObjectImpl.java
+++ /dev/null
@@ -1,116 +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;
-
-import javax.json.*;
-import java.util.*;
-
-/**
- * JsonObject implementation.
- */
-public class JsonObjectImpl extends HashMap<String, JsonValue> implements JsonObject {
- /**
- * @param val Map to store.
- */
- public JsonObjectImpl(Map<String, JsonValue> val) {
- super(val);
- }
-
- /** {@inheritDoc} */
- @Override public JsonArray getJsonArray(String name) {
- return (JsonArray)get(name);
- }
-
- /** {@inheritDoc} */
- @Override public JsonObject getJsonObject(String name) {
- return (JsonObject)get(name);
- }
-
- /** {@inheritDoc} */
- @Override public JsonNumber getJsonNumber(String name) {
- return (JsonNumber)get(name);
- }
-
- /** {@inheritDoc} */
- @Override public JsonString getJsonString(String name) {
- return (JsonString)get(name);
- }
-
- /** {@inheritDoc} */
- @Override public String getString(String name) {
- return getJsonString(name).getString();
- }
-
- /** {@inheritDoc} */
- @Override public String getString(String name, String dfltVal) {
- try {
- return getString(name);
- }
- catch (Exception e) {
- return dfltVal;
- }
- }
-
- /** {@inheritDoc} */
- @Override public int getInt(String name) {
- return getJsonNumber(name).intValue();
- }
-
- /** {@inheritDoc} */
- @Override public int getInt(String name, int dfltVal) {
- try {
- return getInt(name);
- }
- catch (Exception e) {
- return dfltVal;
- }
- }
-
- /** {@inheritDoc} */
- @Override public boolean getBoolean(String name) {
- JsonValue val = get(name);
-
- if (val.equals(JsonValue.TRUE))
- return true;
-
- if (val.equals(JsonValue.FALSE))
- return false;
-
- throw new ClassCastException();
- }
-
- /** {@inheritDoc} */
- @Override public boolean getBoolean(String name, boolean dfltVal) {
- try {
- return getBoolean(name);
- }
- catch (Exception e) {
- return dfltVal;
- }
- }
-
- /** {@inheritDoc} */
- @Override public boolean isNull(String name) {
- return get(name).equals(JsonValue.NULL);
- }
-
- /** {@inheritDoc} */
- @Override public ValueType getValueType() {
- return ValueType.OBJECT;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e6ba441d/modules/json/src/main/java/org/apache/ignite/JsonProviderImpl.java
----------------------------------------------------------------------
diff --git a/modules/json/src/main/java/org/apache/ignite/JsonProviderImpl.java b/modules/json/src/main/java/org/apache/ignite/JsonProviderImpl.java
deleted file mode 100644
index 9bb6305..0000000
--- a/modules/json/src/main/java/org/apache/ignite/JsonProviderImpl.java
+++ /dev/null
@@ -1,104 +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;
-
-import javax.json.*;
-import javax.json.spi.*;
-import javax.json.stream.*;
-import java.io.*;
-import java.util.*;
-
-/**
- * Json provider implementation.
- */
-public class JsonProviderImpl extends JsonProvider {
- /** {@inheritDoc} */
- @Override public JsonParser createParser(Reader reader) {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public JsonParser createParser(InputStream in) {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public JsonParserFactory createParserFactory(Map<String, ?> config) {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public JsonGenerator createGenerator(Writer writer) {
- return new JsonGeneratorImpl(writer);
- }
-
- /** {@inheritDoc} */
- @Override public JsonGenerator createGenerator(OutputStream out) {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public JsonGeneratorFactory createGeneratorFactory(Map<String, ?> config) {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public JsonReader createReader(Reader reader) {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public JsonReader createReader(InputStream in) {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public JsonWriter createWriter(Writer writer) {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public JsonWriter createWriter(OutputStream out) {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public JsonWriterFactory createWriterFactory(Map<String, ?> config) {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public JsonReaderFactory createReaderFactory(Map<String, ?> config) {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public JsonObjectBuilder createObjectBuilder() {
- return new JsonObjectBuilderImpl();
- }
-
- /** {@inheritDoc} */
- @Override public JsonArrayBuilder createArrayBuilder() {
- return new JsonArrayBuilderImpl();
- }
-
- /** {@inheritDoc} */
- @Override public JsonBuilderFactory createBuilderFactory(Map<String, ?> config) {
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e6ba441d/modules/json/src/main/java/org/apache/ignite/JsonStringImpl.java
----------------------------------------------------------------------
diff --git a/modules/json/src/main/java/org/apache/ignite/JsonStringImpl.java b/modules/json/src/main/java/org/apache/ignite/JsonStringImpl.java
deleted file mode 100644
index 6314826..0000000
--- a/modules/json/src/main/java/org/apache/ignite/JsonStringImpl.java
+++ /dev/null
@@ -1,71 +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;
-
-import javax.json.*;
-
-/**
- * Json string implementation.
- */
-public class JsonStringImpl implements JsonString {
- /** Value. */
- private final String val;
-
- /**
- * @param val Value.
- */
- public JsonStringImpl(String val) {
- this.val = val;
- }
-
- /** {@inheritDoc} */
- @Override public String getString() {
- return val;
- }
-
- /** {@inheritDoc} */
- @Override public CharSequence getChars() {
- return val;
- }
-
- /** {@inheritDoc} */
- @Override public ValueType getValueType() {
- return ValueType.STRING;
- }
-
- /** {@inheritDoc} */
- @Override public int hashCode() {
- if (val == null)
- return 0;
-
- return val.hashCode();
- }
-
- /** {@inheritDoc} */
- @Override public boolean equals(Object obj) {
- if (obj == null || !(obj instanceof JsonString))
- return false;
-
- JsonString other = (JsonString)obj;
-
- if (val == null)
- return other.getString() == null;
-
- return val.equals(other.getString());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e6ba441d/modules/json/src/main/java/org/apache/ignite/internal/processors/json/IgniteJsonArray.java
----------------------------------------------------------------------
diff --git a/modules/json/src/main/java/org/apache/ignite/internal/processors/json/IgniteJsonArray.java b/modules/json/src/main/java/org/apache/ignite/internal/processors/json/IgniteJsonArray.java
new file mode 100644
index 0000000..11267ba
--- /dev/null
+++ b/modules/json/src/main/java/org/apache/ignite/internal/processors/json/IgniteJsonArray.java
@@ -0,0 +1,132 @@
+/*
+ * 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.json;
+
+import javax.json.*;
+import java.io.*;
+import java.util.*;
+
+/**
+ * Implementation of JsonArray
+ */
+public class IgniteJsonArray extends ArrayList<JsonValue> implements JsonArray, Serializable {
+ /** Values for getValueAs. */
+ private List<JsonValue> val;
+
+ /**
+ * @param val List json values.
+ */
+ public IgniteJsonArray(List<JsonValue> val) {
+ super(val);
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteJsonObject getJsonObject(int idx) {
+ return (IgniteJsonObject)get(idx);
+ }
+
+ /** {@inheritDoc} */
+ @Override public JsonArray getJsonArray(int idx) {
+ return (JsonArray)get(idx);
+ }
+
+ /** {@inheritDoc} */
+ @Override public JsonNumber getJsonNumber(int idx) {
+ return (JsonNumber)get(idx);
+ }
+
+ /** {@inheritDoc} */
+ @Override public JsonString getJsonString(int idx) {
+ return (JsonString)get(idx);
+ }
+
+ /** {@inheritDoc} */
+ @SuppressWarnings("unchecked")
+ @Override public <T extends JsonValue> List<T> getValuesAs(Class<T> clazz) {
+ if (val == null) {
+ val = new ArrayList(this.size());
+
+ for (int i = 0; i < size(); ++i)
+ val.add(get(i));
+
+ val = Collections.unmodifiableList(val);
+ }
+ return (List<T>) val;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String getString(int idx) {
+ return getJsonString(idx).getString();
+ }
+
+ /** {@inheritDoc} */
+ @Override public String getString(int idx, String dfltVal) {
+ try {
+ return getString(idx);
+ }
+ catch (Exception e) {
+ return dfltVal;
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public int getInt(int idx) {
+ return getJsonNumber(idx).intValue();
+ }
+
+ /** {@inheritDoc} */
+ @Override public int getInt(int idx, int dfltVal) {
+ try {
+ return getInt(idx);
+ } catch (Exception e) {
+ return dfltVal;
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean getBoolean(int idx) {
+ JsonValue val = get(idx);
+
+ if (val.equals(JsonValue.TRUE))
+ return true;
+
+ if (val.equals(JsonValue.FALSE))
+ return false;
+
+ throw new ClassCastException();
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean getBoolean(int idx, boolean dfltVal) {
+ try {
+ return getBoolean(idx);
+ } catch (Exception e) {
+ return dfltVal;
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isNull(int idx) {
+ return get(idx).equals(JsonValue.NULL);
+ }
+
+ /** {@inheritDoc} */
+ @Override public ValueType getValueType() {
+ return ValueType.ARRAY;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e6ba441d/modules/json/src/main/java/org/apache/ignite/internal/processors/json/IgniteJsonArrayBuilder.java
----------------------------------------------------------------------
diff --git a/modules/json/src/main/java/org/apache/ignite/internal/processors/json/IgniteJsonArrayBuilder.java b/modules/json/src/main/java/org/apache/ignite/internal/processors/json/IgniteJsonArrayBuilder.java
new file mode 100644
index 0000000..b65fa6c
--- /dev/null
+++ b/modules/json/src/main/java/org/apache/ignite/internal/processors/json/IgniteJsonArrayBuilder.java
@@ -0,0 +1,130 @@
+/*
+ * 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.json;
+
+import org.apache.ignite.internal.util.typedef.internal.*;
+
+import javax.json.*;
+import java.math.*;
+import java.util.*;
+
+/**
+ * Json array builder.
+ */
+public class IgniteJsonArrayBuilder implements JsonArrayBuilder {
+ /** Json array list. */
+ private List<JsonValue> jsonList = new ArrayList<>();
+
+ /** {@inheritDoc} */
+ @Override public JsonArrayBuilder add(JsonValue val) {
+ A.notNull(val, "value");
+
+ jsonList.add(val);
+
+ return this;
+ }
+
+ /** {@inheritDoc} */
+ @Override public JsonArrayBuilder add(String val) {
+ A.notNull(val, "value");
+
+ jsonList.add(new IgniteJsonString(val));
+
+ return this;
+ }
+
+ /** {@inheritDoc} */
+ @Override public JsonArrayBuilder add(BigDecimal val) {
+ A.notNull(val, "value");
+
+ jsonList.add(new IgniteJsonNumber(val));
+
+ return this;
+ }
+
+ /** {@inheritDoc} */
+ @Override public JsonArrayBuilder add(BigInteger val) {
+ A.notNull(val, "value");
+
+ //TODO: optimize for value
+ jsonList.add(new IgniteJsonNumber(new BigDecimal(val)));
+
+ return this;
+ }
+
+ /** {@inheritDoc} */
+ @Override public JsonArrayBuilder add(int val) {
+ //TODO: optimize for value
+ jsonList.add(new IgniteJsonNumber(new BigDecimal(val)));
+
+ return this;
+ }
+
+ /** {@inheritDoc} */
+ @Override public JsonArrayBuilder add(long val) {
+ //TODO: optimize for value
+ jsonList.add(new IgniteJsonNumber(new BigDecimal(val)));
+
+ return this;
+ }
+
+ /** {@inheritDoc} */
+ @Override public JsonArrayBuilder add(double val) {
+ //TODO: optimize for value
+ jsonList.add(new IgniteJsonNumber(new BigDecimal(val)));
+
+ return this;
+ }
+
+ /** {@inheritDoc} */
+ @Override public JsonArrayBuilder add(boolean val) {
+ jsonList.add(val ? JsonValue.TRUE : JsonValue.FALSE);
+
+ return this;
+ }
+
+ /** {@inheritDoc} */
+ @Override public JsonArrayBuilder addNull() {
+ jsonList.add(JsonValue.NULL);
+
+ return this;
+ }
+
+ /** {@inheritDoc} */
+ @Override public JsonArrayBuilder add(JsonObjectBuilder bld) {
+ A.notNull(bld, "value");
+
+ jsonList.add(bld.build());
+
+ return this;
+ }
+
+ /** {@inheritDoc} */
+ @Override public JsonArrayBuilder add(JsonArrayBuilder bld) {
+ A.notNull(bld, "value");
+
+ jsonList.add(bld.build());
+
+ return this;
+ }
+
+ /** {@inheritDoc} */
+ @Override public JsonArray build() {
+ return new IgniteJsonArray(jsonList);
+ }
+}
[04/21] incubator-ignite git commit: #ignite-961: add test for get
rest protocol.
Posted by se...@apache.org.
#ignite-961: add test for get rest protocol.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/b6c68eb5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/b6c68eb5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/b6c68eb5
Branch: refs/heads/ignite-1121
Commit: b6c68eb560d91127e27648d91f4bd2709f0bd4fd
Parents: a7f664e
Author: ivasilinets <iv...@gridgain.com>
Authored: Fri Jul 17 16:09:15 2015 +0300
Committer: ivasilinets <iv...@gridgain.com>
Committed: Fri Jul 17 16:09:15 2015 +0300
----------------------------------------------------------------------
.../JettyRestProcessorAbstractSelfTest.java | 251 ++++++++++++++++++-
.../http/jetty/GridJettyRestHandler.java | 34 ++-
2 files changed, 269 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b6c68eb5/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 e1425ff..38bfef5 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
@@ -477,7 +477,164 @@ abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestProcessorS
/**
* @throws Exception If failed.
*/
+ public void testContainesKey() throws Exception {
+ grid(0).cache(null).put("key0", "val0");
+
+ String ret = content(F.asMap("cmd", "containskey", "key", "key0"));
+
+ assertNotNull(ret);
+ assertTrue(!ret.isEmpty());
+
+ jsonEquals(ret, cachePattern(true, true));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testContainesKeys() throws Exception {
+ grid(0).cache(null).put("key0", "val0");
+ grid(0).cache(null).put("key1", "val1");
+
+ String ret = content(F.asMap("cmd", "containskeys", "k1", "key0", "k2", "key1"));
+
+ assertNotNull(ret);
+ assertTrue(!ret.isEmpty());
+
+ jsonEquals(ret, cacheBulkPattern(true, true));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
public void testGetAndPut() throws Exception {
+ grid(0).cache(null).put("key0", "val0");
+
+ String ret = content(F.asMap("cmd", "getandput", "key", "key0", "val", "val1"));
+
+ assertNotNull(ret);
+ assertTrue(!ret.isEmpty());
+
+ jsonEquals(ret, cachePattern("val0", true));
+
+ assertEquals("val1", grid(0).cache(null).get("key0"));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testGetAndPutIfAbsent() throws Exception {
+ grid(0).cache(null).put("key0", "val0");
+
+ String ret = content(F.asMap("cmd", "getandputifabsent", "key", "key0", "val", "val1"));
+
+ assertNotNull(ret);
+ assertTrue(!ret.isEmpty());
+
+ jsonEquals(ret, cachePattern("val0", true));
+
+ assertEquals("val0", grid(0).cache(null).get("key0"));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPutIfAbsent2() throws Exception {
+ String ret = content(F.asMap("cmd", "putifabsent", "key", "key0", "val", "val1"));
+
+ assertNotNull(ret);
+ assertTrue(!ret.isEmpty());
+
+ jsonEquals(ret, cachePattern(true, true));
+
+ assertEquals("val1", grid(0).cache(null).get("key0"));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testRemoveValue() throws Exception {
+ grid(0).cache(null).put("key0", "val0");
+
+ String ret = content(F.asMap("cmd", "rmvvalue", "key", "key0", "val", "val1"));
+
+ assertNotNull(ret);
+ assertTrue(!ret.isEmpty());
+
+ jsonEquals(ret, cachePattern(false, true));
+
+ assertEquals("val0", grid(0).cache(null).get("key0"));
+
+ ret = content(F.asMap("cmd", "rmvvalue", "key", "key0", "val", "val0"));
+
+ assertNotNull(ret);
+ assertTrue(!ret.isEmpty());
+
+ jsonEquals(ret, cachePattern(true, true));
+
+ assertNull(grid(0).cache(null).get("key0"));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testGetAndRemove() throws Exception {
+ grid(0).cache(null).put("key0", "val0");
+
+ String ret = content(F.asMap("cmd", "getandrmv", "key", "key0"));
+
+ assertNotNull(ret);
+ assertTrue(!ret.isEmpty());
+
+ jsonEquals(ret, cachePattern("val0", true));
+
+ assertNull(grid(0).cache(null).get("key0"));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testReplaceValue() throws Exception {
+ grid(0).cache(null).put("key0", "val0");
+
+ String ret = content(F.asMap("cmd", "repval", "key", "key0", "val", "val1", "val2", "val2"));
+
+ assertNotNull(ret);
+ assertTrue(!ret.isEmpty());
+
+ jsonEquals(ret, cachePattern(false, true));
+
+ assertEquals("val0", grid(0).cache(null).get("key0"));
+
+ ret = content(F.asMap("cmd", "repval", "key", "key0", "val", "val1", "val2", "val0"));
+
+ assertNotNull(ret);
+ assertTrue(!ret.isEmpty());
+
+ jsonEquals(ret, cachePattern(true, true));
+
+ assertEquals("val1", grid(0).cache(null).get("key0"));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testGetAndReplace() throws Exception {
+ grid(0).cache(null).put("key0", "val0");
+
+ String ret = content(F.asMap("cmd", "getandreplace", "key", "key0", "val", "val1"));
+
+ assertNotNull(ret);
+ assertTrue(!ret.isEmpty());
+
+ jsonEquals(ret, cachePattern("val0", true));
+
+ assertEquals("val1", grid(0).cache(null).get("key0"));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testGetAndPutPost() throws Exception {
String val = "{\"key\":\"key0\", \"val\":\"val0\"}";
String ret = makePostRequest(F.asMap("cmd", "getandput"), val);
@@ -1054,26 +1211,63 @@ abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestProcessorS
/**
* @throws Exception If failed.
*/
+ public void testRunScriptPost() throws Exception {
+ String f = "function(param){return param;}";
+ String ret = makePostRequest(F.asMap("cmd", "runscript", "func", URLEncoder.encode(f)), "{\"arg\":\"hello\"}");
+
+ assertNotNull(ret);
+ assertTrue(!ret.isEmpty());
+
+ jsonEquals(ret, stringPattern("hello", true));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
public void testRunScript() throws Exception {
- String f = "function(){return ignite.name();}";
- String ret = makePostRequest(F.asMap("cmd", "runscript", "func", URLEncoder.encode(f)), "{\"arg\":[]}");
+ String f = "function(param){return param;}";
+ String ret = content(F.asMap("cmd", "runscript", "func", URLEncoder.encode(f), "arg", "hello"));
assertNotNull(ret);
assertTrue(!ret.isEmpty());
- jsonEquals(ret, stringPattern(getTestGridName(1), true));
+ jsonEquals(ret, stringPattern("hello", true));
}
/**
* @throws Exception If failed.
*/
- 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\"}");
+ public void testRunAffinityScriptPost() throws Exception {
+ ClusterNode node = grid(0).affinity(null).mapKeyToNode("key0");
+
+ Ignite ignite = null;
+
+ for (int i = 0; i < GRID_CNT; ++i) {
+ if (grid(i).localNode().equals(node))
+ ignite = grid(i);
+ }
+
+ assertNotNull(ignite);
+
+ String f = "function(expName){"+
+ "if (expName.toString() !== ignite.name().toString()) {" +
+ "throw \"Not correct name.\"" +
+ "}" +
+ "return ignite.name();}";
+
+ String ret = makePostRequest(F.asMap("cmd", "affrun", "func", URLEncoder.encode(f)),
+ "{\"arg\":\"" + ignite.name() + "\",\"key\":\"key0\"}");
assertNotNull(ret);
assertTrue(!ret.isEmpty());
+ jsonEquals(ret, stringPattern(ignite.name(), true));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testRunAffinityScript() throws Exception {
ClusterNode node = grid(0).affinity(null).mapKeyToNode("key0");
Ignite ignite = null;
@@ -1085,13 +1279,25 @@ abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestProcessorS
assertNotNull(ignite);
+ String f = "function(expName){"+
+ "if (expName != ignite.name()) {" +
+ "throw \"Not correct name.\"" +
+ "}" +
+ "return ignite.name();}";
+
+ String ret = content(F.asMap("cmd", "affrun", "func", URLEncoder.encode(f),
+ "key", "key0", "arg", ignite.name()));
+
+ assertNotNull(ret);
+ assertTrue(!ret.isEmpty());
+
jsonEquals(ret, stringPattern(ignite.name(), true));
}
/**
* @throws Exception If failed.
*/
- public void testMapReduceScript() throws Exception {
+ public void testMapReduceScriptPost() throws Exception {
String map = "function(nodes, arg) {" +
"var words = arg.split(\" \");" +
"for (var i = 0; i < words.length; i++) {" +
@@ -1122,6 +1328,37 @@ abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestProcessorS
/**
* @throws Exception If failed.
*/
+ public void testMapReduceScript() throws Exception {
+ String map = "function(nodes, arg) {" +
+ "var words = arg.split(\" \");" +
+ "for (var i = 0; i < words.length; i++) {" +
+ "var f = function(word) {" +
+ "return word.length;" +
+ "};" +
+ "emit(f, words[i], nodes[i % nodes.length]);" +
+ "}"+
+ "};";
+
+ String reduce = "function(results) {"+
+ "var sum = 0;"+
+ "for (var i = 0; i < results.size(); ++i) {"+
+ "sum += results.get(i).intValue();"+
+ "}" +
+ "return sum;" +
+ "};";
+
+ String ret = content(F.asMap("cmd", "excmapreduce", "map", URLEncoder.encode(map),
+ "reduce", URLEncoder.encode(reduce), "arg", URLEncoder.encode("Hello world!")));
+
+ assertNotNull(ret);
+ assertTrue(!ret.isEmpty());
+
+ jsonEquals(ret, integerPattern(11, true));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
public void testQuery() throws Exception {
grid(0).cache(null).put("1", "1");
grid(0).cache(null).put("2", "2");
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b6c68eb5/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 d0ae096..1acab51 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
@@ -496,7 +496,8 @@ public class GridJettyRestHandler extends AbstractHandler {
restReq0.cacheFlags(intValue("cacheFlags", params, 0));
restReq0.ttl(longValue("exp", params, null));
- if (cmd == CACHE_GET_ALL || cmd == CACHE_PUT_ALL || cmd == CACHE_REMOVE_ALL) {
+ if (cmd == CACHE_GET_ALL || cmd == CACHE_PUT_ALL || cmd == CACHE_REMOVE_ALL ||
+ cmd == CACHE_CONTAINS_KEYS) {
List<Object> keys = values("k", params);
List<Object> vals = values("v", params);
@@ -580,8 +581,12 @@ public class GridJettyRestHandler extends AbstractHandler {
restReq0.script((String)params.get("func"));
- Map o = parseRequest(req);
- restReq0.argument(ctx.scripting().toJavaObject(o.get("arg")));
+ if (req.getHeader("Content-Type") != null && req.getHeader("Content-Type").contains("json")) {
+ Map o = parseRequest(req);
+ restReq0.argument(ctx.scripting().toJavaObject(o.get("arg")));
+ }
+ else
+ restReq0.argument(params.get("arg"));
restReq = restReq0;
@@ -594,11 +599,17 @@ public class GridJettyRestHandler extends AbstractHandler {
restReq0.script((String)params.get("func"));
restReq0.cacheName((String) params.get("cacheName"));
- Map o = parseRequest(req);
- restReq0.argument(ctx.scripting().toJavaObject(o.get("arg")));
+ if (req.getHeader("Content-Type") != null && req.getHeader("Content-Type").contains("json")) {
+ Map o = parseRequest(req);
+ restReq0.argument(ctx.scripting().toJavaObject(o.get("arg")));
- Object cacheObj = ctx.scripting().toJavaObject(o.get("key"));
- restReq0.affinityKey(cacheObj);
+ Object cacheObj = ctx.scripting().toJavaObject(o.get("key"));
+ restReq0.affinityKey(cacheObj);
+ }
+ else {
+ restReq0.argument(params.get("arg"));
+ restReq0.affinityKey(params.get("key"));
+ }
restReq = restReq0;
@@ -610,8 +621,13 @@ public class GridJettyRestHandler extends AbstractHandler {
restReq0.mapFunction((String) params.get("map"));
- Map o = parseRequest(req);
- restReq0.argument(ctx.scripting().toJavaObject(o.get("arg")));
+
+ if (req.getHeader("Content-Type") != null && req.getHeader("Content-Type").contains("json")) {
+ Map o = parseRequest(req);
+ restReq0.argument(ctx.scripting().toJavaObject(o.get("arg")));
+ }
+ else
+ restReq0.argument(params.get("arg"));
restReq0.reduceFunction((String) params.get("reduce"));
[17/21] incubator-ignite git commit: #ignite-961: remove debug.
Posted by se...@apache.org.
#ignite-961: remove debug.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/9fdb28cc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/9fdb28cc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/9fdb28cc
Branch: refs/heads/ignite-1121
Commit: 9fdb28cced63a1eba1716e5acf4885ebab5f8186
Parents: 595fe6e
Author: ivasilinets <iv...@gridgain.com>
Authored: Mon Jul 20 10:43:07 2015 +0300
Committer: ivasilinets <iv...@gridgain.com>
Committed: Mon Jul 20 10:43:07 2015 +0300
----------------------------------------------------------------------
.../processors/rest/JettyRestProcessorAbstractSelfTest.java | 2 --
.../affinity/rendezvous/RendezvousAffinityFunction.java | 4 ----
.../processors/affinity/GridAffinityAssignmentCache.java | 8 --------
3 files changed, 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9fdb28cc/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 9509500..5baab05 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
@@ -26,7 +26,6 @@ import org.apache.ignite.cluster.*;
import org.apache.ignite.configuration.*;
import org.apache.ignite.internal.processors.rest.handlers.*;
import org.apache.ignite.internal.util.typedef.*;
-import org.apache.ignite.internal.util.typedef.internal.*;
import org.apache.ignite.testframework.*;
import java.io.*;
@@ -1551,7 +1550,6 @@ abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestProcessorS
protected abstract String signature() throws Exception;
-
/**
* Init cache.
*/
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9fdb28cc/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunction.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunction.java b/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunction.java
index 81472f0..2b26630 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunction.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunction.java
@@ -290,10 +290,6 @@ public class RendezvousAffinityFunction implements AffinityFunction, Externaliza
try {
ByteArrayOutputStream out = new ByteArrayOutputStream();
- if (ignite == null)
- System.out.println("IGNITE IS NULL!!!");
-
-
byte[] nodeHashBytes = ignite.configuration().getMarshaller().marshal(nodeHash);
out.write(U.intToBytes(part), 0, 4); // Avoid IOException.
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9fdb28cc/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java
index 281c153..d40128c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java
@@ -25,7 +25,6 @@ import org.apache.ignite.internal.*;
import org.apache.ignite.internal.processors.cache.*;
import org.apache.ignite.internal.util.future.*;
import org.apache.ignite.internal.util.typedef.*;
-import org.apache.ignite.internal.util.typedef.internal.*;
import org.jetbrains.annotations.*;
import org.jsr166.*;
@@ -186,13 +185,6 @@ public class GridAffinityAssignmentCache {
Collections.sort(sorted, GridNodeOrderComparator.INSTANCE);
}
- /*try {
- ctx.grid().context().resource().injectGeneric(aff);
- }
- catch (IgniteCheckedException e) {
- U.convertException(e);
- }*/
-
List<List<ClusterNode>> prevAssignment = prev == null ? null : prev.assignment();
List<List<ClusterNode>> assignment;
[15/21] incubator-ignite git commit: #ignite-961: add test for
incorrect parameters.
Posted by se...@apache.org.
#ignite-961: add test for incorrect parameters.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/d815e51b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/d815e51b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/d815e51b
Branch: refs/heads/ignite-1121
Commit: d815e51b42c17d8ccc4d7a4f024ed6843d163520
Parents: d2f41c9
Author: ivasilinets <iv...@gridgain.com>
Authored: Mon Jul 20 10:32:29 2015 +0300
Committer: ivasilinets <iv...@gridgain.com>
Committed: Mon Jul 20 10:32:29 2015 +0300
----------------------------------------------------------------------
.../JettyRestProcessorAbstractSelfTest.java | 55 +++++++++-----------
1 file changed, 25 insertions(+), 30 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d815e51b/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 9aab6f5..9509500 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
@@ -199,6 +199,18 @@ abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestProcessorS
}
/**
+ * @param err Error.
+ * @return Regex pattern for JSON.
+ */
+ private String errorPattern(String err) {
+ return "\\{" +
+ "\\\"error\\\":\\\"" + err + "\\\"\\," +
+ "\\\"response\\\":null\\," +
+ "\\\"sessionToken\\\":\\\"\\\"," +
+ "\\\"successStatus\\\":" + 1 + "\\}";
+ }
+
+ /**
* @param res Response.
* @param success Success flag.
* @return Regex pattern for JSON.
@@ -486,7 +498,19 @@ abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestProcessorS
/**
* @throws Exception If failed.
*/
- public void testContainesKey() throws Exception {
+ public void testIncorrectPutPost() throws Exception {
+ String val = "{\"key\":\"key0\"}";
+ String ret = makePostRequest(F.asMap("cmd", "put"), val);
+
+ assertNotNull(ret);
+ assertTrue(!ret.isEmpty());
+ jsonEquals(ret, errorPattern("Failed to find mandatory parameter in request: val"));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testContainsKey() throws Exception {
grid(0).cache(null).put("key0", "val0");
String ret = content(F.asMap("cmd", "containskey", "key", "key0"));
@@ -1593,13 +1617,6 @@ abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestProcessorS
}
/**
- * @param firstName First name.
- */
- public void setFirstName(String firstName) {
- this.firstName = firstName;
- }
-
- /**
* @return First name.
*/
public String getFirstName() {
@@ -1607,33 +1624,11 @@ abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestProcessorS
}
/**
- * @param lastName Last name.
- */
- public void setLastName(String lastName) {
- this.lastName = lastName;
- }
-
- /**
* @return Last name.
*/
public String getLastName() {
return lastName;
}
-
- /**
- * @param id Id.
- */
- public void setId(Integer id) {
- this.id = id;
- }
-
- /**
- * @param salary Salary.
- */
- public void setSalary(double salary) {
- this.salary = salary;
- }
-
/**
* @return Salary.
*/
[12/21] incubator-ignite git commit: #ignite-961: start query-example.
Posted by se...@apache.org.
#ignite-961: start query-example.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/d2f41c93
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/d2f41c93
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/d2f41c93
Branch: refs/heads/ignite-1121
Commit: d2f41c93a4afcfd5d876f68f7ef25429984d98b2
Parents: a2ab189
Author: ivasilinets <iv...@gridgain.com>
Authored: Fri Jul 17 18:46:39 2015 +0300
Committer: ivasilinets <iv...@gridgain.com>
Committed: Fri Jul 17 18:46:39 2015 +0300
----------------------------------------------------------------------
examples/config/js/example-query.xml | 91 ++++++++++++++++++++
examples/pom.xml | 6 ++
.../ignite/examples/ExampleNodeStartup.java | 2 +-
examples/src/main/js/cache-query-example.js | 20 ++---
4 files changed, 108 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d2f41c93/examples/config/js/example-query.xml
----------------------------------------------------------------------
diff --git a/examples/config/js/example-query.xml b/examples/config/js/example-query.xml
new file mode 100644
index 0000000..27136a0
--- /dev/null
+++ b/examples/config/js/example-query.xml
@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+<!--
+ Ignite Spring configuration file to startup Ignite cache.
+
+ This file demonstrates how to configure cache using Spring. Provided cache
+ will be created on node startup.
+
+ Use this configuration file when running HTTP REST examples (see 'examples/rest' folder).
+
+ When starting a standalone node, you need to execute the following command:
+ {IGNITE_HOME}/bin/ignite.{bat|sh} examples/config/example-cache.xml
+
+ When starting Ignite from Java IDE, pass path to this file to Ignition:
+ Ignition.start("examples/config/example-cache.xml");
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd">
+ <bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+ <property name="localHost" value="127.0.0.1" />
+
+ <property name="cacheConfiguration">
+ <list>
+ <!-- Partitioned cache example configuration (Atomic mode). -->
+ <bean class="org.apache.ignite.configuration.CacheConfiguration">
+ <property name="name" value="CacheQueryExample"/>
+ <property name="typeMetadata">
+ <bean class="org.apache.ignite.cache.CacheTypeMetadata">
+ <property name="valueType" value="javax.json.JsonObject"/>
+ <property name="queryFields">
+ <map>
+ <entry key="salary" value="java.lang.Integer"/>
+ <entry key="address" value="javax.json.JsonObject"/>
+ </map>
+ </property>
+ <property name="ascendingFields">
+ <map>
+ <entry key="name" value="java.lang.String"/>
+ <entry key="id" value="java.lang.Integer"/>
+ </map>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </list>
+ </property>
+
+ <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="ipFinder">
+ <!--
+ Ignite provides several options for automatic discovery that can be used
+ instead os static IP based discovery. For information on all options refer
+ to our documentation: http://apacheignite.readme.io/docs/cluster-config
+ -->
+ <!-- Uncomment static IP finder to enable static-based discovery of initial nodes. -->
+ <!--<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">-->
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
+ <property name="addresses">
+ <list>
+ <!-- In distributed environment, replace with actual host IP address. -->
+ <value>127.0.0.1:47500..47509</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d2f41c93/examples/pom.xml
----------------------------------------------------------------------
diff --git a/examples/pom.xml b/examples/pom.xml
index 901851d..8204a36 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -39,6 +39,12 @@
<dependency>
<groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-json</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
<artifactId>ignite-core</artifactId>
<version>${project.version}</version>
</dependency>
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d2f41c93/examples/src/main/java/org/apache/ignite/examples/ExampleNodeStartup.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/ExampleNodeStartup.java b/examples/src/main/java/org/apache/ignite/examples/ExampleNodeStartup.java
index f972b53..1239856 100644
--- a/examples/src/main/java/org/apache/ignite/examples/ExampleNodeStartup.java
+++ b/examples/src/main/java/org/apache/ignite/examples/ExampleNodeStartup.java
@@ -30,6 +30,6 @@ public class ExampleNodeStartup {
* @throws IgniteException If failed.
*/
public static void main(String[] args) throws IgniteException {
- Ignition.start("examples/config/example-ignite.xml");
+ Ignition.start("examples/config/js/example-query.xml");
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d2f41c93/examples/src/main/js/cache-query-example.js
----------------------------------------------------------------------
diff --git a/examples/src/main/js/cache-query-example.js b/examples/src/main/js/cache-query-example.js
index 8b455b5..752175f 100644
--- a/examples/src/main/js/cache-query-example.js
+++ b/examples/src/main/js/cache-query-example.js
@@ -103,16 +103,16 @@ main = function() {
// Initialize cache for people.
function initializeEntries() {
- var key1 = "1";
- var value1 = {"firstName" : "John", "lastName" : "Doe", "salary" : 2000};
- var key2 = "2";
- var value2 = {"firstName" : "Jane", "lastName" : "Doe", "salary" : 1000};
- var key3 = "3";
- var value3 = {"firstName" : "John", "lastName" : "Smith", "salary" : 1000};
- var key4 = "4";
- var value4 = {"firstName" : "Jane", "lastName" : "Smith", "salary" : 2000};
- var key5 = "5";
- var value5 = {"firstName" : "Ann", "lastName" : "Smith", "salary" : 3000};
+ var key1 = 1;
+ var value1 = {"name" : "John", "id" : 1, "salary" : 2000, "address" : {"street" : "1st Avenue"}};
+ var key2 = 2;
+ var value2 = {"name" : "Jane", "id" : 2, "salary" : 1000, "address" : {"street" : "1st Avenue"}};
+ var key3 = 3;
+ var value3 = {"name" : "John", "id" : 3, "salary" : 1000, "address" : {"street" : "1st Avenue"}};
+ var key4 = 4;
+ var value4 = {"name" : "Jane", "id" : 4, "salary" : 2000, "address" : {"street" : "1st Avenue"}};
+ var key5 = 5;
+ var value5 = {"name" : "Ann", "id" : 5, "salary" : 3000, "address" : {"street" : "1st Avenue"}};
return [new CacheEntry(key1, value1), new CacheEntry(key2, value2),
new CacheEntry(key3, value3), new CacheEntry(key4, value4)];
[02/21] incubator-ignite git commit: 1.3.2-SNAPSHOT
Posted by se...@apache.org.
1.3.2-SNAPSHOT
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/7d27103c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/7d27103c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/7d27103c
Branch: refs/heads/ignite-1121
Commit: 7d27103c39be11673f52b6b68ec087742237e258
Parents: 692dd04
Author: Ignite Teamcity <ig...@apache.org>
Authored: Fri Jul 17 05:04:24 2015 +0300
Committer: Ignite Teamcity <ig...@apache.org>
Committed: Fri Jul 17 05:04:24 2015 +0300
----------------------------------------------------------------------
examples/pom.xml | 2 +-
modules/aop/pom.xml | 2 +-
modules/apache-license-gen/pom.xml | 2 +-
modules/aws/pom.xml | 2 +-
modules/clients/pom.xml | 2 +-
modules/cloud/pom.xml | 2 +-
modules/codegen/pom.xml | 2 +-
modules/core/pom.xml | 2 +-
modules/core/src/main/resources/ignite.properties | 2 +-
modules/extdata/p2p/pom.xml | 2 +-
modules/extdata/uri/modules/uri-dependency/pom.xml | 2 +-
modules/extdata/uri/pom.xml | 2 +-
modules/gce/pom.xml | 2 +-
modules/geospatial/pom.xml | 2 +-
modules/hadoop/pom.xml | 2 +-
modules/hibernate/pom.xml | 2 +-
modules/indexing/pom.xml | 2 +-
modules/jcl/pom.xml | 2 +-
modules/jta/pom.xml | 2 +-
modules/kafka/pom.xml | 2 +-
modules/log4j/pom.xml | 2 +-
modules/mesos/pom.xml | 2 +-
modules/rest-http/pom.xml | 2 +-
modules/scalar-2.10/pom.xml | 2 +-
modules/scalar/pom.xml | 2 +-
modules/schedule/pom.xml | 2 +-
modules/schema-import/pom.xml | 2 +-
modules/slf4j/pom.xml | 2 +-
modules/spark-2.10/pom.xml | 2 +-
modules/spark/pom.xml | 2 +-
modules/spring/pom.xml | 2 +-
modules/ssh/pom.xml | 2 +-
modules/tools/pom.xml | 2 +-
modules/urideploy/pom.xml | 2 +-
modules/visor-console-2.10/pom.xml | 2 +-
modules/visor-console/pom.xml | 2 +-
modules/visor-plugins/pom.xml | 2 +-
modules/web/pom.xml | 2 +-
modules/yardstick/pom.xml | 2 +-
modules/yarn/pom.xml | 2 +-
pom.xml | 2 +-
41 files changed, 41 insertions(+), 41 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7d27103c/examples/pom.xml
----------------------------------------------------------------------
diff --git a/examples/pom.xml b/examples/pom.xml
index a94b888..6d3fb07 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -28,7 +28,7 @@
</parent>
<artifactId>ignite-examples</artifactId>
- <version>1.3.1-SNAPSHOT</version>
+ <version>1.3.2-SNAPSHOT</version>
<dependencies>
<dependency>
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7d27103c/modules/aop/pom.xml
----------------------------------------------------------------------
diff --git a/modules/aop/pom.xml b/modules/aop/pom.xml
index fd3e41b..3c55e7d 100644
--- a/modules/aop/pom.xml
+++ b/modules/aop/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-aop</artifactId>
- <version>1.3.1-SNAPSHOT</version>
+ <version>1.3.2-SNAPSHOT</version>
<dependencies>
<dependency>
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7d27103c/modules/apache-license-gen/pom.xml
----------------------------------------------------------------------
diff --git a/modules/apache-license-gen/pom.xml b/modules/apache-license-gen/pom.xml
index 6e22668..2edb962 100644
--- a/modules/apache-license-gen/pom.xml
+++ b/modules/apache-license-gen/pom.xml
@@ -31,7 +31,7 @@
<groupId>org.apache.ignite</groupId>
<artifactId>ignite-apache-license-gen</artifactId>
- <version>1.3.1-SNAPSHOT</version>
+ <version>1.3.2-SNAPSHOT</version>
<build>
<plugins>
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7d27103c/modules/aws/pom.xml
----------------------------------------------------------------------
diff --git a/modules/aws/pom.xml b/modules/aws/pom.xml
index 954d19b..4a568b0 100644
--- a/modules/aws/pom.xml
+++ b/modules/aws/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-aws</artifactId>
- <version>1.3.1-SNAPSHOT</version>
+ <version>1.3.2-SNAPSHOT</version>
<dependencies>
<dependency>
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7d27103c/modules/clients/pom.xml
----------------------------------------------------------------------
diff --git a/modules/clients/pom.xml b/modules/clients/pom.xml
index fbbf4be..68204f3 100644
--- a/modules/clients/pom.xml
+++ b/modules/clients/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-clients</artifactId>
- <version>1.3.1-SNAPSHOT</version>
+ <version>1.3.2-SNAPSHOT</version>
<dependencies>
<dependency>
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7d27103c/modules/cloud/pom.xml
----------------------------------------------------------------------
diff --git a/modules/cloud/pom.xml b/modules/cloud/pom.xml
index 60c87df..a183522 100644
--- a/modules/cloud/pom.xml
+++ b/modules/cloud/pom.xml
@@ -29,7 +29,7 @@
</parent>
<artifactId>ignite-cloud</artifactId>
- <version>1.3.1-SNAPSHOT</version>
+ <version>1.3.2-SNAPSHOT</version>
<properties>
<jcloud.version>1.9.0</jcloud.version>
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7d27103c/modules/codegen/pom.xml
----------------------------------------------------------------------
diff --git a/modules/codegen/pom.xml b/modules/codegen/pom.xml
index 2471585..ea9615c 100644
--- a/modules/codegen/pom.xml
+++ b/modules/codegen/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-codegen</artifactId>
- <version>1.3.1-SNAPSHOT</version>
+ <version>1.3.2-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7d27103c/modules/core/pom.xml
----------------------------------------------------------------------
diff --git a/modules/core/pom.xml b/modules/core/pom.xml
index 2c0dfda..c42be3d 100644
--- a/modules/core/pom.xml
+++ b/modules/core/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-core</artifactId>
- <version>1.3.1-SNAPSHOT</version>
+ <version>1.3.2-SNAPSHOT</version>
<dependencies>
<dependency>
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7d27103c/modules/core/src/main/resources/ignite.properties
----------------------------------------------------------------------
diff --git a/modules/core/src/main/resources/ignite.properties b/modules/core/src/main/resources/ignite.properties
index 3a6aa6f..2313ac3 100644
--- a/modules/core/src/main/resources/ignite.properties
+++ b/modules/core/src/main/resources/ignite.properties
@@ -15,7 +15,7 @@
# limitations under the License.
#
-ignite.version=1.3.1-SNAPSHOT
+ignite.version=1.3.2-SNAPSHOT
ignite.build=0
ignite.revision=DEV
ignite.rel.date=01011970
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7d27103c/modules/extdata/p2p/pom.xml
----------------------------------------------------------------------
diff --git a/modules/extdata/p2p/pom.xml b/modules/extdata/p2p/pom.xml
index 19c9a28..5a80380 100644
--- a/modules/extdata/p2p/pom.xml
+++ b/modules/extdata/p2p/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-extdata-p2p</artifactId>
- <version>1.3.1-SNAPSHOT</version>
+ <version>1.3.2-SNAPSHOT</version>
<dependencies>
<dependency>
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7d27103c/modules/extdata/uri/modules/uri-dependency/pom.xml
----------------------------------------------------------------------
diff --git a/modules/extdata/uri/modules/uri-dependency/pom.xml b/modules/extdata/uri/modules/uri-dependency/pom.xml
index 2ea01d9..b8e4742 100644
--- a/modules/extdata/uri/modules/uri-dependency/pom.xml
+++ b/modules/extdata/uri/modules/uri-dependency/pom.xml
@@ -27,7 +27,7 @@
<artifactId>ignite-extdata-uri-dep</artifactId>
<packaging>jar</packaging>
- <version>1.3.1-SNAPSHOT</version>
+ <version>1.3.2-SNAPSHOT</version>
<modelVersion>4.0.0</modelVersion>
<dependencies>
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7d27103c/modules/extdata/uri/pom.xml
----------------------------------------------------------------------
diff --git a/modules/extdata/uri/pom.xml b/modules/extdata/uri/pom.xml
index 984c744..e4e5bb6 100644
--- a/modules/extdata/uri/pom.xml
+++ b/modules/extdata/uri/pom.xml
@@ -32,7 +32,7 @@
</parent>
<artifactId>ignite-extdata-uri</artifactId>
- <version>1.3.1-SNAPSHOT</version>
+ <version>1.3.2-SNAPSHOT</version>
<dependencies>
<dependency>
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7d27103c/modules/gce/pom.xml
----------------------------------------------------------------------
diff --git a/modules/gce/pom.xml b/modules/gce/pom.xml
index 3ee4360..b1be8ea 100644
--- a/modules/gce/pom.xml
+++ b/modules/gce/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-gce</artifactId>
- <version>1.3.1-SNAPSHOT</version>
+ <version>1.3.2-SNAPSHOT</version>
<dependencies>
<dependency>
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7d27103c/modules/geospatial/pom.xml
----------------------------------------------------------------------
diff --git a/modules/geospatial/pom.xml b/modules/geospatial/pom.xml
index a9fbbe8..ecee8d4 100644
--- a/modules/geospatial/pom.xml
+++ b/modules/geospatial/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-geospatial</artifactId>
- <version>1.3.1-SNAPSHOT</version>
+ <version>1.3.2-SNAPSHOT</version>
<dependencies>
<dependency>
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7d27103c/modules/hadoop/pom.xml
----------------------------------------------------------------------
diff --git a/modules/hadoop/pom.xml b/modules/hadoop/pom.xml
index a07c5b9..555778c 100644
--- a/modules/hadoop/pom.xml
+++ b/modules/hadoop/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-hadoop</artifactId>
- <version>1.3.1-SNAPSHOT</version>
+ <version>1.3.2-SNAPSHOT</version>
<dependencies>
<dependency>
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7d27103c/modules/hibernate/pom.xml
----------------------------------------------------------------------
diff --git a/modules/hibernate/pom.xml b/modules/hibernate/pom.xml
index 54fea68..5976baa 100644
--- a/modules/hibernate/pom.xml
+++ b/modules/hibernate/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-hibernate</artifactId>
- <version>1.3.1-SNAPSHOT</version>
+ <version>1.3.2-SNAPSHOT</version>
<dependencies>
<dependency>
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7d27103c/modules/indexing/pom.xml
----------------------------------------------------------------------
diff --git a/modules/indexing/pom.xml b/modules/indexing/pom.xml
index dac173f..067ec2d 100644
--- a/modules/indexing/pom.xml
+++ b/modules/indexing/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-indexing</artifactId>
- <version>1.3.1-SNAPSHOT</version>
+ <version>1.3.2-SNAPSHOT</version>
<dependencies>
<dependency>
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7d27103c/modules/jcl/pom.xml
----------------------------------------------------------------------
diff --git a/modules/jcl/pom.xml b/modules/jcl/pom.xml
index 3b5a0be..ed864ce 100644
--- a/modules/jcl/pom.xml
+++ b/modules/jcl/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-jcl</artifactId>
- <version>1.3.1-SNAPSHOT</version>
+ <version>1.3.2-SNAPSHOT</version>
<dependencies>
<dependency>
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7d27103c/modules/jta/pom.xml
----------------------------------------------------------------------
diff --git a/modules/jta/pom.xml b/modules/jta/pom.xml
index abe3497..ca5546c 100644
--- a/modules/jta/pom.xml
+++ b/modules/jta/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-jta</artifactId>
- <version>1.3.1-SNAPSHOT</version>
+ <version>1.3.2-SNAPSHOT</version>
<dependencies>
<dependency>
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7d27103c/modules/kafka/pom.xml
----------------------------------------------------------------------
diff --git a/modules/kafka/pom.xml b/modules/kafka/pom.xml
index 9541bd4..5a8cb72 100644
--- a/modules/kafka/pom.xml
+++ b/modules/kafka/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-kafka</artifactId>
- <version>1.3.1-SNAPSHOT</version>
+ <version>1.3.2-SNAPSHOT</version>
<dependencies>
<dependency>
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7d27103c/modules/log4j/pom.xml
----------------------------------------------------------------------
diff --git a/modules/log4j/pom.xml b/modules/log4j/pom.xml
index d1f4823..0489518 100644
--- a/modules/log4j/pom.xml
+++ b/modules/log4j/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-log4j</artifactId>
- <version>1.3.1-SNAPSHOT</version>
+ <version>1.3.2-SNAPSHOT</version>
<dependencies>
<dependency>
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7d27103c/modules/mesos/pom.xml
----------------------------------------------------------------------
diff --git a/modules/mesos/pom.xml b/modules/mesos/pom.xml
index a8061ad..8a63a57 100644
--- a/modules/mesos/pom.xml
+++ b/modules/mesos/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-mesos</artifactId>
- <version>1.3.1-SNAPSHOT</version>
+ <version>1.3.2-SNAPSHOT</version>
<properties>
<mesos.version>0.22.0</mesos.version>
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7d27103c/modules/rest-http/pom.xml
----------------------------------------------------------------------
diff --git a/modules/rest-http/pom.xml b/modules/rest-http/pom.xml
index cc6cbc7..5cb522d 100644
--- a/modules/rest-http/pom.xml
+++ b/modules/rest-http/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-rest-http</artifactId>
- <version>1.3.1-SNAPSHOT</version>
+ <version>1.3.2-SNAPSHOT</version>
<dependencies>
<dependency>
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7d27103c/modules/scalar-2.10/pom.xml
----------------------------------------------------------------------
diff --git a/modules/scalar-2.10/pom.xml b/modules/scalar-2.10/pom.xml
index 2dcaba8..0770410 100644
--- a/modules/scalar-2.10/pom.xml
+++ b/modules/scalar-2.10/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-scalar_2.10</artifactId>
- <version>1.3.1-SNAPSHOT</version>
+ <version>1.3.2-SNAPSHOT</version>
<dependencies>
<dependency>
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7d27103c/modules/scalar/pom.xml
----------------------------------------------------------------------
diff --git a/modules/scalar/pom.xml b/modules/scalar/pom.xml
index 863aaa4..4515772 100644
--- a/modules/scalar/pom.xml
+++ b/modules/scalar/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-scalar</artifactId>
- <version>1.3.1-SNAPSHOT</version>
+ <version>1.3.2-SNAPSHOT</version>
<dependencies>
<dependency>
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7d27103c/modules/schedule/pom.xml
----------------------------------------------------------------------
diff --git a/modules/schedule/pom.xml b/modules/schedule/pom.xml
index 70b38dd..3b734b0 100644
--- a/modules/schedule/pom.xml
+++ b/modules/schedule/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-schedule</artifactId>
- <version>1.3.1-SNAPSHOT</version>
+ <version>1.3.2-SNAPSHOT</version>
<dependencies>
<dependency>
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7d27103c/modules/schema-import/pom.xml
----------------------------------------------------------------------
diff --git a/modules/schema-import/pom.xml b/modules/schema-import/pom.xml
index e542bdb..959e231 100644
--- a/modules/schema-import/pom.xml
+++ b/modules/schema-import/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-schema-import</artifactId>
- <version>1.3.1-SNAPSHOT</version>
+ <version>1.3.2-SNAPSHOT</version>
<dependencies>
<dependency>
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7d27103c/modules/slf4j/pom.xml
----------------------------------------------------------------------
diff --git a/modules/slf4j/pom.xml b/modules/slf4j/pom.xml
index 9eb7958..8fa09cb 100644
--- a/modules/slf4j/pom.xml
+++ b/modules/slf4j/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-slf4j</artifactId>
- <version>1.3.1-SNAPSHOT</version>
+ <version>1.3.2-SNAPSHOT</version>
<dependencies>
<dependency>
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7d27103c/modules/spark-2.10/pom.xml
----------------------------------------------------------------------
diff --git a/modules/spark-2.10/pom.xml b/modules/spark-2.10/pom.xml
index 2dedf6d..82b08bc 100644
--- a/modules/spark-2.10/pom.xml
+++ b/modules/spark-2.10/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-spark_2.10</artifactId>
- <version>1.3.1-SNAPSHOT</version>
+ <version>1.3.2-SNAPSHOT</version>
<dependencies>
<dependency>
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7d27103c/modules/spark/pom.xml
----------------------------------------------------------------------
diff --git a/modules/spark/pom.xml b/modules/spark/pom.xml
index 4ea1a82..107424a 100644
--- a/modules/spark/pom.xml
+++ b/modules/spark/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-spark</artifactId>
- <version>1.3.1-SNAPSHOT</version>
+ <version>1.3.2-SNAPSHOT</version>
<dependencies>
<dependency>
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7d27103c/modules/spring/pom.xml
----------------------------------------------------------------------
diff --git a/modules/spring/pom.xml b/modules/spring/pom.xml
index f772084..fdd2b0a 100644
--- a/modules/spring/pom.xml
+++ b/modules/spring/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-spring</artifactId>
- <version>1.3.1-SNAPSHOT</version>
+ <version>1.3.2-SNAPSHOT</version>
<dependencies>
<dependency>
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7d27103c/modules/ssh/pom.xml
----------------------------------------------------------------------
diff --git a/modules/ssh/pom.xml b/modules/ssh/pom.xml
index 1d3e4e1..9fddc21 100644
--- a/modules/ssh/pom.xml
+++ b/modules/ssh/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-ssh</artifactId>
- <version>1.3.1-SNAPSHOT</version>
+ <version>1.3.2-SNAPSHOT</version>
<dependencies>
<dependency>
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7d27103c/modules/tools/pom.xml
----------------------------------------------------------------------
diff --git a/modules/tools/pom.xml b/modules/tools/pom.xml
index 5179489..f58fbdc 100644
--- a/modules/tools/pom.xml
+++ b/modules/tools/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-tools</artifactId>
- <version>1.3.1-SNAPSHOT</version>
+ <version>1.3.2-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7d27103c/modules/urideploy/pom.xml
----------------------------------------------------------------------
diff --git a/modules/urideploy/pom.xml b/modules/urideploy/pom.xml
index 8c93df7..8c6224f 100644
--- a/modules/urideploy/pom.xml
+++ b/modules/urideploy/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-urideploy</artifactId>
- <version>1.3.1-SNAPSHOT</version>
+ <version>1.3.2-SNAPSHOT</version>
<dependencies>
<dependency>
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7d27103c/modules/visor-console-2.10/pom.xml
----------------------------------------------------------------------
diff --git a/modules/visor-console-2.10/pom.xml b/modules/visor-console-2.10/pom.xml
index f37d4ed..fe56751 100644
--- a/modules/visor-console-2.10/pom.xml
+++ b/modules/visor-console-2.10/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-visor-console_2.10</artifactId>
- <version>1.3.1-SNAPSHOT</version>
+ <version>1.3.2-SNAPSHOT</version>
<dependencies>
<dependency>
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7d27103c/modules/visor-console/pom.xml
----------------------------------------------------------------------
diff --git a/modules/visor-console/pom.xml b/modules/visor-console/pom.xml
index a2d25bc..b310d4c 100644
--- a/modules/visor-console/pom.xml
+++ b/modules/visor-console/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-visor-console</artifactId>
- <version>1.3.1-SNAPSHOT</version>
+ <version>1.3.2-SNAPSHOT</version>
<dependencies>
<dependency>
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7d27103c/modules/visor-plugins/pom.xml
----------------------------------------------------------------------
diff --git a/modules/visor-plugins/pom.xml b/modules/visor-plugins/pom.xml
index 4aca66b..4417b49 100644
--- a/modules/visor-plugins/pom.xml
+++ b/modules/visor-plugins/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-visor-plugins</artifactId>
- <version>1.3.1-SNAPSHOT</version>
+ <version>1.3.2-SNAPSHOT</version>
<dependencies>
<!-- Ignite dependencies -->
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7d27103c/modules/web/pom.xml
----------------------------------------------------------------------
diff --git a/modules/web/pom.xml b/modules/web/pom.xml
index 45ae1f0..74dd525 100644
--- a/modules/web/pom.xml
+++ b/modules/web/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-web</artifactId>
- <version>1.3.1-SNAPSHOT</version>
+ <version>1.3.2-SNAPSHOT</version>
<dependencies>
<dependency>
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7d27103c/modules/yardstick/pom.xml
----------------------------------------------------------------------
diff --git a/modules/yardstick/pom.xml b/modules/yardstick/pom.xml
index 4d9adb7..1044df1 100644
--- a/modules/yardstick/pom.xml
+++ b/modules/yardstick/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-yardstick</artifactId>
- <version>1.3.1-SNAPSHOT</version>
+ <version>1.3.2-SNAPSHOT</version>
<properties>
<yardstick.version>0.7.0</yardstick.version>
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7d27103c/modules/yarn/pom.xml
----------------------------------------------------------------------
diff --git a/modules/yarn/pom.xml b/modules/yarn/pom.xml
index 2679603..35728fa 100644
--- a/modules/yarn/pom.xml
+++ b/modules/yarn/pom.xml
@@ -31,7 +31,7 @@
</parent>
<artifactId>ignite-yarn</artifactId>
- <version>1.3.1-SNAPSHOT</version>
+ <version>1.3.2-SNAPSHOT</version>
<properties>
<hadoop.version>2.7.0</hadoop.version>
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7d27103c/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 85bfe14..29f5fa5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -32,7 +32,7 @@
<groupId>org.apache.ignite</groupId>
<artifactId>apache-ignite</artifactId>
- <version>1.3.1-SNAPSHOT</version>
+ <version>1.3.2-SNAPSHOT</version>
<packaging>pom</packaging>
<properties>
[21/21] 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/aef4919a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/aef4919a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/aef4919a
Branch: refs/heads/ignite-1121
Commit: aef4919a97cbc37e4d29695e2e62914726aa4d9c
Parents: 8fd577d 72b91c1
Author: sevdokimov <se...@jetbrains.com>
Authored: Mon Jul 20 14:35:42 2015 +0300
Committer: sevdokimov <se...@jetbrains.com>
Committed: Mon Jul 20 14:35:42 2015 +0300
----------------------------------------------------------------------
examples/config/js/example-query.xml | 91 ++++
examples/pom.xml | 6 +
.../ignite/examples/ExampleNodeStartup.java | 2 +-
examples/src/main/js/cache-query-example.js | 20 +-
.../JettyRestProcessorAbstractSelfTest.java | 506 ++++++++++++++++++-
.../ignite/compute/ComputeJobResultPolicy.java | 3 +-
.../ignite/internal/GridKernalContext.java | 6 +
.../ignite/internal/GridKernalContextImpl.java | 14 +-
.../ignite/internal/IgniteComponentType.java | 8 +
.../apache/ignite/internal/IgniteKernal.java | 1 +
.../failover/GridFailoverContextImpl.java | 28 +-
.../managers/failover/GridFailoverManager.java | 13 +-
.../processors/cache/GridCacheUtils.java | 4 +-
.../IgniteCacheObjectProcessorImpl.java | 10 +
.../processors/closure/AffinityTask.java | 35 ++
.../closure/GridClosureProcessor.java | 63 ++-
.../json/IgniteJsonNoopProcessor.java | 67 +++
.../processors/json/IgniteJsonProcessor.java | 71 +++
.../processors/query/GridQueryProcessor.java | 235 ++++++++-
.../handlers/query/QueryCommandHandler.java | 3 +
.../processors/task/GridTaskWorker.java | 24 +-
.../ignite/internal/util/IgniteUtils.java | 4 +-
.../plugin/security/SecurityPermission.java | 7 +-
.../ignite/spi/discovery/tcp/ServerImpl.java | 8 +-
.../ignite/spi/failover/FailoverContext.java | 18 +
.../spi/failover/always/AlwaysFailoverSpi.java | 25 +
.../IgniteClientReconnectFailoverTest.java | 47 +-
.../cache/CacheAffinityCallSelfTest.java | 172 +++++++
.../cache/GridCacheAffinityRoutingSelfTest.java | 157 +++++-
.../cache/IgniteCacheNearLockValueSelfTest.java | 2 +
.../spi/failover/GridFailoverTestContext.java | 10 +
.../ignite/testsuites/IgniteCacheTestSuite.java | 1 +
.../org/apache/ignite/JsonArrayBuilderImpl.java | 130 -----
.../java/org/apache/ignite/JsonArrayImpl.java | 131 -----
.../org/apache/ignite/JsonGeneratorImpl.java | 500 ------------------
.../org/apache/ignite/JsonLocationImpl.java | 60 ---
.../java/org/apache/ignite/JsonNumberImpl.java | 116 -----
.../apache/ignite/JsonObjectBuilderImpl.java | 141 ------
.../java/org/apache/ignite/JsonObjectImpl.java | 116 -----
.../org/apache/ignite/JsonProviderImpl.java | 104 ----
.../java/org/apache/ignite/JsonStringImpl.java | 71 ---
.../processors/json/IgniteJsonArray.java | 132 +++++
.../processors/json/IgniteJsonArrayBuilder.java | 130 +++++
.../processors/json/IgniteJsonGenerator.java | 500 ++++++++++++++++++
.../processors/json/IgniteJsonLocation.java | 60 +++
.../json/IgniteJsonMessageFactory.java | 36 ++
.../processors/json/IgniteJsonNumber.java | 116 +++++
.../processors/json/IgniteJsonObject.java | 117 +++++
.../json/IgniteJsonObjectBuilder.java | 141 ++++++
.../json/IgniteJsonProcessorImpl.java | 115 +++++
.../processors/json/IgniteJsonProvider.java | 104 ++++
.../processors/json/IgniteJsonString.java | 77 +++
.../processors/json/JsonCacheObject.java | 103 ++++
.../java/org/apache/ignite/json/IgniteJson.java | 36 ++
.../processors/json/IgniteJsonCacheTest.java | 196 +++++++
.../http/jetty/GridJettyRestHandler.java | 46 +-
.../ignite/schema/ui/SchemaImportApp.java | 36 +-
57 files changed, 3496 insertions(+), 1479 deletions(-)
----------------------------------------------------------------------
[08/21] incubator-ignite git commit: Merge branch 'ignite-962' into
ignite-961
Posted by se...@apache.org.
Merge branch 'ignite-962' 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/488ba593
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/488ba593
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/488ba593
Branch: refs/heads/ignite-1121
Commit: 488ba59366e6271a3926bfa9f7142b684aa7d1ba
Parents: f7bb17c e6ba441
Author: sboikov <sb...@gridgain.com>
Authored: Fri Jul 17 17:21:37 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Fri Jul 17 17:21:37 2015 +0300
----------------------------------------------------------------------
.../ignite/internal/GridKernalContext.java | 6 +
.../ignite/internal/GridKernalContextImpl.java | 14 +-
.../ignite/internal/IgniteComponentType.java | 8 +
.../apache/ignite/internal/IgniteKernal.java | 1 +
.../IgniteCacheObjectProcessorImpl.java | 10 +
.../json/IgniteJsonNoopProcessor.java | 67 +++
.../processors/json/IgniteJsonProcessor.java | 71 +++
.../processors/query/GridQueryProcessor.java | 235 ++++++++-
.../org/apache/ignite/JsonArrayBuilderImpl.java | 130 -----
.../java/org/apache/ignite/JsonArrayImpl.java | 131 -----
.../org/apache/ignite/JsonGeneratorImpl.java | 500 -------------------
.../org/apache/ignite/JsonLocationImpl.java | 60 ---
.../java/org/apache/ignite/JsonNumberImpl.java | 116 -----
.../apache/ignite/JsonObjectBuilderImpl.java | 141 ------
.../java/org/apache/ignite/JsonObjectImpl.java | 116 -----
.../org/apache/ignite/JsonProviderImpl.java | 104 ----
.../java/org/apache/ignite/JsonStringImpl.java | 71 ---
.../processors/json/IgniteJsonArray.java | 132 +++++
.../processors/json/IgniteJsonArrayBuilder.java | 130 +++++
.../processors/json/IgniteJsonGenerator.java | 500 +++++++++++++++++++
.../processors/json/IgniteJsonLocation.java | 60 +++
.../json/IgniteJsonMessageFactory.java | 36 ++
.../processors/json/IgniteJsonNumber.java | 116 +++++
.../processors/json/IgniteJsonObject.java | 117 +++++
.../json/IgniteJsonObjectBuilder.java | 141 ++++++
.../json/IgniteJsonProcessorImpl.java | 115 +++++
.../processors/json/IgniteJsonProvider.java | 104 ++++
.../processors/json/IgniteJsonString.java | 77 +++
.../processors/json/JsonCacheObject.java | 103 ++++
.../java/org/apache/ignite/json/IgniteJson.java | 36 ++
.../processors/json/IgniteJsonCacheTest.java | 194 +++++++
31 files changed, 2249 insertions(+), 1393 deletions(-)
----------------------------------------------------------------------
[18/21] incubator-ignite git commit: Fixed typo and minor fixes to
javadocs.
Posted by se...@apache.org.
Fixed typo and minor fixes to javadocs.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/ede96121
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/ede96121
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/ede96121
Branch: refs/heads/ignite-1121
Commit: ede961215ce3a596f7dcb90e82f48aa723d892bf
Parents: 192fefc
Author: AKuznetsov <ak...@gridgain.com>
Authored: Mon Jul 20 15:06:04 2015 +0700
Committer: AKuznetsov <ak...@gridgain.com>
Committed: Mon Jul 20 15:06:04 2015 +0700
----------------------------------------------------------------------
.../ignite/schema/ui/SchemaImportApp.java | 36 ++++++++++++++++----
1 file changed, 29 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ede96121/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/SchemaImportApp.java
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/SchemaImportApp.java b/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/SchemaImportApp.java
index 00d1bc8..7b9c220 100644
--- a/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/SchemaImportApp.java
+++ b/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/SchemaImportApp.java
@@ -109,7 +109,7 @@ public class SchemaImportApp extends Application {
"jdbc:mysql://[host]:[port]/[database]", "root"),
new Preset("mssql", "Microsoft SQL Server", "sqljdbc41.jar", "com.microsoft.sqlserver.jdbc.SQLServerDriver",
"jdbc:sqlserver://[host]:[port][;databaseName=database]", "sa"),
- new Preset("posgresql", "PostgreSQL", "postgresql-9.3.jdbc4.jar", "org.postgresql.Driver",
+ new Preset("postgresql", "PostgreSQL", "postgresql-9.3.jdbc4.jar", "org.postgresql.Driver",
"jdbc:postgresql://[host]:[port]/[database]", "sa"),
new Preset("custom", "Custom server...", "custom-jdbc.jar", "org.custom.Driver", "jdbc:custom", "sa")
};
@@ -444,6 +444,11 @@ public class SchemaImportApp extends Application {
final boolean singleXml = xmlSingleFileCh.isSelected();
Runnable task = new Task<Void>() {
+ /**
+ * @param pojo POJO descriptor to check.
+ * @param selected Selected flag.
+ * @param msg Message to show in case of check failed.
+ */
private void checkEmpty(final PojoDescriptor pojo, boolean selected, String msg) {
if (!selected) {
Platform.runLater(new Runnable() {
@@ -694,6 +699,8 @@ public class SchemaImportApp extends Application {
/**
* Create connection pane with controls.
+ *
+ * @return Pane with connection controls.
*/
private Pane createConnectionPane() {
connPnl = paneEx(10, 10, 0, 10);
@@ -1110,10 +1117,10 @@ public class SchemaImportApp extends Application {
if (curPojo != null) {
TableView.TableViewSelectionModel<PojoDescriptor> selMdl = pojosTbl.getSelectionModel();
- List<Integer> idxs = new ArrayList<>(selMdl.getSelectedIndices());
+ List<Integer> selIndices = new ArrayList<>(selMdl.getSelectedIndices());
- if (idxs.size() > 1) {
- for (Integer idx : idxs) {
+ if (selIndices.size() > 1) {
+ for (Integer idx : selIndices) {
if (pojos.get(idx) != curPojo)
selMdl.clearSelection(idx);
}
@@ -1242,6 +1249,7 @@ public class SchemaImportApp extends Application {
*
* @param key Property key.
* @param dflt Default value.
+ * @return Property value as string.
*/
private String getStringProp(String key, String dflt) {
String val = prefs.getProperty(key);
@@ -1267,6 +1275,7 @@ public class SchemaImportApp extends Application {
*
* @param key Property key.
* @param dflt Default value.
+ * @return Property value as int.
*/
private int getIntProp(String key, int dflt) {
String val = prefs.getProperty(key);
@@ -1297,6 +1306,7 @@ public class SchemaImportApp extends Application {
*
* @param key Property key.
* @param dflt Default value.
+ * @return Property value as boolean.
*/
private boolean getBoolProp(String key, boolean dflt) {
String val = prefs.getProperty(key);
@@ -1563,7 +1573,11 @@ public class SchemaImportApp extends Application {
/** Combo box. */
private final ComboBox<String> comboBox;
- /** Creates a ComboBox cell factory for use in TableColumn controls. */
+ /**
+ * Creates a ComboBox cell factory for use in TableColumn controls.
+ *
+ * @return Cell factory for cell with java types combobox.
+ */
public static Callback<TableColumn<PojoField, String>, TableCell<PojoField, String>> cellFactory() {
return new Callback<TableColumn<PojoField, String>, TableCell<PojoField, String>>() {
@Override public TableCell<PojoField, String> call(TableColumn<PojoField, String> col) {
@@ -1637,7 +1651,11 @@ public class SchemaImportApp extends Application {
* Special table cell to select schema or table.
*/
private static class PojoDescriptorCell extends TableCell<PojoDescriptor, Boolean> {
- /** Creates a ComboBox cell factory for use in TableColumn controls. */
+ /**
+ * Creates a ComboBox cell factory for use in TableColumn controls.
+ *
+ * @return Cell factory for schema / table selection.
+ */
public static Callback<TableColumn<PojoDescriptor, Boolean>, TableCell<PojoDescriptor, Boolean>> cellFactory() {
return new Callback<TableColumn<PojoDescriptor, Boolean>, TableCell<PojoDescriptor, Boolean>>() {
@Override public TableCell<PojoDescriptor, Boolean> call(TableColumn<PojoDescriptor, Boolean> col) {
@@ -1694,7 +1712,11 @@ public class SchemaImportApp extends Application {
* Special table cell to select "used" fields for code generation.
*/
private static class PojoFieldUseCell extends TableCell<PojoField, Boolean> {
- /** Creates a ComboBox cell factory for use in TableColumn controls. */
+ /**
+ * Creates a ComboBox cell factory for use in TableColumn controls.
+ *
+ * @return Cell factory for used fields selection.
+ */
public static Callback<TableColumn<PojoField, Boolean>, TableCell<PojoField, Boolean>> cellFactory() {
return new Callback<TableColumn<PojoField, Boolean>, TableCell<PojoField, Boolean>>() {
@Override public TableCell<PojoField, Boolean> call(TableColumn<PojoField, Boolean> col) {
[16/21] 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/595fe6ed
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/595fe6ed
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/595fe6ed
Branch: refs/heads/ignite-1121
Commit: 595fe6edc1139ceb1061155c2dffacc963a30844
Parents: d815e51 f557728
Author: ivasilinets <iv...@gridgain.com>
Authored: Mon Jul 20 10:41:12 2015 +0300
Committer: ivasilinets <iv...@gridgain.com>
Committed: Mon Jul 20 10:41:12 2015 +0300
----------------------------------------------------------------------
.../apache/ignite/plugin/security/SecurityPermission.java | 7 +++++--
.../java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java | 8 +++-----
2 files changed, 8 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
[03/21] incubator-ignite git commit: GG-10556 Fixed stuck on
unmarshal security subject.
Posted by se...@apache.org.
GG-10556 Fixed stuck on unmarshal security subject.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/6711d2c7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/6711d2c7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/6711d2c7
Branch: refs/heads/ignite-1121
Commit: 6711d2c799b99d7a0ae3855475cccafbf362f5dd
Parents: 7d27103
Author: nikolay_tikhonov <nt...@gridgain.com>
Authored: Wed Jul 15 10:30:12 2015 +0300
Committer: Alexey Goncharuk <ag...@gridgain.com>
Committed: Fri Jul 17 00:05:31 2015 -0700
----------------------------------------------------------------------
.../java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/6711d2c7/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
index d51293e..a5ae5a9 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
@@ -631,8 +631,7 @@ class ServerImpl extends TcpDiscoveryImpl {
Map<String, Object> attrs = new HashMap<>(locNode.attributes());
- attrs.put(IgniteNodeAttributes.ATTR_SECURITY_SUBJECT,
- spi.ignite().configuration().getMarshaller().marshal(subj));
+ attrs.put(IgniteNodeAttributes.ATTR_SECURITY_SUBJECT, spi.marsh.marshal(subj));
attrs.remove(IgniteNodeAttributes.ATTR_SECURITY_CREDENTIALS);
locNode.setAttributes(attrs);
@@ -2586,8 +2585,7 @@ class ServerImpl extends TcpDiscoveryImpl {
// Stick in authentication subject to node (use security-safe attributes for copy).
Map<String, Object> attrs = new HashMap<>(node.getAttributes());
- attrs.put(IgniteNodeAttributes.ATTR_SECURITY_SUBJECT,
- spi.ignite().configuration().getMarshaller().marshal(subj));
+ attrs.put(IgniteNodeAttributes.ATTR_SECURITY_SUBJECT, spi.marsh.marshal(subj));
node.setAttributes(attrs);
}
@@ -2935,7 +2933,7 @@ class ServerImpl extends TcpDiscoveryImpl {
else {
SecurityContext subj = spi.nodeAuth.authenticateNode(node, cred);
- SecurityContext coordSubj = spi.ignite().configuration().getMarshaller().unmarshal(
+ SecurityContext coordSubj = spi.marsh.unmarshal(
node.<byte[]>attribute(IgniteNodeAttributes.ATTR_SECURITY_SUBJECT),
U.gridClassLoader());