You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2016/09/08 15:40:43 UTC
[01/50] [abbrv] ignite git commit: IGNITE-3726 .NET: Remove summaries
from NuSpec
Repository: ignite
Updated Branches:
refs/heads/ignite-961 297e0a668 -> 7e829bc84
IGNITE-3726 .NET: Remove summaries from NuSpec
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/a2fecaf5
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/a2fecaf5
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/a2fecaf5
Branch: refs/heads/ignite-961
Commit: a2fecaf5f748732a2d3c29bf51ae872c22e01f79
Parents: 6f870fd
Author: Pavel Tupitsyn <pt...@apache.org>
Authored: Wed Aug 24 18:33:08 2016 +0300
Committer: Pavel Tupitsyn <pt...@apache.org>
Committed: Wed Aug 24 18:33:08 2016 +0300
----------------------------------------------------------------------
.../dotnet/Apache.Ignite.AspNet/Apache.Ignite.AspNet.nuspec | 3 ---
.../dotnet/Apache.Ignite.Core/Apache.Ignite.Core.Schema.nuspec | 1 -
.../platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.nuspec | 3 ---
.../platforms/dotnet/Apache.Ignite.Linq/Apache.Ignite.Linq.nuspec | 3 ---
4 files changed, 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/a2fecaf5/modules/platforms/dotnet/Apache.Ignite.AspNet/Apache.Ignite.AspNet.nuspec
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.AspNet/Apache.Ignite.AspNet.nuspec b/modules/platforms/dotnet/Apache.Ignite.AspNet/Apache.Ignite.AspNet.nuspec
index 2324faa..3b3b5ac 100644
--- a/modules/platforms/dotnet/Apache.Ignite.AspNet/Apache.Ignite.AspNet.nuspec
+++ b/modules/platforms/dotnet/Apache.Ignite.AspNet/Apache.Ignite.AspNet.nuspec
@@ -44,9 +44,6 @@ Ideal for web farms: share cached data between servers effortlessly.
More info: https://apacheignite-net.readme.io/
</description>
- <summary>
- Apache Ignite ASP.NET Integration
- </summary>
<releaseNotes></releaseNotes>
<copyright>Copyright 2016</copyright>
<tags>OutputCacheProvider Apache Ignite In-Memory Distributed Computing SQL NoSQL Grid Map Reduce Cache</tags>
http://git-wip-us.apache.org/repos/asf/ignite/blob/a2fecaf5/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.Schema.nuspec
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.Schema.nuspec b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.Schema.nuspec
index 367bdd5..e57e371 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.Schema.nuspec
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.Schema.nuspec
@@ -36,7 +36,6 @@ nuget pack Apache.Ignite.Schema.nuspec -Version 1.6.1
<projectUrl>https://ignite.apache.org/</projectUrl>
<iconUrl>https://ignite.apache.org/images/logo_ignite_32_32.png</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
- <summary>Enables Intellisense(TM) when editing IgniteConfigurationSection in app.config and web.config.</summary>
<description>
XSD file describes the structure of IgniteConfigurationSection and enables Intellisense(TM) when editing IgniteConfigurationSection in app.config and web.config in Visual Studio.
http://git-wip-us.apache.org/repos/asf/ignite/blob/a2fecaf5/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.nuspec
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.nuspec b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.nuspec
index bb6227e..8621103 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.nuspec
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.nuspec
@@ -44,9 +44,6 @@ Apache Ignite In-Memory Data Fabric is a high-performance, integrated and distri
More info: https://apacheignite-net.readme.io/
</description>
- <summary>
- High-performance in-memory platform for computing and transacting on large-scale data sets in real-time.
- </summary>
<releaseNotes></releaseNotes>
<copyright>Copyright 2016</copyright>
<tags>Apache Ignite In-Memory Distributed Computing SQL NoSQL Grid Map Reduce Cache linqpad-samples</tags>
http://git-wip-us.apache.org/repos/asf/ignite/blob/a2fecaf5/modules/platforms/dotnet/Apache.Ignite.Linq/Apache.Ignite.Linq.nuspec
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Linq/Apache.Ignite.Linq.nuspec b/modules/platforms/dotnet/Apache.Ignite.Linq/Apache.Ignite.Linq.nuspec
index 088ca13..330ed29 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Linq/Apache.Ignite.Linq.nuspec
+++ b/modules/platforms/dotnet/Apache.Ignite.Linq/Apache.Ignite.Linq.nuspec
@@ -46,9 +46,6 @@ All Ignite SQL features are supported: distributed joins, groupings, aggregates,
More info: https://apacheignite-net.readme.io/
</description>
- <summary>
- LINQ Provider for Apache Ignite
- </summary>
<releaseNotes></releaseNotes>
<copyright>Copyright 2016</copyright>
<tags>Apache Ignite In-Memory Distributed Computing SQL NoSQL LINQ Grid Map Reduce Cache linqpad-samples</tags>
[22/50] [abbrv] ignite git commit: .NET: Remove unused assembly
references
Posted by sb...@apache.org.
.NET: Remove unused assembly references
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/c2f029fc
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/c2f029fc
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/c2f029fc
Branch: refs/heads/ignite-961
Commit: c2f029fc647b89a3d9a656f50ca356e344c5a6d2
Parents: 2d5d5bc
Author: Pavel Tupitsyn <pt...@apache.org>
Authored: Mon Aug 29 19:00:31 2016 +0300
Committer: Pavel Tupitsyn <pt...@apache.org>
Committed: Mon Aug 29 19:00:31 2016 +0300
----------------------------------------------------------------------
.../Apache.Ignite.Core.Tests.TestDll.csproj | 5 -----
.../dotnet/Apache.Ignite.Linq/Apache.Ignite.Linq.csproj | 5 -----
.../dotnet/Apache.Ignite.NLog/Apache.Ignite.NLog.csproj | 5 -----
modules/platforms/dotnet/Apache.Ignite/Apache.Ignite.csproj | 5 -----
4 files changed, 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2f029fc/modules/platforms/dotnet/Apache.Ignite.Core.Tests.TestDll/Apache.Ignite.Core.Tests.TestDll.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests.TestDll/Apache.Ignite.Core.Tests.TestDll.csproj b/modules/platforms/dotnet/Apache.Ignite.Core.Tests.TestDll/Apache.Ignite.Core.Tests.TestDll.csproj
index 031f6cc..b33023a 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests.TestDll/Apache.Ignite.Core.Tests.TestDll.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests.TestDll/Apache.Ignite.Core.Tests.TestDll.csproj
@@ -33,11 +33,6 @@
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
- <Reference Include="System.Xml.Linq" />
- <Reference Include="System.Data.DataSetExtensions" />
- <Reference Include="Microsoft.CSharp" />
- <Reference Include="System.Data" />
- <Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2f029fc/modules/platforms/dotnet/Apache.Ignite.Linq/Apache.Ignite.Linq.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Linq/Apache.Ignite.Linq.csproj b/modules/platforms/dotnet/Apache.Ignite.Linq/Apache.Ignite.Linq.csproj
index 79b52bd..40e4db6 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Linq/Apache.Ignite.Linq.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite.Linq/Apache.Ignite.Linq.csproj
@@ -44,11 +44,6 @@
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
- <Reference Include="System.Xml.Linq" />
- <Reference Include="System.Data.DataSetExtensions" />
- <Reference Include="Microsoft.CSharp" />
- <Reference Include="System.Data" />
- <Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="CacheExtensions.cs" />
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2f029fc/modules/platforms/dotnet/Apache.Ignite.NLog/Apache.Ignite.NLog.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.NLog/Apache.Ignite.NLog.csproj b/modules/platforms/dotnet/Apache.Ignite.NLog/Apache.Ignite.NLog.csproj
index c8d8705..22ecb1a 100644
--- a/modules/platforms/dotnet/Apache.Ignite.NLog/Apache.Ignite.NLog.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite.NLog/Apache.Ignite.NLog.csproj
@@ -42,11 +42,6 @@
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
- <Reference Include="System.Xml.Linq" />
- <Reference Include="System.Data.DataSetExtensions" />
- <Reference Include="Microsoft.CSharp" />
- <Reference Include="System.Data" />
- <Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="IgniteNLogLogger.cs" />
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2f029fc/modules/platforms/dotnet/Apache.Ignite/Apache.Ignite.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite/Apache.Ignite.csproj b/modules/platforms/dotnet/Apache.Ignite/Apache.Ignite.csproj
index 747e1a5..e98ddd1 100644
--- a/modules/platforms/dotnet/Apache.Ignite/Apache.Ignite.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite/Apache.Ignite.csproj
@@ -36,11 +36,6 @@
<Reference Include="System.Configuration.Install" />
<Reference Include="System.Core" />
<Reference Include="System.ServiceProcess" />
- <Reference Include="System.Xml.Linq" />
- <Reference Include="System.Data.DataSetExtensions" />
- <Reference Include="Microsoft.CSharp" />
- <Reference Include="System.Data" />
- <Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Config\AppSettingsConfigurator.cs" />
[49/50] [abbrv] ignite git commit: Merge master branch to ignite-961
branch
Posted by sb...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/7e829bc8/examples/pom.xml
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/7e829bc8/modules/clients/src/test/java/org/apache/ignite/internal/client/ClientDefaultCacheSelfTest.java
----------------------------------------------------------------------
diff --cc modules/clients/src/test/java/org/apache/ignite/internal/client/ClientDefaultCacheSelfTest.java
index 7c3dd07,09f99fd..3028add
--- a/modules/clients/src/test/java/org/apache/ignite/internal/client/ClientDefaultCacheSelfTest.java
+++ b/modules/clients/src/test/java/org/apache/ignite/internal/client/ClientDefaultCacheSelfTest.java
@@@ -17,12 -17,18 +17,17 @@@
package org.apache.ignite.internal.client;
- import java.io.BufferedReader;
+ import com.fasterxml.jackson.databind.JsonNode;
+ import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
+ import java.io.InputStream;
import java.io.InputStreamReader;
+ import java.io.LineNumberReader;
import java.net.URL;
import java.net.URLConnection;
+ import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
+ import java.util.Map;
-import java.util.UUID;
import org.apache.ignite.cache.CacheAtomicityMode;
import org.apache.ignite.cache.CacheMode;
import org.apache.ignite.configuration.CacheConfiguration;
http://git-wip-us.apache.org/repos/asf/ignite/blob/7e829bc8/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java
----------------------------------------------------------------------
diff --cc modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java
index 0272370,8d3ab74..3e29641
--- 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,30 -23,26 +23,34 @@@ import java.io.IOException
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
+import java.io.PrintStream;
import java.io.Serializable;
+ import java.io.UnsupportedEncodingException;
+import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
+import java.nio.charset.Charset;
+ import java.nio.charset.StandardCharsets;
+ import java.text.DateFormat;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
- import java.util.List;
+ import java.util.Locale;
import java.util.Map;
+ import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
+import java.util.regex.Pattern;
+import javax.json.JsonObject;
+import javax.json.JsonObjectBuilder;
+import javax.json.spi.JsonProvider;
- import net.sf.json.JSONNull;
- import net.sf.json.JSONObject;
+import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
+ import org.apache.ignite.cache.CacheAtomicityMode;
import org.apache.ignite.cache.CacheMode;
import org.apache.ignite.cache.CachePeekMode;
+ import org.apache.ignite.cache.CacheWriteSynchronizationMode;
import org.apache.ignite.cache.query.SqlQuery;
import org.apache.ignite.cache.query.annotations.QuerySqlField;
import org.apache.ignite.cluster.ClusterNode;
@@@ -52,12 -55,56 +63,57 @@@ import org.apache.ignite.internal.proce
import org.apache.ignite.internal.processors.cache.query.GridCacheSqlIndexMetadata;
import org.apache.ignite.internal.processors.cache.query.GridCacheSqlMetadata;
import org.apache.ignite.internal.processors.rest.handlers.GridRestCommandHandler;
+ import org.apache.ignite.internal.processors.rest.protocols.http.jetty.GridJettyObjectMapper;
+ import org.apache.ignite.internal.util.lang.GridTuple3;
+ import org.apache.ignite.internal.util.typedef.C1;
import org.apache.ignite.internal.util.typedef.F;
- import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.internal.util.typedef.P1;
+ import org.apache.ignite.internal.util.typedef.T2;
+ import org.apache.ignite.internal.util.typedef.internal.SB;
+ import org.apache.ignite.internal.util.typedef.internal.U;
+ import org.apache.ignite.internal.visor.cache.VisorCacheClearTask;
+ import org.apache.ignite.internal.visor.cache.VisorCacheConfigurationCollectorTask;
+ import org.apache.ignite.internal.visor.cache.VisorCacheLoadTask;
+ import org.apache.ignite.internal.visor.cache.VisorCacheMetadataTask;
+ import org.apache.ignite.internal.visor.cache.VisorCacheMetricsCollectorTask;
+ import org.apache.ignite.internal.visor.cache.VisorCacheNodesTask;
+ import org.apache.ignite.internal.visor.cache.VisorCacheRebalanceTask;
+ import org.apache.ignite.internal.visor.cache.VisorCacheResetMetricsTask;
+ import org.apache.ignite.internal.visor.cache.VisorCacheStartTask;
+ import org.apache.ignite.internal.visor.cache.VisorCacheStopTask;
+ import org.apache.ignite.internal.visor.cache.VisorCacheSwapBackupsTask;
+ import org.apache.ignite.internal.visor.compute.VisorComputeCancelSessionsTask;
+ import org.apache.ignite.internal.visor.compute.VisorComputeResetMetricsTask;
+ import org.apache.ignite.internal.visor.compute.VisorComputeToggleMonitoringTask;
+ import org.apache.ignite.internal.visor.compute.VisorGatewayTask;
+ import org.apache.ignite.internal.visor.debug.VisorThreadDumpTask;
+ import org.apache.ignite.internal.visor.file.VisorFileBlockTask;
+ import org.apache.ignite.internal.visor.file.VisorLatestTextFilesTask;
+ import org.apache.ignite.internal.visor.igfs.VisorIgfsFormatTask;
+ import org.apache.ignite.internal.visor.igfs.VisorIgfsProfilerClearTask;
+ import org.apache.ignite.internal.visor.igfs.VisorIgfsProfilerTask;
+ import org.apache.ignite.internal.visor.igfs.VisorIgfsResetMetricsTask;
+ import org.apache.ignite.internal.visor.igfs.VisorIgfsSamplingStateTask;
+ import org.apache.ignite.internal.visor.log.VisorLogSearchTask;
+ import org.apache.ignite.internal.visor.misc.VisorAckTask;
+ import org.apache.ignite.internal.visor.misc.VisorLatestVersionTask;
+ import org.apache.ignite.internal.visor.misc.VisorResolveHostNameTask;
+ import org.apache.ignite.internal.visor.node.VisorNodeConfigurationCollectorTask;
+ import org.apache.ignite.internal.visor.node.VisorNodeDataCollectorTask;
+ import org.apache.ignite.internal.visor.node.VisorNodeDataCollectorTaskArg;
+ import org.apache.ignite.internal.visor.node.VisorNodeEventsCollectorTask;
+ import org.apache.ignite.internal.visor.node.VisorNodeGcTask;
+ import org.apache.ignite.internal.visor.node.VisorNodePingTask;
+ import org.apache.ignite.internal.visor.node.VisorNodeSuppressedErrorsTask;
+ import org.apache.ignite.internal.visor.query.VisorQueryArg;
+ import org.apache.ignite.internal.visor.query.VisorQueryCleanupTask;
+ import org.apache.ignite.internal.visor.query.VisorQueryNextPageTask;
+ import org.apache.ignite.internal.visor.query.VisorQueryTask;
+import org.apache.ignite.json.IgniteJson;
import org.apache.ignite.lang.IgniteBiPredicate;
+ import org.apache.ignite.lang.IgniteBiTuple;
import org.apache.ignite.lang.IgnitePredicate;
+ import org.apache.ignite.lang.IgniteUuid;
import org.apache.ignite.testframework.GridTestUtils;
import static org.apache.ignite.IgniteSystemProperties.IGNITE_JETTY_PORT;
@@@ -142,66 -198,54 +207,108 @@@ public abstract class JettyRestProcesso
}
/**
+ * Runs post request.
+ *
+ * @param params Url parameters.
+ * @param postParams Post parameters.
+ * @return Request result.
+ * @throws Exception If failed.
+ */
+ protected String makePostRequest(Map<String, String> params, String postParams) throws Exception {
+ String addr = "http://" + LOC_HOST + ":" + restPort() + "/ignite?";
+
+ for (Map.Entry<String, String> e : params.entrySet())
+ addr += e.getKey() + '=' + e.getValue() + '&';
+
+ URL url = new URL(addr);
+
+ byte[] data = postParams.getBytes(Charset.forName("UTF-8"));
+
+ HttpURLConnection conn = (HttpURLConnection)url.openConnection();
+
+ conn.setRequestMethod("POST");
+
+ conn.setRequestProperty("Content-Type", "application/json");
+
+ String signature = signature();
+
+ if (signature != null)
+ conn.setRequestProperty("X-Signature", signature);
+
+ conn.setRequestProperty("Content-Length", Integer.toString(data.length));
+
+ conn.setUseCaches(false);
+ conn.setDoOutput(true);
+
+ try (PrintStream wr = new PrintStream(conn.getOutputStream())) {
+ wr.print(postParams);
+ wr.flush();
+ wr.close();
+ }
+
+ InputStream in = conn.getInputStream();
+
+ LineNumberReader rdr = new LineNumberReader(new InputStreamReader(in));
+
+ StringBuilder buf = new StringBuilder(256);
+
+ for (String line = rdr.readLine(); line != null; line = rdr.readLine())
+ buf.append(line);
+
+ in.close();
+
+ return buf.toString();
+ }
+
+ /**
- * @param json JSON response.
- * @param ptrn Pattern to match.
+ * @param content Content to check.
*/
- @SuppressWarnings("TypeMayBeWeakened")
- private void jsonEquals(String json, String ptrn) {
- assertTrue("JSON mismatch [json=" + json + ", ptrn=" + ptrn + ']', Pattern.matches(ptrn, json));
+ private void assertResponseContainsError(String content) throws IOException {
+ assertNotNull(content);
+ assertFalse(content.isEmpty());
+
+ JsonNode node = JSON_MAPPER.readTree(content);
+
+ assertEquals(1, node.get("successStatus").asInt());
+ assertFalse(node.get("error").asText().isEmpty());
+ assertTrue(node.get("response").isNull());
+ assertTrue(node.get("sessionToken").asText().isEmpty());
+ }
+
+ /**
+ * @param content Content to check.
+ * @param err Error message.
+ */
+ private void assertResponseContainsError(String content, String err) throws IOException {
+ assertNotNull(content);
+ assertFalse(content.isEmpty());
+
+ assertNotNull(err);
+
+ JsonNode node = JSON_MAPPER.readTree(content);
+
+ assertEquals(1, node.get("successStatus").asInt());
+
+ assertTrue(node.get("response").isNull());
+ assertEquals(err, node.get("error").asText());
+ }
+
+ /**
+ * @param content Content to check.
+ */
+ private JsonNode jsonCacheOperationResponse(String content, boolean bulk) throws IOException {
+ assertNotNull(content);
+ assertFalse(content.isEmpty());
+
+ JsonNode node = JSON_MAPPER.readTree(content);
+
+ assertEquals(bulk, node.get("affinityNodeId").asText().isEmpty());
+ assertEquals(0, node.get("successStatus").asInt());
+ assertTrue(node.get("error").asText().isEmpty());
+
+ assertNotSame(securityEnabled(), node.get("sessionToken").asText().isEmpty());
+
+ return node.get("response");
}
/**
@@@ -218,39 -259,13 +322,41 @@@
}
/**
+ * @param success Success flag.
+ * @return Regex pattern for JSON.
+ */
+ private String cacheNullPattern(boolean success) {
- return "\\{\\\"affinityNodeId\\\":\\\"\\w{8}-\\w{4}-\\w{4}-\\w{4}-\\w{12}\\\"\\," +
++ return "\\{" +
++ "\\\"successStatus\\\":" + (success ? 0 : 1) + "\\," +
++ "\\\"affinityNodeId\\\":\\\"\\w{8}-\\w{4}-\\w{4}-\\w{4}-\\w{12}\\\"\\," +
+ "\\\"error\\\":\\\"\\\"\\," +
- "\\\"response\\\":null\\," +
- "\\\"sessionToken\\\":\\\"\\\"," +
- "\\\"successStatus\\\":" + (success ? 0 : 1) + "\\}";
++ "\\\"sessionToken\\\":\\\".*\\\"\\," +
++ "\\\"response\\\":null" +
++ "\\}";
+ }
+
+ /**
+ * @param err Error.
+ * @return Regex pattern for JSON.
+ */
- private String errorPattern(String err) {
- return "\\{" +
- "\\\"error\\\":\\\"" + err + "\\\"\\," +
- "\\\"response\\\":null\\," +
- "\\\"sessionToken\\\":\\\"\\\"," +
- "\\\"successStatus\\\":" + 1 + "\\}";
++ private JsonNode errorNode(String err) throws IOException {
++ String s = "{" +
++ "\"error\":\"" + err + "\"," +
++ "\"response\":null," +
++ "\"sessionToken\":\"\"," +
++ "\"successStatus\":" + 1 + "}";
++
++ return JSON_MAPPER.readTree(s);
+ }
+
+ /**
+ * @param content Content to check.
* @param res Response.
- * @param success Success flag.
- * @return Regex pattern for JSON.
*/
- private String integerPattern(int res, boolean success) {
- return "\\{\\\"error\\\":\\\"\\\"\\," +
- "\\\"response\\\":" + res + "\\," +
- "\\\"sessionToken\\\":\\\"" + (securityEnabled() && success ? ".+" : "") + "\\\"," +
- "\\\"successStatus\\\":" + (success ? 0 : 1) + "\\}";
+ private void assertCacheBulkOperation(String content, Object res) throws IOException {
+ JsonNode ret = jsonCacheOperationResponse(content, true);
+
+ assertEquals(String.valueOf(res), ret.asText());
}
/**
@@@ -414,265 -517,12 +608,263 @@@
/**
* @throws Exception If failed.
*/
+ public void testGetPost() throws Exception {
+ jcache().put("key0", "val0");
+
+ String val = "{\"key\":\"key0\"}";
+ String ret = makePostRequest(F.asMap("cmd", GridRestCommand.CACHE_GET.key()), val);
+
+ assertNotNull(ret);
+ assertTrue(!ret.isEmpty());
+
+ info("Get command result: " + ret);
+
+ jsonEquals(ret, cachePattern("val0", true));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testReplacePost() throws Exception {
+ jcache().put("key0", "val0");
+
+ String val = "{\"key\":\"key0\", \"val\":\"val2\", \"oldVal\":\"val1\"}";
+ String ret = makePostRequest(F.asMap("cmd", GridRestCommand.CACHE_REPLACE_VALUE.key()), val);
+
+ assertNotNull(ret);
+ assertTrue(!ret.isEmpty());
+
+ info("Get command result: " + ret);
+
+ jsonEquals(ret, cachePattern(false, true));
+
+ val = "{\"key\":\"key0\", \"val\":\"val2\"}";
+ ret = makePostRequest(F.asMap("cmd", GridRestCommand.CACHE_GET_AND_REPLACE.key()),
+ val);
+
+ jsonEquals(ret, cachePattern("val0", true));
+
+ assertEquals("val2", grid(0).cache(null).get("key0"));
+
+ val = "{\"key\":\"key0\", \"val\":\"val3\"}";
+ ret = makePostRequest(F.asMap("cmd", GridRestCommand.CACHE_REPLACE.key()), val);
+
+ assertNotNull(ret);
+ assertTrue(!ret.isEmpty());
+
+ info("Get command result: " + ret);
+
+ assertEquals("val3", grid(0).cache(null).get("key0"));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testRemovePost() throws Exception {
+ jcache().put("key0", "val0");
+
+ String val = "{\"key\":\"key0\", \"val\":\"val2\"}";
+ String ret = makePostRequest(F.asMap("cmd", GridRestCommand.CACHE_REMOVE_VALUE.key()), val);
+
+ assertNotNull(ret);
+ assertTrue(!ret.isEmpty());
+
+ info("Get command result: " + ret);
+
+ jsonEquals(ret, cachePattern(false, true));
+
+ assertEquals("val0", grid(0).cache(null).get("key0"));
+
+ val = "{\"key\":\"key0\"}";
+ ret = makePostRequest(F.asMap("cmd", GridRestCommand.CACHE_GET_AND_REMOVE.key()), val);
+
+ jsonEquals(ret, cachePattern("val0", true));
+
+ assertNull(grid(0).cache(null).get("key0"));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testRemoveAllPost() throws Exception {
+ jcache().put("key0", "val0");
+ jcache().put("key1", "val1");
+
+ String val = "{\"keys\": [\"key0\", \"key1\"]}";
+ String ret = makePostRequest(F.asMap("cmd", GridRestCommand.CACHE_REMOVE_ALL.key()), val);
+
+ assertNotNull(ret);
+ assertTrue(!ret.isEmpty());
+
+ assertEquals(0, grid(0).cache(null).size());
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPutPost() throws Exception {
+ String val = "{\"key\":\"key0\",\"val\":\"val0\"}";
+ String ret = makePostRequest(F.asMap("cmd", GridRestCommand.CACHE_PUT.key()), val);
+
+ assertNotNull(ret);
+ assertTrue(!ret.isEmpty());
+
+ info("Result: " + ret);
+
+ assertEquals(1, grid(0).cache(null).size());
+ assertNotNull(grid(0).cache(null).get("key0"));
+
+ val = "{\"key\":\"key0\"}";
+ ret = makePostRequest(F.asMap("cmd", GridRestCommand.CACHE_CONTAINS_KEY.key()), val);
+
+ assertNotNull(ret);
+ assertTrue(!ret.isEmpty());
+
+ jsonEquals(ret, cachePattern(true, true));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPutJsonKey() throws Exception {
+ String val = "{\"key\":{\"id\": \"1\"},\"val\":\"val0\"}";
+ String ret = makePostRequest(F.asMap("cmd", GridRestCommand.CACHE_PUT.key()), val);
+
+ assertNotNull(ret);
+ assertTrue(!ret.isEmpty());
+
+ info("Result: " + ret);
+
+ JsonProvider provider = IgniteJson.jsonProvider(ignite(0));
+
+ JsonObjectBuilder builder = provider.createObjectBuilder();
+
+ builder.add("id", "1");
+
+ JsonObject key = builder.build();
+
+ assertEquals("val0", grid(0).cache(null).get(key));
+
+ val = "{\"key\":{\"id\": \"1\"}}";
+ ret = makePostRequest(F.asMap("cmd", GridRestCommand.CACHE_CONTAINS_KEY.key()), val);
+
+ assertNotNull(ret);
+ assertTrue(!ret.isEmpty());
+
+ jsonEquals(ret, cachePattern(true, true));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPutJsonValue() throws Exception {
+ String cmd = "{\"key\":\"key0\",\"val\":{\"id\": \"1\"}}";
+ String ret = makePostRequest(F.asMap("cmd", GridRestCommand.CACHE_PUT.key()), cmd);
+
+ assertNotNull(ret);
+ assertTrue(!ret.isEmpty());
+
+ info("Result: " + ret);
+
+ JsonObject val = (JsonObject)grid(0).cache(null).get("key0");
+
+ assertEquals("1", val.getString("id"));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testIncorrectPutPost() throws Exception {
+ String val = "{\"key\":\"key0\"}";
+ String ret = makePostRequest(F.asMap("cmd", GridRestCommand.CACHE_PUT.key()), val);
+
+ assertNotNull(ret);
+ assertTrue(!ret.isEmpty());
- jsonEquals(ret, errorPattern("Failed to find mandatory parameter in request: val"));
++
++ assertEquals(errorNode("Failed to find mandatory parameter in request: val"), JSON_MAPPER.readTree(ret));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testGetAndPutPost() throws Exception {
+ String val = "{\"key\":\"key0\", \"val\":\"val0\"}";
+ String ret = makePostRequest(F.asMap("cmd", GridRestCommand.CACHE_GET_AND_PUT.key()), val);
+
+ assertNotNull(ret);
+ assertTrue(!ret.isEmpty());
+
+ jsonEquals(ret, cacheNullPattern(true));
+
+ assertNotNull(grid(0).cache(null).get("key0"));
+
+ val = "{\"key\": \"key0\", \"val\":\"val1\"}";
+ ret = makePostRequest(F.asMap("cmd", GridRestCommand.CACHE_GET_AND_PUT_IF_ABSENT.key()), val);
+
+ assertNotNull(ret);
+ assertTrue(!ret.isEmpty());
+
+ jsonEquals(ret, cachePattern("val0", true));
+
+ assertEquals("val0", grid(0).cache(null).get("key0"));
+
+ val = "{\"key\": \"key0\"}";
+ ret = makePostRequest(F.asMap("cmd", GridRestCommand.CACHE_REMOVE.key()), val);
+
+ assertNotNull(ret);
+ assertTrue(!ret.isEmpty());
+
+ assertNull(grid(0).cache(null).get("key0"));
+
+ val = "{\"key\": \"key0\", \"val\":\"val1\"}";
+ ret = makePostRequest(F.asMap("cmd", GridRestCommand.CACHE_PUT_IF_ABSENT.key()), val);
+
+ assertNotNull(ret);
+ assertTrue(!ret.isEmpty());
+
+ jsonEquals(ret, cachePattern(true, true));
+
+ assertEquals("val1", grid(0).cache(null).get("key0"));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPutAllPost() throws Exception {
+ String val = "{\"entries\": [{\"key\":\"key0\", \"value\": \"val0\"}, {\"key\":\"key1\", \"value\":\"val1\"}]}";
+ String ret = makePostRequest(F.asMap("cmd", GridRestCommand.CACHE_PUT_ALL.key()), val);
+
+ assertNotNull(ret);
+ assertTrue(!ret.isEmpty());
+
+ assertNotNull(grid(0).cache(null).get("key0"));
+
+ val = "{\"keys\": [\"key0\",\"key1\"]}";
+ ret = makePostRequest(F.asMap("cmd", GridRestCommand.CACHE_CONTAINS_KEYS.key()), val);
+
+ assertNotNull(ret);
+ assertTrue(!ret.isEmpty());
+
+ jsonEquals(ret, cacheBulkPattern(true, true));
+
+ ret = makePostRequest(F.asMap("cmd", GridRestCommand.CACHE_GET_ALL.key()), val);
+
+ assertNotNull(ret);
+ assertTrue(!ret.isEmpty());
+
+ jsonEquals(ret, cacheBulkPattern(
- "\\[\\{\\\"key\\\":\\\"key0\\\",\\\"value\\\":\\\"val0\\\"\\}," +
- "\\{\\\"key\\\":\\\"key1\\\",\\\"value\\\":\\\"val1\\\"\\}\\]", true));
++ "\\{\\\"key0\\\":\\\"val0\\\",\\\"key1\\\":\\\"val1\\\"\\}", true));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
public void testGetAll() throws Exception {
- jcache().put("getKey1", "getVal1");
- jcache().put("getKey2", "getVal2");
+ final Map<String, String> entries = F.asMap("getKey1", "getVal1", "getKey2", "getVal2");
- String ret = content(F.asMap("cmd", GridRestCommand.CACHE_GET_ALL.key(), "k1", "getKey1", "k2", "getKey2"));
+ jcache().putAll(entries);
- assertNotNull(ret);
- assertTrue(!ret.isEmpty());
+ String ret = content(F.asMap("cmd", GridRestCommand.CACHE_GET_ALL.key(), "k1", "getKey1", "k2", "getKey2"));
info("Get all command result: " + ret);
@@@ -1609,28 -1644,6 +1986,28 @@@
/**
* @throws Exception If failed.
*/
+ public void testIncorrectQueryScan() throws Exception {
+ Map<String, String> params = new HashMap<>();
+ params.put("cmd", GridRestCommand.EXECUTE_SCAN_QUERY.key());
+ params.put("pageSize", "10");
+ params.put("cacheName", "person");
+ params.put("className", ScanFilter.class.getName() + 1);
+
+ String ret = content(params);
+
+ assertNotNull(ret);
+ assertTrue(!ret.isEmpty());
+
- JSONObject json = JSONObject.fromObject(ret);
++ JsonNode node = JSON_MAPPER.readTree(ret);
+
- String err = (String)json.get("error");
++ String err = node.get("error").asText();
+
+ assertTrue(err.contains("Failed to find target class"));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
public void testQuery() throws Exception {
grid(0).cache(null).put("1", "1");
grid(0).cache(null).put("2", "2");
@@@ -1827,228 -1856,6 +2220,235 @@@
protected abstract String signature() throws Exception;
/**
+ * @throws Exception If failed.
+ */
+ public void testRunScriptPost() throws Exception {
+ String f = "function(param){return param;}";
+
+ String ret = makePostRequest(F.asMap("cmd", GridRestCommand.RUN_SCRIPT.key(),
+ "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(param){return param;}";
+ String ret = content(F.asMap("cmd", GridRestCommand.RUN_SCRIPT.key(), "func",
+ URLEncoder.encode(f), "arg", "hello"));
+
+ assertNotNull(ret);
+ assertTrue(!ret.isEmpty());
+
+ jsonEquals(ret, stringPattern("hello", true));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testRunScriptCacheGet() throws Exception {
+ grid(0).cache(null).put("tk1", "tv1");
+
+ String f = "function(){return ignite.cache(null).get('tk1');}";
+
+ String ret = content(F.asMap("cmd", GridRestCommand.RUN_SCRIPT.key(), "func",
+ URLEncoder.encode(f, "UTF-8"), "arg", "hello"));
+
+ assertNotNull(ret);
+ assertTrue(!ret.isEmpty());
+
+ jsonEquals(ret, stringPattern("tv1", true));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testRunScriptCachePut() throws Exception {
+ String f = "function(){" +
+ "ignite.cache(null).put('tk1', 'tv1');" +
+ "ignite.cache(null).put('tk2', {'a': '1', 'b': '2'});" +
+ "return 'ok';" +
+ "}";
+
+ String ret = content(F.asMap("cmd", GridRestCommand.RUN_SCRIPT.key(), "func",
+ URLEncoder.encode(f, "UTF-8"), "arg", "hello"));
+
+ assertNotNull(ret);
+ assertTrue(!ret.isEmpty());
+
+ jsonEquals(ret, stringPattern("ok", true));
+
+ assertEquals("tv1", ignite(0).cache(null).get("tk1"));
+
+ JsonObject val = (JsonObject)ignite(0).cache(null).get("tk2");
+
+ assertNotNull(val);
+ assertEquals("1", val.getString("a"));
+ assertEquals("2", val.getString("b"));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ 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 !== \"hello\") {" +
+ "throw \"Not correct arg.\"" +
+ "}" +
+ "return ignite.name();}";
+
+ String ret = makePostRequest(F.asMap("cmd", GridRestCommand.AFFINITY_RUN_SCRIPT.key(),
+ "func", URLEncoder.encode(f)),
+ "{\"arg\":\"" + "hello" + "\",\"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;
+
+ 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 !== \"hello\") {" +
+ "throw \"Not correct arg.\"" +
+ "}" +
+ "return ignite.name();}";
+
+ String ret = content(F.asMap("cmd", GridRestCommand.AFFINITY_RUN_SCRIPT.key(),
+ "func", URLEncoder.encode(f), "key", "key0", "arg", "hello"));
+
+ assertNotNull(ret);
+ assertTrue(!ret.isEmpty());
+
+ jsonEquals(ret, stringPattern(ignite.name(), true));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testMapReduceScriptPost() 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 = makePostRequest(F.asMap("cmd", GridRestCommand.EXECUTE_MAP_REDUCE_SCRIPT.key(),
+ "map", URLEncoder.encode(map),
+ "reduce", URLEncoder.encode(reduce)), "{\"arg\": \"Hello world!\"}");
+
+ assertNotNull(ret);
+ assertTrue(!ret.isEmpty());
+
- jsonEquals(ret, integerPattern(11, true));
++ jsonEquals(ret, doublePattern(11.0, true));
+ }
+
+ /**
+ * @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", GridRestCommand.EXECUTE_MAP_REDUCE_SCRIPT.key(),
+ "map", URLEncoder.encode(map),
+ "reduce", URLEncoder.encode(reduce),
+ "arg", URLEncoder.encode("Hello world!")));
+
+ assertNotNull(ret);
+ assertTrue(!ret.isEmpty());
+
- jsonEquals(ret, integerPattern(11, true));
++ jsonEquals(ret, doublePattern(11, true));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testQueryArgsPost() throws Exception {
+ String qry = "salary > ? and salary <= ?";
+
+ String ret = makePostRequest(F.asMap("cmd", GridRestCommand.EXECUTE_SQL_QUERY.key(),
+ "type", "Person", "pageSize", "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");
++*/
++
++
++ JsonNode node = JSON_MAPPER.readTree(ret);
++
++ JsonNode items = node.get("response").get("items");
+
+ assertEquals(2, items.size());
+
+ assertFalse(queryCursorFound());
+ }
+
+ /**
* @return True if any query cursor is available.
*/
private boolean queryCursorFound() {
@@@ -2188,4 -2060,251 +2653,348 @@@
return n.id().equals(nid);
}
}
+
+ /**
+ * Helper for build {@link VisorGatewayTask} arguments.
+ */
+ public static class VisorGatewayArgument extends HashMap<String, String> {
+ /** Latest argument index. */
+ private int idx = 3;
+
+ /**
+ * Construct helper object.
+ *
+ * @param cls Class of executed task.
+ */
+ public VisorGatewayArgument(Class cls) {
+ super(F.asMap(
+ "cmd", GridRestCommand.EXE.key(),
+ "name", VisorGatewayTask.class.getName(),
+ "p1", "null",
+ "p2", cls.getName()
+ ));
+ }
+
+ /**
+ * Execute task on node.
+ *
+ * @param node Node.
+ * @return This helper for chaining method calls.
+ */
+ public VisorGatewayArgument forNode(ClusterNode node) {
+ put("p1", node.id().toString());
+
+ return this;
+ }
+
+ /**
+ * Prepare list of node IDs.
+ *
+ * @param nodes Collection of nodes.
+ * @return This helper for chaining method calls.
+ */
+ public VisorGatewayArgument forNodes(Collection<ClusterNode> nodes) {
+ put("p1", concat(F.transform(nodes, new C1<ClusterNode, UUID>() {
+ /** {@inheritDoc} */
+ @Override public UUID apply(ClusterNode node) {
+ return node.id();
+ }
+ }).toArray(), ";"));
+
+ return this;
+ }
+
+ /**
+ * Add string argument.
+ *
+ * @param val Value.
+ * @return This helper for chaining method calls.
+ */
+ public VisorGatewayArgument argument(String val) {
+ put("p" + idx++, String.class.getName());
+ put("p" + idx++, val);
+
+ return this;
+ }
+
+ /**
+ * Add custom class argument.
+ *
+ * @param cls Class.
+ * @param vals Values.
+ * @return This helper for chaining method calls.
+ */
+ public VisorGatewayArgument argument(Class cls, Object... vals) {
+ put("p" + idx++, cls.getName());
+
+ for (Object val : vals)
+ put("p" + idx++, val != null ? val.toString() : null);
+
+ return this;
+ }
+
+ /**
+ * Add collection argument.
+ *
+ * @param cls Class.
+ * @param vals Values.
+ * @return This helper for chaining method calls.
+ */
+ public VisorGatewayArgument collection(Class cls, Object... vals) {
+ put("p" + idx++, Collection.class.getName());
+ put("p" + idx++, cls.getName());
+ put("p" + idx++, concat(vals, ";"));
+
+ return this;
+ }
+
+ /**
+ * Add tuple argument.
+ *
+ * @param keyCls Key class.
+ * @param valCls Values class.
+ * @param key Key.
+ * @param val Value.
+ * @return This helper for chaining method calls.
+ */
+ public VisorGatewayArgument pair(Class keyCls, Class valCls, Object key, Object val) {
+ put("p" + idx++, IgniteBiTuple.class.getName());
+ put("p" + idx++, keyCls.getName());
+ put("p" + idx++, valCls.getName());
+ put("p" + idx++, key != null ? key.toString() : "null");
+ put("p" + idx++, val != null ? val.toString() : "null");
+
+ return this;
+ }
+
+ /**
+ * Add tuple argument.
+ *
+ * @param firstCls Class of first argument.
+ * @param secondCls Class of second argument.
+ * @param thirdCls Class of third argument.
+ * @param first First argument.
+ * @param second Second argument.
+ * @param third Third argument.
+ * @return This helper for chaining method calls.
+ */
+ public VisorGatewayArgument tuple3(Class firstCls, Class secondCls, Class thirdCls,
+ Object first, Object second, Object third) {
+ put("p" + idx++, GridTuple3.class.getName());
+ put("p" + idx++, firstCls.getName());
+ put("p" + idx++, secondCls.getName());
+ put("p" + idx++, thirdCls.getName());
+ put("p" + idx++, first != null ? first.toString() : "null");
+ put("p" + idx++, second != null ? second.toString() : "null");
+ put("p" + idx++, third != null ? third.toString() : "null");
+
+ return this;
+ }
+
+ /**
+ * Add set argument.
+ *
+ * @param cls Class.
+ * @param vals Values.
+ * @return This helper for chaining method calls.
+ */
+ public VisorGatewayArgument set(Class cls, Object... vals) {
+ put("p" + idx++, Set.class.getName());
+ put("p" + idx++, cls.getName());
+ put("p" + idx++, concat(vals, ";"));
+
+ return this;
+ }
+
+ /**
+ * Add map argument.
+ *
+ * @param keyCls Key class.
+ * @param valCls Value class.
+ * @param map Map.
+ */
+ public VisorGatewayArgument map(Class keyCls, Class valCls, Map<?, ?> map) throws UnsupportedEncodingException {
+ put("p" + idx++, Map.class.getName());
+ put("p" + idx++, keyCls.getName());
+ put("p" + idx++, valCls.getName());
+
+ SB sb = new SB();
+
+ boolean first = true;
+
+ for (Map.Entry<?, ?> entry : map.entrySet()) {
+ if (!first)
+ sb.a(";");
+
+ sb.a(entry.getKey());
+
+ if (entry.getValue() != null)
+ sb.a("=").a(entry.getValue());
+
+ first = false;
+ }
+
+ put("p" + idx++, URLEncoder.encode(sb.toString(), CHARSET));
+
+ return this;
+ }
+
+ /**
+ * Concat object with delimiter.
+ *
+ * @param vals Values.
+ * @param delim Delimiter.
+ */
+ private static String concat(Object[] vals, String delim) {
+ SB sb = new SB();
+
+ boolean first = true;
+
+ for (Object val : vals) {
+ if (!first)
+ sb.a(delim);
+
+ sb.a(val);
+
+ first = false;
+ }
+
+ return sb.toString();
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ CacheConfiguration cacheIgfs_data = new CacheConfiguration();
+
+ cacheIgfs_data.setName("igfs-data");
+ cacheIgfs_data.setCacheMode(CacheMode.PARTITIONED);
+ cacheIgfs_data.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
+ cacheIgfs_data.setBackups(0);
+
+ cacheIgfs_data.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
+
+ cacheIgfs_data.setAffinityMapper(new IgfsGroupDataBlocksKeyMapper(512));
+
+ CacheConfiguration cacheIgfs_meta = new CacheConfiguration();
+
+ cacheIgfs_meta.setName("igfs-meta");
+ cacheIgfs_meta.setCacheMode(CacheMode.REPLICATED);
+ cacheIgfs_meta.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
+
+ cacheIgfs_meta.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
+
+ cfg.setCacheConfiguration(cfg.getCacheConfiguration()[0], cacheIgfs_data, cacheIgfs_meta);
+
+ FileSystemConfiguration igfs = new FileSystemConfiguration();
+
+ igfs.setName("igfs");
+ igfs.setDataCacheName("igfs-data");
+ igfs.setMetaCacheName("igfs-meta");
+
+ igfs.setIpcEndpointConfiguration(new IgfsIpcEndpointConfiguration());
+
+ cfg.setFileSystemConfiguration(igfs);
+
+ return cfg;
+ }
++
++ /**
++ * @param json JSON response.
++ * @param ptrn Pattern to match.
++ */
++ @SuppressWarnings("TypeMayBeWeakened")
++ private void jsonEquals(String json, String ptrn) {
++ assertTrue("JSON mismatch [json=" + json + ", ptrn=" + ptrn + ']', Pattern.matches(ptrn, json));
++ }
++
++ /**
++ * @param res Response.
++ * @param success Success flag.
++ * @return Regex pattern for JSON.
++ */
++ private String cachePattern(String res, boolean success) {
++ return "\\{" +
++ "\\\"successStatus\\\":" + (success ? 0 : 1) + "\\," +
++ "\\\"affinityNodeId\\\":\\\"\\w{8}-\\w{4}-\\w{4}-\\w{4}-\\w{12}\\\"\\," +
++ "\\\"error\\\":\\\"\\\"\\," +
++ "\\\"sessionToken\\\":\\\"" + (securityEnabled() && success ? ".+" : "") + "\\\"," +
++ "\\\"response\\\":\\\"" + res + "\\\"" +
++ "\\}";
++ }
++
++ /**
++ * @param res Response.
++ * @param success Success flag.
++ * @return Regex pattern for JSON.
++ */
++ private String cachePattern(boolean res, boolean success) {
++ return "\\{" +
++ "\\\"successStatus\\\":" + (success ? 0 : 1) + "\\," +
++ "\\\"affinityNodeId\\\":\\\"\\w{8}-\\w{4}-\\w{4}-\\w{4}-\\w{12}\\\"\\," +
++ "\\\"error\\\":\\\"\\\"\\," +
++ "\\\"sessionToken\\\":\\\"" + (securityEnabled() && success ? ".+" : "") + "\\\"," +
++ "\\\"response\\\":" + res +
++ "\\}";
++ }
++
++ /**
++ * @param res Response.
++ * @param success Success flag.
++ * @return Regex pattern for JSON.
++ */
++ private String cacheBulkPattern(String res, boolean success) {
++ return "\\{" +
++ "\\\"successStatus\\\":" + (success ? 0 : 1) + "\\," +
++ "\\\"affinityNodeId\\\":\\\"\\\"\\," +
++ "\\\"error\\\":\\\"\\\"\\," +
++ "\\\"sessionToken\\\":\\\"" + (securityEnabled() && success ? ".+" : "") + "\\\"," +
++ "\\\"response\\\":" + res +
++ "\\}";
++ }
++
++ /**
++ * @param res Response.
++ * @param success Success flag.
++ * @return Regex pattern for JSON.
++ */
++ private String cacheBulkPattern(boolean res, boolean success) {
++ return "\\{" +
++ "\\\"successStatus\\\":" + (success ? 0 : 1) + "\\," +
++ "\\\"affinityNodeId\\\":\\\"\\\"\\," +
++ "\\\"error\\\":\\\"\\\"\\," +
++ "\\\"sessionToken\\\":\\\"" + (securityEnabled() && success ? ".+" : "") + "\\\"," +
++ "\\\"response\\\":" + res +
++ "\\}";
++ }
++
++ /**
++ * @param res Response.
++ * @param success Success flag.
++ * @return Regex pattern for JSON.
++ */
++ private String doublePattern(double res, boolean success) {
++ return "\\{" +
++ "\\\"successStatus\\\":" + (success ? 0 : 1) + "\\," +
++ "\\\"error\\\":\\\"\\\"\\," +
++ "\\\"sessionToken\\\":\\\"" + (securityEnabled() && success ? ".+" : "") + "\\\"," +
++ "\\\"response\\\":" + res +
++ "\\}";
++ }
++
++ /**
++ * @param res Response.
++ * @param success Success flag.
++ * @return Regex pattern for JSON.
++ */
++ private String stringPattern(String res, boolean success) {
++ return "\\{" +
++ "\\\"successStatus\\\":" + (success ? 0 : 1) + "\\," +
++ "\\\"error\\\":\\\"" + (!success ? ".+" : "") + "\\\"\\," +
++ "\\\"sessionToken\\\":\\\"" + (securityEnabled() && success ? ".+" : "") + "\\\"," +
++ "\\\"response\\\":\\\"" + res + "\\\"" +
++ "\\}";
++ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/7e829bc8/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java
index c7f68f4,3eaef1e..a2f3562
--- a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java
@@@ -48,7 -48,7 +48,8 @@@ import org.apache.ignite.internal.proce
import org.apache.ignite.internal.processors.igfs.IgfsProcessorAdapter;
import org.apache.ignite.internal.processors.job.GridJobProcessor;
import org.apache.ignite.internal.processors.jobmetrics.GridJobMetricsProcessor;
+import org.apache.ignite.internal.processors.json.IgniteJsonProcessor;
+ import org.apache.ignite.internal.processors.odbc.OdbcProcessor;
import org.apache.ignite.internal.processors.offheap.GridOffHeapProcessor;
import org.apache.ignite.internal.processors.platform.PlatformProcessor;
import org.apache.ignite.internal.processors.plugin.IgnitePluginProcessor;
http://git-wip-us.apache.org/repos/asf/ignite/blob/7e829bc8/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java
index 194d068,1ff4543..d64138f
--- a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java
@@@ -64,8 -64,8 +64,9 @@@ import org.apache.ignite.internal.proce
import org.apache.ignite.internal.processors.igfs.IgfsProcessorAdapter;
import org.apache.ignite.internal.processors.job.GridJobProcessor;
import org.apache.ignite.internal.processors.jobmetrics.GridJobMetricsProcessor;
+import org.apache.ignite.internal.processors.json.IgniteJsonProcessor;
import org.apache.ignite.internal.processors.nodevalidation.DiscoveryNodeValidationProcessor;
+ import org.apache.ignite.internal.processors.odbc.OdbcProcessor;
import org.apache.ignite.internal.processors.offheap.GridOffHeapProcessor;
import org.apache.ignite.internal.processors.platform.PlatformProcessor;
import org.apache.ignite.internal.processors.plugin.IgnitePluginProcessor;
http://git-wip-us.apache.org/repos/asf/ignite/blob/7e829bc8/modules/core/src/main/java/org/apache/ignite/internal/IgniteComponentType.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/7e829bc8/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
index 2778c42,b85692e..9ce78d4
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
@@@ -859,13 -881,9 +883,10 @@@ public class IgniteKernal implements Ig
startProcessor(new DataStreamProcessor(ctx));
startProcessor((GridProcessor)IGFS.create(ctx, F.isEmpty(cfg.getFileSystemConfiguration())));
startProcessor(new GridContinuousProcessor(ctx));
- startProcessor((GridProcessor)(cfg.isPeerClassLoadingEnabled() ?
- IgniteComponentType.HADOOP.create(ctx, true): // No-op when peer class loading is enabled.
- IgniteComponentType.HADOOP.createIfInClassPath(ctx, cfg.getHadoopConfiguration() != null)));
- startProcessor(new GridServiceProcessor(ctx));
+ startProcessor((GridProcessor)createHadoopComponent());
startProcessor(new DataStructuresProcessor(ctx));
startProcessor(createComponent(PlatformProcessor.class, ctx));
+ startProcessor((GridProcessor)IgniteComponentType.JSON.createIfInClassPath(ctx, false));
// Start plugins.
for (PluginProvider provider : ctx.plugins().allProviders()) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/7e829bc8/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryObjectBuilderImpl.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/7e829bc8/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectContext.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/7e829bc8/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java
index 9ccb10a,fa81c2a..b7e9448
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java
@@@ -772,21 -788,38 +788,38 @@@ public class CacheObjectBinaryProcessor
}
/** {@inheritDoc} */
- @Override public KeyCacheObject toCacheKeyObject(CacheObjectContext ctx, Object obj, boolean userObj) {
+ @Override public KeyCacheObject toCacheKeyObject(
+ CacheObjectContext ctx,
+ @Nullable GridCacheContext cctx,
+ Object obj,
+ boolean userObj
+ ) {
- if (!((CacheObjectBinaryContext)ctx).binaryEnabled())
+ if (!((CacheObjectBinaryContext)ctx).binaryEnabled() || ctx.kernalContext().json().jsonObject(obj))
- return super.toCacheKeyObject(ctx, obj, userObj);
+ return super.toCacheKeyObject(ctx, cctx, obj, userObj);
- if (obj instanceof KeyCacheObject)
- return (KeyCacheObject)obj;
+ if (obj instanceof KeyCacheObject) {
+ KeyCacheObject key = (KeyCacheObject)obj;
- if (((CacheObjectBinaryContext)ctx).binaryEnabled()) {
- obj = toBinary(obj);
+ if (key instanceof BinaryObjectImpl) {
+ // Need to create a copy because the key can be reused at the application layer after that (IGNITE-3505).
+ key = key.copy(partition(ctx, cctx, key));
+ }
+ else if (key.partition() == -1)
+ // Assume others KeyCacheObjects can not be reused for another cache.
+ key.partition(partition(ctx, cctx, key));
+
+ return key;
+ }
- if (obj instanceof KeyCacheObject)
- return (KeyCacheObject)obj;
+ obj = toBinary(obj);
+
+ if (obj instanceof BinaryObjectImpl) {
+ ((BinaryObjectImpl)obj).partition(partition(ctx, cctx, obj));
+
+ return (KeyCacheObject)obj;
}
- return toCacheKeyObject0(obj, userObj);
+ return toCacheKeyObject0(ctx, cctx, obj, userObj);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/7e829bc8/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
index ac08da6,78a1838..f98a937
--- 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
@@@ -108,16 -113,21 +113,26 @@@ public class IgniteCacheObjectProcessor
}
/** {@inheritDoc} */
- @Override @Nullable public KeyCacheObject toCacheKeyObject(CacheObjectContext ctx, Object obj, boolean userObj) {
- if (obj instanceof KeyCacheObject)
+ @Override public KeyCacheObject toCacheKeyObject(CacheObjectContext ctx,
+ @Nullable GridCacheContext cctx,
+ Object obj,
+ boolean userObj) {
+ if (obj instanceof KeyCacheObject) {
+ KeyCacheObject key = (KeyCacheObject)obj;
+
+ if (key.partition() == -1)
+ // Assume all KeyCacheObjects except BinaryObject can not be reused for another cache.
+ key.partition(partition(ctx, cctx, key));
+
return (KeyCacheObject)obj;
+ }
+ KeyCacheObject key = this.ctx.json().toCacheKeyObject(ctx, obj, userObj);
+
+ if (key != null)
+ return key;
+
- return toCacheKeyObject0(obj, userObj);
+ return toCacheKeyObject0(ctx, cctx, obj, userObj);
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/7e829bc8/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/RestQueryRequest.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/7e829bc8/modules/core/src/main/java/org/apache/ignite/internal/util/GridJavaProcess.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/7e829bc8/modules/json/pom.xml
----------------------------------------------------------------------
diff --cc modules/json/pom.xml
index 192c47f,0000000..3d4ce60
mode 100644,000000..100644
--- a/modules/json/pom.xml
+++ b/modules/json/pom.xml
@@@ -1,76 -1,0 +1,76 @@@
+<?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.
+-->
+
+<!--
+ POM file.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-parent</artifactId>
+ <version>1</version>
+ <relativePath>../../parent</relativePath>
+ </parent>
+
+ <artifactId>ignite-json</artifactId>
- <version>1.6.0-SNAPSHOT</version>
++ <version>1.8.0-SNAPSHOT</version>
+ <url>http://ignite.apache.org</url>
+
+ <dependencies>
+ <dependency>
+ <groupId>javax.json</groupId>
+ <artifactId>javax.json-api</artifactId>
+ <version>1.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-spring</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-log4j</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-indexing</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-core</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
http://git-wip-us.apache.org/repos/asf/ignite/blob/7e829bc8/modules/nodejs/pom.xml
----------------------------------------------------------------------
diff --cc modules/nodejs/pom.xml
index f50b61d,0000000..7b6c189
mode 100644,000000..100644
--- a/modules/nodejs/pom.xml
+++ b/modules/nodejs/pom.xml
@@@ -1,82 -1,0 +1,82 @@@
+<?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.
+-->
+
+<!--
+ POM file.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-parent</artifactId>
+ <version>1</version>
+ <relativePath>../../parent</relativePath>
+ </parent>
+
+ <artifactId>ignite-nodejs</artifactId>
- <version>1.6.0-SNAPSHOT</version>
++ <version>1.8.0-SNAPSHOT</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-spring</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-log4j</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-indexing</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-rest-http</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-core</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
http://git-wip-us.apache.org/repos/asf/ignite/blob/7e829bc8/modules/rest-http/pom.xml
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/7e829bc8/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestHandler.java
----------------------------------------------------------------------
diff --cc modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestHandler.java
index a20f969,c864a10..837f432
--- 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
@@@ -17,16 -17,16 +17,19 @@@
package org.apache.ignite.internal.processors.rest.protocols.http.jetty;
+ import com.fasterxml.jackson.core.JsonProcessingException;
+ import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.BufferedInputStream;
+import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.net.InetSocketAddress;
+import java.util.ArrayList;
+import java.util.Collection;
+ import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
@@@ -37,15 -37,8 +40,9 @@@ import javax.servlet.ServletException
import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
- import net.sf.json.JSON;
- import net.sf.json.JSONException;
- import net.sf.json.JSONObject;
- import net.sf.json.JSONSerializer;
- import net.sf.json.JsonConfig;
- import net.sf.json.processors.JsonValueProcessor;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.processors.rest.GridRestCommand;
import org.apache.ignite.internal.processors.rest.GridRestProtocolHandler;
import org.apache.ignite.internal.processors.rest.GridRestResponse;
@@@ -105,9 -86,9 +92,12 @@@ public class GridJettyRestHandler exten
/** Favicon. */
private volatile byte[] favicon;
+ /** Mapper from Java object to JSON. */
+ private final ObjectMapper jsonMapper;
+
+ /** Grid context. */
+ GridKernalContext ctx;
+
/**
* Creates new HTTP requests handler.
*
@@@ -124,7 -103,7 +114,8 @@@
this.hnd = hnd;
this.log = log;
this.authChecker = authChecker;
+ this.jsonMapper = new GridJettyObjectMapper();
+ this.ctx = ctx;
// Init default page and favicon.
try {
@@@ -735,19 -557,11 +718,19 @@@
restReq0.sqlQuery((String)params.get("qry"));
- restReq0.arguments(values("arg", params).toArray());
+ if (jsonRequest(req)) {
+ Map o = parseRequest(req);
+
+ Collection args = (Collection)o.get("arg");
+
+ restReq0.arguments(args.toArray());
+ }
+ else
+ restReq0.arguments(values("arg", params).toArray());
- restReq0.typeName((String) params.get("type"));
+ restReq0.typeName((String)params.get("type"));
- String pageSize = (String) params.get("pageSize");
+ String pageSize = (String)params.get("pageSize");
if (pageSize != null)
restReq0.pageSize(Integer.parseInt(pageSize));
@@@ -946,77 -754,4 +933,77 @@@
return null;
}
+
+ /**
+ * TODO IGNITE-961: move to JsonProcessor.
+ *
+ * @param req Request.
+ * @return JSON object.
+ * @throws IgniteCheckedException If failed.
+ */
+ private Map parseRequest(HttpServletRequest req) throws IgniteCheckedException {
+ try {
+ BufferedReader reader = req.getReader();
+
+ StringBuilder str = new StringBuilder();
+
+ String line;
+
+ while ((line = reader.readLine()) != null)
+ str.append(line);
+
- return JSONObject.fromObject(str.toString());
++ return jsonMapper.readValue(str.toString(), Map.class);
+ }
+ catch (IOException e) {
+ throw new IgniteCheckedException(e);
+ }
+ }
+
+ /**
+ * Scripting cache entry.
+ */
+ public static class CacheEntry {
+ /** Key. */
+ private Object key;
+
+ /** Value. */
+ private Object val;
+
+ /**
+ * @param key Key.
+ * @param val Value.
+ */
+ public CacheEntry(Object key, Object val) {
+ this.key = key;
+ this.val = val;
+ }
+
+ /**
+ * @return Key.
+ */
+ public Object getKey() {
+ return key;
+ }
+
+ /**
+ * @param key Key.
+ */
+ public void setKey(Object key) {
+ this.key = key;
+ }
+
+ /**
+ * @return Value.
+ */
+ public Object getValue() {
+ return val;
+ }
+
+ /**
+ * @param val Value.
+ */
+ public void setValue(Object val) {
+ this.val = val;
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/7e829bc8/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestProtocol.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/7e829bc8/parent/pom.xml
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/7e829bc8/pom.xml
----------------------------------------------------------------------
diff --cc pom.xml
index 2f87aa4,86f423a..b39346d
--- a/pom.xml
+++ b/pom.xml
@@@ -85,7 -84,10 +85,11 @@@
<module>modules/osgi-paxlogging</module>
<module>modules/osgi-karaf</module>
<module>modules/osgi</module>
+ <module>modules/web/ignite-appserver-test</module>
+ <module>modules/web/ignite-websphere-test</module>
+ <module>modules/cassandra</module>
+ <module>modules/flink</module>
+ <module>modules/json</module>
</modules>
<profiles>
@@@ -765,31 -796,13 +798,40 @@@
</profile>
<profile>
+ <id>ignite-npm</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>compile</phase>
+ <goals>
+ <goal>exec</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <executable>npm</executable>
+ <arguments>
+ <argument>publish</argument>
+ <argument>modules/nodejs/src/main/js</argument>
+ </arguments>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
++
++ <profile>
+ <id>web-console</id>
+ <modules>
+ <module>modules/web-agent</module>
+ <module>modules/web-console</module>
+ <module>modules/schema-import-db</module>
+ </modules>
+ </profile>
<profile>
<id>update-versions</id>
[44/50] [abbrv] ignite git commit: IGNITE-1952 Visorcmd: add a
command for reset (clear) of metrics. Fixes #1029.
Posted by sb...@apache.org.
IGNITE-1952 Visorcmd: add a command for reset (clear) of metrics. Fixes #1029.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/afac3fab
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/afac3fab
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/afac3fab
Branch: refs/heads/ignite-961
Commit: afac3fab5f22250b830383a9f10336d396c83ad9
Parents: bdbc5a3
Author: Saikat Maitra <sa...@gmail.com>
Authored: Mon Sep 5 15:06:39 2016 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Mon Sep 5 15:06:39 2016 +0700
----------------------------------------------------------------------
.../ignite/visor/commands/VisorConsole.scala | 1 +
.../commands/cache/VisorCacheCommand.scala | 33 ++++-
.../commands/cache/VisorCacheResetCommand.scala | 129 +++++++++++++++++++
.../cache/VisorCacheResetCommandSpec.scala | 114 ++++++++++++++++
4 files changed, 271 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/afac3fab/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/VisorConsole.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/VisorConsole.scala b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/VisorConsole.scala
index b4d78b5..ad8c2ed 100644
--- a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/VisorConsole.scala
+++ b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/VisorConsole.scala
@@ -62,6 +62,7 @@ class VisorConsole {
org.apache.ignite.visor.commands.ack.VisorAckCommand
org.apache.ignite.visor.commands.alert.VisorAlertCommand
org.apache.ignite.visor.commands.cache.VisorCacheClearCommand
+ org.apache.ignite.visor.commands.cache.VisorCacheResetCommand
org.apache.ignite.visor.commands.cache.VisorCacheCommand
org.apache.ignite.visor.commands.cache.VisorCacheSwapCommand
org.apache.ignite.visor.commands.config.VisorConfigurationCommand
http://git-wip-us.apache.org/repos/asf/ignite/blob/afac3fab/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheCommand.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheCommand.scala b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheCommand.scala
index 68465de..1fa185f 100755
--- a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheCommand.scala
+++ b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheCommand.scala
@@ -58,6 +58,9 @@ import scala.language.{implicitConversions, reflectiveCalls}
* +-----------------------------------------------------------------------------------------+
* | cache -stop | Stop cache with specified name. |
* +-----------------------------------------------------------------------------------------+
+ * | cache -reset | Reset metrics for cache with specified name. |
+ * +-----------------------------------------------------------------------------------------+
+ *
* }}}
*
* ====Specification====
@@ -69,6 +72,7 @@ import scala.language.{implicitConversions, reflectiveCalls}
* cache -scan -c=<cache-name> {-id=<node-id>|id8=<node-id8>} {-p=<page size>} {-system}
* cache -swap {-c=<cache-name>} {-id=<node-id>|id8=<node-id8>}
* cache -stop -c=<cache-name>
+ * cache -reset -c=<cache-name>
* }}}
*
* ====Arguments====
@@ -113,6 +117,8 @@ import scala.language.{implicitConversions, reflectiveCalls}
* Swaps backup entries in cache.
* -stop
* Stop cache with specified name.
+ * -reset
+ * Reset metrics for cache with specified name.
* -p=<page size>
* Number of object to fetch from cache at once.
* Valid range from 1 to 100.
@@ -153,6 +159,9 @@ import scala.language.{implicitConversions, reflectiveCalls}
* Swaps entries in cache with name taken from 'c0' memory variable.
* cache -stop -c=cache
* Stops cache with name 'cache'.
+ * cache -reset -c=cache
+ * Reset metrics for cache with name 'cache'.
+ *
* }}}
*/
class VisorCacheCommand {
@@ -210,6 +219,9 @@ class VisorCacheCommand {
* <br>
* <ex>cache -stop -c=@c0</ex>
* Stop cache with name taken from 'c0' memory variable.
+ * <br>
+ * <ex>cache -reset -c=@c0</ex>
+ * Reset metrics for cache with name taken from 'c0' memory variable.
*
* @param args Command arguments.
*/
@@ -260,9 +272,9 @@ class VisorCacheCommand {
// Get cache stats data from all nodes.
val aggrData = cacheData(node, cacheName, showSystem)
- if (hasArgFlagIn("clear", "swap", "scan", "stop")) {
+ if (hasArgFlagIn("clear", "swap", "scan", "stop", "reset")) {
if (cacheName.isEmpty)
- askForCache("Select cache from:", node, showSystem && !hasArgFlagIn("clear", "swap", "stop"), aggrData) match {
+ askForCache("Select cache from:", node, showSystem && !hasArgFlagIn("clear", "swap", "stop", "reset"), aggrData) match {
case Some(name) =>
argLst = argLst ++ Seq("c" -> name)
@@ -282,6 +294,8 @@ class VisorCacheCommand {
VisorCacheSwapCommand().swap(argLst, node)
else if (hasArgFlag("stop", argLst))
VisorCacheStopCommand().stop(argLst, node)
+ else if (hasArgFlag("reset", argLst))
+ VisorCacheResetCommand().reset(argLst, node)
}
else {
if (hasArgFlag("clear", argLst))
@@ -290,6 +304,8 @@ class VisorCacheCommand {
warn("Backup swapping of system cache is not allowed: " + name)
else if (hasArgFlag("stop", argLst))
warn("Stopping of system cache is not allowed: " + name)
+ else if (hasArgFlag("reset", argLst))
+ warn("Reset metrics of system cache is not allowed: " + name)
}
}
})
@@ -716,8 +732,9 @@ object VisorCacheCommand {
"cache -clear {-c=<cache-name>} {-id=<node-id>|id8=<node-id8>}",
"cache -scan -c=<cache-name> {-id=<node-id>|id8=<node-id8>} {-p=<page size>}",
"cache -swap {-c=<cache-name>} {-id=<node-id>|id8=<node-id8>}",
- "cache -stop -c=<cache-name>"
- ),
+ "cache -stop -c=<cache-name>",
+ "cache -reset -c=<cache-name>"
+ ),
args = Seq(
"-id8=<node-id>" -> Seq(
"ID8 of the node to get cache statistics from.",
@@ -749,7 +766,10 @@ object VisorCacheCommand {
"Swaps backup entries in cache."
),
"-stop" -> Seq(
- "Stop cache with specified name"
+ "Stop cache with specified name."
+ ),
+ "-reset" -> Seq(
+ "Reset metrics of cache with specified name."
),
"-s=hi|mi|rd|wr|cn" -> Seq(
"Defines sorting type. Sorted by:",
@@ -809,7 +829,8 @@ object VisorCacheCommand {
"cache -swap" -> "Swaps entries in interactively selected cache.",
"cache -swap -c=cache" -> "Swaps entries in cache with name 'cache'.",
"cache -swap -c=@c0" -> "Swaps entries in cache with name taken from 'c0' memory variable.",
- "cache -stop -c=@c0" -> "Stop cache with name taken from 'c0' memory variable."
+ "cache -stop -c=@c0" -> "Stop cache with name taken from 'c0' memory variable.",
+ "cache -reset -c=@c0" -> "Reset metrics for cache with name taken from 'c0' memory variable."
),
emptyArgs = cmd.cache,
withArgs = cmd.cache
http://git-wip-us.apache.org/repos/asf/ignite/blob/afac3fab/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheResetCommand.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheResetCommand.scala b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheResetCommand.scala
new file mode 100644
index 0000000..b59155b
--- /dev/null
+++ b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheResetCommand.scala
@@ -0,0 +1,129 @@
+/*
+ * 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.visor.commands.cache
+
+import org.apache.ignite.cluster.{ClusterGroupEmptyException, ClusterNode}
+import org.apache.ignite.internal.visor.cache.VisorCacheResetMetricsTask
+import org.apache.ignite.internal.visor.util.VisorTaskUtils._
+import org.apache.ignite.visor.visor._
+
+import scala.language.reflectiveCalls
+
+/**
+ * ==Overview==
+ * Visor 'reset' command implementation.
+ *
+ * ====Specification====
+ * {{{
+ * cache -reset -c=<cache name>
+ * }}}
+ *
+ * ====Arguments====
+ * {{{
+ * <cache-name>
+ * Name of the cache.
+ * }}}
+ *
+ * ====Examples====
+ * {{{
+ * cache -reset -c=@c0
+ * Reset metrics for cache with name taken from 'c0' memory variable.
+ * }}}
+ */
+class VisorCacheResetCommand {
+ /**
+ * Prints error message and advise.
+ *
+ * @param errMsgs Error messages.
+ */
+ private def scold(errMsgs: Any*) {
+ assert(errMsgs != null)
+
+ warn(errMsgs: _*)
+ warn("Type 'help cache' to see how to use this command.")
+ }
+
+ private def error(e: Exception) {
+ var cause: Throwable = e
+
+ while (cause.getCause != null)
+ cause = cause.getCause
+
+ scold(cause.getMessage)
+ }
+
+ /**
+ * ===Command===
+ * Reset metrics for cache with specified name.
+ *
+ * ===Examples===
+ * <ex>cache -c=cache -reset</ex>
+ * Reset metrics for cache with name 'cache'.
+ *
+ * @param argLst Command arguments.
+ */
+ def reset(argLst: ArgList, node: Option[ClusterNode]) {
+ val cacheArg = argValue("c", argLst)
+
+ val cacheName = cacheArg match {
+ case None => null // default cache.
+
+ case Some(s) if s.startsWith("@") =>
+ warn("Can't find cache variable with specified name: " + s,
+ "Type 'cache' to see available cache variables."
+ )
+
+ return
+
+ case Some(name) => name
+ }
+
+ val grp = try {
+ groupForDataNode(node, cacheName)
+ }
+ catch {
+ case _: ClusterGroupEmptyException =>
+ scold(messageNodeNotFound(node, cacheName))
+
+ return
+ }
+
+ try {
+ executeRandom(grp, classOf[VisorCacheResetMetricsTask], cacheName)
+
+ println("Visor successfully reset metrics for cache: " + escapeName(cacheName))
+ }
+ catch {
+ case _: ClusterGroupEmptyException => scold(messageNodeNotFound(node, cacheName))
+ case e: Exception => error(e)
+ }
+ }
+}
+
+/**
+ * Companion object that does initialization of the command.
+ */
+object VisorCacheResetCommand {
+ /** Singleton command. */
+ private val cmd = new VisorCacheResetCommand
+
+ /**
+ * Singleton.
+ */
+ def apply() = cmd
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/afac3fab/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/cache/VisorCacheResetCommandSpec.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/cache/VisorCacheResetCommandSpec.scala b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/cache/VisorCacheResetCommandSpec.scala
new file mode 100644
index 0000000..18f728c
--- /dev/null
+++ b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/cache/VisorCacheResetCommandSpec.scala
@@ -0,0 +1,114 @@
+/*
+ * 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.visor.commands.cache
+
+import org.apache.ignite.Ignition
+import org.apache.ignite.cache.CacheAtomicityMode._
+import org.apache.ignite.cache.CacheMode._
+import org.apache.ignite.configuration.{CacheConfiguration, IgniteConfiguration}
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder
+import org.apache.ignite.visor.commands.cache.VisorCacheCommand._
+import org.apache.ignite.visor.{VisorRuntimeBaseSpec, visor}
+import org.jetbrains.annotations.Nullable
+
+import scala.collection.JavaConversions._
+
+/**
+ * Unit test for 'reset' command.
+ */
+class VisorCacheResetCommandSpec extends VisorRuntimeBaseSpec(2) {
+ /** IP finder. */
+ val ipFinder = new TcpDiscoveryVmIpFinder(true)
+
+ /**
+ * Creates grid configuration for provided grid host.
+ *
+ * @param name Grid name.
+ * @return Grid configuration.
+ */
+ override def config(name: String): IgniteConfiguration = {
+ val cfg = new IgniteConfiguration
+
+ cfg.setGridName(name)
+ cfg.setLocalHost("127.0.0.1")
+ cfg.setCacheConfiguration(cacheConfig(null), cacheConfig("cache"))
+
+ val discoSpi = new TcpDiscoverySpi()
+
+ discoSpi.setIpFinder(ipFinder)
+
+ cfg.setDiscoverySpi(discoSpi)
+
+ cfg
+ }
+
+ /**
+ * @param name Cache name.
+ * @return Cache Configuration.
+ */
+ def cacheConfig(@Nullable name: String): CacheConfiguration[Object, Object] = {
+ val cfg = new CacheConfiguration[Object, Object]
+
+ cfg.setCacheMode(REPLICATED)
+ cfg.setAtomicityMode(TRANSACTIONAL)
+ cfg.setName(name)
+
+ cfg
+ }
+
+ describe("A 'reset' visor command") {
+ it("should show correct result for default cache") {
+ Ignition.ignite("node-1").cache[Int, Int](null).putAll(Map(1 -> 1, 2 -> 2, 3 -> 3))
+
+ val lock = Ignition.ignite("node-1").cache[Int, Int](null).lock(1)
+
+ lock.lock()
+
+ VisorCacheResetCommand().reset(Nil, None)
+
+ lock.unlock()
+
+ VisorCacheResetCommand().reset(Nil, None)
+ }
+
+ it("should show correct result for named cache") {
+ Ignition.ignite("node-1").cache[Int, Int]("cache").putAll(Map(1 -> 1, 2 -> 2, 3 -> 3))
+
+ val lock = Ignition.ignite("node-1").cache[Int, Int]("cache").lock(1)
+
+ lock.lock()
+
+ visor.cache("-reset -c=cache")
+
+ lock.unlock()
+
+ visor.cache("-reset -c=cache")
+ }
+
+ it("should show correct help") {
+ VisorCacheCommand
+
+ visor.help("cache")
+ }
+
+ it("should show empty projection error message") {
+ visor.cache("-reset -c=wrong")
+ }
+ }
+}
[20/50] [abbrv] ignite git commit: ignite-2968 Deadlock detection for
optimistic tx and near caches
Posted by sb...@apache.org.
ignite-2968 Deadlock detection for optimistic tx and near caches
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/0465874d
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/0465874d
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/0465874d
Branch: refs/heads/ignite-961
Commit: 0465874d9dddcf962a82a2ef38589121201f0b75
Parents: 2891703
Author: agura <ag...@gridgain.com>
Authored: Wed Aug 24 21:13:29 2016 +0300
Committer: agura <ag...@gridgain.com>
Committed: Mon Aug 29 16:01:16 2016 +0300
----------------------------------------------------------------------
.../processors/cache/GridCacheMapEntry.java | 19 +-
.../GridCachePartitionExchangeManager.java | 7 +
.../GridDistributedTxPrepareRequest.java | 4 +-
.../distributed/dht/GridDhtLockFuture.java | 53 +-
.../distributed/dht/GridDhtTxFinishFuture.java | 4 +-
.../cache/distributed/dht/GridDhtTxLocal.java | 26 +-
.../distributed/dht/GridDhtTxPrepareFuture.java | 109 +++-
.../dht/GridDhtTxPrepareRequest.java | 4 +-
.../colocated/GridDhtColocatedLockFuture.java | 37 +-
.../distributed/near/GridNearLockFuture.java | 90 ++-
...arOptimisticSerializableTxPrepareFuture.java | 13 +-
.../near/GridNearOptimisticTxPrepareFuture.java | 263 ++++++---
...ridNearOptimisticTxPrepareFutureAdapter.java | 5 +-
.../GridNearPessimisticTxPrepareFuture.java | 8 +-
.../near/GridNearTxFinishFuture.java | 5 +-
.../cache/distributed/near/GridNearTxLocal.java | 16 +-
.../near/GridNearTxPrepareRequest.java | 4 +-
.../cache/transactions/IgniteInternalTx.java | 3 +-
.../cache/transactions/IgniteTxAdapter.java | 37 +-
.../cache/transactions/IgniteTxHandler.java | 9 +-
.../transactions/IgniteTxLocalAdapter.java | 19 +-
.../cache/transactions/IgniteTxManager.java | 86 ++-
.../cache/transactions/IgniteTxStateImpl.java | 11 +-
.../cache/transactions/TxDeadlockDetection.java | 51 +-
.../cache/IgniteTxConfigCacheSelfTest.java | 91 ++-
.../IgniteTxTimeoutAbstractTest.java | 8 +-
...tionedMultiNodeLongTxTimeoutFullApiTest.java | 34 ++
...nabledMultiNodeLongTxTimeoutFullApiTest.java | 41 ++
.../local/GridCacheLocalTxTimeoutSelfTest.java | 5 +-
.../transactions/DepthFirstSearchTest.java | 100 +++-
.../TxDeadlockDetectionNoHangsTest.java | 246 ++++++++
.../transactions/TxDeadlockDetectionTest.java | 13 +-
...timisticDeadlockDetectionCrossCacheTest.java | 257 +++++++++
.../TxOptimisticDeadlockDetectionTest.java | 574 +++++++++++++++++++
...simisticDeadlockDetectionCrossCacheTest.java | 165 ++++--
.../TxPessimisticDeadlockDetectionTest.java | 50 +-
.../IgniteCacheFullApiSelfTestSuite.java | 4 +
.../TxDeadlockDetectionTestSuite.java | 6 +
.../commands/cache/VisorCacheStopCommand.scala | 5 +-
39 files changed, 2127 insertions(+), 355 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/0465874d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
index 57fa68e..f692bf4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
@@ -4493,17 +4493,30 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
}
/**
- * @return All MVCC local candidates.
+ * @return All MVCC local and non near candidates.
*/
+ @SuppressWarnings("ForLoopReplaceableByForEach")
@Nullable public synchronized List<GridCacheMvccCandidate> mvccAllLocal() {
GridCacheMvcc mvcc = extras != null ? extras.mvcc() : null;
if (mvcc == null)
return null;
- List<GridCacheMvccCandidate> locs = mvcc.allLocal();
+ List<GridCacheMvccCandidate> allLocs = mvcc.allLocal();
- return (locs == null || locs.isEmpty()) ? null : new ArrayList<>(locs);
+ if (allLocs == null || allLocs.isEmpty())
+ return null;
+
+ List<GridCacheMvccCandidate> locs = new ArrayList<>(allLocs.size());
+
+ for (int i = 0; i < allLocs.size(); i++) {
+ GridCacheMvccCandidate loc = allLocs.get(i);
+
+ if (!loc.nearLocal())
+ locs.add(loc);
+ }
+
+ return locs.isEmpty() ? null : locs;
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/0465874d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
index e6ab046..4eb61e3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
@@ -1302,6 +1302,13 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
for (GridCacheFuture<?> fut : mvcc.atomicFutures())
U.warn(log, ">>> " + fut);
+
+ if (tm != null) {
+ U.warn(log, "Pending transaction deadlock detection futures:");
+
+ for (IgniteInternalFuture<?> fut : tm.deadlockDetectionFutures())
+ U.warn(log, ">>> " + fut);
+ }
}
for (GridCacheContext ctx : cctx.cacheContexts()) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/0465874d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java
index 72e68db..c691374 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java
@@ -154,6 +154,7 @@ public class GridDistributedTxPrepareRequest extends GridDistributedBaseMessage
/**
* @param tx Cache transaction.
+ * @param timeout Transactions timeout.
* @param reads Read entries.
* @param writes Write entries.
* @param txNodes Transaction nodes mapping.
@@ -162,6 +163,7 @@ public class GridDistributedTxPrepareRequest extends GridDistributedBaseMessage
*/
public GridDistributedTxPrepareRequest(
IgniteInternalTx tx,
+ long timeout,
@Nullable Collection<IgniteTxEntry> reads,
Collection<IgniteTxEntry> writes,
Map<UUID, Collection<UUID>> txNodes,
@@ -174,12 +176,12 @@ public class GridDistributedTxPrepareRequest extends GridDistributedBaseMessage
threadId = tx.threadId();
concurrency = tx.concurrency();
isolation = tx.isolation();
- timeout = tx.timeout();
invalidate = tx.isInvalidate();
txSize = tx.size();
sys = tx.system();
plc = tx.ioPolicy();
+ this.timeout = timeout;
this.reads = reads;
this.writes = writes;
this.txNodes = txNodes;
http://git-wip-us.apache.org/repos/asf/ignite/blob/0465874d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java
index 64b8745..b005b29 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java
@@ -242,12 +242,6 @@ public final class GridDhtLockFuture extends GridCompoundIdentityFuture<Boolean>
msgLog = cctx.shared().txLockMessageLogger();
log = U.logger(cctx.kernalContext(), logRef, GridDhtLockFuture.class);
}
-
- if (timeout > 0) {
- timeoutObj = new LockTimeoutObject();
-
- cctx.time().addTimeoutObject(timeoutObj);
- }
}
/** {@inheritDoc} */
@@ -298,8 +292,10 @@ public final class GridDhtLockFuture extends GridCompoundIdentityFuture<Boolean>
/**
* @return Entries.
*/
- public synchronized Collection<GridDhtCacheEntry> entriesCopy() {
- return new ArrayList<>(entries());
+ public Collection<GridDhtCacheEntry> entriesCopy() {
+ synchronized (futs) {
+ return new ArrayList<>(entries());
+ }
}
/**
@@ -412,7 +408,7 @@ public final class GridDhtLockFuture extends GridCompoundIdentityFuture<Boolean>
return null;
}
- synchronized (this) {
+ synchronized (futs) {
entries.add(c == null || c.reentry() ? null : entry);
if (c != null && !c.reentry())
@@ -614,7 +610,7 @@ public final class GridDhtLockFuture extends GridCompoundIdentityFuture<Boolean>
* @param t Error.
*/
public void onError(Throwable t) {
- synchronized (this) {
+ synchronized (futs) {
if (err != null)
return;
@@ -654,15 +650,16 @@ public final class GridDhtLockFuture extends GridCompoundIdentityFuture<Boolean>
* @param entry Entry whose lock ownership changed.
*/
@Override public boolean onOwnerChanged(GridCacheEntryEx entry, GridCacheMvccCandidate owner) {
- if (isDone())
+ if (isDone() || (inTx() && tx.remainingTime() == -1))
return false; // Check other futures.
if (log.isDebugEnabled())
log.debug("Received onOwnerChanged() callback [entry=" + entry + ", owner=" + owner + "]");
if (owner != null && owner.version().equals(lockVer)) {
- synchronized (this) {
- pendingLocks.remove(entry.key());
+ synchronized (futs) {
+ if (!pendingLocks.remove(entry.key()))
+ return false;
}
if (checkLocks())
@@ -677,8 +674,10 @@ public final class GridDhtLockFuture extends GridCompoundIdentityFuture<Boolean>
/**
* @return {@code True} if locks have been acquired.
*/
- private synchronized boolean checkLocks() {
- return pendingLocks.isEmpty();
+ private boolean checkLocks() {
+ synchronized (futs) {
+ return pendingLocks.isEmpty();
+ }
}
/** {@inheritDoc} */
@@ -709,7 +708,7 @@ public final class GridDhtLockFuture extends GridCompoundIdentityFuture<Boolean>
if (isDone() || (err == null && success && !checkLocks()))
return false;
- synchronized (this) {
+ synchronized (futs) {
if (this.err == null)
this.err = err;
}
@@ -776,13 +775,19 @@ public final class GridDhtLockFuture extends GridCompoundIdentityFuture<Boolean>
}
readyLocks();
+
+ if (timeout > 0) {
+ timeoutObj = new LockTimeoutObject();
+
+ cctx.time().addTimeoutObject(timeoutObj);
+ }
}
/**
* @param entries Entries.
*/
private void map(Iterable<GridDhtCacheEntry> entries) {
- synchronized (this) {
+ synchronized (futs) {
if (mapped)
return;
@@ -842,6 +847,8 @@ public final class GridDhtLockFuture extends GridCompoundIdentityFuture<Boolean>
if (log.isDebugEnabled())
log.debug("Mapped DHT lock future [dhtMap=" + F.nodeIds(dhtMap.keySet()) + ", dhtLockFut=" + this + ']');
+ long timeout = inTx() ? tx.remainingTime() : this.timeout;
+
// Create mini futures.
for (Map.Entry<ClusterNode, List<GridDhtCacheEntry>> mapped : dhtMap.entrySet()) {
ClusterNode n = mapped.getKey();
@@ -853,6 +860,9 @@ public final class GridDhtLockFuture extends GridCompoundIdentityFuture<Boolean>
if (cnt > 0) {
assert !n.id().equals(cctx.localNodeId());
+ if (inTx() && tx.remainingTime() == -1)
+ return;
+
MiniFuture fut = new MiniFuture(n, dhtMapping);
GridDhtLockRequest req = new GridDhtLockRequest(
@@ -1109,7 +1119,14 @@ public final class GridDhtLockFuture extends GridCompoundIdentityFuture<Boolean>
if (log.isDebugEnabled())
log.debug("Timed out waiting for lock response: " + this);
- timedOut = true;
+ synchronized (futs) {
+ timedOut = true;
+
+ // Stop locks and responses processing.
+ pendingLocks.clear();
+
+ futs.clear();
+ }
boolean releaseLocks = !(inTx() && cctx.tm().deadlockDetectionEnabled());
http://git-wip-us.apache.org/repos/asf/ignite/blob/0465874d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishFuture.java
index 4ece775..d2e26b4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishFuture.java
@@ -133,6 +133,7 @@ public final class GridDhtTxFinishFuture<K, V> extends GridCompoundIdentityFutur
}
/** {@inheritDoc} */
+ @SuppressWarnings("unchecked")
@Override public boolean onNodeLeft(UUID nodeId) {
for (IgniteInternalFuture<?> fut : futures())
if (isMini(fut)) {
@@ -391,8 +392,7 @@ public final class GridDhtTxFinishFuture<K, V> extends GridCompoundIdentityFutur
* @param nearMap Near map.
* @return {@code True} in case there is at least one synchronous {@code MiniFuture} to wait for.
*/
- private boolean finish(Map<UUID, GridDistributedTxMapping> dhtMap,
- Map<UUID, GridDistributedTxMapping> nearMap) {
+ private boolean finish(Map<UUID, GridDistributedTxMapping> dhtMap, Map<UUID, GridDistributedTxMapping> nearMap) {
if (tx.onePhaseCommit())
return false;
http://git-wip-us.apache.org/repos/asf/ignite/blob/0465874d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocal.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocal.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocal.java
index c9d4345..b659abb 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocal.java
@@ -314,6 +314,8 @@ public class GridDhtTxLocal extends GridDhtTxLocalAdapter implements GridCacheMa
true);
}
+ long timeout = remainingTime();
+
// For pessimistic mode we don't distribute prepare request.
GridDhtTxPrepareFuture fut = prepFut;
@@ -322,11 +324,16 @@ public class GridDhtTxLocal extends GridDhtTxLocalAdapter implements GridCacheMa
if (!PREP_FUT_UPD.compareAndSet(this, null, fut = new GridDhtTxPrepareFuture(
cctx,
this,
+ timeout,
nearMiniId,
Collections.<IgniteTxKey, GridCacheVersion>emptyMap(),
true,
- needReturnValue())))
+ needReturnValue()))) {
+ if (timeout == -1)
+ prepFut.onError(timeoutException());
+
return prepFut;
+ }
}
else
// Prepare was called explicitly.
@@ -334,15 +341,16 @@ public class GridDhtTxLocal extends GridDhtTxLocalAdapter implements GridCacheMa
if (!state(PREPARING)) {
if (setRollbackOnly()) {
- if (timedOut())
- fut.onError(new IgniteTxTimeoutCheckedException("Transaction timed out and was rolled back: " + this));
+ if (timeout == -1)
+ fut.onError(new IgniteTxTimeoutCheckedException("Transaction timed out and was rolled back: " +
+ this));
else
fut.onError(new IgniteCheckedException("Invalid transaction state for prepare [state=" + state() +
", tx=" + this + ']'));
}
else
- fut.onError(new IgniteTxRollbackCheckedException("Invalid transaction state for prepare [state=" + state()
- + ", tx=" + this + ']'));
+ fut.onError(new IgniteTxRollbackCheckedException("Invalid transaction state for prepare [state=" +
+ state() + ", tx=" + this + ']'));
return fut;
}
@@ -394,6 +402,8 @@ public class GridDhtTxLocal extends GridDhtTxLocalAdapter implements GridCacheMa
// In optimistic mode prepare still can be called explicitly from salvageTx.
GridDhtTxPrepareFuture fut = prepFut;
+ long timeout = remainingTime();
+
if (fut == null) {
init();
@@ -401,6 +411,7 @@ public class GridDhtTxLocal extends GridDhtTxLocalAdapter implements GridCacheMa
if (!PREP_FUT_UPD.compareAndSet(this, null, fut = new GridDhtTxPrepareFuture(
cctx,
this,
+ timeout,
nearMiniId,
verMap,
last,
@@ -410,6 +421,9 @@ public class GridDhtTxLocal extends GridDhtTxLocalAdapter implements GridCacheMa
assert f.nearMiniId().equals(nearMiniId) : "Wrong near mini id on existing future " +
"[futMiniId=" + f.nearMiniId() + ", miniId=" + nearMiniId + ", fut=" + f + ']';
+ if (timeout == -1)
+ f.onError(timeoutException());
+
return chainOnePhasePrepare(f);
}
}
@@ -427,7 +441,7 @@ public class GridDhtTxLocal extends GridDhtTxLocalAdapter implements GridCacheMa
fut.complete();
if (setRollbackOnly()) {
- if (timedOut())
+ if (timeout == -1)
fut.onError(new IgniteTxTimeoutCheckedException("Transaction timed out and was rolled back: " +
this));
else
http://git-wip-us.apache.org/repos/asf/ignite/blob/0465874d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
index e9805aa..1bdd9b8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
@@ -59,8 +59,10 @@ import org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry;
import org.apache.ignite.internal.processors.cache.transactions.IgniteTxKey;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
import org.apache.ignite.internal.processors.dr.GridDrType;
+import org.apache.ignite.internal.processors.timeout.GridTimeoutObjectAdapter;
import org.apache.ignite.internal.transactions.IgniteTxHeuristicCheckedException;
import org.apache.ignite.internal.transactions.IgniteTxOptimisticCheckedException;
+import org.apache.ignite.internal.transactions.IgniteTxTimeoutCheckedException;
import org.apache.ignite.internal.util.F0;
import org.apache.ignite.internal.util.GridLeanSet;
import org.apache.ignite.internal.util.future.GridCompoundFuture;
@@ -204,9 +206,13 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
/** */
private boolean invoke;
+ /** Timeout object. */
+ private final PrepareTimeoutObject timeoutObj;
+
/**
* @param cctx Context.
* @param tx Transaction.
+ * @param timeout Timeout.
* @param nearMiniId Near mini future id.
* @param dhtVerMap DHT versions map.
* @param last {@code True} if this is last prepare operation for node.
@@ -215,6 +221,7 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
public GridDhtTxPrepareFuture(
GridCacheSharedContext cctx,
final GridDhtTxLocalAdapter tx,
+ long timeout,
IgniteUuid nearMiniId,
Map<IgniteTxKey, GridCacheVersion> dhtVerMap,
boolean last,
@@ -243,6 +250,8 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
assert dhtMap != null;
assert nearMap != null;
+
+ timeoutObj = timeout > 0 ? new PrepareTimeoutObject(timeout) : null;
}
/** {@inheritDoc} */
@@ -269,7 +278,7 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
boolean rmv;
- synchronized (lockKeys) {
+ synchronized (futs) {
rmv = lockKeys.remove(entry.txKey());
}
@@ -300,7 +309,7 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
if (!locksReady)
return false;
- synchronized (lockKeys) {
+ synchronized (futs) {
return lockKeys.isEmpty();
}
}
@@ -483,32 +492,28 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
* @param res Result.
*/
public void onResult(UUID nodeId, GridDhtTxPrepareResponse res) {
- if (!isDone()) {
- boolean found = false;
-
- MiniFuture mini = miniFuture(res.miniId());
+ if (isDone()) {
+ if (msgLog.isDebugEnabled()) {
+ msgLog.debug("DHT prepare fut, response for finished future [txId=" + tx.nearXidVersion() +
+ ", dhtTxId=" + tx.xidVersion() +
+ ", node=" + nodeId +
+ ", res=" + res +
+ ", fut=" + this + ']');
+ }
- if (mini != null) {
- found = true;
+ return;
+ }
- assert mini.node().id().equals(nodeId);
+ MiniFuture mini = miniFuture(res.miniId());
- mini.onResult(res);
- }
+ if (mini != null) {
+ assert mini.node().id().equals(nodeId);
- if (!found) {
- if (msgLog.isDebugEnabled()) {
- msgLog.debug("DHT prepare fut, failed to find mini future [txId=" + tx.nearXidVersion() +
- ", dhtTxId=" + tx.xidVersion() +
- ", node=" + nodeId +
- ", res=" + res +
- ", fut=" + this + ']');
- }
- }
+ mini.onResult(res);
}
else {
if (msgLog.isDebugEnabled()) {
- msgLog.debug("DHT prepare fut, response for finished future [txId=" + tx.nearXidVersion() +
+ msgLog.debug("DHT prepare fut, failed to find mini future [txId=" + tx.nearXidVersion() +
", dhtTxId=" + tx.xidVersion() +
", node=" + nodeId +
", res=" + res +
@@ -525,8 +530,8 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
*/
@SuppressWarnings("ForLoopReplaceableByForEach")
private MiniFuture miniFuture(IgniteUuid miniId) {
- // We iterate directly over the futs collection here to avoid copy.
synchronized (futs) {
+ // We iterate directly over the futs collection here to avoid copy.
// Avoid iterator creation.
for (int i = 0; i < futs.size(); i++) {
IgniteInternalFuture<IgniteInternalTx> fut = futs.get(i);
@@ -543,9 +548,9 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
return null;
}
}
- }
- return null;
+ return null;
+ }
}
/**
@@ -583,7 +588,7 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
}
if (tx.optimistic() && txEntry.explicitVersion() == null) {
- synchronized (lockKeys) {
+ synchronized (futs) {
lockKeys.add(txEntry.txKey());
}
}
@@ -934,6 +939,9 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
// Don't forget to clean up.
cctx.mvcc().removeMvccFuture(this);
+ if (timeoutObj != null)
+ cctx.time().removeTimeoutObject(timeoutObj);
+
return true;
}
@@ -989,6 +997,11 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
readyLocks();
+ if (timeoutObj != null) {
+ // Start timeout tracking after 'readyLocks' to avoid race with timeout processing.
+ cctx.time().addTimeoutObject(timeoutObj);
+ }
+
mapIfLocked();
}
@@ -1158,6 +1171,8 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
if (last) {
assert tx.transactionNodes() != null;
+ final long timeout = timeoutObj != null ? timeoutObj.timeout : 0;
+
// Create mini futures.
for (GridDistributedTxMapping dhtMapping : tx.dhtMap().values()) {
assert !dhtMapping.empty();
@@ -1175,6 +1190,9 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
if (F.isEmpty(dhtWrites) && F.isEmpty(nearWrites))
continue;
+ if (tx.remainingTime() == -1)
+ return;
+
MiniFuture fut = new MiniFuture(n.id(), dhtMapping, nearMapping);
add(fut); // Append new future.
@@ -1186,6 +1204,7 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
fut.futureId(),
tx.topologyVersion(),
tx,
+ timeout,
dhtWrites,
nearWrites,
txNodes,
@@ -1284,15 +1303,19 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
for (GridDistributedTxMapping nearMapping : tx.nearMap().values()) {
if (!tx.dhtMap().containsKey(nearMapping.node().id())) {
+ if (tx.remainingTime() == -1)
+ return;
+
MiniFuture fut = new MiniFuture(nearMapping.node().id(), null, nearMapping);
- add(fut); // Append new future.
+ add(fut);
GridDhtTxPrepareRequest req = new GridDhtTxPrepareRequest(
futId,
fut.futureId(),
tx.topologyVersion(),
tx,
+ timeout,
null,
nearMapping.writes(),
tx.transactionNodes(),
@@ -1719,4 +1742,38 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
return S.toString(MiniFuture.class, this, "done", isDone(), "cancelled", isCancelled(), "err", error());
}
}
+
+ /**
+ *
+ */
+ private class PrepareTimeoutObject extends GridTimeoutObjectAdapter {
+ /** */
+ private final long timeout;
+
+ /**
+ * @param timeout Timeout.
+ */
+ PrepareTimeoutObject(long timeout) {
+ super(timeout);
+
+ this.timeout = timeout;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void onTimeout() {
+ synchronized (futs) {
+ futs.clear();
+
+ lockKeys.clear();
+ }
+
+ onError(new IgniteTxTimeoutCheckedException("Failed to acquire lock within " +
+ "provided timeout for transaction [timeout=" + tx.timeout() + ", tx=" + tx + ']'));
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(PrepareTimeoutObject.class, this);
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/0465874d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java
index d31ecba..1cdc96f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareRequest.java
@@ -112,6 +112,7 @@ public class GridDhtTxPrepareRequest extends GridDistributedTxPrepareRequest {
* @param miniId Mini future ID.
* @param topVer Topology version.
* @param tx Transaction.
+ * @param timeout Transaction timeout.
* @param dhtWrites DHT writes.
* @param nearWrites Near writes.
* @param txNodes Transaction nodes mapping.
@@ -124,6 +125,7 @@ public class GridDhtTxPrepareRequest extends GridDistributedTxPrepareRequest {
IgniteUuid miniId,
AffinityTopologyVersion topVer,
GridDhtTxLocalAdapter tx,
+ long timeout,
Collection<IgniteTxEntry> dhtWrites,
Collection<IgniteTxEntry> nearWrites,
Map<UUID, Collection<UUID>> txNodes,
@@ -133,7 +135,7 @@ public class GridDhtTxPrepareRequest extends GridDistributedTxPrepareRequest {
UUID subjId,
int taskNameHash,
boolean addDepInfo) {
- super(tx, null, dhtWrites, txNodes, onePhaseCommit, addDepInfo);
+ super(tx, timeout, null, dhtWrites, txNodes, onePhaseCommit, addDepInfo);
assert futId != null;
assert miniId != null;
http://git-wip-us.apache.org/repos/asf/ignite/blob/0465874d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java
index f77efee..b0eea01 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java
@@ -443,23 +443,33 @@ public final class GridDhtColocatedLockFuture extends GridCompoundIdentityFuture
/**
* @return Keys for which locks requested from remote nodes but response isn't received.
*/
- public Set<KeyCacheObject> requestedKeys() {
- Set<KeyCacheObject> requestedKeys = null;
+ public Set<IgniteTxKey> requestedKeys() {
+ synchronized (futs) {
+ if (timeoutObj != null && timeoutObj.requestedKeys != null)
+ return timeoutObj.requestedKeys;
+
+ return requestedKeys0();
+ }
+ }
+ /**
+ * @return Keys for which locks requested from remote nodes but response isn't received.
+ */
+ private Set<IgniteTxKey> requestedKeys0() {
for (IgniteInternalFuture<Boolean> miniFut : futures()) {
if (isMini(miniFut) && !miniFut.isDone()) {
- if (requestedKeys == null)
- requestedKeys = new HashSet<>();
-
MiniFuture mini = (MiniFuture)miniFut;
- requestedKeys.addAll(mini.keys);
+ Set<IgniteTxKey> requestedKeys = U.newHashSet(mini.keys.size());
+
+ for (KeyCacheObject key : mini.keys)
+ requestedKeys.add(new IgniteTxKey(key, cctx.cacheId()));
return requestedKeys;
}
}
- return requestedKeys;
+ return null;
}
/**
@@ -1312,12 +1322,21 @@ public final class GridDhtColocatedLockFuture extends GridCompoundIdentityFuture
super(timeout);
}
+ /** Requested keys. */
+ private Set<IgniteTxKey> requestedKeys;
+
/** {@inheritDoc} */
@Override public void onTimeout() {
if (log.isDebugEnabled())
log.debug("Timed out waiting for lock response: " + this);
if (inTx() && cctx.tm().deadlockDetectionEnabled()) {
+ synchronized (futs) {
+ requestedKeys = requestedKeys0();
+
+ futs.clear(); // Stop response processing.
+ }
+
Set<IgniteTxKey> keys = new HashSet<>();
for (IgniteTxEntry txEntry : tx.allEntries()) {
@@ -1434,7 +1453,7 @@ public final class GridDhtColocatedLockFuture extends GridCompoundIdentityFuture
tx.removeMapping(node.id());
// Primary node left the grid, so fail the future.
- GridDhtColocatedLockFuture.this.onDone(newTopologyException(e, node.id()));
+ GridDhtColocatedLockFuture.this.onDone(false, newTopologyException(e, node.id()));
onDone(true);
}
@@ -1494,7 +1513,7 @@ public final class GridDhtColocatedLockFuture extends GridCompoundIdentityFuture
else
remap();
}
- else {
+ else {
int i = 0;
for (KeyCacheObject k : keys) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/0465874d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java
index 4b6448b..3d9b6ab 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java
@@ -20,10 +20,12 @@ package org.apache.ignite.internal.processors.cache.distributed.near;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Queue;
+import java.util.Set;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicReference;
import org.apache.ignite.IgniteCheckedException;
@@ -48,8 +50,10 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTopolo
import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTransactionalCacheAdapter;
import org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry;
import org.apache.ignite.internal.processors.cache.transactions.IgniteTxKey;
+import org.apache.ignite.internal.processors.cache.transactions.TxDeadlock;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
import org.apache.ignite.internal.processors.timeout.GridTimeoutObjectAdapter;
+import org.apache.ignite.internal.transactions.IgniteTxTimeoutCheckedException;
import org.apache.ignite.internal.util.future.GridCompoundIdentityFuture;
import org.apache.ignite.internal.util.future.GridEmbeddedFuture;
import org.apache.ignite.internal.util.future.GridFutureAdapter;
@@ -63,7 +67,9 @@ import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteBiTuple;
+import org.apache.ignite.lang.IgniteInClosure;
import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.transactions.TransactionDeadlockException;
import org.apache.ignite.transactions.TransactionIsolation;
import org.jetbrains.annotations.Nullable;
import org.jsr166.ConcurrentHashMap8;
@@ -481,6 +487,38 @@ public final class GridNearLockFuture extends GridCompoundIdentityFuture<Boolean
}
/**
+ * @return Keys for which locks requested from remote nodes but response isn't received.
+ */
+ public Set<IgniteTxKey> requestedKeys() {
+ synchronized (futs) {
+ if (timeoutObj != null && timeoutObj.requestedKeys != null)
+ return timeoutObj.requestedKeys;
+
+ return requestedKeys0();
+ }
+ }
+
+ /**
+ * @return Keys for which locks requested from remote nodes but response isn't received.
+ */
+ private Set<IgniteTxKey> requestedKeys0() {
+ for (IgniteInternalFuture<Boolean> miniFut : futures()) {
+ if (isMini(miniFut) && !miniFut.isDone()) {
+ MiniFuture mini = (MiniFuture)miniFut;
+
+ Set<IgniteTxKey> requestedKeys = U.newHashSet(mini.keys.size());
+
+ for (KeyCacheObject key : mini.keys)
+ requestedKeys.add(new IgniteTxKey(key, cctx.cacheId()));
+
+ return requestedKeys;
+ }
+ }
+
+ return null;
+ }
+
+ /**
* Finds pending mini future by the given mini ID.
*
* @param miniId Mini ID to find.
@@ -621,6 +659,10 @@ public final class GridNearLockFuture extends GridCompoundIdentityFuture<Boolean
if (log.isDebugEnabled())
log.debug("Received onDone(..) callback [success=" + success + ", err=" + err + ", fut=" + this + ']');
+ if (inTx() && cctx.tm().deadlockDetectionEnabled() &&
+ (this.err instanceof IgniteTxTimeoutCheckedException || timedOut))
+ return false;
+
// If locks were not acquired yet, delay completion.
if (isDone() || (err == null && success && !checkLocks()))
return false;
@@ -727,7 +769,7 @@ public final class GridNearLockFuture extends GridCompoundIdentityFuture<Boolean
topVer = tx.topologyVersionSnapshot();
if (topVer != null) {
- for (GridDhtTopologyFuture fut : cctx.shared().exchange().exchangeFutures()){
+ for (GridDhtTopologyFuture fut : cctx.shared().exchange().exchangeFutures()) {
if (fut.topologyVersion().equals(topVer)){
Throwable err = fut.validateCache(cctx);
@@ -1373,6 +1415,9 @@ public final class GridNearLockFuture extends GridCompoundIdentityFuture<Boolean
super(timeout);
}
+ /** Requested keys. */
+ private Set<IgniteTxKey> requestedKeys;
+
/** {@inheritDoc} */
@SuppressWarnings({"ThrowableInstanceNeverThrown"})
@Override public void onTimeout() {
@@ -1381,7 +1426,42 @@ public final class GridNearLockFuture extends GridCompoundIdentityFuture<Boolean
timedOut = true;
- onComplete(false, true);
+ if (inTx() && cctx.tm().deadlockDetectionEnabled()) {
+ synchronized (futs) {
+ requestedKeys = requestedKeys0();
+
+ futs.clear(); // Stop response processing.
+ }
+
+ Set<IgniteTxKey> keys = new HashSet<>();
+
+ for (IgniteTxEntry txEntry : tx.allEntries()) {
+ if (!txEntry.locked())
+ keys.add(txEntry.txKey());
+ }
+
+ IgniteInternalFuture<TxDeadlock> fut = cctx.tm().detectDeadlock(tx, keys);
+
+ fut.listen(new IgniteInClosure<IgniteInternalFuture<TxDeadlock>>() {
+ @Override public void apply(IgniteInternalFuture<TxDeadlock> fut) {
+ try {
+ TxDeadlock deadlock = fut.get();
+
+ if (deadlock != null)
+ err = new TransactionDeadlockException(deadlock.toString(cctx.shared()));
+ }
+ catch (IgniteCheckedException e) {
+ err = e;
+
+ U.warn(log, "Failed to detect deadlock.", e);
+ }
+
+ onComplete(false, true);
+ }
+ });
+ }
+ else
+ onComplete(false, true);
}
/** {@inheritDoc} */
@@ -1466,7 +1546,7 @@ public final class GridNearLockFuture extends GridCompoundIdentityFuture<Boolean
tx.removeMapping(node.id());
// Primary node left the grid, so fail the future.
- GridNearLockFuture.this.onDone(newTopologyException(e, node.id()));
+ GridNearLockFuture.this.onDone(false, newTopologyException(e, node.id()));
onDone(true);
}
@@ -1483,6 +1563,10 @@ public final class GridNearLockFuture extends GridCompoundIdentityFuture<Boolean
}
if (res.error() != null) {
+ if (inTx() && cctx.tm().deadlockDetectionEnabled() &&
+ (res.error() instanceof IgniteTxTimeoutCheckedException || tx.remainingTime() == -1))
+ return;
+
if (log.isDebugEnabled())
log.debug("Finishing mini future with an error due to error in response [miniFut=" + this +
", res=" + res + ']');
http://git-wip-us.apache.org/repos/asf/ignite/blob/0465874d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticSerializableTxPrepareFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticSerializableTxPrepareFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticSerializableTxPrepareFuture.java
index 6515140..d251528 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticSerializableTxPrepareFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticSerializableTxPrepareFuture.java
@@ -184,7 +184,7 @@ public class GridNearOptimisticSerializableTxPrepareFuture extends GridNearOptim
}
}
- if (e instanceof IgniteTxOptimisticCheckedException) {
+ if (e instanceof IgniteTxOptimisticCheckedException || e instanceof IgniteTxTimeoutCheckedException) {
if (m != null)
tx.removeMapping(m.node().id());
}
@@ -424,10 +424,21 @@ public class GridNearOptimisticSerializableTxPrepareFuture extends GridNearOptim
final ClusterNode n = m.node();
+ long timeout = tx.remainingTime();
+
+ if (timeout == -1) {
+ IgniteCheckedException err = tx.timeoutException();
+
+ fut.onResult(err);
+
+ return err;
+ }
+
GridNearTxPrepareRequest req = new GridNearTxPrepareRequest(
futId,
tx.topologyVersion(),
tx,
+ timeout,
m.reads(),
m.writes(),
m.near(),
http://git-wip-us.apache.org/repos/asf/ignite/blob/0465874d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFuture.java
index 1ea99c4..5a300ff 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFuture.java
@@ -20,9 +20,11 @@ package org.apache.ignite.internal.processors.cache.distributed.near;
import java.util.ArrayDeque;
import java.util.Collection;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Queue;
+import java.util.Set;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
@@ -41,8 +43,11 @@ import org.apache.ignite.internal.processors.cache.distributed.GridDistributedTx
import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxMapping;
import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx;
import org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry;
+import org.apache.ignite.internal.processors.cache.transactions.IgniteTxKey;
+import org.apache.ignite.internal.processors.cache.transactions.TxDeadlock;
import org.apache.ignite.internal.transactions.IgniteTxRollbackCheckedException;
import org.apache.ignite.internal.transactions.IgniteTxTimeoutCheckedException;
+import org.apache.ignite.internal.util.future.GridEmbeddedFuture;
import org.apache.ignite.internal.util.future.GridFutureAdapter;
import org.apache.ignite.internal.util.tostring.GridToStringExclude;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
@@ -53,7 +58,9 @@ import org.apache.ignite.internal.util.typedef.P1;
import org.apache.ignite.internal.util.typedef.X;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteBiClosure;
import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.transactions.TransactionDeadlockException;
import org.apache.ignite.transactions.TransactionTimeoutException;
import org.jetbrains.annotations.Nullable;
@@ -73,8 +80,7 @@ public class GridNearOptimisticTxPrepareFuture extends GridNearOptimisticTxPrepa
* @param cctx Context.
* @param tx Transaction.
*/
- public GridNearOptimisticTxPrepareFuture(GridCacheSharedContext cctx,
- GridNearTxLocal tx) {
+ public GridNearOptimisticTxPrepareFuture(GridCacheSharedContext cctx, GridNearTxLocal tx) {
super(cctx, tx);
assert tx.optimistic() && !tx.serializable() : tx;
@@ -85,7 +91,11 @@ public class GridNearOptimisticTxPrepareFuture extends GridNearOptimisticTxPrepa
if (log.isDebugEnabled())
log.debug("Transaction future received owner changed callback: " + entry);
- if ((entry.context().isNear() || entry.context().isLocal()) && owner != null && tx.hasWriteKey(entry.txKey())) {
+ if (tx.remainingTime() == -1)
+ return false;
+
+ if ((entry.context().isNear() || entry.context().isLocal()) &&
+ owner != null && tx.hasWriteKey(entry.txKey())) {
if (keyLockFut != null)
keyLockFut.onKeyLocked(entry.txKey());
@@ -124,6 +134,12 @@ public class GridNearOptimisticTxPrepareFuture extends GridNearOptimisticTxPrepa
* @param discoThread {@code True} if executed from discovery thread.
*/
void onError(Throwable e, boolean discoThread) {
+ if (e instanceof IgniteTxTimeoutCheckedException) {
+ onTimeout();
+
+ return;
+ }
+
if (X.hasCause(e, ClusterTopologyCheckedException.class) || X.hasCause(e, ClusterTopologyException.class)) {
if (tx.onePhaseCommit()) {
tx.markForBackupCheck();
@@ -160,7 +176,7 @@ public class GridNearOptimisticTxPrepareFuture extends GridNearOptimisticTxPrepa
if (mini != null) {
assert mini.node().id().equals(nodeId);
- mini.onResult(nodeId, res);
+ mini.onResult(res);
}
else {
if (msgLog.isDebugEnabled()) {
@@ -182,6 +198,33 @@ public class GridNearOptimisticTxPrepareFuture extends GridNearOptimisticTxPrepa
}
/**
+ * @return Keys for which {@link MiniFuture} isn't completed.
+ */
+ @SuppressWarnings("ForLoopReplaceableByForEach")
+ public Set<IgniteTxKey> requestedKeys() {
+ synchronized (futs) {
+ for (int i = 0; i < futs.size(); i++) {
+ IgniteInternalFuture<GridNearTxPrepareResponse> fut = futs.get(i);
+
+ if (isMini(fut) && !fut.isDone()) {
+ MiniFuture miniFut = (MiniFuture)fut;
+
+ Collection<IgniteTxEntry> entries = miniFut.mapping().entries();
+
+ Set<IgniteTxKey> keys = U.newHashSet(entries.size());
+
+ for (IgniteTxEntry entry : entries)
+ keys.add(entry.txKey());
+
+ return keys;
+ }
+ }
+ }
+
+ return null;
+ }
+
+ /**
* Finds pending mini future by the given mini ID.
*
* @param miniId Mini ID to find.
@@ -264,7 +307,7 @@ public class GridNearOptimisticTxPrepareFuture extends GridNearOptimisticTxPrepa
if (!txStateCheck) {
if (tx.setRollbackOnly()) {
- if (tx.timedOut())
+ if (tx.remainingTime() == -1)
onError(new IgniteTxTimeoutCheckedException("Transaction timed out and " +
"was rolled back: " + this), false);
else
@@ -437,89 +480,97 @@ public class GridNearOptimisticTxPrepareFuture extends GridNearOptimisticTxPrepa
final ClusterNode n = m.node();
- GridNearTxPrepareRequest req = new GridNearTxPrepareRequest(
- futId,
- tx.topologyVersion(),
- tx,
- null,
- m.writes(),
- m.near(),
- txMapping.transactionNodes(),
- m.last(),
- tx.onePhaseCommit(),
- tx.needReturnValue() && tx.implicit(),
- tx.implicitSingle(),
- m.explicitLock(),
- tx.subjectId(),
- tx.taskNameHash(),
- m.clientFirst(),
- tx.activeCachesDeploymentEnabled());
-
- for (IgniteTxEntry txEntry : m.entries()) {
- if (txEntry.op() == TRANSFORM)
- req.addDhtVersion(txEntry.txKey(), null);
- }
+ long timeout = tx.remainingTime();
+
+ if (timeout != -1) {
+ GridNearTxPrepareRequest req = new GridNearTxPrepareRequest(
+ futId,
+ tx.topologyVersion(),
+ tx,
+ timeout,
+ null,
+ m.writes(),
+ m.near(),
+ txMapping.transactionNodes(),
+ m.last(),
+ tx.onePhaseCommit(),
+ tx.needReturnValue() && tx.implicit(),
+ tx.implicitSingle(),
+ m.explicitLock(),
+ tx.subjectId(),
+ tx.taskNameHash(),
+ m.clientFirst(),
+ tx.activeCachesDeploymentEnabled());
+
+ for (IgniteTxEntry txEntry : m.entries()) {
+ if (txEntry.op() == TRANSFORM)
+ req.addDhtVersion(txEntry.txKey(), null);
+ }
- // Must lock near entries separately.
- if (m.near()) {
- try {
- tx.optimisticLockEntries(req.writes());
+ // Must lock near entries separately.
+ if (m.near()) {
+ try {
+ tx.optimisticLockEntries(req.writes());
- tx.userPrepare();
- }
- catch (IgniteCheckedException e) {
- onError(e, false);
+ tx.userPrepare();
+ }
+ catch (IgniteCheckedException e) {
+ onError(e, false);
+ }
}
- }
- final MiniFuture fut = new MiniFuture(this, m, mappings);
+ final MiniFuture fut = new MiniFuture(this, m, mappings);
- req.miniId(fut.futureId());
+ req.miniId(fut.futureId());
- add(fut); // Append new future.
+ add(fut); // Append new future.
- // If this is the primary node for the keys.
- if (n.isLocal()) {
- // At this point, if any new node joined, then it is
- // waiting for this transaction to complete, so
- // partition reassignments are not possible here.
- IgniteInternalFuture<GridNearTxPrepareResponse> prepFut = cctx.tm().txHandler().prepareTx(n.id(), tx, req);
+ // If this is the primary node for the keys.
+ if (n.isLocal()) {
+ // At this point, if any new node joined, then it is
+ // waiting for this transaction to complete, so
+ // partition reassignments are not possible here.
+ IgniteInternalFuture<GridNearTxPrepareResponse> prepFut =
+ cctx.tm().txHandler().prepareTx(n.id(), tx, req);
- prepFut.listen(new CI1<IgniteInternalFuture<GridNearTxPrepareResponse>>() {
- @Override public void apply(IgniteInternalFuture<GridNearTxPrepareResponse> prepFut) {
- try {
- fut.onResult(n.id(), prepFut.get());
+ prepFut.listen(new CI1<IgniteInternalFuture<GridNearTxPrepareResponse>>() {
+ @Override public void apply(IgniteInternalFuture<GridNearTxPrepareResponse> prepFut) {
+ try {
+ fut.onResult(prepFut.get());
+ }
+ catch (IgniteCheckedException e) {
+ fut.onResult(e);
+ }
}
- catch (IgniteCheckedException e) {
- fut.onResult(e);
+ });
+ }
+ else {
+ try {
+ cctx.io().send(n, req, tx.ioPolicy());
+
+ if (msgLog.isDebugEnabled()) {
+ msgLog.debug("Near optimistic prepare fut, sent request [txId=" + tx.nearXidVersion() +
+ ", node=" + n.id() + ']');
}
}
- });
- }
- else {
- try {
- cctx.io().send(n, req, tx.ioPolicy());
+ catch (ClusterTopologyCheckedException e) {
+ e.retryReadyFuture(cctx.nextAffinityReadyFuture(tx.topologyVersion()));
- if (msgLog.isDebugEnabled()) {
- msgLog.debug("Near optimistic prepare fut, sent request [txId=" + tx.nearXidVersion() +
- ", node=" + n.id() + ']');
+ fut.onNodeLeft(e, false);
}
- }
- catch (ClusterTopologyCheckedException e) {
- e.retryReadyFuture(cctx.nextAffinityReadyFuture(tx.topologyVersion()));
+ catch (IgniteCheckedException e) {
+ if (msgLog.isDebugEnabled()) {
+ msgLog.debug("Near optimistic prepare fut, failed to sent request [txId=" + tx.nearXidVersion() +
+ ", node=" + n.id() +
+ ", err=" + e + ']');
+ }
- fut.onNodeLeft(e, false);
- }
- catch (IgniteCheckedException e) {
- if (msgLog.isDebugEnabled()) {
- msgLog.debug("Near optimistic prepare fut, failed to sent request [txId=" + tx.nearXidVersion() +
- ", node=" + n.id() +
- ", err=" + e + ']');
+ fut.onResult(e);
}
-
- fut.onResult(e);
}
}
+ else
+ onTimeout();
}
finally {
if (set)
@@ -623,6 +674,61 @@ public class GridNearOptimisticTxPrepareFuture extends GridNearOptimisticTxPrepa
return cur;
}
+ /**
+ *
+ */
+ @SuppressWarnings("ForLoopReplaceableByForEach")
+ private void onTimeout() {
+ if (cctx.tm().deadlockDetectionEnabled()) {
+ Set<IgniteTxKey> keys = null;
+
+ if (keyLockFut != null)
+ keys = new HashSet<>(keyLockFut.lockKeys);
+ else {
+ if (futs != null && !futs.isEmpty()) {
+ for (int i = 0; i < futs.size(); i++) {
+ IgniteInternalFuture<GridNearTxPrepareResponse> fut = futs.get(i);
+
+ if (isMini(fut) && !fut.isDone()) {
+ MiniFuture miniFut = (MiniFuture)fut;
+
+ Collection<IgniteTxEntry> entries = miniFut.mapping().entries();
+
+ keys = U.newHashSet(entries.size());
+
+ for (IgniteTxEntry entry : entries)
+ keys.add(entry.txKey());
+
+ break;
+ }
+ }
+ }
+ }
+
+ add(new GridEmbeddedFuture<>(new IgniteBiClosure<TxDeadlock, Exception, GridNearTxPrepareResponse>() {
+ @Override public GridNearTxPrepareResponse apply(TxDeadlock deadlock, Exception e) {
+ if (e != null)
+ U.warn(log, "Failed to detect deadlock.", e);
+ else {
+ e = new IgniteTxTimeoutCheckedException("Failed to acquire lock within provided timeout for " +
+ "transaction [timeout=" + tx.timeout() + ", tx=" + tx + ']',
+ deadlock != null ? new TransactionDeadlockException(deadlock.toString(cctx)) : null);
+ }
+
+ onDone(null, e);
+
+ return null;
+ }
+ }, cctx.tm().detectDeadlock(tx, keys)));
+ }
+ else {
+ ERR_UPD.compareAndSet(this, null, new IgniteTxTimeoutCheckedException("Failed to acquire lock " +
+ "within provided timeout for transaction [timeout=" + tx.timeout() + ", tx=" + tx + ']'));
+
+ onComplete(false);
+ }
+ }
+
/** {@inheritDoc} */
@Override public String toString() {
Collection<String> futs = F.viewReadOnly(futures(), new C1<IgniteInternalFuture<?>, String>() {
@@ -652,7 +758,7 @@ public class GridNearOptimisticTxPrepareFuture extends GridNearOptimisticTxPrepa
private static final long serialVersionUID = 0L;
/** Receive result flag updater. */
- private static AtomicIntegerFieldUpdater<MiniFuture> RCV_RES_UPD =
+ private static final AtomicIntegerFieldUpdater<MiniFuture> RCV_RES_UPD =
AtomicIntegerFieldUpdater.newUpdater(MiniFuture.class, "rcvRes");
/** Parent future. */
@@ -745,15 +851,21 @@ public class GridNearOptimisticTxPrepareFuture extends GridNearOptimisticTxPrepa
}
/**
- * @param nodeId Failed node ID.
* @param res Result callback.
*/
@SuppressWarnings("ThrowableResultOfMethodCallIgnored")
- void onResult(UUID nodeId, final GridNearTxPrepareResponse res) {
+ void onResult(final GridNearTxPrepareResponse res) {
if (isDone())
return;
if (RCV_RES_UPD.compareAndSet(this, 0, 1)) {
+ if (parent.cctx.tm().deadlockDetectionEnabled() &&
+ (parent.tx.remainingTime() == -1 || res.error() instanceof IgniteTxTimeoutCheckedException)) {
+ parent.onTimeout();
+
+ return;
+ }
+
if (res.error() != null) {
// Fail the whole compound future.
parent.onError(res.error(), false);
@@ -801,8 +913,7 @@ public class GridNearOptimisticTxPrepareFuture extends GridNearOptimisticTxPrepa
*/
private void remap() {
parent.prepareOnTopology(true, new Runnable() {
- @Override
- public void run() {
+ @Override public void run() {
onDone((GridNearTxPrepareResponse) null);
}
});
http://git-wip-us.apache.org/repos/asf/ignite/blob/0465874d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFutureAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFutureAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFutureAdapter.java
index 4d77a3c..a00cf3e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFutureAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFutureAdapter.java
@@ -40,8 +40,7 @@ public abstract class GridNearOptimisticTxPrepareFutureAdapter extends GridNearT
* @param cctx Context.
* @param tx Transaction.
*/
- public GridNearOptimisticTxPrepareFutureAdapter(GridCacheSharedContext cctx,
- GridNearTxLocal tx) {
+ public GridNearOptimisticTxPrepareFutureAdapter(GridCacheSharedContext cctx, GridNearTxLocal tx) {
super(cctx, tx);
assert tx.optimistic() : tx;
@@ -172,7 +171,7 @@ public abstract class GridNearOptimisticTxPrepareFutureAdapter extends GridNearT
protected static class KeyLockFuture extends GridFutureAdapter<GridNearTxPrepareResponse> {
/** */
@GridToStringInclude
- private Collection<IgniteTxKey> lockKeys = new GridConcurrentHashSet<>();
+ protected Collection<IgniteTxKey> lockKeys = new GridConcurrentHashSet<>();
/** */
private volatile boolean allKeysAdded;
http://git-wip-us.apache.org/repos/asf/ignite/blob/0465874d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearPessimisticTxPrepareFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearPessimisticTxPrepareFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearPessimisticTxPrepareFuture.java
index ef2edc9..34b8281 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearPessimisticTxPrepareFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearPessimisticTxPrepareFuture.java
@@ -153,7 +153,7 @@ public class GridNearPessimisticTxPrepareFuture extends GridNearTxPrepareFutureA
@Override public void prepare() {
if (!tx.state(PREPARING)) {
if (tx.setRollbackOnly()) {
- if (tx.timedOut())
+ if (tx.remainingTime() == -1)
onDone(new IgniteTxTimeoutCheckedException("Transaction timed out and was rolled back: " + tx));
else
onDone(new IgniteCheckedException("Invalid transaction state for prepare " +
@@ -222,6 +222,11 @@ public class GridNearPessimisticTxPrepareFuture extends GridNearTxPrepareFutureA
checkOnePhase();
+ long timeout = tx.remainingTime();
+
+ if (timeout == -1)
+ onDone(new IgniteTxTimeoutCheckedException("Transaction timed out and was rolled back: " + tx));
+
for (final GridDistributedTxMapping m : mappings.values()) {
final ClusterNode node = m.node();
@@ -229,6 +234,7 @@ public class GridNearPessimisticTxPrepareFuture extends GridNearTxPrepareFutureA
futId,
tx.topologyVersion(),
tx,
+ timeout,
m.reads(),
m.writes(),
m.near(),
http://git-wip-us.apache.org/repos/asf/ignite/blob/0465874d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishFuture.java
index adde63c..bb5d482 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishFuture.java
@@ -633,6 +633,9 @@ public final class GridNearTxFinishFuture<K, V> extends GridCompoundIdentityFutu
if (m.explicitLock())
syncMode = FULL_SYNC;
+ // Version to be added in completed versions on primary node.
+ GridCacheVersion completedVer = !commit && tx.timeout() > 0 ? tx.xidVersion() : null;
+
GridNearTxFinishRequest req = new GridNearTxFinishRequest(
futId,
tx.xidVersion(),
@@ -645,7 +648,7 @@ public final class GridNearTxFinishFuture<K, V> extends GridCompoundIdentityFutu
m.explicitLock(),
tx.storeEnabled(),
tx.topologyVersion(),
- null,
+ completedVer, // Reuse 'baseVersion' to do not add new fields in message.
null,
null,
tx.size(),
http://git-wip-us.apache.org/repos/asf/ignite/blob/0465874d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
index 28c60d4..410baf8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
@@ -796,6 +796,8 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter {
GridNearTxPrepareFutureAdapter fut = (GridNearTxPrepareFutureAdapter)prepFut;
if (fut == null) {
+ long timeout = remainingTime();
+
// Future must be created before any exception can be thrown.
if (optimistic()) {
fut = serializable() ?
@@ -807,6 +809,12 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter {
if (!PREP_FUT_UPD.compareAndSet(this, null, fut))
return prepFut;
+
+ if (timeout == -1) {
+ fut.onDone(this, timeoutException());
+
+ return fut;
+ }
}
else
// Prepare was called explicitly.
@@ -964,8 +972,10 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter {
Map<UUID, Collection<UUID>> txNodes,
boolean last
) {
+ long timeout = remainingTime();
+
if (state() != PREPARING) {
- if (timedOut())
+ if (timeout == -1)
return new GridFinishedFuture<>(
new IgniteTxTimeoutCheckedException("Transaction timed out: " + this));
@@ -975,11 +985,15 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter {
new IgniteCheckedException("Invalid transaction state for prepare [state=" + state() + ", tx=" + this + ']'));
}
+ if (timeout == -1)
+ return new GridFinishedFuture<>(timeoutException());
+
init();
GridDhtTxPrepareFuture fut = new GridDhtTxPrepareFuture(
cctx,
this,
+ timeout,
IgniteUuid.randomUuid(),
Collections.<IgniteTxKey, GridCacheVersion>emptyMap(),
last,
http://git-wip-us.apache.org/repos/asf/ignite/blob/0465874d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareRequest.java
index 9dfdb43..e55566b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareRequest.java
@@ -94,6 +94,7 @@ public class GridNearTxPrepareRequest extends GridDistributedTxPrepareRequest {
* @param futId Future ID.
* @param topVer Topology version.
* @param tx Transaction.
+ * @param timeout Transaction timeout.
* @param reads Read entries.
* @param writes Write entries.
* @param near {@code True} if mapping is for near caches.
@@ -112,6 +113,7 @@ public class GridNearTxPrepareRequest extends GridDistributedTxPrepareRequest {
IgniteUuid futId,
AffinityTopologyVersion topVer,
IgniteInternalTx tx,
+ long timeout,
Collection<IgniteTxEntry> reads,
Collection<IgniteTxEntry> writes,
boolean near,
@@ -126,7 +128,7 @@ public class GridNearTxPrepareRequest extends GridDistributedTxPrepareRequest {
boolean firstClientReq,
boolean addDepInfo
) {
- super(tx, reads, writes, txNodes, onePhaseCommit, addDepInfo);
+ super(tx, timeout, reads, writes, txNodes, onePhaseCommit, addDepInfo);
assert futId != null;
assert !firstClientReq || tx.optimistic() : tx;
http://git-wip-us.apache.org/repos/asf/ignite/blob/0465874d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteInternalTx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteInternalTx.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteInternalTx.java
index 8c0425d..dd900fe 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteInternalTx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteInternalTx.java
@@ -33,7 +33,6 @@ import org.apache.ignite.internal.processors.cache.GridCacheFilterFailedExceptio
import org.apache.ignite.internal.processors.cache.GridCacheMvccCandidate;
import org.apache.ignite.internal.processors.cache.KeyCacheObject;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
-import org.apache.ignite.internal.processors.timeout.GridTimeoutObject;
import org.apache.ignite.internal.transactions.IgniteTxTimeoutCheckedException;
import org.apache.ignite.internal.util.lang.GridTuple;
import org.apache.ignite.lang.IgniteAsyncSupported;
@@ -46,7 +45,7 @@ import org.jetbrains.annotations.Nullable;
/**
* Transaction managed by cache ({@code 'Ex'} stands for external).
*/
-public interface IgniteInternalTx extends AutoCloseable, GridTimeoutObject {
+public interface IgniteInternalTx extends AutoCloseable {
/**
*
*/
http://git-wip-us.apache.org/repos/asf/ignite/blob/0465874d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
index f76f4bf..eb2989e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
@@ -712,7 +712,7 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter implement
/**
* @return Transaction timeout exception.
*/
- protected final IgniteCheckedException timeoutException() {
+ public final IgniteCheckedException timeoutException() {
return new IgniteTxTimeoutCheckedException("Failed to acquire lock within provided timeout " +
"for transaction [timeout=" + timeout() + ", tx=" + this + ']');
}
@@ -1032,7 +1032,7 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter implement
* @return {@code True} if state changed.
*/
@SuppressWarnings({"TooBroadScope"})
- private boolean state(TransactionState state, boolean timedOut) {
+ protected boolean state(TransactionState state, boolean timedOut) {
boolean valid = false;
TransactionState prev;
@@ -1154,24 +1154,6 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter implement
}
/** {@inheritDoc} */
- @Override public IgniteUuid timeoutId() {
- return xidVer.asGridUuid();
- }
-
- /** {@inheritDoc} */
- @Override public long endTime() {
- long endTime = timeout == 0 ? Long.MAX_VALUE : startTime + timeout;
-
- return endTime > 0 ? endTime : endTime < 0 ? Long.MAX_VALUE : endTime;
- }
-
- /** {@inheritDoc} */
- @Override public void onTimeout() {
- if (local() && !dht())
- state(MARKED_ROLLBACK, true);
- }
-
- /** {@inheritDoc} */
@Override public boolean timedOut() {
return timedOut;
}
@@ -2387,21 +2369,6 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter implement
}
/** {@inheritDoc} */
- @Override public IgniteUuid timeoutId() {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public long endTime() {
- return 0;
- }
-
- /** {@inheritDoc} */
- @Override public void onTimeout() {
- // No-op.
- }
-
- /** {@inheritDoc} */
@Override public boolean equals(Object o) {
return this == o || o instanceof IgniteInternalTx && xid.equals(((IgniteInternalTx)o).xid());
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/0465874d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
index 7c3c206..e67e60f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
@@ -112,8 +112,7 @@ public class IgniteTxHandler {
* @param req Request.
* @return Prepare future.
*/
- public IgniteInternalFuture<?> processNearTxPrepareRequest(final UUID nearNodeId,
- final GridNearTxPrepareRequest req) {
+ public IgniteInternalFuture<?> processNearTxPrepareRequest(final UUID nearNodeId, GridNearTxPrepareRequest req) {
if (txPrepareMsgLog.isDebugEnabled()) {
txPrepareMsgLog.debug("Received near prepare request [txId=" + req.version() +
", node=" + nearNodeId + ']');
@@ -361,7 +360,7 @@ public class IgniteTxHandler {
req.deployInfo() != null);
try {
- ctx.io().send(nearNode, res, req.policy());
+ ctx.io().send(nearNodeId, res, req.policy());
if (txPrepareMsgLog.isDebugEnabled()) {
txPrepareMsgLog.debug("Sent remap response for near prepare [txId=" + req.version() +
@@ -667,6 +666,10 @@ public class IgniteTxHandler {
assert nodeId != null;
assert req != null;
+ // 'baseVersion' message field is re-used for version to be added in completed versions.
+ if (!req.commit() && req.baseVersion() != null)
+ ctx.tm().addRolledbackTx(null, req.baseVersion());
+
// Transaction on local cache only.
if (locTx != null && !locTx.nearLocallyMapped() && !locTx.colocatedLocallyMapped())
return new GridFinishedFuture<IgniteInternalTx>(locTx);
http://git-wip-us.apache.org/repos/asf/ignite/blob/0465874d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
index d9aca4a..9ad7fb0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
@@ -107,6 +107,7 @@ import static org.apache.ignite.internal.processors.dr.GridDrType.DR_NONE;
import static org.apache.ignite.internal.processors.dr.GridDrType.DR_PRIMARY;
import static org.apache.ignite.transactions.TransactionState.COMMITTED;
import static org.apache.ignite.transactions.TransactionState.COMMITTING;
+import static org.apache.ignite.transactions.TransactionState.MARKED_ROLLBACK;
import static org.apache.ignite.transactions.TransactionState.PREPARING;
import static org.apache.ignite.transactions.TransactionState.ROLLED_BACK;
import static org.apache.ignite.transactions.TransactionState.ROLLING_BACK;
@@ -547,14 +548,15 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
@SuppressWarnings({"CatchGenericClass"})
public void userPrepare() throws IgniteCheckedException {
if (state() != PREPARING) {
- if (timedOut())
+ if (remainingTime() == -1)
throw new IgniteTxTimeoutCheckedException("Transaction timed out: " + this);
TransactionState state = state();
setRollbackOnly();
- throw new IgniteCheckedException("Invalid transaction state for prepare [state=" + state + ", tx=" + this + ']');
+ throw new IgniteCheckedException("Invalid transaction state for prepare [state=" +
+ state + ", tx=" + this + ']');
}
checkValid();
@@ -629,7 +631,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
TransactionState state = state();
if (state != COMMITTING) {
- if (timedOut())
+ if (remainingTime() == -1)
throw new IgniteTxTimeoutCheckedException("Transaction timed out: " + this);
setRollbackOnly();
@@ -3540,8 +3542,11 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
* @throws IgniteCheckedException If transaction check failed.
*/
protected void checkValid() throws IgniteCheckedException {
+ if (local() && !dht() && remainingTime() == -1)
+ state(MARKED_ROLLBACK, true);
+
if (isRollbackOnly()) {
- if (timedOut())
+ if (remainingTime() == -1)
throw new IgniteTxTimeoutCheckedException("Cache transaction timed out: " + this);
TransactionState state = state();
@@ -3556,10 +3561,6 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
throw new IgniteCheckedException("Cache transaction marked as rollback-only: " + this);
}
-
- if (remainingTime() == -1 && setRollbackOnly())
- throw new IgniteTxTimeoutCheckedException("Cache transaction timed out " +
- "(was rolled back automatically): " + this);
}
/** {@inheritDoc} */
@@ -3604,7 +3605,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
TransactionState state = state();
- assert state == TransactionState.ACTIVE || timedOut() :
+ assert state == TransactionState.ACTIVE || remainingTime() == -1 :
"Invalid tx state for adding entry [op=" + op + ", val=" + val + ", entry=" + entry + ", filter=" +
Arrays.toString(filter) + ", txCtx=" + cctx.tm().txContextVersion() + ", tx=" + this + ']';
[07/50] [abbrv] ignite git commit: IGNITE-3751: ODBC: Added system
functions support. This closes #985.
Posted by sb...@apache.org.
IGNITE-3751: ODBC: Added system functions support. This closes #985.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/8aabd6ea
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/8aabd6ea
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/8aabd6ea
Branch: refs/heads/ignite-961
Commit: 8aabd6ea65d883d3bbcf37c05c146105dff8a6e2
Parents: e21111f
Author: isapego <ig...@gmail.com>
Authored: Thu Aug 25 16:30:20 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Thu Aug 25 16:30:20 2016 +0300
----------------------------------------------------------------------
modules/platforms/cpp/odbc-test/Makefile.am | 1 +
.../include/sql_function_test_suite_fixture.h | 49 +++++++++++++-
.../cpp/odbc-test/project/vs/odbc-test.vcxproj | 1 +
.../project/vs/odbc-test.vcxproj.filters | 3 +
.../src/sql_function_test_suite_fixture.cpp | 49 ++++++++++++++
.../odbc-test/src/sql_system_functions_test.cpp | 68 ++++++++++++++++++++
.../cpp/odbc/src/config/connection_info.cpp | 2 +-
7 files changed, 171 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/8aabd6ea/modules/platforms/cpp/odbc-test/Makefile.am
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/Makefile.am b/modules/platforms/cpp/odbc-test/Makefile.am
index 6288637..1e00b6f 100644
--- a/modules/platforms/cpp/odbc-test/Makefile.am
+++ b/modules/platforms/cpp/odbc-test/Makefile.am
@@ -66,6 +66,7 @@ ignite_odbc_tests_SOURCES = \
src/sql_string_functions_test.cpp \
src/sql_numeric_functions_test.cpp \
src/sql_aggregate_functions_test.cpp \
+ src/sql_system_functions_test.cpp \
../odbc/src/cursor.cpp \
../odbc/src/config/connection_info.cpp \
../odbc/src/app/application_data_buffer.cpp \
http://git-wip-us.apache.org/repos/asf/ignite/blob/8aabd6ea/modules/platforms/cpp/odbc-test/include/sql_function_test_suite_fixture.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/include/sql_function_test_suite_fixture.h b/modules/platforms/cpp/odbc-test/include/sql_function_test_suite_fixture.h
index c09c1ae..eef0a9b 100644
--- a/modules/platforms/cpp/odbc-test/include/sql_function_test_suite_fixture.h
+++ b/modules/platforms/cpp/odbc-test/include/sql_function_test_suite_fixture.h
@@ -78,7 +78,18 @@ namespace ignite
{
BOOST_FAIL("Function is not defined for the type.");
}
-
+
+ /**
+ * Run query returning single result and check it to be successful.
+ *
+ * @param request SQL request.
+ */
+ template<typename T>
+ void CheckSingleResult(const char* request)
+ {
+ BOOST_FAIL("Function is not defined for the type.");
+ }
+
/**
* Run query returning single result and check it to be equal to expected.
*
@@ -96,6 +107,21 @@ namespace ignite
BOOST_CHECK_EQUAL(res, expected);
}
+ /**
+ * Run query returning single result and check it to be equal to expected.
+ *
+ * @param request SQL request.
+ * @param expected Expected result.
+ * @param type Result type.
+ */
+ template<typename T>
+ void CheckSingleResultNum0(const char* request, SQLSMALLINT type)
+ {
+ T res = 0;
+
+ CheckSingleResult0(request, type, &res, 0, 0);
+ }
+
/** Node started during the test. */
Ignite grid;
@@ -133,6 +159,27 @@ namespace ignite
template<>
void SqlFunctionTestSuiteFixture::CheckSingleResult<double>(const char* request, const double& expected);
+
+ template<>
+ void SqlFunctionTestSuiteFixture::CheckSingleResult<std::string>(const char* request);
+
+ template<>
+ void SqlFunctionTestSuiteFixture::CheckSingleResult<int64_t>(const char* request);
+
+ template<>
+ void SqlFunctionTestSuiteFixture::CheckSingleResult<int32_t>(const char* request);
+
+ template<>
+ void SqlFunctionTestSuiteFixture::CheckSingleResult<int16_t>(const char* request);
+
+ template<>
+ void SqlFunctionTestSuiteFixture::CheckSingleResult<int8_t>(const char* request);
+
+ template<>
+ void SqlFunctionTestSuiteFixture::CheckSingleResult<float>(const char* request);
+
+ template<>
+ void SqlFunctionTestSuiteFixture::CheckSingleResult<double>(const char* request);
}
#endif //_IGNITE_ODBC_TEST_SQL_FUNCTION_TEST_FIXTURE
http://git-wip-us.apache.org/repos/asf/ignite/blob/8aabd6ea/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj b/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj
index e0b786a..2a94a2a 100644
--- a/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj
+++ b/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj
@@ -172,6 +172,7 @@
<ClCompile Include="..\..\src\sql_function_test_suite_fixture.cpp" />
<ClCompile Include="..\..\src\sql_numeric_functions_test.cpp" />
<ClCompile Include="..\..\src\sql_string_functions_test.cpp" />
+ <ClCompile Include="..\..\src\sql_system_functions_test.cpp" />
<ClCompile Include="..\..\src\teamcity\teamcity_boost.cpp" />
<ClCompile Include="..\..\src\teamcity\teamcity_messages.cpp" />
<ClCompile Include="..\..\src\test_utils.cpp" />
http://git-wip-us.apache.org/repos/asf/ignite/blob/8aabd6ea/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters b/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters
index 763a364..9ca51af 100644
--- a/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters
+++ b/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters
@@ -91,6 +91,9 @@
<ClCompile Include="..\..\src\sql_aggregate_functions_test.cpp">
<Filter>Code</Filter>
</ClCompile>
+ <ClCompile Include="..\..\src\sql_system_functions_test.cpp">
+ <Filter>Code</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\include\test_type.h">
http://git-wip-us.apache.org/repos/asf/ignite/blob/8aabd6ea/modules/platforms/cpp/odbc-test/src/sql_function_test_suite_fixture.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/sql_function_test_suite_fixture.cpp b/modules/platforms/cpp/odbc-test/src/sql_function_test_suite_fixture.cpp
index 2398393..f848dc5 100644
--- a/modules/platforms/cpp/odbc-test/src/sql_function_test_suite_fixture.cpp
+++ b/modules/platforms/cpp/odbc-test/src/sql_function_test_suite_fixture.cpp
@@ -185,4 +185,53 @@ namespace ignite
BOOST_CHECK_CLOSE(static_cast<double>(res), expected, 1E-6);
}
+
+ template<>
+ void SqlFunctionTestSuiteFixture::CheckSingleResult<std::string>(const char* request)
+ {
+ SQLCHAR res[ODBC_BUFFER_SIZE] = { 0 };
+ SQLLEN resLen = 0;
+
+ CheckSingleResult0(request, SQL_C_CHAR, res, ODBC_BUFFER_SIZE, &resLen);
+ }
+
+ template<>
+ void SqlFunctionTestSuiteFixture::CheckSingleResult<int64_t>(const char* request)
+ {
+ CheckSingleResultNum0<int64_t>(request, SQL_C_SBIGINT);
+ }
+
+ template<>
+ void SqlFunctionTestSuiteFixture::CheckSingleResult<int32_t>(const char* request)
+ {
+ CheckSingleResultNum0<int32_t>(request, SQL_C_SLONG);
+ }
+
+ template<>
+ void SqlFunctionTestSuiteFixture::CheckSingleResult<int16_t>(const char* request)
+ {
+ CheckSingleResultNum0<int16_t>(request, SQL_C_SSHORT);
+ }
+
+ template<>
+ void SqlFunctionTestSuiteFixture::CheckSingleResult<int8_t>(const char* request)
+ {
+ CheckSingleResultNum0<int8_t>(request, SQL_C_STINYINT);
+ }
+
+ template<>
+ void SqlFunctionTestSuiteFixture::CheckSingleResult<float>(const char* request)
+ {
+ SQLFLOAT res = 0;
+
+ CheckSingleResult0(request, SQL_C_FLOAT, &res, 0, 0);
+ }
+
+ template<>
+ void SqlFunctionTestSuiteFixture::CheckSingleResult<double>(const char* request)
+ {
+ SQLDOUBLE res = 0;
+
+ CheckSingleResult0(request, SQL_C_DOUBLE, &res, 0, 0);
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/8aabd6ea/modules/platforms/cpp/odbc-test/src/sql_system_functions_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/sql_system_functions_test.cpp b/modules/platforms/cpp/odbc-test/src/sql_system_functions_test.cpp
new file mode 100644
index 0000000..d369b0f
--- /dev/null
+++ b/modules/platforms/cpp/odbc-test/src/sql_system_functions_test.cpp
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifdef _WIN32
+# include <windows.h>
+#endif
+
+#include <sql.h>
+#include <sqlext.h>
+
+#include <vector>
+#include <string>
+
+#ifndef _MSC_VER
+# define BOOST_TEST_DYN_LINK
+#endif
+
+#include <boost/test/unit_test.hpp>
+
+#include "ignite/ignite.h"
+#include "ignite/ignition.h"
+#include "ignite/impl/binary/binary_utils.h"
+
+#include "test_type.h"
+#include "test_utils.h"
+#include "sql_function_test_suite_fixture.h"
+
+using namespace ignite;
+using namespace ignite::cache;
+using namespace ignite::cache::query;
+using namespace ignite::common;
+
+using namespace boost::unit_test;
+
+using ignite::impl::binary::BinaryUtils;
+
+BOOST_FIXTURE_TEST_SUITE(SqlSystemFunctionTestSuite, ignite::SqlFunctionTestSuiteFixture)
+
+BOOST_AUTO_TEST_CASE(TestSystemFunctionDatabase)
+{
+ CheckSingleResult<std::string>("SELECT {fn DATABASE()}");
+}
+
+BOOST_AUTO_TEST_CASE(TestSystemFunctionUser)
+{
+ CheckSingleResult<std::string>("SELECT {fn USER()}");
+}
+
+BOOST_AUTO_TEST_CASE(TestSystemFunctionIfnull)
+{
+ CheckSingleResult<int32_t>("SELECT {fn IFNULL(NULL, 42)}", 42);
+}
+
+BOOST_AUTO_TEST_SUITE_END()
http://git-wip-us.apache.org/repos/asf/ignite/blob/8aabd6ea/modules/platforms/cpp/odbc/src/config/connection_info.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/config/connection_info.cpp b/modules/platforms/cpp/odbc/src/config/connection_info.cpp
index b2480c2..cff48cf 100644
--- a/modules/platforms/cpp/odbc/src/config/connection_info.cpp
+++ b/modules/platforms/cpp/odbc/src/config/connection_info.cpp
@@ -286,7 +286,7 @@ namespace ignite
#ifdef SQL_SYSTEM_FUNCTIONS
// Bitmask enumerating the scalar system functions supported by the
// driver and associated data source.
- intParams[SQL_SYSTEM_FUNCTIONS] = 0;
+ intParams[SQL_SYSTEM_FUNCTIONS] = SQL_FN_SYS_USERNAME | SQL_FN_SYS_DBNAME | SQL_FN_SYS_IFNULL;
#endif // SQL_SYSTEM_FUNCTIONS
#ifdef SQL_CONVERT_FUNCTIONS
[09/50] [abbrv] ignite git commit: IGNITE-3390: ODBC: Added DSN
configuration dialog for Windows. This closes #881.
Posted by sb...@apache.org.
IGNITE-3390: ODBC: Added DSN configuration dialog for Windows. This closes #881.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/60afa372
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/60afa372
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/60afa372
Branch: refs/heads/ignite-961
Commit: 60afa372906246d43456518e5f76a454ca2bcadf
Parents: 4343c73
Author: isapego <ig...@gmail.com>
Authored: Thu Aug 25 16:37:43 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Thu Aug 25 16:37:43 2016 +0300
----------------------------------------------------------------------
.../cpp/common/include/ignite/common/utils.h | 7 +
.../cpp/common/os/win/src/common/utils.cpp | 20 ++
.../cpp/core/include/ignite/ignition.h | 2 +-
modules/platforms/cpp/core/src/ignition.cpp | 8 +-
.../cpp/odbc-test/src/configuration_test.cpp | 6 +-
modules/platforms/cpp/odbc/Makefile.am | 1 +
modules/platforms/cpp/odbc/include/Makefile.am | 1 +
.../platforms/cpp/odbc/include/ignite/odbc.h | 1 -
.../include/ignite/odbc/config/configuration.h | 93 +++++-
.../ignite/odbc/diagnostic/diagnostic_record.h | 2 +-
.../cpp/odbc/include/ignite/odbc/dsn_config.h | 61 ++++
.../odbc/include/ignite/odbc/protocol_version.h | 20 +-
.../include/ignite/odbc/system/odbc_constants.h | 4 -
.../odbc/system/ui/dsn_configuration_window.h | 152 +++++++++
.../ignite/odbc/system/ui/custom_window.h | 189 ++++++++++++
.../win/include/ignite/odbc/system/ui/window.h | 201 ++++++++++++
.../odbc/os/win/src/system/ui/custom_window.cpp | 184 +++++++++++
.../src/system/ui/dsn_configuration_window.cpp | 305 +++++++++++++++++++
.../cpp/odbc/os/win/src/system/ui/window.cpp | 192 ++++++++++++
.../cpp/odbc/os/win/src/system_dsn.cpp | 218 +++++++++++++
.../platforms/cpp/odbc/project/vs/odbc.vcxproj | 25 +-
.../cpp/odbc/project/vs/odbc.vcxproj.filters | 30 ++
.../cpp/odbc/src/config/configuration.cpp | 17 +-
modules/platforms/cpp/odbc/src/connection.cpp | 2 +-
.../odbc/src/diagnostic/diagnostic_record.cpp | 2 +-
.../diagnostic/diagnostic_record_storage.cpp | 2 +-
modules/platforms/cpp/odbc/src/dsn_config.cpp | 115 +++++++
modules/platforms/cpp/odbc/src/entry_points.cpp | 8 -
modules/platforms/cpp/odbc/src/odbc.cpp | 88 ++----
.../platforms/cpp/odbc/src/protocol_version.cpp | 23 +-
30 files changed, 1868 insertions(+), 111 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/60afa372/modules/platforms/cpp/common/include/ignite/common/utils.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/include/ignite/common/utils.h b/modules/platforms/cpp/common/include/ignite/common/utils.h
index 331fcb2..f4d2a9f 100644
--- a/modules/platforms/cpp/common/include/ignite/common/utils.h
+++ b/modules/platforms/cpp/common/include/ignite/common/utils.h
@@ -60,6 +60,13 @@ namespace ignite
}
/**
+ * Strips leading and trailing whitespaces from string.
+ *
+ * @param str String to be transformed.
+ */
+ IGNITE_IMPORT_EXPORT void StripSurroundingWhitespaces(std::string& str);
+
+ /**
* Get string representation of long in decimal form.
*
* @param val Long value to be converted to string.
http://git-wip-us.apache.org/repos/asf/ignite/blob/60afa372/modules/platforms/cpp/common/os/win/src/common/utils.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/os/win/src/common/utils.cpp b/modules/platforms/cpp/common/os/win/src/common/utils.cpp
index 47d7f43..77c90b8 100644
--- a/modules/platforms/cpp/common/os/win/src/common/utils.cpp
+++ b/modules/platforms/cpp/common/os/win/src/common/utils.cpp
@@ -40,6 +40,26 @@ namespace ignite
return false;
}
+ void StripSurroundingWhitespaces(std::string& str)
+ {
+ std::string::size_type newBegin = 0;
+ while (newBegin < str.size() && ::isspace(str[newBegin]))
+ ++newBegin;
+
+ if (newBegin == str.size())
+ {
+ str.clear();
+
+ return;
+ }
+
+ std::string::size_type newEnd = str.size() - 1;
+ while (::isspace(str[newEnd]))
+ --newEnd;
+
+ str.assign(str, newBegin, (newEnd - newBegin) + 1);
+ }
+
time_t IgniteTimeGm(const tm& time)
{
tm tmc = time;
http://git-wip-us.apache.org/repos/asf/ignite/blob/60afa372/modules/platforms/cpp/core/include/ignite/ignition.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/ignition.h b/modules/platforms/cpp/core/include/ignite/ignition.h
index f88efe5..57fd51c 100644
--- a/modules/platforms/cpp/core/include/ignite/ignition.h
+++ b/modules/platforms/cpp/core/include/ignite/ignition.h
@@ -154,7 +154,7 @@ namespace ignite
* @param err Error.
*/
static void StopAll(bool cancel, IgniteError* err);
- };
+ };
}
#endif //_IGNITE_IGNITION
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/60afa372/modules/platforms/cpp/core/src/ignition.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/src/ignition.cpp b/modules/platforms/cpp/core/src/ignition.cpp
index 4a7d941..83adb4c 100644
--- a/modules/platforms/cpp/core/src/ignition.cpp
+++ b/modules/platforms/cpp/core/src/ignition.cpp
@@ -216,9 +216,9 @@ namespace ignite
int optsLen;
char** opts = CreateJvmOptions(cfg, homeFound ? &home : NULL, cp, &optsLen);
-
+
envTarget = new SharedPointer<IgniteEnvironment>(env);
-
+
SharedPointer<JniContext> ctx(
JniContext::Create(opts, optsLen, env.Get()->GetJniHandlers(envTarget), &jniErr));
@@ -258,7 +258,7 @@ namespace ignite
if (!javaRef) {
IgniteError::SetError(jniErr.code, jniErr.errCls, jniErr.errMsg, err);
-
+
failed = true;
}
else {
@@ -458,7 +458,7 @@ namespace ignite
JniErrorInfo jniErr;
SharedPointer<JniContext> ctx(JniContext::Create(NULL, 0, JniHandlers(), &jniErr));
-
+
IgniteError::SetError(jniErr.code, jniErr.errCls, jniErr.errMsg, err);
if (err->GetCode() == IgniteError::IGNITE_SUCCESS)
http://git-wip-us.apache.org/repos/asf/ignite/blob/60afa372/modules/platforms/cpp/odbc-test/src/configuration_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/configuration_test.cpp b/modules/platforms/cpp/odbc-test/src/configuration_test.cpp
index c0bb439..1851eae 100644
--- a/modules/platforms/cpp/odbc-test/src/configuration_test.cpp
+++ b/modules/platforms/cpp/odbc-test/src/configuration_test.cpp
@@ -49,7 +49,7 @@ void CheckValidAddress(const char* connectStr, uint16_t port)
BOOST_CHECK_NO_THROW(cfg.FillFromConnectString(connectStr));
- BOOST_CHECK_EQUAL(cfg.GetPort(), port);
+ BOOST_CHECK_EQUAL(cfg.GetTcpPort(), port);
}
void CheckValidProtocolVersion(const char* connectStr, ignite::odbc::ProtocolVersion version)
@@ -92,7 +92,7 @@ void CheckConnectionConfig(const Configuration& cfg)
{
BOOST_CHECK_EQUAL(cfg.GetDriver(), testDriverName);
BOOST_CHECK_EQUAL(cfg.GetHost(), testServerHost);
- BOOST_CHECK_EQUAL(cfg.GetPort(), testServerPort);
+ BOOST_CHECK_EQUAL(cfg.GetTcpPort(), testServerPort);
BOOST_CHECK_EQUAL(cfg.GetAddress(), testAddress);
BOOST_CHECK_EQUAL(cfg.GetCache(), testCacheName);
BOOST_CHECK_EQUAL(cfg.GetDsn(), std::string());
@@ -119,7 +119,7 @@ void CheckDsnConfig(const Configuration& cfg)
BOOST_CHECK_EQUAL(cfg.GetCache(), Configuration::DefaultValue::cache);
BOOST_CHECK_EQUAL(cfg.GetAddress(), Configuration::DefaultValue::address);
BOOST_CHECK_EQUAL(cfg.GetHost(), std::string());
- BOOST_CHECK_EQUAL(cfg.GetPort(), Configuration::DefaultValue::port);
+ BOOST_CHECK_EQUAL(cfg.GetTcpPort(), Configuration::DefaultValue::port);
BOOST_CHECK_EQUAL(cfg.IsDistributedJoins(), false);
BOOST_CHECK_EQUAL(cfg.IsEnforceJoinOrder(), false);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/60afa372/modules/platforms/cpp/odbc/Makefile.am
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/Makefile.am b/modules/platforms/cpp/odbc/Makefile.am
index 9faa999..1781bc0 100644
--- a/modules/platforms/cpp/odbc/Makefile.am
+++ b/modules/platforms/cpp/odbc/Makefile.am
@@ -62,6 +62,7 @@ libignite_odbc_la_SOURCES = \
src/meta/table_meta.cpp \
src/odbc.cpp \
src/entry_points.cpp \
+ src/dsn_config.cpp \
src/query/column_metadata_query.cpp \
src/query/data_query.cpp \
src/query/foreign_keys_query.cpp \
http://git-wip-us.apache.org/repos/asf/ignite/blob/60afa372/modules/platforms/cpp/odbc/include/Makefile.am
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/Makefile.am b/modules/platforms/cpp/odbc/include/Makefile.am
index 0776548..073dcaa 100644
--- a/modules/platforms/cpp/odbc/include/Makefile.am
+++ b/modules/platforms/cpp/odbc/include/Makefile.am
@@ -38,6 +38,7 @@ noinst_HEADERS = \
ignite/odbc/row.h \
ignite/odbc/utility.h \
ignite/odbc/environment.h \
+ ignite/odbc/dsn_config.h \
ignite/odbc/system/odbc_constants.h \
ignite/odbc/system/socket_client.h \
ignite/odbc/meta/primary_key_meta.h \
http://git-wip-us.apache.org/repos/asf/ignite/blob/60afa372/modules/platforms/cpp/odbc/include/ignite/odbc.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc.h b/modules/platforms/cpp/odbc/include/ignite/odbc.h
index 40158dd..810d186 100644
--- a/modules/platforms/cpp/odbc/include/ignite/odbc.h
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc.h
@@ -251,7 +251,6 @@ namespace ignite
SQLSMALLINT tableNameLen,
SQLSMALLINT scope,
SQLSMALLINT nullable);
-
} // namespace ignite
#endif //_IGNITE_ODBC
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/60afa372/modules/platforms/cpp/odbc/include/ignite/odbc/config/configuration.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/config/configuration.h b/modules/platforms/cpp/odbc/include/ignite/odbc/config/configuration.h
index 30f9ad6..8e19a6e 100644
--- a/modules/platforms/cpp/odbc/include/ignite/odbc/config/configuration.h
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/config/configuration.h
@@ -160,12 +160,19 @@ namespace ignite
*
* @return Server port.
*/
- uint16_t GetPort() const
+ uint16_t GetTcpPort() const
{
return endPoint.port;
}
/**
+ * Set server port.
+ *
+ * @param port Server port.
+ */
+ void SetTcpPort(uint16_t port);
+
+ /**
* Get DSN.
*
* @return Data Source Name.
@@ -176,6 +183,16 @@ namespace ignite
}
/**
+ * Set DSN.
+ *
+ * @param dsn Data Source Name.
+ */
+ void SetDsn(const std::string& dsn)
+ {
+ arguments[Key::dsn] = dsn;
+ }
+
+ /**
* Get Driver.
*
* @return Driver name.
@@ -196,6 +213,16 @@ namespace ignite
}
/**
+ * Set server host.
+ *
+ * @param server Server host.
+ */
+ void SetHost(const std::string& server)
+ {
+ arguments[Key::server] = server;
+ }
+
+ /**
* Get cache.
*
* @return Cache name.
@@ -206,6 +233,16 @@ namespace ignite
}
/**
+ * Set cache.
+ *
+ * @param cache Cache name.
+ */
+ void SetCache(const std::string& cache)
+ {
+ arguments[Key::cache] = cache;
+ }
+
+ /**
* Get address.
*
* @return Address.
@@ -216,6 +253,16 @@ namespace ignite
}
/**
+ * Set address.
+ *
+ * @param address Address.
+ */
+ void SetAddress(const std::string& address)
+ {
+ arguments[Key::address] = address;
+ }
+
+ /**
* Check distributed joins flag.
*
* @return True if distributed joins are enabled.
@@ -226,6 +273,16 @@ namespace ignite
}
/**
+ * Set distributed joins.
+ *
+ * @param val Value to set.
+ */
+ void SetDistributedJoins(bool val)
+ {
+ SetBoolValue(Key::distributedJoins, val);
+ }
+
+ /**
* Check enforce join order flag.
*
* @return True if enforcing of join order is enabled.
@@ -236,6 +293,26 @@ namespace ignite
}
/**
+ * Set enforce joins.
+ *
+ * @param val Value to set.
+ */
+ void SetEnforceJoinOrder(bool val)
+ {
+ SetBoolValue(Key::enforceJoinOrder, val);
+ }
+
+ /**
+ * Get argument map.
+ *
+ * @return Argument map.
+ */
+ const ArgumentMap& GetMap() const
+ {
+ return arguments;
+ }
+
+ /**
* Get protocol version.
*
* @return Protocol version.
@@ -243,6 +320,13 @@ namespace ignite
ProtocolVersion GetProtocolVersion() const;
/**
+ * Set protocol version.
+ *
+ * @param version Version to set.
+ */
+ void SetProtocolVersion(const std::string& version);
+
+ /**
* Get string value from the config.
*
* @param key Configuration key.
@@ -269,6 +353,13 @@ namespace ignite
*/
bool GetBoolValue(const std::string& key, bool dflt) const;
+ /**
+ * Set bool value to the config.
+ *
+ * @param key Configuration key.
+ * @param val Value to set.
+ */
+ void SetBoolValue(const std::string& key, bool val);
private:
/**
* Parse connect string into key-value storage.
http://git-wip-us.apache.org/repos/asf/ignite/blob/60afa372/modules/platforms/cpp/odbc/include/ignite/odbc/diagnostic/diagnostic_record.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/diagnostic/diagnostic_record.h b/modules/platforms/cpp/odbc/include/ignite/odbc/diagnostic/diagnostic_record.h
index bfb4f4c..670e0aa 100644
--- a/modules/platforms/cpp/odbc/include/ignite/odbc/diagnostic/diagnostic_record.h
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/diagnostic/diagnostic_record.h
@@ -84,7 +84,7 @@ namespace ignite
*
* @return An informational message on the error or warning.
*/
- const std::string& GetMessage() const;
+ const std::string& GetMessageText() const;
/**
* Get connection name.
http://git-wip-us.apache.org/repos/asf/ignite/blob/60afa372/modules/platforms/cpp/odbc/include/ignite/odbc/dsn_config.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/dsn_config.h b/modules/platforms/cpp/odbc/include/ignite/odbc/dsn_config.h
new file mode 100644
index 0000000..dbad9b5
--- /dev/null
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/dsn_config.h
@@ -0,0 +1,61 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_ODBC_DSN_CONFIG
+#define _IGNITE_ODBC_DSN_CONFIG
+
+#include "ignite/odbc/config/configuration.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ /**
+ * Extract last setup error and throw it like IgniteError.
+ */
+ void ThrowLastSetupError();
+
+ /**
+ * Add new string to the DSN file.
+ *
+ * @param dsn DSN name.
+ * @param key Key.
+ * @param value Value.
+ */
+ void WriteDsnString(const char* dsn, const char* key, const char* value);
+
+ /**
+ * Get string from the DSN file.
+ *
+ * @param dsn DSN name.
+ * @param key Key.
+ * @param dflt Default value.
+ * @return Value.
+ */
+ std::string ReadDsnString(const char* dsn, const char* key, const char* dflt);
+
+ /**
+ * Read DSN to fill the configuration.
+ *
+ * @param dsn DSN name.
+ * @param config Configuration.
+ */
+ void ReadDsnConfiguration(const char* dsn, config::Configuration& config);
+ }
+}
+
+#endif //_IGNITE_ODBC_DSN_CONFIG
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/60afa372/modules/platforms/cpp/odbc/include/ignite/odbc/protocol_version.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/protocol_version.h b/modules/platforms/cpp/odbc/include/ignite/odbc/protocol_version.h
index 747d78d..d3d288e 100644
--- a/modules/platforms/cpp/odbc/include/ignite/odbc/protocol_version.h
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/protocol_version.h
@@ -47,6 +47,13 @@ namespace ignite
static const ProtocolVersion VERSION_UNKNOWN;
/**
+ * Get string to version map.
+ *
+ * @return String to version map.
+ */
+ static const StringToVersionMap& GetMap();
+
+ /**
* Get current version.
*
* @return Current version.
@@ -86,6 +93,13 @@ namespace ignite
bool IsUnknown() const;
/**
+ * Check if the distributed joins supported.
+ *
+ * @retuen True if the distributed joins supported.
+ */
+ bool IsDistributedJoinsSupported() const;
+
+ /**
* Comparison operator.
*
* @param val1 First value.
@@ -152,10 +166,12 @@ namespace ignite
*
* @param major Major version.
* @param minor Minor version.
- * @param maintenance Maintenance version.
+ * @param revision Revision.
* @return Int value for the version.
*/
- static int64_t MakeVersion(uint16_t major, uint16_t minor, uint16_t maintenance);
+ static int64_t MakeVersion(uint16_t major, uint16_t minor, uint16_t revision);
+
+ ProtocolVersion();
/** String to version map. */
static const StringToVersionMap stringToVersionMap;
http://git-wip-us.apache.org/repos/asf/ignite/blob/60afa372/modules/platforms/cpp/odbc/include/ignite/odbc/system/odbc_constants.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/system/odbc_constants.h b/modules/platforms/cpp/odbc/include/ignite/odbc/system/odbc_constants.h
index 60a6552..ecd1a55 100644
--- a/modules/platforms/cpp/odbc/include/ignite/odbc/system/odbc_constants.h
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/system/odbc_constants.h
@@ -27,10 +27,6 @@
# undef min
#endif // min
-#ifdef GetMessage
-# undef GetMessage
-#endif // GetMessage
-
#endif //_WIN32
#define ODBCVER 0x0380
http://git-wip-us.apache.org/repos/asf/ignite/blob/60afa372/modules/platforms/cpp/odbc/include/ignite/odbc/system/ui/dsn_configuration_window.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/system/ui/dsn_configuration_window.h b/modules/platforms/cpp/odbc/include/ignite/odbc/system/ui/dsn_configuration_window.h
new file mode 100644
index 0000000..d2cb569
--- /dev/null
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/system/ui/dsn_configuration_window.h
@@ -0,0 +1,152 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_ODBC_SYSTEM_UI_DSN_CONFIGURATION_WINDOW
+#define _IGNITE_ODBC_SYSTEM_UI_DSN_CONFIGURATION_WINDOW
+
+#include "ignite/odbc/config/configuration.h"
+#include "ignite/odbc/system/ui/custom_window.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ namespace system
+ {
+ namespace ui
+ {
+ /**
+ * DSN configuration window class.
+ */
+ class DsnConfigurationWindow : public CustomWindow
+ {
+ /**
+ * Children windows ids.
+ */
+ enum ChildId
+ {
+ ID_CONNECTION_SETTINGS_GROUP_BOX,
+ ID_NAME_EDIT,
+ ID_NAME_LABEL,
+ ID_ADDRESS_EDIT,
+ ID_ADDRESS_LABEL,
+ ID_CACHE_EDIT,
+ ID_CACHE_LABEL,
+ ID_DISTRIBUTED_JOINS_CHECK_BOX,
+ ID_ENFORCE_JOIN_ORDER_CHECK_BOX,
+ ID_PROTOCOL_VERSION_LABEL,
+ ID_PROTOCOL_VERSION_COMBO_BOX,
+ ID_OK_BUTTON,
+ ID_CANCEL_BUTTON
+ };
+
+ public:
+ /**
+ * Constructor.
+ *
+ * @param parent Parent window handle.
+ */
+ explicit DsnConfigurationWindow(Window* parent, config::Configuration& config);
+
+ /**
+ * Destructor.
+ */
+ virtual ~DsnConfigurationWindow();
+
+ /**
+ * Create window in the center of the parent window.
+ */
+ void Create();
+
+ /**
+ * @copedoc ignite::odbc::system::ui::CustomWindow::OnCreate
+ */
+ virtual void OnCreate();
+
+ /**
+ * @copedoc ignite::odbc::system::ui::CustomWindow::OnMessage
+ */
+ virtual bool OnMessage(UINT msg, WPARAM wParam, LPARAM lParam);
+
+ private:
+ IGNITE_NO_COPY_ASSIGNMENT(DsnConfigurationWindow)
+
+ /**
+ * Retrieves current values from the children and stores
+ * them to the specified configuration.
+ *
+ * @param cfg Configuration.
+ */
+ void RetrieveParameters(config::Configuration& cfg) const;
+
+ /** Window width. */
+ int width;
+
+ /** Window height. */
+ int height;
+
+ /** Connection settings group box. */
+ std::auto_ptr<Window> connectionSettingsGroupBox;
+
+ /** DSN name edit field label. */
+ std::auto_ptr<Window> nameLabel;
+
+ /** DSN name edit field. */
+ std::auto_ptr<Window> nameEdit;
+
+ /** DSN address edit field label. */
+ std::auto_ptr<Window> addressLabel;
+
+ /** DSN address edit field. */
+ std::auto_ptr<Window> addressEdit;
+
+ /** DSN cache edit field label. */
+ std::auto_ptr<Window> cacheLabel;
+
+ /** DSN cache edit field. */
+ std::auto_ptr<Window> cacheEdit;
+
+ /** Distributed joins CheckBox. */
+ std::auto_ptr<Window> distributedJoinsCheckBox;
+
+ /** Enforce join order CheckBox. */
+ std::auto_ptr<Window> enforceJoinOrderCheckBox;
+
+ /** Protocol version edit field. */
+ std::auto_ptr<Window> protocolVersionLabel;
+
+ /** Protocol verion ComboBox. */
+ std::auto_ptr<Window> protocolVersionComboBox;
+
+ /** Ok button. */
+ std::auto_ptr<Window> okButton;
+
+ /** Cancel button. */
+ std::auto_ptr<Window> cancelButton;
+
+ /** Configuration. */
+ config::Configuration& config;
+
+ /** Flag indicating whether OK option was selected. */
+ bool accepted;
+ };
+ }
+ }
+ }
+}
+
+#endif //_IGNITE_ODBC_SYSTEM_UI_DSN_CONFIGURATION_WINDOW
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/60afa372/modules/platforms/cpp/odbc/os/win/include/ignite/odbc/system/ui/custom_window.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/os/win/include/ignite/odbc/system/ui/custom_window.h b/modules/platforms/cpp/odbc/os/win/include/ignite/odbc/system/ui/custom_window.h
new file mode 100644
index 0000000..1502c07
--- /dev/null
+++ b/modules/platforms/cpp/odbc/os/win/include/ignite/odbc/system/ui/custom_window.h
@@ -0,0 +1,189 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_ODBC_SYSTEM_UI_CUSTOM_WINDOW
+#define _IGNITE_ODBC_SYSTEM_UI_CUSTOM_WINDOW
+
+#include "ignite/odbc/system/ui/window.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ namespace system
+ {
+ namespace ui
+ {
+ /**
+ * Application execution result.
+ */
+ enum Result
+ {
+ RESULT_OK,
+ RESULT_CANCEL
+ };
+
+ /**
+ * Process UI messages in current thread.
+ * Blocks until quit message has been received.
+ *
+ * @param window Main window.
+ * @return Application execution result.
+ */
+ Result ProcessMessages(Window& window);
+
+ /**
+ * Window class.
+ */
+ class CustomWindow : public Window
+ {
+ public:
+ /**
+ * Constructor.
+ *
+ * @param parent Parent window.
+ * @param className Window class name.
+ * @param title Window title.
+ * @param callback Event processing function.
+ */
+ CustomWindow(Window* parent, const char* className, const char* title);
+
+ /**
+ * Destructor.
+ */
+ virtual ~CustomWindow();
+
+ /**
+ * Callback which is called upon receiving new message.
+ * Pure virtual. Should be defined by user.
+ *
+ * @param msg Message.
+ * @param wParam Word-sized parameter.
+ * @param lParam Long parameter.
+ * @return Should return true if the message has been
+ * processed by the handler and false otherwise.
+ */
+ virtual bool OnMessage(UINT msg, WPARAM wParam, LPARAM lParam) = 0;
+
+ /**
+ * Callback that is called upon window creation.
+ */
+ virtual void OnCreate() = 0;
+
+ /**
+ * Create child group box window.
+ *
+ * @param posX Position by X coordinate.
+ * @param posY Position by Y coordinate.
+ * @param sizeX Size by X coordinate.
+ * @param sizeY Size by Y coordinate.
+ * @param title Title.
+ * @param id ID to be assigned to the created window.
+ * @return Auto pointer containing new window.
+ */
+ std::auto_ptr<Window> CreateGroupBox(int posX, int posY,
+ int sizeX, int sizeY, const char* title, int id);
+
+ /**
+ * Create child label window.
+ *
+ * @param posX Position by X coordinate.
+ * @param posY Position by Y coordinate.
+ * @param sizeX Size by X coordinate.
+ * @param sizeY Size by Y coordinate.
+ * @param title Title.
+ * @param id ID to be assigned to the created window.
+ * @return Auto pointer containing new window.
+ */
+ std::auto_ptr<Window> CreateLabel(int posX, int posY,
+ int sizeX, int sizeY, const char* title, int id);
+
+ /**
+ * Create child Edit window.
+ *
+ * @param posX Position by X coordinate.
+ * @param posY Position by Y coordinate.
+ * @param sizeX Size by X coordinate.
+ * @param sizeY Size by Y coordinate.
+ * @param title Title.
+ * @param id ID to be assigned to the created window.
+ * @return Auto pointer containing new window.
+ */
+ std::auto_ptr<Window> CreateEdit(int posX, int posY,
+ int sizeX, int sizeY, const char* title, int id, int style = 0);
+
+ /**
+ * Create child button window.
+ *
+ * @param posX Position by X coordinate.
+ * @param posY Position by Y coordinate.
+ * @param sizeX Size by X coordinate.
+ * @param sizeY Size by Y coordinate.
+ * @param title Title.
+ * @param id ID to be assigned to the created window.
+ * @return Auto pointer containing new window.
+ */
+ std::auto_ptr<Window> CreateButton(int posX, int posY,
+ int sizeX, int sizeY, const char* title, int id);
+
+ /**
+ * Create child CheckBox window.
+ *
+ * @param posX Position by X coordinate.
+ * @param posY Position by Y coordinate.
+ * @param sizeX Size by X coordinate.
+ * @param sizeY Size by Y coordinate.
+ * @param title Title.
+ * @param id ID to be assigned to the created window.
+ * @return Auto pointer containing new window.
+ */
+ std::auto_ptr<Window> CreateCheckBox(int posX, int posY,
+ int sizeX, int sizeY, const char* title, int id, bool state);
+
+ /**
+ * Create child ComboBox window.
+ *
+ * @param posX Position by X coordinate.
+ * @param posY Position by Y coordinate.
+ * @param sizeX Size by X coordinate.
+ * @param sizeY Size by Y coordinate.
+ * @param title Title.
+ * @param id ID to be assigned to the created window.
+ * @return Auto pointer containing new window.
+ */
+ std::auto_ptr<Window> CreateComboBox(int posX, int posY,
+ int sizeX, int sizeY, const char* title, int id);
+ private:
+ IGNITE_NO_COPY_ASSIGNMENT(CustomWindow)
+
+ /**
+ * Static callback.
+ *
+ * @param hwnd Window handle.
+ * @param msg Message.
+ * @param wParam Word-sized parameter.
+ * @param lParam Long parameter.
+ * @return Operation result.
+ */
+ static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
+ };
+ }
+ }
+ }
+}
+
+#endif //_IGNITE_ODBC_SYSTEM_UI_CUSTOM_WINDOW
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/60afa372/modules/platforms/cpp/odbc/os/win/include/ignite/odbc/system/ui/window.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/os/win/include/ignite/odbc/system/ui/window.h b/modules/platforms/cpp/odbc/os/win/include/ignite/odbc/system/ui/window.h
new file mode 100644
index 0000000..32a54b2
--- /dev/null
+++ b/modules/platforms/cpp/odbc/os/win/include/ignite/odbc/system/ui/window.h
@@ -0,0 +1,201 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_ODBC_SYSTEM_UI_WINDOW
+#define _IGNITE_ODBC_SYSTEM_UI_WINDOW
+
+#include "ignite/odbc/utility.h"
+#include "ignite/odbc/system/odbc_constants.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ namespace system
+ {
+ namespace ui
+ {
+ /**
+ * Get handle for the current module.
+ *
+ * @return Handle for the current module.
+ */
+ HINSTANCE GetHInstance();
+
+ /**
+ * Window class.
+ */
+ class Window
+ {
+ public:
+ /**
+ * Constructor for a new window that is going to be created.
+ *
+ * @param parent Parent window handle.
+ * @param className Window class name.
+ * @param title Window title.
+ * @param callback Event processing function.
+ */
+ Window(Window* parent, const char* className, const char* title);
+
+ /**
+ * Constructor for the existing window.
+ *
+ * @param handle Window handle.
+ */
+ Window(HWND handle);
+
+ /**
+ * Destructor.
+ */
+ virtual ~Window();
+
+ /**
+ * Create window.
+ *
+ * @param style Window style.
+ * @param posX Window x position.
+ * @param posY Window y position.
+ * @param width Window width.
+ * @param height Window height.
+ * @param id ID for child window.
+ */
+ void Create(DWORD style, int posX, int posY, int width, int height, int id);
+
+ /**
+ * Show window.
+ */
+ void Show();
+
+ /**
+ * Update window.
+ */
+ void Update();
+
+ /**
+ * Destroy window.
+ */
+ void Destroy();
+
+ /**
+ * Get window handle.
+ *
+ * @return Window handle.
+ */
+ HWND GetHandle() const
+ {
+ return handle;
+ }
+
+ /**
+ * Get window text.
+ *
+ * @param text Text.
+ */
+ void GetText(std::string& text) const;
+
+ /**
+ * Set window text.
+ *
+ * @param text Text.
+ */
+ void SetText(const std::string& text) const;
+
+ /**
+ * Get CheckBox state.
+ *
+ * @param True if checked.
+ */
+ bool IsChecked() const;
+
+ /**
+ * Set CheckBox state.
+ *
+ * @param state True if checked.
+ */
+ void SetChecked(bool state);
+
+ /**
+ * Add string.
+ *
+ * @param str String.
+ */
+ void AddString(const std::string& str);
+
+ /**
+ * Set current ComboBox selection.
+ *
+ * @param idx List index.
+ */
+ void SetSelection(int idx);
+
+ /**
+ * Get current ComboBox selection.
+ *
+ * @return idx List index.
+ */
+ int GetSelection() const;
+
+ /**
+ * Set enabled.
+ *
+ * @param enabled Enable flag.
+ */
+ void SetEnabled(bool enabled);
+
+ /**
+ * Check if the window is enabled.
+ *
+ * @return True if enabled.
+ */
+ bool IsEnabled() const;
+
+ protected:
+ /**
+ * Set window handle.
+ *
+ * @param value Window handle.
+ */
+ void SetHandle(HWND value)
+ {
+ handle = value;
+ }
+
+ /** Window class name. */
+ std::string className;
+
+ /** Window title. */
+ std::string title;
+
+ /** Window handle. */
+ HWND handle;
+
+ /** Specifies whether window has been created by the thread and needs destruction. */
+ bool created;
+
+ /** Window parent. */
+ Window* parent;
+
+ private:
+ IGNITE_NO_COPY_ASSIGNMENT(Window)
+ };
+ }
+ }
+ }
+}
+
+#endif //_IGNITE_ODBC_SYSTEM_UI_WINDOW
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/60afa372/modules/platforms/cpp/odbc/os/win/src/system/ui/custom_window.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/os/win/src/system/ui/custom_window.cpp b/modules/platforms/cpp/odbc/os/win/src/system/ui/custom_window.cpp
new file mode 100644
index 0000000..1e855a1
--- /dev/null
+++ b/modules/platforms/cpp/odbc/os/win/src/system/ui/custom_window.cpp
@@ -0,0 +1,184 @@
+/*
+ * 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.
+ */
+
+#include <Windowsx.h>
+
+#include "ignite/odbc/system/ui/custom_window.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ namespace system
+ {
+ namespace ui
+ {
+ Result ProcessMessages(Window& window)
+ {
+ MSG msg;
+
+ while (GetMessage(&msg, NULL, 0, 0) > 0)
+ {
+ if (!IsDialogMessage(window.GetHandle(), &msg))
+ {
+ TranslateMessage(&msg);
+
+ DispatchMessage(&msg);
+ }
+ }
+
+ return static_cast<Result>(msg.wParam);
+ }
+
+ LRESULT CALLBACK CustomWindow::WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+ {
+ CustomWindow* window = reinterpret_cast<CustomWindow*>(GetWindowLongPtr(hwnd, GWLP_USERDATA));
+
+ switch (msg)
+ {
+ case WM_NCCREATE:
+ {
+ _ASSERT(lParam != NULL);
+
+ CREATESTRUCT* createStruct = reinterpret_cast<CREATESTRUCT*>(lParam);
+
+ LONG_PTR longSelfPtr = reinterpret_cast<LONG_PTR>(createStruct->lpCreateParams);
+
+ SetWindowLongPtr(hwnd, GWLP_USERDATA, longSelfPtr);
+
+ return DefWindowProc(hwnd, msg, wParam, lParam);
+ }
+
+ case WM_CREATE:
+ {
+ _ASSERT(window != NULL);
+
+ window->SetHandle(hwnd);
+
+ window->OnCreate();
+
+ return 0;
+ }
+
+ default:
+ break;
+ }
+
+ if (window && window->OnMessage(msg, wParam, lParam))
+ return 0;
+
+ return DefWindowProc(hwnd, msg, wParam, lParam);
+ }
+
+ CustomWindow::CustomWindow(Window* parent, const char* className, const char* title) :
+ Window(parent, className, title)
+ {
+ WNDCLASS wcx;
+
+ wcx.style = CS_HREDRAW | CS_VREDRAW;
+ wcx.lpfnWndProc = WndProc;
+ wcx.cbClsExtra = 0;
+ wcx.cbWndExtra = 0;
+ wcx.hInstance = GetHInstance();
+ wcx.hIcon = NULL;
+ wcx.hCursor = LoadCursor(NULL, IDC_ARROW);
+ wcx.hbrBackground = (HBRUSH)COLOR_WINDOW;
+ wcx.lpszMenuName = NULL;
+ wcx.lpszClassName = className;
+
+
+ if (!RegisterClass(&wcx))
+ {
+ std::stringstream buf;
+
+ buf << "Can not register window class, error code: " << GetLastError();
+
+ throw IgniteError(IgniteError::IGNITE_ERR_GENERIC, buf.str().c_str());
+ }
+ }
+
+ CustomWindow::~CustomWindow()
+ {
+ UnregisterClass(className.c_str(), GetHInstance());
+ }
+
+ std::auto_ptr<Window> CustomWindow::CreateGroupBox(int posX, int posY,
+ int sizeX, int sizeY, const char* title, int id)
+ {
+ std::auto_ptr<Window> child(new Window(this, "Button", title));
+
+ child->Create(WS_CHILD | WS_VISIBLE | BS_GROUPBOX, posX, posY, sizeX, sizeY, id);
+
+ return child;
+ }
+
+ std::auto_ptr<Window> CustomWindow::CreateLabel(int posX, int posY,
+ int sizeX, int sizeY, const char* title, int id)
+ {
+ std::auto_ptr<Window> child(new Window(this, "Static", title));
+
+ child->Create(WS_CHILD | WS_VISIBLE, posX, posY, sizeX, sizeY, id);
+
+ return child;
+ }
+
+ std::auto_ptr<Window> CustomWindow::CreateEdit(int posX, int posY,
+ int sizeX, int sizeY, const char* title, int id, int style)
+ {
+ std::auto_ptr<Window> child(new Window(this, "Edit", title));
+
+ child->Create(WS_CHILD | WS_VISIBLE | WS_BORDER | ES_AUTOHSCROLL | WS_TABSTOP | style,
+ posX, posY, sizeX, sizeY, id);
+
+ return child;
+ }
+
+ std::auto_ptr<Window> CustomWindow::CreateButton(int posX, int posY,
+ int sizeX, int sizeY, const char* title, int id)
+ {
+ std::auto_ptr<Window> child(new Window(this, "Button", title));
+
+ child->Create(WS_CHILD | WS_VISIBLE | WS_TABSTOP, posX, posY, sizeX, sizeY, id);
+
+ return child;
+ }
+
+ std::auto_ptr<Window> CustomWindow::CreateCheckBox(int posX, int posY,
+ int sizeX, int sizeY, const char* title, int id, bool state)
+ {
+ std::auto_ptr<Window> child(new Window(this, "Button", title));
+
+ child->Create(WS_CHILD | WS_VISIBLE | BS_CHECKBOX, posX, posY, sizeX, sizeY, id);
+
+ child->SetChecked(state);
+
+ return child;
+ }
+
+ std::auto_ptr<Window> CustomWindow::CreateComboBox(int posX, int posY,
+ int sizeX, int sizeY, const char * title, int id)
+ {
+ std::auto_ptr<Window> child(new Window(this, "Combobox", title));
+
+ child->Create(WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST, posX, posY, sizeX, sizeY, id);
+
+ return child;
+ }
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/60afa372/modules/platforms/cpp/odbc/os/win/src/system/ui/dsn_configuration_window.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/os/win/src/system/ui/dsn_configuration_window.cpp b/modules/platforms/cpp/odbc/os/win/src/system/ui/dsn_configuration_window.cpp
new file mode 100644
index 0000000..663333a
--- /dev/null
+++ b/modules/platforms/cpp/odbc/os/win/src/system/ui/dsn_configuration_window.cpp
@@ -0,0 +1,305 @@
+/*
+ * 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.
+ */
+
+#include <Windowsx.h>
+
+#include "ignite/odbc/system/ui/dsn_configuration_window.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ namespace system
+ {
+ namespace ui
+ {
+ DsnConfigurationWindow::DsnConfigurationWindow(Window* parent, config::Configuration& config):
+ CustomWindow(parent, "IgniteConfigureDsn", "Configure Apache Ignite DSN"),
+ width(360),
+ height(230),
+ connectionSettingsGroupBox(),
+ nameLabel(),
+ nameEdit(),
+ addressLabel(),
+ addressEdit(),
+ cacheLabel(),
+ cacheEdit(),
+ distributedJoinsCheckBox(),
+ enforceJoinOrderCheckBox(),
+ protocolVersionLabel(),
+ protocolVersionComboBox(),
+ okButton(),
+ cancelButton(),
+ config(config),
+ accepted(false)
+ {
+ // No-op.
+ }
+
+ DsnConfigurationWindow::~DsnConfigurationWindow()
+ {
+ // No-op.
+ }
+
+ void DsnConfigurationWindow::Create()
+ {
+ // Finding out parent position.
+ RECT parentRect;
+ GetWindowRect(parent->GetHandle(), &parentRect);
+
+ // Positioning window to the center of parent window.
+ const int posX = parentRect.left + (parentRect.right - parentRect.left - width) / 2;
+ const int posY = parentRect.top + (parentRect.bottom - parentRect.top - height) / 2;
+
+ RECT desiredRect = {posX, posY, posX + width, posY + height};
+ AdjustWindowRect(&desiredRect, WS_BORDER | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME, FALSE);
+
+ Window::Create(WS_OVERLAPPED | WS_SYSMENU, desiredRect.left, desiredRect.top,
+ desiredRect.right - desiredRect.left, desiredRect.bottom - desiredRect.top, 0);
+
+ if (!handle)
+ {
+ std::stringstream buf;
+
+ buf << "Can not create window, error code: " << GetLastError();
+
+ throw IgniteError(IgniteError::IGNITE_ERR_GENERIC, buf.str().c_str());
+ }
+ }
+
+ void DsnConfigurationWindow::OnCreate()
+ {
+ int margin = 10;
+ int interval = 10;
+
+ int labelSizeX = 80;
+ int labelPosX = margin + interval;
+
+ int editSizeX = width - labelSizeX - 2 * margin - 3 * interval;
+ int editPosX = margin + labelSizeX + 2 * interval;
+
+ int rowSize = 20;
+ int rowPos = margin + 2 * interval;
+
+ int checkBoxSize = (editSizeX - interval) / 2;
+
+ int sectionBegin = margin;
+
+ const char* val = config.GetDsn().c_str();
+ nameLabel = CreateLabel(labelPosX, rowPos, labelSizeX, rowSize, "DSN name:", ID_NAME_LABEL);
+ nameEdit = CreateEdit(editPosX, rowPos, editSizeX, rowSize, val, ID_NAME_EDIT);
+
+ rowPos += interval + rowSize;
+
+ val = config.GetAddress().c_str();
+ addressLabel = CreateLabel(labelPosX, rowPos, labelSizeX, rowSize, "Address:", ID_ADDRESS_LABEL);
+ addressEdit = CreateEdit(editPosX, rowPos, editSizeX, rowSize, val, ID_ADDRESS_EDIT);
+
+ rowPos += interval + rowSize;
+
+ val = config.GetCache().c_str();
+ cacheLabel = CreateLabel(labelPosX, rowPos, labelSizeX, rowSize, "Cache name:", ID_CACHE_LABEL);
+ cacheEdit = CreateEdit(editPosX, rowPos, editSizeX, rowSize, val, ID_CACHE_EDIT);
+
+ rowPos += interval + rowSize;
+
+ protocolVersionLabel = CreateLabel(labelPosX, rowPos, labelSizeX, rowSize,
+ "Protocol version:", ID_PROTOCOL_VERSION_LABEL);
+ protocolVersionComboBox = CreateComboBox(editPosX, rowPos, editSizeX, rowSize,
+ "Protocol version", ID_PROTOCOL_VERSION_COMBO_BOX);
+
+ int id = 0;
+
+ const ProtocolVersion::StringToVersionMap& versionMap = ProtocolVersion::GetMap();
+
+ ProtocolVersion::StringToVersionMap::const_iterator it;
+ for (it = versionMap.begin(); it != versionMap.end(); ++it)
+ {
+ protocolVersionComboBox->AddString(it->first);
+
+ if (it->second == config.GetProtocolVersion())
+ protocolVersionComboBox->SetSelection(id);
+
+ ++id;
+ }
+
+ rowPos += interval + rowSize;
+
+ distributedJoinsCheckBox = CreateCheckBox(editPosX, rowPos, checkBoxSize, rowSize,
+ "Distributed Joins", ID_DISTRIBUTED_JOINS_CHECK_BOX, config.IsDistributedJoins());
+
+ enforceJoinOrderCheckBox = CreateCheckBox(editPosX + checkBoxSize + interval, rowPos, checkBoxSize,
+ rowSize, "Enforce Join Order", ID_ENFORCE_JOIN_ORDER_CHECK_BOX, config.IsEnforceJoinOrder());
+
+ if (!config.GetProtocolVersion().IsDistributedJoinsSupported())
+ {
+ distributedJoinsCheckBox->SetEnabled(false);
+ enforceJoinOrderCheckBox->SetEnabled(false);
+ }
+
+ rowPos += interval * 2 + rowSize;
+
+ connectionSettingsGroupBox = CreateGroupBox(margin, sectionBegin, width - 2 * margin,
+ rowPos - interval - sectionBegin, "Connection settings", ID_CONNECTION_SETTINGS_GROUP_BOX);
+
+ int buttonSizeX = 80;
+ int cancelPosX = width - margin - buttonSizeX;
+ int okPosX = cancelPosX - interval - buttonSizeX;
+
+ rowSize = 25;
+
+ okButton = CreateButton(okPosX, rowPos, buttonSizeX, rowSize, "Ok", ID_OK_BUTTON);
+ cancelButton = CreateButton(cancelPosX, rowPos, buttonSizeX, rowSize, "Cancel", ID_CANCEL_BUTTON);
+ }
+
+ bool DsnConfigurationWindow::OnMessage(UINT msg, WPARAM wParam, LPARAM lParam)
+ {
+ switch (msg)
+ {
+ case WM_COMMAND:
+ {
+ switch (LOWORD(wParam))
+ {
+ case ID_OK_BUTTON:
+ {
+ try
+ {
+ RetrieveParameters(config);
+
+ accepted = true;
+
+ PostMessage(GetHandle(), WM_CLOSE, 0, 0);
+ }
+ catch (IgniteError& err)
+ {
+ MessageBox(NULL, err.GetText(), "Error!", MB_ICONEXCLAMATION | MB_OK);
+ }
+
+ break;
+ }
+
+ case ID_PROTOCOL_VERSION_COMBO_BOX:
+ {
+ if (HIWORD(wParam) == CBN_SELCHANGE)
+ {
+ std::string text;
+
+ protocolVersionComboBox->GetText(text);
+
+ ProtocolVersion version = ProtocolVersion::FromString(text);
+
+ if (!version.IsUnknown() && !version.IsDistributedJoinsSupported())
+ {
+ distributedJoinsCheckBox->SetEnabled(false);
+ enforceJoinOrderCheckBox->SetEnabled(false);
+ }
+ else
+ {
+ distributedJoinsCheckBox->SetEnabled(true);
+ enforceJoinOrderCheckBox->SetEnabled(true);
+ }
+ }
+
+ break;
+ }
+
+ case IDCANCEL:
+ case ID_CANCEL_BUTTON:
+ {
+ PostMessage(GetHandle(), WM_CLOSE, 0, 0);
+
+ break;
+ }
+
+ case ID_DISTRIBUTED_JOINS_CHECK_BOX:
+ {
+ distributedJoinsCheckBox->SetChecked(!distributedJoinsCheckBox->IsChecked());
+
+ break;
+ }
+
+ case ID_ENFORCE_JOIN_ORDER_CHECK_BOX:
+ {
+ enforceJoinOrderCheckBox->SetChecked(!enforceJoinOrderCheckBox->IsChecked());
+
+ break;
+ }
+
+ default:
+ return false;
+ }
+
+ break;
+ }
+
+ case WM_DESTROY:
+ {
+ PostQuitMessage(accepted ? RESULT_OK : RESULT_CANCEL);
+
+ break;
+ }
+
+ default:
+ return false;
+ }
+
+ return true;
+ }
+
+ void DsnConfigurationWindow::RetrieveParameters(config::Configuration& cfg) const
+ {
+ std::string dsn;
+ std::string address;
+ std::string cache;
+ std::string version;
+
+ bool distributedJoins;
+ bool enforceJoinOrder;
+
+ nameEdit->GetText(dsn);
+ addressEdit->GetText(address);
+ cacheEdit->GetText(cache);
+ protocolVersionComboBox->GetText(version);
+
+ common::StripSurroundingWhitespaces(address);
+ common::StripSurroundingWhitespaces(dsn);
+
+ distributedJoins = distributedJoinsCheckBox->IsEnabled() && distributedJoinsCheckBox->IsChecked();
+ enforceJoinOrder = enforceJoinOrderCheckBox->IsEnabled() && enforceJoinOrderCheckBox->IsChecked();
+
+ LOG_MSG("Retriving arguments:\n");
+ LOG_MSG("DSN: %s\n", dsn.c_str());
+ LOG_MSG("Address: %s\n", address.c_str());
+ LOG_MSG("Cache: %s\n", cache.c_str());
+ LOG_MSG("Protocol version: %s\n", version.c_str());
+ LOG_MSG("Distributed Joins: %s\n", distributedJoins ? "true" : "false");
+ LOG_MSG("Enforce Join Order: %s\n", enforceJoinOrder ? "true" : "false");
+
+ if (dsn.empty())
+ throw IgniteError(IgniteError::IGNITE_ERR_GENERIC, "DSN name can not be empty.");
+
+ cfg.SetDsn(dsn);
+ cfg.SetAddress(address);
+ cfg.SetCache(cache);
+ cfg.SetProtocolVersion(version);
+ cfg.SetDistributedJoins(distributedJoins);
+ cfg.SetEnforceJoinOrder(enforceJoinOrder);
+ }
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/60afa372/modules/platforms/cpp/odbc/os/win/src/system/ui/window.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/os/win/src/system/ui/window.cpp b/modules/platforms/cpp/odbc/os/win/src/system/ui/window.cpp
new file mode 100644
index 0000000..1143f01
--- /dev/null
+++ b/modules/platforms/cpp/odbc/os/win/src/system/ui/window.cpp
@@ -0,0 +1,192 @@
+/*
+ * 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.
+ */
+
+#include <Windowsx.h>
+
+#include "ignite/odbc/system/ui/window.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ namespace system
+ {
+ namespace ui
+ {
+ HINSTANCE GetHInstance()
+ {
+ HINSTANCE hInstance = GetModuleHandle(TARGET_MODULE_FULL_NAME);
+
+ if (hInstance == NULL)
+ {
+ std::stringstream buf;
+
+ buf << "Can not get hInstance for the module, error code: " << GetLastError();
+
+ throw IgniteError(IgniteError::IGNITE_ERR_GENERIC, buf.str().c_str());
+ }
+
+ return hInstance;
+ }
+
+ Window::Window(Window* parent, const char* className, const char* title) :
+ className(className),
+ title(title),
+ handle(NULL),
+ created(false),
+ parent(parent)
+ {
+ // No-op.
+ }
+
+ Window::Window(HWND handle) :
+ className(),
+ title(),
+ handle(handle),
+ created(false),
+ parent(0)
+ {
+ // No-op.
+ }
+
+ Window::~Window()
+ {
+ if (created)
+ Destroy();
+ }
+
+ void Window::Create(DWORD style, int posX, int posY, int width, int height, int id)
+ {
+ if (handle)
+ {
+ std::stringstream buf;
+
+ buf << "Window already created, error code: " << GetLastError();
+
+ throw IgniteError(IgniteError::IGNITE_ERR_GENERIC, buf.str().c_str());
+ }
+
+ handle = CreateWindow(
+ className.c_str(),
+ title.c_str(),
+ style,
+ posX,
+ posY,
+ width,
+ height,
+ parent ? parent->GetHandle() : NULL,
+ reinterpret_cast<HMENU>(id),
+ GetHInstance(),
+ this
+ );
+
+ if (!handle)
+ {
+ std::stringstream buf;
+
+ buf << "Can not create window, error code: " << GetLastError();
+
+ throw IgniteError(IgniteError::IGNITE_ERR_GENERIC, buf.str().c_str());
+ }
+
+ created = true;
+
+ HGDIOBJ hfDefault = GetStockObject(DEFAULT_GUI_FONT);
+
+ SendMessage(GetHandle(), WM_SETFONT, (WPARAM)hfDefault, MAKELPARAM(FALSE, 0));
+ }
+
+ void Window::Show()
+ {
+ ShowWindow(handle, SW_SHOW);
+ }
+
+ void Window::Update()
+ {
+ UpdateWindow(handle);
+ }
+
+ void Window::Destroy()
+ {
+ if (handle)
+ DestroyWindow(handle);
+
+ handle = NULL;
+ }
+
+ void Window::GetText(std::string& text) const
+ {
+ int len = GetWindowTextLength(handle);
+
+ if (len <= 0)
+ {
+ text.clear();
+
+ return;
+ }
+
+ text.resize(len + 1);
+
+ if (!GetWindowText(handle, &text[0], len + 1))
+ text.clear();
+
+ text.resize(len);
+ }
+
+ void Window::SetText(const std::string& text) const
+ {
+ SNDMSG(handle, WM_SETTEXT, 0, reinterpret_cast<LPARAM>(text.c_str()));
+ }
+
+ bool Window::IsChecked() const
+ {
+ return Button_GetCheck(handle) == BST_CHECKED;
+ }
+
+ void Window::SetChecked(bool state)
+ {
+ Button_SetCheck(handle, state ? BST_CHECKED : BST_UNCHECKED);
+ }
+
+ void Window::AddString(const std::string & str)
+ {
+ SNDMSG(handle, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(str.c_str()));
+ }
+
+ void Window::SetSelection(int idx)
+ {
+ SNDMSG(handle, CB_SETCURSEL, static_cast<WPARAM>(idx), 0);
+ }
+
+ int Window::GetSelection() const
+ {
+ return static_cast<int>(SNDMSG(handle, CB_GETCURSEL, 0, 0));
+ }
+
+ void Window::SetEnabled(bool enabled)
+ {
+ EnableWindow(GetHandle(), enabled);
+ }
+
+ bool Window::IsEnabled() const
+ {
+ return IsWindowEnabled(GetHandle()) != 0;
+ }
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/60afa372/modules/platforms/cpp/odbc/os/win/src/system_dsn.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/os/win/src/system_dsn.cpp b/modules/platforms/cpp/odbc/os/win/src/system_dsn.cpp
new file mode 100644
index 0000000..f432a40
--- /dev/null
+++ b/modules/platforms/cpp/odbc/os/win/src/system_dsn.cpp
@@ -0,0 +1,218 @@
+/*
+ * 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.
+ */
+
+#include "ignite/odbc/utility.h"
+#include "ignite/odbc/system/odbc_constants.h"
+
+#include "ignite/odbc/dsn_config.h"
+#include "ignite/odbc/system/ui/window.h"
+#include "ignite/odbc/system/ui/dsn_configuration_window.h"
+
+using ignite::odbc::config::Configuration;
+
+/**
+ * Display configuration window for user to configure DSN.
+ *
+ * @param hwndParent Parent window handle.
+ * @param config Output configuration.
+ * @return True on success and false on fail.
+ */
+bool DisplayConfigureDsnWindow(HWND hwndParent, Configuration& config)
+{
+ using namespace ignite::odbc::system::ui;
+
+ if (!hwndParent)
+ return false;
+
+ try
+ {
+ Window parent(hwndParent);
+
+ DsnConfigurationWindow window(&parent, config);
+
+ window.Create();
+
+ window.Show();
+ window.Update();
+
+ return ProcessMessages(window) == RESULT_OK;
+ }
+ catch (const ignite::IgniteError& err)
+ {
+ std::stringstream buf;
+
+ buf << "Message: " << err.GetText() << ", Code: " << err.GetCode();
+
+ std::string message = buf.str();
+
+ MessageBox(NULL, message.c_str(), "Error!", MB_ICONEXCLAMATION | MB_OK);
+
+ SQLPostInstallerError(err.GetCode(), err.GetText());
+ }
+
+ return false;
+}
+
+/**
+ * Register DSN with specified configuration.
+ *
+ * @param config Configuration.
+ * @param driver Driver.
+ * @return True on success and false on fail.
+ */
+bool RegisterDsn(const Configuration& config, LPCSTR driver)
+{
+ using namespace ignite::odbc::config;
+ using ignite::common::LexicalCast;
+
+ typedef Configuration::ArgumentMap ArgMap;
+
+ const char* dsn = config.GetDsn().c_str();
+
+ try
+ {
+ if (!SQLWriteDSNToIni(dsn, driver))
+ ignite::odbc::ThrowLastSetupError();
+
+ const ArgMap& map = config.GetMap();
+
+ std::set<std::string> ignore;
+
+ ignore.insert(Configuration::Key::dsn);
+ ignore.insert(Configuration::Key::driver);
+
+ for (ArgMap::const_iterator it = map.begin(); it != map.end(); ++it)
+ {
+ const std::string& key = it->first;
+ const std::string& value = it->second;
+
+ if (ignore.find(key) != ignore.end())
+ continue;
+
+ ignite::odbc::WriteDsnString(dsn, key.c_str(), value.c_str());
+ }
+
+ return true;
+ }
+ catch (ignite::IgniteError& err)
+ {
+ MessageBox(NULL, err.GetText(), "Error!", MB_ICONEXCLAMATION | MB_OK);
+
+ SQLPostInstallerError(err.GetCode(), err.GetText());
+ }
+
+ return false;
+}
+
+/**
+ * Unregister specified DSN.
+ *
+ * @param dsn DSN name.
+ * @return True on success and false on fail.
+ */
+bool UnregisterDsn(const char* dsn)
+{
+ try
+ {
+ if (!SQLRemoveDSNFromIni(dsn))
+ ignite::odbc::ThrowLastSetupError();
+
+ return true;
+ }
+ catch (ignite::IgniteError& err)
+ {
+ MessageBox(NULL, err.GetText(), "Error!", MB_ICONEXCLAMATION | MB_OK);
+
+ SQLPostInstallerError(err.GetCode(), err.GetText());
+ }
+
+ return false;
+}
+
+BOOL INSTAPI ConfigDSN(HWND hwndParent, WORD req, LPCSTR driver, LPCSTR attributes)
+{
+ using namespace ignite::odbc;
+
+ LOG_MSG("ConfigDSN called\n");
+
+ Configuration config;
+
+ LOG_MSG("Attributes: %s\n", attributes);
+
+ config.FillFromConfigAttributes(attributes);
+
+ if (!SQLValidDSN(config.GetDsn().c_str()))
+ return FALSE;
+
+ LOG_MSG("Driver: %s\n", driver);
+ LOG_MSG("Attributes: %s\n", attributes);
+
+ LOG_MSG("DSN: %s\n", config.GetDsn().c_str());
+
+ switch (req)
+ {
+ case ODBC_ADD_DSN:
+ {
+ LOG_MSG("ODBC_ADD_DSN\n");
+
+ if (!DisplayConfigureDsnWindow(hwndParent, config))
+ return FALSE;
+
+ if (!RegisterDsn(config, driver))
+ return FALSE;
+
+ break;
+ }
+
+ case ODBC_CONFIG_DSN:
+ {
+ LOG_MSG("ODBC_CONFIG_DSN\n");
+
+ std::string dsn = config.GetDsn();
+
+ Configuration loaded(config);
+
+ ReadDsnConfiguration(dsn.c_str(), loaded);
+
+ if (!DisplayConfigureDsnWindow(hwndParent, loaded))
+ return FALSE;
+
+ if (!RegisterDsn(loaded, driver))
+ return FALSE;
+
+ if (loaded.GetDsn() != dsn && !UnregisterDsn(dsn.c_str()))
+ return FALSE;
+
+ break;
+ }
+
+ case ODBC_REMOVE_DSN:
+ {
+ LOG_MSG("ODBC_REMOVE_DSN\n");
+
+ if (!UnregisterDsn(config.GetDsn().c_str()))
+ return FALSE;
+
+ break;
+ }
+
+ default:
+ return FALSE;
+ }
+
+ return TRUE;
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/60afa372/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj b/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj
index 0e0f0d3..d48db21 100644
--- a/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj
+++ b/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj
@@ -93,8 +93,8 @@
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>false</SDLCheck>
- <AdditionalIncludeDirectories>$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\..\binary\include;$(ProjectDir)\..\..\..\binary\os\win\include;$(ProjectDir)\..\..\include;$(ProjectDir)\..\..\os\win;$(ProjectDir)\..\..\src</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;IGNITE_IMPL;IGNITE_FRIEND;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\..\binary\include;$(ProjectDir)\..\..\..\binary\os\win\include;$(ProjectDir)\..\..\include;$(ProjectDir)\..\..\os\win\include;$(ProjectDir)\..\..\src</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;IGNITE_IMPL;IGNITE_FRIEND;TARGET_MODULE_FULL_NAME="$(TargetFileName)";_DEBUG;ODBC_DEBUG;ODBC_LOG_PATH="D:\\odbc.log";%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -107,8 +107,8 @@
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>false</SDLCheck>
- <AdditionalIncludeDirectories>$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\..\binary\include;$(ProjectDir)\..\..\..\binary\os\win\include;$(ProjectDir)\..\..\include;$(ProjectDir)\..\..\os\win;$(ProjectDir)\..\..\src</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;IGNITE_IMPL;IGNITE_FRIEND;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\..\binary\include;$(ProjectDir)\..\..\..\binary\os\win\include;$(ProjectDir)\..\..\include;$(ProjectDir)\..\..\os\win\include;$(ProjectDir)\..\..\src</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;IGNITE_IMPL;IGNITE_FRIEND;TARGET_MODULE_FULL_NAME="$(TargetFileName)";_DEBUG;ODBC_DEBUG;ODBC_LOG_PATH="D:\\odbc.log";%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -123,8 +123,8 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>false</SDLCheck>
- <AdditionalIncludeDirectories>$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\..\binary\include;$(ProjectDir)\..\..\..\binary\os\win\include;$(ProjectDir)\..\..\include;$(ProjectDir)\..\..\os\win;$(ProjectDir)\..\..\src</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;IGNITE_IMPL;IGNITE_FRIEND;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\..\binary\include;$(ProjectDir)\..\..\..\binary\os\win\include;$(ProjectDir)\..\..\include;$(ProjectDir)\..\..\os\win\include;$(ProjectDir)\..\..\src</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;IGNITE_IMPL;IGNITE_FRIEND;TARGET_MODULE_FULL_NAME="$(TargetFileName)";%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -141,8 +141,8 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>false</SDLCheck>
- <AdditionalIncludeDirectories>$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\..\binary\include;$(ProjectDir)\..\..\..\binary\os\win\include;$(ProjectDir)\..\..\include;$(ProjectDir)\..\..\os\win;$(ProjectDir)\..\..\src</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;IGNITE_IMPL;IGNITE_FRIEND;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\..\binary\include;$(ProjectDir)\..\..\..\binary\os\win\include;$(ProjectDir)\..\..\include;$(ProjectDir)\..\..\os\win\include;$(ProjectDir)\..\..\src</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;IGNITE_IMPL;IGNITE_FRIEND;TARGET_MODULE_FULL_NAME="$(TargetFileName)";%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -153,7 +153,11 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
+ <ClCompile Include="..\..\os\win\src\system_dsn.cpp" />
<ClCompile Include="..\..\os\win\src\system\socket_client.cpp" />
+ <ClCompile Include="..\..\os\win\src\system\ui\custom_window.cpp" />
+ <ClCompile Include="..\..\os\win\src\system\ui\dsn_configuration_window.cpp" />
+ <ClCompile Include="..\..\os\win\src\system\ui\window.cpp" />
<ClCompile Include="..\..\src\app\application_data_buffer.cpp" />
<ClCompile Include="..\..\src\app\parameter.cpp" />
<ClCompile Include="..\..\src\column.cpp" />
@@ -165,6 +169,7 @@
<ClCompile Include="..\..\src\diagnostic\diagnosable_adapter.cpp" />
<ClCompile Include="..\..\src\diagnostic\diagnostic_record.cpp" />
<ClCompile Include="..\..\src\diagnostic\diagnostic_record_storage.cpp" />
+ <ClCompile Include="..\..\src\dsn_config.cpp" />
<ClCompile Include="..\..\src\entry_points.cpp" />
<ClCompile Include="..\..\src\environment.cpp" />
<ClCompile Include="..\..\src\meta\column_meta.cpp" />
@@ -201,6 +206,7 @@
<ClInclude Include="..\..\include\ignite\odbc\diagnostic\diagnosable_adapter.h" />
<ClInclude Include="..\..\include\ignite\odbc\diagnostic\diagnostic_record.h" />
<ClInclude Include="..\..\include\ignite\odbc\diagnostic\diagnostic_record_storage.h" />
+ <ClInclude Include="..\..\include\ignite\odbc\dsn_config.h" />
<ClInclude Include="..\..\include\ignite\odbc\environment.h" />
<ClInclude Include="..\..\include\ignite\odbc\message.h" />
<ClInclude Include="..\..\include\ignite\odbc\meta\column_meta.h" />
@@ -221,8 +227,11 @@
<ClInclude Include="..\..\include\ignite\odbc\statement.h" />
<ClInclude Include="..\..\include\ignite\odbc\system\odbc_constants.h" />
<ClInclude Include="..\..\include\ignite\odbc\system\socket_client.h" />
+ <ClInclude Include="..\..\include\ignite\odbc\system\ui\dsn_configuration_window.h" />
<ClInclude Include="..\..\include\ignite\odbc\type_traits.h" />
<ClInclude Include="..\..\include\ignite\odbc\utility.h" />
+ <ClInclude Include="..\..\os\win\include\ignite\odbc\system\ui\custom_window.h" />
+ <ClInclude Include="..\..\os\win\include\ignite\odbc\system\ui\window.h" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\binary\project\vs\binary.vcxproj">
http://git-wip-us.apache.org/repos/asf/ignite/blob/60afa372/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj.filters
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj.filters b/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj.filters
index 9caf483..58764e4 100644
--- a/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj.filters
+++ b/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj.filters
@@ -26,6 +26,9 @@
<Filter Include="Code\diagnostic">
<UniqueIdentifier>{df33e506-b5d8-423f-bcc5-1825242a3e28}</UniqueIdentifier>
</Filter>
+ <Filter Include="Code\system\ui">
+ <UniqueIdentifier>{ff144e89-0a10-42c3-97dd-d22bfdbc7abb}</UniqueIdentifier>
+ </Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\src\odbc.cpp">
@@ -115,6 +118,21 @@
<ClCompile Include="..\..\src\entry_points.cpp">
<Filter>Code</Filter>
</ClCompile>
+ <ClCompile Include="..\..\os\win\src\system\ui\window.cpp">
+ <Filter>Code\system\ui</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\os\win\src\system\ui\custom_window.cpp">
+ <Filter>Code\system\ui</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\os\win\src\system\ui\dsn_configuration_window.cpp">
+ <Filter>Code\system\ui</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\os\win\src\system_dsn.cpp">
+ <Filter>Code\system</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\dsn_config.cpp">
+ <Filter>Code</Filter>
+ </ClCompile>
<ClCompile Include="..\..\src\protocol_version.cpp">
<Filter>Code</Filter>
</ClCompile>
@@ -227,6 +245,18 @@
<ClInclude Include="..\..\include\ignite\odbc.h">
<Filter>Code</Filter>
</ClInclude>
+ <ClInclude Include="..\..\os\win\include\ignite\odbc\system\ui\window.h">
+ <Filter>Code\system\ui</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\os\win\include\ignite\odbc\system\ui\custom_window.h">
+ <Filter>Code\system\ui</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\ignite\odbc\system\ui\dsn_configuration_window.h">
+ <Filter>Code\system\ui</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\ignite\odbc\dsn_config.h">
+ <Filter>Code</Filter>
+ </ClInclude>
<ClInclude Include="..\..\include\ignite\odbc\protocol_version.h">
<Filter>Code</Filter>
</ClInclude>
[08/50] [abbrv] ignite git commit: IGNITE-3390: ODBC: Added DSN
configuration dialog for Windows. This closes #881.
Posted by sb...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/60afa372/modules/platforms/cpp/odbc/src/config/configuration.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/config/configuration.cpp b/modules/platforms/cpp/odbc/src/config/configuration.cpp
index 24c2bdf..dbe40bd 100644
--- a/modules/platforms/cpp/odbc/src/config/configuration.cpp
+++ b/modules/platforms/cpp/odbc/src/config/configuration.cpp
@@ -122,7 +122,7 @@ namespace ignite
return connect_string_buffer.str();
}
- void Configuration::FillFromConfigAttributes(const char * attributes)
+ void Configuration::FillFromConfigAttributes(const char* attributes)
{
// Initializing map.
arguments.clear();
@@ -150,6 +150,11 @@ namespace ignite
}
}
+ void Configuration::SetTcpPort(uint16_t port)
+ {
+ arguments[Key::port] = common::LexicalCast<std::string>(port);
+ }
+
ProtocolVersion Configuration::GetProtocolVersion() const
{
ArgumentMap::const_iterator it = arguments.find(Key::protocolVersion);
@@ -160,6 +165,11 @@ namespace ignite
return DefaultValue::protocolVersion;
}
+ void Configuration::SetProtocolVersion(const std::string& version)
+ {
+ arguments[Key::protocolVersion] = version;
+ }
+
const std::string& Configuration::GetStringValue(const std::string& key, const std::string& dflt) const
{
ArgumentMap::const_iterator it = arguments.find(common::ToLower(key));
@@ -206,6 +216,11 @@ namespace ignite
return dflt;
}
+ void Configuration::SetBoolValue(const std::string& key, bool val)
+ {
+ arguments[key] = val ? "true" : "false";
+ }
+
void Configuration::ParseAttributeList(const char * str, size_t len, char delimeter, ArgumentMap & args)
{
std::string connect_str(str, len);
http://git-wip-us.apache.org/repos/asf/ignite/blob/60afa372/modules/platforms/cpp/odbc/src/connection.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/connection.cpp b/modules/platforms/cpp/odbc/src/connection.cpp
index 4315698..0fd9513 100644
--- a/modules/platforms/cpp/odbc/src/connection.cpp
+++ b/modules/platforms/cpp/odbc/src/connection.cpp
@@ -117,7 +117,7 @@ namespace ignite
return SQL_RESULT_ERROR;
}
- connected = socket.Connect(cfg.GetHost().c_str(), cfg.GetPort());
+ connected = socket.Connect(cfg.GetHost().c_str(), cfg.GetTcpPort());
if (!connected)
{
http://git-wip-us.apache.org/repos/asf/ignite/blob/60afa372/modules/platforms/cpp/odbc/src/diagnostic/diagnostic_record.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/diagnostic/diagnostic_record.cpp b/modules/platforms/cpp/odbc/src/diagnostic/diagnostic_record.cpp
index 0fdfbc8..8553ee4 100644
--- a/modules/platforms/cpp/odbc/src/diagnostic/diagnostic_record.cpp
+++ b/modules/platforms/cpp/odbc/src/diagnostic/diagnostic_record.cpp
@@ -171,7 +171,7 @@ namespace ignite
return ORIGIN_ISO_9075;
}
- const std::string& DiagnosticRecord::GetMessage() const
+ const std::string& DiagnosticRecord::GetMessageText() const
{
return message;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/60afa372/modules/platforms/cpp/odbc/src/diagnostic/diagnostic_record_storage.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/diagnostic/diagnostic_record_storage.cpp b/modules/platforms/cpp/odbc/src/diagnostic/diagnostic_record_storage.cpp
index 90c0a4f..99ef292 100644
--- a/modules/platforms/cpp/odbc/src/diagnostic/diagnostic_record_storage.cpp
+++ b/modules/platforms/cpp/odbc/src/diagnostic/diagnostic_record_storage.cpp
@@ -190,7 +190,7 @@ namespace ignite
case IGNITE_SQL_DIAG_STATUS_MESSAGE_TEXT:
{
- buffer.PutString(record.GetMessage());
+ buffer.PutString(record.GetMessageText());
return SQL_RESULT_SUCCESS;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/60afa372/modules/platforms/cpp/odbc/src/dsn_config.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/dsn_config.cpp b/modules/platforms/cpp/odbc/src/dsn_config.cpp
new file mode 100644
index 0000000..a304567
--- /dev/null
+++ b/modules/platforms/cpp/odbc/src/dsn_config.cpp
@@ -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.
+ */
+
+#include <set>
+
+#include "ignite/odbc/utility.h"
+#include "ignite/odbc/system/odbc_constants.h"
+
+#include "ignite/odbc/dsn_config.h"
+
+using ignite::odbc::config::Configuration;
+
+#define BUFFER_SIZE 1024
+#define CONFIG_FILE "ODBC.INI"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ void ThrowLastSetupError()
+ {
+ DWORD code;
+ char msg[BUFFER_SIZE];
+
+ SQLInstallerError(1, &code, msg, sizeof(msg), NULL);
+
+ std::stringstream buf;
+
+ buf << "Message: \"" << msg << "\", Code: " << code;
+
+ throw IgniteError(IgniteError::IGNITE_ERR_GENERIC, buf.str().c_str());
+ }
+
+ void WriteDsnString(const char* dsn, const char* key, const char* value)
+ {
+ if (!SQLWritePrivateProfileString(dsn, key, value, CONFIG_FILE))
+ ThrowLastSetupError();
+ }
+
+ std::string ReadDsnString(const char* dsn, const std::string& key, const char* dflt)
+ {
+ char buf[BUFFER_SIZE];
+
+ memset(buf, 0, sizeof(buf));
+
+ SQLGetPrivateProfileString(dsn, key.c_str(), dflt, buf, sizeof(buf), CONFIG_FILE);
+
+ return std::string(buf);
+ }
+
+ int ReadDsnInt(const char* dsn, const std::string& key, int dflt)
+ {
+ char buf[BUFFER_SIZE];
+
+ memset(buf, 0, sizeof(buf));
+
+ std::string dflt0 = common::LexicalCast<std::string>(dflt);
+
+ SQLGetPrivateProfileString(dsn, key.c_str(), dflt0.c_str(), buf, sizeof(buf), CONFIG_FILE);
+
+ return common::LexicalCast<int, std::string>(buf);
+ }
+
+ bool ReadDsnBool(const char* dsn, const std::string& key, bool dflt)
+ {
+ char buf[BUFFER_SIZE];
+
+ memset(buf, 0, sizeof(buf));
+
+ std::string dflt0 = dflt ? "true" : "false";
+
+ SQLGetPrivateProfileString(dsn, key.c_str(), dflt0.c_str(), buf, sizeof(buf), CONFIG_FILE);
+
+ return std::string(buf) == "true";
+ }
+
+ void ReadDsnConfiguration(const char* dsn, Configuration& config)
+ {
+ std::string address = ReadDsnString(dsn, Configuration::Key::address, config.GetAddress().c_str());
+ std::string server = ReadDsnString(dsn, Configuration::Key::server, config.GetHost().c_str());
+ uint16_t port = ReadDsnInt(dsn, Configuration::Key::port, config.GetTcpPort());
+ std::string cache = ReadDsnString(dsn, Configuration::Key::cache, config.GetCache().c_str());
+ bool distributedJoins = ReadDsnBool(dsn, Configuration::Key::distributedJoins, config.IsDistributedJoins());
+ bool enforceJoinOrder = ReadDsnBool(dsn, Configuration::Key::enforceJoinOrder, config.IsEnforceJoinOrder());
+ std::string version = ReadDsnString(dsn, Configuration::Key::protocolVersion,
+ config.GetProtocolVersion().ToString().c_str());
+
+ LOG_MSG("%d\n", __LINE__);
+
+ config.SetAddress(address);
+ config.SetHost(server);
+ config.SetTcpPort(port);
+ config.SetCache(cache);
+ config.SetDistributedJoins(distributedJoins);
+ config.SetEnforceJoinOrder(enforceJoinOrder);
+ config.SetProtocolVersion(version);
+
+ LOG_MSG("%d\n", __LINE__);
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/60afa372/modules/platforms/cpp/odbc/src/entry_points.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/entry_points.cpp b/modules/platforms/cpp/odbc/src/entry_points.cpp
index c8e78a5..f6195e1 100644
--- a/modules/platforms/cpp/odbc/src/entry_points.cpp
+++ b/modules/platforms/cpp/odbc/src/entry_points.cpp
@@ -19,14 +19,6 @@
#include "ignite/odbc/utility.h"
-BOOL INSTAPI ConfigDSN(HWND hwndParent,
- WORD req,
- LPCSTR driver,
- LPCSTR attributes)
-{
- return ignite::ConfigDSN(hwndParent, req, driver, attributes);
-}
-
SQLRETURN SQL_API SQLGetInfo(SQLHDBC conn,
SQLUSMALLINT infoType,
SQLPOINTER infoValue,
http://git-wip-us.apache.org/repos/asf/ignite/blob/60afa372/modules/platforms/cpp/odbc/src/odbc.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/odbc.cpp b/modules/platforms/cpp/odbc/src/odbc.cpp
index 9b4179e..fd35cba 100644
--- a/modules/platforms/cpp/odbc/src/odbc.cpp
+++ b/modules/platforms/cpp/odbc/src/odbc.cpp
@@ -28,70 +28,11 @@
#include "ignite/odbc/environment.h"
#include "ignite/odbc/connection.h"
#include "ignite/odbc/statement.h"
+#include "ignite/odbc/dsn_config.h"
#include "ignite/odbc.h"
namespace ignite
{
-
- BOOL ConfigDSN(HWND hwndParent,
- WORD req,
- LPCSTR driver,
- LPCSTR attributes)
- {
- LOG_MSG("ConfigDSN called\n");
-
- ignite::odbc::config::Configuration config;
-
- try
- {
- config.FillFromConfigAttributes(attributes);
- }
- catch (IgniteError& e)
- {
- SQLPostInstallerError(e.GetCode(), e.GetText());
-
- return SQL_FALSE;
- }
-
- if (!SQLValidDSN(config.GetDsn().c_str()))
- return SQL_FALSE;
-
- LOG_MSG("Driver: %s\n", driver);
- LOG_MSG("Attributes: %s\n", attributes);
-
- LOG_MSG("DSN: %s\n", config.GetDsn().c_str());
-
- switch (req)
- {
- case ODBC_ADD_DSN:
- {
- LOG_MSG("ODBC_ADD_DSN\n");
-
- return SQLWriteDSNToIni(config.GetDsn().c_str(), driver);
- }
-
- case ODBC_CONFIG_DSN:
- {
- LOG_MSG("ODBC_CONFIG_DSN\n");
- break;
- }
-
- case ODBC_REMOVE_DSN:
- {
- LOG_MSG("ODBC_REMOVE_DSN\n");
-
- return SQLRemoveDSNFromIni(config.GetDsn().c_str());
- }
-
- default:
- {
- return SQL_FALSE;
- }
- }
-
- return SQL_TRUE;
- }
-
SQLRETURN SQLGetInfo(SQLHDBC conn,
SQLUSMALLINT infoType,
SQLPOINTER infoValue,
@@ -315,10 +256,10 @@ namespace ignite
SQLSMALLINT* outConnectionStringLen,
SQLUSMALLINT driverCompletion)
{
- using ignite::odbc::Connection;
- using ignite::odbc::diagnostic::DiagnosticRecordStorage;
- using ignite::utility::SqlStringToString;
- using ignite::utility::CopyStringToBuffer;
+ using odbc::Connection;
+ using odbc::diagnostic::DiagnosticRecordStorage;
+ using utility::SqlStringToString;
+ using utility::CopyStringToBuffer;
UNREFERENCED_PARAMETER(windowHandle);
@@ -332,7 +273,16 @@ namespace ignite
std::string connectStr = SqlStringToString(inConnectionString, inConnectionStringLen);
- connection->Establish(connectStr);
+ odbc::config::Configuration config;
+
+ config.FillFromConnectString(connectStr);
+
+ std::string dsn = config.GetDsn();
+
+ if (!dsn.empty())
+ odbc::ReadDsnConfiguration(dsn.c_str(), config);
+
+ connection->Establish(config);
const DiagnosticRecordStorage& diag = connection->GetDiagnosticRecords();
@@ -372,9 +322,11 @@ namespace ignite
if (!connection)
return SQL_INVALID_HANDLE;
- //std::string server = SqlStringToString(serverName, serverNameLen);
+ odbc::config::Configuration config;
+
+ std::string dsn = SqlStringToString(serverName, serverNameLen);
- Configuration config;
+ odbc::ReadDsnConfiguration(dsn.c_str(), config);
connection->Establish(config);
@@ -1175,7 +1127,7 @@ namespace ignite
SqlLen outResLen;
ApplicationDataBuffer outBuffer(IGNITE_ODBC_C_TYPE_CHAR, msgBuffer, msgBufferLen, &outResLen);
- outBuffer.PutString(record.GetMessage());
+ outBuffer.PutString(record.GetMessageText());
*msgLen = static_cast<SQLSMALLINT>(outResLen);
http://git-wip-us.apache.org/repos/asf/ignite/blob/60afa372/modules/platforms/cpp/odbc/src/protocol_version.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/protocol_version.cpp b/modules/platforms/cpp/odbc/src/protocol_version.cpp
index c65099d..ebd3b6a 100644
--- a/modules/platforms/cpp/odbc/src/protocol_version.cpp
+++ b/modules/platforms/cpp/odbc/src/protocol_version.cpp
@@ -14,12 +14,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-#include "ignite/odbc/protocol_version.h"
#include <ignite/common/concurrent.h>
#include <ignite/common/utils.h>
#include <ignite/ignite_error.h>
+#include "ignite/odbc/protocol_version.h"
+#include "ignite/odbc/utility.h"
+
namespace ignite
{
namespace odbc
@@ -50,10 +51,15 @@ namespace ignite
// No-op.
}
- int64_t ProtocolVersion::MakeVersion(uint16_t major, uint16_t minor, uint16_t maintenance)
+ int64_t ProtocolVersion::MakeVersion(uint16_t major, uint16_t minor, uint16_t revision)
{
const static int64_t MASK = 0x000000000000FFFFLL;
- return ((major & MASK) << 48) | ((minor & MASK) << 32) | ((maintenance & MASK) << 16);
+ return ((major & MASK) << 48) | ((minor & MASK) << 32) | ((revision & MASK) << 16);
+ }
+
+ const ProtocolVersion::StringToVersionMap& ProtocolVersion::GetMap()
+ {
+ return stringToVersionMap;
}
const ProtocolVersion& ProtocolVersion::GetCurrent()
@@ -68,8 +74,8 @@ namespace ignite
if (it == stringToVersionMap.end())
{
throw IgniteError(IgniteError::IGNITE_ERR_GENERIC,
- "Invalid version format. Valid format is X.Y.Z, where X, Y and Z are major, "
- "minor and maintenance versions of Ignite since which protocol is introduced.");
+ "Invalid version format. Valid format is X.Y.Z, where X, Y and Z are major "
+ "and minor versions and revision of Ignite since which protocol is introduced.");
}
return it->second;
@@ -100,6 +106,11 @@ namespace ignite
return *this == VERSION_UNKNOWN;
}
+ bool ProtocolVersion::IsDistributedJoinsSupported() const
+ {
+ return *this >= VERSION_1_8_0;
+ }
+
bool operator==(const ProtocolVersion& val1, const ProtocolVersion& val2)
{
return val1.val == val2.val;
[06/50] [abbrv] ignite git commit: IGNITE-3738: ODBC: Fixed escape
sequence whitespaces handling. This closes #982.
Posted by sb...@apache.org.
IGNITE-3738: ODBC: Fixed escape sequence whitespaces handling. This closes #982.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/e21111f2
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/e21111f2
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/e21111f2
Branch: refs/heads/ignite-961
Commit: e21111f287039011bc9437c94fb574e61e2ac226
Parents: 0e3a6e2
Author: Andrey V. Mashenkov <an...@gmail.com>
Authored: Thu Aug 25 16:26:02 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Thu Aug 25 16:26:02 2016 +0300
----------------------------------------------------------------------
.../processors/odbc/escape/OdbcEscapeToken.java | 61 +++++++++++
.../processors/odbc/escape/OdbcEscapeType.java | 81 ++++++++++++++-
.../processors/odbc/escape/OdbcEscapeUtils.java | 103 +++++++++++++------
.../odbc/OdbcEscapeSequenceSelfTest.java | 15 ++-
4 files changed, 225 insertions(+), 35 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/e21111f2/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/escape/OdbcEscapeToken.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/escape/OdbcEscapeToken.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/escape/OdbcEscapeToken.java
new file mode 100644
index 0000000..6bb4f81
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/escape/OdbcEscapeToken.java
@@ -0,0 +1,61 @@
+/*
+ * 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.odbc.escape;
+
+import org.apache.ignite.internal.util.typedef.internal.S;
+
+/**
+ * ODBC escape sequence token.
+ */
+public class OdbcEscapeToken {
+ /** Escape sequence type. */
+ private final OdbcEscapeType type;
+
+ /** Token length. */
+ private final int len;
+
+ /**
+ * Constructor.
+ *
+ * @param type Escape sequence type.
+ * @param len Token length.
+ */
+ public OdbcEscapeToken(OdbcEscapeType type, int len) {
+ this.type = type;
+ this.len = len;
+ }
+
+ /**
+ * @return Escape sequence type.
+ */
+ public OdbcEscapeType type() {
+ return type;
+ }
+
+ /**
+ * @return Token length.
+ */
+ public int length() {
+ return len;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(OdbcEscapeToken.class, this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e21111f2/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/escape/OdbcEscapeType.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/escape/OdbcEscapeType.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/escape/OdbcEscapeType.java
index 2df413f..96a2127 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/escape/OdbcEscapeType.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/escape/OdbcEscapeType.java
@@ -22,5 +22,84 @@ package org.apache.ignite.internal.processors.odbc.escape;
*/
public enum OdbcEscapeType {
/** Scalar function. */
- FN
+ SCALAR_FUNCTION("fn", true, false),
+
+ /** Outer join. */
+ OUTER_JOIN("oj", true, false),
+
+ /** Date. */
+ DATE("d", true, false),
+
+ /** Timestamp. */
+ TIMESTAMP("ts", true, false),
+
+ /** Time. */
+ TIME("t", true, false),
+
+ /** GUID. */
+ GUID("guid", true, false),
+
+ /** LIKE clause. */
+ LIKE("\'", false, true);
+
+ /** Values in convenient order. */
+ private static final OdbcEscapeType[] VALS = new OdbcEscapeType[] {
+ SCALAR_FUNCTION, // Assume that scalar functions are very frequent.
+ DATE, TIMESTAMP, // Date and timestamp are relatively frequent as well; also TS must go before T.
+ OUTER_JOIN, // Joins are less frequent,
+ LIKE, TIME, GUID // LIKE, TIME and GUID are even less frequent.
+ };
+
+ /**
+ * Get values in convenient order, where the most frequent values goes first, and "startsWith" invocation is
+ * enough to get type (i.e. "ts" goes before "t").
+ *
+ * @return Values.
+ */
+ public static OdbcEscapeType[] sortedValues() {
+ return VALS;
+ }
+
+ /** Escape sequence body. */
+ private final String body;
+
+ /** Whether token must be delimited from the rest of escape sequence. */
+ private final boolean delimited;
+
+ /** Whether empty escape sequence is allowed. */
+ private final boolean allowEmpty;
+
+ /**
+ * Constructor.
+ *
+ * @param body Escape sequence body.
+ * @param delimited Whether token must be delimited from the rest of escape sequence.
+ * @param allowEmpty Whether empty escape sequence is allowed.
+ */
+ OdbcEscapeType(String body, boolean delimited, boolean allowEmpty) {
+ this.body = body;
+ this.delimited = delimited;
+ this.allowEmpty = allowEmpty;
+ }
+
+ /**
+ * @return Escape sequence body.
+ */
+ public String body() {
+ return body;
+ }
+
+ /**
+ * @return Whether token must be delimited from the rest of escape sequence.
+ */
+ public boolean delimited() {
+ return delimited;
+ }
+
+ /**
+ * @return Whether empty escape sequence is allowed.
+ */
+ public boolean allowEmpty() {
+ return allowEmpty;
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e21111f2/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/escape/OdbcEscapeUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/escape/OdbcEscapeUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/escape/OdbcEscapeUtils.java
index 4d8ca69..6299c7e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/escape/OdbcEscapeUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/escape/OdbcEscapeUtils.java
@@ -90,18 +90,18 @@ public class OdbcEscapeUtils {
if (nested == null)
// Found sequence without nesting, process it.
- parseRes = parseExpression(text, openPos, curPos - openPos);
+ parseRes = parseExpression(text, openPos, curPos + 1 - openPos);
else {
// Special case to process nesting.
String res0 = appendNested(text, openPos, curPos + 1, nested);
nested = null;
- parseRes = parseExpression(res0, 0, res0.length()-1);
+ parseRes = parseExpression(res0, 0, res0.length());
}
if (earlyExit)
- return new OdbcEscapeParseResult(startPos, curPos - startPos + 1, parseRes);
+ return new OdbcEscapeParseResult(startPos, curPos + 1 - startPos, parseRes);
else
res.append(parseRes);
@@ -137,23 +137,21 @@ public class OdbcEscapeUtils {
char firstChar = text.charAt(startPos);
if (firstChar == '{') {
- char lastChar = text.charAt(startPos + len);
+ char lastChar = text.charAt(startPos + len - 1);
if (lastChar != '}')
throw new IgniteException("Failed to parse escape sequence because it is not enclosed: " +
substring(text, startPos, len));
- OdbcEscapeType typ = sequenceType(text, startPos, len);
+ OdbcEscapeToken token = parseToken(text, startPos, len);
- switch (typ) {
- case FN:
- return parseScalarExpression(text, startPos, len);
+ switch (token.type()) {
+ case SCALAR_FUNCTION:
+ return parseScalarExpression(text, startPos, len, token);
- default: {
- assert false : "Unknown expression type: " + typ;
-
- return null;
- }
+ default:
+ throw new IgniteException("Unsupported escape sequence token [text=" +
+ substring(text, startPos, len) + ", token=" + token.type().body() + ']');
}
}
else {
@@ -161,8 +159,60 @@ public class OdbcEscapeUtils {
if (startPos == 0 || text.length() == len)
return text;
else
- return text.substring(startPos, startPos + len);
+ return substring(text, startPos, len);
+ }
+ }
+
+ /**
+ * Get escape sequence info.
+ *
+ * @param text Text.
+ * @param startPos Start position.
+ * @return Escape sequence info.
+ */
+ private static OdbcEscapeToken parseToken(String text, int startPos, int len) {
+ assert validSubstring(text, startPos, len);
+ assert text.charAt(startPos) == '{';
+
+ int pos = startPos + 1;
+
+ while (Character.isWhitespace(text.charAt(pos)))
+ pos++;
+
+ OdbcEscapeType curTyp = null;
+ boolean empty = false;
+
+ for (OdbcEscapeType typ : OdbcEscapeType.sortedValues()) {
+ if (text.startsWith(typ.body(), pos)) {
+ pos += typ.body().length();
+
+ if (typ == OdbcEscapeType.LIKE)
+ throw new IgniteException("LIKE escape sequence is not supported yet.");
+ else {
+ empty = (startPos + len == pos + 1);
+
+ if (!empty && typ.delimited()) {
+ char charAfter = text.charAt(pos);
+
+ if (!Character.isWhitespace(charAfter))
+ throw new IgniteException("Unexpected escape sequence token: " +
+ substring(text, startPos, len));
+ }
+ }
+
+ curTyp = typ;
+
+ break;
+ }
}
+
+ if (curTyp == null)
+ throw new IgniteException("Unsupported escape sequence: " + substring(text, startPos, len));
+
+ if (empty && !curTyp.allowEmpty())
+ throw new IgniteException("Escape sequence cannot be empty: " + substring(text, startPos, len));
+
+ return new OdbcEscapeToken(curTyp, pos - (startPos + 1));
}
/**
@@ -171,12 +221,16 @@ public class OdbcEscapeUtils {
* @param text Text.
* @param startPos Start position.
* @param len Length.
+ * @param token Token.
* @return Parsed expression.
*/
- private static String parseScalarExpression(String text, int startPos, int len) {
+ private static String parseScalarExpression(String text, int startPos, int len, OdbcEscapeToken token) {
assert validSubstring(text, startPos, len);
- return substring(text, startPos + 3, len - 3).trim();
+ int startPos0 = startPos + 1 /* open brace */ + token.length() /* token. */;
+ int len0 = len - 1 /* open brace */ - token.length() /* token */ - 1 /* close brace */;
+
+ return substring(text, startPos0, len0).trim();
}
/**
@@ -212,23 +266,6 @@ public class OdbcEscapeUtils {
}
/**
- * Get escape sequence type.
- *
- * @param text Text.
- * @param startPos Start position.
- * @return Escape sequence type.
- */
- private static OdbcEscapeType sequenceType(String text, int startPos, int len) {
- assert validSubstring(text, startPos, len);
- assert text.charAt(startPos) == '{';
-
- if (text.startsWith("fn", startPos + 1))
- return OdbcEscapeType.FN;
-
- throw new IgniteException("Unsupported escape sequence: " + text.substring(startPos, startPos + len));
- }
-
- /**
* Perform "substring" using start position and length.
*
* @param text Text.
http://git-wip-us.apache.org/repos/asf/ignite/blob/e21111f2/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/OdbcEscapeSequenceSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/OdbcEscapeSequenceSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/OdbcEscapeSequenceSelfTest.java
index 73fa0f4..d9be6cc 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/OdbcEscapeSequenceSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/OdbcEscapeSequenceSelfTest.java
@@ -141,7 +141,7 @@ public class OdbcEscapeSequenceSelfTest extends GridCommonAbstractTest {
/**
* Test non-closed escape sequence.
*/
- public void testFailedOnInvalidSequence1() {
+ public void testFailedOnNonClosedEscapeSequence() {
checkFail("select {fn func1(field1, {fn func2(field2), field3)} from SomeTable;");
}
@@ -153,6 +153,19 @@ public class OdbcEscapeSequenceSelfTest extends GridCommonAbstractTest {
}
/**
+ * Test escape sequences with additional whitespace characters
+ */
+ public void testFunctionEscapeSequenceWithWhitespaces() throws Exception {
+ check("func1()", "{ fn func1()}");
+
+ check("func1()", "{ fn func1()}");
+
+ check("func1()", "{ \n fn func1()}");
+
+ checkFail("{ \n func1()}");
+ }
+
+ /**
* Check parsing logic.
*
* @param exp Expected result.
[40/50] [abbrv] ignite git commit: Merge branch 'ignite-1.6.7' into
ignite-1.7.2
Posted by sb...@apache.org.
Merge branch 'ignite-1.6.7' into ignite-1.7.2
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/bdbc5a37
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/bdbc5a37
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/bdbc5a37
Branch: refs/heads/ignite-961
Commit: bdbc5a37c1924ba4427221ee6cdf506c7f3ba248
Parents: 31dbc5d 70e69cb
Author: isapego <is...@gridgain.com>
Authored: Wed Aug 31 17:13:34 2016 +0300
Committer: isapego <is...@gridgain.com>
Committed: Wed Aug 31 17:13:34 2016 +0300
----------------------------------------------------------------------
.../ignite/cache/store/jdbc/dialect/SQLServerDialect.java | 2 +-
modules/platforms/cpp/odbc/include/ignite/odbc/connection.h | 7 -------
2 files changed, 1 insertion(+), 8 deletions(-)
----------------------------------------------------------------------
[45/50] [abbrv] ignite git commit: Merge branches 'ignite-1.7.2' to
'master'.
Posted by sb...@apache.org.
Merge branches 'ignite-1.7.2' to 'master'.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/857a1eac
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/857a1eac
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/857a1eac
Branch: refs/heads/ignite-961
Commit: 857a1eac12a39ea8d269ac35be7267d8cf16818b
Parents: 347429a afac3fa
Author: Alexey Kuznetsov <ak...@apache.org>
Authored: Mon Sep 5 15:11:00 2016 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Mon Sep 5 15:11:00 2016 +0700
----------------------------------------------------------------------
.../store/jdbc/dialect/SQLServerDialect.java | 2 +-
.../cpp/odbc/include/ignite/odbc/connection.h | 7 -
.../ignite/visor/commands/VisorConsole.scala | 1 +
.../commands/cache/VisorCacheCommand.scala | 33 ++++-
.../commands/cache/VisorCacheResetCommand.scala | 129 +++++++++++++++++++
.../cache/VisorCacheResetCommandSpec.scala | 114 ++++++++++++++++
6 files changed, 272 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
[34/50] [abbrv] ignite git commit: Fix for C++ tests.
Posted by sb...@apache.org.
Fix for C++ tests.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/31dbc5d6
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/31dbc5d6
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/31dbc5d6
Branch: refs/heads/ignite-961
Commit: 31dbc5d65f8ea51010d2129e7c6e9a27acbf8528
Parents: 4a259da
Author: isapego <is...@gridgain.com>
Authored: Tue Aug 30 17:28:34 2016 +0300
Committer: isapego <is...@gridgain.com>
Committed: Tue Aug 30 17:28:34 2016 +0300
----------------------------------------------------------------------
.../odbc-test/config/queries-test-noodbc.xml | 48 +++++++--------
.../cpp/odbc-test/config/queries-test.xml | 50 +++++++--------
.../cpp/odbc-test/project/vs/odbc-test.vcxproj | 1 +
.../project/vs/odbc-test.vcxproj.filters | 3 +
.../cpp/odbc-test/src/queries_test.cpp | 64 +++-----------------
.../odbc-test/src/sql_test_suite_fixture.cpp | 14 ++---
6 files changed, 68 insertions(+), 112 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/31dbc5d6/modules/platforms/cpp/odbc-test/config/queries-test-noodbc.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/config/queries-test-noodbc.xml b/modules/platforms/cpp/odbc-test/config/queries-test-noodbc.xml
index 18447c2..db19669 100644
--- a/modules/platforms/cpp/odbc-test/config/queries-test-noodbc.xml
+++ b/modules/platforms/cpp/odbc-test/config/queries-test-noodbc.xml
@@ -28,6 +28,7 @@
<bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
<property name="localHost" value="127.0.0.1"/>
<property name="connectorConfiguration"><null/></property>
+ <property name="odbcConfiguration"><null/></property>
<property name="cacheConfiguration">
<list>
@@ -38,14 +39,14 @@
<property name="writeSynchronizationMode" value="FULL_SYNC"/>
<!-- Configure type metadata to enable queries. -->
- <property name="queryEntities">
- <list>
- <bean class="org.apache.ignite.cache.QueryEntity">
- <property name="keyType" value="java.lang.Long"/>
- <property name="valueType" value="TestType"/>
+ <property name="queryEntities">
+ <list>
+ <bean class="org.apache.ignite.cache.QueryEntity">
+ <property name="keyType" value="java.lang.Long"/>
+ <property name="valueType" value="TestType"/>
- <property name="fields">
- <map>
+ <property name="fields">
+ <map>
<entry key="i8Field" value="java.lang.Byte"/>
<entry key="i16Field" value="java.lang.Short"/>
<entry key="i32Field" value="java.lang.Integer"/>
@@ -57,22 +58,22 @@
<entry key="guidField" value="java.util.UUID"/>
<entry key="dateField" value="java.util.Date"/>
<entry key="timestampField" value="java.sql.Timestamp"/>
- </map>
- </property>
+ </map>
+ </property>
- <property name="indexes">
- <list>
- <bean class="org.apache.ignite.cache.QueryIndex">
- <constructor-arg value="i32Field"/>
- </bean>
- <bean class="org.apache.ignite.cache.QueryIndex">
- <constructor-arg value="i64Field"/>
- </bean>
- </list>
- </property>
- </bean>
- </list>
- </property>
+ <property name="indexes">
+ <list>
+ <bean class="org.apache.ignite.cache.QueryIndex">
+ <constructor-arg value="i32Field"/>
+ </bean>
+ <bean class="org.apache.ignite.cache.QueryIndex">
+ <constructor-arg value="i64Field"/>
+ </bean>
+ </list>
+ </property>
+ </bean>
+ </list>
+ </property>
</bean>
</list>
</property>
@@ -86,8 +87,7 @@
instead os static IP based discovery.
-->
<!-- 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">
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
<property name="addresses">
<list>
<!-- In distributed environment, replace with actual host IP address. -->
http://git-wip-us.apache.org/repos/asf/ignite/blob/31dbc5d6/modules/platforms/cpp/odbc-test/config/queries-test.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/config/queries-test.xml b/modules/platforms/cpp/odbc-test/config/queries-test.xml
index 54cb9be..26e6341 100644
--- a/modules/platforms/cpp/odbc-test/config/queries-test.xml
+++ b/modules/platforms/cpp/odbc-test/config/queries-test.xml
@@ -32,8 +32,8 @@
<!-- Enabling ODBC. -->
<property name="odbcConfiguration">
<bean class="org.apache.ignite.configuration.OdbcConfiguration">
- <property name="endpointAddress" value="127.0.0.1:11110"/>
- </bean>
+ <property name="endpointAddress" value="127.0.0.1:11110"/>
+ </bean>
</property>
<property name="cacheConfiguration">
@@ -43,16 +43,16 @@
<property name="cacheMode" value="PARTITIONED"/>
<property name="atomicityMode" value="TRANSACTIONAL"/>
<property name="writeSynchronizationMode" value="FULL_SYNC"/>
-
+
<!-- Configure type metadata to enable queries. -->
- <property name="queryEntities">
- <list>
- <bean class="org.apache.ignite.cache.QueryEntity">
- <property name="keyType" value="java.lang.Long"/>
- <property name="valueType" value="TestType"/>
+ <property name="queryEntities">
+ <list>
+ <bean class="org.apache.ignite.cache.QueryEntity">
+ <property name="keyType" value="java.lang.Long"/>
+ <property name="valueType" value="TestType"/>
- <property name="fields">
- <map>
+ <property name="fields">
+ <map>
<entry key="i8Field" value="java.lang.Byte"/>
<entry key="i16Field" value="java.lang.Short"/>
<entry key="i32Field" value="java.lang.Integer"/>
@@ -64,22 +64,22 @@
<entry key="guidField" value="java.util.UUID"/>
<entry key="dateField" value="java.util.Date"/>
<entry key="timestampField" value="java.sql.Timestamp"/>
- </map>
- </property>
+ </map>
+ </property>
- <property name="indexes">
- <list>
- <bean class="org.apache.ignite.cache.QueryIndex">
- <constructor-arg value="i32Field"/>
- </bean>
- <bean class="org.apache.ignite.cache.QueryIndex">
- <constructor-arg value="i64Field"/>
- </bean>
- </list>
- </property>
- </bean>
- </list>
- </property>
+ <property name="indexes">
+ <list>
+ <bean class="org.apache.ignite.cache.QueryIndex">
+ <constructor-arg value="i32Field"/>
+ </bean>
+ <bean class="org.apache.ignite.cache.QueryIndex">
+ <constructor-arg value="i64Field"/>
+ </bean>
+ </list>
+ </property>
+ </bean>
+ </list>
+ </property>
</bean>
</list>
</property>
http://git-wip-us.apache.org/repos/asf/ignite/blob/31dbc5d6/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj b/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj
index 0702047..cb5735f 100644
--- a/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj
+++ b/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj
@@ -203,6 +203,7 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
+ <None Include="..\..\config\queries-test-noodbc.xml" />
<None Include="..\..\config\queries-test.xml" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
http://git-wip-us.apache.org/repos/asf/ignite/blob/31dbc5d6/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters b/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters
index 0a72640..270bdd6 100644
--- a/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters
+++ b/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters
@@ -125,5 +125,8 @@
<None Include="..\..\config\queries-test.xml">
<Filter>Configs</Filter>
</None>
+ <None Include="..\..\config\queries-test-noodbc.xml">
+ <Filter>Configs</Filter>
+ </None>
</ItemGroup>
</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/31dbc5d6/modules/platforms/cpp/odbc-test/src/queries_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/queries_test.cpp b/modules/platforms/cpp/odbc-test/src/queries_test.cpp
index ab59952..c907772 100644
--- a/modules/platforms/cpp/odbc-test/src/queries_test.cpp
+++ b/modules/platforms/cpp/odbc-test/src/queries_test.cpp
@@ -60,35 +60,6 @@ struct QueriesTestSuiteFixture
*/
void Connect(const std::string& connectStr)
{
- IgniteConfiguration cfg;
-
- cfg.jvmOpts.push_back("-Xdebug");
- cfg.jvmOpts.push_back("-Xnoagent");
- cfg.jvmOpts.push_back("-Djava.compiler=NONE");
- cfg.jvmOpts.push_back("-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005");
- cfg.jvmOpts.push_back("-XX:+HeapDumpOnOutOfMemoryError");
-
-#ifdef IGNITE_TESTS_32
- cfg.jvmInitMem = 256;
- cfg.jvmMaxMem = 768;
-#else
- cfg.jvmInitMem = 1024;
- cfg.jvmMaxMem = 4096;
-#endif
-
- char* cfgPath = getenv("IGNITE_NATIVE_TEST_ODBC_CONFIG_PATH");
-
- cfg.springCfgPath = std::string(cfgPath).append("/").append("queries-test.xml");
-
- IgniteError err;
-
- grid = Ignition::Start(cfg, &err);
-
- if (err.GetCode() != IgniteError::IGNITE_SUCCESS)
- BOOST_FAIL(err.GetText());
-
- testCache = grid.GetCache<int64_t, TestType>("cache");
-
// Allocate an environment handle
SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env);
@@ -141,7 +112,7 @@ struct QueriesTestSuiteFixture
SQLFreeHandle(SQL_HANDLE_ENV, env);
}
- static Ignite StartAdditionalNode(const char* name)
+ static Ignite StartNode(const char* name, const char* config)
{
IgniteConfiguration cfg;
@@ -163,43 +134,24 @@ struct QueriesTestSuiteFixture
BOOST_REQUIRE(cfgPath != 0);
- cfg.springCfgPath.assign(cfgPath).append("/queries-test.xml");
+ cfg.springCfgPath.assign(cfgPath).append("/").append(config);
IgniteError err;
return Ignition::Start(cfg, name);
}
+ static Ignite StartAdditionalNode(const char* name)
+ {
+ return StartNode(name, "queries-test-noodbc.xml");
+ }
+
/**
* Constructor.
*/
QueriesTestSuiteFixture() : testCache(0), env(NULL), dbc(NULL), stmt(NULL)
{
- IgniteConfiguration cfg;
-
- cfg.jvmOpts.push_back("-Xdebug");
- cfg.jvmOpts.push_back("-Xnoagent");
- cfg.jvmOpts.push_back("-Djava.compiler=NONE");
- cfg.jvmOpts.push_back("-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005");
- cfg.jvmOpts.push_back("-XX:+HeapDumpOnOutOfMemoryError");
-
-#ifdef IGNITE_TESTS_32
- cfg.jvmInitMem = 256;
- cfg.jvmMaxMem = 768;
-#else
- cfg.jvmInitMem = 1024;
- cfg.jvmMaxMem = 4096;
-#endif
-
- char* cfgPath = getenv("IGNITE_NATIVE_TEST_ODBC_CONFIG_PATH");
-
- BOOST_REQUIRE(cfgPath != 0);
-
- cfg.springCfgPath.assign(cfgPath).append("/queries-test.xml");
-
- IgniteError err;
-
- grid = Ignition::Start(cfg, "NodeMain");
+ grid = StartNode("NodeMain", "queries-test.xml");
testCache = grid.GetCache<int64_t, TestType>("cache");
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/31dbc5d6/modules/platforms/cpp/odbc-test/src/sql_test_suite_fixture.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/sql_test_suite_fixture.cpp b/modules/platforms/cpp/odbc-test/src/sql_test_suite_fixture.cpp
index 16e5ea0..69b4bfa 100644
--- a/modules/platforms/cpp/odbc-test/src/sql_test_suite_fixture.cpp
+++ b/modules/platforms/cpp/odbc-test/src/sql_test_suite_fixture.cpp
@@ -45,7 +45,7 @@ namespace ignite
char* cfgPath = getenv("IGNITE_NATIVE_TEST_ODBC_CONFIG_PATH");
- BOOST_REQUIRE(cfgPath != 0) ;
+ BOOST_REQUIRE(cfgPath != 0);
cfg.springCfgPath.assign(cfgPath).append("/queries-test.xml");
@@ -54,14 +54,14 @@ namespace ignite
grid = Ignition::Start(cfg, &err);
if (err.GetCode() != IgniteError::IGNITE_SUCCESS)
- BOOST_FAIL(err.GetText()) ;
+ BOOST_FAIL(err.GetText()) ;
testCache = grid.GetCache<int64_t, TestType>("cache");
// Allocate an environment handle
SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env);
- BOOST_REQUIRE(env != NULL) ;
+ BOOST_REQUIRE(env != NULL);
// We want ODBC 3 support
SQLSetEnvAttr(env, SQL_ATTR_ODBC_VERSION, reinterpret_cast<void*>(SQL_OV_ODBC3), 0);
@@ -69,10 +69,10 @@ namespace ignite
// Allocate a connection handle
SQLAllocHandle(SQL_HANDLE_DBC, env, &dbc);
- BOOST_REQUIRE(dbc != NULL) ;
+ BOOST_REQUIRE(dbc != NULL);
// Connect string
- SQLCHAR connectStr[] = "DRIVER={Apache Ignite};SERVER=localhost;PORT=10800;CACHE=cache";
+ SQLCHAR connectStr[] = "DRIVER={Apache Ignite};ADDRESS=127.0.0.1:11110;CACHE=cache";
SQLCHAR outstr[ODBC_BUFFER_SIZE];
SQLSMALLINT outstrlen;
@@ -85,13 +85,13 @@ namespace ignite
{
Ignition::Stop(grid.GetName(), true);
- BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_DBC, dbc)) ;
+ BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_DBC, dbc));
}
// Allocate a statement handle
SQLAllocHandle(SQL_HANDLE_STMT, dbc, &stmt);
- BOOST_REQUIRE(stmt != NULL) ;
+ BOOST_REQUIRE(stmt != NULL);
}
SqlTestSuiteFixture::~SqlTestSuiteFixture()
[42/50] [abbrv] ignite git commit: ignite-613 Fixed test.
Posted by sb...@apache.org.
ignite-613 Fixed test.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/9c6e650b
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/9c6e650b
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/9c6e650b
Branch: refs/heads/ignite-961
Commit: 9c6e650b4dfc0adc5b3cdb4ceb4880366e0e39c4
Parents: 6ca7e06
Author: sboikov <sb...@gridgain.com>
Authored: Thu Sep 1 17:27:43 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Thu Sep 1 17:27:43 2016 +0300
----------------------------------------------------------------------
.../IgniteCacheReplicatedQuerySelfTest.java | 50 +++++++-------------
1 file changed, 16 insertions(+), 34 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/9c6e650b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheReplicatedQuerySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheReplicatedQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheReplicatedQuerySelfTest.java
index e462cce..0a9f51c 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheReplicatedQuerySelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheReplicatedQuerySelfTest.java
@@ -21,10 +21,8 @@ import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
-import java.lang.reflect.Field;
import java.util.Collection;
import java.util.Iterator;
-import java.util.Map;
import java.util.UUID;
import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentMap;
@@ -40,21 +38,15 @@ import org.apache.ignite.cache.query.annotations.QuerySqlField;
import org.apache.ignite.events.DiscoveryEvent;
import org.apache.ignite.events.Event;
import org.apache.ignite.events.EventType;
-import org.apache.ignite.internal.IgniteKernal;
-import org.apache.ignite.internal.processors.cache.GridCacheContext;
import org.apache.ignite.internal.processors.cache.IgniteCacheAbstractQuerySelfTest;
import org.apache.ignite.internal.processors.cache.query.GridCacheQueryManager;
import org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing;
-import org.apache.ignite.internal.util.future.GridFutureAdapter;
-import org.apache.ignite.internal.util.lang.GridCloseableIterator;
import org.apache.ignite.internal.util.typedef.X;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.lang.IgniteBiTuple;
import org.apache.ignite.lang.IgnitePredicate;
import org.apache.ignite.testframework.GridTestUtils;
import org.apache.ignite.transactions.Transaction;
-import org.springframework.util.ReflectionUtils;
import static org.apache.ignite.cache.CacheMode.REPLICATED;
import static org.apache.ignite.cache.CachePeekMode.ALL;
@@ -278,26 +270,6 @@ public class IgniteCacheReplicatedQuerySelfTest extends IgniteCacheAbstractQuery
}
/**
- * Returns private field {@code qryIters} of {@link GridCacheQueryManager} for the given grid.
- *
- * @param g Grid which {@link GridCacheQueryManager} should be observed.
- * @return {@code qryIters} of {@link GridCacheQueryManager}.
- */
- private ConcurrentMap<UUID,
- Map<Long, GridFutureAdapter<GridCloseableIterator<IgniteBiTuple<CacheKey, CacheValue>>>>>
- distributedQueryManagerQueryItersMap(Ignite g) {
- GridCacheContext ctx = ((IgniteKernal)g).internalCache().context();
-
- Field qryItersField = ReflectionUtils.findField(ctx.queries().getClass(), "qryIters");
-
- qryItersField.setAccessible(true);
-
- return (ConcurrentMap<UUID,
- Map<Long, GridFutureAdapter<GridCloseableIterator<IgniteBiTuple<CacheKey, CacheValue>>>>>)
- ReflectionUtils.getField(qryItersField, ctx.queries());
- }
-
- /**
* @throws Exception If test failed.
*/
public void testToString() throws Exception {
@@ -355,8 +327,6 @@ public class IgniteCacheReplicatedQuerySelfTest extends IgniteCacheAbstractQuery
* @throws Exception If failed.
*/
public void testNodeLeft() throws Exception {
- fail("https://issues.apache.org/jira/browse/IGNITE-613");
-
Ignite g = startGrid("client");
try {
@@ -375,10 +345,12 @@ public class IgniteCacheReplicatedQuerySelfTest extends IgniteCacheAbstractQuery
assertEquals(0, (int)q.iterator().next().getKey());
- ConcurrentMap<UUID, ConcurrentMap<Long, ?>> map = U.field(((IgniteH2Indexing)U.field(U.field(
- grid(0).context(), "qryProc"), "idx")).mapQueryExecutor(), "qryRess");
+ // Query for replicated cache was run on one of nodes.
+ ConcurrentMap<?, ?> mapNode1 = queryResultMap(0);
+ ConcurrentMap<?, ?> mapNode2 = queryResultMap(1);
+ ConcurrentMap<?, ?> mapNode3 = queryResultMap(2);
- assertEquals(1, map.size());
+ assertEquals(1, mapNode1.size() + mapNode2.size() + mapNode3.size());
final UUID nodeId = g.cluster().localNode().id();
@@ -397,7 +369,9 @@ public class IgniteCacheReplicatedQuerySelfTest extends IgniteCacheAbstractQuery
latch.await();
- assertEquals(0, map.size());
+ assertEquals(0, mapNode1.size());
+ assertEquals(0, mapNode2.size());
+ assertEquals(0, mapNode3.size());
}
finally {
stopGrid("client");
@@ -405,6 +379,14 @@ public class IgniteCacheReplicatedQuerySelfTest extends IgniteCacheAbstractQuery
}
/**
+ * @param node Node index.
+ * @return Query results map.
+ */
+ private ConcurrentMap<?, ?> queryResultMap(int node) {
+ return U.field(((IgniteH2Indexing)U.field(grid(node).context().query(), "idx")).mapQueryExecutor(), "qryRess");
+ }
+
+ /**
* @param cache Cache.
* @throws Exception If check failed.
*/
[48/50] [abbrv] ignite git commit: IGNITE-3809: Fix for
ArrayIndexOutOfBoundsException in GridUnsafeLru. - Fixes #1017.
Posted by sb...@apache.org.
IGNITE-3809: Fix for ArrayIndexOutOfBoundsException in GridUnsafeLru. - Fixes #1017.
Signed-off-by: shtykh_roman <rs...@yahoo.com>
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/31b9bb84
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/31b9bb84
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/31b9bb84
Branch: refs/heads/ignite-961
Commit: 31b9bb84dd29259121759c655bac6247d2b93285
Parents: 69632c8
Author: shtykh_roman <rs...@yahoo.com>
Authored: Wed Sep 7 14:35:31 2016 +0900
Committer: shtykh_roman <rs...@yahoo.com>
Committed: Wed Sep 7 14:35:31 2016 +0900
----------------------------------------------------------------------
.../util/offheap/unsafe/GridUnsafeLru.java | 30 +++++++++++++++++---
1 file changed, 26 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/31b9bb84/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafeLru.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafeLru.java b/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafeLru.java
index aaff4f9..ea65217 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafeLru.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafeLru.java
@@ -28,8 +28,7 @@ import org.apache.ignite.internal.util.typedef.internal.S;
/**
* Striped LRU queue.
*/
-@SuppressWarnings("ForLoopReplaceableByForEach")
-class GridUnsafeLru {
+@SuppressWarnings("ForLoopReplaceableByForEach") class GridUnsafeLru {
/** Number of stripes. */
private final short cnt;
@@ -47,6 +46,9 @@ class GridUnsafeLru {
/** Current round-robin remove stripe index. */
private final AtomicInteger rmvIdx;
+ /** Max stripe index count. */
+ private final int maxIdxCnt;
+
/** Released flag. */
private AtomicBoolean released = new AtomicBoolean(false);
@@ -68,6 +70,8 @@ class GridUnsafeLru {
addIdx = new AtomicInteger();
rmvIdx = new AtomicInteger(cnt / 2);
+
+ maxIdxCnt = cnt - 1;
}
/**
@@ -156,7 +160,7 @@ class GridUnsafeLru {
* @throws GridOffHeapOutOfMemoryException If failed.
*/
long offer(int part, long addr, int hash) throws GridOffHeapOutOfMemoryException {
- return lrus[addIdx.getAndIncrement() % cnt].offer(part, addr, hash);
+ return lrus[incrementAndGet(addIdx, maxIdxCnt)].offer(part, addr, hash);
}
/**
@@ -165,7 +169,7 @@ class GridUnsafeLru {
* @return Queue node address.
*/
long prePoll() {
- int idx = rmvIdx.getAndIncrement();
+ int idx = incrementAndGet(rmvIdx, maxIdxCnt);
// Must try to poll from each LRU.
for (int i = 0; i < lrus.length; i++) {
@@ -180,6 +184,7 @@ class GridUnsafeLru {
/**
* Removes polling node from the queue.
+ *
* @param qAddr Queue node address.
*/
void poll(long qAddr) {
@@ -215,6 +220,23 @@ class GridUnsafeLru {
}
}
+ /**
+ * Atomically increments the given value by one, re-starting from 0 when the specified maximum is reached.
+ *
+ * @param value Value to increment.
+ * @param max Maximum after reaching which the value is reset to 0.
+ * @return Incremented value.
+ */
+ private int incrementAndGet(AtomicInteger value, int max) {
+ while (true) {
+ int cur = value.get();
+ int next = cur == max ? 0 : cur + 1;
+
+ if (value.compareAndSet(cur, next))
+ return next;
+ }
+ }
+
/** {@inheritDoc} */
@Override public String toString() {
return S.toString(GridUnsafeLru.class, this);
[35/50] [abbrv] ignite git commit: Merge branches 'ignite-1.7.2' and
'master'.
Posted by sb...@apache.org.
Merge branches 'ignite-1.7.2' and 'master'.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/8f697876
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/8f697876
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/8f697876
Branch: refs/heads/ignite-961
Commit: 8f697876a3a3ab491434289864a17ea3c3f82ce9
Parents: d98cd30 31dbc5d
Author: Alexey Kuznetsov <ak...@apache.org>
Authored: Wed Aug 31 10:29:53 2016 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Wed Aug 31 10:29:53 2016 +0700
----------------------------------------------------------------------
.../java/org/apache/ignite/IgniteCache.java | 15 +
.../processors/cache/CacheLazyEntry.java | 2 +
.../EntryProcessorResourceInjectorProxy.java | 105 ++++
.../processors/cache/GridCacheMapEntry.java | 13 +-
.../processors/cache/IgniteCacheProxy.java | 112 +++-
.../GridNearAtomicSingleUpdateFuture.java | 17 +-
.../dht/atomic/GridNearAtomicUpdateFuture.java | 8 +-
.../local/atomic/GridLocalAtomicCache.java | 18 +-
.../processors/cache/query/CacheQuery.java | 11 +-
.../query/GridCacheDistributedQueryManager.java | 22 +-
.../cache/query/GridCacheLocalQueryManager.java | 3 +-
.../cache/query/GridCacheQueryAdapter.java | 69 ++-
.../cache/query/GridCacheQueryBean.java | 8 +-
.../cache/query/GridCacheQueryInfo.java | 8 +-
.../cache/query/GridCacheQueryManager.java | 125 ++--
.../cache/query/GridCacheQueryRequest.java | 6 +-
.../transactions/IgniteTxLocalAdapter.java | 5 +-
.../processors/odbc/escape/OdbcEscapeUtils.java | 115 ++--
.../processors/resource/GridResourceIoc.java | 438 ++++++++++----
.../resource/GridResourceProcessor.java | 396 ++++++-------
.../cache/GridCacheAbstractFullApiSelfTest.java | 393 +++++++++++--
.../cache/GridCacheAbstractSelfTest.java | 140 ++++-
.../GridCacheTransformEventSelfTest.java | 66 ++-
...ePartitionedBasicStoreMultiNodeSelfTest.java | 2 +
.../GridCacheQueryTransformerSelfTest.java | 570 +++++++++++++++++++
.../odbc/OdbcEscapeSequenceSelfTest.java | 164 +++++-
.../multijvm/IgniteCacheProcessProxy.java | 6 +
.../IgniteCacheQuerySelfTestSuite.java | 2 +
.../odbc-test/config/queries-test-noodbc.xml | 48 +-
.../cpp/odbc-test/config/queries-test.xml | 50 +-
.../cpp/odbc-test/project/vs/odbc-test.vcxproj | 1 +
.../project/vs/odbc-test.vcxproj.filters | 3 +
.../cpp/odbc-test/src/queries_test.cpp | 64 +--
.../odbc-test/src/sql_test_suite_fixture.cpp | 14 +-
.../GridTransformSpringInjectionSelfTest.java | 186 ++++++
.../testsuites/IgniteSpringTestSuite.java | 7 +-
.../commands/cache/VisorCacheStopCommand.scala | 5 +-
.../IgniteInvokeWithInjectionBenchmark.java | 74 +++
.../IgniteInvokeWithInjectionTxBenchmark.java | 30 +
39 files changed, 2632 insertions(+), 689 deletions(-)
----------------------------------------------------------------------
[05/50] [abbrv] ignite git commit: IGNITE-3757: ODBC: Added aggregate
functions support. This closes #983.
Posted by sb...@apache.org.
IGNITE-3757: ODBC: Added aggregate functions support. This closes #983.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/0e3a6e2d
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/0e3a6e2d
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/0e3a6e2d
Branch: refs/heads/ignite-961
Commit: 0e3a6e2df8b42f255a5a4688d5827dccaabfd3a4
Parents: 5a3b3e2
Author: isapego <is...@gridgain.com>
Authored: Thu Aug 25 14:34:31 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Thu Aug 25 14:34:31 2016 +0300
----------------------------------------------------------------------
modules/platforms/cpp/odbc-test/Makefile.am | 1 +
.../cpp/odbc-test/project/vs/odbc-test.vcxproj | 1 +
.../project/vs/odbc-test.vcxproj.filters | 3 +
.../src/sql_aggregate_functions_test.cpp | 249 +++++++++++++++++++
.../cpp/odbc/src/config/connection_info.cpp | 5 +-
5 files changed, 256 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/0e3a6e2d/modules/platforms/cpp/odbc-test/Makefile.am
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/Makefile.am b/modules/platforms/cpp/odbc-test/Makefile.am
index 62bdec3..6288637 100644
--- a/modules/platforms/cpp/odbc-test/Makefile.am
+++ b/modules/platforms/cpp/odbc-test/Makefile.am
@@ -65,6 +65,7 @@ ignite_odbc_tests_SOURCES = \
src/sql_function_test_suite_fixture.cpp \
src/sql_string_functions_test.cpp \
src/sql_numeric_functions_test.cpp \
+ src/sql_aggregate_functions_test.cpp \
../odbc/src/cursor.cpp \
../odbc/src/config/connection_info.cpp \
../odbc/src/app/application_data_buffer.cpp \
http://git-wip-us.apache.org/repos/asf/ignite/blob/0e3a6e2d/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj b/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj
index a83ed6b..e0b786a 100644
--- a/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj
+++ b/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj
@@ -168,6 +168,7 @@
<ClCompile Include="..\..\src\queries_test.cpp" />
<ClCompile Include="..\..\src\parser_test.cpp" />
<ClCompile Include="..\..\src\row_test.cpp" />
+ <ClCompile Include="..\..\src\sql_aggregate_functions_test.cpp" />
<ClCompile Include="..\..\src\sql_function_test_suite_fixture.cpp" />
<ClCompile Include="..\..\src\sql_numeric_functions_test.cpp" />
<ClCompile Include="..\..\src\sql_string_functions_test.cpp" />
http://git-wip-us.apache.org/repos/asf/ignite/blob/0e3a6e2d/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters b/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters
index f993ed9..763a364 100644
--- a/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters
+++ b/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters
@@ -88,6 +88,9 @@
<ClCompile Include="..\..\src\sql_function_test_suite_fixture.cpp">
<Filter>Code</Filter>
</ClCompile>
+ <ClCompile Include="..\..\src\sql_aggregate_functions_test.cpp">
+ <Filter>Code</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\include\test_type.h">
http://git-wip-us.apache.org/repos/asf/ignite/blob/0e3a6e2d/modules/platforms/cpp/odbc-test/src/sql_aggregate_functions_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/sql_aggregate_functions_test.cpp b/modules/platforms/cpp/odbc-test/src/sql_aggregate_functions_test.cpp
new file mode 100644
index 0000000..6254913
--- /dev/null
+++ b/modules/platforms/cpp/odbc-test/src/sql_aggregate_functions_test.cpp
@@ -0,0 +1,249 @@
+/*
+ * 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.
+ */
+
+#define _USE_MATH_DEFINES
+
+#ifdef _WIN32
+# include <windows.h>
+#endif
+
+#include <sql.h>
+#include <sqlext.h>
+
+#include <cmath>
+
+#include <vector>
+#include <string>
+
+#ifndef _MSC_VER
+# define BOOST_TEST_DYN_LINK
+#endif
+
+#include <boost/test/unit_test.hpp>
+
+#include "ignite/ignite.h"
+#include "ignite/ignition.h"
+#include "ignite/impl/binary/binary_utils.h"
+
+#include "test_type.h"
+#include "test_utils.h"
+#include "sql_function_test_suite_fixture.h"
+
+using namespace ignite;
+using namespace ignite::cache;
+using namespace ignite::cache::query;
+using namespace ignite::common;
+
+using namespace boost::unit_test;
+
+using ignite::impl::binary::BinaryUtils;
+
+BOOST_FIXTURE_TEST_SUITE(SqlAggregateFunctionTestSuite, ignite::SqlFunctionTestSuiteFixture)
+
+BOOST_AUTO_TEST_CASE(TestAggregateFunctionAvgInt)
+{
+ std::vector<TestType> in(3);
+
+ in[0].i32Field = 43;
+ in[1].i32Field = 311;
+ in[2].i32Field = 7;
+
+ int32_t avg = 0;
+
+ for (int32_t i = 0; i < static_cast<int32_t>(in.size()); ++i)
+ {
+ testCache.Put(i, in[i]);
+
+ avg += in[i].i32Field;
+ }
+
+ avg /= static_cast<int32_t>(in.size());
+
+ CheckSingleResult<int64_t>("SELECT {fn AVG(i32Field)} FROM TestType", avg);
+}
+
+BOOST_AUTO_TEST_CASE(TestAggregateFunctionAvgIntDistinct)
+{
+ std::vector<TestType> in(3);
+
+ in[0].i32Field = 43;
+ in[1].i32Field = 311;
+ in[2].i32Field = 7;
+
+ int32_t avg = 0;
+
+ for (int32_t i = 0; i < static_cast<int32_t>(in.size()); ++i)
+ {
+ testCache.Put(i, in[i]);
+
+ avg += in[i].i32Field;
+ }
+
+ avg /= static_cast<int32_t>(in.size());
+
+ testCache.Put(in.size() + 10, in[0]);
+
+ CheckSingleResult<int64_t>("SELECT {fn AVG(DISTINCT i32Field)} FROM TestType", avg);
+}
+
+BOOST_AUTO_TEST_CASE(TestAggregateFunctionAvgFloat)
+{
+ std::vector<TestType> in(3);
+
+ in[0].floatField = 43.0;
+ in[1].floatField = 311.0;
+ in[2].floatField = 7.0;
+
+ float avg = 0;
+
+ for (int32_t i = 0; i < static_cast<int32_t>(in.size()); ++i)
+ {
+ testCache.Put(i, in[i]);
+
+ avg += in[i].i32Field;
+ }
+
+ avg /= in.size();
+
+ CheckSingleResult<float>("SELECT {fn AVG(floatField)} FROM TestType", avg);
+}
+
+BOOST_AUTO_TEST_CASE(TestAggregateFunctionAvgFloatDistinct)
+{
+ std::vector<TestType> in(3);
+
+ in[0].floatField = 43.0;
+ in[1].floatField = 311.0;
+ in[2].floatField = 7.0;
+
+ float avg = 0;
+
+ for (int32_t i = 0; i < static_cast<int32_t>(in.size()); ++i)
+ {
+ testCache.Put(i, in[i]);
+
+ avg += in[i].i32Field;
+ }
+
+ avg /= in.size();
+
+ testCache.Put(in.size() + 10, in[0]);
+
+ CheckSingleResult<float>("SELECT {fn AVG(DISTINCT floatField)} FROM TestType", avg);
+}
+
+BOOST_AUTO_TEST_CASE(TestAggregateFunctionCount)
+{
+ std::vector<TestType> in(8);
+
+ for (int32_t i = 0; i < static_cast<int32_t>(in.size()); ++i)
+ testCache.Put(i, in[i]);
+
+ CheckSingleResult<int64_t>("SELECT {fn COUNT(*)} FROM TestType", in.size());
+}
+
+BOOST_AUTO_TEST_CASE(TestAggregateFunctionCountDistinct)
+{
+ std::vector<TestType> in(8);
+
+ for (int32_t i = 0; i < static_cast<int32_t>(in.size()); ++i)
+ {
+ in[i].i32Field = i;
+
+ testCache.Put(i, in[i]);
+ }
+
+ testCache.Put(in.size() + 10, in[0]);
+
+ CheckSingleResult<int64_t>("SELECT {fn COUNT(DISTINCT i32Field)} FROM TestType", in.size());
+}
+
+BOOST_AUTO_TEST_CASE(TestAggregateFunctionMax)
+{
+ std::vector<TestType> in(4);
+
+ in[0].i32Field = 121;
+ in[1].i32Field = 17;
+ in[2].i32Field = 314041;
+ in[3].i32Field = 9410;
+
+ for (int32_t i = 0; i < static_cast<int32_t>(in.size()); ++i)
+ testCache.Put(i, in[i]);
+
+ CheckSingleResult<int64_t>("SELECT {fn MAX(i32Field)} FROM TestType", in[2].i32Field);
+}
+
+BOOST_AUTO_TEST_CASE(TestAggregateFunctionMin)
+{
+ std::vector<TestType> in(4);
+
+ in[0].i32Field = 121;
+ in[1].i32Field = 17;
+ in[2].i32Field = 314041;
+ in[3].i32Field = 9410;
+
+ for (int32_t i = 0; i < static_cast<int32_t>(in.size()); ++i)
+ testCache.Put(i, in[i]);
+
+ CheckSingleResult<int64_t>("SELECT {fn MIN(i32Field)} FROM TestType", in[1].i32Field);
+}
+
+BOOST_AUTO_TEST_CASE(TestAggregateFunctionSum)
+{
+ std::vector<TestType> in(4);
+
+ in[0].i32Field = 121;
+ in[1].i32Field = 17;
+ in[2].i32Field = 314041;
+ in[3].i32Field = 9410;
+
+ int64_t sum = 0;
+
+ for (int32_t i = 0; i < static_cast<int32_t>(in.size()); ++i)
+ {
+ testCache.Put(i, in[i]);
+
+ sum += in[i].i32Field;
+ }
+
+ CheckSingleResult<int64_t>("SELECT {fn SUM(i32Field)} FROM TestType", sum);
+}
+
+BOOST_AUTO_TEST_CASE(TestAggregateFunctionSumDistinct)
+{
+ std::vector<TestType> in(4);
+
+ in[0].i32Field = 121;
+ in[1].i32Field = 17;
+ in[2].i32Field = 314041;
+ in[3].i32Field = 9410;
+
+ int64_t sum = 0;
+
+ for (int32_t i = 0; i < static_cast<int32_t>(in.size()); ++i)
+ {
+ testCache.Put(i, in[i]);
+
+ sum += in[i].i32Field;
+ }
+
+ testCache.Put(in.size() + 10, in[0]);
+
+ CheckSingleResult<int64_t>("SELECT {fn SUM(DISTINCT i32Field)} FROM TestType", sum);
+}
+
+BOOST_AUTO_TEST_SUITE_END()
http://git-wip-us.apache.org/repos/asf/ignite/blob/0e3a6e2d/modules/platforms/cpp/odbc/src/config/connection_info.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/config/connection_info.cpp b/modules/platforms/cpp/odbc/src/config/connection_info.cpp
index 1fed7c5..b2480c2 100644
--- a/modules/platforms/cpp/odbc/src/config/connection_info.cpp
+++ b/modules/platforms/cpp/odbc/src/config/connection_info.cpp
@@ -225,9 +225,8 @@ namespace ignite
#ifdef SQL_AGGREGATE_FUNCTIONS
// Bitmask enumerating support for aggregation functions.
- intParams[SQL_AGGREGATE_FUNCTIONS] = SQL_AF_ALL | SQL_AF_AVG |
- SQL_AF_COUNT | SQL_AF_DISTINCT | SQL_AF_MAX | SQL_AF_MIN |
- SQL_AF_SUM;
+ intParams[SQL_AGGREGATE_FUNCTIONS] = SQL_AF_AVG | SQL_AF_COUNT |
+ SQL_AF_DISTINCT | SQL_AF_MAX | SQL_AF_MIN | SQL_AF_SUM;
#endif // SQL_AGGREGATE_FUNCTIONS
#ifdef SQL_NUMERIC_FUNCTIONS
[23/50] [abbrv] ignite git commit: .NET: System type ctors cleanup -
use appropriate reader type
Posted by sb...@apache.org.
.NET: System type ctors cleanup - use appropriate reader type
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/db300bac
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/db300bac
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/db300bac
Branch: refs/heads/ignite-961
Commit: db300bac24b68b3e268480636249efa5e4a11e65
Parents: c2f029f
Author: Pavel Tupitsyn <pt...@apache.org>
Authored: Mon Aug 29 19:47:23 2016 +0300
Committer: Pavel Tupitsyn <pt...@apache.org>
Committed: Mon Aug 29 19:47:23 2016 +0300
----------------------------------------------------------------------
.../Impl/Binary/DateTimeHolder.cs | 4 +--
.../Impl/Binary/Marshaller.cs | 36 ++++++++++----------
.../Impl/Binary/SerializableObjectHolder.cs | 6 ++--
.../Impl/Cache/CacheEntryFilterHolder.cs | 10 +++---
.../Impl/Cache/CacheEntryProcessorHolder.cs | 8 ++---
.../Continuous/ContinuousQueryFilterHolder.cs | 8 ++---
.../Impl/Compute/Closure/ComputeActionJob.cs | 6 ++--
.../Impl/Compute/Closure/ComputeFuncJob.cs | 8 ++---
.../Impl/Compute/Closure/ComputeOutFuncJob.cs | 9 ++---
.../Impl/Compute/ComputeFunc.cs | 9 +++--
.../Impl/Compute/ComputeJob.cs | 10 +++---
.../Impl/Compute/ComputeJobHolder.cs | 8 ++---
.../Impl/Compute/ComputeOutFunc.cs | 8 ++---
.../Impl/Datastream/StreamReceiverHolder.cs | 2 +-
.../Impl/Messaging/MessageListenerHolder.cs | 8 ++---
15 files changed, 60 insertions(+), 80 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/db300bac/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/DateTimeHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/DateTimeHolder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/DateTimeHolder.cs
index 473f6c4..b80348e 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/DateTimeHolder.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/DateTimeHolder.cs
@@ -42,11 +42,11 @@ namespace Apache.Ignite.Core.Impl.Binary
/// Constructor.
/// </summary>
/// <param name="reader">The reader.</param>
- public DateTimeHolder(IBinaryReader reader)
+ public DateTimeHolder(IBinaryRawReader reader)
{
Debug.Assert(reader != null);
- _item = DateTime.FromBinary(reader.GetRawReader().ReadLong());
+ _item = DateTime.FromBinary(reader.ReadLong());
}
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/db300bac/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Marshaller.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Marshaller.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Marshaller.cs
index 6e63e9a..035b356 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Marshaller.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Marshaller.cs
@@ -574,26 +574,26 @@ namespace Apache.Ignite.Core.Impl.Binary
/// </summary>
private void AddSystemTypes()
{
- AddSystemType(BinaryUtils.TypeNativeJobHolder, w => new ComputeJobHolder(w));
- AddSystemType(BinaryUtils.TypeComputeJobWrapper, w => new ComputeJobWrapper(w));
- AddSystemType(BinaryUtils.TypeIgniteProxy, w => new IgniteProxy());
- AddSystemType(BinaryUtils.TypeComputeOutFuncJob, w => new ComputeOutFuncJob(w));
- AddSystemType(BinaryUtils.TypeComputeOutFuncWrapper, w => new ComputeOutFuncWrapper(w));
- AddSystemType(BinaryUtils.TypeComputeFuncWrapper, w => new ComputeFuncWrapper(w));
- AddSystemType(BinaryUtils.TypeComputeFuncJob, w => new ComputeFuncJob(w));
- AddSystemType(BinaryUtils.TypeComputeActionJob, w => new ComputeActionJob(w));
- AddSystemType(BinaryUtils.TypeContinuousQueryRemoteFilterHolder, w => new ContinuousQueryFilterHolder(w));
- AddSystemType(BinaryUtils.TypeSerializableHolder, w => new SerializableObjectHolder(w),
+ AddSystemType(BinaryUtils.TypeNativeJobHolder, r => new ComputeJobHolder(r));
+ AddSystemType(BinaryUtils.TypeComputeJobWrapper, r => new ComputeJobWrapper(r));
+ AddSystemType(BinaryUtils.TypeIgniteProxy, r => new IgniteProxy());
+ AddSystemType(BinaryUtils.TypeComputeOutFuncJob, r => new ComputeOutFuncJob(r));
+ AddSystemType(BinaryUtils.TypeComputeOutFuncWrapper, r => new ComputeOutFuncWrapper(r));
+ AddSystemType(BinaryUtils.TypeComputeFuncWrapper, r => new ComputeFuncWrapper(r));
+ AddSystemType(BinaryUtils.TypeComputeFuncJob, r => new ComputeFuncJob(r));
+ AddSystemType(BinaryUtils.TypeComputeActionJob, r => new ComputeActionJob(r));
+ AddSystemType(BinaryUtils.TypeContinuousQueryRemoteFilterHolder, r => new ContinuousQueryFilterHolder(r));
+ AddSystemType(BinaryUtils.TypeSerializableHolder, r => new SerializableObjectHolder(r),
serializer: new SerializableSerializer());
- AddSystemType(BinaryUtils.TypeDateTimeHolder, w => new DateTimeHolder(w),
+ AddSystemType(BinaryUtils.TypeDateTimeHolder, r => new DateTimeHolder(r),
serializer: new DateTimeSerializer());
- AddSystemType(BinaryUtils.TypeCacheEntryProcessorHolder, w => new CacheEntryProcessorHolder(w));
- AddSystemType(BinaryUtils.TypeCacheEntryPredicateHolder, w => new CacheEntryFilterHolder(w));
- AddSystemType(BinaryUtils.TypeMessageListenerHolder, w => new MessageListenerHolder(w));
- AddSystemType(BinaryUtils.TypeStreamReceiverHolder, w => new StreamReceiverHolder(w));
- AddSystemType(0, w => new AffinityKey(w), "affKey");
- AddSystemType(BinaryUtils.TypePlatformJavaObjectFactoryProxy, w => new PlatformJavaObjectFactoryProxy());
- AddSystemType(0, w => new ObjectInfoHolder(w));
+ AddSystemType(BinaryUtils.TypeCacheEntryProcessorHolder, r => new CacheEntryProcessorHolder(r));
+ AddSystemType(BinaryUtils.TypeCacheEntryPredicateHolder, r => new CacheEntryFilterHolder(r));
+ AddSystemType(BinaryUtils.TypeMessageListenerHolder, r => new MessageListenerHolder(r));
+ AddSystemType(BinaryUtils.TypeStreamReceiverHolder, r => new StreamReceiverHolder(r));
+ AddSystemType(0, r => new AffinityKey(r), "affKey");
+ AddSystemType(BinaryUtils.TypePlatformJavaObjectFactoryProxy, r => new PlatformJavaObjectFactoryProxy());
+ AddSystemType(0, r => new ObjectInfoHolder(r));
}
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/db300bac/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/SerializableObjectHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/SerializableObjectHolder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/SerializableObjectHolder.cs
index 08b44df..99c8f49 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/SerializableObjectHolder.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/SerializableObjectHolder.cs
@@ -67,13 +67,11 @@ namespace Apache.Ignite.Core.Impl.Binary
/// Initializes a new instance of the <see cref="SerializableObjectHolder"/> class.
/// </summary>
/// <param name="reader">The reader.</param>
- public SerializableObjectHolder(IBinaryReader reader)
+ public SerializableObjectHolder(BinaryReader reader)
{
Debug.Assert(reader != null);
- var reader0 = (BinaryReader) reader.GetRawReader();
-
- using (var streamAdapter = new BinaryStreamAdapter(reader0.Stream))
+ using (var streamAdapter = new BinaryStreamAdapter(reader.Stream))
{
_item = new BinaryFormatter().Deserialize(streamAdapter, null);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/db300bac/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryFilterHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryFilterHolder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryFilterHolder.cs
index 4487c59..90db02c 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryFilterHolder.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryFilterHolder.cs
@@ -88,15 +88,13 @@ namespace Apache.Ignite.Core.Impl.Cache
/// Initializes a new instance of the <see cref="CacheEntryFilterHolder"/> class.
/// </summary>
/// <param name="reader">The reader.</param>
- public CacheEntryFilterHolder(IBinaryReader reader)
+ public CacheEntryFilterHolder(BinaryReader reader)
{
- var reader0 = (BinaryReader)reader.GetRawReader();
+ _pred = reader.ReadObject<object>();
- _pred = reader0.ReadObject<object>();
+ _keepBinary = reader.ReadBoolean();
- _keepBinary = reader0.ReadBoolean();
-
- _marsh = reader0.Marshaller;
+ _marsh = reader.Marshaller;
_invoker = GetInvoker(_pred);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/db300bac/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryProcessorHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryProcessorHolder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryProcessorHolder.cs
index a0f8f3a..9fc7c7d 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryProcessorHolder.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryProcessorHolder.cs
@@ -113,12 +113,10 @@ namespace Apache.Ignite.Core.Impl.Cache
/// Initializes a new instance of the <see cref="CacheEntryProcessorHolder"/> class.
/// </summary>
/// <param name="reader">The reader.</param>
- public CacheEntryProcessorHolder(IBinaryReader reader)
+ public CacheEntryProcessorHolder(IBinaryRawReader reader)
{
- var reader0 = (BinaryReader) reader.GetRawReader();
-
- _proc = reader0.ReadObject<object>();
- _arg = reader0.ReadObject<object>();
+ _proc = reader.ReadObject<object>();
+ _arg = reader.ReadObject<object>();
_processFunc = GetProcessFunc(_proc);
http://git-wip-us.apache.org/repos/asf/ignite/blob/db300bac/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryFilterHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryFilterHolder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryFilterHolder.cs
index c2e7762..6eebbbe 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryFilterHolder.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryFilterHolder.cs
@@ -75,12 +75,10 @@ namespace Apache.Ignite.Core.Impl.Cache.Query.Continuous
/// Initializes a new instance of the <see cref="ContinuousQueryFilterHolder"/> class.
/// </summary>
/// <param name="reader">The reader.</param>
- public ContinuousQueryFilterHolder(IBinaryReader reader)
+ public ContinuousQueryFilterHolder(IBinaryRawReader reader)
{
- var rawReader = (BinaryReader) reader.GetRawReader();
-
- _filter = rawReader.ReadObject<object>();
- _keepBinary = rawReader.ReadBoolean();
+ _filter = reader.ReadObject<object>();
+ _keepBinary = reader.ReadBoolean();
}
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/db300bac/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeActionJob.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeActionJob.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeActionJob.cs
index d7c4311..55332d5 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeActionJob.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeActionJob.cs
@@ -72,11 +72,9 @@ namespace Apache.Ignite.Core.Impl.Compute.Closure
/// Initializes a new instance of the <see cref="ComputeActionJob"/> class.
/// </summary>
/// <param name="reader">The reader.</param>
- public ComputeActionJob(IBinaryReader reader)
+ public ComputeActionJob(IBinaryRawReader reader)
{
- var reader0 = (BinaryReader)reader.GetRawReader();
-
- _action = reader0.ReadObject<IComputeAction>();
+ _action = reader.ReadObject<IComputeAction>();
}
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/db300bac/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeFuncJob.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeFuncJob.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeFuncJob.cs
index 8f76fcf..0cd8df2 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeFuncJob.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeFuncJob.cs
@@ -75,12 +75,10 @@ namespace Apache.Ignite.Core.Impl.Compute.Closure
/// Initializes a new instance of the <see cref="ComputeFuncJob"/> class.
/// </summary>
/// <param name="reader">The reader.</param>
- public ComputeFuncJob(IBinaryReader reader)
+ public ComputeFuncJob(IBinaryRawReader reader)
{
- var reader0 = (BinaryReader) reader.GetRawReader();
-
- _clo = reader0.ReadObject<IComputeFunc>();
- _arg = reader0.ReadObject<object>();
+ _clo = reader.ReadObject<IComputeFunc>();
+ _arg = reader.ReadObject<object>();
}
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/db300bac/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeOutFuncJob.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeOutFuncJob.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeOutFuncJob.cs
index c99d821..abdf448 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeOutFuncJob.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeOutFuncJob.cs
@@ -65,11 +65,12 @@ namespace Apache.Ignite.Core.Impl.Compute.Closure
writer0.WithDetach(w => w.WriteObject(_clo));
}
- public ComputeOutFuncJob(IBinaryReader reader)
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ComputeOutFuncJob" /> class.
+ /// </summary>
+ public ComputeOutFuncJob(IBinaryRawReader reader)
{
- var reader0 = (BinaryReader) reader.GetRawReader();
-
- _clo = reader0.ReadObject<IComputeOutFunc>();
+ _clo = reader.ReadObject<IComputeOutFunc>();
}
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/db300bac/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeFunc.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeFunc.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeFunc.cs
index 454f7bb..db22c94 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeFunc.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeFunc.cs
@@ -66,7 +66,7 @@ namespace Apache.Ignite.Core.Impl.Compute
}
catch (TargetInvocationException ex)
{
- throw ex.InnerException;
+ throw ex.InnerException ?? ex;
}
}
@@ -82,11 +82,9 @@ namespace Apache.Ignite.Core.Impl.Compute
/// Initializes a new instance of the <see cref="ComputeFuncWrapper"/> class.
/// </summary>
/// <param name="reader">The reader.</param>
- public ComputeFuncWrapper(IBinaryReader reader)
+ public ComputeFuncWrapper(IBinaryRawReader reader)
{
- var reader0 = (BinaryReader)reader.GetRawReader();
-
- _func = reader0.ReadObject<object>();
+ _func = reader.ReadObject<object>();
_invoker = DelegateTypeDescriptor.GetComputeFunc(_func.GetType());
}
@@ -95,6 +93,7 @@ namespace Apache.Ignite.Core.Impl.Compute
/// Injects the Ignite instance.
/// </summary>
[InstanceResource]
+ // ReSharper disable once UnusedMember.Global (used by injector)
public void InjectIgnite(IIgnite ignite)
{
// Propagate injection
http://git-wip-us.apache.org/repos/asf/ignite/blob/db300bac/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJob.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJob.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJob.cs
index 526c445..ad29b03 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJob.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJob.cs
@@ -52,11 +52,9 @@ namespace Apache.Ignite.Core.Impl.Compute
/// Initializes a new instance of the <see cref="ComputeJobWrapper"/> class.
/// </summary>
/// <param name="reader">The reader.</param>
- public ComputeJobWrapper(IBinaryReader reader)
+ public ComputeJobWrapper(IBinaryRawReader reader)
{
- var reader0 = (BinaryReader)reader.GetRawReader();
-
- _job = reader0.ReadObject<object>();
+ _job = reader.ReadObject<object>();
DelegateTypeDescriptor.GetComputeJob(_job.GetType(), out _execute, out _cancel);
}
@@ -82,7 +80,7 @@ namespace Apache.Ignite.Core.Impl.Compute
}
catch (TargetInvocationException ex)
{
- throw ex.InnerException;
+ throw ex.InnerException ?? ex;
}
}
@@ -95,7 +93,7 @@ namespace Apache.Ignite.Core.Impl.Compute
}
catch (TargetInvocationException ex)
{
- throw ex.InnerException;
+ throw ex.InnerException ?? ex;
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/db300bac/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJobHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJobHolder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJobHolder.cs
index 0d93010..6389730 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJobHolder.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJobHolder.cs
@@ -47,15 +47,13 @@ namespace Apache.Ignite.Core.Impl.Compute
/// Default ctor for marshalling.
/// </summary>
/// <param name="reader"></param>
- public ComputeJobHolder(IBinaryReader reader)
+ public ComputeJobHolder(BinaryReader reader)
{
Debug.Assert(reader != null);
- var reader0 = (BinaryReader) reader.GetRawReader();
+ _ignite = reader.Marshaller.Ignite;
- _ignite = reader0.Marshaller.Ignite;
-
- _job = reader0.ReadObject<IComputeJob>();
+ _job = reader.ReadObject<IComputeJob>();
}
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/db300bac/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeOutFunc.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeOutFunc.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeOutFunc.cs
index 1867f8c..f581c3f 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeOutFunc.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeOutFunc.cs
@@ -70,7 +70,7 @@ namespace Apache.Ignite.Core.Impl.Compute
}
catch (TargetInvocationException ex)
{
- throw ex.InnerException;
+ throw ex.InnerException ?? ex;
}
}
@@ -86,11 +86,9 @@ namespace Apache.Ignite.Core.Impl.Compute
/// Initializes a new instance of the <see cref="ComputeOutFuncWrapper"/> class.
/// </summary>
/// <param name="reader">The reader.</param>
- public ComputeOutFuncWrapper(IBinaryReader reader)
+ public ComputeOutFuncWrapper(IBinaryRawReader reader)
{
- var reader0 = (BinaryReader)reader.GetRawReader();
-
- _func = reader0.ReadObject<object>();
+ _func = reader.ReadObject<object>();
_invoker = DelegateTypeDescriptor.GetComputeOutFunc(_func.GetType());
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/db300bac/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Datastream/StreamReceiverHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Datastream/StreamReceiverHolder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Datastream/StreamReceiverHolder.cs
index 90ade5a..953ddb6 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Datastream/StreamReceiverHolder.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Datastream/StreamReceiverHolder.cs
@@ -50,7 +50,7 @@ namespace Apache.Ignite.Core.Impl.Datastream
/// Initializes a new instance of the <see cref="StreamReceiverHolder"/> class.
/// </summary>
/// <param name="reader">The reader.</param>
- public StreamReceiverHolder(BinaryReader reader)
+ public StreamReceiverHolder(IBinaryRawReader reader)
{
var rcvType = reader.ReadByte();
http://git-wip-us.apache.org/repos/asf/ignite/blob/db300bac/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Messaging/MessageListenerHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Messaging/MessageListenerHolder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Messaging/MessageListenerHolder.cs
index 1a2c18a..8e794d1 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Messaging/MessageListenerHolder.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Messaging/MessageListenerHolder.cs
@@ -155,15 +155,13 @@ namespace Apache.Ignite.Core.Impl.Messaging
/// Initializes a new instance of the <see cref="MessageListenerHolder"/> class.
/// </summary>
/// <param name="reader">The reader.</param>
- public MessageListenerHolder(IBinaryReader reader)
+ public MessageListenerHolder(BinaryReader reader)
{
- var reader0 = (BinaryReader)reader.GetRawReader();
-
- _filter = reader0.ReadObject<object>();
+ _filter = reader.ReadObject<object>();
_invoker = GetInvoker(_filter);
- _ignite = reader0.Marshaller.Ignite;
+ _ignite = reader.Marshaller.Ignite;
ResourceProcessor.Inject(_filter, _ignite);
}
[32/50] [abbrv] ignite git commit: Revert wrong merge.
Posted by sb...@apache.org.
Revert wrong merge.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/1ef150eb
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/1ef150eb
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/1ef150eb
Branch: refs/heads/ignite-961
Commit: 1ef150eba52eb63c2bfc3fafa0d036cf26be1c5b
Parents: fbbcaf4
Author: Alexey Kuznetsov <ak...@apache.org>
Authored: Tue Aug 30 18:18:20 2016 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Tue Aug 30 18:18:20 2016 +0700
----------------------------------------------------------------------
.../ignite/visor/commands/cache/VisorCacheStopCommand.scala | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/1ef150eb/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheStopCommand.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheStopCommand.scala b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheStopCommand.scala
index 1b55505..22fb89d 100644
--- a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheStopCommand.scala
+++ b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheStopCommand.scala
@@ -19,7 +19,6 @@ package org.apache.ignite.visor.commands.cache
import org.apache.ignite.cluster.{ClusterGroupEmptyException, ClusterNode}
import org.apache.ignite.visor.visor._
-
import org.apache.ignite.internal.visor.cache.VisorCacheStopTask
import org.apache.ignite.internal.visor.util.VisorTaskUtils._
@@ -102,7 +101,9 @@ class VisorCacheStopCommand {
return
}
- ask(s"Are you sure you want to stop cache: ${escapeName(cacheName)}? (y/n) [n]: ", "n") match {
+ val dflt = if (batchMode) "y" else "n"
+
+ ask(s"Are you sure you want to stop cache: ${escapeName(cacheName)}? (y/n) [$dflt]: ", dflt) match {
case "y" | "Y" =>
try {
executeRandom(grp, classOf[VisorCacheStopTask], cacheName)
[15/50] [abbrv] ignite git commit: IGNITE-3745: ODBC: Implemented
date/time/timestamp escape sequence parsing. This closes #991.
Posted by sb...@apache.org.
IGNITE-3745: ODBC: Implemented date/time/timestamp escape sequence parsing. This closes #991.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/92f18bf3
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/92f18bf3
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/92f18bf3
Branch: refs/heads/ignite-961
Commit: 92f18bf353cc8c3821c6500ce9f1cd397a7cf17c
Parents: 87a1928
Author: Andrey V. Mashenkov <an...@gmail.com>
Authored: Fri Aug 26 15:31:30 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Fri Aug 26 15:31:30 2016 +0300
----------------------------------------------------------------------
.../processors/odbc/escape/OdbcEscapeUtils.java | 30 ++-
.../odbc/OdbcEscapeSequenceSelfTest.java | 191 +++++++++++++++++--
2 files changed, 203 insertions(+), 18 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/92f18bf3/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/escape/OdbcEscapeUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/escape/OdbcEscapeUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/escape/OdbcEscapeUtils.java
index 83ec9d8..4c1deb6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/escape/OdbcEscapeUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/escape/OdbcEscapeUtils.java
@@ -26,10 +26,17 @@ import java.util.regex.Pattern;
* ODBC escape sequence parse.
*/
public class OdbcEscapeUtils {
+ /** Odbc date regexp pattern: '2016-08-23' */
+ private static final Pattern DATE_PATTERN = Pattern.compile("^'\\d{4}-\\d{2}-\\d{2}'$");
- /**
- * GUID regexp pattern: '12345678-9abc-def0-1234-123456789abc'
- */
+ /** Odbc time regexp pattern: '14:33:44' */
+ private static final Pattern TIME_PATTERN = Pattern.compile("^'\\d{2}:\\d{2}:\\d{2}'$");
+
+ /** Odbc timestamp regexp pattern: '2016-08-23 14:33:44.12345' */
+ private static final Pattern TIMESTAMP_PATTERN =
+ Pattern.compile("^'\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}(\\.\\d+)?'$");
+
+ /** GUID regexp pattern: '12345678-9abc-def0-1234-123456789abc' */
private static final Pattern GUID_PATTERN =
Pattern.compile("^'\\p{XDigit}{8}-\\p{XDigit}{4}-\\p{XDigit}{4}-\\p{XDigit}{4}-\\p{XDigit}{12}'$");
@@ -241,7 +248,16 @@ public class OdbcEscapeUtils {
return parseScalarExpression(text, startPos0, len0);
case GUID:
- return parseGuidExpression(text, startPos0, len0);
+ return parseExpression(text, startPos0, len0, token.type(), GUID_PATTERN);
+
+ case DATE:
+ return parseExpression(text, startPos0, len0, token.type(), DATE_PATTERN);
+
+ case TIME:
+ return parseExpression(text, startPos0, len0, token.type(), TIME_PATTERN);
+
+ case TIMESTAMP:
+ return parseExpression(text, startPos0, len0, token.type(), TIMESTAMP_PATTERN);
default:
throw new IgniteException("Unsupported escape sequence token [text=" +
@@ -269,11 +285,11 @@ public class OdbcEscapeUtils {
* @param len Length.
* @return Parsed expression.
*/
- private static String parseGuidExpression(String text, int startPos, int len) {
+ private static String parseExpression(String text, int startPos, int len, OdbcEscapeType type, Pattern pattern) {
String val = substring(text, startPos, len).trim();
- if (!GUID_PATTERN.matcher(val).matches())
- throw new IgniteException("Invalid GUID escape sequence: " + substring(text, startPos, len));
+ if (!pattern.matcher(val).matches())
+ throw new IgniteException("Invalid " + type + " escape sequence: " + substring(text, startPos, len));
return val;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/92f18bf3/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/OdbcEscapeSequenceSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/OdbcEscapeSequenceSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/OdbcEscapeSequenceSelfTest.java
index 7225c1a..1aa90fd 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/OdbcEscapeSequenceSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/OdbcEscapeSequenceSelfTest.java
@@ -142,12 +142,14 @@ public class OdbcEscapeSequenceSelfTest extends GridCommonAbstractTest {
* Test invalid escape sequence.
*/
public void testFailedOnInvalidFunctionSequence() {
+ checkFail("{fnfunc1()}");
+
checkFail("select {fn func1(field1, {fn func2(field2), field3)} from SomeTable;");
checkFail("select {fn func1(field1, fn func2(field2)}, field3)} from SomeTable;");
}
- /**
+ /**
* Test escape sequences with additional whitespace characters
*/
public void testFunctionEscapeSequenceWithWhitespaces() throws Exception {
@@ -155,7 +157,7 @@ public class OdbcEscapeSequenceSelfTest extends GridCommonAbstractTest {
check("func1()", "{ fn func1()}");
- check("func1()", "{ \n fn func1()}");
+ check("func1()", "{ \n fn\nfunc1()}");
checkFail("{ \n func1()}");
}
@@ -178,6 +180,21 @@ public class OdbcEscapeSequenceSelfTest extends GridCommonAbstractTest {
"select '12345678-9abc-def0-1234-123456789abc'",
"select {guid '12345678-9abc-def0-1234-123456789abc'}"
);
+ }
+
+ /**
+ * Test invalid escape sequence.
+ */
+ public void testFailedOnInvalidGuidSequence() {
+ checkFail("select {guid'12345678-9abc-def0-1234-123456789abc'}");
+
+ checkFail("select {guid 12345678-9abc-def0-1234-123456789abc'}");
+
+ checkFail("select {guid '12345678-9abc-def0-1234-123456789abc}");
+
+ checkFail("select {guid '12345678-9abc-def0-1234-123456789abc' from SomeTable;");
+
+ checkFail("select guid '12345678-9abc-def0-1234-123456789abc'} from SomeTable;");
checkFail("select {guid '1234567-1234-1234-1234-123456789abc'}");
@@ -191,15 +208,6 @@ public class OdbcEscapeSequenceSelfTest extends GridCommonAbstractTest {
}
/**
- * Test invalid escape sequence.
- */
- public void testFailedOnInvalidGuidSequence() {
- checkFail("select {guid '12345678-9abc-def0-1234-123456789abc' from SomeTable;");
-
- checkFail("select guid '12345678-9abc-def0-1234-123456789abc'} from SomeTable;");
- }
-
- /**
* Test escape sequences with additional whitespace characters
*/
public void testGuidEscapeSequenceWithWhitespaces() throws Exception {
@@ -220,6 +228,167 @@ public class OdbcEscapeSequenceSelfTest extends GridCommonAbstractTest {
}
/**
+ * Test date escape sequences
+ */
+ public void testDateEscapeSequence() throws Exception {
+ check(
+ "'2016-08-26'",
+ "{d '2016-08-26'}"
+ );
+
+ check(
+ "select '2016-08-26'",
+ "select {d '2016-08-26'}"
+ );
+
+ check(
+ "select '2016-08-26' from table;",
+ "select {d '2016-08-26'} from table;"
+ );
+ }
+
+ /**
+ * Test date escape sequences with additional whitespace characters
+ */
+ public void testDateEscapeSequenceWithWhitespaces() throws Exception {
+ check("'2016-08-26'", "{ d '2016-08-26'}");
+
+ check("'2016-08-26'", "{ d '2016-08-26'}");
+
+ check("'2016-08-26'", "{ \n d\n'2016-08-26'}");
+ }
+
+ /**
+ * Test invalid escape sequence.
+ */
+ public void testFailedOnInvalidDateSequence() {
+ checkFail("{d'2016-08-26'}");
+
+ checkFail("{d 2016-08-26'}");
+
+ checkFail("{d '2016-08-26}");
+
+ checkFail("{d '16-08-26'}");
+
+ checkFail("{d '2016/08/02'}");
+
+ checkFail("select {d '2016-08-26' from table;");
+
+ checkFail("select {}d '2016-08-26'} from table;");
+ }
+
+ /**
+ * Test date escape sequences
+ */
+ public void testTimeEscapeSequence() throws Exception {
+ check("'13:15:08'", "{t '13:15:08'}");
+
+ check("select '13:15:08'", "select {t '13:15:08'}");
+
+ check("select '13:15:08' from table;", "select {t '13:15:08'} from table;"
+ );
+ }
+
+ /**
+ * Test date escape sequences with additional whitespace characters
+ */
+ public void testTimeEscapeSequenceWithWhitespaces() throws Exception {
+ check("'13:15:08'", "{ t '13:15:08'}");
+
+ check("'13:15:08'", "{ t '13:15:08'}");
+
+ check("'13:15:08'", "{ \n t\n'13:15:08'}");
+ }
+
+ /**
+ * Test invalid escape sequence.
+ */
+ public void testFailedOnInvalidTimeSequence() {
+ checkFail("{t'13:15:08'}");
+
+ checkFail("{t 13:15:08'}");
+
+ checkFail("{t '13:15:08}");
+
+ checkFail("{t '13 15:08'}");
+
+ checkFail("{t '3:15:08'}");
+
+ checkFail("select {t '13:15:08' from table;");
+
+ checkFail("select {}t '13:15:08'} from table;");
+ }
+
+ /**
+ * Test timestamp escape sequences
+ */
+ public void testTimestampEscapeSequence() throws Exception {
+ check(
+ "'2016-08-26 13:15:08'",
+ "{ts '2016-08-26 13:15:08'}"
+ );
+
+ check(
+ "'2016-08-26 13:15:08.123456'",
+ "{ts '2016-08-26 13:15:08.123456'}"
+ );
+
+ check(
+ "select '2016-08-26 13:15:08'",
+ "select {ts '2016-08-26 13:15:08'}"
+ );
+
+ check(
+ "select '2016-08-26 13:15:08' from table;",
+ "select {ts '2016-08-26 13:15:08'} from table;"
+ );
+ }
+
+ /**
+ * Test timestamp escape sequences with additional whitespace characters
+ */
+ public void testTimestampEscapeSequenceWithWhitespaces() throws Exception {
+ check("'2016-08-26 13:15:08'",
+ "{ ts '2016-08-26 13:15:08'}"
+ );
+
+ check("'2016-08-26 13:15:08'",
+ "{ ts '2016-08-26 13:15:08'}"
+ );
+
+ check("'2016-08-26 13:15:08'",
+ "{ \n ts\n'2016-08-26 13:15:08'}"
+ );
+ }
+
+ /**
+ * Test invalid escape sequence.
+ */
+ public void testFailedOnInvalidTimestampSequence() {
+ checkFail("{ts '2016-08-26 13:15:08,12345'}");
+
+ checkFail("{ts'2016-08-26 13:15:08'}");
+
+ checkFail("{ts 2016-08-26 13:15:08'}");
+
+ checkFail("{ts '2016-08-26 13:15:08}");
+
+ checkFail("{ts '16-08-26 13:15:08'}");
+
+ checkFail("{ts '2016-08-26 3:25:08'}");
+
+ checkFail("{ts '2016-08 26 03:25:08'}");
+
+ checkFail("{ts '2016-08-26 03 25:08'}");
+
+ checkFail("{t s '2016-08-26 13:15:08''}");
+
+ checkFail("select {ts '2016-08-26 13:15:08' from table;");
+
+ checkFail("select {}ts '2016-08-26 13:15:08'} from table;");
+ }
+
+ /**
* Check parsing logic.
*
* @param exp Expected result.
[38/50] [abbrv] ignite git commit: IGNITE-3390: Added DSN
configuration window.
Posted by sb...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc/os/win/include/ignite/odbc/system/ui/custom_window.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/os/win/include/ignite/odbc/system/ui/custom_window.h b/modules/platforms/cpp/odbc/os/win/include/ignite/odbc/system/ui/custom_window.h
new file mode 100644
index 0000000..1502c07
--- /dev/null
+++ b/modules/platforms/cpp/odbc/os/win/include/ignite/odbc/system/ui/custom_window.h
@@ -0,0 +1,189 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_ODBC_SYSTEM_UI_CUSTOM_WINDOW
+#define _IGNITE_ODBC_SYSTEM_UI_CUSTOM_WINDOW
+
+#include "ignite/odbc/system/ui/window.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ namespace system
+ {
+ namespace ui
+ {
+ /**
+ * Application execution result.
+ */
+ enum Result
+ {
+ RESULT_OK,
+ RESULT_CANCEL
+ };
+
+ /**
+ * Process UI messages in current thread.
+ * Blocks until quit message has been received.
+ *
+ * @param window Main window.
+ * @return Application execution result.
+ */
+ Result ProcessMessages(Window& window);
+
+ /**
+ * Window class.
+ */
+ class CustomWindow : public Window
+ {
+ public:
+ /**
+ * Constructor.
+ *
+ * @param parent Parent window.
+ * @param className Window class name.
+ * @param title Window title.
+ * @param callback Event processing function.
+ */
+ CustomWindow(Window* parent, const char* className, const char* title);
+
+ /**
+ * Destructor.
+ */
+ virtual ~CustomWindow();
+
+ /**
+ * Callback which is called upon receiving new message.
+ * Pure virtual. Should be defined by user.
+ *
+ * @param msg Message.
+ * @param wParam Word-sized parameter.
+ * @param lParam Long parameter.
+ * @return Should return true if the message has been
+ * processed by the handler and false otherwise.
+ */
+ virtual bool OnMessage(UINT msg, WPARAM wParam, LPARAM lParam) = 0;
+
+ /**
+ * Callback that is called upon window creation.
+ */
+ virtual void OnCreate() = 0;
+
+ /**
+ * Create child group box window.
+ *
+ * @param posX Position by X coordinate.
+ * @param posY Position by Y coordinate.
+ * @param sizeX Size by X coordinate.
+ * @param sizeY Size by Y coordinate.
+ * @param title Title.
+ * @param id ID to be assigned to the created window.
+ * @return Auto pointer containing new window.
+ */
+ std::auto_ptr<Window> CreateGroupBox(int posX, int posY,
+ int sizeX, int sizeY, const char* title, int id);
+
+ /**
+ * Create child label window.
+ *
+ * @param posX Position by X coordinate.
+ * @param posY Position by Y coordinate.
+ * @param sizeX Size by X coordinate.
+ * @param sizeY Size by Y coordinate.
+ * @param title Title.
+ * @param id ID to be assigned to the created window.
+ * @return Auto pointer containing new window.
+ */
+ std::auto_ptr<Window> CreateLabel(int posX, int posY,
+ int sizeX, int sizeY, const char* title, int id);
+
+ /**
+ * Create child Edit window.
+ *
+ * @param posX Position by X coordinate.
+ * @param posY Position by Y coordinate.
+ * @param sizeX Size by X coordinate.
+ * @param sizeY Size by Y coordinate.
+ * @param title Title.
+ * @param id ID to be assigned to the created window.
+ * @return Auto pointer containing new window.
+ */
+ std::auto_ptr<Window> CreateEdit(int posX, int posY,
+ int sizeX, int sizeY, const char* title, int id, int style = 0);
+
+ /**
+ * Create child button window.
+ *
+ * @param posX Position by X coordinate.
+ * @param posY Position by Y coordinate.
+ * @param sizeX Size by X coordinate.
+ * @param sizeY Size by Y coordinate.
+ * @param title Title.
+ * @param id ID to be assigned to the created window.
+ * @return Auto pointer containing new window.
+ */
+ std::auto_ptr<Window> CreateButton(int posX, int posY,
+ int sizeX, int sizeY, const char* title, int id);
+
+ /**
+ * Create child CheckBox window.
+ *
+ * @param posX Position by X coordinate.
+ * @param posY Position by Y coordinate.
+ * @param sizeX Size by X coordinate.
+ * @param sizeY Size by Y coordinate.
+ * @param title Title.
+ * @param id ID to be assigned to the created window.
+ * @return Auto pointer containing new window.
+ */
+ std::auto_ptr<Window> CreateCheckBox(int posX, int posY,
+ int sizeX, int sizeY, const char* title, int id, bool state);
+
+ /**
+ * Create child ComboBox window.
+ *
+ * @param posX Position by X coordinate.
+ * @param posY Position by Y coordinate.
+ * @param sizeX Size by X coordinate.
+ * @param sizeY Size by Y coordinate.
+ * @param title Title.
+ * @param id ID to be assigned to the created window.
+ * @return Auto pointer containing new window.
+ */
+ std::auto_ptr<Window> CreateComboBox(int posX, int posY,
+ int sizeX, int sizeY, const char* title, int id);
+ private:
+ IGNITE_NO_COPY_ASSIGNMENT(CustomWindow)
+
+ /**
+ * Static callback.
+ *
+ * @param hwnd Window handle.
+ * @param msg Message.
+ * @param wParam Word-sized parameter.
+ * @param lParam Long parameter.
+ * @return Operation result.
+ */
+ static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
+ };
+ }
+ }
+ }
+}
+
+#endif //_IGNITE_ODBC_SYSTEM_UI_CUSTOM_WINDOW
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc/os/win/include/ignite/odbc/system/ui/window.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/os/win/include/ignite/odbc/system/ui/window.h b/modules/platforms/cpp/odbc/os/win/include/ignite/odbc/system/ui/window.h
new file mode 100644
index 0000000..32a54b2
--- /dev/null
+++ b/modules/platforms/cpp/odbc/os/win/include/ignite/odbc/system/ui/window.h
@@ -0,0 +1,201 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_ODBC_SYSTEM_UI_WINDOW
+#define _IGNITE_ODBC_SYSTEM_UI_WINDOW
+
+#include "ignite/odbc/utility.h"
+#include "ignite/odbc/system/odbc_constants.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ namespace system
+ {
+ namespace ui
+ {
+ /**
+ * Get handle for the current module.
+ *
+ * @return Handle for the current module.
+ */
+ HINSTANCE GetHInstance();
+
+ /**
+ * Window class.
+ */
+ class Window
+ {
+ public:
+ /**
+ * Constructor for a new window that is going to be created.
+ *
+ * @param parent Parent window handle.
+ * @param className Window class name.
+ * @param title Window title.
+ * @param callback Event processing function.
+ */
+ Window(Window* parent, const char* className, const char* title);
+
+ /**
+ * Constructor for the existing window.
+ *
+ * @param handle Window handle.
+ */
+ Window(HWND handle);
+
+ /**
+ * Destructor.
+ */
+ virtual ~Window();
+
+ /**
+ * Create window.
+ *
+ * @param style Window style.
+ * @param posX Window x position.
+ * @param posY Window y position.
+ * @param width Window width.
+ * @param height Window height.
+ * @param id ID for child window.
+ */
+ void Create(DWORD style, int posX, int posY, int width, int height, int id);
+
+ /**
+ * Show window.
+ */
+ void Show();
+
+ /**
+ * Update window.
+ */
+ void Update();
+
+ /**
+ * Destroy window.
+ */
+ void Destroy();
+
+ /**
+ * Get window handle.
+ *
+ * @return Window handle.
+ */
+ HWND GetHandle() const
+ {
+ return handle;
+ }
+
+ /**
+ * Get window text.
+ *
+ * @param text Text.
+ */
+ void GetText(std::string& text) const;
+
+ /**
+ * Set window text.
+ *
+ * @param text Text.
+ */
+ void SetText(const std::string& text) const;
+
+ /**
+ * Get CheckBox state.
+ *
+ * @param True if checked.
+ */
+ bool IsChecked() const;
+
+ /**
+ * Set CheckBox state.
+ *
+ * @param state True if checked.
+ */
+ void SetChecked(bool state);
+
+ /**
+ * Add string.
+ *
+ * @param str String.
+ */
+ void AddString(const std::string& str);
+
+ /**
+ * Set current ComboBox selection.
+ *
+ * @param idx List index.
+ */
+ void SetSelection(int idx);
+
+ /**
+ * Get current ComboBox selection.
+ *
+ * @return idx List index.
+ */
+ int GetSelection() const;
+
+ /**
+ * Set enabled.
+ *
+ * @param enabled Enable flag.
+ */
+ void SetEnabled(bool enabled);
+
+ /**
+ * Check if the window is enabled.
+ *
+ * @return True if enabled.
+ */
+ bool IsEnabled() const;
+
+ protected:
+ /**
+ * Set window handle.
+ *
+ * @param value Window handle.
+ */
+ void SetHandle(HWND value)
+ {
+ handle = value;
+ }
+
+ /** Window class name. */
+ std::string className;
+
+ /** Window title. */
+ std::string title;
+
+ /** Window handle. */
+ HWND handle;
+
+ /** Specifies whether window has been created by the thread and needs destruction. */
+ bool created;
+
+ /** Window parent. */
+ Window* parent;
+
+ private:
+ IGNITE_NO_COPY_ASSIGNMENT(Window)
+ };
+ }
+ }
+ }
+}
+
+#endif //_IGNITE_ODBC_SYSTEM_UI_WINDOW
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc/os/win/src/system/ui/custom_window.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/os/win/src/system/ui/custom_window.cpp b/modules/platforms/cpp/odbc/os/win/src/system/ui/custom_window.cpp
new file mode 100644
index 0000000..1e855a1
--- /dev/null
+++ b/modules/platforms/cpp/odbc/os/win/src/system/ui/custom_window.cpp
@@ -0,0 +1,184 @@
+/*
+ * 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.
+ */
+
+#include <Windowsx.h>
+
+#include "ignite/odbc/system/ui/custom_window.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ namespace system
+ {
+ namespace ui
+ {
+ Result ProcessMessages(Window& window)
+ {
+ MSG msg;
+
+ while (GetMessage(&msg, NULL, 0, 0) > 0)
+ {
+ if (!IsDialogMessage(window.GetHandle(), &msg))
+ {
+ TranslateMessage(&msg);
+
+ DispatchMessage(&msg);
+ }
+ }
+
+ return static_cast<Result>(msg.wParam);
+ }
+
+ LRESULT CALLBACK CustomWindow::WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+ {
+ CustomWindow* window = reinterpret_cast<CustomWindow*>(GetWindowLongPtr(hwnd, GWLP_USERDATA));
+
+ switch (msg)
+ {
+ case WM_NCCREATE:
+ {
+ _ASSERT(lParam != NULL);
+
+ CREATESTRUCT* createStruct = reinterpret_cast<CREATESTRUCT*>(lParam);
+
+ LONG_PTR longSelfPtr = reinterpret_cast<LONG_PTR>(createStruct->lpCreateParams);
+
+ SetWindowLongPtr(hwnd, GWLP_USERDATA, longSelfPtr);
+
+ return DefWindowProc(hwnd, msg, wParam, lParam);
+ }
+
+ case WM_CREATE:
+ {
+ _ASSERT(window != NULL);
+
+ window->SetHandle(hwnd);
+
+ window->OnCreate();
+
+ return 0;
+ }
+
+ default:
+ break;
+ }
+
+ if (window && window->OnMessage(msg, wParam, lParam))
+ return 0;
+
+ return DefWindowProc(hwnd, msg, wParam, lParam);
+ }
+
+ CustomWindow::CustomWindow(Window* parent, const char* className, const char* title) :
+ Window(parent, className, title)
+ {
+ WNDCLASS wcx;
+
+ wcx.style = CS_HREDRAW | CS_VREDRAW;
+ wcx.lpfnWndProc = WndProc;
+ wcx.cbClsExtra = 0;
+ wcx.cbWndExtra = 0;
+ wcx.hInstance = GetHInstance();
+ wcx.hIcon = NULL;
+ wcx.hCursor = LoadCursor(NULL, IDC_ARROW);
+ wcx.hbrBackground = (HBRUSH)COLOR_WINDOW;
+ wcx.lpszMenuName = NULL;
+ wcx.lpszClassName = className;
+
+
+ if (!RegisterClass(&wcx))
+ {
+ std::stringstream buf;
+
+ buf << "Can not register window class, error code: " << GetLastError();
+
+ throw IgniteError(IgniteError::IGNITE_ERR_GENERIC, buf.str().c_str());
+ }
+ }
+
+ CustomWindow::~CustomWindow()
+ {
+ UnregisterClass(className.c_str(), GetHInstance());
+ }
+
+ std::auto_ptr<Window> CustomWindow::CreateGroupBox(int posX, int posY,
+ int sizeX, int sizeY, const char* title, int id)
+ {
+ std::auto_ptr<Window> child(new Window(this, "Button", title));
+
+ child->Create(WS_CHILD | WS_VISIBLE | BS_GROUPBOX, posX, posY, sizeX, sizeY, id);
+
+ return child;
+ }
+
+ std::auto_ptr<Window> CustomWindow::CreateLabel(int posX, int posY,
+ int sizeX, int sizeY, const char* title, int id)
+ {
+ std::auto_ptr<Window> child(new Window(this, "Static", title));
+
+ child->Create(WS_CHILD | WS_VISIBLE, posX, posY, sizeX, sizeY, id);
+
+ return child;
+ }
+
+ std::auto_ptr<Window> CustomWindow::CreateEdit(int posX, int posY,
+ int sizeX, int sizeY, const char* title, int id, int style)
+ {
+ std::auto_ptr<Window> child(new Window(this, "Edit", title));
+
+ child->Create(WS_CHILD | WS_VISIBLE | WS_BORDER | ES_AUTOHSCROLL | WS_TABSTOP | style,
+ posX, posY, sizeX, sizeY, id);
+
+ return child;
+ }
+
+ std::auto_ptr<Window> CustomWindow::CreateButton(int posX, int posY,
+ int sizeX, int sizeY, const char* title, int id)
+ {
+ std::auto_ptr<Window> child(new Window(this, "Button", title));
+
+ child->Create(WS_CHILD | WS_VISIBLE | WS_TABSTOP, posX, posY, sizeX, sizeY, id);
+
+ return child;
+ }
+
+ std::auto_ptr<Window> CustomWindow::CreateCheckBox(int posX, int posY,
+ int sizeX, int sizeY, const char* title, int id, bool state)
+ {
+ std::auto_ptr<Window> child(new Window(this, "Button", title));
+
+ child->Create(WS_CHILD | WS_VISIBLE | BS_CHECKBOX, posX, posY, sizeX, sizeY, id);
+
+ child->SetChecked(state);
+
+ return child;
+ }
+
+ std::auto_ptr<Window> CustomWindow::CreateComboBox(int posX, int posY,
+ int sizeX, int sizeY, const char * title, int id)
+ {
+ std::auto_ptr<Window> child(new Window(this, "Combobox", title));
+
+ child->Create(WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST, posX, posY, sizeX, sizeY, id);
+
+ return child;
+ }
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc/os/win/src/system/ui/dsn_configuration_window.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/os/win/src/system/ui/dsn_configuration_window.cpp b/modules/platforms/cpp/odbc/os/win/src/system/ui/dsn_configuration_window.cpp
new file mode 100644
index 0000000..76132bd
--- /dev/null
+++ b/modules/platforms/cpp/odbc/os/win/src/system/ui/dsn_configuration_window.cpp
@@ -0,0 +1,212 @@
+/*
+ * 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.
+ */
+
+#include <Windowsx.h>
+
+#include "ignite/odbc/system/ui/dsn_configuration_window.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ namespace system
+ {
+ namespace ui
+ {
+ DsnConfigurationWindow::DsnConfigurationWindow(Window* parent, config::Configuration& config):
+ CustomWindow(parent, "IgniteConfigureDsn", "Configure Apache Ignite DSN"),
+ width(360),
+ height(160),
+ connectionSettingsGroupBox(),
+ nameLabel(),
+ nameEdit(),
+ addressLabel(),
+ addressEdit(),
+ cacheLabel(),
+ cacheEdit(),
+ okButton(),
+ cancelButton(),
+ config(config),
+ accepted(false)
+ {
+ // No-op.
+ }
+
+ DsnConfigurationWindow::~DsnConfigurationWindow()
+ {
+ // No-op.
+ }
+
+ void DsnConfigurationWindow::Create()
+ {
+ // Finding out parent position.
+ RECT parentRect;
+ GetWindowRect(parent->GetHandle(), &parentRect);
+
+ // Positioning window to the center of parent window.
+ const int posX = parentRect.left + (parentRect.right - parentRect.left - width) / 2;
+ const int posY = parentRect.top + (parentRect.bottom - parentRect.top - height) / 2;
+
+ RECT desiredRect = {posX, posY, posX + width, posY + height};
+ AdjustWindowRect(&desiredRect, WS_BORDER | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME, FALSE);
+
+ Window::Create(WS_OVERLAPPED | WS_SYSMENU, desiredRect.left, desiredRect.top,
+ desiredRect.right - desiredRect.left, desiredRect.bottom - desiredRect.top, 0);
+
+ if (!handle)
+ {
+ std::stringstream buf;
+
+ buf << "Can not create window, error code: " << GetLastError();
+
+ throw IgniteError(IgniteError::IGNITE_ERR_GENERIC, buf.str().c_str());
+ }
+ }
+
+ void DsnConfigurationWindow::OnCreate()
+ {
+ int margin = 10;
+ int interval = 10;
+
+ int labelSizeX = 80;
+ int labelPosX = margin + interval;
+
+ int editSizeX = width - labelSizeX - 2 * margin - 3 * interval;
+ int editPosX = margin + labelSizeX + 2 * interval;
+
+ int rowSize = 20;
+ int rowPos = margin + 2 * interval;
+
+ int checkBoxSize = (editSizeX - interval) / 2;
+
+ int sectionBegin = margin;
+
+ const char* val = config.GetDsn().c_str();
+ nameLabel = CreateLabel(labelPosX, rowPos, labelSizeX, rowSize, "DSN name:", ID_NAME_LABEL);
+ nameEdit = CreateEdit(editPosX, rowPos, editSizeX, rowSize, val, ID_NAME_EDIT);
+
+ rowPos += interval + rowSize;
+
+ val = config.GetAddress().c_str();
+ addressLabel = CreateLabel(labelPosX, rowPos, labelSizeX, rowSize, "Address:", ID_ADDRESS_LABEL);
+ addressEdit = CreateEdit(editPosX, rowPos, editSizeX, rowSize, val, ID_ADDRESS_EDIT);
+
+ rowPos += interval + rowSize;
+
+ val = config.GetCache().c_str();
+ cacheLabel = CreateLabel(labelPosX, rowPos, labelSizeX, rowSize, "Cache name:", ID_CACHE_LABEL);
+ cacheEdit = CreateEdit(editPosX, rowPos, editSizeX, rowSize, val, ID_CACHE_EDIT);
+
+ rowPos += interval * 2 + rowSize;
+
+ connectionSettingsGroupBox = CreateGroupBox(margin, sectionBegin, width - 2 * margin,
+ rowPos - interval - sectionBegin, "Connection settings", ID_CONNECTION_SETTINGS_GROUP_BOX);
+
+ int buttonSizeX = 80;
+ int cancelPosX = width - margin - buttonSizeX;
+ int okPosX = cancelPosX - interval - buttonSizeX;
+
+ rowSize = 25;
+
+ okButton = CreateButton(okPosX, rowPos, buttonSizeX, rowSize, "Ok", ID_OK_BUTTON);
+ cancelButton = CreateButton(cancelPosX, rowPos, buttonSizeX, rowSize, "Cancel", ID_CANCEL_BUTTON);
+ }
+
+ bool DsnConfigurationWindow::OnMessage(UINT msg, WPARAM wParam, LPARAM lParam)
+ {
+ switch (msg)
+ {
+ case WM_COMMAND:
+ {
+ switch (LOWORD(wParam))
+ {
+ case ID_OK_BUTTON:
+ {
+ try
+ {
+ RetrieveParameters(config);
+
+ accepted = true;
+
+ PostMessage(GetHandle(), WM_CLOSE, 0, 0);
+ }
+ catch (IgniteError& err)
+ {
+ MessageBox(NULL, err.GetText(), "Error!", MB_ICONEXCLAMATION | MB_OK);
+ }
+
+ break;
+ }
+
+ case IDCANCEL:
+ case ID_CANCEL_BUTTON:
+ {
+ PostMessage(GetHandle(), WM_CLOSE, 0, 0);
+
+ break;
+ }
+
+ default:
+ return false;
+ }
+
+ break;
+ }
+
+ case WM_DESTROY:
+ {
+ PostQuitMessage(accepted ? RESULT_OK : RESULT_CANCEL);
+
+ break;
+ }
+
+ default:
+ return false;
+ }
+
+ return true;
+ }
+
+ void DsnConfigurationWindow::RetrieveParameters(config::Configuration& cfg) const
+ {
+ std::string dsn;
+ std::string address;
+ std::string cache;
+
+ nameEdit->GetText(dsn);
+ addressEdit->GetText(address);
+ cacheEdit->GetText(cache);
+
+ common::StripSurroundingWhitespaces(address);
+ common::StripSurroundingWhitespaces(dsn);
+
+ LOG_MSG("Retriving arguments:\n");
+ LOG_MSG("DSN: %s\n", dsn.c_str());
+ LOG_MSG("Address: %s\n", address.c_str());
+ LOG_MSG("Cache: %s\n", cache.c_str());
+
+ if (dsn.empty())
+ throw IgniteError(IgniteError::IGNITE_ERR_GENERIC, "DSN name can not be empty.");
+
+ cfg.SetDsn(dsn);
+ cfg.SetAddress(address);
+ cfg.SetCache(cache);
+ }
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc/os/win/src/system/ui/window.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/os/win/src/system/ui/window.cpp b/modules/platforms/cpp/odbc/os/win/src/system/ui/window.cpp
new file mode 100644
index 0000000..1143f01
--- /dev/null
+++ b/modules/platforms/cpp/odbc/os/win/src/system/ui/window.cpp
@@ -0,0 +1,192 @@
+/*
+ * 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.
+ */
+
+#include <Windowsx.h>
+
+#include "ignite/odbc/system/ui/window.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ namespace system
+ {
+ namespace ui
+ {
+ HINSTANCE GetHInstance()
+ {
+ HINSTANCE hInstance = GetModuleHandle(TARGET_MODULE_FULL_NAME);
+
+ if (hInstance == NULL)
+ {
+ std::stringstream buf;
+
+ buf << "Can not get hInstance for the module, error code: " << GetLastError();
+
+ throw IgniteError(IgniteError::IGNITE_ERR_GENERIC, buf.str().c_str());
+ }
+
+ return hInstance;
+ }
+
+ Window::Window(Window* parent, const char* className, const char* title) :
+ className(className),
+ title(title),
+ handle(NULL),
+ created(false),
+ parent(parent)
+ {
+ // No-op.
+ }
+
+ Window::Window(HWND handle) :
+ className(),
+ title(),
+ handle(handle),
+ created(false),
+ parent(0)
+ {
+ // No-op.
+ }
+
+ Window::~Window()
+ {
+ if (created)
+ Destroy();
+ }
+
+ void Window::Create(DWORD style, int posX, int posY, int width, int height, int id)
+ {
+ if (handle)
+ {
+ std::stringstream buf;
+
+ buf << "Window already created, error code: " << GetLastError();
+
+ throw IgniteError(IgniteError::IGNITE_ERR_GENERIC, buf.str().c_str());
+ }
+
+ handle = CreateWindow(
+ className.c_str(),
+ title.c_str(),
+ style,
+ posX,
+ posY,
+ width,
+ height,
+ parent ? parent->GetHandle() : NULL,
+ reinterpret_cast<HMENU>(id),
+ GetHInstance(),
+ this
+ );
+
+ if (!handle)
+ {
+ std::stringstream buf;
+
+ buf << "Can not create window, error code: " << GetLastError();
+
+ throw IgniteError(IgniteError::IGNITE_ERR_GENERIC, buf.str().c_str());
+ }
+
+ created = true;
+
+ HGDIOBJ hfDefault = GetStockObject(DEFAULT_GUI_FONT);
+
+ SendMessage(GetHandle(), WM_SETFONT, (WPARAM)hfDefault, MAKELPARAM(FALSE, 0));
+ }
+
+ void Window::Show()
+ {
+ ShowWindow(handle, SW_SHOW);
+ }
+
+ void Window::Update()
+ {
+ UpdateWindow(handle);
+ }
+
+ void Window::Destroy()
+ {
+ if (handle)
+ DestroyWindow(handle);
+
+ handle = NULL;
+ }
+
+ void Window::GetText(std::string& text) const
+ {
+ int len = GetWindowTextLength(handle);
+
+ if (len <= 0)
+ {
+ text.clear();
+
+ return;
+ }
+
+ text.resize(len + 1);
+
+ if (!GetWindowText(handle, &text[0], len + 1))
+ text.clear();
+
+ text.resize(len);
+ }
+
+ void Window::SetText(const std::string& text) const
+ {
+ SNDMSG(handle, WM_SETTEXT, 0, reinterpret_cast<LPARAM>(text.c_str()));
+ }
+
+ bool Window::IsChecked() const
+ {
+ return Button_GetCheck(handle) == BST_CHECKED;
+ }
+
+ void Window::SetChecked(bool state)
+ {
+ Button_SetCheck(handle, state ? BST_CHECKED : BST_UNCHECKED);
+ }
+
+ void Window::AddString(const std::string & str)
+ {
+ SNDMSG(handle, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(str.c_str()));
+ }
+
+ void Window::SetSelection(int idx)
+ {
+ SNDMSG(handle, CB_SETCURSEL, static_cast<WPARAM>(idx), 0);
+ }
+
+ int Window::GetSelection() const
+ {
+ return static_cast<int>(SNDMSG(handle, CB_GETCURSEL, 0, 0));
+ }
+
+ void Window::SetEnabled(bool enabled)
+ {
+ EnableWindow(GetHandle(), enabled);
+ }
+
+ bool Window::IsEnabled() const
+ {
+ return IsWindowEnabled(GetHandle()) != 0;
+ }
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc/os/win/src/system_dsn.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/os/win/src/system_dsn.cpp b/modules/platforms/cpp/odbc/os/win/src/system_dsn.cpp
new file mode 100644
index 0000000..f432a40
--- /dev/null
+++ b/modules/platforms/cpp/odbc/os/win/src/system_dsn.cpp
@@ -0,0 +1,218 @@
+/*
+ * 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.
+ */
+
+#include "ignite/odbc/utility.h"
+#include "ignite/odbc/system/odbc_constants.h"
+
+#include "ignite/odbc/dsn_config.h"
+#include "ignite/odbc/system/ui/window.h"
+#include "ignite/odbc/system/ui/dsn_configuration_window.h"
+
+using ignite::odbc::config::Configuration;
+
+/**
+ * Display configuration window for user to configure DSN.
+ *
+ * @param hwndParent Parent window handle.
+ * @param config Output configuration.
+ * @return True on success and false on fail.
+ */
+bool DisplayConfigureDsnWindow(HWND hwndParent, Configuration& config)
+{
+ using namespace ignite::odbc::system::ui;
+
+ if (!hwndParent)
+ return false;
+
+ try
+ {
+ Window parent(hwndParent);
+
+ DsnConfigurationWindow window(&parent, config);
+
+ window.Create();
+
+ window.Show();
+ window.Update();
+
+ return ProcessMessages(window) == RESULT_OK;
+ }
+ catch (const ignite::IgniteError& err)
+ {
+ std::stringstream buf;
+
+ buf << "Message: " << err.GetText() << ", Code: " << err.GetCode();
+
+ std::string message = buf.str();
+
+ MessageBox(NULL, message.c_str(), "Error!", MB_ICONEXCLAMATION | MB_OK);
+
+ SQLPostInstallerError(err.GetCode(), err.GetText());
+ }
+
+ return false;
+}
+
+/**
+ * Register DSN with specified configuration.
+ *
+ * @param config Configuration.
+ * @param driver Driver.
+ * @return True on success and false on fail.
+ */
+bool RegisterDsn(const Configuration& config, LPCSTR driver)
+{
+ using namespace ignite::odbc::config;
+ using ignite::common::LexicalCast;
+
+ typedef Configuration::ArgumentMap ArgMap;
+
+ const char* dsn = config.GetDsn().c_str();
+
+ try
+ {
+ if (!SQLWriteDSNToIni(dsn, driver))
+ ignite::odbc::ThrowLastSetupError();
+
+ const ArgMap& map = config.GetMap();
+
+ std::set<std::string> ignore;
+
+ ignore.insert(Configuration::Key::dsn);
+ ignore.insert(Configuration::Key::driver);
+
+ for (ArgMap::const_iterator it = map.begin(); it != map.end(); ++it)
+ {
+ const std::string& key = it->first;
+ const std::string& value = it->second;
+
+ if (ignore.find(key) != ignore.end())
+ continue;
+
+ ignite::odbc::WriteDsnString(dsn, key.c_str(), value.c_str());
+ }
+
+ return true;
+ }
+ catch (ignite::IgniteError& err)
+ {
+ MessageBox(NULL, err.GetText(), "Error!", MB_ICONEXCLAMATION | MB_OK);
+
+ SQLPostInstallerError(err.GetCode(), err.GetText());
+ }
+
+ return false;
+}
+
+/**
+ * Unregister specified DSN.
+ *
+ * @param dsn DSN name.
+ * @return True on success and false on fail.
+ */
+bool UnregisterDsn(const char* dsn)
+{
+ try
+ {
+ if (!SQLRemoveDSNFromIni(dsn))
+ ignite::odbc::ThrowLastSetupError();
+
+ return true;
+ }
+ catch (ignite::IgniteError& err)
+ {
+ MessageBox(NULL, err.GetText(), "Error!", MB_ICONEXCLAMATION | MB_OK);
+
+ SQLPostInstallerError(err.GetCode(), err.GetText());
+ }
+
+ return false;
+}
+
+BOOL INSTAPI ConfigDSN(HWND hwndParent, WORD req, LPCSTR driver, LPCSTR attributes)
+{
+ using namespace ignite::odbc;
+
+ LOG_MSG("ConfigDSN called\n");
+
+ Configuration config;
+
+ LOG_MSG("Attributes: %s\n", attributes);
+
+ config.FillFromConfigAttributes(attributes);
+
+ if (!SQLValidDSN(config.GetDsn().c_str()))
+ return FALSE;
+
+ LOG_MSG("Driver: %s\n", driver);
+ LOG_MSG("Attributes: %s\n", attributes);
+
+ LOG_MSG("DSN: %s\n", config.GetDsn().c_str());
+
+ switch (req)
+ {
+ case ODBC_ADD_DSN:
+ {
+ LOG_MSG("ODBC_ADD_DSN\n");
+
+ if (!DisplayConfigureDsnWindow(hwndParent, config))
+ return FALSE;
+
+ if (!RegisterDsn(config, driver))
+ return FALSE;
+
+ break;
+ }
+
+ case ODBC_CONFIG_DSN:
+ {
+ LOG_MSG("ODBC_CONFIG_DSN\n");
+
+ std::string dsn = config.GetDsn();
+
+ Configuration loaded(config);
+
+ ReadDsnConfiguration(dsn.c_str(), loaded);
+
+ if (!DisplayConfigureDsnWindow(hwndParent, loaded))
+ return FALSE;
+
+ if (!RegisterDsn(loaded, driver))
+ return FALSE;
+
+ if (loaded.GetDsn() != dsn && !UnregisterDsn(dsn.c_str()))
+ return FALSE;
+
+ break;
+ }
+
+ case ODBC_REMOVE_DSN:
+ {
+ LOG_MSG("ODBC_REMOVE_DSN\n");
+
+ if (!UnregisterDsn(config.GetDsn().c_str()))
+ return FALSE;
+
+ break;
+ }
+
+ default:
+ return FALSE;
+ }
+
+ return TRUE;
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj b/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj
index 5820030..348a11a 100644
--- a/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj
+++ b/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj
@@ -93,8 +93,8 @@
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>false</SDLCheck>
- <AdditionalIncludeDirectories>$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\..\binary\include;$(ProjectDir)\..\..\..\binary\os\win\include;$(ProjectDir)\..\..\include;$(ProjectDir)\..\..\os\win;$(ProjectDir)\..\..\src</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;IGNITE_IMPL;IGNITE_FRIEND;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\..\binary\include;$(ProjectDir)\..\..\..\binary\os\win\include;$(ProjectDir)\..\..\include;$(ProjectDir)\..\..\os\win\include;$(ProjectDir)\..\..\src</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;IGNITE_IMPL;IGNITE_FRIEND;TARGET_MODULE_FULL_NAME="$(TargetFileName)";_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -107,8 +107,8 @@
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>false</SDLCheck>
- <AdditionalIncludeDirectories>$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\..\binary\include;$(ProjectDir)\..\..\..\binary\os\win\include;$(ProjectDir)\..\..\include;$(ProjectDir)\..\..\os\win;$(ProjectDir)\..\..\src</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;IGNITE_IMPL;IGNITE_FRIEND;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\..\binary\include;$(ProjectDir)\..\..\..\binary\os\win\include;$(ProjectDir)\..\..\include;$(ProjectDir)\..\..\os\win\include;$(ProjectDir)\..\..\src</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;IGNITE_IMPL;IGNITE_FRIEND;TARGET_MODULE_FULL_NAME="$(TargetFileName)";_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -123,8 +123,8 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>false</SDLCheck>
- <AdditionalIncludeDirectories>$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\..\binary\include;$(ProjectDir)\..\..\..\binary\os\win\include;$(ProjectDir)\..\..\include;$(ProjectDir)\..\..\os\win;$(ProjectDir)\..\..\src</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;IGNITE_IMPL;IGNITE_FRIEND;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\..\binary\include;$(ProjectDir)\..\..\..\binary\os\win\include;$(ProjectDir)\..\..\include;$(ProjectDir)\..\..\os\win\include;$(ProjectDir)\..\..\src</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;IGNITE_IMPL;IGNITE_FRIEND;TARGET_MODULE_FULL_NAME="$(TargetFileName)";%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -141,8 +141,8 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>false</SDLCheck>
- <AdditionalIncludeDirectories>$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\..\binary\include;$(ProjectDir)\..\..\..\binary\os\win\include;$(ProjectDir)\..\..\include;$(ProjectDir)\..\..\os\win;$(ProjectDir)\..\..\src</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;IGNITE_IMPL;IGNITE_FRIEND;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\..\binary\include;$(ProjectDir)\..\..\..\binary\os\win\include;$(ProjectDir)\..\..\include;$(ProjectDir)\..\..\os\win\include;$(ProjectDir)\..\..\src</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;IGNITE_IMPL;IGNITE_FRIEND;TARGET_MODULE_FULL_NAME="$(TargetFileName)";%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -153,7 +153,11 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
+ <ClCompile Include="..\..\os\win\src\system_dsn.cpp" />
<ClCompile Include="..\..\os\win\src\system\socket_client.cpp" />
+ <ClCompile Include="..\..\os\win\src\system\ui\custom_window.cpp" />
+ <ClCompile Include="..\..\os\win\src\system\ui\dsn_configuration_window.cpp" />
+ <ClCompile Include="..\..\os\win\src\system\ui\window.cpp" />
<ClCompile Include="..\..\src\app\application_data_buffer.cpp" />
<ClCompile Include="..\..\src\app\parameter.cpp" />
<ClCompile Include="..\..\src\column.cpp" />
@@ -165,11 +169,13 @@
<ClCompile Include="..\..\src\diagnostic\diagnosable_adapter.cpp" />
<ClCompile Include="..\..\src\diagnostic\diagnostic_record.cpp" />
<ClCompile Include="..\..\src\diagnostic\diagnostic_record_storage.cpp" />
+ <ClCompile Include="..\..\src\dsn_config.cpp" />
<ClCompile Include="..\..\src\entry_points.cpp" />
<ClCompile Include="..\..\src\environment.cpp" />
<ClCompile Include="..\..\src\meta\column_meta.cpp" />
<ClCompile Include="..\..\src\meta\table_meta.cpp" />
<ClCompile Include="..\..\src\odbc.cpp" />
+ <ClCompile Include="..\..\src\protocol_version.cpp" />
<ClCompile Include="..\..\src\query\data_query.cpp" />
<ClCompile Include="..\..\src\query\column_metadata_query.cpp" />
<ClCompile Include="..\..\src\query\foreign_keys_query.cpp" />
@@ -200,12 +206,14 @@
<ClInclude Include="..\..\include\ignite\odbc\diagnostic\diagnosable_adapter.h" />
<ClInclude Include="..\..\include\ignite\odbc\diagnostic\diagnostic_record.h" />
<ClInclude Include="..\..\include\ignite\odbc\diagnostic\diagnostic_record_storage.h" />
+ <ClInclude Include="..\..\include\ignite\odbc\dsn_config.h" />
<ClInclude Include="..\..\include\ignite\odbc\environment.h" />
<ClInclude Include="..\..\include\ignite\odbc\message.h" />
<ClInclude Include="..\..\include\ignite\odbc\meta\column_meta.h" />
<ClInclude Include="..\..\include\ignite\odbc\meta\primary_key_meta.h" />
<ClInclude Include="..\..\include\ignite\odbc\meta\table_meta.h" />
<ClInclude Include="..\..\include\ignite\odbc\parser.h" />
+ <ClInclude Include="..\..\include\ignite\odbc\protocol_version.h" />
<ClInclude Include="..\..\include\ignite\odbc\query\data_query.h" />
<ClInclude Include="..\..\include\ignite\odbc\query\column_metadata_query.h" />
<ClInclude Include="..\..\include\ignite\odbc\query\foreign_keys_query.h" />
@@ -219,8 +227,11 @@
<ClInclude Include="..\..\include\ignite\odbc\statement.h" />
<ClInclude Include="..\..\include\ignite\odbc\system\odbc_constants.h" />
<ClInclude Include="..\..\include\ignite\odbc\system\socket_client.h" />
+ <ClInclude Include="..\..\include\ignite\odbc\system\ui\dsn_configuration_window.h" />
<ClInclude Include="..\..\include\ignite\odbc\type_traits.h" />
<ClInclude Include="..\..\include\ignite\odbc\utility.h" />
+ <ClInclude Include="..\..\os\win\include\ignite\odbc\system\ui\custom_window.h" />
+ <ClInclude Include="..\..\os\win\include\ignite\odbc\system\ui\window.h" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\binary\project\vs\binary.vcxproj">
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj.filters
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj.filters b/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj.filters
index 6ca58e2..58764e4 100644
--- a/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj.filters
+++ b/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj.filters
@@ -26,6 +26,9 @@
<Filter Include="Code\diagnostic">
<UniqueIdentifier>{df33e506-b5d8-423f-bcc5-1825242a3e28}</UniqueIdentifier>
</Filter>
+ <Filter Include="Code\system\ui">
+ <UniqueIdentifier>{ff144e89-0a10-42c3-97dd-d22bfdbc7abb}</UniqueIdentifier>
+ </Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\src\odbc.cpp">
@@ -115,6 +118,24 @@
<ClCompile Include="..\..\src\entry_points.cpp">
<Filter>Code</Filter>
</ClCompile>
+ <ClCompile Include="..\..\os\win\src\system\ui\window.cpp">
+ <Filter>Code\system\ui</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\os\win\src\system\ui\custom_window.cpp">
+ <Filter>Code\system\ui</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\os\win\src\system\ui\dsn_configuration_window.cpp">
+ <Filter>Code\system\ui</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\os\win\src\system_dsn.cpp">
+ <Filter>Code\system</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\dsn_config.cpp">
+ <Filter>Code</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\protocol_version.cpp">
+ <Filter>Code</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="module.def">
@@ -224,5 +245,20 @@
<ClInclude Include="..\..\include\ignite\odbc.h">
<Filter>Code</Filter>
</ClInclude>
+ <ClInclude Include="..\..\os\win\include\ignite\odbc\system\ui\window.h">
+ <Filter>Code\system\ui</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\os\win\include\ignite\odbc\system\ui\custom_window.h">
+ <Filter>Code\system\ui</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\ignite\odbc\system\ui\dsn_configuration_window.h">
+ <Filter>Code\system\ui</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\ignite\odbc\dsn_config.h">
+ <Filter>Code</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\ignite\odbc\protocol_version.h">
+ <Filter>Code</Filter>
+ </ClInclude>
</ItemGroup>
</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc/src/config/configuration.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/config/configuration.cpp b/modules/platforms/cpp/odbc/src/config/configuration.cpp
index 8d57dee..f40c74f 100644
--- a/modules/platforms/cpp/odbc/src/config/configuration.cpp
+++ b/modules/platforms/cpp/odbc/src/config/configuration.cpp
@@ -15,13 +15,14 @@
* limitations under the License.
*/
-#include <cstring>
-
#include <string>
#include <sstream>
#include <algorithm>
#include <iterator>
+#include "ignite/common/common.h"
+#include "ignite/common/utils.h"
+
#include "ignite/odbc/utility.h"
#include "ignite/odbc/config/configuration.h"
@@ -31,50 +32,29 @@ namespace ignite
{
namespace config
{
- /** Default values for configuration. */
- namespace dflt
- {
- /** Default value for DSN attribute. */
- const std::string dsn = "Default Apache Ignite DSN";
+ const std::string Configuration::Key::dsn = "dsn";
+ const std::string Configuration::Key::driver = "driver";
+ const std::string Configuration::Key::cache = "cache";
+ const std::string Configuration::Key::address = "address";
+ const std::string Configuration::Key::server = "server";
+ const std::string Configuration::Key::port = "port";
+ const std::string Configuration::Key::protocolVersion = "protocol_version";
- /** Default value for Driver attribute. */
- const std::string driver = "Apache Ignite";
+ const std::string Configuration::DefaultValue::dsn = "Apache Ignite DSN";
+ const std::string Configuration::DefaultValue::driver = "Apache Ignite";
+ const std::string Configuration::DefaultValue::cache = "";
+ const std::string Configuration::DefaultValue::address = "";
+ const std::string Configuration::DefaultValue::server = "";
- /** Default value for host attribute. */
- const std::string host = "localhost";
+ const uint16_t Configuration::DefaultValue::port = 10800;
- /** Default value for port attribute. */
- const uint16_t port = 10800;
+ const ProtocolVersion& Configuration::DefaultValue::protocolVersion = ProtocolVersion::GetCurrent();
- /** Default value for cache attribute. */
- const std::string cache = "";
- }
-
- /** Connection attribute keywords. */
- namespace attrkey
- {
- /** Connection attribute keyword for DSN attribute. */
- const std::string dsn = "dsn";
-
- /** Connection attribute keyword for Driver attribute. */
- const std::string driver = "driver";
-
- /** Connection attribute keyword for server host attribute. */
- const std::string host = "server";
-
- /** Connection attribute keyword for server port attribute. */
- const std::string port = "port";
-
- /** Connection attribute keyword for cache attribute. */
- const std::string cache = "cache";
- }
Configuration::Configuration() :
- dsn(dflt::dsn), driver(dflt::driver),
- host(dflt::host), port(dflt::port),
- cache(dflt::cache)
+ arguments()
{
- // No-op.
+ ParseAddress(DefaultValue::address, endPoint);
}
Configuration::~Configuration()
@@ -84,7 +64,11 @@ namespace ignite
void Configuration::FillFromConnectString(const char* str, size_t len)
{
- ArgumentMap connect_attributes;
+ // Initializing map.
+ arguments.clear();
+
+ // Initializing DSN to empty string.
+ arguments[Key::dsn].clear();
// Ignoring terminating zero byte if present.
// Some Driver Managers pass zero-terminated connection string
@@ -92,39 +76,19 @@ namespace ignite
if (len && !str[len - 1])
--len;
- ParseAttributeList(str, len, ';', connect_attributes);
-
- ArgumentMap::const_iterator it;
-
- it = connect_attributes.find(attrkey::dsn);
- if (it != connect_attributes.end())
- dsn = it->second;
- else
- dsn.clear();
-
- it = connect_attributes.find(attrkey::driver);
- if (it != connect_attributes.end())
- driver = it->second;
- else
- driver = dflt::driver;
-
- it = connect_attributes.find(attrkey::host);
- if (it != connect_attributes.end())
- host = it->second;
- else
- host = dflt::host;
-
- it = connect_attributes.find(attrkey::port);
- if (it != connect_attributes.end())
- port = atoi(it->second.c_str());
- else
- port = dflt::port;
+ ParseAttributeList(str, len, ';', arguments);
- it = connect_attributes.find(attrkey::cache);
- if (it != connect_attributes.end())
- cache = it->second;
+ ArgumentMap::const_iterator it = arguments.find(Key::address);
+ if (it != arguments.end())
+ {
+ // Parsing address.
+ ParseAddress(it->second, endPoint);
+ }
else
- cache = dflt::cache;
+ {
+ endPoint.host = GetStringValue(Key::server, DefaultValue::server);
+ endPoint.port = static_cast<uint16_t>(GetIntValue(Key::port, DefaultValue::port));
+ }
}
void Configuration::FillFromConnectString(const std::string& str)
@@ -136,27 +100,27 @@ namespace ignite
{
std::stringstream connect_string_buffer;
- if (!driver.empty())
- connect_string_buffer << attrkey::driver << "={" << driver << "};";
-
- if (!host.empty())
- connect_string_buffer << attrkey::host << '=' << host << ';';
-
- if (port)
- connect_string_buffer << attrkey::port << '=' << port << ';';
+ for (ArgumentMap::const_iterator it = arguments.begin(); it != arguments.end(); ++it)
+ {
+ const std::string& key = it->first;
+ const std::string& value = it->second;
- if (!dsn.empty())
- connect_string_buffer << attrkey::dsn << '=' << dsn << ';';
+ if (value.empty())
+ continue;
- if (!cache.empty())
- connect_string_buffer << attrkey::cache << '=' << cache << ';';
+ if (value.find(' ') == std::string::npos)
+ connect_string_buffer << key << '=' << value << ';';
+ else
+ connect_string_buffer << key << "={" << value << "};";
+ }
return connect_string_buffer.str();
}
- void Configuration::FillFromConfigAttributes(const char * attributes)
+ void Configuration::FillFromConfigAttributes(const char* attributes)
{
- ArgumentMap config_attributes;
+ // Initializing map.
+ arguments.clear();
size_t len = 0;
@@ -166,45 +130,74 @@ namespace ignite
++len;
- ParseAttributeList(attributes, len, '\0', config_attributes);
-
- ArgumentMap::const_iterator it;
+ ParseAttributeList(attributes, len, '\0', arguments);
- it = config_attributes.find(attrkey::dsn);
- if (it != config_attributes.end())
- dsn = it->second;
+ ArgumentMap::const_iterator it = arguments.find(Key::address);
+ if (it != arguments.end())
+ {
+ // Parsing address.
+ ParseAddress(it->second, endPoint);
+ }
else
- dsn = dflt::dsn;
+ {
+ endPoint.host = GetStringValue(Key::server, DefaultValue::server);
+ endPoint.port = static_cast<uint16_t>(GetIntValue(Key::port, DefaultValue::port));
+ }
+ }
- it = config_attributes.find(attrkey::driver);
- if (it != config_attributes.end())
- driver = it->second;
- else
- driver.clear();
+ void Configuration::SetTcpPort(uint16_t port)
+ {
+ arguments[Key::port] = common::LexicalCast<std::string>(port);
+ }
- it = config_attributes.find(attrkey::host);
- if (it != config_attributes.end())
- host = it->second;
- else
- host.clear();
+ ProtocolVersion Configuration::GetProtocolVersion() const
+ {
+ ArgumentMap::const_iterator it = arguments.find(Key::protocolVersion);
- it = config_attributes.find(attrkey::port);
- if (it != config_attributes.end())
- port = atoi(it->second.c_str());
- else
- port = 0;
+ if (it != arguments.end())
+ return ProtocolVersion::FromString(it->second);
- it = config_attributes.find(attrkey::cache);
- if (it != config_attributes.end())
- cache = it->second;
- else
- cache.clear();
+ return DefaultValue::protocolVersion;
+ }
+
+ void Configuration::SetProtocolVersion(const std::string& version)
+ {
+ arguments[Key::protocolVersion] = version;
+ }
+
+ const std::string& Configuration::GetStringValue(const std::string& key, const std::string& dflt) const
+ {
+ ArgumentMap::const_iterator it = arguments.find(common::ToLower(key));
+
+ if (it != arguments.end())
+ return it->second;
+
+ return dflt;
}
- void Configuration::ParseAttributeList(const char * str, size_t len, char delimeter, ArgumentMap & args) const
+ int64_t Configuration::GetIntValue(const std::string& key, int64_t dflt) const
+ {
+ ArgumentMap::const_iterator it = arguments.find(common::ToLower(key));
+
+ if (it != arguments.end())
+ {
+ const std::string& val = it->second;
+
+ if (!common::AllOf(val.begin(), val.end(), isdigit))
+ IGNITE_ERROR_FORMATTED_1(IgniteError::IGNITE_ERR_GENERIC,
+ "Invalid argument value: Integer value is expected.", "key", key);
+
+ return common::LexicalCast<int64_t>(val);
+ }
+
+ return dflt;
+ }
+
+
+
+ void Configuration::ParseAttributeList(const char * str, size_t len, char delimeter, ArgumentMap & args)
{
std::string connect_str(str, len);
- args.clear();
while (!connect_str.empty())
{
@@ -245,6 +238,51 @@ namespace ignite
connect_str.erase(attr_begin - 1);
}
}
+
+ void Configuration::ParseAddress(const std::string& address, EndPoint& res)
+ {
+ int64_t colonNum = std::count(address.begin(), address.end(), ':');
+
+ if (colonNum == 0)
+ {
+ res.host = address;
+ res.port = DefaultValue::port;
+ }
+ else if (colonNum == 1)
+ {
+ size_t pos = address.find(':');
+
+ if (pos == address.size() - 1)
+ throw IgniteError(IgniteError::IGNITE_ERR_GENERIC,
+ "Invalid address format: no port after colon");
+
+ res.host = address.substr(0, pos);
+
+ std::string port = address.substr(pos + 1);
+
+ if (!common::AllOf(port.begin(), port.end(), isdigit))
+ throw IgniteError(IgniteError::IGNITE_ERR_GENERIC,
+ "Invalid address format: port can only contain digits");
+
+ int32_t intPort = common::LexicalCast<int32_t>(port);
+
+ if (port.size() > sizeof("65535") - 1 || intPort > UINT16_MAX)
+ {
+ throw IgniteError(IgniteError::IGNITE_ERR_GENERIC,
+ "Invalid address format: Port value is too large,"
+ " valid value should be in range from 1 to 65535");
+ }
+
+ if (intPort == 0)
+ throw IgniteError(IgniteError::IGNITE_ERR_GENERIC,
+ "Invalid address format: Port value can not be zero");
+
+ res.port = static_cast<uint16_t>(intPort);
+ }
+ else
+ throw IgniteError(IgniteError::IGNITE_ERR_GENERIC,
+ "Invalid address format: too many colons");
+ }
}
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc/src/connection.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/connection.cpp b/modules/platforms/cpp/odbc/src/connection.cpp
index 2441759..cffecdf 100644
--- a/modules/platforms/cpp/odbc/src/connection.cpp
+++ b/modules/platforms/cpp/odbc/src/connection.cpp
@@ -39,9 +39,11 @@ namespace ignite
{
namespace odbc
{
- const std::string Connection::PROTOCOL_VERSION_SINCE = "1.6.0";
-
- Connection::Connection() : socket(), connected(false), cache(), parser()
+ Connection::Connection() :
+ socket(),
+ connected(false),
+ parser(),
+ config()
{
// No-op.
}
@@ -53,8 +55,8 @@ namespace ignite
const config::ConnectionInfo& Connection::GetInfo() const
{
- // Connection info is the same for all connections now.
- static config::ConnectionInfo info;
+ // Connection info is constant and the same for all connections now.
+ const static config::ConnectionInfo info;
return info;
}
@@ -76,32 +78,38 @@ namespace ignite
return res;
}
- void Connection::Establish(const std::string& server)
+ void Connection::Establish(const std::string& connectStr)
{
- IGNITE_ODBC_API_CALL(InternalEstablish(server));
+ IGNITE_ODBC_API_CALL(InternalEstablish(connectStr));
}
- SqlResult Connection::InternalEstablish(const std::string& server)
+ SqlResult Connection::InternalEstablish(const std::string& connectStr)
{
config::Configuration config;
- if (server != config.GetDsn())
+ try
{
- AddStatusRecord(SQL_STATE_HY000_GENERAL_ERROR, "Unknown server.");
+ config.FillFromConnectString(connectStr);
+ }
+ catch (IgniteError& e)
+ {
+ AddStatusRecord(SQL_STATE_HY000_GENERAL_ERROR, e.GetText());
return SQL_RESULT_ERROR;
}
- return InternalEstablish(config.GetHost(), config.GetPort(), config.GetCache());
+ return InternalEstablish(config);
}
- void Connection::Establish(const std::string& host, uint16_t port, const std::string& cache)
+ void Connection::Establish(const config::Configuration cfg)
{
- IGNITE_ODBC_API_CALL(InternalEstablish(host, port, cache));
+ IGNITE_ODBC_API_CALL(InternalEstablish(cfg));
}
- SqlResult Connection::InternalEstablish(const std::string & host, uint16_t port, const std::string & cache)
+ SqlResult Connection::InternalEstablish(const config::Configuration cfg)
{
+ config = cfg;
+
if (connected)
{
AddStatusRecord(SQL_STATE_08002_ALREADY_CONNECTED, "Already connected.");
@@ -109,9 +117,7 @@ namespace ignite
return SQL_RESULT_ERROR;
}
- this->cache = cache;
-
- connected = socket.Connect(host.c_str(), port);
+ connected = socket.Connect(cfg.GetHost().c_str(), cfg.GetTcpPort());
if (!connected)
{
@@ -262,11 +268,16 @@ namespace ignite
const std::string& Connection::GetCache() const
{
- return cache;
+ return config.GetCache();
+ }
+
+ const config::Configuration& Connection::GetConfiguration() const
+ {
+ return config;
}
diagnostic::DiagnosticRecord Connection::CreateStatusRecord(SqlState sqlState,
- const std::string& message, int32_t rowNum, int32_t columnNum) const
+ const std::string& message, int32_t rowNum, int32_t columnNum)
{
return diagnostic::DiagnosticRecord(sqlState, message, "", "", rowNum, columnNum);
}
@@ -296,7 +307,20 @@ namespace ignite
SqlResult Connection::MakeRequestHandshake()
{
- HandshakeRequest req(PROTOCOL_VERSION);
+ int64_t protocolVersion = 0;
+
+ try
+ {
+ protocolVersion = config.GetProtocolVersion().GetIntValue();
+ }
+ catch (const IgniteError& err)
+ {
+ AddStatusRecord(SQL_STATE_01S00_INVALID_CONNECTION_STRING_ATTRIBUTE, err.GetText());
+
+ return SQL_RESULT_ERROR;
+ }
+
+ HandshakeRequest req(protocolVersion);
HandshakeResponse rsp;
try
@@ -330,7 +354,7 @@ namespace ignite
constructor << "Node rejected handshake message. "
<< "Current node Apache Ignite version: " << rsp.CurrentVer() << ", "
<< "node protocol version introduced in version: " << rsp.ProtoVerSince() << ", "
- << "driver protocol version introduced in version: " << PROTOCOL_VERSION_SINCE << ".";
+ << "driver protocol version introduced in version: " << config.GetProtocolVersion().ToString() << ".";
AddStatusRecord(SQL_STATE_08001_CANNOT_CONNECT, constructor.str());
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc/src/diagnostic/diagnostic_record.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/diagnostic/diagnostic_record.cpp b/modules/platforms/cpp/odbc/src/diagnostic/diagnostic_record.cpp
index 568c125..8553ee4 100644
--- a/modules/platforms/cpp/odbc/src/diagnostic/diagnostic_record.cpp
+++ b/modules/platforms/cpp/odbc/src/diagnostic/diagnostic_record.cpp
@@ -34,6 +34,9 @@ namespace
/** SQL state 01004 constant. */
const std::string STATE_01004 = "01004";
+ /** SQL state 01S00 constant. */
+ const std::string STATE_01S00 = "01S00";
+
/** SQL state 01S01 constant. */
const std::string STATE_01S01 = "01S01";
@@ -168,7 +171,7 @@ namespace ignite
return ORIGIN_ISO_9075;
}
- const std::string& DiagnosticRecord::GetMessage() const
+ const std::string& DiagnosticRecord::GetMessageText() const
{
return message;
}
@@ -190,6 +193,9 @@ namespace ignite
case SQL_STATE_01004_DATA_TRUNCATED:
return STATE_01004;
+ case SQL_STATE_01S00_INVALID_CONNECTION_STRING_ATTRIBUTE:
+ return STATE_01S00;
+
case SQL_STATE_01S01_ERROR_IN_ROW:
return STATE_01S01;
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc/src/diagnostic/diagnostic_record_storage.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/diagnostic/diagnostic_record_storage.cpp b/modules/platforms/cpp/odbc/src/diagnostic/diagnostic_record_storage.cpp
index 90c0a4f..99ef292 100644
--- a/modules/platforms/cpp/odbc/src/diagnostic/diagnostic_record_storage.cpp
+++ b/modules/platforms/cpp/odbc/src/diagnostic/diagnostic_record_storage.cpp
@@ -190,7 +190,7 @@ namespace ignite
case IGNITE_SQL_DIAG_STATUS_MESSAGE_TEXT:
{
- buffer.PutString(record.GetMessage());
+ buffer.PutString(record.GetMessageText());
return SQL_RESULT_SUCCESS;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc/src/dsn_config.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/dsn_config.cpp b/modules/platforms/cpp/odbc/src/dsn_config.cpp
new file mode 100644
index 0000000..99635dc
--- /dev/null
+++ b/modules/platforms/cpp/odbc/src/dsn_config.cpp
@@ -0,0 +1,111 @@
+/*
+ * 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.
+ */
+
+#include <set>
+
+#include "ignite/odbc/utility.h"
+#include "ignite/odbc/system/odbc_constants.h"
+
+#include "ignite/odbc/dsn_config.h"
+
+using ignite::odbc::config::Configuration;
+
+#define BUFFER_SIZE 1024
+#define CONFIG_FILE "ODBC.INI"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ void ThrowLastSetupError()
+ {
+ DWORD code;
+ char msg[BUFFER_SIZE];
+
+ SQLInstallerError(1, &code, msg, sizeof(msg), NULL);
+
+ std::stringstream buf;
+
+ buf << "Message: \"" << msg << "\", Code: " << code;
+
+ throw IgniteError(IgniteError::IGNITE_ERR_GENERIC, buf.str().c_str());
+ }
+
+ void WriteDsnString(const char* dsn, const char* key, const char* value)
+ {
+ if (!SQLWritePrivateProfileString(dsn, key, value, CONFIG_FILE))
+ ThrowLastSetupError();
+ }
+
+ std::string ReadDsnString(const char* dsn, const std::string& key, const char* dflt)
+ {
+ char buf[BUFFER_SIZE];
+
+ memset(buf, 0, sizeof(buf));
+
+ SQLGetPrivateProfileString(dsn, key.c_str(), dflt, buf, sizeof(buf), CONFIG_FILE);
+
+ return std::string(buf);
+ }
+
+ int ReadDsnInt(const char* dsn, const std::string& key, int dflt)
+ {
+ char buf[BUFFER_SIZE];
+
+ memset(buf, 0, sizeof(buf));
+
+ std::string dflt0 = common::LexicalCast<std::string>(dflt);
+
+ SQLGetPrivateProfileString(dsn, key.c_str(), dflt0.c_str(), buf, sizeof(buf), CONFIG_FILE);
+
+ return common::LexicalCast<int, std::string>(buf);
+ }
+
+ bool ReadDsnBool(const char* dsn, const std::string& key, bool dflt)
+ {
+ char buf[BUFFER_SIZE];
+
+ memset(buf, 0, sizeof(buf));
+
+ std::string dflt0 = dflt ? "true" : "false";
+
+ SQLGetPrivateProfileString(dsn, key.c_str(), dflt0.c_str(), buf, sizeof(buf), CONFIG_FILE);
+
+ return std::string(buf) == "true";
+ }
+
+ void ReadDsnConfiguration(const char* dsn, Configuration& config)
+ {
+ std::string address = ReadDsnString(dsn, Configuration::Key::address, config.GetAddress().c_str());
+ std::string server = ReadDsnString(dsn, Configuration::Key::server, config.GetHost().c_str());
+ uint16_t port = ReadDsnInt(dsn, Configuration::Key::port, config.GetTcpPort());
+ std::string cache = ReadDsnString(dsn, Configuration::Key::cache, config.GetCache().c_str());
+ std::string version = ReadDsnString(dsn, Configuration::Key::protocolVersion,
+ config.GetProtocolVersion().ToString().c_str());
+
+ LOG_MSG("%d\n", __LINE__);
+
+ config.SetAddress(address);
+ config.SetHost(server);
+ config.SetTcpPort(port);
+ config.SetCache(cache);
+ config.SetProtocolVersion(version);
+
+ LOG_MSG("%d\n", __LINE__);
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc/src/entry_points.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/entry_points.cpp b/modules/platforms/cpp/odbc/src/entry_points.cpp
index c8e78a5..f6195e1 100644
--- a/modules/platforms/cpp/odbc/src/entry_points.cpp
+++ b/modules/platforms/cpp/odbc/src/entry_points.cpp
@@ -19,14 +19,6 @@
#include "ignite/odbc/utility.h"
-BOOL INSTAPI ConfigDSN(HWND hwndParent,
- WORD req,
- LPCSTR driver,
- LPCSTR attributes)
-{
- return ignite::ConfigDSN(hwndParent, req, driver, attributes);
-}
-
SQLRETURN SQL_API SQLGetInfo(SQLHDBC conn,
SQLUSMALLINT infoType,
SQLPOINTER infoValue,
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc/src/odbc.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/odbc.cpp b/modules/platforms/cpp/odbc/src/odbc.cpp
index 3b31f1d..fd35cba 100644
--- a/modules/platforms/cpp/odbc/src/odbc.cpp
+++ b/modules/platforms/cpp/odbc/src/odbc.cpp
@@ -28,61 +28,11 @@
#include "ignite/odbc/environment.h"
#include "ignite/odbc/connection.h"
#include "ignite/odbc/statement.h"
+#include "ignite/odbc/dsn_config.h"
#include "ignite/odbc.h"
namespace ignite
{
-
- BOOL ConfigDSN(HWND hwndParent,
- WORD req,
- LPCSTR driver,
- LPCSTR attributes)
- {
- LOG_MSG("ConfigDSN called\n");
-
- ignite::odbc::config::Configuration config;
-
- config.FillFromConfigAttributes(attributes);
-
- if (!SQLValidDSN(config.GetDsn().c_str()))
- return SQL_FALSE;
-
- LOG_MSG("Driver: %s\n", driver);
- LOG_MSG("Attributes: %s\n", attributes);
-
- LOG_MSG("DSN: %s\n", config.GetDsn().c_str());
-
- switch (req)
- {
- case ODBC_ADD_DSN:
- {
- LOG_MSG("ODBC_ADD_DSN\n");
-
- return SQLWriteDSNToIni(config.GetDsn().c_str(), driver);
- }
-
- case ODBC_CONFIG_DSN:
- {
- LOG_MSG("ODBC_CONFIG_DSN\n");
- break;
- }
-
- case ODBC_REMOVE_DSN:
- {
- LOG_MSG("ODBC_REMOVE_DSN\n");
-
- return SQLRemoveDSNFromIni(config.GetDsn().c_str());
- }
-
- default:
- {
- return SQL_FALSE;
- }
- }
-
- return SQL_TRUE;
- }
-
SQLRETURN SQLGetInfo(SQLHDBC conn,
SQLUSMALLINT infoType,
SQLPOINTER infoValue,
@@ -306,10 +256,10 @@ namespace ignite
SQLSMALLINT* outConnectionStringLen,
SQLUSMALLINT driverCompletion)
{
- using ignite::odbc::Connection;
- using ignite::odbc::diagnostic::DiagnosticRecordStorage;
- using ignite::utility::SqlStringToString;
- using ignite::utility::CopyStringToBuffer;
+ using odbc::Connection;
+ using odbc::diagnostic::DiagnosticRecordStorage;
+ using utility::SqlStringToString;
+ using utility::CopyStringToBuffer;
UNREFERENCED_PARAMETER(windowHandle);
@@ -323,18 +273,23 @@ namespace ignite
std::string connectStr = SqlStringToString(inConnectionString, inConnectionStringLen);
- ignite::odbc::config::Configuration config;
+ odbc::config::Configuration config;
config.FillFromConnectString(connectStr);
- connection->Establish(config.GetHost(), config.GetPort(), config.GetCache());
+ std::string dsn = config.GetDsn();
+
+ if (!dsn.empty())
+ odbc::ReadDsnConfiguration(dsn.c_str(), config);
+
+ connection->Establish(config);
const DiagnosticRecordStorage& diag = connection->GetDiagnosticRecords();
if (!diag.IsSuccessful())
return diag.GetReturnCode();
- std::string outConnectStr = config.ToConnectString();
+ std::string outConnectStr = connection->GetConfiguration().ToConnectString();
size_t reslen = CopyStringToBuffer(outConnectStr,
reinterpret_cast<char*>(outConnectionString),
@@ -357,7 +312,7 @@ namespace ignite
SQLSMALLINT authLen)
{
using ignite::odbc::Connection;
- using ignite::odbc::diagnostic::DiagnosticRecordStorage;
+ using ignite::odbc::config::Configuration;
using ignite::utility::SqlStringToString;
LOG_MSG("SQLConnect called\n");
@@ -367,9 +322,13 @@ namespace ignite
if (!connection)
return SQL_INVALID_HANDLE;
- std::string server = SqlStringToString(serverName, serverNameLen);
+ odbc::config::Configuration config;
+
+ std::string dsn = SqlStringToString(serverName, serverNameLen);
+
+ odbc::ReadDsnConfiguration(dsn.c_str(), config);
- connection->Establish(server);
+ connection->Establish(config);
return connection->GetDiagnosticRecords().GetReturnCode();
}
@@ -1168,7 +1127,7 @@ namespace ignite
SqlLen outResLen;
ApplicationDataBuffer outBuffer(IGNITE_ODBC_C_TYPE_CHAR, msgBuffer, msgBufferLen, &outResLen);
- outBuffer.PutString(record.GetMessage());
+ outBuffer.PutString(record.GetMessageText());
*msgLen = static_cast<SQLSMALLINT>(outResLen);
[14/50] [abbrv] ignite git commit: IGNITE-3776: Removed code
duplication in GridNearAtomicAbstractUpdateFuture.
Posted by sb...@apache.org.
IGNITE-3776: Removed code duplication in GridNearAtomicAbstractUpdateFuture.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/87a1928a
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/87a1928a
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/87a1928a
Branch: refs/heads/ignite-961
Commit: 87a1928a4f90b4f8a221041cfff9d22e3dd801cc
Parents: 99e3e8a
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Fri Aug 26 15:22:15 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Fri Aug 26 15:22:15 2016 +0300
----------------------------------------------------------------------
.../GridNearAtomicAbstractUpdateFuture.java | 69 +++++++++++++++++++
.../GridNearAtomicSingleUpdateFuture.java | 70 +-------------------
.../dht/atomic/GridNearAtomicUpdateFuture.java | 68 +------------------
3 files changed, 73 insertions(+), 134 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/87a1928a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicAbstractUpdateFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicAbstractUpdateFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicAbstractUpdateFuture.java
index 3e69c02..85751bb 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicAbstractUpdateFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicAbstractUpdateFuture.java
@@ -17,6 +17,7 @@
package org.apache.ignite.internal.processors.cache.distributed.dht.atomic;
+import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.cache.CacheWriteSynchronizationMode;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
@@ -29,6 +30,7 @@ import org.apache.ignite.internal.processors.cache.GridCacheOperation;
import org.apache.ignite.internal.processors.cache.GridCacheReturn;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
import org.apache.ignite.internal.util.future.GridFutureAdapter;
+import org.apache.ignite.internal.util.typedef.CI2;
import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteUuid;
@@ -246,4 +248,71 @@ public abstract class GridNearAtomicAbstractUpdateFuture extends GridFutureAdapt
protected boolean storeFuture() {
return cctx.config().getAtomicWriteOrderMode() == CLOCK || syncMode != FULL_ASYNC;
}
+
+ /**
+ * Maps future to single node.
+ *
+ * @param nodeId Node ID.
+ * @param req Request.
+ */
+ protected void mapSingle(UUID nodeId, GridNearAtomicUpdateRequest req) {
+ if (cctx.localNodeId().equals(nodeId)) {
+ cache.updateAllAsyncInternal(nodeId, req,
+ new CI2<GridNearAtomicUpdateRequest, GridNearAtomicUpdateResponse>() {
+ @Override public void apply(GridNearAtomicUpdateRequest req, GridNearAtomicUpdateResponse res) {
+ onResult(res.nodeId(), res, false);
+ }
+ });
+ }
+ else {
+ try {
+ cctx.io().send(req.nodeId(), req, cctx.ioPolicy());
+
+ if (msgLog.isDebugEnabled()) {
+ msgLog.debug("Near update fut, sent request [futId=" + req.futureVersion() +
+ ", writeVer=" + req.updateVersion() +
+ ", node=" + req.nodeId() + ']');
+ }
+
+ if (syncMode == FULL_ASYNC)
+ onDone(new GridCacheReturn(cctx, true, true, null, true));
+ }
+ catch (IgniteCheckedException e) {
+ if (msgLog.isDebugEnabled()) {
+ msgLog.debug("Near update fut, failed to send request [futId=" + req.futureVersion() +
+ ", writeVer=" + req.updateVersion() +
+ ", node=" + req.nodeId() +
+ ", err=" + e + ']');
+ }
+
+ onSendError(req, e);
+ }
+ }
+ }
+
+ /**
+ * Response callback.
+ *
+ * @param nodeId Node ID.
+ * @param res Update response.
+ * @param nodeErr {@code True} if response was created on node failure.
+ */
+ public abstract void onResult(UUID nodeId, GridNearAtomicUpdateResponse res, boolean nodeErr);
+
+ /**
+ * @param req Request.
+ * @param e Error.
+ */
+ protected void onSendError(GridNearAtomicUpdateRequest req, IgniteCheckedException e) {
+ synchronized (mux) {
+ GridNearAtomicUpdateResponse res = new GridNearAtomicUpdateResponse(cctx.cacheId(),
+ req.nodeId(),
+ req.futureVersion(),
+ cctx.deploymentEnabled());
+
+ res.addFailedKeys(req.keys(), e);
+
+ onResult(req.nodeId(), res, true);
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/87a1928a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFuture.java
index aad4186..661a178 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFuture.java
@@ -37,7 +37,6 @@ import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
import org.apache.ignite.internal.util.future.GridFinishedFuture;
import org.apache.ignite.internal.util.future.GridFutureAdapter;
import org.apache.ignite.internal.util.typedef.CI1;
-import org.apache.ignite.internal.util.typedef.CI2;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.X;
import org.apache.ignite.internal.util.typedef.internal.CU;
@@ -52,7 +51,6 @@ import java.util.Map;
import java.util.UUID;
import static org.apache.ignite.cache.CacheAtomicWriteOrderMode.CLOCK;
-import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_ASYNC;
import static org.apache.ignite.internal.processors.cache.GridCacheOperation.TRANSFORM;
/**
@@ -191,15 +189,9 @@ public class GridNearAtomicSingleUpdateFuture extends GridNearAtomicAbstractUpda
return false;
}
- /**
- * Response callback.
- *
- * @param nodeId Node ID.
- * @param res Update response.
- * @param nodeErr {@code True} if response was created on node failure.
- */
+ /** {@inheritDoc} */
@SuppressWarnings({"unchecked", "ThrowableResultOfMethodCallIgnored"})
- public void onResult(UUID nodeId, GridNearAtomicUpdateResponse res, boolean nodeErr) {
+ @Override public void onResult(UUID nodeId, GridNearAtomicUpdateResponse res, boolean nodeErr) {
GridNearAtomicUpdateRequest req;
AffinityTopologyVersion remapTopVer = null;
@@ -441,64 +433,6 @@ public class GridNearAtomicSingleUpdateFuture extends GridNearAtomicAbstractUpda
map(topVer);
}
- /**
- * Maps future to single node.
- *
- * @param nodeId Node ID.
- * @param req Request.
- */
- private void mapSingle(UUID nodeId, GridNearAtomicUpdateRequest req) {
- if (cctx.localNodeId().equals(nodeId)) {
- cache.updateAllAsyncInternal(nodeId, req,
- new CI2<GridNearAtomicUpdateRequest, GridNearAtomicUpdateResponse>() {
- @Override public void apply(GridNearAtomicUpdateRequest req, GridNearAtomicUpdateResponse res) {
- onResult(res.nodeId(), res, false);
- }
- });
- }
- else {
- try {
- cctx.io().send(req.nodeId(), req, cctx.ioPolicy());
-
- if (msgLog.isDebugEnabled()) {
- msgLog.debug("Near update single fut, sent request [futId=" + req.futureVersion() +
- ", writeVer=" + req.updateVersion() +
- ", node=" + req.nodeId() + ']');
- }
-
- if (syncMode == FULL_ASYNC)
- onDone(new GridCacheReturn(cctx, true, true, null, true));
- }
- catch (IgniteCheckedException e) {
- if (msgLog.isDebugEnabled()) {
- msgLog.debug("Near update single fut, failed to send request [futId=" + req.futureVersion() +
- ", writeVer=" + req.updateVersion() +
- ", node=" + req.nodeId() +
- ", err=" + e + ']');
- }
-
- onSendError(req, e);
- }
- }
- }
-
- /**
- * @param req Request.
- * @param e Error.
- */
- void onSendError(GridNearAtomicUpdateRequest req, IgniteCheckedException e) {
- synchronized (mux) {
- GridNearAtomicUpdateResponse res = new GridNearAtomicUpdateResponse(cctx.cacheId(),
- req.nodeId(),
- req.futureVersion(),
- cctx.deploymentEnabled());
-
- res.addFailedKeys(req.keys(), e);
-
- onResult(req.nodeId(), res, true);
- }
- }
-
/** {@inheritDoc} */
protected void map(AffinityTopologyVersion topVer) {
Collection<ClusterNode> topNodes = CU.affinityNodes(cctx, topVer);
http://git-wip-us.apache.org/repos/asf/ignite/blob/87a1928a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java
index 0d88ef8..2432f63 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java
@@ -253,15 +253,9 @@ public class GridNearAtomicUpdateFuture extends GridNearAtomicAbstractUpdateFutu
return false;
}
- /**
- * Response callback.
- *
- * @param nodeId Node ID.
- * @param res Update response.
- * @param nodeErr {@code True} if response was created on node failure.
- */
+ /** {@inheritDoc} */
@SuppressWarnings({"unchecked", "ThrowableResultOfMethodCallIgnored"})
- public void onResult(UUID nodeId, GridNearAtomicUpdateResponse res, boolean nodeErr) {
+ @Override public void onResult(UUID nodeId, GridNearAtomicUpdateResponse res, boolean nodeErr) {
GridNearAtomicUpdateRequest req;
AffinityTopologyVersion remapTopVer = null;
@@ -552,47 +546,6 @@ public class GridNearAtomicUpdateFuture extends GridNearAtomicAbstractUpdateFutu
}
/**
- * Maps future to single node.
- *
- * @param nodeId Node ID.
- * @param req Request.
- */
- private void mapSingle(UUID nodeId, GridNearAtomicUpdateRequest req) {
- if (cctx.localNodeId().equals(nodeId)) {
- cache.updateAllAsyncInternal(nodeId, req,
- new CI2<GridNearAtomicUpdateRequest, GridNearAtomicUpdateResponse>() {
- @Override public void apply(GridNearAtomicUpdateRequest req, GridNearAtomicUpdateResponse res) {
- onResult(res.nodeId(), res, false);
- }
- });
- }
- else {
- try {
- cctx.io().send(req.nodeId(), req, cctx.ioPolicy());
-
- if (msgLog.isDebugEnabled()) {
- msgLog.debug("Near update fut, sent request [futId=" + req.futureVersion() +
- ", writeVer=" + req.updateVersion() +
- ", node=" + req.nodeId() + ']');
- }
-
- if (syncMode == FULL_ASYNC)
- onDone(new GridCacheReturn(cctx, true, true, null, true));
- }
- catch (IgniteCheckedException e) {
- if (msgLog.isDebugEnabled()) {
- msgLog.debug("Near update fut, failed to send request [futId=" + req.futureVersion() +
- ", writeVer=" + req.updateVersion() +
- ", node=" + req.nodeId() +
- ", err=" + e + ']');
- }
-
- onSendError(req, e);
- }
- }
- }
-
- /**
* Sends messages to remote nodes and updates local cache.
*
* @param mappings Mappings to send.
@@ -646,23 +599,6 @@ public class GridNearAtomicUpdateFuture extends GridNearAtomicAbstractUpdateFutu
onDone(new GridCacheReturn(cctx, true, true, null, true));
}
- /**
- * @param req Request.
- * @param e Error.
- */
- void onSendError(GridNearAtomicUpdateRequest req, IgniteCheckedException e) {
- synchronized (mux) {
- GridNearAtomicUpdateResponse res = new GridNearAtomicUpdateResponse(cctx.cacheId(),
- req.nodeId(),
- req.futureVersion(),
- cctx.deploymentEnabled());
-
- res.addFailedKeys(req.keys(), e);
-
- onResult(req.nodeId(), res, true);
- }
- }
-
/** {@inheritDoc} */
protected void map(AffinityTopologyVersion topVer) {
map(topVer, null);
[03/50] [abbrv] ignite git commit: IGNITE-3755 .NET: LINQ -
user-friendly CacheQueryable.ToString()
Posted by sb...@apache.org.
IGNITE-3755 .NET: LINQ - user-friendly CacheQueryable.ToString()
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/22d3b1e9
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/22d3b1e9
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/22d3b1e9
Branch: refs/heads/ignite-961
Commit: 22d3b1e941e2d37a3c13763d07908eaec9427298
Parents: a2fecaf
Author: Pavel Tupitsyn <pt...@apache.org>
Authored: Thu Aug 25 10:33:25 2016 +0300
Committer: Pavel Tupitsyn <pt...@apache.org>
Committed: Thu Aug 25 10:33:25 2016 +0300
----------------------------------------------------------------------
.../Cache/Query/CacheLinqTest.cs | 21 ++++++++++++++++++--
.../Cache/Query/SqlFieldsQuery.cs | 16 +++++++++++++++
.../Impl/CacheFieldsQueryExecutor.cs | 2 +-
.../Impl/CacheQueryableBase.cs | 10 +++-------
4 files changed, 39 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/22d3b1e9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheLinqTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheLinqTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheLinqTest.cs
index 6d3af67..1ac7fa7 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheLinqTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheLinqTest.cs
@@ -28,7 +28,6 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
{
using System;
using System.Collections;
- using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Linq.Expressions;
using System.Text.RegularExpressions;
@@ -1171,6 +1170,11 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
Assert.IsFalse(fq.EnableDistributedJoins);
Assert.IsTrue(fq.EnforceJoinOrder);
+ var str = query.ToString();
+ Assert.AreEqual("CacheQueryable [CacheName=, TableName=Person, Query=SqlFieldsQuery [Sql=select " +
+ "_T0._key, _T0._val from \"\".Person as _T0 where (_T0._key > ?), Arguments=[10], " +
+ "Local=True, PageSize=999, EnableDistributedJoins=False, EnforceJoinOrder=True]]", str);
+
// Check fields query
var fieldsQuery = (ICacheQueryable) cache.AsCacheQueryable().Select(x => x.Value.Name);
@@ -1184,11 +1188,24 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
Assert.IsFalse(fq.EnableDistributedJoins);
Assert.IsFalse(fq.EnforceJoinOrder);
+ str = fieldsQuery.ToString();
+ Assert.AreEqual("CacheQueryable [CacheName=, TableName=Person, Query=SqlFieldsQuery [Sql=select " +
+ "_T0.Name from \"\".Person as _T0, Arguments=[], Local=False, PageSize=1024, " +
+ "EnableDistributedJoins=False, EnforceJoinOrder=False]]", str);
+
// Check distributed joins flag propagation
var distrQuery = cache.AsCacheQueryable(new QueryOptions {EnableDistributedJoins = true})
- .Where(x => x.Key > 10);
+ .Where(x => x.Key > 10 && x.Value.Age > 20 && x.Value.Name.Contains("x"));
+
query = (ICacheQueryable) distrQuery;
+
Assert.IsTrue(query.GetFieldsQuery().EnableDistributedJoins);
+
+ str = distrQuery.ToString();
+ Assert.AreEqual("CacheQueryable [CacheName=, TableName=Person, Query=SqlFieldsQuery [Sql=select " +
+ "_T0._key, _T0._val from \"\".Person as _T0 where (((_T0._key > ?) and (_T0.age1 > ?)) " +
+ "and (_T0.Name like \'%\' || ? || \'%\') ), Arguments=[10, 20, x], Local=False, " +
+ "PageSize=1024, EnableDistributedJoins=True, EnforceJoinOrder=False]]", str);
}
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/22d3b1e9/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/SqlFieldsQuery.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/SqlFieldsQuery.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/SqlFieldsQuery.cs
index ed9d0eb..1d896b8 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/SqlFieldsQuery.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/SqlFieldsQuery.cs
@@ -18,6 +18,7 @@
namespace Apache.Ignite.Core.Cache.Query
{
using System.Diagnostics.CodeAnalysis;
+ using System.Linq;
/// <summary>
/// SQL fields query.
@@ -102,5 +103,20 @@ namespace Apache.Ignite.Core.Cache.Query
/// <c>true</c> if join order should be enforced; otherwise, <c>false</c>.
/// </value>
public bool EnforceJoinOrder { get; set; }
+
+ /// <summary>
+ /// Returns a <see cref="string" /> that represents this instance.
+ /// </summary>
+ /// <returns>
+ /// A <see cref="string" /> that represents this instance.
+ /// </returns>
+ public override string ToString()
+ {
+ var args = string.Join(", ", Arguments.Select(x => x == null ? "null" : x.ToString()));
+
+ return string.Format("SqlFieldsQuery [Sql={0}, Arguments=[{1}], Local={2}, PageSize={3}, " +
+ "EnableDistributedJoins={4}, EnforceJoinOrder={5}]", Sql, args, Local,
+ PageSize, EnableDistributedJoins, EnforceJoinOrder);
+ }
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/22d3b1e9/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheFieldsQueryExecutor.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheFieldsQueryExecutor.cs b/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheFieldsQueryExecutor.cs
index 3d48f41..0c9d4a2 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheFieldsQueryExecutor.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheFieldsQueryExecutor.cs
@@ -282,7 +282,7 @@ namespace Apache.Ignite.Linq.Impl
/// <summary>
/// Gets the fields query.
/// </summary>
- private SqlFieldsQuery GetFieldsQuery(string text, object[] args)
+ internal SqlFieldsQuery GetFieldsQuery(string text, object[] args)
{
return new SqlFieldsQuery(text, _local, args)
{
http://git-wip-us.apache.org/repos/asf/ignite/blob/22d3b1e9/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheQueryableBase.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheQueryableBase.cs b/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheQueryableBase.cs
index 5dc40ab..21a7850 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheQueryableBase.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheQueryableBase.cs
@@ -66,12 +66,7 @@ namespace Apache.Ignite.Linq.Impl
var data = GetQueryData();
var executor = CacheQueryProvider.Executor;
- return new SqlFieldsQuery(data.QueryText, executor.Local, data.Parameters.ToArray())
- {
- EnableDistributedJoins = executor.EnableDistributedJoins,
- EnforceJoinOrder = executor.EnforceJoinOrder,
- PageSize = executor.PageSize
- };
+ return executor.GetFieldsQuery(data.QueryText, data.Parameters.ToArray());
}
/** <inheritdoc /> */
@@ -143,7 +138,8 @@ namespace Apache.Ignite.Linq.Impl
/// </returns>
public override string ToString()
{
- return GetQueryData().ToString();
+ return string.Format("CacheQueryable [CacheName={0}, TableName={1}, Query={2}]",
+ CacheName, TableName, GetFieldsQuery());
}
}
}
\ No newline at end of file
[25/50] [abbrv] ignite git commit: Merge ignite-1.7.2 to master
Posted by sb...@apache.org.
Merge ignite-1.7.2 to master
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/f89375bd
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/f89375bd
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/f89375bd
Branch: refs/heads/ignite-961
Commit: f89375bdd6159134fae5d0b7b28b876b6e335a32
Parents: 2d5d5bc fea3eea
Author: agura <ag...@gridgain.com>
Authored: Mon Aug 29 20:35:08 2016 +0300
Committer: agura <ag...@gridgain.com>
Committed: Mon Aug 29 20:35:08 2016 +0300
----------------------------------------------------------------------
.../local/LocalIgfsSecondaryFileSystem.java | 38 +-
.../processors/cache/GridCacheMapEntry.java | 19 +-
.../GridCachePartitionExchangeManager.java | 7 +
.../GridDistributedTxPrepareRequest.java | 4 +-
.../distributed/dht/GridDhtLockFuture.java | 53 +-
.../distributed/dht/GridDhtTxFinishFuture.java | 4 +-
.../cache/distributed/dht/GridDhtTxLocal.java | 26 +-
.../distributed/dht/GridDhtTxPrepareFuture.java | 101 +-
.../dht/GridDhtTxPrepareRequest.java | 4 +-
.../GridNearAtomicAbstractUpdateFuture.java | 69 ++
.../GridNearAtomicSingleUpdateFuture.java | 70 +-
.../dht/atomic/GridNearAtomicUpdateFuture.java | 68 +-
.../colocated/GridDhtColocatedLockFuture.java | 37 +-
.../distributed/near/GridNearLockFuture.java | 90 +-
...arOptimisticSerializableTxPrepareFuture.java | 13 +-
.../near/GridNearOptimisticTxPrepareFuture.java | 263 +++--
...ridNearOptimisticTxPrepareFutureAdapter.java | 5 +-
.../GridNearPessimisticTxPrepareFuture.java | 8 +-
.../near/GridNearTxFinishFuture.java | 5 +-
.../cache/distributed/near/GridNearTxLocal.java | 16 +-
.../near/GridNearTxPrepareRequest.java | 4 +-
.../cache/transactions/IgniteInternalTx.java | 3 +-
.../cache/transactions/IgniteTxAdapter.java | 37 +-
.../cache/transactions/IgniteTxHandler.java | 11 +-
.../transactions/IgniteTxLocalAdapter.java | 19 +-
.../cache/transactions/IgniteTxManager.java | 86 +-
.../cache/transactions/IgniteTxStateImpl.java | 11 +-
.../cache/transactions/TxDeadlockDetection.java | 51 +-
.../processors/odbc/OdbcNioListener.java | 2 +-
.../processors/odbc/OdbcRequestHandler.java | 36 +-
.../odbc/escape/OdbcEscapeParseResult.java | 73 ++
.../processors/odbc/escape/OdbcEscapeToken.java | 61 +
.../processors/odbc/escape/OdbcEscapeType.java | 105 ++
.../processors/odbc/escape/OdbcEscapeUtils.java | 361 ++++++
.../service/GridServiceProcessor.java | 18 +-
.../util/future/GridCompoundFuture.java | 10 +
.../ignite/spi/discovery/tcp/ClientImpl.java | 7 +-
.../cache/IgniteTxConfigCacheSelfTest.java | 91 +-
.../IgniteTxTimeoutAbstractTest.java | 8 +-
...tionedMultiNodeLongTxTimeoutFullApiTest.java | 34 +
...nabledMultiNodeLongTxTimeoutFullApiTest.java | 41 +
.../local/GridCacheLocalTxTimeoutSelfTest.java | 5 +-
.../transactions/DepthFirstSearchTest.java | 100 +-
.../TxDeadlockDetectionNoHangsTest.java | 246 ++++
.../transactions/TxDeadlockDetectionTest.java | 13 +-
...timisticDeadlockDetectionCrossCacheTest.java | 257 +++++
.../TxOptimisticDeadlockDetectionTest.java | 574 ++++++++++
...simisticDeadlockDetectionCrossCacheTest.java | 165 ++-
.../TxPessimisticDeadlockDetectionTest.java | 50 +-
.../igfs/IgfsAbstractBaseSelfTest.java | 1067 ++++++++++++++++++
.../processors/igfs/IgfsAbstractSelfTest.java | 1012 +----------------
...SecondaryFileSystemDualAbstractSelfTest.java | 143 +++
.../odbc/OdbcEscapeSequenceSelfTest.java | 420 +++++++
.../ignite/testsuites/IgniteBasicTestSuite.java | 2 +
.../IgniteCacheFullApiSelfTestSuite.java | 4 +
.../TxDeadlockDetectionTestSuite.java | 6 +
.../cpp/common/include/ignite/common/utils.h | 7 +
.../cpp/common/os/win/src/common/utils.cpp | 20 +
.../cpp/common/src/common/big_integer.cpp | 1 -
.../cpp/core/include/ignite/ignition.h | 2 +-
modules/platforms/cpp/core/src/ignition.cpp | 8 +-
modules/platforms/cpp/odbc-test/Makefile.am | 9 +
.../platforms/cpp/odbc-test/include/Makefile.am | 4 +-
.../odbc-test/include/sql_test_suite_fixture.h | 191 ++++
.../cpp/odbc-test/include/test_utils.h | 45 +
.../cpp/odbc-test/project/vs/odbc-test.vcxproj | 11 +
.../project/vs/odbc-test.vcxproj.filters | 33 +
.../cpp/odbc-test/src/configuration_test.cpp | 6 +-
.../cpp/odbc-test/src/queries_test.cpp | 78 +-
.../src/sql_aggregate_functions_test.cpp | 249 ++++
.../src/sql_numeric_functions_test.cpp | 309 +++++
.../cpp/odbc-test/src/sql_operators_test.cpp | 214 ++++
.../odbc-test/src/sql_string_functions_test.cpp | 291 +++++
.../odbc-test/src/sql_system_functions_test.cpp | 47 +
.../odbc-test/src/sql_test_suite_fixture.cpp | 271 +++++
.../cpp/odbc-test/src/sql_types_test.cpp | 60 +
.../src/sql_value_expressions_test.cpp | 94 ++
.../platforms/cpp/odbc-test/src/test_utils.cpp | 36 +
modules/platforms/cpp/odbc/Makefile.am | 1 +
modules/platforms/cpp/odbc/include/Makefile.am | 1 +
.../platforms/cpp/odbc/include/ignite/odbc.h | 1 -
.../include/ignite/odbc/config/configuration.h | 93 +-
.../ignite/odbc/diagnostic/diagnostic_record.h | 2 +-
.../cpp/odbc/include/ignite/odbc/dsn_config.h | 61 +
.../odbc/include/ignite/odbc/protocol_version.h | 20 +-
.../include/ignite/odbc/system/odbc_constants.h | 4 -
.../odbc/system/ui/dsn_configuration_window.h | 152 +++
.../ignite/odbc/system/ui/custom_window.h | 189 ++++
.../win/include/ignite/odbc/system/ui/window.h | 201 ++++
.../odbc/os/win/src/system/ui/custom_window.cpp | 184 +++
.../src/system/ui/dsn_configuration_window.cpp | 305 +++++
.../cpp/odbc/os/win/src/system/ui/window.cpp | 192 ++++
.../cpp/odbc/os/win/src/system_dsn.cpp | 218 ++++
.../platforms/cpp/odbc/project/vs/odbc.vcxproj | 25 +-
.../cpp/odbc/project/vs/odbc.vcxproj.filters | 30 +
.../cpp/odbc/src/config/configuration.cpp | 17 +-
.../cpp/odbc/src/config/connection_info.cpp | 57 +-
modules/platforms/cpp/odbc/src/connection.cpp | 2 +-
.../odbc/src/diagnostic/diagnostic_record.cpp | 2 +-
.../diagnostic/diagnostic_record_storage.cpp | 2 +-
modules/platforms/cpp/odbc/src/dsn_config.cpp | 115 ++
modules/platforms/cpp/odbc/src/entry_points.cpp | 8 -
modules/platforms/cpp/odbc/src/odbc.cpp | 88 +-
.../platforms/cpp/odbc/src/protocol_version.cpp | 23 +-
.../platforms/cpp/odbc/src/query/data_query.cpp | 6 +-
modules/platforms/cpp/odbc/src/utility.cpp | 14 +-
.../commands/cache/VisorCacheStopCommand.scala | 5 +-
107 files changed, 8330 insertions(+), 1707 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/f89375bd/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java
index 187c8a4,b005b29..f2b5f49
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java
@@@ -298,8 -292,10 +292,10 @@@ public final class GridDhtLockFuture ex
/**
* @return Entries.
*/
- public synchronized Collection<GridDhtCacheEntry> entriesCopy() {
- return new ArrayList<>(entries());
+ public Collection<GridDhtCacheEntry> entriesCopy() {
- synchronized (futs) {
++ synchronized (sync) {
+ return new ArrayList<>(entries());
+ }
}
/**
@@@ -412,7 -408,7 +408,7 @@@
return null;
}
- synchronized (this) {
- synchronized (futs) {
++ synchronized (sync) {
entries.add(c == null || c.reentry() ? null : entry);
if (c != null && !c.reentry())
@@@ -614,7 -610,7 +610,7 @@@
* @param t Error.
*/
public void onError(Throwable t) {
- synchronized (this) {
- synchronized (futs) {
++ synchronized (sync) {
if (err != null)
return;
@@@ -661,8 -657,9 +657,9 @@@
log.debug("Received onOwnerChanged() callback [entry=" + entry + ", owner=" + owner + "]");
if (owner != null && owner.version().equals(lockVer)) {
- synchronized (this) {
- pendingLocks.remove(entry.key());
- synchronized (futs) {
++ synchronized (sync) {
+ if (!pendingLocks.remove(entry.key()))
+ return false;
}
if (checkLocks())
@@@ -677,8 -674,10 +674,10 @@@
/**
* @return {@code True} if locks have been acquired.
*/
- private synchronized boolean checkLocks() {
- return pendingLocks.isEmpty();
+ private boolean checkLocks() {
- synchronized (futs) {
++ synchronized (sync) {
+ return pendingLocks.isEmpty();
+ }
}
/** {@inheritDoc} */
@@@ -709,7 -708,7 +708,7 @@@
if (isDone() || (err == null && success && !checkLocks()))
return false;
- synchronized (this) {
- synchronized (futs) {
++ synchronized (sync) {
if (this.err == null)
this.err = err;
}
@@@ -782,7 -787,7 +787,7 @@@
* @param entries Entries.
*/
private void map(Iterable<GridDhtCacheEntry> entries) {
- synchronized (this) {
- synchronized (futs) {
++ synchronized (sync) {
if (mapped)
return;
@@@ -1109,7 -1119,14 +1119,14 @@@
if (log.isDebugEnabled())
log.debug("Timed out waiting for lock response: " + this);
- timedOut = true;
- synchronized (futs) {
++ synchronized (sync) {
+ timedOut = true;
+
+ // Stop locks and responses processing.
+ pendingLocks.clear();
+
- futs.clear();
++ clear();
+ }
boolean releaseLocks = !(inTx() && cctx.tm().deadlockDetectionEnabled());
http://git-wip-us.apache.org/repos/asf/ignite/blob/f89375bd/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
index 2800897,1bdd9b8..3cb0fbc
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
@@@ -269,7 -278,7 +278,7 @@@ public final class GridDhtTxPrepareFutu
boolean rmv;
- synchronized (lockKeys) {
- synchronized (futs) {
++ synchronized (sync) {
rmv = lockKeys.remove(entry.txKey());
}
@@@ -300,7 -309,7 +309,7 @@@
if (!locksReady)
return false;
- synchronized (lockKeys) {
- synchronized (futs) {
++ synchronized (sync) {
return lockKeys.isEmpty();
}
}
@@@ -583,7 -588,7 +588,7 @@@
}
if (tx.optimistic() && txEntry.explicitVersion() == null) {
- synchronized (lockKeys) {
- synchronized (futs) {
++ synchronized (sync) {
lockKeys.add(txEntry.txKey());
}
}
@@@ -1284,9 -1303,12 +1303,12 @@@
for (GridDistributedTxMapping nearMapping : tx.nearMap().values()) {
if (!tx.dhtMap().containsKey(nearMapping.node().id())) {
+ if (tx.remainingTime() == -1)
+ return;
+
MiniFuture fut = new MiniFuture(nearMapping.node().id(), null, nearMapping);
- add(fut);
+ add(fut); // Append new future.
GridDhtTxPrepareRequest req = new GridDhtTxPrepareRequest(
futId,
@@@ -1719,4 -1742,38 +1742,38 @@@
return S.toString(MiniFuture.class, this, "done", isDone(), "cancelled", isCancelled(), "err", error());
}
}
+
+ /**
+ *
+ */
+ private class PrepareTimeoutObject extends GridTimeoutObjectAdapter {
+ /** */
+ private final long timeout;
+
+ /**
+ * @param timeout Timeout.
+ */
+ PrepareTimeoutObject(long timeout) {
+ super(timeout);
+
+ this.timeout = timeout;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void onTimeout() {
- synchronized (futs) {
- futs.clear();
++ synchronized (sync) {
++ clear();
+
+ lockKeys.clear();
+ }
+
+ onError(new IgniteTxTimeoutCheckedException("Failed to acquire lock within " +
+ "provided timeout for transaction [timeout=" + tx.timeout() + ", tx=" + tx + ']'));
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(PrepareTimeoutObject.class, this);
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/f89375bd/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java
index 05b4a2b,b0eea01..ddb6500
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java
@@@ -443,17 -443,27 +443,27 @@@ public final class GridDhtColocatedLock
/**
* @return Keys for which locks requested from remote nodes but response isn't received.
*/
- public Set<KeyCacheObject> requestedKeys() {
- Set<KeyCacheObject> requestedKeys = null;
+ public Set<IgniteTxKey> requestedKeys() {
- synchronized (futs) {
++ synchronized (sync) {
+ if (timeoutObj != null && timeoutObj.requestedKeys != null)
+ return timeoutObj.requestedKeys;
+
+ return requestedKeys0();
+ }
+ }
+ /**
+ * @return Keys for which locks requested from remote nodes but response isn't received.
+ */
+ private Set<IgniteTxKey> requestedKeys0() {
for (IgniteInternalFuture<Boolean> miniFut : futures()) {
if (isMini(miniFut) && !miniFut.isDone()) {
- if (requestedKeys == null)
- requestedKeys = new HashSet<>();
-
MiniFuture mini = (MiniFuture)miniFut;
- requestedKeys.addAll(mini.keys);
+ Set<IgniteTxKey> requestedKeys = U.newHashSet(mini.keys.size());
+
+ for (KeyCacheObject key : mini.keys)
+ requestedKeys.add(new IgniteTxKey(key, cctx.cacheId()));
return requestedKeys;
}
@@@ -1318,6 -1331,12 +1331,12 @@@
log.debug("Timed out waiting for lock response: " + this);
if (inTx() && cctx.tm().deadlockDetectionEnabled()) {
- synchronized (futs) {
++ synchronized (sync) {
+ requestedKeys = requestedKeys0();
+
- futs.clear(); // Stop response processing.
++ clear(); // Stop response processing.
+ }
+
Set<IgniteTxKey> keys = new HashSet<>();
for (IgniteTxEntry txEntry : tx.allEntries()) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/f89375bd/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java
index 3b53c5e,3d9b6ab..02f6cce
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java
@@@ -481,6 -487,38 +487,38 @@@ public final class GridNearLockFuture e
}
/**
+ * @return Keys for which locks requested from remote nodes but response isn't received.
+ */
+ public Set<IgniteTxKey> requestedKeys() {
- synchronized (futs) {
++ synchronized (sync) {
+ if (timeoutObj != null && timeoutObj.requestedKeys != null)
+ return timeoutObj.requestedKeys;
+
+ return requestedKeys0();
+ }
+ }
+
+ /**
+ * @return Keys for which locks requested from remote nodes but response isn't received.
+ */
+ private Set<IgniteTxKey> requestedKeys0() {
+ for (IgniteInternalFuture<Boolean> miniFut : futures()) {
+ if (isMini(miniFut) && !miniFut.isDone()) {
+ MiniFuture mini = (MiniFuture)miniFut;
+
+ Set<IgniteTxKey> requestedKeys = U.newHashSet(mini.keys.size());
+
+ for (KeyCacheObject key : mini.keys)
+ requestedKeys.add(new IgniteTxKey(key, cctx.cacheId()));
+
+ return requestedKeys;
+ }
+ }
+
+ return null;
+ }
+
+ /**
* Finds pending mini future by the given mini ID.
*
* @param miniId Mini ID to find.
@@@ -1381,7 -1426,42 +1426,42 @@@
timedOut = true;
- onComplete(false, true);
+ if (inTx() && cctx.tm().deadlockDetectionEnabled()) {
- synchronized (futs) {
++ synchronized (sync) {
+ requestedKeys = requestedKeys0();
+
- futs.clear(); // Stop response processing.
++ clear(); // Stop response processing.
+ }
+
+ Set<IgniteTxKey> keys = new HashSet<>();
+
+ for (IgniteTxEntry txEntry : tx.allEntries()) {
+ if (!txEntry.locked())
+ keys.add(txEntry.txKey());
+ }
+
+ IgniteInternalFuture<TxDeadlock> fut = cctx.tm().detectDeadlock(tx, keys);
+
+ fut.listen(new IgniteInClosure<IgniteInternalFuture<TxDeadlock>>() {
+ @Override public void apply(IgniteInternalFuture<TxDeadlock> fut) {
+ try {
+ TxDeadlock deadlock = fut.get();
+
+ if (deadlock != null)
+ err = new TransactionDeadlockException(deadlock.toString(cctx.shared()));
+ }
+ catch (IgniteCheckedException e) {
+ err = e;
+
+ U.warn(log, "Failed to detect deadlock.", e);
+ }
+
+ onComplete(false, true);
+ }
+ });
+ }
+ else
+ onComplete(false, true);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/f89375bd/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticSerializableTxPrepareFuture.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/f89375bd/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFuture.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFuture.java
index 7a49422,5a300ff..0382b15
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFuture.java
@@@ -182,6 -198,33 +198,33 @@@ public class GridNearOptimisticTxPrepar
}
/**
+ * @return Keys for which {@link MiniFuture} isn't completed.
+ */
+ @SuppressWarnings("ForLoopReplaceableByForEach")
+ public Set<IgniteTxKey> requestedKeys() {
- synchronized (futs) {
- for (int i = 0; i < futs.size(); i++) {
- IgniteInternalFuture<GridNearTxPrepareResponse> fut = futs.get(i);
++ synchronized (sync) {
++ for (int i = 0; i < futuresCount(); i++) {
++ IgniteInternalFuture<GridNearTxPrepareResponse> fut = future(i);
+
+ if (isMini(fut) && !fut.isDone()) {
+ MiniFuture miniFut = (MiniFuture)fut;
+
+ Collection<IgniteTxEntry> entries = miniFut.mapping().entries();
+
+ Set<IgniteTxKey> keys = U.newHashSet(entries.size());
+
+ for (IgniteTxEntry entry : entries)
+ keys.add(entry.txKey());
+
+ return keys;
+ }
+ }
+ }
+
+ return null;
+ }
+
+ /**
* Finds pending mini future by the given mini ID.
*
* @param miniId Mini ID to find.
@@@ -623,6 -674,61 +674,61 @@@
return cur;
}
+ /**
+ *
+ */
+ @SuppressWarnings("ForLoopReplaceableByForEach")
+ private void onTimeout() {
+ if (cctx.tm().deadlockDetectionEnabled()) {
+ Set<IgniteTxKey> keys = null;
+
+ if (keyLockFut != null)
+ keys = new HashSet<>(keyLockFut.lockKeys);
+ else {
- if (futs != null && !futs.isEmpty()) {
- for (int i = 0; i < futs.size(); i++) {
- IgniteInternalFuture<GridNearTxPrepareResponse> fut = futs.get(i);
++ synchronized (sync) {
++ for (int i = 0; i < futuresCount(); i++) {
++ IgniteInternalFuture<GridNearTxPrepareResponse> fut = future(i);
+
+ if (isMini(fut) && !fut.isDone()) {
+ MiniFuture miniFut = (MiniFuture)fut;
+
+ Collection<IgniteTxEntry> entries = miniFut.mapping().entries();
+
+ keys = U.newHashSet(entries.size());
+
+ for (IgniteTxEntry entry : entries)
+ keys.add(entry.txKey());
+
+ break;
+ }
+ }
+ }
+ }
+
+ add(new GridEmbeddedFuture<>(new IgniteBiClosure<TxDeadlock, Exception, GridNearTxPrepareResponse>() {
+ @Override public GridNearTxPrepareResponse apply(TxDeadlock deadlock, Exception e) {
+ if (e != null)
+ U.warn(log, "Failed to detect deadlock.", e);
+ else {
+ e = new IgniteTxTimeoutCheckedException("Failed to acquire lock within provided timeout for " +
+ "transaction [timeout=" + tx.timeout() + ", tx=" + tx + ']',
+ deadlock != null ? new TransactionDeadlockException(deadlock.toString(cctx)) : null);
+ }
+
+ onDone(null, e);
+
+ return null;
+ }
+ }, cctx.tm().detectDeadlock(tx, keys)));
+ }
+ else {
+ ERR_UPD.compareAndSet(this, null, new IgniteTxTimeoutCheckedException("Failed to acquire lock " +
+ "within provided timeout for transaction [timeout=" + tx.timeout() + ", tx=" + tx + ']'));
+
+ onComplete(false);
+ }
+ }
+
/** {@inheritDoc} */
@Override public String toString() {
Collection<String> futs = F.viewReadOnly(futures(), new C1<IgniteInternalFuture<?>, String>() {
http://git-wip-us.apache.org/repos/asf/ignite/blob/f89375bd/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearPessimisticTxPrepareFuture.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/f89375bd/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishFuture.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/f89375bd/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
index f0af551,620d9ae..68b884c
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
@@@ -679,7 -678,7 +678,7 @@@ public class IgniteTxHandler
IgniteInternalFuture<IgniteInternalTx> fut = finish(nodeId, null, req);
-- assert req.txState() != null || fut.error() != null ||
++ assert req.txState() != null || (fut != null && fut.error() != null) ||
(ctx.tm().tx(req.version()) == null && ctx.tm().nearTx(req.version()) == null);
return fut;
http://git-wip-us.apache.org/repos/asf/ignite/blob/f89375bd/modules/core/src/main/java/org/apache/ignite/internal/util/future/GridCompoundFuture.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/internal/util/future/GridCompoundFuture.java
index b83133a,3409341..0f7e020
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/future/GridCompoundFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/future/GridCompoundFuture.java
@@@ -159,15 -154,9 +159,16 @@@ public class GridCompoundFuture<T, R> e
*
* @return Collection of futures.
*/
++ @SuppressWarnings("unchecked")
public Collection<IgniteInternalFuture<T>> futures() {
- synchronized (futs) {
- return new ArrayList<>(futs);
+ synchronized (sync) {
+ if(futs == null)
+ return Collections.emptyList();
+
+ if (futs instanceof IgniteInternalFuture)
+ return Collections.singletonList((IgniteInternalFuture<T>)futs);
+
+ return new ArrayList<>((Collection<IgniteInternalFuture<T>>)futs);
}
}
@@@ -240,8 -217,8 +241,17 @@@
}
/**
- * @return {@code True} if this future was initialized. Initialization happens when
- * {@link #markInitialized()} method is called on future.
++ * Clear futures.
++ */
++ protected void clear() {
++ synchronized (sync) {
++ futs = null;
++ }
++ }
++
++ /**
+ * @return {@code True} if this future was initialized. Initialization happens when {@link #markInitialized()}
+ * method is called on future.
*/
public boolean initialized() {
return initFlag == INIT_FLAG;
http://git-wip-us.apache.org/repos/asf/ignite/blob/f89375bd/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
----------------------------------------------------------------------
diff --cc modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
index 939e226,6bb2c11..846f6ea
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
@@@ -127,8 -127,9 +128,9 @@@ public class IgniteBasicTestSuite exten
suite.addTestSuite(GridNodeMetricsLogSelfTest.class);
suite.addTestSuite(IgniteExceptionInNioWorkerSelfTest.class);
-
+ suite.addTestSuite(IgniteLocalNodeMapBeforeStartTest.class);
suite.addTestSuite(OdbcProcessorValidationSelfTest.class);
+ suite.addTestSuite(OdbcEscapeSequenceSelfTest.class);
GridTestUtils.addTestIfNeeded(suite, DynamicProxySerializationMultiJvmSelfTest.class, ignoredTests);
[04/50] [abbrv] ignite git commit: IGNITE-3749: ODBC: Added support
for numeric scalar functions. This closes #981.
Posted by sb...@apache.org.
IGNITE-3749: ODBC: Added support for numeric scalar functions. This closes #981.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/5a3b3e2c
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/5a3b3e2c
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/5a3b3e2c
Branch: refs/heads/ignite-961
Commit: 5a3b3e2c6ecb5d6c96513b79f21828526b4a98a0
Parents: d6449ff
Author: isapego <is...@gridgain.com>
Authored: Thu Aug 25 12:35:07 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Thu Aug 25 12:35:07 2016 +0300
----------------------------------------------------------------------
modules/platforms/cpp/odbc-test/Makefile.am | 2 +
.../platforms/cpp/odbc-test/include/Makefile.am | 3 +-
.../include/sql_function_test_suite_fixture.h | 138 +++++++++
.../cpp/odbc-test/project/vs/odbc-test.vcxproj | 3 +
.../project/vs/odbc-test.vcxproj.filters | 9 +
.../src/sql_function_test_suite_fixture.cpp | 188 +++++++++++
.../src/sql_numeric_functions_test.cpp | 309 +++++++++++++++++++
.../odbc-test/src/sql_string_functions_test.cpp | 228 +-------------
.../cpp/odbc/src/config/connection_info.cpp | 7 +-
9 files changed, 659 insertions(+), 228 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/5a3b3e2c/modules/platforms/cpp/odbc-test/Makefile.am
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/Makefile.am b/modules/platforms/cpp/odbc-test/Makefile.am
index cc84a7f..62bdec3 100644
--- a/modules/platforms/cpp/odbc-test/Makefile.am
+++ b/modules/platforms/cpp/odbc-test/Makefile.am
@@ -62,7 +62,9 @@ ignite_odbc_tests_SOURCES = \
src/utility_test.cpp \
src/queries_test.cpp \
src/test_utils.cpp \
+ src/sql_function_test_suite_fixture.cpp \
src/sql_string_functions_test.cpp \
+ src/sql_numeric_functions_test.cpp \
../odbc/src/cursor.cpp \
../odbc/src/config/connection_info.cpp \
../odbc/src/app/application_data_buffer.cpp \
http://git-wip-us.apache.org/repos/asf/ignite/blob/5a3b3e2c/modules/platforms/cpp/odbc-test/include/Makefile.am
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/include/Makefile.am b/modules/platforms/cpp/odbc-test/include/Makefile.am
index 7b17102..baca1b7 100644
--- a/modules/platforms/cpp/odbc-test/include/Makefile.am
+++ b/modules/platforms/cpp/odbc-test/include/Makefile.am
@@ -20,5 +20,6 @@ ACLOCAL_AMFLAGS =-I m4
noinst_HEADERS = \
teamcity/teamcity_messages.h \
test_type.h \
- test_utils.h
+ test_utils.h \
+ sql_function_test_suite_fixture.h
http://git-wip-us.apache.org/repos/asf/ignite/blob/5a3b3e2c/modules/platforms/cpp/odbc-test/include/sql_function_test_suite_fixture.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/include/sql_function_test_suite_fixture.h b/modules/platforms/cpp/odbc-test/include/sql_function_test_suite_fixture.h
new file mode 100644
index 0000000..c09c1ae
--- /dev/null
+++ b/modules/platforms/cpp/odbc-test/include/sql_function_test_suite_fixture.h
@@ -0,0 +1,138 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_ODBC_TEST_SQL_FUNCTION_TEST_FIXTURE
+#define _IGNITE_ODBC_TEST_SQL_FUNCTION_TEST_FIXTURE
+
+#ifdef _WIN32
+# include <windows.h>
+#endif
+
+#include <sql.h>
+#include <sqlext.h>
+
+#include <string>
+
+#ifndef _MSC_VER
+# define BOOST_TEST_DYN_LINK
+#endif
+
+#include <boost/test/unit_test.hpp>
+
+#include "ignite/ignite.h"
+#include "ignite/ignition.h"
+
+#include "test_type.h"
+
+namespace ignite
+{
+ /**
+ * Test setup fixture.
+ */
+ struct SqlFunctionTestSuiteFixture
+ {
+ /**
+ * Constructor.
+ */
+ SqlFunctionTestSuiteFixture();
+
+ /**
+ * Destructor.
+ */
+ ~SqlFunctionTestSuiteFixture();
+
+ /**
+ * Run query returning single result and stores it to buffer.
+ *
+ * @param request SQL request.
+ * @param type Result type.
+ * @param column Result buffer.
+ * @param bufSize Result buffer size.
+ * @param resSize Size of received value.
+ */
+ void CheckSingleResult0(const char* request, SQLSMALLINT type,
+ void* column, SQLLEN bufSize, SQLLEN* resSize) const;
+
+ /**
+ * Run query returning single result and check it to be equal to expected.
+ *
+ * @param request SQL request.
+ * @param expected Expected result.
+ */
+ template<typename T>
+ void CheckSingleResult(const char* request, const T& expected)
+ {
+ BOOST_FAIL("Function is not defined for the type.");
+ }
+
+ /**
+ * Run query returning single result and check it to be equal to expected.
+ *
+ * @param request SQL request.
+ * @param expected Expected result.
+ * @param type Result type.
+ */
+ template<typename T>
+ void CheckSingleResultNum0(const char* request, const T& expected, SQLSMALLINT type)
+ {
+ T res = 0;
+
+ CheckSingleResult0(request, type, &res, 0, 0);
+
+ BOOST_CHECK_EQUAL(res, expected);
+ }
+
+
+ /** Node started during the test. */
+ Ignite grid;
+
+ /** Test cache instance. */
+ cache::Cache<int64_t, TestType> testCache;
+
+ /** ODBC Environment. */
+ SQLHENV env;
+
+ /** ODBC Connect. */
+ SQLHDBC dbc;
+
+ /** ODBC Statement. */
+ SQLHSTMT stmt;
+ };
+
+ template<>
+ void SqlFunctionTestSuiteFixture::CheckSingleResult<std::string>(const char* request, const std::string& expected);
+
+ template<>
+ void SqlFunctionTestSuiteFixture::CheckSingleResult<int64_t>(const char* request, const int64_t& expected);
+
+ template<>
+ void SqlFunctionTestSuiteFixture::CheckSingleResult<int32_t>(const char* request, const int32_t& expected);
+
+ template<>
+ void SqlFunctionTestSuiteFixture::CheckSingleResult<int16_t>(const char* request, const int16_t& expected);
+
+ template<>
+ void SqlFunctionTestSuiteFixture::CheckSingleResult<int8_t>(const char* request, const int8_t& expected);
+
+ template<>
+ void SqlFunctionTestSuiteFixture::CheckSingleResult<float>(const char* request, const float& expected);
+
+ template<>
+ void SqlFunctionTestSuiteFixture::CheckSingleResult<double>(const char* request, const double& expected);
+}
+
+#endif //_IGNITE_ODBC_TEST_SQL_FUNCTION_TEST_FIXTURE
http://git-wip-us.apache.org/repos/asf/ignite/blob/5a3b3e2c/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj b/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj
index 619b4b2..a83ed6b 100644
--- a/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj
+++ b/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj
@@ -168,6 +168,8 @@
<ClCompile Include="..\..\src\queries_test.cpp" />
<ClCompile Include="..\..\src\parser_test.cpp" />
<ClCompile Include="..\..\src\row_test.cpp" />
+ <ClCompile Include="..\..\src\sql_function_test_suite_fixture.cpp" />
+ <ClCompile Include="..\..\src\sql_numeric_functions_test.cpp" />
<ClCompile Include="..\..\src\sql_string_functions_test.cpp" />
<ClCompile Include="..\..\src\teamcity\teamcity_boost.cpp" />
<ClCompile Include="..\..\src\teamcity\teamcity_messages.cpp" />
@@ -175,6 +177,7 @@
<ClCompile Include="..\..\src\utility_test.cpp" />
</ItemGroup>
<ItemGroup>
+ <ClInclude Include="..\..\include\sql_function_test_suite_fixture.h" />
<ClInclude Include="..\..\include\teamcity\teamcity_messages.h" />
<ClInclude Include="..\..\include\test_type.h" />
<ClInclude Include="..\..\include\test_utils.h" />
http://git-wip-us.apache.org/repos/asf/ignite/blob/5a3b3e2c/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters b/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters
index 1871149..f993ed9 100644
--- a/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters
+++ b/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters
@@ -82,6 +82,12 @@
<ClCompile Include="..\..\src\test_utils.cpp">
<Filter>Code</Filter>
</ClCompile>
+ <ClCompile Include="..\..\src\sql_numeric_functions_test.cpp">
+ <Filter>Code</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\sql_function_test_suite_fixture.cpp">
+ <Filter>Code</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\include\test_type.h">
@@ -93,6 +99,9 @@
<ClInclude Include="..\..\include\test_utils.h">
<Filter>Code</Filter>
</ClInclude>
+ <ClInclude Include="..\..\include\sql_function_test_suite_fixture.h">
+ <Filter>Code</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\..\config\queries-test.xml">
http://git-wip-us.apache.org/repos/asf/ignite/blob/5a3b3e2c/modules/platforms/cpp/odbc-test/src/sql_function_test_suite_fixture.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/sql_function_test_suite_fixture.cpp b/modules/platforms/cpp/odbc-test/src/sql_function_test_suite_fixture.cpp
new file mode 100644
index 0000000..2398393
--- /dev/null
+++ b/modules/platforms/cpp/odbc-test/src/sql_function_test_suite_fixture.cpp
@@ -0,0 +1,188 @@
+/*
+ * 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.
+ */
+
+#include "sql_function_test_suite_fixture.h"
+
+#include "test_utils.h"
+
+namespace ignite
+{
+ SqlFunctionTestSuiteFixture::SqlFunctionTestSuiteFixture():
+ testCache(0),
+ env(NULL),
+ dbc(NULL),
+ stmt(NULL)
+ {
+ IgniteConfiguration cfg;
+
+ cfg.jvmOpts.push_back("-Xdebug");
+ cfg.jvmOpts.push_back("-Xnoagent");
+ cfg.jvmOpts.push_back("-Djava.compiler=NONE");
+ cfg.jvmOpts.push_back("-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005");
+ cfg.jvmOpts.push_back("-XX:+HeapDumpOnOutOfMemoryError");
+
+#ifdef IGNITE_TESTS_32
+ cfg.jvmInitMem = 256;
+ cfg.jvmMaxMem = 768;
+#else
+ cfg.jvmInitMem = 1024;
+ cfg.jvmMaxMem = 4096;
+#endif
+
+ char* cfgPath = getenv("IGNITE_NATIVE_TEST_ODBC_CONFIG_PATH");
+
+ BOOST_REQUIRE(cfgPath != 0) ;
+
+ cfg.springCfgPath.assign(cfgPath).append("/queries-test.xml");
+
+ IgniteError err;
+
+ grid = Ignition::Start(cfg, &err);
+
+ if (err.GetCode() != IgniteError::IGNITE_SUCCESS)
+ BOOST_FAIL(err.GetText()) ;
+
+ testCache = grid.GetCache<int64_t, TestType>("cache");
+
+ // Allocate an environment handle
+ SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env);
+
+ BOOST_REQUIRE(env != NULL) ;
+
+ // We want ODBC 3 support
+ SQLSetEnvAttr(env, SQL_ATTR_ODBC_VERSION, reinterpret_cast<void*>(SQL_OV_ODBC3), 0);
+
+ // Allocate a connection handle
+ SQLAllocHandle(SQL_HANDLE_DBC, env, &dbc);
+
+ BOOST_REQUIRE(dbc != NULL) ;
+
+ // Connect string
+ SQLCHAR connectStr[] = "DRIVER={Apache Ignite};SERVER=localhost;PORT=10800;CACHE=cache";
+
+ SQLCHAR outstr[ODBC_BUFFER_SIZE];
+ SQLSMALLINT outstrlen;
+
+ // Connecting to ODBC server.
+ SQLRETURN ret = SQLDriverConnect(dbc, NULL, connectStr, static_cast<SQLSMALLINT>(sizeof(connectStr)),
+ outstr, sizeof(outstr), &outstrlen, SQL_DRIVER_COMPLETE);
+
+ if (!SQL_SUCCEEDED(ret))
+ {
+ Ignition::Stop(grid.GetName(), true);
+
+ BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_DBC, dbc)) ;
+ }
+
+ // Allocate a statement handle
+ SQLAllocHandle(SQL_HANDLE_STMT, dbc, &stmt);
+
+ BOOST_REQUIRE(stmt != NULL) ;
+ }
+
+ SqlFunctionTestSuiteFixture::~SqlFunctionTestSuiteFixture()
+ {
+ // Releasing statement handle.
+ SQLFreeHandle(SQL_HANDLE_STMT, stmt);
+
+ // Disconneting from the server.
+ SQLDisconnect(dbc);
+
+ // Releasing allocated handles.
+ SQLFreeHandle(SQL_HANDLE_DBC, dbc);
+ SQLFreeHandle(SQL_HANDLE_ENV, env);
+
+ ignite::Ignition::Stop(grid.GetName(), true);
+ }
+
+ void SqlFunctionTestSuiteFixture::CheckSingleResult0(const char* request,
+ SQLSMALLINT type, void* column, SQLLEN bufSize, SQLLEN* resSize) const
+ {
+ SQLRETURN ret;
+
+ ret = SQLBindCol(stmt, 1, type, column, bufSize, resSize);
+
+ if (!SQL_SUCCEEDED(ret))
+ BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt)) ;
+
+ ret = SQLExecDirect(stmt, reinterpret_cast<SQLCHAR*>(const_cast<char*>(request)), SQL_NTS);
+ if (!SQL_SUCCEEDED(ret))
+ BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt)) ;
+
+ ret = SQLFetch(stmt);
+ if (!SQL_SUCCEEDED(ret))
+ BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt)) ;
+
+ ret = SQLFetch(stmt);
+ BOOST_CHECK(ret == SQL_NO_DATA) ;
+ }
+
+ template<>
+ void SqlFunctionTestSuiteFixture::CheckSingleResult<std::string>(const char* request, const std::string& expected)
+ {
+ SQLCHAR res[ODBC_BUFFER_SIZE] = { 0 };
+ SQLLEN resLen = 0;
+
+ CheckSingleResult0(request, SQL_C_CHAR, res, ODBC_BUFFER_SIZE, &resLen);
+
+ BOOST_CHECK_EQUAL(std::string(reinterpret_cast<char*>(res), static_cast<size_t>(resLen)), expected);
+ }
+
+ template<>
+ void SqlFunctionTestSuiteFixture::CheckSingleResult<int64_t>(const char* request, const int64_t& expected)
+ {
+ CheckSingleResultNum0<int64_t>(request, expected, SQL_C_SBIGINT);
+ }
+
+ template<>
+ void SqlFunctionTestSuiteFixture::CheckSingleResult<int32_t>(const char* request, const int32_t& expected)
+ {
+ CheckSingleResultNum0<int32_t>(request, expected, SQL_C_SLONG);
+ }
+
+ template<>
+ void SqlFunctionTestSuiteFixture::CheckSingleResult<int16_t>(const char* request, const int16_t& expected)
+ {
+ CheckSingleResultNum0<int16_t>(request, expected, SQL_C_SSHORT);
+ }
+
+ template<>
+ void SqlFunctionTestSuiteFixture::CheckSingleResult<int8_t>(const char* request, const int8_t& expected)
+ {
+ CheckSingleResultNum0<int8_t>(request, expected, SQL_C_STINYINT);
+ }
+
+ template<>
+ void SqlFunctionTestSuiteFixture::CheckSingleResult<float>(const char* request, const float& expected)
+ {
+ SQLFLOAT res = 0;
+
+ CheckSingleResult0(request, SQL_C_FLOAT, &res, 0, 0);
+
+ BOOST_CHECK_CLOSE(static_cast<float>(res), expected, 1E-6f);
+ }
+
+ template<>
+ void SqlFunctionTestSuiteFixture::CheckSingleResult<double>(const char* request, const double& expected)
+ {
+ SQLDOUBLE res = 0;
+
+ CheckSingleResult0(request, SQL_C_DOUBLE, &res, 0, 0);
+
+ BOOST_CHECK_CLOSE(static_cast<double>(res), expected, 1E-6);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5a3b3e2c/modules/platforms/cpp/odbc-test/src/sql_numeric_functions_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/sql_numeric_functions_test.cpp b/modules/platforms/cpp/odbc-test/src/sql_numeric_functions_test.cpp
new file mode 100644
index 0000000..80ffd83
--- /dev/null
+++ b/modules/platforms/cpp/odbc-test/src/sql_numeric_functions_test.cpp
@@ -0,0 +1,309 @@
+/*
+ * 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.
+ */
+
+#define _USE_MATH_DEFINES
+
+#ifdef _WIN32
+# include <windows.h>
+#endif
+
+#include <sql.h>
+#include <sqlext.h>
+
+#include <cmath>
+
+#include <vector>
+#include <string>
+
+#ifndef _MSC_VER
+# define BOOST_TEST_DYN_LINK
+#endif
+
+#include <boost/test/unit_test.hpp>
+
+#include "ignite/ignite.h"
+#include "ignite/ignition.h"
+#include "ignite/impl/binary/binary_utils.h"
+
+#include "test_type.h"
+#include "test_utils.h"
+#include "sql_function_test_suite_fixture.h"
+
+using namespace ignite;
+using namespace ignite::cache;
+using namespace ignite::cache::query;
+using namespace ignite::common;
+
+using namespace boost::unit_test;
+
+using ignite::impl::binary::BinaryUtils;
+
+BOOST_FIXTURE_TEST_SUITE(SqlNumericFunctionTestSuite, ignite::SqlFunctionTestSuiteFixture)
+
+BOOST_AUTO_TEST_CASE(TestNumericFunctionAbs)
+{
+ TestType in;
+
+ in.i32Field = -42;
+
+ testCache.Put(1, in);
+
+ CheckSingleResult<int32_t>("SELECT {fn ABS(i32Field)} FROM TestType", std::abs(in.i32Field));
+}
+
+BOOST_AUTO_TEST_CASE(TestNumericFunctionAcos)
+{
+ TestType in;
+
+ in.doubleField = 0.32;
+
+ testCache.Put(1, in);
+
+ CheckSingleResult<double>("SELECT {fn ACOS(doubleField)} FROM TestType", std::acos(in.doubleField));
+}
+
+BOOST_AUTO_TEST_CASE(TestNumericFunctionAsin)
+{
+ TestType in;
+
+ in.doubleField = 0.12;
+
+ testCache.Put(1, in);
+
+ CheckSingleResult<double>("SELECT {fn ASIN(doubleField)} FROM TestType", std::asin(in.doubleField));
+}
+
+BOOST_AUTO_TEST_CASE(TestNumericFunctionAtan)
+{
+ TestType in;
+
+ in.doubleField = 0.14;
+
+ testCache.Put(1, in);
+
+ CheckSingleResult<double>("SELECT {fn ATAN(doubleField)} FROM TestType", std::atan(in.doubleField));
+}
+
+BOOST_AUTO_TEST_CASE(TestNumericFunctionAtan2)
+{
+ TestType in;
+
+ in.doubleField = 0.24;
+
+ testCache.Put(1, in);
+
+ CheckSingleResult<double>("SELECT {fn ATAN2(doubleField, 0.2)} FROM TestType", std::atan2(in.doubleField, 0.2));
+}
+
+BOOST_AUTO_TEST_CASE(TestNumericFunctionCeiling)
+{
+ TestType in;
+
+ in.doubleField = 7.31;
+
+ testCache.Put(1, in);
+
+ CheckSingleResult<double>("SELECT {fn CEILING(doubleField)} FROM TestType", std::ceil(in.doubleField));
+}
+
+BOOST_AUTO_TEST_CASE(TestNumericFunctionCos)
+{
+ TestType in;
+
+ in.doubleField = 2.31;
+
+ testCache.Put(1, in);
+
+ CheckSingleResult<double>("SELECT {fn COS(doubleField)} FROM TestType", std::cos(in.doubleField));
+}
+
+BOOST_AUTO_TEST_CASE(TestNumericFunctionCot)
+{
+ TestType in;
+
+ in.doubleField = 2.31;
+
+ testCache.Put(1, in);
+
+ CheckSingleResult<double>("SELECT {fn COT(doubleField)} FROM TestType", 1 / std::tan(in.doubleField));
+}
+
+BOOST_AUTO_TEST_CASE(TestNumericFunctionDegrees)
+{
+ TestType in;
+
+ in.doubleField = 2.31;
+
+ testCache.Put(1, in);
+
+ CheckSingleResult<double>("SELECT {fn DEGREES(doubleField)} FROM TestType", in.doubleField * M_1_PI * 180);
+}
+
+BOOST_AUTO_TEST_CASE(TestNumericFunctionExp)
+{
+ TestType in;
+
+ in.doubleField = 1.23;
+
+ testCache.Put(1, in);
+
+ CheckSingleResult<double>("SELECT {fn EXP(doubleField)} FROM TestType", std::exp(in.doubleField));
+}
+
+BOOST_AUTO_TEST_CASE(TestNumericFunctionFloor)
+{
+ TestType in;
+
+ in.doubleField = 5.29;
+
+ testCache.Put(1, in);
+
+ CheckSingleResult<double>("SELECT {fn FLOOR(doubleField)} FROM TestType", std::floor(in.doubleField));
+}
+
+BOOST_AUTO_TEST_CASE(TestNumericFunctionLog)
+{
+ TestType in;
+
+ in.doubleField = 15.3;
+
+ testCache.Put(1, in);
+
+ CheckSingleResult<double>("SELECT {fn LOG(doubleField)} FROM TestType", std::log(in.doubleField));
+}
+
+BOOST_AUTO_TEST_CASE(TestNumericFunctionLog10)
+{
+ TestType in;
+
+ in.doubleField = 15.3;
+
+ testCache.Put(1, in);
+
+ CheckSingleResult<double>("SELECT {fn LOG10(doubleField)} FROM TestType", std::log10(in.doubleField));
+}
+
+BOOST_AUTO_TEST_CASE(TestNumericFunctionMod)
+{
+ TestType in;
+
+ in.i64Field = 26;
+
+ testCache.Put(1, in);
+
+ CheckSingleResult<int64_t>("SELECT {fn MOD(i64Field, 3)} FROM TestType", in.i64Field % 3);
+}
+
+BOOST_AUTO_TEST_CASE(TestNumericFunctionPi)
+{
+ CheckSingleResult<double>("SELECT {fn PI()}", M_PI);
+}
+
+BOOST_AUTO_TEST_CASE(TestNumericFunctionPower)
+{
+ TestType in;
+
+ in.doubleField = 1.81;
+
+ testCache.Put(1, in);
+
+ CheckSingleResult<double>("SELECT {fn POWER(doubleField, 2.5)} FROM TestType", std::pow(in.doubleField, 2.5));
+}
+
+BOOST_AUTO_TEST_CASE(TestNumericFunctionRadians)
+{
+ TestType in;
+
+ in.doubleField = 161;
+
+ testCache.Put(1, in);
+
+ CheckSingleResult<double>("SELECT {fn RADIANS(doubleField)} FROM TestType", in.doubleField * M_PI / 180.0);
+}
+
+BOOST_AUTO_TEST_CASE(TestNumericFunctionRand)
+{
+ CheckSingleResult<double>("SELECT {fn RAND()} * 0", 0);
+}
+
+BOOST_AUTO_TEST_CASE(TestNumericFunctionRound)
+{
+ TestType in;
+
+ in.doubleField = 5.29;
+
+ testCache.Put(1, in);
+
+ CheckSingleResult<double>("SELECT {fn ROUND(doubleField)} FROM TestType", std::floor(in.doubleField));
+}
+
+BOOST_AUTO_TEST_CASE(TestNumericFunctionSign)
+{
+ TestType in;
+
+ in.doubleField = -1.39;
+
+ testCache.Put(1, in);
+
+ CheckSingleResult<double>("SELECT {fn SIGN(doubleField)} FROM TestType", in.doubleField < 0 ? -1 : in.doubleField == 0 ? 0 : 1);
+}
+
+BOOST_AUTO_TEST_CASE(TestNumericFunctionSin)
+{
+ TestType in;
+
+ in.doubleField = 1.01;
+
+ testCache.Put(1, in);
+
+ CheckSingleResult<double>("SELECT {fn SIN(doubleField)} FROM TestType", std::sin(in.doubleField));
+}
+
+BOOST_AUTO_TEST_CASE(TestNumericFunctionSqrt)
+{
+ TestType in;
+
+ in.doubleField = 2.56;
+
+ testCache.Put(1, in);
+
+ CheckSingleResult<double>("SELECT {fn SQRT(doubleField)} FROM TestType", std::sqrt(in.doubleField));
+}
+
+BOOST_AUTO_TEST_CASE(TestNumericFunctionTan)
+{
+ TestType in;
+
+ in.doubleField = 0.56;
+
+ testCache.Put(1, in);
+
+ CheckSingleResult<double>("SELECT {fn TAN(doubleField)} FROM TestType", std::tan(in.doubleField));
+}
+
+BOOST_AUTO_TEST_CASE(TestNumericFunctionTruncate)
+{
+ TestType in;
+
+ in.doubleField = 4.17133;
+
+ testCache.Put(1, in);
+
+ CheckSingleResult<double>("SELECT {fn TRUNCATE(doubleField, 3)} FROM TestType", 4.171);
+}
+
+BOOST_AUTO_TEST_SUITE_END()
http://git-wip-us.apache.org/repos/asf/ignite/blob/5a3b3e2c/modules/platforms/cpp/odbc-test/src/sql_string_functions_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/sql_string_functions_test.cpp b/modules/platforms/cpp/odbc-test/src/sql_string_functions_test.cpp
index e84aba6..d22bb83 100644
--- a/modules/platforms/cpp/odbc-test/src/sql_string_functions_test.cpp
+++ b/modules/platforms/cpp/odbc-test/src/sql_string_functions_test.cpp
@@ -15,8 +15,6 @@
* limitations under the License.
*/
-#define _USE_MATH_DEFINES
-
#ifdef _WIN32
# include <windows.h>
#endif
@@ -24,8 +22,6 @@
#include <sql.h>
#include <sqlext.h>
-#include <cmath>
-
#include <vector>
#include <string>
@@ -41,6 +37,7 @@
#include "test_type.h"
#include "test_utils.h"
+#include "sql_function_test_suite_fixture.h"
using namespace ignite;
using namespace ignite::cache;
@@ -51,228 +48,7 @@ using namespace boost::unit_test;
using ignite::impl::binary::BinaryUtils;
-/**
- * Test setup fixture.
- */
-struct SqlStringFunctionTestSuiteFixture
-{
- /**
- * Constructor.
- */
- SqlStringFunctionTestSuiteFixture() :
- testCache(0),
- env(NULL),
- dbc(NULL),
- stmt(NULL)
- {
- IgniteConfiguration cfg;
-
- cfg.jvmOpts.push_back("-Xdebug");
- cfg.jvmOpts.push_back("-Xnoagent");
- cfg.jvmOpts.push_back("-Djava.compiler=NONE");
- cfg.jvmOpts.push_back("-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005");
- cfg.jvmOpts.push_back("-XX:+HeapDumpOnOutOfMemoryError");
-
-#ifdef IGNITE_TESTS_32
- cfg.jvmInitMem = 256;
- cfg.jvmMaxMem = 768;
-#else
- cfg.jvmInitMem = 1024;
- cfg.jvmMaxMem = 4096;
-#endif
-
- char* cfgPath = getenv("IGNITE_NATIVE_TEST_ODBC_CONFIG_PATH");
-
- BOOST_REQUIRE(cfgPath != 0);
-
- cfg.springCfgPath.assign(cfgPath).append("/queries-test.xml");
-
- IgniteError err;
-
- grid = Ignition::Start(cfg, &err);
-
- if (err.GetCode() != IgniteError::IGNITE_SUCCESS)
- BOOST_FAIL(err.GetText());
-
- testCache = grid.GetCache<int64_t, TestType>("cache");
-
- // Allocate an environment handle
- SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env);
-
- BOOST_REQUIRE(env != NULL);
-
- // We want ODBC 3 support
- SQLSetEnvAttr(env, SQL_ATTR_ODBC_VERSION, reinterpret_cast<void*>(SQL_OV_ODBC3), 0);
-
- // Allocate a connection handle
- SQLAllocHandle(SQL_HANDLE_DBC, env, &dbc);
-
- BOOST_REQUIRE(dbc != NULL);
-
- // Connect string
- SQLCHAR connectStr[] = "DRIVER={Apache Ignite};SERVER=localhost;PORT=10800;CACHE=cache";
-
- SQLCHAR outstr[ODBC_BUFFER_SIZE];
- SQLSMALLINT outstrlen;
-
- // Connecting to ODBC server.
- SQLRETURN ret = SQLDriverConnect(dbc, NULL, connectStr, static_cast<SQLSMALLINT>(sizeof(connectStr)),
- outstr, sizeof(outstr), &outstrlen, SQL_DRIVER_COMPLETE);
-
- if (!SQL_SUCCEEDED(ret))
- {
- Ignition::Stop(grid.GetName(), true);
-
- BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_DBC, dbc));
- }
-
- // Allocate a statement handle
- SQLAllocHandle(SQL_HANDLE_STMT, dbc, &stmt);
-
- BOOST_REQUIRE(stmt != NULL);
- }
-
- /**
- * Destructor.
- */
- ~SqlStringFunctionTestSuiteFixture()
- {
- // Releasing statement handle.
- SQLFreeHandle(SQL_HANDLE_STMT, stmt);
-
- // Disconneting from the server.
- SQLDisconnect(dbc);
-
- // Releasing allocated handles.
- SQLFreeHandle(SQL_HANDLE_DBC, dbc);
- SQLFreeHandle(SQL_HANDLE_ENV, env);
-
- Ignition::Stop(grid.GetName(), true);
- }
-
- void CheckSingleResult0(const char* request, SQLSMALLINT type, void* column, SQLLEN bufSize, SQLLEN* resSize)
- {
- SQLRETURN ret;
-
- ret = SQLBindCol(stmt, 1, type, column, bufSize, resSize);
-
- if (!SQL_SUCCEEDED(ret))
- BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt));
-
- ret = SQLExecDirect(stmt, reinterpret_cast<SQLCHAR*>(const_cast<char*>(request)), SQL_NTS);
- if (!SQL_SUCCEEDED(ret))
- BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt));
-
- ret = SQLFetch(stmt);
- if (!SQL_SUCCEEDED(ret))
- BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt));
-
- ret = SQLFetch(stmt);
- BOOST_CHECK(ret == SQL_NO_DATA);
- }
-
- /**
- * Run query returning single result and check it to be equal to expected.
- *
- * @param request SQL request.
- * @param expected Expected result.
- */
- template<typename T>
- void CheckSingleResult(const char* request, const T& expected)
- {
- BOOST_FAIL("Function is not defined for the type.");
- }
-
- /**
- * Run query returning single result and check it to be equal to expected.
- *
- * @param request SQL request.
- * @param expected Expected result.
- * @param type Result type.
- */
- template<typename T>
- void CheckSingleResultNum0(const char* request, const T& expected, SQLSMALLINT type)
- {
- T res = 0;
-
- CheckSingleResult0(request, type, &res, 0, 0);
-
- BOOST_CHECK_EQUAL(res, expected);
- }
-
-
- /** Node started during the test. */
- Ignite grid;
-
- /** Test cache instance. */
- Cache<int64_t, TestType> testCache;
-
- /** ODBC Environment. */
- SQLHENV env;
-
- /** ODBC Connect. */
- SQLHDBC dbc;
-
- /** ODBC Statement. */
- SQLHSTMT stmt;
-};
-
-template<>
-void SqlStringFunctionTestSuiteFixture::CheckSingleResult<std::string>(const char* request, const std::string& expected)
-{
- SQLCHAR res[ODBC_BUFFER_SIZE] = { 0 };
- SQLLEN resLen = 0;
-
- CheckSingleResult0(request, SQL_C_CHAR, res, ODBC_BUFFER_SIZE, &resLen);
-
- BOOST_CHECK_EQUAL(std::string(reinterpret_cast<char*>(res), static_cast<size_t>(resLen)), expected);
-}
-
-template<>
-void SqlStringFunctionTestSuiteFixture::CheckSingleResult<int64_t>(const char* request, const int64_t& expected)
-{
- CheckSingleResultNum0<int64_t>(request, expected, SQL_C_SBIGINT);
-}
-
-template<>
-void SqlStringFunctionTestSuiteFixture::CheckSingleResult<int32_t>(const char* request, const int32_t& expected)
-{
- CheckSingleResultNum0<int32_t>(request, expected, SQL_C_SLONG);
-}
-
-template<>
-void SqlStringFunctionTestSuiteFixture::CheckSingleResult<int16_t>(const char* request, const int16_t& expected)
-{
- CheckSingleResultNum0<int16_t>(request, expected, SQL_C_SSHORT);
-}
-
-template<>
-void SqlStringFunctionTestSuiteFixture::CheckSingleResult<int8_t>(const char* request, const int8_t& expected)
-{
- CheckSingleResultNum0<int8_t>(request, expected, SQL_C_STINYINT);
-}
-
-template<>
-void SqlStringFunctionTestSuiteFixture::CheckSingleResult<float>(const char* request, const float& expected)
-{
- SQLFLOAT res = 0;
-
- CheckSingleResult0(request, SQL_C_FLOAT, &res, 0, 0);
-
- BOOST_CHECK_CLOSE(static_cast<float>(res), expected, 1E-6f);
-}
-
-template<>
-void SqlStringFunctionTestSuiteFixture::CheckSingleResult<double>(const char* request, const double& expected)
-{
- SQLDOUBLE res = 0;
-
- CheckSingleResult0(request, SQL_C_DOUBLE, &res, 0, 0);
-
- BOOST_CHECK_CLOSE(static_cast<double>(res), expected, 1E-6);
-}
-
-BOOST_FIXTURE_TEST_SUITE(SqlStringFunctionTestSuite, SqlStringFunctionTestSuiteFixture)
+BOOST_FIXTURE_TEST_SUITE(SqlStringFunctionTestSuite, ignite::SqlFunctionTestSuiteFixture)
BOOST_AUTO_TEST_CASE(TestStringFunctionAscii)
{
http://git-wip-us.apache.org/repos/asf/ignite/blob/5a3b3e2c/modules/platforms/cpp/odbc/src/config/connection_info.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/config/connection_info.cpp b/modules/platforms/cpp/odbc/src/config/connection_info.cpp
index f9a3f96..1fed7c5 100644
--- a/modules/platforms/cpp/odbc/src/config/connection_info.cpp
+++ b/modules/platforms/cpp/odbc/src/config/connection_info.cpp
@@ -233,7 +233,12 @@ namespace ignite
#ifdef SQL_NUMERIC_FUNCTIONS
// Bitmask enumerating the scalar numeric functions supported by
// the driver and associated data source.
- intParams[SQL_NUMERIC_FUNCTIONS] = SQL_FN_NUM_ABS;
+ intParams[SQL_NUMERIC_FUNCTIONS] = SQL_FN_NUM_ABS | SQL_FN_NUM_ACOS | SQL_FN_NUM_ASIN |
+ SQL_FN_NUM_ATAN | SQL_FN_NUM_ATAN2 | SQL_FN_NUM_CEILING | SQL_FN_NUM_COS | SQL_FN_NUM_COT |
+ SQL_FN_NUM_EXP | SQL_FN_NUM_FLOOR | SQL_FN_NUM_LOG | SQL_FN_NUM_MOD | SQL_FN_NUM_SIGN |
+ SQL_FN_NUM_SIN | SQL_FN_NUM_SQRT | SQL_FN_NUM_TAN | SQL_FN_NUM_PI | SQL_FN_NUM_RAND |
+ SQL_FN_NUM_DEGREES | SQL_FN_NUM_LOG10 | SQL_FN_NUM_POWER | SQL_FN_NUM_RADIANS | SQL_FN_NUM_ROUND |
+ SQL_FN_NUM_TRUNCATE;
#endif // SQL_NUMERIC_FUNCTIONS
#ifdef SQL_STRING_FUNCTIONS
[29/50] [abbrv] ignite git commit: ignite-2560 Support resource
injection for entry processor, optimizations for resource injection.
Posted by sb...@apache.org.
ignite-2560 Support resource injection for entry processor, optimizations for resource injection.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/f9ff97c9
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/f9ff97c9
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/f9ff97c9
Branch: refs/heads/ignite-961
Commit: f9ff97c91374dcd9cd8ad08d46d1d2de44193060
Parents: 407071e
Author: Andrey V. Mashenkov <an...@gmail.com>
Authored: Tue Aug 30 09:31:20 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Tue Aug 30 09:32:23 2016 +0300
----------------------------------------------------------------------
.../processors/cache/CacheLazyEntry.java | 2 +
.../EntryProcessorResourceInjectorProxy.java | 105 +++++
.../processors/cache/GridCacheMapEntry.java | 13 +-
.../GridNearAtomicSingleUpdateFuture.java | 17 +-
.../dht/atomic/GridNearAtomicUpdateFuture.java | 8 +-
.../local/atomic/GridLocalAtomicCache.java | 18 +-
.../transactions/IgniteTxLocalAdapter.java | 5 +-
.../processors/resource/GridResourceIoc.java | 438 +++++++++++++++----
.../resource/GridResourceProcessor.java | 396 +++++++----------
.../cache/GridCacheAbstractFullApiSelfTest.java | 404 +++++++++++++++--
.../cache/GridCacheAbstractSelfTest.java | 140 +++++-
.../GridCacheTransformEventSelfTest.java | 66 ++-
...ePartitionedBasicStoreMultiNodeSelfTest.java | 2 +
.../GridTransformSpringInjectionSelfTest.java | 186 ++++++++
.../testsuites/IgniteSpringTestSuite.java | 7 +-
.../IgniteInvokeWithInjectionBenchmark.java | 74 ++++
.../IgniteInvokeWithInjectionTxBenchmark.java | 30 ++
17 files changed, 1515 insertions(+), 396 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/f9ff97c9/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLazyEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLazyEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLazyEntry.java
index c8cfc99..02cccc7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLazyEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLazyEntry.java
@@ -191,6 +191,8 @@ public class CacheLazyEntry<K, V> extends CacheInterceptorEntry<K, V> {
@Override public <T> T unwrap(Class<T> cls) {
if (cls.isAssignableFrom(Ignite.class))
return (T)cctx.kernalContext().grid();
+ else if (cls.isAssignableFrom(GridCacheContext.class))
+ return (T)cctx;
else if (cls.isAssignableFrom(getClass()))
return cls.cast(this);
http://git-wip-us.apache.org/repos/asf/ignite/blob/f9ff97c9/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/EntryProcessorResourceInjectorProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/EntryProcessorResourceInjectorProxy.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/EntryProcessorResourceInjectorProxy.java
new file mode 100644
index 0000000..76b2511
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/EntryProcessorResourceInjectorProxy.java
@@ -0,0 +1,105 @@
+/*
+ * 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 java.io.Serializable;
+import javax.cache.processor.EntryProcessor;
+import javax.cache.processor.EntryProcessorException;
+import javax.cache.processor.MutableEntry;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.internal.GridKernalContext;
+import org.apache.ignite.internal.processors.resource.GridResourceIoc;
+import org.apache.ignite.internal.processors.resource.GridResourceProcessor;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Entry processor wrapper injecting Ignite resources into target processor before execution.
+ */
+public class EntryProcessorResourceInjectorProxy<K, V, T> implements EntryProcessor<K, V, T>, Serializable {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** Delegate. */
+ private EntryProcessor<K, V, T> delegate;
+
+ /** Injected flag. */
+ private transient boolean injected;
+
+ /**
+ * @param delegate Delegate.
+ */
+ private EntryProcessorResourceInjectorProxy(EntryProcessor<K, V, T> delegate) {
+ this.delegate = delegate;
+ }
+
+ /** {@inheritDoc} */
+ @Override public T process(MutableEntry<K, V> entry, Object... arguments) throws EntryProcessorException {
+ if (!injected) {
+ GridCacheContext cctx = entry.unwrap(GridCacheContext.class);
+
+ GridResourceProcessor rsrc = cctx.kernalContext().resource();
+
+ try {
+ rsrc.inject(delegate, GridResourceIoc.AnnotationSet.ENTRY_PROCESSOR, cctx.name());
+ }
+ catch (IgniteCheckedException e) {
+ throw new IgniteException(e);
+ }
+
+ injected = true;
+ }
+
+ return delegate.process(entry, arguments);
+ }
+
+ /**
+ * @return Delegate entry processor.
+ */
+ public EntryProcessor<K, V, T> delegate() {
+ return delegate;
+ }
+
+ /**
+ * Wraps EntryProcessor if needed.
+ *
+ * @param ctx Context.
+ * @param proc Entry proc.
+ * @return Wrapped entry proc if wrapping is needed.
+ */
+ public static <K, V, T> EntryProcessor<K, V, T> wrap(GridKernalContext ctx,
+ @Nullable EntryProcessor<K, V, T> proc) {
+ if (proc == null || proc instanceof EntryProcessorResourceInjectorProxy)
+ return proc;
+
+ GridResourceProcessor rsrcProcessor = ctx.resource();
+
+ return rsrcProcessor.isAnnotationsPresent(null, proc, GridResourceIoc.AnnotationSet.ENTRY_PROCESSOR) ?
+ new EntryProcessorResourceInjectorProxy<>(proc) : proc;
+ }
+
+ /**
+ * Unwraps EntryProcessor as Object if needed.
+ *
+ * @param obj Entry processor.
+ * @return Unwrapped entry processor.
+ */
+ static Object unwrap(Object obj) {
+ return (obj instanceof EntryProcessorResourceInjectorProxy) ? ((EntryProcessorResourceInjectorProxy)obj).delegate() : obj;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/f9ff97c9/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
index f692bf4..c760ac1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
@@ -896,6 +896,8 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
}
if (evt && cctx.events().isRecordable(EVT_CACHE_OBJECT_READ)) {
+ transformClo = EntryProcessorResourceInjectorProxy.unwrap(transformClo);
+
cctx.events().addEvent(
partition(),
key,
@@ -1004,7 +1006,9 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
deletedUnlocked(false);
}
- if (evt && cctx.events().isRecordable(EVT_CACHE_OBJECT_READ))
+ if (evt && cctx.events().isRecordable(EVT_CACHE_OBJECT_READ)) {
+ transformClo = EntryProcessorResourceInjectorProxy.unwrap(transformClo);
+
cctx.events().addEvent(
partition(),
key,
@@ -1019,6 +1023,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
transformClo != null ? transformClo.getClass().getName() : null,
taskName,
keepBinary);
+ }
}
}
@@ -1685,7 +1690,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
// Calculate new value.
if (op == GridCacheOperation.TRANSFORM) {
- transformCloClsName = writeObj.getClass().getName();
+ transformCloClsName = EntryProcessorResourceInjectorProxy.unwrap(writeObj).getClass().getName();
EntryProcessor<Object, Object, ?> entryProcessor = (EntryProcessor<Object, Object, ?>)writeObj;
@@ -2463,6 +2468,8 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
if (transformClo != null && cctx.events().isRecordable(EVT_CACHE_OBJECT_READ)) {
evtOld = cctx.unwrapTemporary(oldVal);
+ transformClo = EntryProcessorResourceInjectorProxy.unwrap(transformClo);
+
cctx.events().addEvent(partition(), key, evtNodeId, null,
newVer, EVT_CACHE_OBJECT_READ, evtOld, evtOld != null || hadVal, evtOld,
evtOld != null || hadVal, subjId, transformClo.getClass().getName(), taskName,
@@ -2553,6 +2560,8 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
if (transformClo != null && cctx.events().isRecordable(EVT_CACHE_OBJECT_READ)) {
evtOld = cctx.unwrapTemporary(oldVal);
+ transformClo = EntryProcessorResourceInjectorProxy.unwrap(transformClo);
+
cctx.events().addEvent(partition(), key, evtNodeId, null,
newVer, EVT_CACHE_OBJECT_READ, evtOld, evtOld != null || hadVal, evtOld,
evtOld != null || hadVal, subjId, transformClo.getClass().getName(), taskName,
http://git-wip-us.apache.org/repos/asf/ignite/blob/f9ff97c9/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFuture.java
index 661a178..256c7ac 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFuture.java
@@ -17,6 +17,13 @@
package org.apache.ignite.internal.processors.cache.distributed.dht.atomic;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+import java.util.UUID;
+import javax.cache.expiry.ExpiryPolicy;
+import javax.cache.processor.EntryProcessor;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.cache.CacheWriteSynchronizationMode;
import org.apache.ignite.cluster.ClusterNode;
@@ -26,6 +33,7 @@ import org.apache.ignite.internal.cluster.ClusterTopologyServerNotFoundException
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
import org.apache.ignite.internal.processors.cache.CacheEntryPredicate;
import org.apache.ignite.internal.processors.cache.CachePartialUpdateCheckedException;
+import org.apache.ignite.internal.processors.cache.EntryProcessorResourceInjectorProxy;
import org.apache.ignite.internal.processors.cache.GridCacheContext;
import org.apache.ignite.internal.processors.cache.GridCacheOperation;
import org.apache.ignite.internal.processors.cache.GridCacheReturn;
@@ -43,13 +51,6 @@ import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.jetbrains.annotations.Nullable;
-import javax.cache.expiry.ExpiryPolicy;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Map;
-import java.util.UUID;
-
import static org.apache.ignite.cache.CacheAtomicWriteOrderMode.CLOCK;
import static org.apache.ignite.internal.processors.cache.GridCacheOperation.TRANSFORM;
@@ -549,6 +550,8 @@ public class GridNearAtomicSingleUpdateFuture extends GridNearAtomicAbstractUpda
if (op != TRANSFORM)
val = cctx.toCacheObject(val);
+ else
+ val = EntryProcessorResourceInjectorProxy.wrap(cctx.kernalContext(), (EntryProcessor)val);
ClusterNode primary = cctx.affinity().primary(cacheKey, topVer);
http://git-wip-us.apache.org/repos/asf/ignite/blob/f9ff97c9/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java
index 2432f63..30a0c3d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java
@@ -25,6 +25,7 @@ import java.util.List;
import java.util.Map;
import java.util.UUID;
import javax.cache.expiry.ExpiryPolicy;
+import javax.cache.processor.EntryProcessor;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.cache.CacheWriteSynchronizationMode;
import org.apache.ignite.cluster.ClusterNode;
@@ -34,6 +35,7 @@ import org.apache.ignite.internal.cluster.ClusterTopologyServerNotFoundException
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
import org.apache.ignite.internal.processors.cache.CacheEntryPredicate;
import org.apache.ignite.internal.processors.cache.CachePartialUpdateCheckedException;
+import org.apache.ignite.internal.processors.cache.EntryProcessorResourceInjectorProxy;
import org.apache.ignite.internal.processors.cache.GridCacheAffinityManager;
import org.apache.ignite.internal.processors.cache.GridCacheContext;
import org.apache.ignite.internal.processors.cache.GridCacheOperation;
@@ -800,7 +802,7 @@ public class GridNearAtomicUpdateFuture extends GridNearAtomicAbstractUpdateFutu
val = conflictPutVal.valueEx();
conflictVer = conflictPutVal.version();
- conflictTtl = conflictPutVal.ttl();
+ conflictTtl = conflictPutVal.ttl();
conflictExpireTime = conflictPutVal.expireTime();
}
else if (conflictRmvVals != null) {
@@ -826,6 +828,8 @@ public class GridNearAtomicUpdateFuture extends GridNearAtomicAbstractUpdateFutu
if (op != TRANSFORM)
val = cctx.toCacheObject(val);
+ else
+ val = EntryProcessorResourceInjectorProxy.wrap(cctx.kernalContext(), (EntryProcessor)val);
List<ClusterNode> affNodes = mapKey(cacheKey, topVer);
@@ -940,6 +944,8 @@ public class GridNearAtomicUpdateFuture extends GridNearAtomicAbstractUpdateFutu
if (op != TRANSFORM)
val = cctx.toCacheObject(val);
+ else
+ val = EntryProcessorResourceInjectorProxy.wrap(cctx.kernalContext(), (EntryProcessor)val);
ClusterNode primary = cctx.affinity().primary(cacheKey.partition(), topVer);
http://git-wip-us.apache.org/repos/asf/ignite/blob/f9ff97c9/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
index ac08f8f..a419887 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
@@ -57,6 +57,8 @@ import org.apache.ignite.internal.processors.cache.KeyCacheObject;
import org.apache.ignite.internal.processors.cache.local.GridLocalCache;
import org.apache.ignite.internal.processors.cache.transactions.IgniteTxLocalEx;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
+import org.apache.ignite.internal.processors.resource.GridResourceIoc;
+import org.apache.ignite.internal.processors.resource.GridResourceProcessor;
import org.apache.ignite.internal.util.F0;
import org.apache.ignite.internal.util.GridUnsafe;
import org.apache.ignite.internal.util.future.GridEmbeddedFuture;
@@ -432,7 +434,6 @@ public class GridLocalAtomicCache<K, V> extends GridLocalCache<K, V> {
needVer);
}
-
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override public IgniteInternalFuture<Map<K, V>> getAllAsync(
@@ -511,7 +512,7 @@ public class GridLocalAtomicCache<K, V> extends GridLocalCache<K, V> {
entry = swapOrOffheap ? entryEx(cacheKey) : peekEx(cacheKey);
if (entry != null) {
- CacheObject v ;
+ CacheObject v;
GridCacheVersion ver;
if (needVer) {
@@ -541,7 +542,8 @@ public class GridLocalAtomicCache<K, V> extends GridLocalCache<K, V> {
deserializeBinary,
true,
ver);
- }else
+ }
+ else
success = false;
}
else {
@@ -944,6 +946,8 @@ public class GridLocalAtomicCache<K, V> extends GridLocalCache<K, V> {
if (op == UPDATE)
val = ctx.toCacheObject(val);
+ else if (op == TRANSFORM)
+ ctx.kernalContext().resource().inject(val, GridResourceIoc.AnnotationSet.ENTRY_PROCESSOR, ctx.name());
while (true) {
GridCacheEntryEx entry = null;
@@ -1014,7 +1018,7 @@ public class GridLocalAtomicCache<K, V> extends GridLocalCache<K, V> {
if (err != null)
throw err;
- Object ret = res == null ? null : rawRetval ? new GridCacheReturn(ctx, true, keepBinary, res.get2(), res.get1()) :
+ Object ret = res == null ? null : rawRetval ? new GridCacheReturn(ctx, true, keepBinary, res.get2(), res.get1()) :
(retval || op == TRANSFORM) ? res.get2() : res.get1();
if (op == TRANSFORM && ret == null)
@@ -1035,8 +1039,8 @@ public class GridLocalAtomicCache<K, V> extends GridLocalCache<K, V> {
* @param filter Optional filter.
* @param subjId Subject ID.
* @param taskName Task name.
- * @throws CachePartialUpdateCheckedException If update failed.
* @return Results map for invoke operation.
+ * @throws CachePartialUpdateCheckedException If update failed.
*/
@SuppressWarnings({"ForLoopReplaceableByForEach", "unchecked"})
private Map<K, EntryProcessorResult> updateWithBatch(
@@ -1101,6 +1105,10 @@ public class GridLocalAtomicCache<K, V> extends GridLocalCache<K, V> {
}
if (op == TRANSFORM) {
+ ctx.kernalContext().resource().inject(val,
+ GridResourceIoc.AnnotationSet.ENTRY_PROCESSOR,
+ ctx.name());
+
EntryProcessor<Object, Object, Object> entryProcessor =
(EntryProcessor<Object, Object, Object>)val;
http://git-wip-us.apache.org/repos/asf/ignite/blob/f9ff97c9/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
index 9ad7fb0..ee992cc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
@@ -43,6 +43,7 @@ import org.apache.ignite.internal.processors.cache.CacheEntryPredicate;
import org.apache.ignite.internal.processors.cache.CacheInvokeEntry;
import org.apache.ignite.internal.processors.cache.CacheObject;
import org.apache.ignite.internal.processors.cache.CacheOperationContext;
+import org.apache.ignite.internal.processors.cache.EntryProcessorResourceInjectorProxy;
import org.apache.ignite.internal.processors.cache.GridCacheContext;
import org.apache.ignite.internal.processors.cache.GridCacheEntryEx;
import org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedException;
@@ -65,7 +66,6 @@ import org.apache.ignite.internal.processors.dr.GridDrType;
import org.apache.ignite.internal.transactions.IgniteTxHeuristicCheckedException;
import org.apache.ignite.internal.transactions.IgniteTxRollbackCheckedException;
import org.apache.ignite.internal.transactions.IgniteTxTimeoutCheckedException;
-import org.apache.ignite.transactions.TransactionDeadlockException;
import org.apache.ignite.internal.util.GridLeanMap;
import org.apache.ignite.internal.util.future.GridEmbeddedFuture;
import org.apache.ignite.internal.util.future.GridFinishedFuture;
@@ -89,6 +89,7 @@ import org.apache.ignite.lang.IgniteBiTuple;
import org.apache.ignite.lang.IgniteClosure;
import org.apache.ignite.plugin.security.SecurityPermission;
import org.apache.ignite.transactions.TransactionConcurrency;
+import org.apache.ignite.transactions.TransactionDeadlockException;
import org.apache.ignite.transactions.TransactionIsolation;
import org.apache.ignite.transactions.TransactionState;
import org.jetbrains.annotations.Nullable;
@@ -3664,7 +3665,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
this,
op,
val,
- entryProcessor,
+ EntryProcessorResourceInjectorProxy.wrap(cctx.kernalContext(), entryProcessor),
invokeArgs,
hasDrTtl ? drTtl : -1L,
entry,
http://git-wip-us.apache.org/repos/asf/ignite/blob/f9ff97c9/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceIoc.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceIoc.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceIoc.java
index 35824fa..0158973 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceIoc.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceIoc.java
@@ -21,12 +21,12 @@ import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.atomic.AtomicReference;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.managers.deployment.GridDeployment;
import org.apache.ignite.internal.util.GridLeanIdentitySet;
@@ -35,6 +35,17 @@ import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.T2;
import org.apache.ignite.internal.util.typedef.X;
import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.resources.CacheNameResource;
+import org.apache.ignite.resources.CacheStoreSessionResource;
+import org.apache.ignite.resources.IgniteInstanceResource;
+import org.apache.ignite.resources.JobContextResource;
+import org.apache.ignite.resources.LoadBalancerResource;
+import org.apache.ignite.resources.LoggerResource;
+import org.apache.ignite.resources.ServiceResource;
+import org.apache.ignite.resources.SpringApplicationContextResource;
+import org.apache.ignite.resources.SpringResource;
+import org.apache.ignite.resources.TaskContinuousMapperResource;
+import org.apache.ignite.resources.TaskSessionResource;
import org.jetbrains.annotations.Nullable;
import org.jsr166.ConcurrentHashMap8;
@@ -42,17 +53,12 @@ import org.jsr166.ConcurrentHashMap8;
* Resource container contains caches for classes used for injection.
* Caches used to improve the efficiency of standard Java reflection mechanism.
*/
-class GridResourceIoc {
+public class GridResourceIoc {
/** Task class resource mapping. Used to efficiently cleanup resources related to class loader. */
- private final ConcurrentMap<ClassLoader, Set<Class<?>>> taskMap =
- new ConcurrentHashMap8<>();
+ private final ConcurrentMap<ClassLoader, Set<Class<?>>> taskMap = new ConcurrentHashMap8<>();
/** Class descriptors cache. */
- private final ConcurrentMap<Class<?>, ClassDescriptor> clsDescs = new ConcurrentHashMap8<>();
-
- /** */
- private final ConcurrentMap<Class<?>, Class<? extends Annotation>[]> annCache =
- new ConcurrentHashMap8<>();
+ private AtomicReference<Map<Class<?>, ClassDescriptor>> clsDescs = new AtomicReference<>();
/**
* @param ldr Class loader.
@@ -61,8 +67,22 @@ class GridResourceIoc {
Set<Class<?>> clss = taskMap.remove(ldr);
if (clss != null) {
- clsDescs.keySet().removeAll(clss);
- annCache.keySet().removeAll(clss);
+ Map<Class<?>, ClassDescriptor> newMap, oldMap;
+
+ do {
+ oldMap = clsDescs.get();
+
+ if (oldMap == null)
+ break;
+
+ newMap = new HashMap<>(oldMap.size() - clss.size());
+
+ for (Map.Entry<Class<?>, ClassDescriptor> entry : oldMap.entrySet()) {
+ if (!clss.contains(entry.getKey()))
+ newMap.put(entry.getKey(), entry.getValue());
+ }
+ }
+ while (!clsDescs.compareAndSet(oldMap, newMap));
}
}
@@ -71,8 +91,8 @@ class GridResourceIoc {
*/
void undeployAll() {
taskMap.clear();
- clsDescs.clear();
- annCache.clear();
+
+ clsDescs.set(null);
}
/**
@@ -83,8 +103,8 @@ class GridResourceIoc {
* @param injector Resource to inject.
* @param dep Deployment.
* @param depCls Deployment class.
- * @throws IgniteCheckedException Thrown in case of any errors during injection.
* @return {@code True} if resource was injected.
+ * @throws IgniteCheckedException Thrown in case of any errors during injection.
*/
@SuppressWarnings("SimplifiableIfStatement")
boolean inject(Object target,
@@ -92,26 +112,41 @@ class GridResourceIoc {
GridResourceInjector injector,
@Nullable GridDeployment dep,
@Nullable Class<?> depCls)
- throws IgniteCheckedException
- {
+ throws IgniteCheckedException {
return injectInternal(target, annCls, injector, dep, depCls, null);
}
/**
+ * @param dep Deployment.
* @param cls Class.
+ * @return Descriptor.
*/
- private ClassDescriptor descriptor(@Nullable GridDeployment dep, Class<?> cls) {
- ClassDescriptor res = clsDescs.get(cls);
+ ClassDescriptor descriptor(@Nullable GridDeployment dep, Class<?> cls) {
+ Map<Class<?>, ClassDescriptor> newMap, oldMap;
+ ClassDescriptor res, newDesc = null;
+
+ do {
+ oldMap = clsDescs.get();
+
+ if (oldMap != null && (res = oldMap.get(cls)) != null)
+ break;
- if (res == null) {
if (dep != null) {
Set<Class<?>> classes = F.addIfAbsent(taskMap, dep.classLoader(), F.<Class<?>>newCSet());
classes.add(cls);
+
+ dep = null;
}
- res = F.addIfAbsent(clsDescs, cls, new ClassDescriptor(cls));
+ if (oldMap == null)
+ newMap = new HashMap<>();
+ else
+ (newMap = new HashMap<>(oldMap.size() + 1)).putAll(oldMap);
+
+ newMap.put(cls, res = newDesc == null ? (newDesc = new ClassDescriptor(cls)) : newDesc);
}
+ while (!clsDescs.compareAndSet(oldMap, newMap));
return res;
}
@@ -123,8 +158,8 @@ class GridResourceIoc {
* @param dep Deployment.
* @param depCls Deployment class.
* @param checkedObjs Set of already inspected objects to avoid indefinite recursion.
- * @throws IgniteCheckedException Thrown in case of any errors during injection.
* @return {@code True} if resource was injected.
+ * @throws IgniteCheckedException Thrown in case of any errors during injection.
*/
private boolean injectInternal(Object target,
Class<? extends Annotation> annCls,
@@ -132,56 +167,14 @@ class GridResourceIoc {
@Nullable GridDeployment dep,
@Nullable Class<?> depCls,
@Nullable Set<Object> checkedObjs)
- throws IgniteCheckedException
- {
+ throws IgniteCheckedException {
Class<?> targetCls = target.getClass();
ClassDescriptor descr = descriptor(dep, targetCls);
T2<GridResourceField[], GridResourceMethod[]> annotatedMembers = descr.annotatedMembers(annCls);
- if (descr.recursiveFields().length == 0 && annotatedMembers == null)
- return false;
-
- if (checkedObjs == null && descr.recursiveFields().length > 0)
- checkedObjs = new GridLeanIdentitySet<>();
-
- if (checkedObjs != null && !checkedObjs.add(target))
- return false;
-
- boolean injected = false;
-
- for (Field field : descr.recursiveFields()) {
- try {
- Object obj = field.get(target);
-
- if (obj != null) {
- assert checkedObjs != null;
-
- injected |= injectInternal(obj, annCls, injector, dep, depCls, checkedObjs);
- }
- }
- catch (IllegalAccessException e) {
- throw new IgniteCheckedException("Failed to inject resource [field=" + field.getName() +
- ", target=" + target + ']', e);
- }
- }
-
- if (annotatedMembers != null) {
- for (GridResourceField field : annotatedMembers.get1()) {
- injector.inject(field, target, depCls, dep);
-
- injected = true;
- }
-
- for (GridResourceMethod mtd : annotatedMembers.get2()) {
- injector.inject(mtd, target, depCls, dep);
-
- injected = true;
- }
- }
-
- return injected;
+ return descr.injectInternal(target, annCls, annotatedMembers, injector, dep, depCls, checkedObjs);
}
/**
@@ -202,36 +195,18 @@ class GridResourceIoc {
}
/**
+ * Checks if annotation is presented on a field or method of the specified object.
+ *
+ * @param target Target object.
+ * @param annSet Annotation classes to find on fields or methods of target object.
* @param dep Deployment.
- * @param target Target.
- * @param annClss Annotations.
- * @return Filtered set of annotations that present in target.
+ * @return {@code true} if any annotation is presented, {@code false} if it's not.
*/
- @SuppressWarnings({"SuspiciousToArrayCall", "unchecked"})
- Class<? extends Annotation>[] filter(
- @Nullable GridDeployment dep, Object target,
- Collection<Class<? extends Annotation>> annClss) {
+ boolean isAnnotationsPresent(@Nullable GridDeployment dep, Object target, AnnotationSet annSet) {
assert target != null;
- assert annClss != null && !annClss.isEmpty();
+ assert annSet != null;
- Class<?> cls = target.getClass();
-
- Class<? extends Annotation>[] res = annCache.get(cls);
-
- if (res == null) {
- Collection<Class<? extends Annotation>> res0 = new ArrayList<>();
-
- for (Class<? extends Annotation> annCls : annClss) {
- if (isAnnotationPresent(target, annCls, dep))
- res0.add(annCls);
- }
-
- res = res0.toArray(new Class[res0.size()]);
-
- annCache.putIfAbsent(cls, res);
- }
-
- return res;
+ return descriptor(dep, target.getClass()).isAnnotated(annSet) != 0;
}
/**
@@ -251,16 +226,18 @@ class GridResourceIoc {
return t2 == null ? GridResourceMethod.EMPTY_ARRAY : t2.get2();
}
- /** {@inheritDoc} */
+ /** Print memory statistics */
public void printMemoryStats() {
X.println(">>> taskMapSize: " + taskMap.size());
- X.println(">>> classDescriptorsCacheSize: " + clsDescs.size());
+
+ Map<Class<?>, ClassDescriptor> map = clsDescs.get();
+ X.println(">>> classDescriptorsCacheSize: " + (map == null ? 0 : map.size()));
}
/**
*
*/
- private static class ClassDescriptor {
+ class ClassDescriptor {
/** */
private final Field[] recursiveFields;
@@ -268,8 +245,18 @@ class GridResourceIoc {
private final Map<Class<? extends Annotation>, T2<GridResourceField[], GridResourceMethod[]>> annMap;
/**
+ * Uses as enum-map with enum {@link AnnotationSet} member as key,
+ * and bitmap as a result of matching found annotations with enum set {@link ResourceAnnotation} as value.
+ */
+ private final int[] containsAnnSets;
+
+ /** Uses as enum-map with enum {@link ResourceAnnotation} member as a keys. */
+ private final T2<GridResourceField[], GridResourceMethod[]>[] annArr;
+
+ /**
* @param cls Class.
*/
+ @SuppressWarnings("unchecked")
ClassDescriptor(Class<?> cls) {
Map<Class<? extends Annotation>, T2<List<GridResourceField>, List<GridResourceMethod>>> annMap
= new HashMap<>();
@@ -335,20 +322,277 @@ class GridResourceIoc {
this.annMap.put(entry.getKey(), new T2<>(fields, mtds));
}
+
+ T2<GridResourceField[], GridResourceMethod[]>[] annArr = null;
+
+ if (annMap.isEmpty())
+ containsAnnSets = null;
+ else {
+ int annotationsBits = 0;
+
+ for (ResourceAnnotation ann : ResourceAnnotation.values()) {
+ T2<GridResourceField[], GridResourceMethod[]> member = annotatedMembers(ann.clazz);
+
+ if (member != null) {
+ if (annArr == null)
+ annArr = new T2[ResourceAnnotation.values().length];
+
+ annArr[ann.ordinal()] = member;
+
+ annotationsBits |= 1 << ann.ordinal();
+ }
+ }
+
+ AnnotationSet[] annotationSets = AnnotationSet.values();
+
+ containsAnnSets = new int[annotationSets.length];
+
+ for (int i = 0; i < annotationSets.length; i++)
+ containsAnnSets[i] = annotationsBits & annotationSets[i].annotationsBitSet;
+ }
+
+ this.annArr = annArr;
}
/**
* @return Recursive fields.
*/
- public Field[] recursiveFields() {
+ Field[] recursiveFields() {
return recursiveFields;
}
/**
+ * @param annCls Annotation class.
* @return Fields.
*/
- @Nullable public T2<GridResourceField[], GridResourceMethod[]> annotatedMembers(Class<? extends Annotation> annCls) {
+ @Nullable T2<GridResourceField[], GridResourceMethod[]> annotatedMembers(Class<? extends Annotation> annCls) {
return annMap.get(annCls);
}
+
+ /**
+ * @param set annotation set.
+ * @return {@code Bitmask} > 0 if any annotation is presented, otherwise return 0;
+ */
+ int isAnnotated(AnnotationSet set) {
+ return recursiveFields.length > 0 ? set.annotationsBitSet :
+ (containsAnnSets == null ? 0 : containsAnnSets[set.ordinal()]);
+ }
+
+ /**
+ * @param ann Annotation.
+ * @return {@code True} if annotation is presented.
+ */
+ boolean isAnnotated(ResourceAnnotation ann) {
+ return recursiveFields.length > 0 || (annArr != null && annArr[ann.ordinal()] != null);
+ }
+
+ /**
+ * @param target Target object.
+ * @param annCls Annotation class.
+ * @param annotatedMembers Setter annotation.
+ * @param injector Resource to inject.
+ * @param dep Deployment.
+ * @param depCls Deployment class.
+ * @param checkedObjs Set of already inspected objects to avoid indefinite recursion.
+ * @return {@code True} if resource was injected.
+ * @throws IgniteCheckedException Thrown in case of any errors during injection.
+ */
+ boolean injectInternal(Object target,
+ Class<? extends Annotation> annCls,
+ T2<GridResourceField[], GridResourceMethod[]> annotatedMembers,
+ GridResourceInjector injector,
+ @Nullable GridDeployment dep,
+ @Nullable Class<?> depCls,
+ @Nullable Set<Object> checkedObjs)
+ throws IgniteCheckedException {
+ if (recursiveFields.length == 0 && annotatedMembers == null)
+ return false;
+
+ if (checkedObjs == null && recursiveFields.length > 0)
+ checkedObjs = new GridLeanIdentitySet<>();
+
+ if (checkedObjs != null && !checkedObjs.add(target))
+ return false;
+
+ boolean injected = false;
+
+ for (Field field : recursiveFields) {
+ try {
+ Object obj = field.get(target);
+
+ if (obj != null) {
+ assert checkedObjs != null;
+
+ ClassDescriptor desc = descriptor(dep, obj.getClass());
+ injected |= desc.injectInternal(obj, annCls, desc.annotatedMembers(annCls),
+ injector, dep, depCls, checkedObjs);
+ }
+ }
+ catch (IllegalAccessException e) {
+ throw new IgniteCheckedException("Failed to inject resource [field=" + field.getName() +
+ ", target=" + target + ']', e);
+ }
+ }
+
+ if (annotatedMembers != null) {
+ for (GridResourceField field : annotatedMembers.get1()) {
+ injector.inject(field, target, depCls, dep);
+
+ injected = true;
+ }
+
+ for (GridResourceMethod mtd : annotatedMembers.get2()) {
+ injector.inject(mtd, target, depCls, dep);
+
+ injected = true;
+ }
+ }
+
+ return injected;
+ }
+
+ /**
+ * @param target Target object.
+ * @param ann Setter annotation.
+ * @param injector Resource to inject.
+ * @param dep Deployment.
+ * @param depCls Deployment class.
+ * @return {@code True} if resource was injected.
+ * @throws IgniteCheckedException Thrown in case of any errors during injection.
+ */
+ public boolean inject(Object target,
+ ResourceAnnotation ann,
+ GridResourceInjector injector,
+ @Nullable GridDeployment dep,
+ @Nullable Class<?> depCls)
+ throws IgniteCheckedException {
+ return injectInternal(target,
+ ann.clazz,
+ annArr == null ? null : annArr[ann.ordinal()],
+ injector,
+ dep,
+ depCls,
+ null);
+ }
+ }
+
+ /**
+ *
+ */
+ enum ResourceAnnotation {
+ /** */
+ CACHE_NAME(CacheNameResource.class),
+
+ /** */
+ SPRING_APPLICATION_CONTEXT(SpringApplicationContextResource.class),
+
+ /** */
+ SPRING(SpringResource.class),
+
+ /** */
+ IGNITE_INSTANCE(IgniteInstanceResource.class),
+
+ /** */
+ LOGGER(LoggerResource.class),
+
+ /** */
+ SERVICE(ServiceResource.class),
+
+ /** */
+ TASK_SESSION(TaskSessionResource.class),
+
+ /** */
+ LOAD_BALANCER(LoadBalancerResource.class),
+
+ /** */
+ TASK_CONTINUOUS_MAPPER(TaskContinuousMapperResource.class),
+
+ /** */
+ JOB_CONTEXT(JobContextResource.class),
+
+ /** */
+ CACHE_STORE_SESSION(CacheStoreSessionResource.class);
+
+ /** */
+ public final Class<? extends Annotation> clazz;
+
+ /**
+ * @param clazz annotation class.
+ */
+ ResourceAnnotation(Class<? extends Annotation> clazz) {
+ this.clazz = clazz;
+ }
+ }
+
+ /**
+ *
+ */
+ public enum AnnotationSet {
+ /** */
+ GENERIC(
+ ResourceAnnotation.SPRING_APPLICATION_CONTEXT,
+ ResourceAnnotation.SPRING,
+ ResourceAnnotation.IGNITE_INSTANCE,
+ ResourceAnnotation.LOGGER,
+ ResourceAnnotation.SERVICE
+ ),
+
+ /** */
+ ENTRY_PROCESSOR(
+ ResourceAnnotation.CACHE_NAME,
+
+ ResourceAnnotation.SPRING_APPLICATION_CONTEXT,
+ ResourceAnnotation.SPRING,
+ ResourceAnnotation.IGNITE_INSTANCE,
+ ResourceAnnotation.LOGGER,
+ ResourceAnnotation.SERVICE
+ ),
+
+ /** */
+ TASK(
+ ResourceAnnotation.TASK_SESSION,
+ ResourceAnnotation.LOAD_BALANCER,
+ ResourceAnnotation.TASK_CONTINUOUS_MAPPER,
+
+ ResourceAnnotation.SPRING_APPLICATION_CONTEXT,
+ ResourceAnnotation.SPRING,
+ ResourceAnnotation.IGNITE_INSTANCE,
+ ResourceAnnotation.LOGGER,
+ ResourceAnnotation.SERVICE
+ ),
+
+ /** */
+ JOB(
+ ResourceAnnotation.TASK_SESSION,
+ ResourceAnnotation.JOB_CONTEXT,
+
+ ResourceAnnotation.SPRING_APPLICATION_CONTEXT,
+ ResourceAnnotation.SPRING,
+ ResourceAnnotation.IGNITE_INSTANCE,
+ ResourceAnnotation.LOGGER,
+ ResourceAnnotation.SERVICE
+ );
+
+ /** Resource annotations bits for fast checks. */
+ public final int annotationsBitSet;
+
+ /** Holds annotations in order */
+ public final ResourceAnnotation[] annotations;
+
+ /**
+ * @param annotations ResourceAnnotations.
+ */
+ AnnotationSet(ResourceAnnotation... annotations) {
+ assert annotations.length < 32 : annotations.length;
+
+ this.annotations = annotations;
+
+ int mask = 0;
+
+ for (ResourceAnnotation ann : annotations)
+ mask |= 1 << ann.ordinal();
+
+ annotationsBitSet = mask;
+ }
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/f9ff97c9/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceProcessor.java
index afe0ef1..84d07b6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceProcessor.java
@@ -20,12 +20,11 @@ package org.apache.ignite.internal.processors.resource;
import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
-import java.util.Arrays;
import java.util.Collection;
import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.IgniteLogger;
import org.apache.ignite.cache.store.CacheStoreSession;
import org.apache.ignite.compute.ComputeJob;
+import org.apache.ignite.compute.ComputeJobContext;
import org.apache.ignite.compute.ComputeLoadBalancer;
import org.apache.ignite.compute.ComputeTask;
import org.apache.ignite.compute.ComputeTaskContinuousMapper;
@@ -34,22 +33,10 @@ import org.apache.ignite.internal.GridInternalWrapper;
import org.apache.ignite.internal.GridJobContextImpl;
import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.GridTaskSessionImpl;
-import org.apache.ignite.internal.IgniteEx;
import org.apache.ignite.internal.managers.deployment.GridDeployment;
import org.apache.ignite.internal.processors.GridProcessorAdapter;
import org.apache.ignite.internal.util.typedef.X;
import org.apache.ignite.lifecycle.LifecycleBean;
-import org.apache.ignite.resources.CacheNameResource;
-import org.apache.ignite.resources.CacheStoreSessionResource;
-import org.apache.ignite.resources.IgniteInstanceResource;
-import org.apache.ignite.resources.JobContextResource;
-import org.apache.ignite.resources.LoadBalancerResource;
-import org.apache.ignite.resources.LoggerResource;
-import org.apache.ignite.resources.ServiceResource;
-import org.apache.ignite.resources.SpringApplicationContextResource;
-import org.apache.ignite.resources.SpringResource;
-import org.apache.ignite.resources.TaskContinuousMapperResource;
-import org.apache.ignite.resources.TaskSessionResource;
import org.apache.ignite.services.Service;
import org.apache.ignite.spi.IgniteSpi;
import org.jetbrains.annotations.Nullable;
@@ -58,42 +45,6 @@ import org.jetbrains.annotations.Nullable;
* Processor for all Ignite and task/job resources.
*/
public class GridResourceProcessor extends GridProcessorAdapter {
- /** */
- private static final Collection<Class<? extends Annotation>> JOB_INJECTIONS = Arrays.asList(
- TaskSessionResource.class,
- JobContextResource.class,
- IgniteInstanceResource.class,
- SpringApplicationContextResource.class,
- SpringResource.class,
- LoggerResource.class,
- ServiceResource.class);
-
- /** */
- private static final Collection<Class<? extends Annotation>> TASK_INJECTIONS = Arrays.asList(
- TaskSessionResource.class,
- LoadBalancerResource.class,
- TaskContinuousMapperResource.class,
- IgniteInstanceResource.class,
- SpringApplicationContextResource.class,
- SpringResource.class,
- LoggerResource.class,
- ServiceResource.class);
-
- /** Grid instance injector. */
- private GridResourceBasicInjector<IgniteEx> gridInjector;
-
- /** Spring application context injector. */
- private GridResourceInjector springCtxInjector;
-
- /** Logger injector. */
- private GridResourceBasicInjector<IgniteLogger> logInjector;
-
- /** Services injector. */
- private GridResourceBasicInjector<Collection<Service>> srvcInjector;
-
- /** Spring bean resources injector. */
- private GridResourceInjector springBeanInjector;
-
/** Cleaning injector. */
private final GridResourceInjector nullInjector = new GridResourceBasicInjector<>(null);
@@ -103,6 +54,9 @@ public class GridResourceProcessor extends GridProcessorAdapter {
/** */
private final GridResourceIoc ioc = new GridResourceIoc();
+ /** */
+ private final GridResourceInjector[] injectorByAnnotation;
+
/**
* Creates resources processor.
*
@@ -111,9 +65,14 @@ public class GridResourceProcessor extends GridProcessorAdapter {
public GridResourceProcessor(GridKernalContext ctx) {
super(ctx);
- gridInjector = new GridResourceBasicInjector<>(ctx.grid());
- logInjector = new GridResourceLoggerInjector(ctx.config().getGridLogger());
- srvcInjector = new GridResourceServiceInjector(ctx.grid());
+ injectorByAnnotation = new GridResourceInjector[GridResourceIoc.ResourceAnnotation.values().length];
+
+ injectorByAnnotation[GridResourceIoc.ResourceAnnotation.SERVICE.ordinal()] =
+ new GridResourceServiceInjector(ctx.grid());
+ injectorByAnnotation[GridResourceIoc.ResourceAnnotation.LOGGER.ordinal()] =
+ new GridResourceLoggerInjector(ctx.config().getGridLogger());
+ injectorByAnnotation[GridResourceIoc.ResourceAnnotation.IGNITE_INSTANCE.ordinal()] =
+ new GridResourceBasicInjector<>(ctx.grid());
}
/** {@inheritDoc} */
@@ -138,8 +97,12 @@ public class GridResourceProcessor extends GridProcessorAdapter {
public void setSpringContext(@Nullable GridSpringResourceContext rsrcCtx) {
this.rsrcCtx = rsrcCtx;
- springCtxInjector = rsrcCtx != null ? rsrcCtx.springContextInjector() : nullInjector;
- springBeanInjector = rsrcCtx != null ? rsrcCtx.springBeanInjector() : nullInjector;
+ GridResourceInjector springCtxInjector = rsrcCtx != null ? rsrcCtx.springContextInjector() : nullInjector;
+ GridResourceInjector springBeanInjector = rsrcCtx != null ? rsrcCtx.springBeanInjector() : nullInjector;
+
+ injectorByAnnotation[GridResourceIoc.ResourceAnnotation.SPRING.ordinal()] = springBeanInjector;
+ injectorByAnnotation[GridResourceIoc.ResourceAnnotation.SPRING_APPLICATION_CONTEXT.ordinal()] =
+ springCtxInjector;
}
/**
@@ -187,17 +150,15 @@ public class GridResourceProcessor extends GridProcessorAdapter {
* @throws IgniteCheckedException Thrown in case of any errors.
*/
public void inject(GridDeployment dep, Class<?> depCls, Object target) throws IgniteCheckedException {
+ assert target != null;
+
if (log.isDebugEnabled())
log.debug("Injecting resources: " + target);
// Unwrap Proxy object.
target = unwrapTarget(target);
- ioc.inject(target, IgniteInstanceResource.class, gridInjector, dep, depCls);
- ioc.inject(target, SpringApplicationContextResource.class, springCtxInjector, dep, depCls);
- ioc.inject(target, SpringResource.class, springBeanInjector, dep, depCls);
- ioc.inject(target, LoggerResource.class, logInjector, dep, depCls);
- ioc.inject(target, ServiceResource.class, srvcInjector, dep, depCls);
+ inject(target, GridResourceIoc.AnnotationSet.GENERIC, dep, depCls);
}
/**
@@ -216,7 +177,7 @@ public class GridResourceProcessor extends GridProcessorAdapter {
// Unwrap Proxy object.
obj = unwrapTarget(obj);
- ioc.inject(obj, CacheNameResource.class, new GridResourceBasicInjector<>(cacheName), null, null);
+ inject(obj, GridResourceIoc.ResourceAnnotation.CACHE_NAME, null, null, cacheName);
}
/**
@@ -236,7 +197,7 @@ public class GridResourceProcessor extends GridProcessorAdapter {
// Unwrap Proxy object.
obj = unwrapTarget(obj);
- return ioc.inject(obj, CacheStoreSessionResource.class, new GridResourceBasicInjector<>(ses), null, null);
+ return inject(obj, GridResourceIoc.ResourceAnnotation.CACHE_STORE_SESSION, null, null, ses);
}
/**
@@ -244,6 +205,17 @@ public class GridResourceProcessor extends GridProcessorAdapter {
* @throws IgniteCheckedException If failed to inject.
*/
public void injectGeneric(Object obj) throws IgniteCheckedException {
+ inject(obj, GridResourceIoc.AnnotationSet.GENERIC);
+ }
+
+ /**
+ * @param obj Object to inject.
+ * @param annSet Supported annotations.
+ * @param params Parameters.
+ * @throws IgniteCheckedException If failed to inject.
+ */
+ public void inject(Object obj, GridResourceIoc.AnnotationSet annSet, Object... params)
+ throws IgniteCheckedException {
assert obj != null;
if (log.isDebugEnabled())
@@ -252,33 +224,126 @@ public class GridResourceProcessor extends GridProcessorAdapter {
// Unwrap Proxy object.
obj = unwrapTarget(obj);
- // No deployment for lifecycle beans.
- ioc.inject(obj, SpringApplicationContextResource.class, springCtxInjector, null, null);
- ioc.inject(obj, SpringResource.class, springBeanInjector, null, null);
- ioc.inject(obj, IgniteInstanceResource.class, gridInjector, null, null);
- ioc.inject(obj, LoggerResource.class, logInjector, null, null);
- ioc.inject(obj, ServiceResource.class, srvcInjector, null, null);
+ inject(obj, annSet, null, null, params);
+ }
+
+ /**
+ * @param obj Object to inject.
+ * @param annSet Supported annotations.
+ * @param dep Deployment.
+ * @param depCls Deployment class.
+ * @param params Parameters.
+ * @throws IgniteCheckedException If failed to inject.
+ */
+ private void inject(Object obj,
+ GridResourceIoc.AnnotationSet annSet,
+ @Nullable GridDeployment dep,
+ @Nullable Class<?> depCls,
+ Object... params)
+ throws IgniteCheckedException {
+ GridResourceIoc.ClassDescriptor clsDesc = ioc.descriptor(null, obj.getClass());
+
+ assert clsDesc != null;
+
+ if (clsDesc.isAnnotated(annSet) == 0)
+ return;
+
+ int i = 0;
+ for (GridResourceIoc.ResourceAnnotation ann : annSet.annotations) {
+ if (clsDesc.isAnnotated(ann)) {
+ final GridResourceInjector injector = injectorByAnnotation(ann, i < params.length ? params[i] : null);
+
+ if (injector != null)
+ clsDesc.inject(obj, ann, injector, dep, depCls);
+ }
+
+ i++;
+ }
}
/**
* @param obj Object.
+ * @param annSet Supported annotations.
* @throws IgniteCheckedException If failed.
*/
- public void cleanupGeneric(Object obj) throws IgniteCheckedException {
- if (obj != null) {
- if (log.isDebugEnabled())
- log.debug("Cleaning up resources: " + obj);
-
- // Unwrap Proxy object.
- obj = unwrapTarget(obj);
-
- // Caching key is null for the life-cycle beans.
- ioc.inject(obj, LoggerResource.class, nullInjector, null, null);
- ioc.inject(obj, ServiceResource.class, nullInjector, null, null);
- ioc.inject(obj, SpringApplicationContextResource.class, nullInjector, null, null);
- ioc.inject(obj, SpringResource.class, nullInjector, null, null);
- ioc.inject(obj, IgniteInstanceResource.class, nullInjector, null, null);
+ private void cleanup(Object obj, GridResourceIoc.AnnotationSet annSet)
+ throws IgniteCheckedException {
+ assert obj != null;
+
+ if (log.isDebugEnabled())
+ log.debug("Cleaning up resources: " + obj);
+
+ // Unwrap Proxy object.
+ obj = unwrapTarget(obj);
+
+ GridResourceIoc.ClassDescriptor clsDesc = ioc.descriptor(null, obj.getClass());
+
+ assert clsDesc != null;
+
+ if (clsDesc.isAnnotated(annSet) == 0)
+ return;
+
+ for (GridResourceIoc.ResourceAnnotation ann : annSet.annotations)
+ clsDesc.inject(obj, ann, nullInjector, null, null);
+ }
+
+ /**
+ * @param ann Annotation.
+ * @param param Injector parameter.
+ * @return Injector.
+ */
+ private GridResourceInjector injectorByAnnotation(GridResourceIoc.ResourceAnnotation ann, Object param) {
+ final GridResourceInjector res;
+
+ switch (ann) {
+ case CACHE_NAME:
+ case TASK_SESSION:
+ case LOAD_BALANCER:
+ case TASK_CONTINUOUS_MAPPER:
+ case CACHE_STORE_SESSION:
+ res = new GridResourceBasicInjector<>(param);
+ break;
+
+ case JOB_CONTEXT:
+ res = new GridResourceJobContextInjector((ComputeJobContext)param);
+ break;
+
+ default:
+ res = injectorByAnnotation[ann.ordinal()];
+ break;
}
+
+ return res;
+ }
+
+ /**
+ * @param obj Object to inject.
+ * @throws IgniteCheckedException If failed to inject.
+ */
+ private boolean inject(Object obj, GridResourceIoc.ResourceAnnotation ann, @Nullable GridDeployment dep,
+ @Nullable Class<?> depCls, Object param)
+ throws IgniteCheckedException {
+ GridResourceIoc.ClassDescriptor clsDesc = ioc.descriptor(null, obj.getClass());
+
+ assert clsDesc != null;
+
+ if (clsDesc.isAnnotated(ann)) {
+ GridResourceInjector injector = injectorByAnnotation(ann, param);
+
+ if (injector != null)
+ return clsDesc.inject(obj, ann, injector, dep, depCls);
+ }
+
+ return false;
+ }
+
+ /**
+ * @param obj Object.
+ * @throws IgniteCheckedException If failed.
+ */
+ public void cleanupGeneric(Object obj) throws IgniteCheckedException {
+ if (obj != null)
+ cleanup(obj, GridResourceIoc.AnnotationSet.GENERIC);
}
/**
@@ -321,30 +386,8 @@ public class GridResourceProcessor extends GridProcessorAdapter {
*/
private void injectToJob(GridDeployment dep, Class<?> taskCls, Object job, ComputeTaskSession ses,
GridJobContextImpl jobCtx) throws IgniteCheckedException {
- Class<? extends Annotation>[] filtered = ioc.filter(dep, job, JOB_INJECTIONS);
-
- if (filtered.length > 0) {
- for (Class<? extends Annotation> annCls : filtered) {
- if (annCls == TaskSessionResource.class)
- injectBasicResource(job, TaskSessionResource.class, ses, dep, taskCls);
- else if (annCls == JobContextResource.class)
- ioc.inject(job, JobContextResource.class, new GridResourceJobContextInjector(jobCtx),
- dep, taskCls);
- else if (annCls == IgniteInstanceResource.class)
- ioc.inject(job, IgniteInstanceResource.class, gridInjector, dep, taskCls);
- else if (annCls == SpringApplicationContextResource.class)
- ioc.inject(job, SpringApplicationContextResource.class, springCtxInjector, dep, taskCls);
- else if (annCls == SpringResource.class)
- ioc.inject(job, SpringResource.class, springBeanInjector, dep, taskCls);
- else if (annCls == LoggerResource.class)
- ioc.inject(job, LoggerResource.class, logInjector, dep, taskCls);
- else {
- assert annCls == ServiceResource.class;
-
- ioc.inject(job, ServiceResource.class, srvcInjector, dep, taskCls);
- }
- }
- }
+
+ inject(job, GridResourceIoc.AnnotationSet.JOB, dep, taskCls, ses, jobCtx);
}
/**
@@ -365,34 +408,7 @@ public class GridResourceProcessor extends GridProcessorAdapter {
// Unwrap Proxy object.
Object obj = unwrapTarget(task);
- Class<? extends Annotation>[] filtered = ioc.filter(dep, obj, TASK_INJECTIONS);
-
- if (filtered.length == 0)
- return;
-
- Class<?> taskCls = obj.getClass();
-
- for (Class<? extends Annotation> annCls : filtered) {
- if (annCls == TaskSessionResource.class)
- injectBasicResource(obj, TaskSessionResource.class, ses, dep, taskCls);
- else if (annCls == LoadBalancerResource.class)
- injectBasicResource(obj, LoadBalancerResource.class, balancer, dep, taskCls);
- else if (annCls == TaskContinuousMapperResource.class)
- injectBasicResource(obj, TaskContinuousMapperResource.class, mapper, dep, taskCls);
- else if (annCls == IgniteInstanceResource.class)
- ioc.inject(obj, IgniteInstanceResource.class, gridInjector, dep, taskCls);
- else if (annCls == SpringApplicationContextResource.class)
- ioc.inject(obj, SpringApplicationContextResource.class, springCtxInjector, dep, taskCls);
- else if (annCls == SpringResource.class)
- ioc.inject(obj, SpringResource.class, springBeanInjector, dep, taskCls);
- else if (annCls == LoggerResource.class)
- ioc.inject(obj, LoggerResource.class, logInjector, dep, taskCls);
- else {
- assert annCls == ServiceResource.class;
-
- ioc.inject(obj, ServiceResource.class, srvcInjector, dep, taskCls);
- }
- }
+ inject(obj, GridResourceIoc.AnnotationSet.TASK, dep, null, ses, balancer, mapper);
}
/**
@@ -408,24 +424,25 @@ public class GridResourceProcessor extends GridProcessorAdapter {
}
/**
+ * Checks if annotations presents in specified object.
+ *
+ * @param dep Class deployment.
+ * @param target Object to check.
+ * @param annSet Annotations to find.
+ * @return {@code true} if any annotation is presented, {@code false} if it's not.
+ */
+ public boolean isAnnotationsPresent(GridDeployment dep, Object target, GridResourceIoc.AnnotationSet annSet) {
+ return ioc.isAnnotationsPresent(dep, target, annSet);
+ }
+
+ /**
* Injects held resources into given SPI implementation.
*
* @param spi SPI implementation.
* @throws IgniteCheckedException Throw in case of any errors.
*/
public void inject(IgniteSpi spi) throws IgniteCheckedException {
- if (log.isDebugEnabled())
- log.debug("Injecting resources: " + spi);
-
- // Unwrap Proxy object.
- Object obj = unwrapTarget(spi);
-
- // Caching key is null for the SPIs.
- ioc.inject(obj, SpringApplicationContextResource.class, springCtxInjector, null, null);
- ioc.inject(obj, SpringResource.class, springBeanInjector, null, null);
- ioc.inject(obj, LoggerResource.class, logInjector, null, null);
- ioc.inject(obj, ServiceResource.class, srvcInjector, null, null);
- ioc.inject(obj, IgniteInstanceResource.class, gridInjector, null, null);
+ injectGeneric(spi);
}
/**
@@ -436,17 +453,7 @@ public class GridResourceProcessor extends GridProcessorAdapter {
* @throws IgniteCheckedException Thrown in case of any errors.
*/
public void cleanup(IgniteSpi spi) throws IgniteCheckedException {
- if (log.isDebugEnabled())
- log.debug("Cleaning up resources: " + spi);
-
- // Unwrap Proxy object.
- Object obj = unwrapTarget(spi);
-
- ioc.inject(obj, LoggerResource.class, nullInjector, null, null);
- ioc.inject(obj, ServiceResource.class, nullInjector, null, null);
- ioc.inject(obj, SpringApplicationContextResource.class, nullInjector, null, null);
- ioc.inject(obj, SpringResource.class, nullInjector, null, null);
- ioc.inject(obj, IgniteInstanceResource.class, nullInjector, null, null);
+ cleanupGeneric(spi);
}
/**
@@ -456,18 +463,7 @@ public class GridResourceProcessor extends GridProcessorAdapter {
* @throws IgniteCheckedException Thrown in case of any errors.
*/
public void inject(LifecycleBean lifecycleBean) throws IgniteCheckedException {
- if (log.isDebugEnabled())
- log.debug("Injecting resources: " + lifecycleBean);
-
- // Unwrap Proxy object.
- Object obj = unwrapTarget(lifecycleBean);
-
- // No deployment for lifecycle beans.
- ioc.inject(obj, SpringApplicationContextResource.class, springCtxInjector, null, null);
- ioc.inject(obj, SpringResource.class, springBeanInjector, null, null);
- ioc.inject(obj, IgniteInstanceResource.class, gridInjector, null, null);
- ioc.inject(obj, LoggerResource.class, logInjector, null, null);
- ioc.inject(obj, ServiceResource.class, srvcInjector, null, null);
+ injectGeneric(lifecycleBean);
}
/**
@@ -478,18 +474,7 @@ public class GridResourceProcessor extends GridProcessorAdapter {
* @throws IgniteCheckedException Thrown in case of any errors.
*/
public void cleanup(LifecycleBean lifecycleBean) throws IgniteCheckedException {
- if (log.isDebugEnabled())
- log.debug("Cleaning up resources: " + lifecycleBean);
-
- // Unwrap Proxy object.
- Object obj = unwrapTarget(lifecycleBean);
-
- // Caching key is null for the life-cycle beans.
- ioc.inject(obj, LoggerResource.class, nullInjector, null, null);
- ioc.inject(obj, ServiceResource.class, nullInjector, null, null);
- ioc.inject(obj, SpringApplicationContextResource.class, nullInjector, null, null);
- ioc.inject(obj, SpringResource.class, nullInjector, null, null);
- ioc.inject(obj, IgniteInstanceResource.class, nullInjector, null, null);
+ cleanupGeneric(lifecycleBean);
}
/**
@@ -499,18 +484,7 @@ public class GridResourceProcessor extends GridProcessorAdapter {
* @throws IgniteCheckedException If failed.
*/
public void inject(Service svc) throws IgniteCheckedException {
- if (log.isDebugEnabled())
- log.debug("Injecting resources: " + svc);
-
- // Unwrap Proxy object.
- Object obj = unwrapTarget(svc);
-
- // No deployment for lifecycle beans.
- ioc.inject(obj, SpringApplicationContextResource.class, springCtxInjector, null, null);
- ioc.inject(obj, SpringResource.class, springBeanInjector, null, null);
- ioc.inject(obj, IgniteInstanceResource.class, gridInjector, null, null);
- ioc.inject(obj, LoggerResource.class, logInjector, null, null);
- ioc.inject(obj, ServiceResource.class, srvcInjector, null, null);
+ injectGeneric(svc);
}
/**
@@ -521,39 +495,7 @@ public class GridResourceProcessor extends GridProcessorAdapter {
* @throws IgniteCheckedException Thrown in case of any errors.
*/
public void cleanup(Service svc) throws IgniteCheckedException {
- if (log.isDebugEnabled())
- log.debug("Cleaning up resources: " + svc);
-
- // Unwrap Proxy object.
- Object obj = unwrapTarget(svc);
-
- // Caching key is null for the life-cycle beans.
- ioc.inject(obj, LoggerResource.class, nullInjector, null, null);
- ioc.inject(obj, ServiceResource.class, nullInjector, null, null);
- ioc.inject(obj, SpringApplicationContextResource.class, nullInjector, null, null);
- ioc.inject(obj, SpringResource.class, nullInjector, null, null);
- ioc.inject(obj, IgniteInstanceResource.class, nullInjector, null, null);
- }
-
- /**
- * This method is declared public as it is used from tests as well.
- * Note, that this method can be used only with unwrapped objects
- * (see {@link #unwrapTarget(Object)}).
- *
- * @param target Target object.
- * @param annCls Setter annotation.
- * @param rsrc Resource to inject.
- * @param dep Deployment.
- * @param depCls Deployed class.
- * @throws IgniteCheckedException If injection failed.
- */
- public void injectBasicResource(Object target, Class<? extends Annotation> annCls, Object rsrc,
- GridDeployment dep, Class<?> depCls) throws IgniteCheckedException {
- // Safety.
- assert !(rsrc instanceof GridResourceInjector) : "Invalid injection.";
-
- // Basic injection don't cache anything. Use null as a key.
- ioc.inject(target, annCls, new GridResourceBasicInjector<>(rsrc), dep, depCls);
+ cleanupGeneric(svc);
}
/**
@@ -602,4 +544,4 @@ public class GridResourceProcessor extends GridProcessorAdapter {
ioc.printMemoryStats();
}
-}
\ No newline at end of file
+}
[47/50] [abbrv] ignite git commit: Fixed RAT license header check.
Posted by sb...@apache.org.
Fixed RAT license header check.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/69632c8f
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/69632c8f
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/69632c8f
Branch: refs/heads/ignite-961
Commit: 69632c8fa7a62b5d24c46f7440c83bcdb6151fd2
Parents: b640b8e
Author: Alexey Kuznetsov <ak...@apache.org>
Authored: Tue Sep 6 15:26:54 2016 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Tue Sep 6 15:26:54 2016 +0700
----------------------------------------------------------------------
.../scripts/recreate-cassandra-artifacts.bat | 32 +++++++++++---------
1 file changed, 17 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/69632c8f/modules/cassandra/src/test/scripts/recreate-cassandra-artifacts.bat
----------------------------------------------------------------------
diff --git a/modules/cassandra/src/test/scripts/recreate-cassandra-artifacts.bat b/modules/cassandra/src/test/scripts/recreate-cassandra-artifacts.bat
index 47b0a22..d538ea4 100644
--- a/modules/cassandra/src/test/scripts/recreate-cassandra-artifacts.bat
+++ b/modules/cassandra/src/test/scripts/recreate-cassandra-artifacts.bat
@@ -1,19 +1,21 @@
-echo off
+::
+:: 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.
+::
-rem Licensed to the Apache Software Foundation (ASF) under one or more
-rem contributor license agreements. See the NOTICE file distributed with
-rem this work for additional information regarding copyright ownership.
-rem The ASF licenses this file to You under the Apache License, Version 2.0
-rem (the "License"); you may not use this file except in compliance with
-rem the License. You may obtain a copy of the License at
-rem
-rem http://www.apache.org/licenses/LICENSE-2.0
-rem
-rem Unless required by applicable law or agreed to in writing, software
-rem distributed under the License is distributed on an "AS IS" BASIS,
-rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-rem See the License for the specific language governing permissions and
-rem limitations under the License.
+echo off
echo.
[12/50] [abbrv] ignite git commit: IGNITE-3761: ODBC: Added tests for
SQL_SQL92_VALUE_EXPRESSIONS. This closes #989.
Posted by sb...@apache.org.
IGNITE-3761: ODBC: Added tests for SQL_SQL92_VALUE_EXPRESSIONS. This closes #989.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/6fd53ea5
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/6fd53ea5
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/6fd53ea5
Branch: refs/heads/ignite-961
Commit: 6fd53ea5b50148e5a1156d83ea28acb8faf84035
Parents: ae0b5eb
Author: Igor Sapego <is...@gridgain.com>
Authored: Fri Aug 26 11:19:39 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Fri Aug 26 11:19:39 2016 +0300
----------------------------------------------------------------------
modules/platforms/cpp/odbc-test/Makefile.am | 1 +
.../cpp/odbc-test/project/vs/odbc-test.vcxproj | 1 +
.../project/vs/odbc-test.vcxproj.filters | 3 +
.../src/sql_function_test_suite_fixture.cpp | 7 +-
.../odbc-test/src/sql_system_functions_test.cpp | 21 -----
.../cpp/odbc-test/src/sql_value_expressions.cpp | 94 ++++++++++++++++++++
modules/platforms/cpp/odbc/src/utility.cpp | 14 +--
7 files changed, 112 insertions(+), 29 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/6fd53ea5/modules/platforms/cpp/odbc-test/Makefile.am
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/Makefile.am b/modules/platforms/cpp/odbc-test/Makefile.am
index 1e00b6f..1f641be 100644
--- a/modules/platforms/cpp/odbc-test/Makefile.am
+++ b/modules/platforms/cpp/odbc-test/Makefile.am
@@ -67,6 +67,7 @@ ignite_odbc_tests_SOURCES = \
src/sql_numeric_functions_test.cpp \
src/sql_aggregate_functions_test.cpp \
src/sql_system_functions_test.cpp \
+ src/sql_value_expressions.cpp \
../odbc/src/cursor.cpp \
../odbc/src/config/connection_info.cpp \
../odbc/src/app/application_data_buffer.cpp \
http://git-wip-us.apache.org/repos/asf/ignite/blob/6fd53ea5/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj b/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj
index 2a94a2a..4d3a9cc 100644
--- a/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj
+++ b/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj
@@ -173,6 +173,7 @@
<ClCompile Include="..\..\src\sql_numeric_functions_test.cpp" />
<ClCompile Include="..\..\src\sql_string_functions_test.cpp" />
<ClCompile Include="..\..\src\sql_system_functions_test.cpp" />
+ <ClCompile Include="..\..\src\sql_value_expressions.cpp" />
<ClCompile Include="..\..\src\teamcity\teamcity_boost.cpp" />
<ClCompile Include="..\..\src\teamcity\teamcity_messages.cpp" />
<ClCompile Include="..\..\src\test_utils.cpp" />
http://git-wip-us.apache.org/repos/asf/ignite/blob/6fd53ea5/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters b/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters
index 9ca51af..c4d70b7 100644
--- a/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters
+++ b/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters
@@ -94,6 +94,9 @@
<ClCompile Include="..\..\src\sql_system_functions_test.cpp">
<Filter>Code</Filter>
</ClCompile>
+ <ClCompile Include="..\..\src\sql_value_expressions.cpp">
+ <Filter>Code</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\include\test_type.h">
http://git-wip-us.apache.org/repos/asf/ignite/blob/6fd53ea5/modules/platforms/cpp/odbc-test/src/sql_function_test_suite_fixture.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/sql_function_test_suite_fixture.cpp b/modules/platforms/cpp/odbc-test/src/sql_function_test_suite_fixture.cpp
index f848dc5..4d8b919 100644
--- a/modules/platforms/cpp/odbc-test/src/sql_function_test_suite_fixture.cpp
+++ b/modules/platforms/cpp/odbc-test/src/sql_function_test_suite_fixture.cpp
@@ -139,7 +139,12 @@ namespace ignite
CheckSingleResult0(request, SQL_C_CHAR, res, ODBC_BUFFER_SIZE, &resLen);
- BOOST_CHECK_EQUAL(std::string(reinterpret_cast<char*>(res), static_cast<size_t>(resLen)), expected);
+ std::string actual;
+
+ if (resLen > 0)
+ actual.assign(reinterpret_cast<char*>(res), static_cast<size_t>(resLen));
+
+ BOOST_CHECK_EQUAL(actual, expected);
}
template<>
http://git-wip-us.apache.org/repos/asf/ignite/blob/6fd53ea5/modules/platforms/cpp/odbc-test/src/sql_system_functions_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/sql_system_functions_test.cpp b/modules/platforms/cpp/odbc-test/src/sql_system_functions_test.cpp
index d369b0f..752925d 100644
--- a/modules/platforms/cpp/odbc-test/src/sql_system_functions_test.cpp
+++ b/modules/platforms/cpp/odbc-test/src/sql_system_functions_test.cpp
@@ -15,39 +15,18 @@
* limitations under the License.
*/
-#ifdef _WIN32
-# include <windows.h>
-#endif
-
-#include <sql.h>
-#include <sqlext.h>
-
-#include <vector>
-#include <string>
-
#ifndef _MSC_VER
# define BOOST_TEST_DYN_LINK
#endif
#include <boost/test/unit_test.hpp>
-#include "ignite/ignite.h"
-#include "ignite/ignition.h"
-#include "ignite/impl/binary/binary_utils.h"
-
-#include "test_type.h"
-#include "test_utils.h"
#include "sql_function_test_suite_fixture.h"
using namespace ignite;
-using namespace ignite::cache;
-using namespace ignite::cache::query;
-using namespace ignite::common;
using namespace boost::unit_test;
-using ignite::impl::binary::BinaryUtils;
-
BOOST_FIXTURE_TEST_SUITE(SqlSystemFunctionTestSuite, ignite::SqlFunctionTestSuiteFixture)
BOOST_AUTO_TEST_CASE(TestSystemFunctionDatabase)
http://git-wip-us.apache.org/repos/asf/ignite/blob/6fd53ea5/modules/platforms/cpp/odbc-test/src/sql_value_expressions.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/sql_value_expressions.cpp b/modules/platforms/cpp/odbc-test/src/sql_value_expressions.cpp
new file mode 100644
index 0000000..e7d6598
--- /dev/null
+++ b/modules/platforms/cpp/odbc-test/src/sql_value_expressions.cpp
@@ -0,0 +1,94 @@
+/*
+ * 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.
+ */
+
+#ifndef _MSC_VER
+# define BOOST_TEST_DYN_LINK
+#endif
+
+#include <boost/test/unit_test.hpp>
+
+#include "sql_function_test_suite_fixture.h"
+
+using namespace ignite;
+
+using namespace boost::unit_test;
+
+BOOST_FIXTURE_TEST_SUITE(SqlValueExpressionTestSuite, ignite::SqlFunctionTestSuiteFixture)
+
+BOOST_AUTO_TEST_CASE(TestCase)
+{
+ TestType in;
+
+ in.i32Field = 82;
+
+ testCache.Put(1, in);
+
+ CheckSingleResult<int32_t>(
+ "SELECT "
+ "CASE i32Field WHEN 82 "
+ "THEN (i32Field / 2) "
+ "ELSE (i32Field / 3) "
+ "END "
+ "FROM TestType", in.i32Field / 2);
+
+
+ CheckSingleResult<int32_t>(
+ "SELECT "
+ "CASE i32Field WHEN 22 "
+ "THEN (i32Field / 2) "
+ "ELSE (i32Field / 3) "
+ "END "
+ "FROM TestType", in.i32Field / 3);;
+}
+
+BOOST_AUTO_TEST_CASE(TestCast)
+{
+ TestType in;
+
+ in.i32Field = 12345;
+ in.strField = "54321";
+
+ testCache.Put(1, in);
+
+ CheckSingleResult<int32_t>("SELECT CAST(strField AS INT) + i32Field FROM TestType",
+ common::LexicalCast<int32_t>(in.strField) + in.i32Field);
+
+ CheckSingleResult<std::string>("SELECT CAST(i32Field AS VARCHAR) || strField FROM TestType",
+ common::LexicalCast<std::string>(in.i32Field) + in.strField);
+}
+
+BOOST_AUTO_TEST_CASE(TestCoalesce)
+{
+ CheckSingleResult<std::string>("SELECT COALESCE('One', 'Two', 'Three')", "One");
+ CheckSingleResult<std::string>("SELECT COALESCE(NULL, 'Two', 'Three')", "Two");
+ CheckSingleResult<std::string>("SELECT COALESCE(NULL, 'Two', NULL)", "Two");
+ CheckSingleResult<std::string>("SELECT COALESCE(NULL, NULL, 'Three')", "Three");
+}
+
+BOOST_AUTO_TEST_CASE(TestNullif)
+{
+ TestType in;
+
+ in.strField = "SomeValue";
+
+ testCache.Put(1, in);
+
+ CheckSingleResult<std::string>("SELECT NULLIF(strField, 'blablabla') FROM TestType", in.strField);
+ CheckSingleResult<std::string>("SELECT NULLIF(strField, 'SomeValue') FROM TestType", "");
+}
+
+BOOST_AUTO_TEST_SUITE_END()
http://git-wip-us.apache.org/repos/asf/ignite/blob/6fd53ea5/modules/platforms/cpp/odbc/src/utility.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/utility.cpp b/modules/platforms/cpp/odbc/src/utility.cpp
index 133f059..19be799 100644
--- a/modules/platforms/cpp/odbc/src/utility.cpp
+++ b/modules/platforms/cpp/odbc/src/utility.cpp
@@ -56,19 +56,19 @@ namespace ignite
void ReadString(ignite::impl::binary::BinaryReaderImpl& reader, std::string& str)
{
int32_t strLen = reader.ReadString(0, 0);
- if (!strLen)
+ if (strLen > 0)
{
- str.clear();
-
- char dummy;
+ str.resize(strLen);
- reader.ReadString(&dummy, sizeof(dummy));
+ reader.ReadString(&str[0], static_cast<int32_t>(str.size()));
}
else
{
- str.resize(strLen);
+ str.clear();
- reader.ReadString(&str[0], static_cast<int32_t>(str.size()));
+ char dummy;
+
+ reader.ReadString(&dummy, sizeof(dummy));
}
}
[21/50] [abbrv] ignite git commit: Merged ignite-1.6.7 to ignite-1.7.2
Posted by sb...@apache.org.
Merged ignite-1.6.7 to ignite-1.7.2
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/fea3eeaa
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/fea3eeaa
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/fea3eeaa
Branch: refs/heads/ignite-961
Commit: fea3eeaac839381ec3662275a82f4d12af6f12dd
Parents: 60afa37 0465874
Author: agura <ag...@gridgain.com>
Authored: Mon Aug 29 18:38:35 2016 +0300
Committer: agura <ag...@gridgain.com>
Committed: Mon Aug 29 18:38:35 2016 +0300
----------------------------------------------------------------------
.../local/LocalIgfsSecondaryFileSystem.java | 38 +-
.../processors/cache/GridCacheMapEntry.java | 19 +-
.../GridCachePartitionExchangeManager.java | 7 +
.../GridDistributedTxPrepareRequest.java | 4 +-
.../distributed/dht/GridDhtLockFuture.java | 53 +-
.../distributed/dht/GridDhtTxFinishFuture.java | 4 +-
.../cache/distributed/dht/GridDhtTxLocal.java | 26 +-
.../distributed/dht/GridDhtTxPrepareFuture.java | 109 +-
.../dht/GridDhtTxPrepareRequest.java | 4 +-
.../GridNearAtomicAbstractUpdateFuture.java | 69 ++
.../GridNearAtomicSingleUpdateFuture.java | 70 +-
.../dht/atomic/GridNearAtomicUpdateFuture.java | 68 +-
.../colocated/GridDhtColocatedLockFuture.java | 37 +-
.../distributed/near/GridNearLockFuture.java | 90 +-
...arOptimisticSerializableTxPrepareFuture.java | 13 +-
.../near/GridNearOptimisticTxPrepareFuture.java | 263 +++--
...ridNearOptimisticTxPrepareFutureAdapter.java | 5 +-
.../GridNearPessimisticTxPrepareFuture.java | 8 +-
.../near/GridNearTxFinishFuture.java | 5 +-
.../cache/distributed/near/GridNearTxLocal.java | 16 +-
.../near/GridNearTxPrepareRequest.java | 4 +-
.../cache/transactions/IgniteInternalTx.java | 3 +-
.../cache/transactions/IgniteTxAdapter.java | 37 +-
.../cache/transactions/IgniteTxHandler.java | 9 +-
.../transactions/IgniteTxLocalAdapter.java | 19 +-
.../cache/transactions/IgniteTxManager.java | 86 +-
.../cache/transactions/IgniteTxStateImpl.java | 11 +-
.../cache/transactions/TxDeadlockDetection.java | 51 +-
.../processors/odbc/OdbcNioListener.java | 2 +-
.../processors/odbc/OdbcRequestHandler.java | 36 +-
.../odbc/escape/OdbcEscapeParseResult.java | 73 ++
.../processors/odbc/escape/OdbcEscapeToken.java | 61 +
.../processors/odbc/escape/OdbcEscapeType.java | 105 ++
.../processors/odbc/escape/OdbcEscapeUtils.java | 361 ++++++
.../service/GridServiceProcessor.java | 18 +-
.../ignite/spi/discovery/tcp/ClientImpl.java | 7 +-
.../cache/IgniteTxConfigCacheSelfTest.java | 91 +-
.../IgniteTxTimeoutAbstractTest.java | 8 +-
...tionedMultiNodeLongTxTimeoutFullApiTest.java | 34 +
...nabledMultiNodeLongTxTimeoutFullApiTest.java | 41 +
.../local/GridCacheLocalTxTimeoutSelfTest.java | 5 +-
.../transactions/DepthFirstSearchTest.java | 100 +-
.../TxDeadlockDetectionNoHangsTest.java | 246 ++++
.../transactions/TxDeadlockDetectionTest.java | 13 +-
...timisticDeadlockDetectionCrossCacheTest.java | 257 +++++
.../TxOptimisticDeadlockDetectionTest.java | 574 ++++++++++
...simisticDeadlockDetectionCrossCacheTest.java | 165 ++-
.../TxPessimisticDeadlockDetectionTest.java | 50 +-
.../igfs/IgfsAbstractBaseSelfTest.java | 1067 ++++++++++++++++++
.../processors/igfs/IgfsAbstractSelfTest.java | 1012 +----------------
...SecondaryFileSystemDualAbstractSelfTest.java | 143 +++
.../odbc/OdbcEscapeSequenceSelfTest.java | 420 +++++++
.../ignite/testsuites/IgniteBasicTestSuite.java | 2 +
.../IgniteCacheFullApiSelfTestSuite.java | 4 +
.../TxDeadlockDetectionTestSuite.java | 6 +
.../cpp/common/src/common/big_integer.cpp | 1 -
modules/platforms/cpp/odbc-test/Makefile.am | 9 +
.../platforms/cpp/odbc-test/include/Makefile.am | 4 +-
.../odbc-test/include/sql_test_suite_fixture.h | 191 ++++
.../cpp/odbc-test/include/test_utils.h | 45 +
.../cpp/odbc-test/project/vs/odbc-test.vcxproj | 11 +
.../project/vs/odbc-test.vcxproj.filters | 33 +
.../cpp/odbc-test/src/queries_test.cpp | 78 +-
.../src/sql_aggregate_functions_test.cpp | 249 ++++
.../src/sql_numeric_functions_test.cpp | 309 +++++
.../cpp/odbc-test/src/sql_operators_test.cpp | 214 ++++
.../odbc-test/src/sql_string_functions_test.cpp | 291 +++++
.../odbc-test/src/sql_system_functions_test.cpp | 47 +
.../odbc-test/src/sql_test_suite_fixture.cpp | 271 +++++
.../cpp/odbc-test/src/sql_types_test.cpp | 60 +
.../src/sql_value_expressions_test.cpp | 94 ++
.../platforms/cpp/odbc-test/src/test_utils.cpp | 36 +
.../cpp/odbc/src/config/connection_info.cpp | 57 +-
.../platforms/cpp/odbc/src/query/data_query.cpp | 6 +-
modules/platforms/cpp/odbc/src/utility.cpp | 14 +-
.../commands/cache/VisorCacheStopCommand.scala | 5 +-
76 files changed, 6455 insertions(+), 1599 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/fea3eeaa/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/fea3eeaa/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
index f0af551,e67e60f..620d9ae
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
@@@ -696,9 -666,10 +695,13 @@@ public class IgniteTxHandler
assert nodeId != null;
assert req != null;
+ if (locTx != null)
+ req.txState(locTx.txState());
+
+ // 'baseVersion' message field is re-used for version to be added in completed versions.
+ if (!req.commit() && req.baseVersion() != null)
+ ctx.tm().addRolledbackTx(null, req.baseVersion());
+
// Transaction on local cache only.
if (locTx != null && !locTx.nearLocallyMapped() && !locTx.colocatedLocallyMapped())
return new GridFinishedFuture<IgniteInternalTx>(locTx);
http://git-wip-us.apache.org/repos/asf/ignite/blob/fea3eeaa/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxStateImpl.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/fea3eeaa/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcRequestHandler.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcRequestHandler.java
index 8f2d092,ce98720..3805d32
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcRequestHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcRequestHandler.java
@@@ -120,10 -123,12 +129,10 @@@ public class OdbcRequestHandler
* @param req Handshake request.
* @return Response.
*/
- private OdbcResponse performHandshake(OdbcHandshakeRequest req) {
+ private OdbcResponse performHandshake(long reqId, OdbcHandshakeRequest req) {
- OdbcHandshakeResult res;
+ OdbcProtocolVersion version = req.version();
- if (req.version() == OdbcMessageParser.PROTO_VER)
- res = new OdbcHandshakeResult(true, null, null);
- else {
+ if (version.isUnknown()) {
IgniteProductVersion ver = ctx.grid().version();
String verStr = Byte.toString(ver.major()) + '.' + ver.minor() + '.' + ver.maintenance();
http://git-wip-us.apache.org/repos/asf/ignite/blob/fea3eeaa/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/fea3eeaa/modules/platforms/cpp/odbc-test/Makefile.am
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/fea3eeaa/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/fea3eeaa/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters
----------------------------------------------------------------------
diff --cc modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters
index aead2af,84f5a29..0a72640
--- a/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters
+++ b/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters
@@@ -76,9 -76,33 +76,36 @@@
<ClCompile Include="..\..\src\queries_test.cpp">
<Filter>Code</Filter>
</ClCompile>
+ <ClCompile Include="..\..\..\odbc\src\protocol_version.cpp">
+ <Filter>Externals</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\sql_string_functions_test.cpp">
+ <Filter>Code</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\test_utils.cpp">
+ <Filter>Code</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\sql_numeric_functions_test.cpp">
+ <Filter>Code</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\sql_aggregate_functions_test.cpp">
+ <Filter>Code</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\sql_system_functions_test.cpp">
+ <Filter>Code</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\sql_operators_test.cpp">
+ <Filter>Code</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\sql_types_test.cpp">
+ <Filter>Code</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\sql_test_suite_fixture.cpp">
+ <Filter>Code</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\sql_value_expressions_test.cpp">
+ <Filter>Code</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\include\test_type.h">
http://git-wip-us.apache.org/repos/asf/ignite/blob/fea3eeaa/modules/platforms/cpp/odbc-test/src/queries_test.cpp
----------------------------------------------------------------------
diff --cc modules/platforms/cpp/odbc-test/src/queries_test.cpp
index 58b5f64,2d9bd58..ab59952
--- a/modules/platforms/cpp/odbc-test/src/queries_test.cpp
+++ b/modules/platforms/cpp/odbc-test/src/queries_test.cpp
@@@ -77,12 -53,41 +54,41 @@@ using ignite::impl::binary::BinaryUtils
struct QueriesTestSuiteFixture
{
/**
- * Constructor.
+ * Establish connection to node.
+ *
+ * @param connectStr Connection string.
*/
- QueriesTestSuiteFixture() : testCache(0), env(NULL), dbc(NULL), stmt(NULL)
+ void Connect(const std::string& connectStr)
{
+ IgniteConfiguration cfg;
+
+ cfg.jvmOpts.push_back("-Xdebug");
+ cfg.jvmOpts.push_back("-Xnoagent");
+ cfg.jvmOpts.push_back("-Djava.compiler=NONE");
+ cfg.jvmOpts.push_back("-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005");
+ cfg.jvmOpts.push_back("-XX:+HeapDumpOnOutOfMemoryError");
+
+ #ifdef IGNITE_TESTS_32
+ cfg.jvmInitMem = 256;
+ cfg.jvmMaxMem = 768;
+ #else
+ cfg.jvmInitMem = 1024;
+ cfg.jvmMaxMem = 4096;
+ #endif
+
+ char* cfgPath = getenv("IGNITE_NATIVE_TEST_ODBC_CONFIG_PATH");
+
- BOOST_REQUIRE(cfgPath != 0);
-
- cfg.springCfgPath.assign(cfgPath).append("/queries-test.xml");
++ cfg.springCfgPath = std::string(cfgPath).append("/").append("queries-test.xml");
+
+ IgniteError err;
+
+ grid = Ignition::Start(cfg, &err);
+
+ if (err.GetCode() != IgniteError::IGNITE_SUCCESS)
+ BOOST_FAIL(err.GetText());
+
+ testCache = grid.GetCache<int64_t, TestType>("cache");
+
// Allocate an environment handle
SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env);
@@@ -133,71 -138,8 +139,79 @@@
// Releasing allocated handles.
SQLFreeHandle(SQL_HANDLE_DBC, dbc);
SQLFreeHandle(SQL_HANDLE_ENV, env);
+ }
- Ignition::Stop(grid.GetName(), true);
+ static Ignite StartAdditionalNode(const char* name)
+ {
+ IgniteConfiguration cfg;
+
+ cfg.jvmOpts.push_back("-Xdebug");
+ cfg.jvmOpts.push_back("-Xnoagent");
+ cfg.jvmOpts.push_back("-Djava.compiler=NONE");
+ cfg.jvmOpts.push_back("-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005");
+ cfg.jvmOpts.push_back("-XX:+HeapDumpOnOutOfMemoryError");
+
+#ifdef IGNITE_TESTS_32
+ cfg.jvmInitMem = 256;
+ cfg.jvmMaxMem = 768;
+#else
+ cfg.jvmInitMem = 1024;
+ cfg.jvmMaxMem = 4096;
+#endif
+
- cfg.springCfgPath.assign(getenv("IGNITE_NATIVE_TEST_ODBC_CONFIG_PATH")).append("/queries-test-noodbc.xml");
++ char* cfgPath = getenv("IGNITE_NATIVE_TEST_ODBC_CONFIG_PATH");
++
++ BOOST_REQUIRE(cfgPath != 0);
++
++ cfg.springCfgPath.assign(cfgPath).append("/queries-test.xml");
+
+ IgniteError err;
+
+ return Ignition::Start(cfg, name);
+ }
+
+ /**
+ * Constructor.
+ */
+ QueriesTestSuiteFixture() : testCache(0), env(NULL), dbc(NULL), stmt(NULL)
+ {
+ IgniteConfiguration cfg;
+
+ cfg.jvmOpts.push_back("-Xdebug");
+ cfg.jvmOpts.push_back("-Xnoagent");
+ cfg.jvmOpts.push_back("-Djava.compiler=NONE");
+ cfg.jvmOpts.push_back("-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005");
+ cfg.jvmOpts.push_back("-XX:+HeapDumpOnOutOfMemoryError");
+
+#ifdef IGNITE_TESTS_32
+ cfg.jvmInitMem = 256;
+ cfg.jvmMaxMem = 768;
+#else
+ cfg.jvmInitMem = 1024;
+ cfg.jvmMaxMem = 4096;
+#endif
+
- cfg.springCfgPath.assign(getenv("IGNITE_NATIVE_TEST_ODBC_CONFIG_PATH")).append("/queries-test.xml");
++ char* cfgPath = getenv("IGNITE_NATIVE_TEST_ODBC_CONFIG_PATH");
++
++ BOOST_REQUIRE(cfgPath != 0);
++
++ cfg.springCfgPath.assign(cfgPath).append("/queries-test.xml");
+
+ IgniteError err;
+
+ grid = Ignition::Start(cfg, "NodeMain");
+
+ testCache = grid.GetCache<int64_t, TestType>("cache");
+ }
+
+ /**
+ * Destructor.
+ */
+ ~QueriesTestSuiteFixture()
+ {
+ Disconnect();
+
+ Ignition::StopAll(true);
}
template<typename T>
[43/50] [abbrv] ignite git commit: IGNITE-3818: Replace "Kafka" with
"Storm" in Storm streamer README. - Fixes #1025.
Posted by sb...@apache.org.
IGNITE-3818: Replace "Kafka" with "Storm" in Storm streamer README. - Fixes #1025.
Signed-off-by: shtykh_roman <rs...@yahoo.com>
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/347429ac
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/347429ac
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/347429ac
Branch: refs/heads/ignite-961
Commit: 347429ac62f15197ae7d8f1aadc95b15f028e65f
Parents: 9c6e650
Author: shtykh_roman <rs...@yahoo.com>
Authored: Mon Sep 5 10:38:35 2016 +0900
Committer: shtykh_roman <rs...@yahoo.com>
Committed: Mon Sep 5 10:38:35 2016 +0900
----------------------------------------------------------------------
modules/storm/README.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/347429ac/modules/storm/README.txt
----------------------------------------------------------------------
diff --git a/modules/storm/README.txt b/modules/storm/README.txt
index eb20f25..684fdb5 100644
--- a/modules/storm/README.txt
+++ b/modules/storm/README.txt
@@ -5,7 +5,7 @@ Apache Ignite Storm Streamer module provides streaming via Storm to Ignite cache
Starting data transfer to Ignite cache can be done with the following steps.
-1. Import Ignite Kafka Streamer Module In Maven Project
+1. Import Ignite Storm Streamer Module In Maven Project
If you are using Maven to manage dependencies of your project, you can add Storm module
dependency like this (replace '${ignite.version}' with actual Ignite version you are
[11/50] [abbrv] ignite git commit: IGNITE-3739: ODBC: Added GUID
escape sequence support. This closes #988.
Posted by sb...@apache.org.
IGNITE-3739: ODBC: Added GUID escape sequence support. This closes #988.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/ae0b5ebf
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/ae0b5ebf
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/ae0b5ebf
Branch: refs/heads/ignite-961
Commit: ae0b5ebf02f3eb70d24dd3b0eb63dde9843c82b0
Parents: 8aabd6e
Author: Andrey V. Mashenkov <an...@gmail.com>
Authored: Fri Aug 26 11:12:31 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Fri Aug 26 11:12:31 2016 +0300
----------------------------------------------------------------------
.../processors/odbc/escape/OdbcEscapeType.java | 16 ++--
.../processors/odbc/escape/OdbcEscapeUtils.java | 71 +++++++++++++---
.../odbc/OdbcEscapeSequenceSelfTest.java | 86 ++++++++++++++++----
3 files changed, 136 insertions(+), 37 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/ae0b5ebf/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/escape/OdbcEscapeType.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/escape/OdbcEscapeType.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/escape/OdbcEscapeType.java
index 96a2127..3bf0324 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/escape/OdbcEscapeType.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/escape/OdbcEscapeType.java
@@ -63,8 +63,8 @@ public enum OdbcEscapeType {
/** Escape sequence body. */
private final String body;
- /** Whether token must be delimited from the rest of escape sequence. */
- private final boolean delimited;
+ /** Whether this is a standard token with no special handling. */
+ private final boolean standard;
/** Whether empty escape sequence is allowed. */
private final boolean allowEmpty;
@@ -73,12 +73,12 @@ public enum OdbcEscapeType {
* Constructor.
*
* @param body Escape sequence body.
- * @param delimited Whether token must be delimited from the rest of escape sequence.
+ * @param standard Whether this is a standard token with no special handling.
* @param allowEmpty Whether empty escape sequence is allowed.
*/
- OdbcEscapeType(String body, boolean delimited, boolean allowEmpty) {
+ OdbcEscapeType(String body, boolean standard, boolean allowEmpty) {
this.body = body;
- this.delimited = delimited;
+ this.standard = standard;
this.allowEmpty = allowEmpty;
}
@@ -90,10 +90,10 @@ public enum OdbcEscapeType {
}
/**
- * @return Whether token must be delimited from the rest of escape sequence.
+ * @return Whether this is a standard token with no special handling.
*/
- public boolean delimited() {
- return delimited;
+ public boolean standard() {
+ return standard;
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/ae0b5ebf/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/escape/OdbcEscapeUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/escape/OdbcEscapeUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/escape/OdbcEscapeUtils.java
index 6299c7e..83ec9d8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/escape/OdbcEscapeUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/escape/OdbcEscapeUtils.java
@@ -20,11 +20,19 @@ package org.apache.ignite.internal.processors.odbc.escape;
import org.apache.ignite.IgniteException;
import java.util.LinkedList;
+import java.util.regex.Pattern;
/**
* ODBC escape sequence parse.
*/
public class OdbcEscapeUtils {
+
+ /**
+ * GUID regexp pattern: '12345678-9abc-def0-1234-123456789abc'
+ */
+ private static final Pattern GUID_PATTERN =
+ Pattern.compile("^'\\p{XDigit}{8}-\\p{XDigit}{4}-\\p{XDigit}{4}-\\p{XDigit}{4}-\\p{XDigit}{12}'$");
+
/**
* Parse escape sequence.
*
@@ -145,14 +153,11 @@ public class OdbcEscapeUtils {
OdbcEscapeToken token = parseToken(text, startPos, len);
- switch (token.type()) {
- case SCALAR_FUNCTION:
- return parseScalarExpression(text, startPos, len, token);
-
- default:
- throw new IgniteException("Unsupported escape sequence token [text=" +
- substring(text, startPos, len) + ", token=" + token.type().body() + ']');
- }
+ if (token.type().standard())
+ return parseStandardExpression(text, startPos, len, token);
+ else
+ throw new IgniteException("Unsupported escape sequence token [text=" +
+ substring(text, startPos, len) + ", token=" + token.type().body() + ']');
}
else {
// Nothing to escape, return original string.
@@ -191,7 +196,7 @@ public class OdbcEscapeUtils {
else {
empty = (startPos + len == pos + 1);
- if (!empty && typ.delimited()) {
+ if (!empty && typ.standard()) {
char charAfter = text.charAt(pos);
if (!Character.isWhitespace(charAfter))
@@ -216,21 +221,61 @@ public class OdbcEscapeUtils {
}
/**
- * Parse concrete expression.
+ * Parse standard token.
*
* @param text Text.
* @param startPos Start position.
* @param len Length.
* @param token Token.
- * @return Parsed expression.
+ * @return Result.
*/
- private static String parseScalarExpression(String text, int startPos, int len, OdbcEscapeToken token) {
+ private static String parseStandardExpression(String text, int startPos, int len, OdbcEscapeToken token) {
assert validSubstring(text, startPos, len);
+ // Get expression borders.
int startPos0 = startPos + 1 /* open brace */ + token.length() /* token. */;
int len0 = len - 1 /* open brace */ - token.length() /* token */ - 1 /* close brace */;
- return substring(text, startPos0, len0).trim();
+ switch (token.type()) {
+ case SCALAR_FUNCTION:
+ return parseScalarExpression(text, startPos0, len0);
+
+ case GUID:
+ return parseGuidExpression(text, startPos0, len0);
+
+ default:
+ throw new IgniteException("Unsupported escape sequence token [text=" +
+ substring(text, startPos, len) + ", token=" + token.type().body() + ']');
+ }
+ }
+
+ /**
+ * Parse scalar function expression.
+ *
+ * @param text Text.
+ * @param startPos Start position.
+ * @param len Length.
+ * @return Parsed expression.
+ */
+ private static String parseScalarExpression(String text, int startPos, int len) {
+ return substring(text, startPos, len).trim();
+ }
+
+ /**
+ * Parse concrete expression.
+ *
+ * @param text Text.
+ * @param startPos Start position.
+ * @param len Length.
+ * @return Parsed expression.
+ */
+ private static String parseGuidExpression(String text, int startPos, int len) {
+ String val = substring(text, startPos, len).trim();
+
+ if (!GUID_PATTERN.matcher(val).matches())
+ throw new IgniteException("Invalid GUID escape sequence: " + substring(text, startPos, len));
+
+ return val;
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/ae0b5ebf/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/OdbcEscapeSequenceSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/OdbcEscapeSequenceSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/OdbcEscapeSequenceSelfTest.java
index d9be6cc..7225c1a 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/OdbcEscapeSequenceSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/OdbcEscapeSequenceSelfTest.java
@@ -25,18 +25,23 @@ import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import java.util.concurrent.Callable;
/**
- * Scalar function escape sequence parser tests.
+ * Escape sequence parser tests.
*/
public class OdbcEscapeSequenceSelfTest extends GridCommonAbstractTest {
/**
* Test simple cases.
*/
- public void testSimple() {
+ public void testTrivial() {
check(
"select * from table;",
"select * from table;"
);
+ }
+ /**
+ * Test escape sequence series.
+ */
+ public void testSimpleFunction() throws Exception {
check(
"test()",
"{fn test()}"
@@ -51,12 +56,7 @@ public class OdbcEscapeSequenceSelfTest extends GridCommonAbstractTest {
"select test() from table;",
"select {fn test()} from table;"
);
- }
- /**
- * Test escape sequence series.
- */
- public void testSimpleFunction() throws Exception {
check(
"func(field1) func(field2)",
"{fn func(field1)} {fn func(field2)}"
@@ -139,20 +139,15 @@ public class OdbcEscapeSequenceSelfTest extends GridCommonAbstractTest {
}
/**
- * Test non-closed escape sequence.
+ * Test invalid escape sequence.
*/
- public void testFailedOnNonClosedEscapeSequence() {
+ public void testFailedOnInvalidFunctionSequence() {
checkFail("select {fn func1(field1, {fn func2(field2), field3)} from SomeTable;");
- }
- /**
- * Test closing undeclared escape sequence.
- */
- public void testFailedOnClosingNotOpenedSequence() {
- checkFail("select {fn func1(field1, func2(field2)}, field3)} from SomeTable;");
+ checkFail("select {fn func1(field1, fn func2(field2)}, field3)} from SomeTable;");
}
- /**
+ /**
* Test escape sequences with additional whitespace characters
*/
public void testFunctionEscapeSequenceWithWhitespaces() throws Exception {
@@ -166,6 +161,65 @@ public class OdbcEscapeSequenceSelfTest extends GridCommonAbstractTest {
}
/**
+ * Test guid escape sequences
+ */
+ public void testGuidEscapeSequence() {
+ check(
+ "'12345678-9abc-def0-1234-123456789abc'",
+ "{guid '12345678-9abc-def0-1234-123456789abc'}"
+ );
+
+ check(
+ "select '12345678-9abc-def0-1234-123456789abc' from SomeTable;",
+ "select {guid '12345678-9abc-def0-1234-123456789abc'} from SomeTable;"
+ );
+
+ check(
+ "select '12345678-9abc-def0-1234-123456789abc'",
+ "select {guid '12345678-9abc-def0-1234-123456789abc'}"
+ );
+
+ checkFail("select {guid '1234567-1234-1234-1234-123456789abc'}");
+
+ checkFail("select {guid '1234567-8123-4123-4123-4123456789abc'}");
+
+ checkFail("select {guid '12345678-9abc-defg-1234-123456789abc'}");
+
+ checkFail("select {guid '12345678-12345678-1234-1234-1234-123456789abc'}");
+
+ checkFail("select {guid '12345678-1234-1234-1234-123456789abcdef'}");
+ }
+
+ /**
+ * Test invalid escape sequence.
+ */
+ public void testFailedOnInvalidGuidSequence() {
+ checkFail("select {guid '12345678-9abc-def0-1234-123456789abc' from SomeTable;");
+
+ checkFail("select guid '12345678-9abc-def0-1234-123456789abc'} from SomeTable;");
+ }
+
+ /**
+ * Test escape sequences with additional whitespace characters
+ */
+ public void testGuidEscapeSequenceWithWhitespaces() throws Exception {
+ check(
+ "'12345678-9abc-def0-1234-123456789abc'",
+ "{ guid '12345678-9abc-def0-1234-123456789abc'}"
+ );
+
+ check(
+ "'12345678-9abc-def0-1234-123456789abc'",
+ "{ guid '12345678-9abc-def0-1234-123456789abc'}"
+ );
+
+ check(
+ "'12345678-9abc-def0-1234-123456789abc'",
+ "{ \n guid\n'12345678-9abc-def0-1234-123456789abc'}"
+ );
+ }
+
+ /**
* Check parsing logic.
*
* @param exp Expected result.
[33/50] [abbrv] ignite git commit: Merge remote-tracking branch
'ignite-gg/ignite-1.6.7' into ignite-1.7.2
Posted by sb...@apache.org.
Merge remote-tracking branch 'ignite-gg/ignite-1.6.7' into ignite-1.7.2
# Conflicts:
# modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
# modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
# modules/spring/src/test/java/org/apache/ignite/testsuites/IgniteSpringTestSuite.java
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/4a259da2
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/4a259da2
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/4a259da2
Branch: refs/heads/ignite-961
Commit: 4a259da296946740e180d25559e5cacba60a97ad
Parents: fea3eea 1ef150e
Author: EdShangGG <es...@gridgain.com>
Authored: Tue Aug 30 14:39:13 2016 +0300
Committer: EdShangGG <es...@gridgain.com>
Committed: Tue Aug 30 14:39:13 2016 +0300
----------------------------------------------------------------------
.../java/org/apache/ignite/IgniteCache.java | 15 +
.../processors/cache/CacheLazyEntry.java | 2 +
.../EntryProcessorResourceInjectorProxy.java | 105 ++++
.../processors/cache/GridCacheMapEntry.java | 13 +-
.../processors/cache/IgniteCacheProxy.java | 112 +++-
.../GridNearAtomicSingleUpdateFuture.java | 17 +-
.../dht/atomic/GridNearAtomicUpdateFuture.java | 8 +-
.../local/atomic/GridLocalAtomicCache.java | 18 +-
.../processors/cache/query/CacheQuery.java | 11 +-
.../query/GridCacheDistributedQueryManager.java | 22 +-
.../cache/query/GridCacheLocalQueryManager.java | 3 +-
.../cache/query/GridCacheQueryAdapter.java | 69 ++-
.../cache/query/GridCacheQueryBean.java | 8 +-
.../cache/query/GridCacheQueryInfo.java | 8 +-
.../cache/query/GridCacheQueryManager.java | 125 ++--
.../cache/query/GridCacheQueryRequest.java | 6 +-
.../transactions/IgniteTxLocalAdapter.java | 5 +-
.../processors/odbc/escape/OdbcEscapeUtils.java | 115 ++--
.../processors/resource/GridResourceIoc.java | 438 ++++++++++----
.../resource/GridResourceProcessor.java | 396 ++++++-------
.../cache/GridCacheAbstractFullApiSelfTest.java | 393 +++++++++++--
.../cache/GridCacheAbstractSelfTest.java | 140 ++++-
.../GridCacheTransformEventSelfTest.java | 66 ++-
...ePartitionedBasicStoreMultiNodeSelfTest.java | 2 +
.../GridCacheQueryTransformerSelfTest.java | 570 +++++++++++++++++++
.../odbc/OdbcEscapeSequenceSelfTest.java | 164 +++++-
.../multijvm/IgniteCacheProcessProxy.java | 6 +
.../IgniteCacheQuerySelfTestSuite.java | 2 +
.../GridTransformSpringInjectionSelfTest.java | 186 ++++++
.../testsuites/IgniteSpringTestSuite.java | 7 +-
.../commands/cache/VisorCacheStopCommand.scala | 5 +-
.../IgniteInvokeWithInjectionBenchmark.java | 74 +++
.../IgniteInvokeWithInjectionTxBenchmark.java | 30 +
33 files changed, 2564 insertions(+), 577 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/4a259da2/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/4a259da2/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
index 9935f93,454ce04..4b4275f
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
@@@ -1439,12 -1478,9 +1436,12 @@@ public abstract class GridCacheQueryMan
res = loc ?
executeQuery(qry, qryInfo.arguments(), loc, qry.subjectId(), taskName,
- recipient(qryInfo.senderId(), qryInfo.requestId())) :
+ recipient(qryInfo.senderId(), qryInfo.requestId())) :
queryResult(qryInfo, taskName);
+ if (res == null)
+ return;
+
iter = res.iterator(recipient(qryInfo.senderId(), qryInfo.requestId()));
type = res.type();
@@@ -1793,7 -1848,8 +1809,8 @@@
* @return Iterator.
* @throws IgniteCheckedException In case of error.
*/
- @Nullable private QueryResult<K, V> queryResult(final GridCacheQueryInfo qryInfo, String taskName) throws IgniteCheckedException {
- private QueryResult<K, V> queryResult(final GridCacheQueryInfo qryInfo,
++ @Nullable private QueryResult<K, V> queryResult(final GridCacheQueryInfo qryInfo,
+ String taskName) throws IgniteCheckedException {
assert qryInfo != null;
final UUID sndId = qryInfo.senderId();
http://git-wip-us.apache.org/repos/asf/ignite/blob/4a259da2/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/4a259da2/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
----------------------------------------------------------------------
diff --cc modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
index 0203354,3652acd..4198535
--- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
@@@ -126,18 -116,7 +127,19 @@@ public class IgniteCacheQuerySelfTestSu
suite.addTestSuite(IgniteBinaryWrappedObjectFieldsQuerySelfTest.class);
suite.addTestSuite(IgniteCacheQueryH2IndexingLeakTest.class);
suite.addTestSuite(IgniteCacheQueryNoRebalanceSelfTest.class);
+ suite.addTestSuite(GridCacheQueryTransformerSelfTest.class);
+ suite.addTestSuite(IgniteCachePrimitiveFieldsQuerySelfTest.class);
+
+ suite.addTestSuite(IgniteCacheJoinQueryWithAffinityKeyTest.class);
+ suite.addTestSuite(IgniteCacheDistributedJoinCollocatedAndNotTest.class);
+ suite.addTestSuite(IgniteCacheDistributedJoinPartitionedAndReplicatedTest.class);
+ suite.addTestSuite(IgniteCacheDistributedJoinQueryConditionsTest.class);
+ suite.addTestSuite(IgniteCacheDistributedJoinTest.class);
+ suite.addTestSuite(IgniteCacheJoinPartitionedAndReplicatedTest.class);
+ suite.addTestSuite(IgniteCacheDistributedJoinNoIndexTest.class);
+ suite.addTestSuite(IgniteCrossCachesJoinsQueryTest.class);
+ suite.addTestSuite(IgniteCacheCrossCacheJoinRandomTest.class);
+ suite.addTestSuite(IgniteCacheDistributedJoinCustomAffinityMapper.class);
return suite;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4a259da2/modules/spring/src/test/java/org/apache/ignite/testsuites/IgniteSpringTestSuite.java
----------------------------------------------------------------------
diff --cc modules/spring/src/test/java/org/apache/ignite/testsuites/IgniteSpringTestSuite.java
index 3b70556,67b117d..587d46b
--- a/modules/spring/src/test/java/org/apache/ignite/testsuites/IgniteSpringTestSuite.java
+++ b/modules/spring/src/test/java/org/apache/ignite/testsuites/IgniteSpringTestSuite.java
@@@ -18,7 -18,8 +18,9 @@@
package org.apache.ignite.testsuites;
import junit.framework.TestSuite;
+ import org.apache.ignite.cache.spring.GridSpringCacheManagerSelfTest;
+ import org.apache.ignite.cache.spring.SpringCacheManagerContextInjectionTest;
+import org.apache.ignite.internal.IgniteSpringBeanTest;
import org.apache.ignite.cache.store.jdbc.CacheJdbcBlobStoreFactorySelfTest;
import org.apache.ignite.cache.store.jdbc.CacheJdbcPojoStoreFactorySelfTest;
import org.apache.ignite.cache.store.spring.CacheSpringStoreSessionListenerSelfTest;
[18/50] [abbrv] ignite git commit: ignite-2968 Deadlock detection for
optimistic tx and near caches
Posted by sb...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/0465874d/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxPessimisticDeadlockDetectionCrossCacheTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxPessimisticDeadlockDetectionCrossCacheTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxPessimisticDeadlockDetectionCrossCacheTest.java
index abbefd0..4bf5a41 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxPessimisticDeadlockDetectionCrossCacheTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxPessimisticDeadlockDetectionCrossCacheTest.java
@@ -17,7 +17,7 @@
package org.apache.ignite.internal.processors.cache.transactions;
-import java.util.concurrent.ConcurrentMap;
+import java.util.Collection;
import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
@@ -26,6 +26,7 @@ import org.apache.ignite.IgniteCache;
import org.apache.ignite.cache.CacheMode;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.NearCacheConfiguration;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.IgniteKernal;
import org.apache.ignite.internal.util.typedef.internal.U;
@@ -60,22 +61,6 @@ public class TxPessimisticDeadlockDetectionCrossCacheTest extends GridCommonAbst
cfg.setDiscoverySpi(discoSpi);
}
- CacheConfiguration ccfg0 = defaultCacheConfiguration();
-
- ccfg0.setName("cache0");
- ccfg0.setCacheMode(CacheMode.PARTITIONED);
- ccfg0.setBackups(1);
- ccfg0.setNearConfiguration(null);
-
- CacheConfiguration ccfg1 = defaultCacheConfiguration();
-
- ccfg1.setName("cache1");
- ccfg1.setCacheMode(CacheMode.PARTITIONED);
- ccfg1.setBackups(1);
- ccfg1.setNearConfiguration(null);
-
- cfg.setCacheConfiguration(ccfg0, ccfg1);
-
return cfg;
}
@@ -96,70 +81,132 @@ public class TxPessimisticDeadlockDetectionCrossCacheTest extends GridCommonAbst
/**
* @throws Exception If failed.
*/
- public void testDeadlock() throws Exception {
- final CyclicBarrier barrier = new CyclicBarrier(2);
+ public void testDeadlockNoNear() throws Exception {
+ doTestDeadlock(false, false);
+ }
- final AtomicInteger threadCnt = new AtomicInteger();
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDeadlockOneNear() throws Exception {
+ doTestDeadlock(false, true);
+ }
- final AtomicBoolean deadlock = new AtomicBoolean();
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDeadlockAnotherNear() throws Exception {
+ doTestDeadlock(true, false);
+ doTestDeadlock(false, true);
+ }
- IgniteInternalFuture<Long> fut = GridTestUtils.runMultiThreadedAsync(new Runnable() {
- @Override public void run() {
- int threadNum = threadCnt.getAndIncrement();
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDeadlockBothNear() throws Exception {
+ doTestDeadlock(true, true);
+ }
- Ignite ignite = ignite(0);
+ /**
+ * @param near0 Near flag for cache0.
+ * @param near1 Near flag for cache1.
+ */
+ private void doTestDeadlock(boolean near0, boolean near1) throws Exception {
+ IgniteCache<Integer, Integer> cache0 = null;
+ IgniteCache<Integer, Integer> cache1 = null;
- IgniteCache<Integer, Integer> cache1 = ignite.cache("cache" + (threadNum == 0 ? 0 : 1));
+ try {
+ cache0 = getCache(ignite(0), "cache0", near0);
+ cache1 = getCache(ignite(0), "cache1", near1);
- IgniteCache<Integer, Integer> cache2 = ignite.cache("cache" + (threadNum == 0 ? 1 : 0));
+ awaitPartitionMapExchange();
- try (Transaction tx =
- ignite.transactions().txStart(PESSIMISTIC, REPEATABLE_READ, 500, 0)
- ) {
- int key1 = primaryKey(cache1);
+ final CyclicBarrier barrier = new CyclicBarrier(2);
- log.info(">>> Performs put [node=" + ((IgniteKernal)ignite).localNode() +
- ", tx=" + tx + ", key=" + key1 + ", cache=" + cache1.getName() + ']');
+ final AtomicInteger threadCnt = new AtomicInteger();
- cache1.put(key1, 0);
+ final AtomicBoolean deadlock = new AtomicBoolean();
- barrier.await();
+ IgniteInternalFuture<Long> fut = GridTestUtils.runMultiThreadedAsync(new Runnable() {
+ @Override public void run() {
+ int threadNum = threadCnt.getAndIncrement();
- int key2 = primaryKey(cache2);
+ Ignite ignite = ignite(0);
- log.info(">>> Performs put [node=" + ((IgniteKernal)ignite).localNode() +
- ", tx=" + tx + ", key=" + key2 + ", cache=" + cache2.getName() + ']');
+ IgniteCache<Integer, Integer> cache1 = ignite.cache("cache" + (threadNum == 0 ? 0 : 1));
- cache2.put(key2, 1);
+ IgniteCache<Integer, Integer> cache2 = ignite.cache("cache" + (threadNum == 0 ? 1 : 0));
- tx.commit();
- }
- catch (Throwable e) {
- // At least one stack trace should contain TransactionDeadlockException.
- if (hasCause(e, TransactionTimeoutException.class) &&
- hasCause(e, TransactionDeadlockException.class)
- ) {
- if (deadlock.compareAndSet(false, true))
- U.error(log, "At least one stack trace should contain " +
- TransactionDeadlockException.class.getSimpleName(), e);
+ try (Transaction tx =
+ ignite.transactions().txStart(PESSIMISTIC, REPEATABLE_READ, 500, 0)
+ ) {
+ int key1 = primaryKey(cache1);
+
+ log.info(">>> Performs put [node=" + ((IgniteKernal)ignite).localNode() +
+ ", tx=" + tx + ", key=" + key1 + ", cache=" + cache1.getName() + ']');
+
+ cache1.put(key1, 0);
+
+ barrier.await();
+
+ int key2 = primaryKey(cache2);
+
+ log.info(">>> Performs put [node=" + ((IgniteKernal)ignite).localNode() +
+ ", tx=" + tx + ", key=" + key2 + ", cache=" + cache2.getName() + ']');
+
+ cache2.put(key2, 1);
+
+ tx.commit();
+ }
+ catch (Throwable e) {
+ // At least one stack trace should contain TransactionDeadlockException.
+ if (hasCause(e, TransactionTimeoutException.class) &&
+ hasCause(e, TransactionDeadlockException.class)
+ ) {
+ if (deadlock.compareAndSet(false, true))
+ U.error(log, "At least one stack trace should contain " +
+ TransactionDeadlockException.class.getSimpleName(), e);
+ }
}
}
- }
- }, 2, "tx-thread");
+ }, 2, "tx-thread");
- fut.get();
+ fut.get();
- assertTrue(deadlock.get());
+ assertTrue(deadlock.get());
- for (int i = 0; i < NODES_CNT ; i++) {
- Ignite ignite = ignite(i);
+ for (int i = 0; i < NODES_CNT ; i++) {
+ Ignite ignite = ignite(i);
- IgniteTxManager txMgr = ((IgniteKernal)ignite).context().cache().context().tm();
+ IgniteTxManager txMgr = ((IgniteKernal)ignite).context().cache().context().tm();
- ConcurrentMap<Long, TxDeadlockDetection.TxDeadlockFuture> futs =
- GridTestUtils.getFieldValue(txMgr, IgniteTxManager.class, "deadlockDetectFuts");
+ Collection<IgniteInternalFuture<?>> futs = txMgr.deadlockDetectionFutures();
- assertTrue(futs.isEmpty());
+ assertTrue(futs.isEmpty());
+ }
+ }
+ finally {
+ if (cache0 != null)
+ cache0.destroy();
+
+ if (cache1 != null)
+ cache1.destroy();
}
}
+
+ /**
+ * @param ignite Ignite.
+ * @param name Name.
+ * @param near Near.
+ */
+ private IgniteCache<Integer, Integer> getCache(Ignite ignite, String name, boolean near) {
+ CacheConfiguration ccfg = defaultCacheConfiguration();
+
+ ccfg.setName(name);
+ ccfg.setCacheMode(CacheMode.PARTITIONED);
+ ccfg.setBackups(1);
+ ccfg.setNearConfiguration(near ? new NearCacheConfiguration() : null);
+
+ return ignite.getOrCreateCache(ccfg);
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/0465874d/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxPessimisticDeadlockDetectionTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxPessimisticDeadlockDetectionTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxPessimisticDeadlockDetectionTest.java
index ee1a989..83eb908 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxPessimisticDeadlockDetectionTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxPessimisticDeadlockDetectionTest.java
@@ -25,7 +25,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
@@ -43,6 +42,7 @@ import org.apache.ignite.internal.IgniteKernal;
import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
import org.apache.ignite.internal.processors.cache.GridCacheConcurrentMap;
import org.apache.ignite.internal.processors.cache.GridCacheMapEntry;
+import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
import org.apache.ignite.internal.processors.cache.IgniteCacheProxy;
import org.apache.ignite.internal.processors.cache.KeyCacheObject;
import org.apache.ignite.internal.util.GridConcurrentHashSet;
@@ -135,7 +135,7 @@ public class TxPessimisticDeadlockDetectionTest extends GridCommonAbstractTest {
/**
* @throws Exception If failed.
*/
- public void _testDeadlocksPartitionedNear() throws Exception {
+ public void testDeadlocksPartitionedNear() throws Exception {
for (CacheWriteSynchronizationMode syncMode : CacheWriteSynchronizationMode.values()) {
doTestDeadlocks(createCache(PARTITIONED, syncMode, true), NO_OP_TRANSFORMER);
doTestDeadlocks(createCache(PARTITIONED, syncMode, true), WRAPPING_TRANSFORMER);
@@ -178,6 +178,7 @@ public class TxPessimisticDeadlockDetectionTest extends GridCommonAbstractTest {
* @param cacheMode Cache mode.
* @param syncMode Write sync mode.
* @param near Near.
+ * @return Created cache.
*/
@SuppressWarnings("unchecked")
private IgniteCache createCache(CacheMode cacheMode, CacheWriteSynchronizationMode syncMode, boolean near) {
@@ -189,7 +190,19 @@ public class TxPessimisticDeadlockDetectionTest extends GridCommonAbstractTest {
ccfg.setNearConfiguration(near ? new NearCacheConfiguration() : null);
ccfg.setWriteSynchronizationMode(syncMode);
- return ignite(0).getOrCreateCache(ccfg);
+ IgniteCache cache = ignite(0).createCache(ccfg);
+
+ if (near) {
+ for (int i = 0; i < NODES_CNT; i++) {
+ Ignite client = ignite(i + NODES_CNT);
+
+ assertTrue(client.configuration().isClientMode());
+
+ client.createNearCache(ccfg.getName(), new NearCacheConfiguration<>());
+ }
+ }
+
+ return cache;
}
/**
@@ -323,7 +336,14 @@ public class TxPessimisticDeadlockDetectionTest extends GridCommonAbstractTest {
}
}, loc ? 2 : txCnt, "tx-thread");
- fut.get();
+ try {
+ fut.get();
+ }
+ catch (IgniteCheckedException e) {
+ U.error(null, "Unexpected exception", e);
+
+ fail();
+ }
U.sleep(1000);
@@ -331,13 +351,17 @@ public class TxPessimisticDeadlockDetectionTest extends GridCommonAbstractTest {
assertNotNull(deadlockE);
+ boolean fail = false;
+
// Check transactions, futures and entry locks state.
for (int i = 0; i < NODES_CNT * 2; i++) {
Ignite ignite = ignite(i);
int cacheId = ((IgniteCacheProxy)ignite.cache(CACHE_NAME)).context().cacheId();
- IgniteTxManager txMgr = ((IgniteKernal)ignite).context().cache().context().tm();
+ GridCacheSharedContext<Object, Object> cctx = ((IgniteKernal)ignite).context().cache().context();
+
+ IgniteTxManager txMgr = cctx.tm();
Collection<IgniteInternalTx> activeTxs = txMgr.activeTransactions();
@@ -345,13 +369,16 @@ public class TxPessimisticDeadlockDetectionTest extends GridCommonAbstractTest {
Collection<IgniteTxEntry> entries = tx.allEntries();
for (IgniteTxEntry entry : entries) {
- if (entry.cacheId() == cacheId)
- fail("Transaction still exists: " + tx);
+ if (entry.cacheId() == cacheId) {
+ fail = true;
+
+ U.error(log, "Transaction still exists: " + "\n" + tx.xidVersion() +
+ "\n" + tx.nearXidVersion() + "\n nodeId=" + cctx.localNodeId() + "\n tx=" + tx);
+ }
}
}
- ConcurrentMap<Long, TxDeadlockDetection.TxDeadlockFuture> futs =
- GridTestUtils.getFieldValue(txMgr, IgniteTxManager.class, "deadlockDetectFuts");
+ Collection<IgniteInternalFuture<?>> futs = txMgr.deadlockDetectionFutures();
assertTrue(futs.isEmpty());
@@ -371,6 +398,9 @@ public class TxPessimisticDeadlockDetectionTest extends GridCommonAbstractTest {
}
}
+ if (fail)
+ fail("Some transactions still exist");
+
// Check deadlock report
String msg = deadlockE.getMessage();
@@ -484,4 +514,4 @@ public class TxPessimisticDeadlockDetectionTest extends GridCommonAbstractTest {
return id;
}
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/0465874d/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFullApiSelfTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFullApiSelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFullApiSelfTestSuite.java
index 8414461..14e5833 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFullApiSelfTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFullApiSelfTestSuite.java
@@ -36,6 +36,7 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.GridCachePart
import org.apache.ignite.internal.processors.cache.distributed.dht.GridCachePartitionedNearDisabledOffHeapTieredAtomicFullApiSelfTest;
import org.apache.ignite.internal.processors.cache.distributed.dht.GridCachePartitionedNearDisabledOffHeapTieredFullApiSelfTest;
import org.apache.ignite.internal.processors.cache.distributed.dht.GridCachePartitionedNearDisabledOffHeapTieredMultiNodeFullApiSelfTest;
+import org.apache.ignite.internal.processors.cache.distributed.near.CachePartitionedMultiNodeLongTxTimeoutFullApiTest;
import org.apache.ignite.internal.processors.cache.distributed.near.GridCacheAtomicClientOnlyFairAffinityMultiNodeFullApiSelfTest;
import org.apache.ignite.internal.processors.cache.distributed.near.GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest;
import org.apache.ignite.internal.processors.cache.distributed.near.GridCacheAtomicClientOnlyMultiNodeP2PDisabledFullApiSelfTest;
@@ -74,6 +75,7 @@ import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePar
import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePartitionedMultiNodeCounterSelfTest;
import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePartitionedMultiNodeFullApiSelfTest;
import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePartitionedMultiNodeP2PDisabledFullApiSelfTest;
+import org.apache.ignite.internal.processors.cache.distributed.near.CachePartitionedNearEnabledMultiNodeLongTxTimeoutFullApiTest;
import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePartitionedNearOnlyNoPrimaryFullApiSelfTest;
import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePartitionedOffHeapFullApiSelfTest;
import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePartitionedOffHeapMultiNodeFullApiSelfTest;
@@ -167,6 +169,8 @@ public class IgniteCacheFullApiSelfTestSuite extends TestSuite {
suite.addTestSuite(GridCacheAtomicPrimaryWriteOrderMultiNodeP2PDisabledFullApiSelfTest.class);
suite.addTestSuite(GridCacheAtomicNearEnabledMultiNodeFullApiSelfTest.class);
suite.addTestSuite(GridCacheAtomicNearEnabledPrimaryWriteOrderMultiNodeFullApiSelfTest.class);
+ suite.addTestSuite(CachePartitionedMultiNodeLongTxTimeoutFullApiTest.class);
+ suite.addTestSuite(CachePartitionedNearEnabledMultiNodeLongTxTimeoutFullApiTest.class);
suite.addTestSuite(GridCachePartitionedNearDisabledMultiNodeFullApiSelfTest.class);
suite.addTestSuite(GridCachePartitionedNearDisabledMultiNodeP2PDisabledFullApiSelfTest.class);
http://git-wip-us.apache.org/repos/asf/ignite/blob/0465874d/modules/core/src/test/java/org/apache/ignite/testsuites/TxDeadlockDetectionTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/TxDeadlockDetectionTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/TxDeadlockDetectionTestSuite.java
index c057e55..5a1b1ad 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/TxDeadlockDetectionTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/TxDeadlockDetectionTestSuite.java
@@ -19,7 +19,10 @@ package org.apache.ignite.testsuites;
import junit.framework.TestSuite;
import org.apache.ignite.internal.processors.cache.transactions.DepthFirstSearchTest;
+import org.apache.ignite.internal.processors.cache.transactions.TxDeadlockDetectionNoHangsTest;
import org.apache.ignite.internal.processors.cache.transactions.TxDeadlockDetectionTest;
+import org.apache.ignite.internal.processors.cache.transactions.TxOptimisticDeadlockDetectionCrossCacheTest;
+import org.apache.ignite.internal.processors.cache.transactions.TxOptimisticDeadlockDetectionTest;
import org.apache.ignite.internal.processors.cache.transactions.TxPessimisticDeadlockDetectionCrossCacheTest;
import org.apache.ignite.internal.processors.cache.transactions.TxPessimisticDeadlockDetectionTest;
@@ -35,9 +38,12 @@ public class TxDeadlockDetectionTestSuite extends TestSuite {
TestSuite suite = new TestSuite("Ignite Deadlock Detection Test Suite");
suite.addTestSuite(DepthFirstSearchTest.class);
+ suite.addTestSuite(TxOptimisticDeadlockDetectionTest.class);
+ suite.addTestSuite(TxOptimisticDeadlockDetectionCrossCacheTest.class);
suite.addTestSuite(TxPessimisticDeadlockDetectionTest.class);
suite.addTestSuite(TxPessimisticDeadlockDetectionCrossCacheTest.class);
suite.addTestSuite(TxDeadlockDetectionTest.class);
+ suite.addTestSuite(TxDeadlockDetectionNoHangsTest.class);
return suite;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/0465874d/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheStopCommand.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheStopCommand.scala b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheStopCommand.scala
index 22fb89d..1b55505 100644
--- a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheStopCommand.scala
+++ b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheStopCommand.scala
@@ -19,6 +19,7 @@ package org.apache.ignite.visor.commands.cache
import org.apache.ignite.cluster.{ClusterGroupEmptyException, ClusterNode}
import org.apache.ignite.visor.visor._
+
import org.apache.ignite.internal.visor.cache.VisorCacheStopTask
import org.apache.ignite.internal.visor.util.VisorTaskUtils._
@@ -101,9 +102,7 @@ class VisorCacheStopCommand {
return
}
- val dflt = if (batchMode) "y" else "n"
-
- ask(s"Are you sure you want to stop cache: ${escapeName(cacheName)}? (y/n) [$dflt]: ", dflt) match {
+ ask(s"Are you sure you want to stop cache: ${escapeName(cacheName)}? (y/n) [n]: ", "n") match {
case "y" | "Y" =>
try {
executeRandom(grp, classOf[VisorCacheStopTask], cacheName)
[10/50] [abbrv] ignite git commit: IGNITE-3755 .NET: remove unused
CacheFieldsQueryExecutor methods
Posted by sb...@apache.org.
IGNITE-3755 .NET: remove unused CacheFieldsQueryExecutor methods
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/2d5d5bc2
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/2d5d5bc2
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/2d5d5bc2
Branch: refs/heads/ignite-961
Commit: 2d5d5bc2e8aad98da1e20ee9fad7f0c0792fbea5
Parents: 22d3b1e
Author: Pavel Tupitsyn <pt...@apache.org>
Authored: Thu Aug 25 16:55:40 2016 +0300
Committer: Pavel Tupitsyn <pt...@apache.org>
Committed: Thu Aug 25 16:55:40 2016 +0300
----------------------------------------------------------------------
.../Impl/CacheFieldsQueryExecutor.cs | 32 --------------------
1 file changed, 32 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/2d5d5bc2/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheFieldsQueryExecutor.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheFieldsQueryExecutor.cs b/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheFieldsQueryExecutor.cs
index 0c9d4a2..8dfddc7 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheFieldsQueryExecutor.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheFieldsQueryExecutor.cs
@@ -75,38 +75,6 @@ namespace Apache.Ignite.Linq.Impl
_enforceJoinOrder = enforceJoinOrder;
}
- /// <summary>
- /// Gets the local flag.
- /// </summary>
- public bool Local
- {
- get { return _local; }
- }
-
- /// <summary>
- /// Gets the size of the page.
- /// </summary>
- public int PageSize
- {
- get { return _pageSize; }
- }
-
- /// <summary>
- /// Gets a value indicating whether distributed joins are enabled.
- /// </summary>
- public bool EnableDistributedJoins
- {
- get { return _enableDistributedJoins; }
- }
-
- /// <summary>
- /// Gets a value indicating whether join order should be enforced.
- /// </summary>
- public bool EnforceJoinOrder
- {
- get { return _enforceJoinOrder; }
- }
-
/** <inheritdoc /> */
public T ExecuteScalar<T>(QueryModel queryModel)
{
[02/50] [abbrv] ignite git commit: Fixed issues on node stop: - in
service processor need guard depExe access with busyLock - do not error log
IO errors in ClientImpl on stop
Posted by sb...@apache.org.
Fixed issues on node stop:
- in service processor need guard depExe access with busyLock
- do not error log IO errors in ClientImpl on stop
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/d6449ffb
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/d6449ffb
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/d6449ffb
Branch: refs/heads/ignite-961
Commit: d6449ffbc65acda6a2cf4484608188367837dd17
Parents: 13dfcbe
Author: sboikov <sb...@gridgain.com>
Authored: Wed Aug 24 18:34:02 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Wed Aug 24 18:34:02 2016 +0300
----------------------------------------------------------------------
.../processors/service/GridServiceProcessor.java | 18 +++++++++++++-----
.../ignite/spi/discovery/tcp/ClientImpl.java | 7 ++++++-
2 files changed, 19 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/d6449ffb/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
index 01b7302..7b76c48 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
@@ -1355,11 +1355,19 @@ public class GridServiceProcessor extends GridProcessorAdapter {
private class ServiceEntriesListener implements CacheEntryUpdatedListener<Object, Object> {
/** {@inheritDoc} */
@Override public void onUpdated(final Iterable<CacheEntryEvent<?, ?>> deps) {
- depExe.submit(new BusyRunnable() {
- @Override public void run0() {
- onSystemCacheUpdated(deps);
- }
- });
+ if (!busyLock.enterBusy())
+ return;
+
+ try {
+ depExe.submit(new BusyRunnable() {
+ @Override public void run0() {
+ onSystemCacheUpdated(deps);
+ }
+ });
+ }
+ finally {
+ busyLock.leaveBusy();
+ }
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d6449ffb/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
index 9821134..1e71888 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
@@ -1115,7 +1115,12 @@ class ClientImpl extends TcpDiscoveryImpl {
}
}
catch (IgniteCheckedException e) {
- U.error(log, "Failed to send message: " + msg, e);
+ if (spi.getSpiContext().isStopping()) {
+ if (log.isDebugEnabled())
+ log.debug("Failed to send message, node is stopping [msg=" + msg + ", err=" + e + ']');
+ }
+ else
+ U.error(log, "Failed to send message: " + msg, e);
msg = null;
}
[50/50] [abbrv] ignite git commit: Merge master branch to ignite-961
branch
Posted by sb...@apache.org.
Merge master branch to ignite-961 branch
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/7e829bc8
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/7e829bc8
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/7e829bc8
Branch: refs/heads/ignite-961
Commit: 7e829bc84d0fad6b1e75fcf94cda5dcf67aebdbf
Parents: eb3a551 31b9bb8
Author: agura <ag...@gridgain.com>
Authored: Thu Sep 8 18:31:03 2016 +0300
Committer: agura <ag...@gridgain.com>
Committed: Thu Sep 8 18:31:03 2016 +0300
----------------------------------------------------------------------
.gitignore | 42 +-
RELEASE_NOTES.txt | 108 +
assembly/LICENSE_FABRIC | 3 +-
assembly/LICENSE_HADOOP | 1 -
assembly/dependencies-fabric-lgpl.xml | 3 +
assembly/dependencies-fabric.xml | 3 +
assembly/dependencies-schema-import.xml | 1 +
assembly/libs/README.txt | 39 +-
assembly/release-fabric-base.xml | 30 +
assembly/release-schema-import.xml | 2 +-
bin/ignite.bat | 7 +-
bin/ignite.sh | 6 +-
bin/include/hadoop-classpath.bat | 73 -
bin/include/hadoop-classpath.sh | 65 -
bin/include/setenv.bat | 4 +-
bin/include/setenv.sh | 25 +-
config/hadoop/default-config.xml | 111 +-
examples/config/filesystem/example-igfs.xml | 3 -
examples/pom.xml | 2 +-
examples/schema-import/pom.xml | 2 +-
.../java/org/apache/ignite/schema/Demo.java | 23 +-
.../ignite/schema/H2DataSourceFactory.java | 35 +
.../hibernate/HibernateL2CacheExample.java | 2 +-
.../CacheContinuousAsyncQueryExample.java | 138 +
.../datagrid/CacheContinuousQueryExample.java | 13 +-
.../examples/datagrid/CacheQueryExample.java | 78 +-
.../store/CacheLoadOnlyStoreExample.java | 171 +
.../datastructures/IgniteLockExample.java | 293 +
.../streaming/StreamVisitorExample.java | 31 +-
examples/src/main/resources/person.csv | 20 +
.../ignite/examples/CacheExamplesSelfTest.java | 16 +
.../examples/IndexingBridgeMethodTest.java | 93 +
.../IgniteExamplesJ8SelfTestSuite.java | 2 +
modules/aop/pom.xml | 2 +-
modules/apache-license-gen/pom.xml | 2 +-
modules/aws/pom.xml | 40 +-
modules/benchmarks/pom.xml | 6 +-
.../jmh/notify/JmhParkVsNotifyBenchmark.java | 105 +
.../jmh/notify/JmhWaitStategyBenchmark.java | 259 +
.../internal/benchmarks/model/IntValue.java | 19 +-
modules/camel/pom.xml | 2 +-
modules/cassandra/README.txt | 32 +
modules/cassandra/licenses/apache-2.0.txt | 202 +
modules/cassandra/pom.xml | 341 +
.../store/cassandra/CassandraCacheStore.java | 409 ++
.../cassandra/CassandraCacheStoreFactory.java | 200 +
.../store/cassandra/common/CassandraHelper.java | 133 +
.../cassandra/common/PropertyMappingHelper.java | 220 +
.../store/cassandra/common/RandomSleeper.java | 104 +
.../store/cassandra/common/SystemHelper.java | 46 +
.../store/cassandra/common/package-info.java | 21 +
.../store/cassandra/datasource/Credentials.java | 37 +
.../store/cassandra/datasource/DataSource.java | 550 ++
.../cassandra/datasource/PlainCredentials.java | 50 +
.../cassandra/datasource/package-info.java | 21 +
.../cache/store/cassandra/package-info.java | 21 +
.../persistence/KeyPersistenceSettings.java | 274 +
.../KeyValuePersistenceSettings.java | 478 ++
.../persistence/PersistenceController.java | 421 ++
.../persistence/PersistenceSettings.java | 335 +
.../persistence/PersistenceStrategy.java | 62 +
.../store/cassandra/persistence/PojoField.java | 219 +
.../cassandra/persistence/PojoKeyField.java | 91 +
.../cassandra/persistence/PojoValueField.java | 152 +
.../persistence/ValuePersistenceSettings.java | 107 +
.../cassandra/persistence/package-info.java | 21 +
.../cassandra/serializer/JavaSerializer.java | 81 +
.../cassandra/serializer/KryoSerializer.java | 93 +
.../store/cassandra/serializer/Serializer.java | 43 +
.../cassandra/serializer/package-info.java | 21 +
.../session/BatchExecutionAssistant.java | 95 +
.../cassandra/session/BatchLoaderAssistant.java | 47 +
.../cassandra/session/CassandraSession.java | 60 +
.../cassandra/session/CassandraSessionImpl.java | 832 +++
.../cassandra/session/ExecutionAssistant.java | 77 +
.../session/GenericBatchExecutionAssistant.java | 71 +
.../session/LoadCacheCustomQueryWorker.java | 105 +
.../store/cassandra/session/package-info.java | 21 +
.../cassandra/session/pool/SessionPool.java | 173 +
.../cassandra/session/pool/SessionWrapper.java | 71 +
.../cassandra/session/pool/package-info.java | 21 +
.../store/cassandra/utils/DDLGenerator.java | 64 +
.../store/cassandra/utils/package-info.java | 21 +
.../cassandra/src/test/bootstrap/aws/README.txt | 13 +
.../aws/cassandra/cassandra-bootstrap.sh | 336 +
.../bootstrap/aws/cassandra/cassandra-env.sh | 287 +
.../bootstrap/aws/cassandra/cassandra-start.sh | 217 +
.../aws/cassandra/cassandra-template.yaml | 888 +++
.../cassandra/src/test/bootstrap/aws/common.sh | 1481 +++++
modules/cassandra/src/test/bootstrap/aws/env.sh | 113 +
.../test/bootstrap/aws/ganglia/agent-start.sh | 75 +
.../bootstrap/aws/ganglia/ganglia-bootstrap.sh | 417 ++
.../bootstrap/aws/ignite/ignite-bootstrap.sh | 336 +
.../ignite/ignite-cassandra-server-template.xml | 190 +
.../src/test/bootstrap/aws/ignite/ignite-env.sh | 29 +
.../test/bootstrap/aws/ignite/ignite-start.sh | 266 +
.../src/test/bootstrap/aws/logs-collector.sh | 173 +
.../tests/ignite-cassandra-client-template.xml | 192 +
.../test/bootstrap/aws/tests/tests-bootstrap.sh | 317 +
.../test/bootstrap/aws/tests/tests-manager.sh | 458 ++
.../test/bootstrap/aws/tests/tests-report.sh | 499 ++
.../CassandraDirectPersistenceLoadTest.java | 107 +
.../tests/CassandraDirectPersistenceTest.java | 371 ++
.../apache/ignite/tests/DDLGeneratorTest.java | 43 +
.../tests/IgnitePersistentStoreLoadTest.java | 111 +
.../ignite/tests/IgnitePersistentStoreTest.java | 369 ++
.../LoadTestsCassandraArtifactsCreator.java | 104 +
.../org/apache/ignite/tests/load/Generator.java | 27 +
.../apache/ignite/tests/load/IntGenerator.java | 33 +
.../ignite/tests/load/LoadTestDriver.java | 238 +
.../apache/ignite/tests/load/LongGenerator.java | 28 +
.../ignite/tests/load/PersonGenerator.java | 43 +
.../ignite/tests/load/PersonIdGenerator.java | 31 +
.../ignite/tests/load/StringGenerator.java | 28 +
.../org/apache/ignite/tests/load/Worker.java | 429 ++
.../tests/load/cassandra/BulkReadWorker.java | 63 +
.../tests/load/cassandra/BulkWriteWorker.java | 52 +
.../ignite/tests/load/cassandra/ReadWorker.java | 51 +
.../tests/load/cassandra/WriteWorker.java | 51 +
.../tests/load/cassandra/package-info.java | 21 +
.../tests/load/ignite/BulkReadWorker.java | 52 +
.../tests/load/ignite/BulkWriteWorker.java | 52 +
.../ignite/tests/load/ignite/ReadWorker.java | 51 +
.../ignite/tests/load/ignite/WriteWorker.java | 51 +
.../ignite/tests/load/ignite/package-info.java | 21 +
.../apache/ignite/tests/load/package-info.java | 21 +
.../org/apache/ignite/tests/package-info.java | 21 +
.../org/apache/ignite/tests/pojos/Person.java | 246 +
.../org/apache/ignite/tests/pojos/PersonId.java | 110 +
.../apache/ignite/tests/pojos/package-info.java | 21 +
.../ignite/tests/utils/CacheStoreHelper.java | 64 +
.../tests/utils/CassandraAdminCredentials.java | 36 +
.../ignite/tests/utils/CassandraHelper.java | 358 ++
.../tests/utils/CassandraLifeCycleBean.java | 149 +
.../utils/CassandraRegularCredentials.java | 36 +
.../ignite/tests/utils/TestCacheSession.java | 91 +
.../apache/ignite/tests/utils/TestsHelper.java | 375 ++
.../apache/ignite/tests/utils/package-info.java | 21 +
.../src/test/resources/log4j.properties | 119 +
.../tests/cassandra/connection-settings.xml | 52 +
.../tests/cassandra/connection.properties | 17 +
.../tests/cassandra/credentials.properties | 22 +
.../tests/cassandra/embedded-cassandra.yaml | 119 +
.../ignite/tests/cassandra/keyspaces.properties | 17 +
.../tests/persistence/blob/ignite-config.xml | 94 +
.../persistence/blob/persistence-settings-1.xml | 21 +
.../persistence/blob/persistence-settings-2.xml | 21 +
.../persistence/blob/persistence-settings-3.xml | 29 +
.../tests/persistence/pojo/ignite-config.xml | 113 +
.../persistence/pojo/persistence-settings-1.xml | 21 +
.../persistence/pojo/persistence-settings-2.xml | 21 +
.../persistence/pojo/persistence-settings-3.xml | 173 +
.../persistence/primitive/ignite-config.xml | 94 +
.../primitive/ignite-remote-client-config.xml | 99 +
.../primitive/ignite-remote-server-config.xml | 110 +
.../primitive/persistence-settings-1.xml | 21 +
.../primitive/persistence-settings-2.xml | 21 +
.../src/test/resources/tests.properties | 50 +
.../src/test/scripts/cassandra-load-tests.bat | 41 +
.../src/test/scripts/cassandra-load-tests.sh | 39 +
.../src/test/scripts/ignite-load-tests.bat | 41 +
.../src/test/scripts/ignite-load-tests.sh | 39 +
modules/cassandra/src/test/scripts/jvm-opt.sh | 21 +
modules/cassandra/src/test/scripts/jvm-opts.bat | 24 +
.../scripts/recreate-cassandra-artifacts.bat | 41 +
.../scripts/recreate-cassandra-artifacts.sh | 39 +
modules/clients/pom.xml | 10 +-
modules/clients/src/test/config/jdbc-config.xml | 3 +-
.../client/ClientDefaultCacheSelfTest.java | 89 +-
.../ignite/internal/client/ClientHttpTask.java | 33 +-
.../ignite/internal/client/ClientTcpTask.java | 10 +-
.../ClientAbstractMultiNodeSelfTest.java | 8 +-
.../integration/ClientAbstractSelfTest.java | 92 +-
.../internal/jdbc2/JdbcConnectionSelfTest.java | 2 +
.../jdbc2/JdbcDistributedJoinsQueryTest.java | 319 +
.../internal/jdbc2/JdbcMetadataSelfTest.java | 63 +-
.../internal/jdbc2/JdbcNoDefaultCacheTest.java | 161 +
.../internal/jdbc2/JdbcResultSetSelfTest.java | 4 +-
.../JettyRestProcessorAbstractSelfTest.java | 1729 ++++--
.../rest/JettyRestProcessorSignedSelfTest.java | 5 +-
.../JettyRestProcessorUnsignedSelfTest.java | 5 +-
.../rest/RestBinaryProtocolSelfTest.java | 4 +-
.../rest/RestMemcacheProtocolSelfTest.java | 4 +-
.../internal/processors/rest/SimplePerson.java | 74 +
.../ignite/jdbc/JdbcMetadataSelfTest.java | 18 +
.../ignite/jdbc/JdbcNoDefaultCacheTest.java | 161 +
.../ignite/jdbc/JdbcResultSetSelfTest.java | 4 +-
.../jdbc/suite/IgniteJdbcDriverTestSuite.java | 5 +
modules/cloud/pom.xml | 2 +-
modules/codegen/pom.xml | 2 +-
.../ignite/codegen/MessageCodeGenerator.java | 139 +-
modules/core/pom.xml | 23 +-
.../src/main/java/org/apache/ignite/Ignite.java | 21 +-
.../java/org/apache/ignite/IgniteCache.java | 257 +-
.../java/org/apache/ignite/IgniteCompute.java | 69 +-
.../java/org/apache/ignite/IgniteCondition.java | 338 +
.../org/apache/ignite/IgniteDataStreamer.java | 57 +-
.../IgniteDataStreamerTimeoutException.java | 45 +
.../org/apache/ignite/IgniteFileSystem.java | 39 +-
.../org/apache/ignite/IgniteJdbcDriver.java | 16 +-
.../main/java/org/apache/ignite/IgniteLock.java | 489 ++
.../apache/ignite/IgniteSystemProperties.java | 91 +-
.../main/java/org/apache/ignite/Ignition.java | 19 +-
.../ignite/binary/BinaryObjectBuilder.java | 11 +
.../ignite/cache/CacheInterceptorEntry.java | 39 +
.../cache/CacheWriteSynchronizationMode.java | 5 +-
.../org/apache/ignite/cache/QueryEntity.java | 18 +
.../ignite/cache/affinity/AffinityFunction.java | 2 +
.../affinity/fair/FairAffinityFunction.java | 89 +-
.../rendezvous/RendezvousAffinityFunction.java | 45 +-
.../cache/query/CacheQueryEntryEvent.java | 12 +-
.../ignite/cache/query/ContinuousQuery.java | 109 +-
.../ignite/cache/query/SqlFieldsQuery.java | 53 +
.../org/apache/ignite/cache/query/SqlQuery.java | 28 +
.../store/jdbc/CacheAbstractJdbcStore.java | 140 +-
.../cache/store/jdbc/CacheJdbcBlobStore.java | 20 +-
.../cache/store/jdbc/CacheJdbcPojoStore.java | 9 +-
.../store/jdbc/CacheJdbcPojoStoreFactory.java | 85 +-
.../store/jdbc/JdbcTypesDefaultTransformer.java | 117 +
.../cache/store/jdbc/JdbcTypesTransformer.java | 39 +
.../store/jdbc/dialect/BasicJdbcDialect.java | 7 +-
.../cache/store/jdbc/dialect/JdbcDialect.java | 11 +-
.../cache/store/jdbc/dialect/MySQLDialect.java | 18 +-
.../store/jdbc/dialect/SQLServerDialect.java | 2 +-
.../org/apache/ignite/compute/ComputeJob.java | 2 +-
.../ignite/compute/ComputeJobAfterSend.java | 2 +-
.../compute/ComputeJobBeforeFailover.java | 2 +-
.../ignite/compute/ComputeJobContext.java | 2 +-
.../compute/ComputeJobContinuationAdapter.java | 12 +-
.../ignite/compute/ComputeLoadBalancer.java | 12 +-
.../org/apache/ignite/compute/ComputeTask.java | 26 +-
.../ignite/compute/ComputeTaskAdapter.java | 8 +-
.../compute/ComputeTaskNoResultCache.java | 6 +-
.../ignite/compute/ComputeTaskSession.java | 4 +-
.../ignite/compute/ComputeTaskSplitAdapter.java | 8 +-
.../apache/ignite/compute/gridify/Gridify.java | 2 +-
.../configuration/BasicAddressResolver.java | 146 +
.../configuration/CacheConfiguration.java | 10 +
.../configuration/ConnectorConfiguration.java | 4 +
.../configuration/FileSystemConfiguration.java | 154 +-
.../configuration/HadoopConfiguration.java | 41 +-
.../configuration/IgniteConfiguration.java | 166 +-
.../ignite/configuration/OdbcConfiguration.java | 118 +
.../configuration/TransactionConfiguration.java | 40 +
.../igfs/IgfsGroupDataBlocksKeyMapper.java | 43 +-
.../igfs/IgfsIpcEndpointConfiguration.java | 28 +
.../java/org/apache/ignite/igfs/IgfsPath.java | 48 +-
.../org/apache/ignite/igfs/IgfsPathSummary.java | 32 +-
.../apache/ignite/igfs/mapreduce/IgfsTask.java | 6 +-
.../igfs/secondary/IgfsSecondaryFileSystem.java | 6 +-
.../local/LocalIgfsSecondaryFileSystem.java | 406 ++
.../igfs/secondary/local/package-info.java | 22 +
.../ignite/igfs/secondary/package-info.java | 2 +-
.../ignite/internal/GridCodegenConverter.java | 56 +
.../internal/GridEventConsumeHandler.java | 12 +-
.../ignite/internal/GridJobExecuteRequest.java | 148 +-
.../ignite/internal/GridJobExecuteResponse.java | 42 +-
.../ignite/internal/GridKernalContext.java | 16 +
.../ignite/internal/GridKernalContextImpl.java | 28 +-
.../apache/ignite/internal/GridLoggerProxy.java | 3 +-
.../internal/GridMessageListenHandler.java | 12 +-
.../ignite/internal/GridTaskSessionImpl.java | 2 +-
.../org/apache/ignite/internal/GridTopic.java | 5 +-
.../ignite/internal/IgniteComponentType.java | 4 +-
.../ignite/internal/IgniteComputeImpl.java | 120 +-
.../ignite/internal/IgniteEventsImpl.java | 11 +-
.../apache/ignite/internal/IgniteKernal.java | 153 +-
.../ignite/internal/IgniteMessagingImpl.java | 7 +-
.../ignite/internal/IgniteNodeAttributes.java | 10 +
.../ignite/internal/IgniteServicesImpl.java | 2 +-
.../org/apache/ignite/internal/IgnitionEx.java | 90 +-
.../apache/ignite/internal/LessNamingBean.java | 28 +
.../ignite/internal/MarshallerContextImpl.java | 100 +-
.../internal/binary/BinaryClassDescriptor.java | 88 +-
.../ignite/internal/binary/BinaryContext.java | 315 +-
.../internal/binary/BinaryEnumObjectImpl.java | 52 +-
.../internal/binary/BinaryFieldAccessor.java | 1 +
.../binary/BinaryMethodWriteReplacer.java | 59 +
.../ignite/internal/binary/BinaryObjectEx.java | 11 +
.../internal/binary/BinaryObjectExImpl.java | 4 +-
.../internal/binary/BinaryObjectImpl.java | 93 +-
.../binary/BinaryObjectOffheapImpl.java | 48 +-
.../internal/binary/BinaryReaderExImpl.java | 75 +-
.../ignite/internal/binary/BinarySchema.java | 11 +-
.../ignite/internal/binary/BinaryTreeMap.java | 96 +
.../binary/BinaryTreeMapWriteReplacer.java | 34 +
.../ignite/internal/binary/BinaryTreeSet.java | 93 +
.../binary/BinaryTreeSetWriteReplacer.java | 34 +
.../ignite/internal/binary/BinaryTypeImpl.java | 8 +
.../ignite/internal/binary/BinaryTypeProxy.java | 111 +
.../ignite/internal/binary/BinaryUtils.java | 326 +-
.../internal/binary/BinaryWriteReplacer.java | 33 +
.../internal/binary/BinaryWriterExImpl.java | 42 +-
.../internal/binary/GridBinaryMarshaller.java | 7 +-
.../binary/builder/BinaryBuilderReader.java | 11 +-
.../binary/builder/BinaryObjectBuilderImpl.java | 107 +-
.../GridClientConnectionManagerAdapter.java | 25 +-
.../connection/GridClientNioTcpConnection.java | 3 +
.../GridClientOptimizedMarshaller.java | 4 +-
.../GridClientZipOptimizedMarshaller.java | 167 +
.../impl/GridTcpRouterNioListenerAdapter.java | 11 +-
.../internal/cluster/ClusterGroupAdapter.java | 24 +-
.../ignite/internal/cluster/ClusterGroupEx.java | 14 +-
.../internal/cluster/IgniteClusterImpl.java | 9 +-
.../internal/direct/DirectMessageReader.java | 7 +-
.../internal/direct/DirectMessageWriter.java | 4 +-
.../direct/state/DirectMessageState.java | 7 +-
.../stream/v2/DirectByteBufferStreamImplV2.java | 2 +-
.../ignite/internal/jdbc/JdbcStatement.java | 9 +-
.../ignite/internal/jdbc2/JdbcConnection.java | 33 +-
.../ignite/internal/jdbc2/JdbcQueryTask.java | 24 +-
.../ignite/internal/jdbc2/JdbcResultSet.java | 6 +-
.../ignite/internal/jdbc2/JdbcStatement.java | 9 +-
.../logger/platform/PlatformLogger.java | 223 +
.../internal/managers/GridManagerAdapter.java | 21 +-
.../checkpoint/GridCheckpointManager.java | 2 +-
.../managers/communication/GridIoManager.java | 290 +-
.../communication/GridIoMessageFactory.java | 30 +-
.../managers/communication/GridIoPolicy.java | 6 +
.../deployment/GridDeploymentCommunication.java | 5 +-
.../deployment/GridDeploymentLocalStore.java | 2 +-
.../discovery/GridDiscoveryManager.java | 170 +-
.../eventstorage/GridEventStorageManager.java | 10 +-
.../failover/GridFailoverContextImpl.java | 27 +-
.../managers/failover/GridFailoverManager.java | 17 +-
.../affinity/GridAffinityAssignment.java | 64 +-
.../affinity/GridAffinityAssignmentCache.java | 312 +-
.../GridAffinityFunctionContextImpl.java | 9 +
.../affinity/GridAffinityProcessor.java | 143 +-
.../processors/affinity/GridAffinityUtils.java | 6 +-
.../cache/CacheAffinityChangeMessage.java | 160 +
.../cache/CacheAffinitySharedManager.java | 1795 ++++++
.../cache/CacheClusterMetricsMXBeanImpl.java | 410 ++
.../cache/CacheEntryPredicateAdapter.java | 3 +
.../cache/CacheEntrySerializablePredicate.java | 3 +-
.../cache/CacheEvictableEntryImpl.java | 13 +-
.../cache/CacheInvokeDirectResult.java | 3 +-
.../processors/cache/CacheInvokeEntry.java | 41 +-
.../processors/cache/CacheLazyEntry.java | 61 +-
.../cache/CacheLocalMetricsMXBeanImpl.java | 410 ++
.../cache/CacheMetricsMXBeanImpl.java | 410 --
.../internal/processors/cache/CacheObject.java | 3 +
.../processors/cache/CacheObjectContext.java | 15 +
.../processors/cache/CacheOperationFilter.java | 61 +
.../cache/CacheWeakQueryIteratorsHolder.java | 169 +-
.../cache/DynamicCacheChangeRequest.java | 17 +
.../cache/DynamicCacheDescriptor.java | 49 +
.../EntryProcessorResourceInjectorProxy.java | 105 +
.../processors/cache/GridCacheAdapter.java | 1552 +++--
.../cache/GridCacheAffinityManager.java | 154 +-
.../processors/cache/GridCacheAtomicFuture.java | 5 -
.../cache/GridCacheClearAllRunnable.java | 3 +-
.../cache/GridCacheConcurrentMap.java | 1996 +-----
.../cache/GridCacheConcurrentMapImpl.java | 344 +
.../processors/cache/GridCacheContext.java | 92 +-
.../GridCacheDefaultAffinityKeyMapper.java | 19 +
.../cache/GridCacheDeploymentManager.java | 7 +-
.../processors/cache/GridCacheEntryEx.java | 35 +-
.../processors/cache/GridCacheEntryInfo.java | 2 +-
.../processors/cache/GridCacheEntrySet.java | 113 -
.../cache/GridCacheEvictionManager.java | 34 +-
.../processors/cache/GridCacheIoManager.java | 220 +-
.../processors/cache/GridCacheKeySet.java | 104 -
.../processors/cache/GridCacheLogger.java | 3 +-
.../processors/cache/GridCacheMapEntry.java | 1038 ++--
.../processors/cache/GridCacheMessage.java | 15 +-
.../processors/cache/GridCacheMvcc.java | 7 +
.../cache/GridCacheMvccCandidate.java | 16 +-
.../processors/cache/GridCacheMvccManager.java | 160 +-
.../GridCachePartitionExchangeManager.java | 343 +-
.../processors/cache/GridCachePreloader.java | 23 +-
.../cache/GridCachePreloaderAdapter.java | 17 +-
.../processors/cache/GridCacheProcessor.java | 375 +-
.../processors/cache/GridCacheProxyImpl.java | 148 +-
.../processors/cache/GridCacheReturn.java | 10 +-
.../cache/GridCacheSharedContext.java | 122 +-
.../processors/cache/GridCacheSwapManager.java | 161 +-
.../processors/cache/GridCacheTtlManager.java | 91 +-
.../processors/cache/GridCacheUtils.java | 213 +-
.../processors/cache/GridNoStorageCacheMap.java | 107 +
.../processors/cache/IgniteCacheProxy.java | 242 +-
.../processors/cache/IgniteInternalCache.java | 144 +-
.../processors/cache/KeyCacheObject.java | 18 +
.../processors/cache/KeyCacheObjectImpl.java | 40 +-
.../cache/affinity/GridCacheAffinityImpl.java | 9 +-
.../cache/binary/CacheObjectBinaryContext.java | 10 +-
.../binary/CacheObjectBinaryProcessorImpl.java | 113 +-
.../CacheDataStructuresManager.java | 4 +-
.../distributed/GridCacheCommittedTxInfo.java | 1 +
.../distributed/GridCacheTxRecoveryFuture.java | 141 +-
.../distributed/GridCacheTxRecoveryRequest.java | 7 +
.../GridCacheTxRecoveryResponse.java | 29 +-
.../GridDistributedCacheAdapter.java | 6 +-
.../distributed/GridDistributedLockRequest.java | 25 +-
.../GridDistributedLockResponse.java | 17 +-
.../GridDistributedTxFinishRequest.java | 28 +-
.../GridDistributedTxFinishResponse.java | 7 +
.../GridDistributedTxPrepareRequest.java | 38 +-
.../GridDistributedTxPrepareResponse.java | 28 +-
.../GridDistributedTxRemoteAdapter.java | 20 +-
.../GridDistributedUnlockRequest.java | 22 +-
.../dht/CacheDistributedGetFutureAdapter.java | 3 -
.../dht/GridCachePartitionedConcurrentMap.java | 271 +
.../dht/GridClientPartitionTopology.java | 23 +-
.../dht/GridDhtAffinityAssignmentResponse.java | 199 +-
.../dht/GridDhtAssignmentFetchFuture.java | 80 +-
.../distributed/dht/GridDhtCacheAdapter.java | 182 +-
.../distributed/dht/GridDhtCacheEntry.java | 35 +-
.../cache/distributed/dht/GridDhtGetFuture.java | 78 +-
.../distributed/dht/GridDhtGetSingleFuture.java | 6 +
.../distributed/dht/GridDhtLocalPartition.java | 189 +-
.../distributed/dht/GridDhtLockFuture.java | 166 +-
.../distributed/dht/GridDhtLockRequest.java | 16 +-
.../dht/GridDhtOffHeapCacheEntry.java | 8 +
.../dht/GridDhtPartitionTopology.java | 21 +-
.../dht/GridDhtPartitionTopologyImpl.java | 668 +-
.../dht/GridDhtPartitionsReservation.java | 3 +-
.../dht/GridDhtTransactionalCacheAdapter.java | 149 +-
.../distributed/dht/GridDhtTxFinishFuture.java | 125 +-
.../dht/GridDhtTxFinishResponse.java | 3 +-
.../cache/distributed/dht/GridDhtTxLocal.java | 263 +-
.../distributed/dht/GridDhtTxLocalAdapter.java | 15 +-
.../distributed/dht/GridDhtTxPrepareFuture.java | 253 +-
.../dht/GridDhtTxPrepareRequest.java | 4 +-
.../cache/distributed/dht/GridDhtTxRemote.java | 9 +-
.../distributed/dht/GridDhtUnlockRequest.java | 15 +-
.../distributed/dht/GridNoStorageCacheMap.java | 122 -
.../dht/GridPartitionedGetFuture.java | 17 +-
.../dht/GridPartitionedSingleGetFuture.java | 17 +-
.../dht/atomic/GridDhtAtomicCache.java | 962 ++-
.../GridDhtAtomicDeferredUpdateResponse.java | 7 +
.../atomic/GridDhtAtomicOffHeapCacheEntry.java | 8 +
.../dht/atomic/GridDhtAtomicUpdateFuture.java | 183 +-
.../dht/atomic/GridDhtAtomicUpdateRequest.java | 155 +-
.../dht/atomic/GridDhtAtomicUpdateResponse.java | 9 +-
.../GridNearAtomicAbstractUpdateFuture.java | 318 +
.../GridNearAtomicSingleUpdateFuture.java | 600 ++
.../dht/atomic/GridNearAtomicUpdateFuture.java | 1445 ++---
.../dht/atomic/GridNearAtomicUpdateRequest.java | 40 +-
.../atomic/GridNearAtomicUpdateResponse.java | 9 +-
.../dht/colocated/GridDhtColocatedCache.java | 40 +-
.../colocated/GridDhtColocatedLockFuture.java | 188 +-
.../GridDhtColocatedOffHeapCacheEntry.java | 8 +
.../colocated/GridDhtDetachedCacheEntry.java | 2 +-
.../dht/preloader/GridDhtForceKeysFuture.java | 9 +-
.../dht/preloader/GridDhtForceKeysResponse.java | 3 +-
.../GridDhtPartitionDemandMessage.java | 3 +-
.../dht/preloader/GridDhtPartitionDemander.java | 57 +-
.../dht/preloader/GridDhtPartitionMap2.java | 9 +-
.../dht/preloader/GridDhtPartitionSupplier.java | 37 +-
.../GridDhtPartitionsExchangeFuture.java | 1586 ++---
.../preloader/GridDhtPartitionsFullMessage.java | 5 +-
.../GridDhtPartitionsSingleMessage.java | 5 +-
.../dht/preloader/GridDhtPreloader.java | 158 +-
.../distributed/near/GridNearAtomicCache.java | 44 +-
.../distributed/near/GridNearCacheAdapter.java | 114 +-
.../distributed/near/GridNearCacheEntry.java | 118 +-
.../distributed/near/GridNearGetFuture.java | 50 +-
.../distributed/near/GridNearGetRequest.java | 45 +-
.../distributed/near/GridNearGetResponse.java | 3 +-
.../distributed/near/GridNearLockFuture.java | 109 +-
.../distributed/near/GridNearLockRequest.java | 16 +-
...arOptimisticSerializableTxPrepareFuture.java | 24 +-
.../near/GridNearOptimisticTxPrepareFuture.java | 316 +-
...ridNearOptimisticTxPrepareFutureAdapter.java | 21 +-
.../GridNearPessimisticTxPrepareFuture.java | 50 +-
.../near/GridNearSingleGetRequest.java | 24 +-
.../near/GridNearSingleGetResponse.java | 3 +-
.../near/GridNearTransactionalCache.java | 9 +-
.../near/GridNearTxFinishFuture.java | 249 +-
.../near/GridNearTxFinishRequest.java | 46 +-
.../near/GridNearTxFinishResponse.java | 3 +-
.../cache/distributed/near/GridNearTxLocal.java | 126 +-
.../near/GridNearTxPrepareFutureAdapter.java | 19 +-
.../near/GridNearTxPrepareRequest.java | 4 +-
.../distributed/near/GridNearTxRemote.java | 24 +-
.../distributed/near/GridNearUnlockRequest.java | 21 +-
.../processors/cache/dr/GridCacheDrManager.java | 4 +-
.../cache/dr/GridOsCacheDrManager.java | 2 +-
.../processors/cache/local/GridLocalCache.java | 7 +-
.../cache/local/GridLocalCacheEntry.java | 27 -
.../cache/local/GridLocalLockFuture.java | 77 +-
.../local/atomic/GridLocalAtomicCache.java | 190 +-
.../processors/cache/query/CacheQuery.java | 19 +-
.../cache/query/CacheQueryFuture.java | 13 +-
.../query/GridCacheDistributedQueryManager.java | 102 +-
.../cache/query/GridCacheLocalQueryFuture.java | 7 +-
.../cache/query/GridCacheLocalQueryManager.java | 33 +-
.../cache/query/GridCacheQueryAdapter.java | 236 +-
.../cache/query/GridCacheQueryBean.java | 8 +-
.../cache/query/GridCacheQueryErrorFuture.java | 12 +-
.../query/GridCacheQueryFutureAdapter.java | 10 +-
.../cache/query/GridCacheQueryInfo.java | 8 +-
.../cache/query/GridCacheQueryManager.java | 720 ++-
.../cache/query/GridCacheQueryMarshallable.java | 37 +
.../cache/query/GridCacheQueryRequest.java | 19 +-
.../cache/query/GridCacheQueryResponse.java | 3 +-
.../cache/query/GridCacheSqlIndexMetadata.java | 3 +-
.../cache/query/GridCacheSqlMetadata.java | 3 +-
.../cache/query/GridCacheSqlQuery.java | 35 +-
.../cache/query/GridCacheTwoStepQuery.java | 123 +-
.../CacheContinuousQueryBatchAck.java | 4 +
.../continuous/CacheContinuousQueryEntry.java | 54 +-
.../continuous/CacheContinuousQueryEvent.java | 7 +
.../continuous/CacheContinuousQueryHandler.java | 805 ++-
.../CacheContinuousQueryHandlerV2.java | 176 +
.../CacheContinuousQueryListener.java | 6 +-
.../continuous/CacheContinuousQueryManager.java | 451 +-
.../query/jdbc/GridCacheQueryJdbcTask.java | 59 +-
.../jdbc/GridCacheQueryJdbcValidationTask.java | 10 +-
.../store/GridCacheStoreManagerAdapter.java | 32 +-
.../cache/transactions/IgniteInternalTx.java | 43 +-
.../transactions/IgniteTransactionsImpl.java | 9 +-
.../cache/transactions/IgniteTxAdapter.java | 421 +-
.../cache/transactions/IgniteTxEntry.java | 78 +-
.../cache/transactions/IgniteTxHandler.java | 425 +-
.../IgniteTxImplicitSingleStateImpl.java | 53 +-
.../transactions/IgniteTxLocalAdapter.java | 555 +-
.../cache/transactions/IgniteTxLocalEx.java | 26 +-
.../cache/transactions/IgniteTxManager.java | 634 +-
.../IgniteTxRemoteSingleStateImpl.java | 30 +
.../IgniteTxRemoteStateAdapter.java | 16 +-
.../transactions/IgniteTxRemoteStateImpl.java | 72 +-
.../cache/transactions/IgniteTxState.java | 11 +-
.../cache/transactions/IgniteTxStateAware.java | 34 +
.../cache/transactions/IgniteTxStateImpl.java | 53 +-
.../cache/transactions/TxDeadlock.java | 159 +
.../cache/transactions/TxDeadlockDetection.java | 626 ++
.../processors/cache/transactions/TxLock.java | 225 +
.../cache/transactions/TxLockList.java | 134 +
.../cache/transactions/TxLocksRequest.java | 205 +
.../cache/transactions/TxLocksResponse.java | 318 +
.../GridCacheLazyPlainVersionedEntry.java | 107 +
.../version/GridCachePlainVersionedEntry.java | 7 +-
.../version/GridCacheRawVersionedEntry.java | 5 +-
.../cache/version/GridCacheVersion.java | 14 +-
.../cache/version/GridCacheVersionEx.java | 9 +
.../cache/version/GridCacheVersionManager.java | 21 +-
.../cacheobject/IgniteCacheObjectProcessor.java | 18 +-
.../IgniteCacheObjectProcessorImpl.java | 94 +-
.../processors/clock/GridClockServer.java | 3 +-
.../processors/closure/AffinityTask.java | 17 +-
.../processors/closure/GridClosurePolicy.java | 51 -
.../closure/GridClosureProcessor.java | 603 +-
.../processors/cluster/GridUpdateNotifier.java | 3 +-
.../continuous/GridContinuousHandler.java | 9 +-
.../continuous/GridContinuousProcessor.java | 307 +-
.../continuous/GridContinuousQueryBatch.java | 47 +
.../StartRoutineAckDiscoveryMessage.java | 22 +-
.../StartRoutineDiscoveryMessage.java | 22 +-
.../datastreamer/DataStreamProcessor.java | 12 +-
.../datastreamer/DataStreamerImpl.java | 119 +-
.../datastructures/DataStructuresProcessor.java | 167 +-
.../datastructures/GridCacheAtomicLongImpl.java | 3 +-
.../GridCacheAtomicReferenceImpl.java | 4 +-
.../GridCacheAtomicSequenceImpl.java | 3 +-
.../GridCacheAtomicStampedImpl.java | 3 +-
.../GridCacheCountDownLatchImpl.java | 57 +-
.../datastructures/GridCacheLockEx.java | 52 +
.../datastructures/GridCacheLockImpl.java | 1538 +++++
.../datastructures/GridCacheLockState.java | 353 ++
.../datastructures/GridCacheQueueProxy.java | 3 +-
.../datastructures/GridCacheSemaphoreEx.java | 5 +
.../datastructures/GridCacheSemaphoreImpl.java | 271 +-
.../datastructures/GridCacheSetImpl.java | 9 +-
.../datastructures/GridCacheSetProxy.java | 3 +-
.../processors/hadoop/HadoopJobInfo.java | 3 +-
.../processors/hadoop/HadoopNoopProcessor.java | 29 +-
.../hadoop/HadoopProcessorAdapter.java | 7 +
.../internal/processors/igfs/IgfsAsyncImpl.java | 17 +-
.../internal/processors/igfs/IgfsBlockKey.java | 30 +-
.../processors/igfs/IgfsBlockLocationImpl.java | 87 +-
.../IgfsColocatedMetadataAffinityKeyMapper.java | 47 +
.../internal/processors/igfs/IgfsContext.java | 14 +-
.../processors/igfs/IgfsCreateResult.java | 66 +
.../processors/igfs/IgfsDataManager.java | 373 +-
.../processors/igfs/IgfsDeleteResult.java | 62 +
.../processors/igfs/IgfsDeleteWorker.java | 111 +-
.../processors/igfs/IgfsDirectoryInfo.java | 284 +
.../internal/processors/igfs/IgfsEntryInfo.java | 319 +
.../ignite/internal/processors/igfs/IgfsEx.java | 28 +-
.../processors/igfs/IgfsFileAffinityRange.java | 52 +-
.../internal/processors/igfs/IgfsFileImpl.java | 121 +-
.../internal/processors/igfs/IgfsFileInfo.java | 515 +-
.../internal/processors/igfs/IgfsFileMap.java | 50 +-
.../processors/igfs/IgfsFileWorkerBatch.java | 75 +-
.../IgfsFileWorkerBatchCancelledException.java | 51 +
.../igfs/IgfsFragmentizerManager.java | 107 +-
.../internal/processors/igfs/IgfsImpl.java | 757 +--
.../processors/igfs/IgfsInputStreamAdapter.java | 5 +-
.../processors/igfs/IgfsInputStreamImpl.java | 40 +-
.../igfs/IgfsInvalidRangeException.java | 4 +-
.../processors/igfs/IgfsIpcHandler.java | 109 +-
...zySecondaryFileSystemPositionedReadable.java | 77 +
.../processors/igfs/IgfsListingEntry.java | 161 +-
.../processors/igfs/IgfsMetaManager.java | 3169 +++++-----
.../processors/igfs/IgfsModeResolver.java | 103 +-
.../processors/igfs/IgfsNodePredicate.java | 80 +
.../igfs/IgfsOutputStreamAdapter.java | 265 -
.../processors/igfs/IgfsOutputStreamImpl.java | 645 +-
.../internal/processors/igfs/IgfsPathIds.java | 325 +
.../internal/processors/igfs/IgfsPaths.java | 6 +-
.../processors/igfs/IgfsPathsCreateResult.java | 64 +
.../internal/processors/igfs/IgfsProcessor.java | 107 +-
.../IgfsSecondaryFileSystemCreateContext.java | 114 +
.../igfs/IgfsSecondaryFileSystemImpl.java | 15 +-
.../igfs/IgfsSecondaryFileSystemV2.java | 40 +
.../IgfsSecondaryInputStreamDescriptor.java | 6 +-
.../IgfsSecondaryOutputStreamDescriptor.java | 73 -
.../internal/processors/igfs/IgfsServer.java | 2 +-
.../internal/processors/igfs/IgfsUtils.java | 789 ++-
.../igfs/client/IgfsClientAbstractCallable.java | 125 +
.../igfs/client/IgfsClientAffinityCallable.java | 95 +
.../igfs/client/IgfsClientDeleteCallable.java | 77 +
.../igfs/client/IgfsClientExistsCallable.java | 58 +
.../igfs/client/IgfsClientInfoCallable.java | 59 +
.../client/IgfsClientListFilesCallable.java | 61 +
.../client/IgfsClientListPathsCallable.java | 60 +
.../igfs/client/IgfsClientMkdirsCallable.java | 82 +
.../igfs/client/IgfsClientRenameCallable.java | 80 +
.../igfs/client/IgfsClientSetTimesCallable.java | 87 +
.../igfs/client/IgfsClientSizeCallable.java | 59 +
.../igfs/client/IgfsClientSummaryCallable.java | 59 +
.../igfs/client/IgfsClientUpdateCallable.java | 81 +
.../meta/IgfsClientMetaIdsForPathCallable.java | 65 +
.../meta/IgfsClientMetaInfoForPathCallable.java | 63 +
.../meta/IgfsClientMetaUnlockCallable.java | 123 +
.../igfs/data/IgfsDataPutProcessor.java | 99 +
.../meta/IgfsMetaDirectoryCreateProcessor.java | 182 +
.../IgfsMetaDirectoryListingAddProcessor.java | 136 +
...IgfsMetaDirectoryListingRemoveProcessor.java | 132 +
...IgfsMetaDirectoryListingRenameProcessor.java | 133 +
...gfsMetaDirectoryListingReplaceProcessor.java | 130 +
.../igfs/meta/IgfsMetaFileCreateProcessor.java | 194 +
.../igfs/meta/IgfsMetaFileLockProcessor.java | 107 +
.../meta/IgfsMetaFileRangeDeleteProcessor.java | 111 +
.../meta/IgfsMetaFileRangeUpdateProcessor.java | 120 +
.../meta/IgfsMetaFileReserveSpaceProcessor.java | 120 +
.../igfs/meta/IgfsMetaFileUnlockProcessor.java | 166 +
.../meta/IgfsMetaUpdatePropertiesProcessor.java | 121 +
.../igfs/meta/IgfsMetaUpdateTimesProcessor.java | 113 +
.../internal/processors/igfs/package-info.java | 2 +-
.../local/LocalFileSystemIgfsFile.java | 134 +
...fsSecondaryFileSystemPositionedReadable.java | 65 +
.../processors/job/GridJobProcessor.java | 167 +-
.../internal/processors/job/GridJobWorker.java | 209 +-
.../processors/odbc/OdbcBufferedParser.java | 81 +
.../processors/odbc/OdbcColumnMeta.java | 110 +
.../processors/odbc/OdbcHandshakeRequest.java | 83 +
.../processors/odbc/OdbcHandshakeResult.java | 73 +
.../processors/odbc/OdbcMessageParser.java | 289 +
.../processors/odbc/OdbcNioListener.java | 179 +
.../processors/odbc/OdbcNioServerBuffer.java | 114 +
.../internal/processors/odbc/OdbcProcessor.java | 165 +
.../processors/odbc/OdbcProtocolVersion.java | 125 +
.../processors/odbc/OdbcQueryCloseRequest.java | 49 +
.../processors/odbc/OdbcQueryCloseResult.java | 40 +
.../odbc/OdbcQueryExecuteRequest.java | 78 +
.../processors/odbc/OdbcQueryExecuteResult.java | 54 +
.../processors/odbc/OdbcQueryFetchRequest.java | 61 +
.../processors/odbc/OdbcQueryFetchResult.java | 66 +
.../odbc/OdbcQueryGetColumnsMetaRequest.java | 74 +
.../odbc/OdbcQueryGetColumnsMetaResult.java | 42 +
.../odbc/OdbcQueryGetTablesMetaRequest.java | 85 +
.../odbc/OdbcQueryGetTablesMetaResult.java | 42 +
.../internal/processors/odbc/OdbcRequest.java | 58 +
.../processors/odbc/OdbcRequestHandler.java | 394 ++
.../internal/processors/odbc/OdbcResponse.java | 96 +
.../internal/processors/odbc/OdbcTableMeta.java | 85 +
.../internal/processors/odbc/OdbcUtils.java | 56 +
.../odbc/escape/OdbcEscapeParseResult.java | 73 +
.../processors/odbc/escape/OdbcEscapeToken.java | 61 +
.../processors/odbc/escape/OdbcEscapeType.java | 105 +
.../processors/odbc/escape/OdbcEscapeUtils.java | 380 ++
.../offheap/GridOffHeapProcessor.java | 14 +-
.../platform/PlatformAbstractBootstrap.java | 40 +-
.../platform/PlatformAbstractTarget.java | 17 +-
.../processors/platform/PlatformBootstrap.java | 12 +-
.../platform/PlatformConfigurationEx.java | 6 +
.../processors/platform/PlatformContext.java | 16 +
.../platform/PlatformContextImpl.java | 87 +-
.../PlatformDefaultJavaObjectFactory.java | 62 +
.../processors/platform/PlatformIgnition.java | 25 +-
.../platform/PlatformJavaObjectFactoryEx.java | 36 +
.../PlatformJavaObjectFactoryProxy.java | 192 +
.../PlatformJavaObjectSingletonFactory.java | 48 +
.../platform/PlatformNoopProcessor.java | 29 +-
.../processors/platform/PlatformProcessor.java | 42 +
.../platform/PlatformProcessorImpl.java | 170 +-
.../platform/cache/PlatformCache.java | 387 +-
.../affinity/PlatformAffinityFunction.java | 304 +
.../PlatformAffinityFunctionTarget.java | 113 +
.../cache/affinity/PlatformAffinityUtils.java | 118 +
.../query/PlatformContinuousQueryImpl.java | 50 +-
.../callback/PlatformCallbackGateway.java | 147 +-
.../callback/PlatformCallbackUtils.java | 77 +
.../platform/cluster/PlatformClusterGroup.java | 19 +
.../platform/compute/PlatformAbstractTask.java | 1 +
.../platform/compute/PlatformCompute.java | 26 +-
.../cpp/PlatformCppConfigurationEx.java | 6 +
.../datastreamer/PlatformDataStreamer.java | 7 +-
.../dotnet/PlatformDotNetBootstrap.java | 21 +
.../dotnet/PlatformDotNetCacheStore.java | 37 +-
.../PlatformDotNetConfigurationClosure.java | 59 +-
.../dotnet/PlatformDotNetConfigurationEx.java | 12 +-
.../dotnet/PlatformDotNetConsoleStream.java | 54 +
.../services/PlatformAbstractService.java | 3 +-
.../platform/services/PlatformServices.java | 249 +-
.../utils/PlatformConfigurationUtils.java | 500 +-
.../platform/utils/PlatformFutureUtils.java | 6 +-
.../platform/utils/PlatformUtils.java | 234 +
.../processors/plugin/CachePluginManager.java | 25 +
.../processors/query/GridQueryIndexing.java | 51 +-
.../processors/query/GridQueryProcessor.java | 228 +-
.../query/GridQueryTypeDescriptor.java | 7 +
.../messages/GridQueryCancelRequest.java | 2 +-
.../twostep/messages/GridQueryFailResponse.java | 2 +-
.../messages/GridQueryNextPageRequest.java | 2 +-
.../messages/GridQueryNextPageResponse.java | 12 +-
.../h2/twostep/messages/GridQueryRequest.java | 28 +-
.../processors/resource/GridResourceIoc.java | 438 +-
.../GridResourceJobContextInjector.java | 4 +-
.../resource/GridResourceProcessor.java | 396 +-
.../message/GridClientHandshakeRequest.java | 4 +-
.../handlers/cache/GridCacheCommandHandler.java | 102 +-
.../handlers/log/GridLogCommandHandler.java | 32 +-
.../handlers/query/QueryCommandHandler.java | 28 +-
.../handlers/task/GridTaskCommandHandler.java | 8 +-
.../protocols/tcp/GridTcpRestNioListener.java | 19 +-
.../rest/protocols/tcp/GridTcpRestProtocol.java | 19 +-
.../rest/request/RestQueryRequest.java | 19 +-
.../service/GridServiceAssignments.java | 10 +-
.../service/GridServiceNotFoundException.java | 4 +-
.../service/GridServiceProcessor.java | 884 ++-
.../processors/service/GridServiceProxy.java | 244 +-
.../service/LazyServiceConfiguration.java | 129 +
.../processors/service/ServiceContextImpl.java | 29 +-
.../service/ServiceDescriptorImpl.java | 17 +-
.../processors/task/GridTaskProcessor.java | 11 +-
.../processors/task/GridTaskWorker.java | 280 +-
.../apache/ignite/internal/util/ClassCache.java | 32 +
.../org/apache/ignite/internal/util/F0.java | 4 +-
.../internal/util/GridExecutionStatistics.java | 106 -
.../ignite/internal/util/GridJavaProcess.java | 5 +-
.../ignite/internal/util/GridLeanSet.java | 1 +
.../ignite/internal/util/HostAndPortRange.java | 205 +
.../internal/util/IgniteExceptionRegistry.java | 5 +-
.../ignite/internal/util/IgniteUtils.java | 281 +-
.../util/StripedCompositeReadWriteLock.java | 184 +
.../util/future/GridCompoundFuture.java | 100 +-
.../internal/util/future/GridFutureAdapter.java | 3 +-
.../shmem/IpcSharedMemoryServerEndpoint.java | 6 +-
.../ignite/internal/util/lang/GridFunc.java | 119 +-
.../ignite/internal/util/lang/GridTuple.java | 2 -
.../ignite/internal/util/lang/GridTuple3.java | 2 -
.../ignite/internal/util/lang/GridTuple4.java | 2 -
.../ignite/internal/util/lang/GridTuple5.java | 2 -
.../ignite/internal/util/lang/GridTuple6.java | 2 -
.../ignite/internal/util/lang/GridTupleV.java | 1 +
.../internal/util/nio/GridDirectParser.java | 4 +-
.../util/nio/GridNioRecoveryDescriptor.java | 40 +-
.../ignite/internal/util/nio/GridNioServer.java | 107 +-
.../util/nio/GridSelectorNioSessionImpl.java | 7 +
.../util/nio/GridTcpNioCommunicationClient.java | 5 +-
.../offheap/unsafe/GridOffHeapSnapTreeMap.java | 91 +-
.../util/offheap/unsafe/GridUnsafeLru.java | 30 +-
.../util/offheap/unsafe/GridUnsafeMap.java | 4 +-
.../apache/ignite/internal/util/typedef/PN.java | 2 +-
.../apache/ignite/internal/util/typedef/X.java | 2 +-
.../ignite/internal/visor/cache/VisorCache.java | 77 +-
.../cache/VisorCacheAffinityConfiguration.java | 5 +-
.../visor/cache/VisorCacheAffinityNodeTask.java | 70 +
.../cache/VisorCacheAggregatedMetrics.java | 116 +-
.../visor/cache/VisorCacheConfiguration.java | 8 +-
.../cache/VisorCacheDefaultConfiguration.java | 5 +-
.../cache/VisorCacheEvictionConfiguration.java | 5 +-
.../internal/visor/cache/VisorCacheMetrics.java | 102 +-
.../cache/VisorCacheMetricsCollectorTask.java | 21 +-
.../visor/cache/VisorCacheMetricsV2.java | 66 +
.../cache/VisorCacheNearConfiguration.java | 5 +-
.../visor/cache/VisorCachePartition.java | 90 +
.../visor/cache/VisorCachePartitions.java | 89 +
.../visor/cache/VisorCachePartitionsTask.java | 152 +
.../cache/VisorCacheQueryConfiguration.java | 3 +-
.../visor/cache/VisorCacheQueryMetrics.java | 5 +-
.../cache/VisorCacheRebalanceConfiguration.java | 5 +-
.../visor/cache/VisorCacheResetMetricsTask.java | 2 +-
.../cache/VisorCacheStoreConfiguration.java | 3 +-
.../cache/VisorCacheTypeFieldMetadata.java | 3 +-
.../visor/cache/VisorCacheTypeMetadata.java | 23 +-
.../internal/visor/cache/VisorCacheV2.java | 2 +-
.../internal/visor/cache/VisorCacheV3.java | 52 +
.../internal/visor/cache/VisorCacheV4.java | 124 +
.../visor/compute/VisorGatewayTask.java | 362 ++
.../internal/visor/debug/VisorThreadInfo.java | 5 +-
.../visor/debug/VisorThreadLockInfo.java | 5 +-
.../internal/visor/event/VisorGridEvent.java | 5 +-
.../internal/visor/file/VisorFileBlock.java | 5 +-
.../ignite/internal/visor/igfs/VisorIgfs.java | 7 +-
.../internal/visor/igfs/VisorIgfsEndpoint.java | 5 +-
.../internal/visor/igfs/VisorIgfsMetrics.java | 16 +-
.../visor/igfs/VisorIgfsProfilerEntry.java | 5 +-
.../visor/igfs/VisorIgfsProfilerTask.java | 20 +-
.../VisorIgfsProfilerUniformityCounters.java | 5 +-
.../visor/log/VisorLogSearchResult.java | 5 +-
.../visor/node/VisorAtomicConfiguration.java | 5 +-
.../visor/node/VisorBasicConfiguration.java | 5 +-
.../node/VisorExecutorServiceConfiguration.java | 5 +-
.../visor/node/VisorGridConfiguration.java | 5 +-
.../visor/node/VisorIgfsConfiguration.java | 3 +-
.../visor/node/VisorLifecycleConfiguration.java | 5 +-
.../visor/node/VisorMetricsConfiguration.java | 5 +-
.../visor/node/VisorNodeDataCollectorJob.java | 74 +-
.../visor/node/VisorNodeDataCollectorTask.java | 26 -
.../node/VisorNodeDataCollectorTaskResult.java | 5 +-
.../node/VisorPeerToPeerConfiguration.java | 5 +-
.../visor/node/VisorRestConfiguration.java | 5 +-
.../node/VisorSegmentationConfiguration.java | 5 +-
.../visor/node/VisorSpisConfiguration.java | 5 +-
.../node/VisorTransactionConfiguration.java | 5 +-
.../internal/visor/query/VisorQueryArgV2.java | 49 +
.../internal/visor/query/VisorQueryField.java | 5 +-
.../internal/visor/query/VisorQueryJob.java | 39 +-
.../internal/visor/query/VisorQueryResult.java | 5 +-
.../query/VisorQueryScanSubstringFilter.java | 63 +
.../internal/visor/query/VisorQueryUtils.java | 6 +
.../internal/visor/util/VisorTaskUtils.java | 22 +-
.../WebSessionAttributeProcessor.java | 134 +
.../internal/websession/WebSessionEntity.java | 193 +
.../apache/ignite/lang/IgniteAsyncCallback.java | 111 +
.../java/org/apache/ignite/lang/IgniteUuid.java | 2 +-
.../ignite/logger/java/JavaLoggerFormatter.java | 4 +-
.../apache/ignite/marshaller/Marshaller.java | 6 +-
.../OptimizedObjectStreamRegistry.java | 151 +-
.../platform/PlatformJavaObjectFactory.java | 36 +
.../dotnet/PlatformDotNetAffinityFunction.java | 186 +
.../ignite/plugin/CachePluginProvider.java | 11 +
.../extensions/communication/MessageReader.java | 9 +
.../plugin/security/SecurityPermissionSet.java | 5 +-
.../ignite/plugin/security/SecuritySubject.java | 5 +-
.../ignite/resources/JobContextResource.java | 4 +-
.../SpringApplicationContextResource.java | 4 +-
.../apache/ignite/resources/SpringResource.java | 15 +-
.../ignite/scheduler/SchedulerFuture.java | 5 +-
.../ignite/services/ServiceConfiguration.java | 14 +-
.../ignite/spi/IgniteNodeValidationResult.java | 8 +-
.../org/apache/ignite/spi/IgniteSpiAdapter.java | 42 +-
.../ignite/spi/IgniteSpiConsistencyChecked.java | 8 +
.../jobstealing/JobStealingCollisionSpi.java | 14 +-
.../jobstealing/JobStealingDisabled.java | 2 +-
.../communication/tcp/TcpCommunicationSpi.java | 220 +-
.../tcp/TcpCommunicationSpiMBean.java | 8 +-
.../ignite/spi/discovery/tcp/ClientImpl.java | 50 +-
.../ignite/spi/discovery/tcp/ServerImpl.java | 863 ++-
.../spi/discovery/tcp/TcpDiscoveryImpl.java | 13 +-
.../spi/discovery/tcp/TcpDiscoverySpi.java | 41 +-
.../tcp/internal/TcpDiscoveryNode.java | 43 +-
.../tcp/internal/TcpDiscoveryStatistics.java | 45 +-
.../ipfinder/jdbc/BasicJdbcIpFinderDialect.java | 28 +
.../tcp/ipfinder/jdbc/JdbcIpFinderDialect.java | 28 +
.../jdbc/OracleJdbcIpFinderDialect.java | 28 +
.../ipfinder/jdbc/TcpDiscoveryJdbcIpFinder.java | 69 +-
.../TcpDiscoveryMulticastIpFinder.java | 1 +
.../sharedfs/TcpDiscoverySharedFsIpFinder.java | 60 +-
.../messages/TcpDiscoveryAbstractMessage.java | 4 +-
.../TcpDiscoveryClientHeartbeatMessage.java | 1 +
.../TcpDiscoveryClientReconnectMessage.java | 16 +
.../TcpDiscoveryCustomEventMessage.java | 15 +-
.../TcpDiscoveryJoinRequestMessage.java | 16 +-
.../TcpDiscoveryStatusCheckMessage.java | 18 +-
.../ignite/spi/failover/FailoverContext.java | 15 +-
.../spi/failover/always/AlwaysFailoverSpi.java | 15 +-
.../spi/indexing/IndexingQueryFilter.java | 9 +
.../spi/loadbalancing/LoadBalancingSpi.java | 8 +-
.../adaptive/AdaptiveLoadBalancingSpi.java | 20 +-
.../adaptive/AdaptiveLoadProbe.java | 2 +-
.../roundrobin/RoundRobinLoadBalancingSpi.java | 6 +-
.../WeightedRandomLoadBalancingSpi.java | 14 +-
.../spi/swapspace/file/FileSwapSpaceSpi.java | 2 +
.../spi/swapspace/noop/NoopSwapSpaceSpi.java | 2 +
.../thread/IgniteStripedThreadPoolExecutor.java | 164 +-
.../org/apache/ignite/thread/IgniteThread.java | 34 +-
.../ignite/thread/IgniteThreadFactory.java | 7 +-
.../apache/ignite/transactions/Transaction.java | 19 +-
.../TransactionDeadlockException.java | 42 +
.../TransactionTimeoutException.java | 5 +-
.../java/org/jetbrains/annotations/NotNull.java | 38 -
.../org/jetbrains/annotations/Nullable.java | 33 -
.../org/jetbrains/annotations/package-info.java | 27 -
.../resources/META-INF/classnames.properties | 249 +-
.../core/src/main/resources/ignite.properties | 2 +-
modules/core/src/test/config/igfs-loopback.xml | 7 -
modules/core/src/test/config/igfs-shmem.xml | 7 -
modules/core/src/test/config/log4j-test.xml | 6 +
.../config/websession/example-cache-base.xml | 148 +
.../config/websession/example-cache-client.xml | 33 +
.../test/config/websession/example-cache.xml | 128 +-
.../test/config/websession/example-cache2.xml | 31 +
.../GridCacheAffinityBackupsSelfTest.java | 2 +-
.../AbstractAffinityFunctionSelfTest.java | 18 +-
.../affinity/AffinityClientNodeSelfTest.java | 77 +-
...ityFunctionBackupFilterAbstractSelfTest.java | 131 +-
.../affinity/AffinityHistoryCleanupTest.java | 414 ++
...airAffinityFunctionBackupFilterSelfTest.java | 9 +
.../fair/FairAffinityFunctionNodesSelfTest.java | 2 +
.../local/LocalAffinityFunctionTest.java | 80 +
...ousAffinityFunctionBackupFilterSelfTest.java | 9 +
.../CacheJdbcPojoStoreAbstractSelfTest.java | 69 +-
...eJdbcStoreAbstractMultithreadedSelfTest.java | 25 +-
.../cache/store/jdbc/H2DataSourceFactory.java | 35 +
.../ignite/cache/store/jdbc/model/Person.java | 25 +
.../ignite/igfs/IgfsEventsAbstractSelfTest.java | 24 +-
.../igfs/IgfsFragmentizerAbstractSelfTest.java | 4 +-
.../ignite/igfs/IgfsFragmentizerSelfTest.java | 2 -
.../ignite/internal/ClusterGroupSelfTest.java | 30 +-
.../internal/ClusterNodeMetricsSelfTest.java | 101 +-
.../ComputeJobCancelWithServiceSelfTest.java | 154 +
.../ignite/internal/GridAffinitySelfTest.java | 9 +-
...omputationBinarylizableClosuresSelfTest.java | 413 ++
.../GridEventStorageCheckAllEventsSelfTest.java | 30 +-
.../ignite/internal/GridGetOrStartSelfTest.java | 70 +
.../GridJobMasterLeaveAwareSelfTest.java | 4 +-
...ectionLocalJobMultipleArgumentsSelfTest.java | 4 +-
.../GridTaskCancelSingleNodeSelfTest.java | 37 +-
.../internal/GridTaskExecutionSelfTest.java | 90 +-
.../GridTaskFailoverAffinityRunTest.java | 8 +-
.../IgniteClientReconnectAbstractTest.java | 15 +-
.../IgniteClientReconnectAtomicsTest.java | 66 +-
.../IgniteClientReconnectCollectionsTest.java | 4 +-
.../IgniteClientReconnectComputeTest.java | 6 +-
...eClientReconnectContinuousProcessorTest.java | 60 +-
.../IgniteClientReconnectFailoverTest.java | 2 +
.../IgniteClientReconnectServicesTest.java | 4 +-
.../IgniteClientReconnectStreamerTest.java | 2 +-
.../IgniteComputeEmptyClusterGroupTest.java | 8 +-
...eConcurrentEntryProcessorAccessStopTest.java | 82 +
.../IgniteLocalNodeMapBeforeStartTest.java | 82 +
.../MarshallerContextLockingSelfTest.java | 139 +
.../internal/TestRecordingCommunicationSpi.java | 65 +-
.../ignite/internal/binary/AffinityKey.java | 69 +
.../internal/binary/BinaryEnumsSelfTest.java | 51 +-
.../binary/BinaryMarshallerSelfTest.java | 263 +-
.../BinaryObjectBuilderAdditionalSelfTest.java | 220 +-
...naryObjectBuilderDefaultMappersSelfTest.java | 2 +-
.../internal/binary/BinaryTreeSelfTest.java | 341 +
.../binary/GridBinaryAffinityKeySelfTest.java | 19 +-
.../binary/GridBinaryWildcardsSelfTest.java | 53 +-
...aultBinaryMappersBinaryMetaDataSelfTest.java | 17 +
.../GridDiscoveryManagerAttributesSelfTest.java | 126 +
.../BinaryObjectOffHeapUnswapTemporaryTest.java | 368 ++
.../cache/CacheAffinityCallSelfTest.java | 85 +-
.../cache/CacheClientStoreSelfTest.java | 209 +-
.../cache/CacheEntryProcessorCopySelfTest.java | 213 +
.../cache/CacheEnumOperationsAbstractTest.java | 32 +
.../cache/CacheGetEntryAbstractTest.java | 39 +-
...GetEntryOptimisticReadCommittedSeltTest.java | 2 +-
...erceptorPartitionCounterLocalSanityTest.java | 687 ++
...torPartitionCounterRandomOperationsTest.java | 1054 ++++
.../CacheMetricsForClusterGroupSelfTest.java | 2 +-
.../processors/cache/CacheNamesSelfTest.java | 16 +-
.../CacheNamesWithSpecialCharactersTest.java | 71 +
...cheNearUpdateTopologyChangeAbstractTest.java | 2 +
.../cache/CacheReadThroughRestartSelfTest.java | 2 +
.../CacheSerializableTransactionsTest.java | 5 +
.../CacheStartupInDeploymentModesTest.java | 230 +
.../CacheStoreUsageMultinodeAbstractTest.java | 5 +-
.../cache/CacheSwapUnswapGetTest.java | 4 +-
.../processors/cache/CacheTxFastFinishTest.java | 253 +
.../CacheTxNotAllowReadFromBackupTest.java | 297 +
.../cache/CrossCacheTxRandomOperationsTest.java | 13 +-
.../EntryVersionConsistencyReadThroughTest.java | 265 +
.../cache/GridCacheAbstractFullApiSelfTest.java | 877 ++-
.../GridCacheAbstractLocalStoreSelfTest.java | 480 +-
.../cache/GridCacheAbstractMetricsSelfTest.java | 126 +-
.../GridCacheAbstractRemoveFailureTest.java | 10 +-
.../cache/GridCacheAbstractSelfTest.java | 224 +-
...acheAbstractUsersAffinityMapperSelfTest.java | 2 +-
.../cache/GridCacheDeploymentSelfTest.java | 2 +
.../cache/GridCacheEntryVersionSelfTest.java | 2 +-
.../GridCacheInterceptorAbstractSelfTest.java | 2 +-
.../GridCacheOffHeapValuesEvictionSelfTest.java | 18 +-
.../GridCacheOnCopyFlagAbstractSelfTest.java | 479 +-
.../GridCachePartitionedLocalStoreSelfTest.java | 6 -
...chePartitionedOffHeapLocalStoreSelfTest.java | 6 -
.../GridCachePreloadingEvictionsSelfTest.java | 4 +-
.../GridCacheReplicatedLocalStoreSelfTest.java | 6 -
...ridCacheStoreManagerDeserializationTest.java | 354 ++
.../cache/GridCacheStoreValueBytesSelfTest.java | 2 +-
...ridCacheSwapSpaceSpiConsistencySelfTest.java | 146 +
...acheTcpClientDiscoveryMultiThreadedTest.java | 2 +-
.../processors/cache/GridCacheTestEntryEx.java | 18 +-
...cheTransactionalAbstractMetricsSelfTest.java | 4 +-
.../GridCacheTtlManagerNotificationTest.java | 202 +
.../cache/GridCacheTtlManagerSelfTest.java | 2 +-
...ridCacheTxPartitionedLocalStoreSelfTest.java | 6 -
...idCacheValueConsistencyAbstractSelfTest.java | 9 +-
.../GridCacheVersionTopologyChangeTest.java | 246 +
...calCacheStoreManagerDeserializationTest.java | 101 +
.../processors/cache/H2CacheStoreStrategy.java | 468 ++
.../cache/IgniteCacheAbstractTest.java | 8 +-
.../cache/IgniteCacheAtomicPeekModesTest.java | 2 +-
.../IgniteCacheBinaryObjectsScanSelfTest.java | 2 +
.../IgniteCacheConfigVariationsFullApiTest.java | 5876 ++++++++++++++++++
.../cache/IgniteCacheCreateRestartSelfTest.java | 2 -
.../IgniteCacheEntryListenerAbstractTest.java | 91 +-
.../cache/IgniteCacheEntryListenerTxTest.java | 5 -
.../IgniteCacheEntryProcessorNodeJoinTest.java | 147 +-
...niteCacheExpireAndUpdateConsistencyTest.java | 437 ++
.../cache/IgniteCacheIncrementTxTest.java | 299 +
.../IgniteCacheInterceptorSelfTestSuite.java | 2 +
...gniteCacheInvokeReadThroughAbstractTest.java | 382 ++
...iteCacheInvokeReadThroughSingleNodeTest.java | 106 +
.../cache/IgniteCacheInvokeReadThroughTest.java | 182 +-
.../cache/IgniteCacheNearLockValueSelfTest.java | 2 +-
.../IgniteCacheP2pUnmarshallingErrorTest.java | 1 -
...CacheP2pUnmarshallingRebalanceErrorTest.java | 36 +-
.../IgniteCacheP2pUnmarshallingTxErrorTest.java | 2 +
.../cache/IgniteCachePeekModesAbstractTest.java | 471 +-
.../IgniteCachePutStackOverflowSelfTest.java | 133 +
.../IgniteCacheReadThroughEvictionSelfTest.java | 297 +
...acheReadThroughEvictionsVariationsSuite.java | 58 +
.../IgniteCacheReadThroughStoreCallTest.java | 288 +
.../IgniteClientAffinityAssignmentSelfTest.java | 2 +-
...eDynamicCacheStartNoExchangeTimeoutTest.java | 2 +
...niteDynamicCacheStartStopConcurrentTest.java | 8 +-
.../IgniteDynamicClientCacheStartSelfTest.java | 107 +-
.../cache/IgniteTxConfigCacheSelfTest.java | 288 +
.../IgniteTxExceptionAbstractSelfTest.java | 38 +-
.../cache/IgniteTxReentryAbstractSelfTest.java | 2 +-
.../IgniteTxStoreExceptionAbstractSelfTest.java | 8 +-
...rceptorCacheConfigVariationsFullApiTest.java | 118 +
...terceptorWithKeepBinaryCacheFullApiTest.java | 124 +
.../processors/cache/MapCacheStoreStrategy.java | 145 +
.../MarshallerCacheJobRunNodeRestartTest.java | 307 +
.../cache/TestCacheStoreStrategy.java | 96 +
.../cache/WithKeepBinaryCacheFullApiTest.java | 1234 ++++
.../CacheKeepBinaryWithInterceptorTest.java | 419 ++
...acheBinaryObjectUserClassloaderSelfTest.java | 274 +
.../GridCacheBinaryObjectsAbstractSelfTest.java | 299 +-
...eAbstractDataStructuresFailoverSelfTest.java | 264 +-
...actQueueFailoverDataConsistencySelfTest.java | 2 +-
.../GridCacheQueueCleanupSelfTest.java | 4 +-
.../GridCacheSequenceApiSelfAbstractTest.java | 37 -
.../GridCacheSetAbstractSelfTest.java | 5 +-
.../GridCacheSetFailoverAbstractSelfTest.java | 8 +-
.../IgniteClientDataStructuresAbstractTest.java | 70 +
.../IgniteCountDownLatchAbstractSelfTest.java | 158 +-
.../IgniteDataStructureUniqueNameTest.java | 16 +-
.../IgniteLockAbstractSelfTest.java | 1629 +++++
.../IgniteSemaphoreAbstractSelfTest.java | 56 +-
.../local/IgniteLocalLockSelfTest.java | 110 +
.../IgnitePartitionedLockSelfTest.java | 33 +
.../IgnitePartitionedQueueNoBackupsTest.java | 6 +-
.../IgnitePartitionedSetNoBackupsSelfTest.java | 6 +-
.../IgniteReplicatedLockSelfTest.java | 33 +
.../CacheGetInsideLockChangingTopologyTest.java | 6 +
...eLateAffinityAssignmentFairAffinityTest.java | 32 +
...ffinityAssignmentNodeJoinValidationTest.java | 134 +
.../CacheLateAffinityAssignmentTest.java | 2684 ++++++++
.../GridCacheAbstractJobExecutionTest.java | 6 +-
.../distributed/GridCacheLockAbstractTest.java | 2 +-
.../GridCacheTransformEventSelfTest.java | 68 +-
...niteCacheClientNodeChangingTopologyTest.java | 37 +-
...teCacheClientNodePartitionsExchangeTest.java | 85 +-
.../IgniteCacheClientReconnectTest.java | 2 +
.../IgniteCacheConnectionRecoveryTest.java | 205 +
.../distributed/IgniteCacheCreatePutTest.java | 143 +-
.../distributed/IgniteCacheGetRestartTest.java | 4 +
.../distributed/IgniteCacheManyClientsTest.java | 6 +
.../IgniteCacheMessageRecoveryAbstractTest.java | 14 +-
...eCacheMessageRecoveryIdleConnectionTest.java | 157 +
.../IgniteCacheMessageWriteTimeoutTest.java | 129 +
.../IgniteCacheNearRestartRollbackSelfTest.java | 28 +-
.../distributed/IgniteCachePrimarySyncTest.java | 45 +-
.../IgniteCacheReadFromBackupTest.java | 12 +-
.../IgniteCacheServerNodeConcurrentStart.java | 3 +
.../IgniteCacheSingleGetMessageTest.java | 8 +-
.../IgniteCacheTxIteratorSelfTest.java | 241 +
.../IgniteTxCachePrimarySyncTest.java | 1114 ++++
...teSynchronizationModesMultithreadedTest.java | 422 ++
.../IgniteTxTimeoutAbstractTest.java | 8 +-
.../dht/GridCacheColocatedDebugTest.java | 2 +-
.../dht/GridCacheDhtEvictionSelfTest.java | 15 +-
.../GridCacheDhtPreloadMessageCountTest.java | 6 +-
.../distributed/dht/GridCacheDhtTestUtils.java | 9 +-
...ePartitionedNearDisabledMetricsSelfTest.java | 2 +-
...idCachePartitionedPreloadEventsSelfTest.java | 11 +
...ridCachePartitionedUnloadEventsSelfTest.java | 2 +
.../dht/GridCacheTxNodeFailureSelfTest.java | 12 +-
.../dht/IgniteCacheConcurrentPutGetRemove.java | 201 +
.../IgniteCachePutRetryAbstractSelfTest.java | 4 +-
...tionedMultiNodeLongTxTimeoutFullApiTest.java | 34 +
...nabledMultiNodeLongTxTimeoutFullApiTest.java | 41 +
...imaryWriteOrderMultiNodeFullApiSelfTest.java | 35 +
...AtomicPartitionedTckMetricsSelfTestImpl.java | 92 +-
.../near/GridCacheNearJobExecutionSelfTest.java | 2 -
.../near/GridCacheNearMetricsSelfTest.java | 152 +-
.../near/GridCacheNearMultiNodeSelfTest.java | 4 +-
.../near/GridCacheNearOneNodeSelfTest.java | 4 +-
...idCacheNearOnlyMultiNodeFullApiSelfTest.java | 170 +-
.../near/GridCacheNearReadersSelfTest.java | 2 +
.../near/GridCacheNearTxForceKeyTest.java | 6 +-
...ePartitionedBasicStoreMultiNodeSelfTest.java | 2 +
...idCachePartitionedHitsAndMissesSelfTest.java | 2 +-
...LateAffDisabledMultiNodeFullApiSelfTest.java | 34 +
...achePartitionedMultiNodeCounterSelfTest.java | 43 +-
...achePartitionedMultiNodeFullApiSelfTest.java | 2 +
...edOffHeapTieredMultiNodeFullApiSelfTest.java | 2 +-
...achePartitionedPreloadLifecycleSelfTest.java | 102 +-
...idCacheRendezvousAffinityClientSelfTest.java | 2 +
.../rebalancing/CacheNodeSafeAssertion.java | 118 +
...cingDelayedPartitionMapExchangeSelfTest.java | 14 +-
.../GridCacheRebalancingOrderingTest.java | 916 +++
...cheRebalancingPartitionDistributionTest.java | 149 +
.../GridCacheRebalancingSyncSelfTest.java | 245 +-
.../GridCacheReplicatedJobExecutionTest.java | 2 -
.../IgniteCacheSyncRebalanceModeSelfTest.java | 116 +
...CacheReplicatedPreloadLifecycleSelfTest.java | 132 +-
...idCacheReplicatedPreloadOffHeapSelfTest.java | 3 +-
.../GridCacheReplicatedPreloadSelfTest.java | 216 +-
.../IgniteCacheExpiryPolicyAbstractTest.java | 3 +-
.../IgniteCacheExpiryPolicyTestSuite.java | 9 +
.../expiry/IgniteCacheTtlCleanupSelfTest.java | 2 +-
.../IgniteCacheLoaderWriterAbstractTest.java | 10 +
...CacheLocalOffHeapAndSwapMetricsSelfTest.java | 415 --
.../CacheOffHeapAndSwapMetricsSelfTest.java | 621 ++
...dCacheAtomicLocalTckMetricsSelfTestImpl.java | 92 +-
.../local/GridCacheLocalTxTimeoutSelfTest.java | 5 +-
.../GridCacheQueryTransformerSelfTest.java | 570 ++
...FailoverAtomicPrimaryWriteOrderSelfTest.java | 50 +
...sQueryAsyncFailoverTxReplicatedSelfTest.java | 37 +
...eContinuousQueryAsyncFailoverTxSelfTest.java | 44 +
...eContinuousQueryAsyncFilterListenerTest.java | 986 +++
...acheContinuousQueryExecuteInPrimaryTest.java | 306 +
...ryFactoryAsyncFilterRandomOperationTest.java | 131 +
...usQueryFactoryFilterRandomOperationTest.java | 725 +++
...ContinuousQueryFailoverAbstractSelfTest.java | 114 +-
.../CacheContinuousQueryLostPartitionTest.java | 14 +-
...ontinuousQueryOperationFromCallbackTest.java | 627 ++
.../CacheContinuousQueryOperationP2PTest.java | 326 +
.../CacheContinuousQueryOrderingEventTest.java | 722 +++
...acheContinuousQueryRandomOperationsTest.java | 606 +-
...inuousQueryRandomOperationsTwoNodesTest.java | 28 +
.../CacheContinuousQueryVariationsTest.java | 949 +++
.../CacheEntryProcessorNonSerializableTest.java | 410 ++
...CacheKeepBinaryIterationNearEnabledTest.java | 44 +
...acheKeepBinaryIterationStoreEnabledTest.java | 90 +
...CacheKeepBinaryIterationSwapEnabledTest.java | 56 +
.../CacheKeepBinaryIterationTest.java | 471 ++
...yRemoteFilterMissingInClassPathSelfTest.java | 237 +
...ridCacheContinuousQueryAbstractSelfTest.java | 49 +-
.../GridCacheContinuousQueryConcurrentTest.java | 466 ++
...eContinuousQueryMultiNodesFilteringTest.java | 278 +
...dCacheContinuousQueryNodesFilteringTest.java | 168 +
...niteCacheContinuousQueryBackupQueueTest.java | 299 +
...eCacheContinuousQueryImmutableEntryTest.java | 205 +
...teCacheContinuousQueryNoUnsubscribeTest.java | 153 +
...BehindStorePartitionedMultiNodeSelfTest.java | 11 +-
.../transactions/DepthFirstSearchTest.java | 350 ++
.../TxDeadlockDetectionNoHangsTest.java | 246 +
.../transactions/TxDeadlockDetectionTest.java | 494 ++
...timisticDeadlockDetectionCrossCacheTest.java | 257 +
.../TxOptimisticDeadlockDetectionTest.java | 574 ++
...simisticDeadlockDetectionCrossCacheTest.java | 212 +
.../TxPessimisticDeadlockDetectionTest.java | 517 ++
.../cluster/GridAddressResolverSelfTest.java | 97 +
...gniteComputeConfigVariationsFullApiTest.java | 2011 ++++++
.../continuous/GridMessageListenSelfTest.java | 30 +-
.../IgniteNoCustomEventsOnNodeStart.java | 85 +
.../datastreamer/DataStreamerTimeoutTest.java | 163 +
...faultIgfsSecondaryFileSystemTestAdapter.java | 117 +
.../igfs/IgfsAbstractBaseSelfTest.java | 1067 ++++
.../processors/igfs/IgfsAbstractSelfTest.java | 1951 ++----
.../igfs/IgfsBackupFailoverSelfTest.java | 2 +-
...lockMessageSystemPoolStarvationSelfTest.java | 299 +
...sCachePerBlockLruEvictionPolicySelfTest.java | 7 +-
.../igfs/IgfsClientCacheSelfTest.java | 139 -
.../igfs/IgfsDataManagerSelfTest.java | 79 +-
.../igfs/IgfsDualAbstractSelfTest.java | 369 +-
.../igfs/IgfsDualAsyncClientSelfTest.java | 28 +
.../igfs/IgfsDualSyncClientSelfTest.java | 28 +
.../igfs/IgfsExUniversalFileSystemAdapter.java | 101 -
.../processors/igfs/IgfsFileInfoSelfTest.java | 26 +-
.../processors/igfs/IgfsIgniteMock.java | 501 ++
...SecondaryFileSystemDualAbstractSelfTest.java | 219 +
...ondaryFileSystemDualAsyncClientSelfTest.java | 28 +
...calSecondaryFileSystemDualAsyncSelfTest.java | 32 +
...condaryFileSystemDualSyncClientSelfTest.java | 28 +
...ocalSecondaryFileSystemDualSyncSelfTest.java | 32 +
...IgfsLocalSecondaryFileSystemTestAdapter.java | 141 +
.../igfs/IgfsMetaManagerSelfTest.java | 125 +-
.../processors/igfs/IgfsMetricsSelfTest.java | 54 +-
.../internal/processors/igfs/IgfsMock.java | 410 ++
.../igfs/IgfsModeResolverSelfTest.java | 161 +-
.../processors/igfs/IgfsModesSelfTest.java | 64 +-
.../processors/igfs/IgfsOneClientNodeTest.java | 7 +-
.../igfs/IgfsPrimaryClientSelfTest.java | 30 +
.../igfs/IgfsPrimaryMultiNodeSelfTest.java | 28 +
.../IgfsPrimaryOptimziedMarshallerSelfTest.java | 28 +
...PrimaryRelaxedConsistencyClientSelfTest.java | 28 +
...maryRelaxedConsistencyMultiNodeSelfTest.java | 28 +
.../IgfsPrimaryRelaxedConsistencySelfTest.java | 28 +
.../processors/igfs/IgfsProcessorSelfTest.java | 71 +-
.../igfs/IgfsProcessorValidationSelfTest.java | 70 +-
.../IgfsSecondaryFileSystemTestAdapter.java | 118 +
.../processors/igfs/IgfsSizeSelfTest.java | 151 +-
.../processors/igfs/IgfsStartCacheTest.java | 9 +-
.../processors/igfs/IgfsStreamsSelfTest.java | 32 +-
.../processors/igfs/IgfsTaskSelfTest.java | 2 +-
.../igfs/UniversalFileSystemAdapter.java | 98 -
...niteMessagingConfigVariationFullApiTest.java | 484 ++
.../odbc/OdbcEscapeSequenceSelfTest.java | 572 ++
.../odbc/OdbcProcessorValidationSelfTest.java | 144 +
.../GridCacheAtomicCommandHandlerSelfTest.java | 39 +
.../cache/GridCacheCommandHandlerSelfTest.java | 20 +-
.../handlers/log/GridLogCommandHandlerTest.java | 97 +-
.../query/GridQueryCommandHandlerTest.java | 191 +
.../service/GridServiceClientNodeTest.java | 102 +-
...rviceDeploymentExceptionPropagationTest.java | 80 +
...GridServiceProxyClientReconnectSelfTest.java | 124 +
.../GridServiceProxyNodeStopSelfTest.java | 105 +
...gniteServiceConfigVariationsFullApiTest.java | 350 ++
...yment2ClassLoadersDefaultMarshallerTest.java | 259 +
...eployment2ClassLoadersJdkMarshallerTest.java | 31 +
...ent2ClassLoadersOptimizedMarshallerTest.java | 31 +
...oymentClassLoadingDefaultMarshallerTest.java | 212 +
...DeploymentClassLoadingJdkMarshallerTest.java | 31 +
...mentClassLoadingOptimizedMarshallerTest.java | 31 +
.../service/IgniteServiceReassignmentTest.java | 250 +
.../ServicePredicateAccessCacheTest.java | 4 +-
.../processors/service/inner/MyService.java | 11 +
.../processors/service/inner/MyServiceImpl.java | 10 +
.../internal/util/IgniteUtilsSelfTest.java | 15 +
...GridUnsafeDataOutputArraySizingSelfTest.java | 144 +-
.../unsafe/GridOffheapSnapTreeSelfTest.java | 2 +-
.../ignite/jvmtest/ConcurrentMapTest.java | 3 +-
.../cache/GridCacheDataStructuresLoadTest.java | 53 +
.../GridTcpCommunicationBenchmark.java | 26 +-
.../loadtests/hashmap/GridCacheTestContext.java | 2 +
...namicProxySerializationMultiJvmSelfTest.java | 106 +-
.../marshaller/MarshallerContextTestImpl.java | 7 +
.../OptimizedMarshallerPooledSelfTest.java | 8 +
.../GridP2PMissedResourceCacheSizeSelfTest.java | 6 +-
.../platform/PlatformAttributeNodeFilter.java | 31 +
.../platform/PlatformCacheEntryEventFilter.java | 193 +
.../PlatformCacheEntryEventFilterFactory.java | 59 +
.../platform/PlatformComputeEchoTask.java | 11 +-
...latformDefaultJavaObjectFactorySelfTest.java | 185 +
.../platform/PlatformDeployServiceTask.java | 360 ++
.../PlatformJavaObjectFactoryProxySelfTest.java | 220 +
.../ignite/platform/PlatformSqlQueryTask.java | 117 +
.../platform/PlatformStartIgniteTask.java | 78 +
.../ignite/platform/PlatformStopIgniteTask.java | 75 +
.../ignite/platform/PlatformStringTestTask.java | 67 +
.../platform/javaobject/TestJavaObject.java | 271 +
.../javaobject/TestJavaObjectNoDefaultCtor.java | 49 +
.../TestJavaObjectNoDefaultCtorFactory.java | 68 +
.../spi/GridTcpSpiForwardingSelfTest.java | 237 +-
.../GridTcpCommunicationSpiConfigSelfTest.java | 22 +
.../tcp/TcpClientDiscoverySpiSelfTest.java | 48 +-
.../tcp/TcpDiscoveryMultiThreadedTest.java | 222 +
.../spi/discovery/tcp/TcpDiscoverySelfTest.java | 274 +-
.../tcp/TcpDiscoverySpiConfigSelfTest.java | 22 +
.../TcpDiscoverySpiFailureTimeoutSelfTest.java | 23 +-
.../spi/discovery/tcp/TestTcpDiscoverySpi.java | 5 +-
.../jdbc/TcpDiscoveryJdbcIpFinderSelfTest.java | 2 +-
.../TcpDiscoverySharedFsIpFinderSelfTest.java | 25 +
.../vm/TcpDiscoveryVmIpFinderSelfTest.java | 75 +
.../spi/failover/GridFailoverTestContext.java | 6 +
.../GridSwapSpaceSpiConsistencySelfTest.java | 131 +
.../properties/NotStringSystemPropertyTest.java | 124 +
.../ignite/testframework/GridTestUtils.java | 5 +-
.../ignite/testframework/IgniteTestSuite.java | 191 +
.../assertions/AlwaysAssertion.java | 29 +
.../testframework/assertions/Assertion.java | 31 +
.../testframework/assertions/package-info.java | 22 +
.../configvariations/CacheStartMode.java | 29 +
.../configvariations/ConfigFactory.java | 39 +
.../configvariations/ConfigParameter.java | 34 +
.../configvariations/ConfigVariations.java | 346 ++
.../ConfigVariationsFactory.java | 197 +
.../ConfigVariationsTestSuiteBuilder.java | 401 ++
.../IgniteConfigVariationsTestSuite.java | 50 +
.../configvariations/Parameters.java | 377 ++
.../configvariations/VariationsIterator.java | 174 +
.../configvariations/VariationsTestsConfig.java | 174 +
.../testframework/junits/GridAbstractTest.java | 65 +-
.../junits/GridTestKernalContext.java | 35 +-
...IgniteCacheConfigVariationsAbstractTest.java | 547 ++
.../IgniteConfigVariationsAbstractTest.java | 660 ++
.../ignite/testframework/junits/IgniteMock.java | 10 +
.../junits/common/GridCommonAbstractTest.java | 222 +-
.../common/GridRollingRestartAbstractTest.java | 324 +
.../multijvm/IgniteCacheProcessProxy.java | 168 +-
.../multijvm/IgniteClusterProcessProxy.java | 5 +
.../junits/multijvm/IgniteProcessProxy.java | 31 +-
.../ConfigVariationsTestSuiteBuilderTest.java | 112 +
.../testframework/test/ParametersTest.java | 87 +
.../test/VariationsIteratorTest.java | 156 +
...naryObjectsTxDeadlockDetectionTestSuite.java | 37 +
.../ignite/testsuites/IgniteBasicTestSuite.java | 23 +-
.../testsuites/IgniteBinaryCacheTestSuite.java | 2 +
...IgniteBinaryObjectsComputeGridTestSuite.java | 7 +-
.../IgniteBinaryObjectsTestSuite.java | 13 +-
...heBasicConfigVariationsFullApiTestSuite.java | 41 +
.../IgniteCacheDataStructuresSelfTestSuite.java | 17 +-
.../IgniteCacheFailoverTestSuite.java | 2 +
.../IgniteCacheFullApiSelfTestSuite.java | 10 +
.../IgniteCacheMetricsSelfTestSuite.java | 4 +-
.../ignite/testsuites/IgniteCacheTestSuite.java | 24 +
.../testsuites/IgniteCacheTestSuite2.java | 7 +
.../testsuites/IgniteCacheTestSuite3.java | 4 +
.../testsuites/IgniteCacheTestSuite4.java | 26 +-
.../testsuites/IgniteCacheTestSuite5.java | 22 +-
...teBasicConfigVariationsFullApiTestSuite.java | 72 +
...iteContinuousQueryConfigVariationsSuite.java | 60 +
.../ignite/testsuites/IgniteIgfsTestSuite.java | 39 +-
.../apache/ignite/testsuites/IgniteIgnore.java | 35 +
.../testsuites/IgniteIgnoredTestSuite.java | 63 +
.../testsuites/IgniteKernalSelfTestSuite.java | 27 +-
.../IgniteMarshallerSelfTestSuite.java | 2 +-
...essagingConfigVariationFullApiTestSuite.java | 72 +
.../testsuites/IgnitePlatformsTestSuite.java | 41 +
.../testsuites/IgniteRestHandlerTestSuite.java | 4 +
...ServiceConfigVariationsFullApiTestSuite.java | 92 +
.../IgniteSpiSwapSpaceSelfTestSuite.java | 2 +
...orCacheConfigVariationsFullApiTestSuite.java | 41 +
.../TxDeadlockDetectionTestSuite.java | 50 +
...ryCacheConfigVariationsFullApiTestSuite.java | 71 +
modules/docker/1.6.0/Dockerfile | 44 +
modules/docker/1.6.0/run.sh | 51 +
modules/docker/1.7.0/Dockerfile | 44 +
modules/docker/1.7.0/run.sh | 51 +
modules/docker/Dockerfile | 24 +-
modules/extdata/p2p/pom.xml | 2 +-
...CacheDeploymentCachePluginConfiguration.java | 7 +
.../p2p/CacheDeploymentEntryEventFilter.java | 33 +
.../CacheDeploymentEntryEventFilterFactory.java | 31 +
.../CacheDeploymentExternalizableTestValue.java | 69 +
.../apache/ignite/tests/p2p/NoopService.java | 41 +
.../apache/ignite/tests/p2p/NoopService2.java | 41 +
.../extdata/uri/modules/uri-dependency/pom.xml | 2 +-
modules/extdata/uri/pom.xml | 2 +-
modules/flink/README.txt | 33 +
modules/flink/licenses/apache-2.0.txt | 202 +
modules/flink/pom.xml | 167 +
.../apache/ignite/sink/flink/IgniteSink.java | 204 +
.../apache/ignite/sink/flink/package-info.java | 22 +
.../sink/flink/FlinkIgniteSinkSelfTest.java | 188 +
.../flink/FlinkIgniteSinkSelfTestSuite.java | 38 +
.../flink/src/test/resources/example-ignite.xml | 70 +
modules/flume/pom.xml | 2 +-
modules/gce/pom.xml | 2 +-
modules/geospatial/pom.xml | 2 +-
.../query/h2/opt/GridH2SpatialIndex.java | 74 +-
modules/hadoop/pom.xml | 2 +-
.../hadoop/fs/BasicHadoopFileSystemFactory.java | 56 +-
.../fs/CachingHadoopFileSystemFactory.java | 7 +-
.../fs/IgniteHadoopIgfsSecondaryFileSystem.java | 63 +-
.../fs/KerberosHadoopFileSystemFactory.java | 4 +-
.../hadoop/fs/v1/IgniteHadoopFileSystem.java | 26 +-
.../hadoop/fs/v2/IgniteHadoopFileSystem.java | 50 +-
.../IgniteHadoopClientProtocolProvider.java | 1 +
.../mapreduce/IgniteHadoopMapReducePlanner.java | 120 +-
.../IgniteHadoopWeightedMapReducePlanner.java | 846 +++
.../ignite/hadoop/util/BasicUserNameMapper.java | 112 +
.../hadoop/util/ChainedUserNameMapper.java | 94 +
.../hadoop/util/KerberosUserNameMapper.java | 137 +
.../ignite/hadoop/util/UserNameMapper.java | 37 +
.../apache/ignite/hadoop/util/package-info.java | 22 +
.../processors/hadoop/HadoopAttributes.java | 168 +
.../processors/hadoop/HadoopClassLoader.java | 122 +-
.../processors/hadoop/HadoopClasspathMain.java | 44 +
.../processors/hadoop/HadoopClasspathUtils.java | 295 +
.../processors/hadoop/HadoopContext.java | 3 +-
.../processors/hadoop/HadoopDefaultJobInfo.java | 8 +-
.../processors/hadoop/HadoopLocations.java | 123 +
.../processors/hadoop/HadoopProcessor.java | 118 +-
.../internal/processors/hadoop/HadoopUtils.java | 81 +
.../hadoop/igfs/HadoopIgfsProperties.java | 11 +-
.../hadoop/igfs/HadoopIgfsWrapper.java | 11 +-
.../hadoop/jobtracker/HadoopJobTracker.java | 22 +-
.../planner/HadoopAbstractMapReducePlanner.java | 116 +
.../planner/HadoopMapReducePlanGroup.java | 150 +
.../planner/HadoopMapReducePlanTopology.java | 89 +
.../shuffle/collections/HadoopMultimapBase.java | 90 +-
.../child/HadoopChildProcessRunner.java | 4 +-
.../processors/hadoop/v2/HadoopV2Job.java | 14 +-
.../hadoop/v2/HadoopV2JobResourceManager.java | 6 +-
.../hadoop/cache/HadoopTxConfigCacheTest.java | 42 +
.../util/BasicUserNameMapperSelfTest.java | 133 +
.../util/ChainedUserNameMapperSelfTest.java | 107 +
.../util/KerberosUserNameMapperSelfTest.java | 99 +
.../ignite/igfs/Hadoop1DualAbstractTest.java | 52 +-
.../igfs/HadoopFIleSystemFactorySelfTest.java | 3 +-
...oopFileSystemUniversalFileSystemAdapter.java | 131 -
.../HadoopIgfs20FileSystemAbstractSelfTest.java | 2 +
.../igfs/HadoopIgfsDualAbstractSelfTest.java | 13 +-
...adoopIgfsSecondaryFileSystemTestAdapter.java | 149 +
.../apache/ignite/igfs/IgfsEventsTestSuite.java | 16 +-
.../IgniteHadoopFileSystemAbstractSelfTest.java | 3 +-
...IgniteHadoopFileSystemHandshakeSelfTest.java | 121 +-
.../IgniteHadoopFileSystemLoggerSelfTest.java | 21 +-
...teHadoopFileSystemSecondaryModeSelfTest.java | 327 -
.../hadoop/HadoopAbstractMapReduceTest.java | 429 ++
.../hadoop/HadoopClassLoaderTest.java | 2 +-
.../HadoopDefaultMapReducePlannerSelfTest.java | 459 +-
.../processors/hadoop/HadoopErrorSimulator.java | 326 +
.../HadoopMapReduceErrorResilienceTest.java | 154 +
.../processors/hadoop/HadoopMapReduceTest.java | 379 +-
.../hadoop/HadoopNoHadoopMapReduceTest.java | 47 +
.../processors/hadoop/HadoopPlannerMockJob.java | 168 +
.../hadoop/HadoopSnappyFullMapReduceTest.java | 8 +
.../processors/hadoop/HadoopSnappyTest.java | 2 +-
.../processors/hadoop/HadoopTasksV1Test.java | 2 +-
.../processors/hadoop/HadoopTasksV2Test.java | 2 +-
.../processors/hadoop/HadoopV2JobSelfTest.java | 2 +-
.../HadoopWeightedMapReducePlannerTest.java | 599 ++
.../HadoopWeightedPlannerMapReduceTest.java | 38 +
.../hadoop/examples/HadoopWordCount1Map.java | 12 +
.../hadoop/examples/HadoopWordCount1Reduce.java | 5 +
.../hadoop/examples/HadoopWordCount2.java | 2 +-
.../examples/HadoopWordCount2Combiner.java | 45 +
.../hadoop/examples/HadoopWordCount2Mapper.java | 19 +-
.../examples/HadoopWordCount2Reducer.java | 43 +-
.../collections/HadoopAbstractMapTest.java | 6 +-
.../collections/HadoopHashMapSelfTest.java | 68 +-
.../testsuites/IgniteHadoopTestSuite.java | 59 +-
modules/hibernate/pom.xml | 2 +-
.../HibernateL2CacheTransactionalSelfTest.java | 9 +
...nateL2CacheTransactionalUseSyncSelfTest.java | 31 +
.../testsuites/IgniteHibernateTestSuite.java | 4 +-
modules/indexing/pom.xml | 9 +-
.../query/h2/GridH2ResultSetIterator.java | 62 +-
.../processors/query/h2/IgniteH2Indexing.java | 863 ++-
.../query/h2/opt/GridH2AbstractKeyValueRow.java | 95 +-
.../query/h2/opt/GridH2CollocationModel.java | 783 +++
.../processors/query/h2/opt/GridH2Cursor.java | 36 +-
.../query/h2/opt/GridH2DefaultTableEngine.java | 38 +
.../query/h2/opt/GridH2IndexBase.java | 1426 ++++-
.../query/h2/opt/GridH2KeyValueRowOffheap.java | 17 +-
.../query/h2/opt/GridH2MetaTable.java | 383 ++
.../query/h2/opt/GridH2QueryContext.java | 612 ++
.../query/h2/opt/GridH2QueryType.java | 49 +
.../query/h2/opt/GridH2RetryException.java | 32 +
.../processors/query/h2/opt/GridH2Row.java | 86 +-
.../query/h2/opt/GridH2RowDescriptor.java | 28 +-
.../query/h2/opt/GridH2RowFactory.java | 179 +
.../processors/query/h2/opt/GridH2Table.java | 371 +-
.../query/h2/opt/GridH2TreeIndex.java | 142 +-
.../processors/query/h2/opt/GridH2Utils.java | 133 -
.../query/h2/opt/GridH2ValueCacheObject.java | 14 +-
.../query/h2/opt/GridLuceneIndex.java | 7 +-
.../processors/query/h2/sql/GridSqlAlias.java | 12 +
.../processors/query/h2/sql/GridSqlColumn.java | 22 +-
.../processors/query/h2/sql/GridSqlConst.java | 5 +
.../processors/query/h2/sql/GridSqlElement.java | 11 +
.../processors/query/h2/sql/GridSqlJoin.java | 17 +-
.../query/h2/sql/GridSqlOperation.java | 2 +-
.../query/h2/sql/GridSqlOperationType.java | 8 +-
.../query/h2/sql/GridSqlQueryParser.java | 97 +-
.../query/h2/sql/GridSqlQuerySplitter.java | 299 +-
.../processors/query/h2/sql/GridSqlSelect.java | 11 +-
.../processors/query/h2/sql/GridSqlTable.java | 70 +
.../processors/query/h2/sql/GridSqlType.java | 5 +
.../query/h2/twostep/GridMapQueryExecutor.java | 451 +-
.../query/h2/twostep/GridMergeIndex.java | 75 +-
.../h2/twostep/GridMergeIndexUnsorted.java | 6 +-
.../query/h2/twostep/GridMergeTable.java | 4 +-
.../h2/twostep/GridReduceQueryExecutor.java | 343 +-
.../query/h2/twostep/GridThreadLocalTable.java | 68 +-
.../query/h2/twostep/msg/GridH2Array.java | 9 +-
.../query/h2/twostep/msg/GridH2Boolean.java | 10 +-
.../query/h2/twostep/msg/GridH2Byte.java | 9 +-
.../query/h2/twostep/msg/GridH2Bytes.java | 11 +-
.../query/h2/twostep/msg/GridH2CacheObject.java | 9 +-
.../query/h2/twostep/msg/GridH2Date.java | 9 +-
.../query/h2/twostep/msg/GridH2Decimal.java | 11 +-
.../query/h2/twostep/msg/GridH2Double.java | 9 +-
.../query/h2/twostep/msg/GridH2Float.java | 9 +-
.../query/h2/twostep/msg/GridH2Geometry.java | 11 +-
.../h2/twostep/msg/GridH2IndexRangeRequest.java | 208 +
.../twostep/msg/GridH2IndexRangeResponse.java | 279 +
.../query/h2/twostep/msg/GridH2Integer.java | 20 +-
.../query/h2/twostep/msg/GridH2JavaObject.java | 11 +-
.../query/h2/twostep/msg/GridH2Long.java | 9 +-
.../query/h2/twostep/msg/GridH2Null.java | 15 +-
.../h2/twostep/msg/GridH2QueryRequest.java | 401 ++
.../query/h2/twostep/msg/GridH2RowMessage.java | 116 +
.../query/h2/twostep/msg/GridH2RowRange.java | 181 +
.../h2/twostep/msg/GridH2RowRangeBounds.java | 188 +
.../query/h2/twostep/msg/GridH2Short.java | 9 +-
.../query/h2/twostep/msg/GridH2String.java | 9 +-
.../query/h2/twostep/msg/GridH2Time.java | 9 +-
.../query/h2/twostep/msg/GridH2Timestamp.java | 11 +-
.../query/h2/twostep/msg/GridH2Uuid.java | 9 +-
.../h2/twostep/msg/GridH2ValueMessage.java | 2 +-
.../twostep/msg/GridH2ValueMessageFactory.java | 22 +-
.../CacheAbstractQueryMetricsSelfTest.java | 4 +-
.../CacheBinaryKeyConcurrentQueryTest.java | 298 +
.../cache/CacheIndexingOffheapCleanupTest.java | 178 +
.../CacheOffheapBatchIndexingBaseTest.java | 313 +
.../CacheOffheapBatchIndexingMultiTypeTest.java | 108 +
...CacheOffheapBatchIndexingSingleTypeTest.java | 161 +
.../CacheOperationsWithExpirationTest.java | 355 ++
.../cache/CacheQueryNewClientSelfTest.java | 115 +
.../cache/CacheSqlQueryValueCopySelfTest.java | 226 +
.../ClientReconnectAfterClusterRestartTest.java | 225 +
.../cache/GridCacheOffheapIndexGetSelfTest.java | 48 +
...idCacheReduceQueryMultithreadedSelfTest.java | 168 -
.../IgniteCacheAbstractFieldsQuerySelfTest.java | 2 +-
.../cache/IgniteCacheAbstractQuerySelfTest.java | 64 +-
.../IgniteCacheConfigVariationsQueryTest.java | 505 ++
.../IgniteCacheCrossCacheJoinRandomTest.java | 442 ++
...acheDistributedJoinCollocatedAndNotTest.java | 365 ++
...acheDistributedJoinCustomAffinityMapper.java | 262 +
.../IgniteCacheDistributedJoinNoIndexTest.java | 299 +
...ributedJoinPartitionedAndReplicatedTest.java | 487 ++
...CacheDistributedJoinQueryConditionsTest.java | 624 ++
.../cache/IgniteCacheDistributedJoinTest.java | 316 +
...PartitionedAndReplicatedCollocationTest.java | 399 ++
...teCacheJoinPartitionedAndReplicatedTest.java | 316 +
...IgniteCacheJoinQueryWithAffinityKeyTest.java | 646 ++
...eLockPartitionOnAffinityRunAbstractTest.java | 430 ++
...PartitionOnAffinityRunAtomicCacheOpTest.java | 329 +
...niteCacheLockPartitionOnAffinityRunTest.java | 852 +++
...LockPartitionOnAffinityRunTxCacheOpTest.java | 33 +
...titionOnAffinityRunWithCollisionSpiTest.java | 204 +
.../cache/IgniteCacheOffheapIndexScanTest.java | 195 +
...IgniteCachePrimitiveFieldsQuerySelfTest.java | 134 +
.../cache/IgniteCacheQueriesLoadTest1.java | 604 ++
.../IgniteCacheQueryH2IndexingLeakTest.java | 214 +
.../cache/IgniteCacheQueryIndexSelfTest.java | 2 +-
.../cache/IgniteCacheQueryLoadSelfTest.java | 12 +-
.../IgniteCacheStarvationOnRebalanceTest.java | 166 +
.../cache/IgniteCacheUnionDuplicatesTest.java | 151 +
.../cache/IgniteClientReconnectQueriesTest.java | 4 +-
.../cache/IgniteCrossCachesJoinsQueryTest.java | 1641 +++++
.../IgniteCacheQueryNoRebalanceSelfTest.java | 82 +
...QueryNodeRestartDistributedJoinSelfTest.java | 476 ++
.../IgniteCacheQueryNodeRestartSelfTest2.java | 3 +
.../IgniteCacheReplicatedQuerySelfTest.java | 50 +-
.../IgniteCacheLocalFieldsQuerySelfTest.java | 16 +
...dCacheAbstractReduceFieldsQuerySelfTest.java | 420 --
...ridCacheReduceFieldsQueryAtomicSelfTest.java | 38 -
...GridCacheReduceFieldsQueryLocalSelfTest.java | 37 -
...cheReduceFieldsQueryPartitionedSelfTest.java | 59 -
...acheReduceFieldsQueryReplicatedSelfTest.java | 37 -
.../query/IgniteSqlSchemaIndexingTest.java | 5 +-
.../query/IgniteSqlSplitterSelfTest.java | 908 ++-
.../h2/GridIndexingSpiAbstractSelfTest.java | 147 +-
.../query/h2/opt/GridH2TableSelfTest.java | 10 +-
.../h2/sql/AbstractH2CompareQueryTest.java | 165 +-
.../query/h2/sql/GridQueryParsingTest.java | 28 +-
.../H2CompareBigQueryDistributedJoinsTest.java | 28 +
.../query/h2/sql/H2CompareBigQueryTest.java | 119 +-
.../IgniteBinaryCacheQueryTestSuite.java | 3 -
.../IgniteBinaryCacheQueryTestSuite2.java | 42 +
.../IgniteBinaryCacheQueryTestSuite3.java | 39 +
.../IgniteBinaryCacheQueryTestSuite4.java | 39 +
.../IgniteCacheAffinityRunTestSuite.java | 45 +
...gniteCacheConfigVariationQueryTestSuite.java | 41 +
.../IgniteCacheQuerySelfTestSuite.java | 181 +-
.../IgniteCacheQuerySelfTestSuite2.java | 103 +
.../IgniteCacheQuerySelfTestSuite3.java | 129 +
.../IgniteCacheQuerySelfTestSuite4.java | 56 +
.../IgniteCacheWithIndexingTestSuite.java | 13 +-
modules/jcl/pom.xml | 2 +-
modules/jms11/pom.xml | 2 +-
modules/json/pom.xml | 2 +-
modules/jta/pom.xml | 2 +-
.../websphere/WebSphereLibertyTmFactory.java | 77 +
.../cache/jta/websphere/WebSphereTmFactory.java | 244 +
.../cache/jta/websphere/package-info.java | 22 +
.../processors/cache/jta/CacheJtaManager.java | 26 +-
.../processors/cache/jta/CacheJtaResource.java | 304 +
.../cache/jta/GridCacheXAResource.java | 251 -
.../cache/AbstarctCacheJtaSelfTest.java | 183 -
.../cache/AbstractCacheJtaSelfTest.java | 183 +
.../GridPartitionedCacheJtaFactorySelfTest.java | 2 +-
...rtitionedCacheJtaFactoryUseSyncSelfTest.java | 32 +
...titionedCacheJtaLookupClassNameSelfTest.java | 2 +-
...eplicatedCacheJtaFactoryUseSyncSelfTest.java | 32 +
.../ignite/testsuites/IgniteJtaTestSuite.java | 5 +
modules/kafka/README.txt | 85 +-
modules/kafka/pom.xml | 5 +-
.../ignite/stream/kafka/KafkaStreamer.java | 4 +-
.../kafka/connect/IgniteSourceConnector.java | 81 +
.../kafka/connect/IgniteSourceConstants.java | 44 +
.../stream/kafka/connect/IgniteSourceTask.java | 363 ++
.../stream/kafka/connect/package-info.java | 21 +
.../serialization/CacheEventConverter.java | 66 +
.../serialization/CacheEventDeserializer.java | 54 +
.../serialization/CacheEventSerializer.java | 54 +
.../connect/serialization/package-info.java | 21 +
.../kafka/IgniteKafkaStreamerSelfTestSuite.java | 4 +-
.../kafka/KafkaIgniteStreamerSelfTest.java | 11 +-
.../ignite/stream/kafka/TestKafkaBroker.java | 27 +-
.../kafka/connect/IgniteSinkConnectorTest.java | 21 +-
.../connect/IgniteSourceConnectorMock.java | 30 +
.../connect/IgniteSourceConnectorTest.java | 353 ++
.../kafka/connect/IgniteSourceTaskMock.java | 31 +
.../kafka/connect/TestCacheEventFilter.java | 31 +
.../kafka/src/test/resources/example-ignite.xml | 4 +-
modules/log4j/pom.xml | 2 +-
modules/log4j2/pom.xml | 2 +-
modules/mesos/pom.xml | 42 +-
.../apache/ignite/mesos/ClusterProperties.java | 133 +-
.../apache/ignite/mesos/IgniteFramework.java | 23 +-
.../ignite/mesos/resource/IgniteProvider.java | 198 +-
.../ignite/mesos/resource/JettyServer.java | 16 +-
.../ignite/mesos/resource/ResourceProvider.java | 78 +-
modules/mqtt/pom.xml | 2 +-
modules/nodejs/pom.xml | 2 +-
modules/osgi-karaf/pom.xml | 2 +-
modules/osgi-paxlogging/pom.xml | 2 +-
modules/osgi/pom.xml | 2 +-
modules/platforms/cpp/DEVNOTES.txt | 66 +-
modules/platforms/cpp/Makefile.am | 61 +
modules/platforms/cpp/Makefile.amrel | 49 +
modules/platforms/cpp/README.txt | 29 +-
modules/platforms/cpp/binary/Makefile.am | 69 +
.../platforms/cpp/binary/include/Makefile.am | 46 +
.../cpp/binary/include/ignite/binary/binary.h | 34 +
.../include/ignite/binary/binary_consts.h | 86 +
.../include/ignite/binary/binary_containers.h | 650 ++
.../include/ignite/binary/binary_raw_reader.h | 408 ++
.../include/ignite/binary/binary_raw_writer.h | 376 ++
.../include/ignite/binary/binary_reader.h | 446 ++
.../binary/include/ignite/binary/binary_type.h | 310 +
.../include/ignite/binary/binary_writer.h | 414 ++
.../include/ignite/impl/binary/binary_common.h | 194 +
.../ignite/impl/binary/binary_id_resolver.h | 104 +
.../ignite/impl/binary/binary_reader_impl.h | 1426 +++++
.../include/ignite/impl/binary/binary_schema.h | 136 +
.../ignite/impl/binary/binary_type_handler.h | 102 +
.../ignite/impl/binary/binary_type_manager.h | 120 +
.../ignite/impl/binary/binary_type_snapshot.h | 122 +
.../ignite/impl/binary/binary_type_updater.h | 53 +
.../include/ignite/impl/binary/binary_utils.h | 633 ++
.../ignite/impl/binary/binary_writer_impl.h | 985 +++
.../include/ignite/impl/interop/interop.h | 25 +
.../ignite/impl/interop/interop_input_stream.h | 250 +
.../ignite/impl/interop/interop_memory.h | 269 +
.../ignite/impl/interop/interop_output_stream.h | 250 +
.../interop/interop_stream_position_guard.h | 79 +
.../cpp/binary/project/vs/binary.vcxproj | 233 +
.../binary/project/vs/binary.vcxproj.filters | 145 +
.../cpp/binary/src/binary/binary_containers.cpp | 76 +
.../cpp/binary/src/binary/binary_raw_reader.cpp | 166 +
.../cpp/binary/src/binary/binary_raw_writer.cpp | 167 +
.../cpp/binary/src/binary/binary_reader.cpp | 173 +
.../cpp/binary/src/binary/binary_type.cpp | 51 +
.../cpp/binary/src/binary/binary_writer.cpp | 174 +
.../src/impl/binary/binary_reader_impl.cpp | 921 +++
.../binary/src/impl/binary/binary_schema.cpp | 135 +
.../src/impl/binary/binary_type_handler.cpp | 78 +
.../src/impl/binary/binary_type_manager.cpp | 201 +
.../src/impl/binary/binary_type_snapshot.cpp | 70 +
.../src/impl/binary/binary_type_updater.cpp | 32 +
.../cpp/binary/src/impl/binary/binary_utils.cpp | 303 +
.../src/impl/binary/binary_writer_impl.cpp | 770 +++
.../src/impl/interop/interop_input_stream.cpp | 238 +
.../binary/src/impl/interop/interop_memory.cpp | 171 +
.../src/impl/interop/interop_output_stream.cpp | 234 +
modules/platforms/cpp/common/Makefile.am | 53 +-
modules/platforms/cpp/common/configure.ac | 62 -
.../platforms/cpp/common/ignite-common.pc.in | 9 -
.../platforms/cpp/common/include/Makefile.am | 22 +-
.../common/include/ignite/common/big_integer.h | 523 ++
.../cpp/common/include/ignite/common/bits.h | 218 +
.../common/include/ignite/common/concurrent.h | 191 +-
.../cpp/common/include/ignite/common/decimal.h | 527 ++
.../include/ignite/common/default_allocator.h | 95 +
.../include/ignite/common/dynamic_size_array.h | 415 ++
.../cpp/common/include/ignite/common/exports.h | 182 -
.../include/ignite/common/fixed_size_array.h | 288 +
.../cpp/common/include/ignite/common/java.h | 743 ---
.../cpp/common/include/ignite/common/utils.h | 226 +-
.../platforms/cpp/common/include/ignite/date.h | 138 +
.../platforms/cpp/common/include/ignite/guid.h | 172 +
.../cpp/common/include/ignite/ignite_error.h | 285 +
.../cpp/common/include/ignite/timestamp.h | 166 +
.../cpp/common/os/linux/include/Makefile.am | 9 +-
.../os/linux/include/ignite/common/common.h | 57 +-
.../linux/include/ignite/common/concurrent_os.h | 2 +-
.../cpp/common/os/linux/src/common.cpp | 59 -
.../os/linux/src/common/concurrent_os.cpp | 175 +
.../cpp/common/os/linux/src/common/utils.cpp | 136 +
.../cpp/common/os/linux/src/concurrent_os.cpp | 175 -
.../os/win/include/ignite/common/common.h | 26 +-
.../win/include/ignite/common/concurrent_os.h | 4 +-
.../platforms/cpp/common/os/win/src/common.cpp | 65 -
.../common/os/win/src/common/concurrent_os.cpp | 175 +
.../cpp/common/os/win/src/common/utils.cpp | 142 +
.../cpp/common/os/win/src/concurrent_os.cpp | 175 -
.../cpp/common/project/vs/common.vcxproj | 78 +-
.../common/project/vs/common.vcxproj.filters | 75 +-
.../platforms/cpp/common/project/vs/module.def | 132 -
.../cpp/common/src/common/big_integer.cpp | 829 +++
.../platforms/cpp/common/src/common/bits.cpp | 233 +
.../cpp/common/src/common/concurrent.cpp | 105 +
.../platforms/cpp/common/src/common/decimal.cpp | 275 +
modules/platforms/cpp/common/src/concurrent.cpp | 94 -
modules/platforms/cpp/common/src/date.cpp | 83 +
modules/platforms/cpp/common/src/exports.cpp | 545 --
modules/platforms/cpp/common/src/guid.cpp | 65 +
.../platforms/cpp/common/src/ignite_error.cpp | 226 +
modules/platforms/cpp/common/src/java.cpp | 2735 --------
modules/platforms/cpp/common/src/timestamp.cpp | 117 +
modules/platforms/cpp/configure.ac | 108 +
modules/platforms/cpp/configure.acrel | 93 +
modules/platforms/cpp/core-test/Makefile.am | 67 +-
.../cpp/core-test/config/cache-query.xml | 44 +-
.../cpp/core-test/config/cache-test.xml | 6 +
modules/platforms/cpp/core-test/configure.ac | 62 -
.../platforms/cpp/core-test/include/Makefile.am | 10 +-
.../include/ignite/binary_test_utils.h | 96 +
.../cpp/core-test/project/vs/core-test.vcxproj | 25 +-
.../project/vs/core-test.vcxproj.filters | 23 +-
.../src/binary_reader_writer_raw_test.cpp | 124 +
.../core-test/src/binary_reader_writer_test.cpp | 192 +
.../cpp/core-test/src/binary_session_test.cpp | 36 +
.../platforms/cpp/core-test/src/bits_test.cpp | 124 +
.../cpp/core-test/src/cache_query_test.cpp | 871 ++-
.../platforms/cpp/core-test/src/cache_test.cpp | 24 +
.../cpp/core-test/src/concurrent_test.cpp | 93 +
.../cpp/core-test/src/decimal_test.cpp | 1101 ++++
.../core-test/src/dynamic_size_array_test.cpp | 360 ++
.../cpp/core-test/src/fixed_size_array_test.cpp | 208 +
.../cpp/core-test/src/ignite_error_test.cpp | 45 +
.../cpp/core-test/src/interop_test.cpp | 148 +
.../cpp/core-test/src/transactions_test.cpp | 639 ++
modules/platforms/cpp/core/Makefile.am | 86 +-
modules/platforms/cpp/core/configure.ac | 62 -
modules/platforms/cpp/core/include/Makefile.am | 83 +-
.../cpp/core/include/ignite/binary/binary.h | 34 -
.../core/include/ignite/binary/binary_consts.h | 86 -
.../include/ignite/binary/binary_containers.h | 530 --
.../include/ignite/binary/binary_raw_reader.h | 355 --
.../include/ignite/binary/binary_raw_writer.h | 331 -
.../core/include/ignite/binary/binary_reader.h | 389 --
.../core/include/ignite/binary/binary_type.h | 310 -
.../core/include/ignite/binary/binary_writer.h | 367 --
.../cpp/core/include/ignite/cache/cache.h | 202 +-
.../cpp/core/include/ignite/cache/cache_entry.h | 45 +-
.../core/include/ignite/cache/cache_peek_mode.h | 6 +-
.../cpp/core/include/ignite/cache/query/query.h | 6 +-
.../include/ignite/cache/query/query_argument.h | 39 +-
.../include/ignite/cache/query/query_cursor.h | 70 +-
.../ignite/cache/query/query_fields_cursor.h | 52 +-
.../ignite/cache/query/query_fields_row.h | 59 +-
.../include/ignite/cache/query/query_scan.h | 18 +-
.../core/include/ignite/cache/query/query_sql.h | 76 +-
.../ignite/cache/query/query_sql_fields.h | 126 +-
.../include/ignite/cache/query/query_text.h | 6 +-
.../platforms/cpp/core/include/ignite/guid.h | 117 -
.../platforms/cpp/core/include/ignite/ignite.h | 49 +-
.../core/include/ignite/ignite_configuration.h | 12 +-
.../cpp/core/include/ignite/ignite_error.h | 265 -
.../cpp/core/include/ignite/ignition.h | 9 +-
.../include/ignite/impl/binary/binary_common.h | 188 -
.../ignite/impl/binary/binary_id_resolver.h | 106 -
.../ignite/impl/binary/binary_reader_impl.h | 1309 ----
.../include/ignite/impl/binary/binary_schema.h | 136 -
.../ignite/impl/binary/binary_type_handler.h | 102 -
.../ignite/impl/binary/binary_type_manager.h | 120 -
.../ignite/impl/binary/binary_type_snapshot.h | 122 -
.../ignite/impl/binary/binary_type_updater.h | 53 -
.../impl/binary/binary_type_updater_impl.h | 8 +-
.../include/ignite/impl/binary/binary_utils.h | 344 -
.../ignite/impl/binary/binary_writer_impl.h | 913 ---
.../core/include/ignite/impl/cache/cache_impl.h | 75 +-
.../impl/cache/query/query_fields_row_impl.h | 24 +-
.../ignite/impl/cache/query/query_impl.h | 9 +-
.../core/include/ignite/impl/handle_registry.h | 6 +-
.../include/ignite/impl/ignite_environment.h | 18 +-
.../cpp/core/include/ignite/impl/ignite_impl.h | 71 +-
.../core/include/ignite/impl/interop/interop.h | 25 -
.../impl/interop/interop_external_memory.h | 54 +
.../ignite/impl/interop/interop_input_stream.h | 250 -
.../ignite/impl/interop/interop_memory.h | 280 -
.../ignite/impl/interop/interop_output_stream.h | 250 -
.../interop/interop_stream_position_guard.h | 79 -
.../ignite/impl/interop/interop_target.h | 153 +
.../cpp/core/include/ignite/impl/operations.h | 134 +-
.../ignite/impl/transactions/transaction_impl.h | 220 +
.../impl/transactions/transactions_impl.h | 138 +
.../include/ignite/transactions/transaction.h | 278 +
.../ignite/transactions/transaction_consts.h | 144 +
.../ignite/transactions/transaction_metrics.h | 181 +
.../include/ignite/transactions/transactions.h | 180 +
modules/platforms/cpp/core/namespaces.dox | 10 +-
.../cpp/core/os/linux/include/Makefile.am | 23 -
.../core/os/linux/include/ignite/impl/utils.h | 155 -
.../cpp/core/os/linux/src/impl/utils.cpp | 439 --
.../cpp/core/os/win/include/ignite/impl/utils.h | 155 -
.../cpp/core/os/win/src/impl/utils.cpp | 453 --
.../platforms/cpp/core/project/vs/core.vcxproj | 90 +-
.../cpp/core/project/vs/core.vcxproj.filters | 179 +-
.../cpp/core/src/binary/binary_containers.cpp | 76 -
.../cpp/core/src/binary/binary_raw_reader.cpp | 145 -
.../cpp/core/src/binary/binary_raw_writer.cpp | 147 -
.../cpp/core/src/binary/binary_reader.cpp | 152 -
.../cpp/core/src/binary/binary_type.cpp | 51 -
.../cpp/core/src/binary/binary_writer.cpp | 154 -
modules/platforms/cpp/core/src/guid.cpp | 65 -
modules/platforms/cpp/core/src/ignite.cpp | 12 +-
modules/platforms/cpp/core/src/ignite_error.cpp | 222 -
modules/platforms/cpp/core/src/ignition.cpp | 24 +-
.../core/src/impl/binary/binary_reader_impl.cpp | 760 ---
.../cpp/core/src/impl/binary/binary_schema.cpp | 135 -
.../src/impl/binary/binary_type_handler.cpp | 78 -
.../src/impl/binary/binary_type_manager.cpp | 201 -
.../src/impl/binary/binary_type_snapshot.cpp | 70 -
.../src/impl/binary/binary_type_updater.cpp | 32 -
.../impl/binary/binary_type_updater_impl.cpp | 5 +-
.../cpp/core/src/impl/binary/binary_utils.cpp | 211 -
.../core/src/impl/binary/binary_writer_impl.cpp | 623 --
.../cpp/core/src/impl/cache/cache_impl.cpp | 141 +-
.../core/src/impl/cache/query/query_impl.cpp | 3 +-
.../cpp/core/src/impl/ignite_environment.cpp | 3 +-
.../platforms/cpp/core/src/impl/ignite_impl.cpp | 30 +-
.../impl/interop/interop_external_memory.cpp | 45 +
.../src/impl/interop/interop_input_stream.cpp | 235 -
.../core/src/impl/interop/interop_memory.cpp | 182 -
.../src/impl/interop/interop_output_stream.cpp | 233 -
.../core/src/impl/interop/interop_target.cpp | 179 +
.../src/impl/transactions/transaction_impl.cpp | 196 +
.../src/impl/transactions/transactions_impl.cpp | 205 +
.../cpp/core/src/transactions/transaction.cpp | 204 +
.../cpp/core/src/transactions/transactions.cpp | 142 +
modules/platforms/cpp/cpp.dxg | 6 +-
modules/platforms/cpp/examples/Makefile.am | 26 +-
modules/platforms/cpp/examples/README.txt | 16 +-
.../cpp/examples/config/example-cache.xml | 77 -
modules/platforms/cpp/examples/configure.ac | 45 +-
.../platforms/cpp/examples/include/Makefile.am | 9 +-
.../examples/include/ignite/examples/address.h | 26 +-
.../include/ignite/examples/organization.h | 33 +-
.../examples/include/ignite/examples/person.h | 110 +
.../cpp/examples/odbc-example/Makefile.am | 57 +
.../odbc-example/config/example-odbc.xml | 113 +
.../project/vs/odbc-example.vcxproj | 108 +
.../project/vs/odbc-example.vcxproj.filters | 28 +
.../examples/odbc-example/src/odbc_example.cpp | 286 +
.../cpp/examples/project/vs/ignite-examples.sln | 17 +-
.../examples/project/vs/ignite-examples.vcxproj | 107 -
.../project/vs/ignite-examples.vcxproj.filters | 30 -
.../cpp/examples/putget-example/Makefile.am | 56 +
.../putget-example/config/example-cache.xml | 75 +
.../project/vs/putget-example.vcxproj | 107 +
.../project/vs/putget-example.vcxproj.filters | 30 +
.../putget-example/src/putget_example.cpp | 126 +
.../cpp/examples/query-example/Makefile.am | 56 +
.../query-example/config/query-example.xml | 121 +
.../project/vs/query-example.vcxproj | 108 +
.../project/vs/query-example.vcxproj.filters | 27 +
.../query-example/src/query_example.cpp | 405 ++
.../cpp/examples/src/putgetexample.cpp | 126 -
modules/platforms/cpp/ignite/Makefile.am | 40 +-
modules/platforms/cpp/ignite/configure.ac | 62 -
.../cpp/ignite/project/vs/ignite.vcxproj | 47 +-
.../ignite/project/vs/ignite.vcxproj.filters | 8 -
modules/platforms/cpp/ignite/src/ignite.cpp | 10 +-
modules/platforms/cpp/jni/Makefile.am | 62 +
modules/platforms/cpp/jni/include/Makefile.am | 25 +
.../cpp/jni/include/ignite/jni/exports.h | 191 +
.../platforms/cpp/jni/include/ignite/jni/java.h | 787 +++
.../cpp/jni/include/ignite/jni/utils.h | 101 +
.../platforms/cpp/jni/os/linux/src/utils.cpp | 417 ++
modules/platforms/cpp/jni/os/win/src/utils.cpp | 428 ++
modules/platforms/cpp/jni/project/README.TXT | 1 +
modules/platforms/cpp/jni/project/vs/README.TXT | 1 +
.../platforms/cpp/jni/project/vs/jni.vcxproj | 205 +
.../cpp/jni/project/vs/jni.vcxproj.filters | 42 +
modules/platforms/cpp/jni/project/vs/module.def | 140 +
.../platforms/cpp/jni/project/vs/targetver.h | 25 +
modules/platforms/cpp/jni/src/exports.cpp | 577 ++
modules/platforms/cpp/jni/src/java.cpp | 3027 +++++++++
modules/platforms/cpp/odbc-test/Makefile.am | 90 +
modules/platforms/cpp/odbc-test/README.TXT | 1 +
.../odbc-test/config/queries-test-noodbc.xml | 103 +
.../cpp/odbc-test/config/queries-test.xml | 109 +
.../platforms/cpp/odbc-test/include/Makefile.am | 25 +
.../odbc-test/include/sql_test_suite_fixture.h | 191 +
.../include/teamcity/teamcity_messages.h | 55 +
.../platforms/cpp/odbc-test/include/test_type.h | 130 +
.../cpp/odbc-test/include/test_utils.h | 45 +
.../cpp/odbc-test/project/vs/odbc-test.vcxproj | 212 +
.../project/vs/odbc-test.vcxproj.filters | 132 +
.../src/application_data_buffer_test.cpp | 1002 +++
.../platforms/cpp/odbc-test/src/column_test.cpp | 290 +
.../cpp/odbc-test/src/configuration_test.cpp | 384 ++
.../cpp/odbc-test/src/connection_info_test.cpp | 219 +
.../platforms/cpp/odbc-test/src/cursor_test.cpp | 205 +
.../platforms/cpp/odbc-test/src/parser_test.cpp | 87 +
.../cpp/odbc-test/src/queries_test.cpp | 691 ++
.../platforms/cpp/odbc-test/src/row_test.cpp | 209 +
.../src/sql_aggregate_functions_test.cpp | 249 +
.../src/sql_numeric_functions_test.cpp | 309 +
.../cpp/odbc-test/src/sql_operators_test.cpp | 214 +
.../odbc-test/src/sql_string_functions_test.cpp | 291 +
.../odbc-test/src/sql_system_functions_test.cpp | 47 +
.../odbc-test/src/sql_test_suite_fixture.cpp | 271 +
.../cpp/odbc-test/src/sql_types_test.cpp | 60 +
.../src/sql_value_expressions_test.cpp | 94 +
.../odbc-test/src/teamcity/teamcity_boost.cpp | 159 +
.../src/teamcity/teamcity_messages.cpp | 150 +
.../platforms/cpp/odbc-test/src/test_utils.cpp | 36 +
.../cpp/odbc-test/src/utility_test.cpp | 81 +
modules/platforms/cpp/odbc/Makefile.am | 85 +
modules/platforms/cpp/odbc/README.txt | 89 +
modules/platforms/cpp/odbc/include/Makefile.am | 59 +
.../platforms/cpp/odbc/include/ignite/odbc.h | 256 +
.../ignite/odbc/app/application_data_buffer.h | 386 ++
.../odbc/include/ignite/odbc/app/parameter.h | 113 +
.../cpp/odbc/include/ignite/odbc/column.h | 155 +
.../cpp/odbc/include/ignite/odbc/common_types.h | 228 +
.../include/ignite/odbc/config/configuration.h | 393 ++
.../ignite/odbc/config/connection_info.h | 98 +
.../cpp/odbc/include/ignite/odbc/connection.h | 276 +
.../cpp/odbc/include/ignite/odbc/cursor.h | 114 +
.../ignite/odbc/diagnostic/diagnosable.h | 82 +
.../odbc/diagnostic/diagnosable_adapter.h | 107 +
.../ignite/odbc/diagnostic/diagnostic_record.h | 165 +
.../odbc/diagnostic/diagnostic_record_storage.h | 198 +
.../cpp/odbc/include/ignite/odbc/dsn_config.h | 61 +
.../cpp/odbc/include/ignite/odbc/environment.h | 137 +
.../cpp/odbc/include/ignite/odbc/message.h | 766 +++
.../odbc/include/ignite/odbc/meta/column_meta.h | 195 +
.../include/ignite/odbc/meta/primary_key_meta.h | 188 +
.../odbc/include/ignite/odbc/meta/table_meta.h | 166 +
.../cpp/odbc/include/ignite/odbc/parser.h | 134 +
.../odbc/include/ignite/odbc/protocol_version.h | 188 +
.../ignite/odbc/query/column_metadata_query.h | 146 +
.../odbc/include/ignite/odbc/query/data_query.h | 152 +
.../ignite/odbc/query/foreign_keys_query.h | 143 +
.../ignite/odbc/query/primary_keys_query.h | 137 +
.../cpp/odbc/include/ignite/odbc/query/query.h | 119 +
.../ignite/odbc/query/special_columns_query.h | 142 +
.../ignite/odbc/query/table_metadata_query.h | 150 +
.../include/ignite/odbc/query/type_info_query.h | 118 +
.../cpp/odbc/include/ignite/odbc/result_page.h | 101 +
.../cpp/odbc/include/ignite/odbc/row.h | 132 +
.../cpp/odbc/include/ignite/odbc/statement.h | 525 ++
.../include/ignite/odbc/system/odbc_constants.h | 41 +
.../include/ignite/odbc/system/socket_client.h | 92 +
.../odbc/system/ui/dsn_configuration_window.h | 152 +
.../cpp/odbc/include/ignite/odbc/type_traits.h | 316 +
.../cpp/odbc/include/ignite/odbc/utility.h | 180 +
.../cpp/odbc/install/ignite-odbc-install.ini | 5 +
.../cpp/odbc/install/install_amd64.cmd | 40 +
.../platforms/cpp/odbc/install/install_x86.cmd | 21 +
.../odbc/os/linux/src/system/socket_client.cpp | 120 +
.../ignite/odbc/system/ui/custom_window.h | 189 +
.../win/include/ignite/odbc/system/ui/window.h | 201 +
.../odbc/os/win/src/system/socket_client.cpp | 133 +
.../odbc/os/win/src/system/ui/custom_window.cpp | 184 +
.../src/system/ui/dsn_configuration_window.cpp | 305 +
.../cpp/odbc/os/win/src/system/ui/window.cpp | 192 +
.../cpp/odbc/os/win/src/system_dsn.cpp | 218 +
modules/platforms/cpp/odbc/project/README.TXT | 1 +
.../platforms/cpp/odbc/project/vs/README.TXT | 1 +
.../platforms/cpp/odbc/project/vs/module.def | 69 +
.../platforms/cpp/odbc/project/vs/odbc.vcxproj | 247 +
.../cpp/odbc/project/vs/odbc.vcxproj.filters | 264 +
.../odbc/src/app/application_data_buffer.cpp | 1321 ++++
.../platforms/cpp/odbc/src/app/parameter.cpp | 179 +
modules/platforms/cpp/odbc/src/column.cpp | 488 ++
modules/platforms/cpp/odbc/src/common_types.cpp | 120 +
.../cpp/odbc/src/config/configuration.cpp | 315 +
.../cpp/odbc/src/config/connection_info.cpp | 433 ++
modules/platforms/cpp/odbc/src/connection.cpp | 374 ++
modules/platforms/cpp/odbc/src/cursor.cpp | 82 +
.../odbc/src/diagnostic/diagnosable_adapter.cpp | 51 +
.../odbc/src/diagnostic/diagnostic_record.cpp | 247 +
.../diagnostic/diagnostic_record_storage.cpp | 242 +
modules/platforms/cpp/odbc/src/dsn_config.cpp | 115 +
modules/platforms/cpp/odbc/src/entry_points.cpp | 686 ++
modules/platforms/cpp/odbc/src/environment.cpp | 172 +
.../platforms/cpp/odbc/src/meta/column_meta.cpp | 274 +
.../platforms/cpp/odbc/src/meta/table_meta.cpp | 50 +
modules/platforms/cpp/odbc/src/odbc.cpp | 1320 ++++
.../platforms/cpp/odbc/src/protocol_version.cpp | 145 +
.../odbc/src/query/column_metadata_query.cpp | 318 +
.../platforms/cpp/odbc/src/query/data_query.cpp | 274 +
.../cpp/odbc/src/query/foreign_keys_query.cpp | 131 +
.../cpp/odbc/src/query/primary_keys_query.cpp | 210 +
.../odbc/src/query/special_columns_query.cpp | 121 +
.../cpp/odbc/src/query/table_metadata_query.cpp | 244 +
.../cpp/odbc/src/query/type_info_query.cpp | 394 ++
modules/platforms/cpp/odbc/src/result_page.cpp | 58 +
modules/platforms/cpp/odbc/src/row.cpp | 120 +
modules/platforms/cpp/odbc/src/statement.cpp | 524 ++
modules/platforms/cpp/odbc/src/type_traits.cpp | 669 ++
modules/platforms/cpp/odbc/src/utility.cpp | 141 +
modules/platforms/cpp/project/vs/ignite.sln | 69 +-
modules/platforms/cpp/project/vs/ignite.slnrel | 49 +-
.../platforms/cpp/project/vs/ignite_x86.slnrel | 49 +-
.../Apache.Ignite.AspNet.csproj | 73 +
.../Apache.Ignite.AspNet.nuspec | 54 +
.../Apache.Ignite.AspNet.ruleset | 9 +
.../Apache.Ignite.AspNet.snk | Bin 0 -> 596 bytes
.../IgniteOutputCacheProvider.cs | 220 +
.../Apache.Ignite.AspNet/IgniteWebUtils.cs | 44 +
.../dotnet/Apache.Ignite.AspNet/Package-Info.cs | 26 +
.../Properties/AssemblyInfo.cs | 39 +
.../Apache.Ignite.Benchmarks.csproj | 36 +-
.../Apache.Ignite.Benchmarks/BenchmarkRunner.cs | 5 +-
.../Interop/PlatformBenchmarkBase.cs | 2 +-
.../Properties/AssemblyInfo.cs | 8 +-
.../Apache.Ignite.Core.Tests.NuGet.csproj | 76 +-
.../Apache.Ignite.Core.Tests.NuGet.sln | 6 +
.../AspNetTest.cs | 73 +
.../Apache.Ignite.Core.Tests.NuGet/CacheTest.cs | 37 +-
.../Apache.Ignite.Core.Tests.NuGet/NLogTest.cs | 82 +
.../Apache.Ignite.Core.Tests.NuGet/NuGet.config | 5 +-
.../Properties/AssemblyInfo.cs | 8 +-
.../SchemaTest.cs | 62 +
.../install-package.cmd | 3 -
.../install-package.ps1 | 34 +
.../packages.config | 27 +
.../Apache.Ignite.Core.Tests.TestDll.csproj | 37 +-
.../Properties/AssemblyInfo.cs | 8 +-
.../Apache.Ignite.Core.Tests.csproj | 196 +-
.../AspNet/IgniteOutputCacheProviderTest.cs | 172 +
.../Binary/BinaryBuilderSelfTest.cs | 487 +-
.../Binary/BinaryBuilderSelfTestFullFooter.cs | 31 +
.../Binary/BinaryCompactFooterInteropTest.cs | 128 +
.../Binary/BinaryReaderWriterTest.cs | 171 +
.../Binary/BinarySelfTest.cs | 413 +-
.../Binary/BinarySelfTestFullFooter.cs | 35 +
.../Binary/BinaryStringTest.cs | 100 +
.../Binary/IO/BinaryStreamsTest.cs | 151 +
.../Binary/JavaTypeMappingTest.cs | 158 +
.../Binary/TypeResolverTest.cs | 107 +
.../Cache/Affinity/AffinityFieldTest.cs | 199 +
.../Affinity/AffinityFunctionSpringTest.cs | 184 +
.../Cache/Affinity/AffinityFunctionTest.cs | 485 ++
.../Cache/Affinity/AffinityKeyTest.cs | 66 +
.../Cache/Affinity/AffinityTest.cs | 138 +
.../Affinity/AffinityTopologyVersionTest.cs | 59 +
.../Cache/CacheAbstractTest.cs | 82 +-
.../Cache/CacheAffinityTest.cs | 139 -
.../Cache/CacheConfigurationTest.cs | 208 +-
.../Cache/CacheNearTest.cs | 188 +
.../Cache/CacheResultTest.cs | 75 +
.../Cache/CacheTestAsyncWrapper.cs | 12 +
.../Cache/Query/CacheLinqTest.cs | 1543 +++++
.../Query/CacheQueriesCodeConfigurationTest.cs | 28 +-
.../Cache/Query/CacheQueriesTest.cs | 303 +-
.../Continuous/ContinuousQueryAbstractTest.cs | 85 +-
.../Continuous/ContinuousQueryJavaFilterTest.cs | 322 +
.../Cache/Store/CacheParallelLoadStoreTest.cs | 2 +-
.../Cache/Store/CacheStoreAdapterTest.cs | 90 +
.../Cache/Store/CacheStoreTest.cs | 85 +-
.../Cache/Store/CacheStoreTestCodeConfig.cs | 106 +
.../Cache/Store/CacheTestParallelLoadStore.cs | 9 +
.../Cache/Store/CacheTestStore.cs | 52 +-
.../Collections/MultiValueDictionaryTest.cs | 58 +
.../Collections/ReadOnlyCollectionTest.cs | 59 +
.../Collections/ReadOnlyDictionaryTest.cs | 70 +
.../Common/IgniteGuidTest.cs | 62 +
.../Compute/AbstractTaskTest.cs | 49 +-
.../Compute/BinarizableClosureTaskTest.cs | 18 +-
.../Compute/BinarizableTaskTest.cs | 31 +-
.../Compute/CancellationTest.cs | 10 +
.../Compute/ClosureTaskTest.cs | 192 +-
.../Compute/ComputeApiTest.cs | 255 +-
.../Compute/ComputeApiTestFullFooter.cs | 65 +
.../Compute/FailoverTaskSelfTest.cs | 7 +-
.../Compute/IgniteExceptionTaskSelfTest.cs | 55 +-
.../Compute/MixedClusterTest.cs | 182 +
.../Compute/ResourceTaskTest.cs | 59 +-
.../Compute/SerializableClosureTaskTest.cs | 5 +
.../Compute/TaskAdapterTest.cs | 21 +-
.../Compute/TaskResultTest.cs | 24 +-
.../Config/Apache.Ignite.exe.config.test2 | 58 +
.../Config/Apache.Ignite.exe.config.test3 | 34 +
.../Config/Cache/Affinity/affinity-function.xml | 127 +
.../Cache/Affinity/affinity-function2.xml | 49 +
.../Config/Cache/Store/cache-store-session.xml | 3 +-
.../Config/Compute/compute-grid1.xml | 24 +-
.../Config/Compute/compute-grid2.xml | 20 +-
.../Config/Compute/compute-grid3.xml | 7 +-
.../Config/Compute/compute-standalone.xml | 5 +-
.../Config/Dynamic/dynamic-client.xml | 3 +-
.../Config/Dynamic/dynamic-data-no-cfg.xml | 3 +-
.../Config/Dynamic/dynamic-data.xml | 3 +-
.../Config/Lifecycle/lifecycle-beans.xml | 3 +-
.../Config/Lifecycle/lifecycle-no-beans.xml | 3 +-
.../Config/Log/custom-log.xml | 50 +
.../Config/Log/dotnet-log4j.xml | 143 +
.../Apache.Ignite.Core.Tests/Config/binary.xml | 56 -
.../Config/cache-binarizables.xml | 3 +-
.../Config/cache-local-node.xml | 66 +
.../Config/cache-query-continuous.xml | 4 +-
.../Config/cache-query.xml | 43 +-
.../Config/ignite-dotnet-cfg.xml | 52 +
.../Config/marshaller-default.xml | 3 +-
.../Config/marshaller-explicit.xml | 3 +-
.../Config/marshaller-invalid.xml | 3 +-
.../native-client-test-cache-affinity.xml | 5 +-
.../native-client-test-cache-parallel-store.xml | 3 +-
.../Config/native-client-test-cache-store.xml | 3 +-
.../Config/native-client-test-cache.xml | 3 +-
.../Config/reconnect-test.xml | 43 +
.../Config/spring-test.xml | 46 +
.../Config/start-test-grid1.xml | 3 +-
.../Config/start-test-grid2.xml | 3 +-
.../Config/start-test-grid3.xml | 3 +-
.../ConsoleRedirectTest.cs | 177 +
.../Dataload/DataStreamerTestTopologyChange.cs | 104 +
.../Apache.Ignite.Core.Tests/DeploymentTest.cs | 179 +
.../Apache.Ignite.Core.Tests/EventsTest.cs | 200 +-
.../Examples/Example.cs | 8 +-
.../Examples/ExamplesTest.cs | 51 +-
.../Examples/PathUtil.cs | 10 +-
.../Examples/ProjectFilesTest.cs | 4 +-
.../Apache.Ignite.Core.Tests/ExceptionsTest.cs | 132 +-
.../Apache.Ignite.Core.Tests/ExecutableTest.cs | 88 +-
.../IgniteConfigurationSectionTest.cs | 32 +
.../IgniteConfigurationSerializerTest.cs | 402 +-
.../IgniteConfigurationTest.cs | 161 +-
.../IgniteStartStopTest.cs | 4 +-
.../Apache.Ignite.Core.Tests/JavaHomeTest.cs | 69 +
.../Apache.Ignite.Core.Tests/LifecycleTest.cs | 9 +
.../Log/CustomLoggerTest.cs | 449 ++
.../Log/DefaultLoggerTest.cs | 114 +
.../Log/NLogLoggerTest.cs | 166 +
.../Apache.Ignite.Core.Tests/MessagingTest.cs | 16 +-
.../Process/IgniteProcess.cs | 15 +-
.../ProjectFilesTest.cs | 88 +
.../Properties/AssemblyInfo.cs | 8 +-
.../Apache.Ignite.Core.Tests/ReconnectTest.cs | 19 +-
.../Services/ServiceProxyTest.cs | 12 +-
.../Services/ServicesTest.cs | 294 +-
.../Services/ServicesTestFullFooter.cs | 33 +
.../Apache.Ignite.Core.Tests/TestAppConfig.cs | 100 +
.../Apache.Ignite.Core.Tests/TestRunner.cs | 47 +-
.../Apache.Ignite.Core.Tests/TestUtils.cs | 77 +-
.../TypeResolverTest.cs | 107 -
.../WindowsServiceTest.cs | 124 +
.../dotnet/Apache.Ignite.Core.Tests/app.config | 10 +-
.../Apache.Ignite.Core.Tests/custom_app.config | 34 +
.../Apache.Ignite.Core.Tests/packages.config | 4 +
.../Apache.Ignite.Core.Schema.nuspec | 52 +
.../Apache.Ignite.Core.csproj | 134 +-
.../Apache.Ignite.Core.nuspec | 20 +-
.../Binary/BinaryConfiguration.cs | 44 +-
.../Binary/BinaryReflectiveSerializer.cs | 98 +
.../Binary/IBinaryObjectBuilder.cs | 2 +-
.../Cache/Affinity/AffinityFunctionContext.cs | 120 +
.../Cache/Affinity/AffinityKey.cs | 173 +
.../Affinity/AffinityKeyMappedAttribute.cs | 46 +
.../Cache/Affinity/AffinityTopologyVersion.cs | 138 +
.../Cache/Affinity/Fair/FairAffinityFunction.cs | 33 +
.../Cache/Affinity/Fair/Package-Info.cs | 26 +
.../Cache/Affinity/IAffinityFunction.cs | 82 +
.../Cache/Affinity/Package-Info.cs | 26 +
.../Cache/Affinity/Rendezvous/Package-Info.cs | 26 +
.../Rendezvous/RendezvousAffinityFunction.cs | 32 +
.../Cache/CachePartialUpdateException.cs | 6 +-
.../Cache/Configuration/CacheConfiguration.cs | 97 +-
.../Configuration/NearCacheConfiguration.cs | 75 +
.../Cache/Configuration/Package-Info.cs | 26 +
.../Cache/Configuration/QueryEntity.cs | 30 +-
.../Cache/Configuration/QueryField.cs | 17 +-
.../Cache/Eviction/EvictionPolicyBase.cs | 126 +
.../Cache/Eviction/FifoEvictionPolicy.cs | 39 +
.../Cache/Eviction/IEvictionPolicy.cs | 32 +
.../Cache/Eviction/LruEvictionPolicy.cs | 39 +
.../Cache/Eviction/Package-Info.cs | 26 +
.../dotnet/Apache.Ignite.Core/Cache/ICache.cs | 26 +
.../Continuous/ContinuousQueryExtensions.cs | 42 +
.../Cache/Query/SqlFieldsQuery.cs | 43 +-
.../Apache.Ignite.Core/Cache/Query/SqlQuery.cs | 13 +
.../Store/CacheParallelLoadStoreAdapter.cs | 7 +
.../Apache.Ignite.Core/Cluster/IClusterGroup.cs | 6 +
.../Apache.Ignite.Core/Common/JavaException.cs | 66 +
.../Communication/ICommunicationSpi.cs | 37 +
.../Communication/Package-Info.cs | 26 +
.../Communication/Tcp/Package-Info.cs | 26 +
.../Communication/Tcp/TcpCommunicationSpi.cs | 283 +
.../Configuration/AtomicConfiguration.cs | 67 +
.../Configuration/Package-Info.cs | 26 +
.../Discovery/Package-Info.cs | 26 +
.../Discovery/Tcp/Multicast/Package-Info.cs | 26 +
.../Multicast/TcpDiscoveryMulticastIpFinder.cs | 9 +-
.../Discovery/Tcp/Package-Info.cs | 26 +
.../Discovery/Tcp/Static/Package-Info.cs | 26 +
.../Discovery/Tcp/TcpDiscoverySpi.cs | 161 +
.../Apache.Ignite.Core/Events/CacheEvent.cs | 9 +-
.../Apache.Ignite.Core/Events/DiscoveryEvent.cs | 4 +-
.../Apache.Ignite.Core/Events/EventBase.cs | 2 +-
.../Apache.Ignite.Core/Events/EventReader.cs | 12 +-
.../dotnet/Apache.Ignite.Core/IIgnite.cs | 83 +
.../Apache.Ignite.Core/IgniteConfiguration.cs | 444 +-
.../IgniteConfigurationSection.xsd | 1143 +++-
.../dotnet/Apache.Ignite.Core/Ignition.cs | 157 +-
.../Impl/Binary/BinarizableSerializer.cs | 22 +-
.../Apache.Ignite.Core/Impl/Binary/Binary.cs | 8 +-
.../Impl/Binary/BinaryFullTypeDescriptor.cs | 8 +-
.../Impl/Binary/BinaryHandleDictionary.cs | 32 +-
.../Impl/Binary/BinaryObject.cs | 11 +-
.../Impl/Binary/BinaryObjectBuilder.cs | 27 +-
.../Impl/Binary/BinaryObjectHandle.cs | 59 -
.../Impl/Binary/BinaryObjectHeader.cs | 181 +-
.../Impl/Binary/BinaryObjectSchema.cs | 20 +
.../Impl/Binary/BinaryObjectSchemaHolder.cs | 18 +-
.../Impl/Binary/BinaryObjectSchemaSerializer.cs | 262 +
.../Impl/Binary/BinaryReader.cs | 163 +-
.../Impl/Binary/BinaryReaderExtensions.cs | 38 +
.../Impl/Binary/BinaryReaderHandleDictionary.cs | 2 +-
.../Impl/Binary/BinaryReflectiveActions.cs | 617 +-
.../Impl/Binary/BinaryReflectiveSerializer.cs | 218 -
.../BinaryReflectiveSerializerInternal.cs | 169 +
.../Binary/BinarySurrogateTypeDescriptor.cs | 6 +-
.../Impl/Binary/BinarySystemHandlers.cs | 147 +-
.../Impl/Binary/BinarySystemTypeSerializer.cs | 20 +-
.../Impl/Binary/BinaryUtils.cs | 195 +-
.../Impl/Binary/BinaryWriter.cs | 227 +-
.../Impl/Binary/BinaryWriterExtensions.cs | 78 +
.../Impl/Binary/DateTimeHolder.cs | 4 +-
.../Impl/Binary/DateTimeSerializer.cs | 48 +
.../Impl/Binary/IBinarySerializerInternal.cs | 42 +
.../Impl/Binary/IBinarySystemTypeSerializer.cs | 34 -
.../Impl/Binary/IBinaryTypeDescriptor.cs | 2 +-
.../Impl/Binary/Io/BinaryHeapStream.cs | 2 +-
.../Impl/Binary/Io/BinaryStreamAdapter.cs | 5 +
.../Impl/Binary/Io/BinaryStreamBase.cs | 25 +-
.../Impl/Binary/Io/IBinaryStream.cs | 2 +-
.../Apache.Ignite.Core/Impl/Binary/JavaTypes.cs | 74 +-
.../Impl/Binary/Marshaller.cs | 183 +-
.../Impl/Binary/Metadata/BinaryType.cs | 28 +-
.../Impl/Binary/ReferenceEqualityComparer.cs | 45 +
.../Impl/Binary/SerializableObjectHolder.cs | 6 +-
.../Impl/Binary/SerializableSerializer.cs | 48 +
.../Binary/Structure/BinaryStructureTracker.cs | 7 +-
.../Impl/Binary/UserSerializerProxy.cs | 68 +
.../Impl/Cache/Affinity/AffinityFunctionBase.cs | 140 +
.../Affinity/AffinityFunctionSerializer.cs | 277 +
.../Cache/Affinity/PlatformAffinityFunction.cs | 74 +
.../Apache.Ignite.Core/Impl/Cache/CacheEntry.cs | 2 +-
.../Impl/Cache/CacheEntryFilterHolder.cs | 10 +-
.../Impl/Cache/CacheEntryProcessorHolder.cs | 8 +-
.../Apache.Ignite.Core/Impl/Cache/CacheImpl.cs | 295 +-
.../Apache.Ignite.Core/Impl/Cache/CacheOp.cs | 3 +-
.../Cache/Event/JavaCacheEntryEventFilter.cs | 51 +
.../Impl/Cache/ICacheInternal.cs | 40 +
.../Continuous/ContinuousQueryFilterHolder.cs | 8 +-
.../Continuous/ContinuousQueryHandleImpl.cs | 17 +-
.../Impl/Cache/Query/FieldsQueryCursor.cs | 26 +-
.../Impl/Cache/Store/CacheStore.cs | 4 +-
.../Impl/Cluster/ClusterGroupImpl.cs | 21 +
.../Impl/Cluster/ClusterNodeImpl.cs | 2 +-
.../Impl/Collections/MultiValueDictionary.cs | 26 -
.../Impl/Collections/ReadOnlyDictionary.cs | 2 +-
.../Apache.Ignite.Core/Impl/Common/Classpath.cs | 26 +-
.../Impl/Common/DelegateConverter.cs | 175 +-
.../Common/IgniteConfigurationXmlSerializer.cs | 67 +-
.../Impl/Common/IgniteHome.cs | 32 +-
.../Impl/Common/ObjectInfoHolder.cs | 86 +
.../Impl/Common/ObjectStringConverter.cs | 104 +
.../Apache.Ignite.Core/Impl/Common/Platform.cs | 35 +
.../Common/PlatformJavaObjectFactoryProxy.cs | 106 +
.../Impl/Common/ResizeableArray.cs | 64 -
.../Impl/Common/TypeCaster.cs | 12 +
.../Impl/Compute/Closure/ComputeActionJob.cs | 6 +-
.../Impl/Compute/Closure/ComputeFuncJob.cs | 8 +-
.../Impl/Compute/Closure/ComputeOutFuncJob.cs | 9 +-
.../Impl/Compute/ComputeFunc.cs | 9 +-
.../Impl/Compute/ComputeJob.cs | 10 +-
.../Impl/Compute/ComputeJobHolder.cs | 8 +-
.../Impl/Compute/ComputeOutFunc.cs | 8 +-
.../Impl/Compute/ComputeTaskHolder.cs | 3 +-
.../Impl/Datastream/DataStreamerImpl.cs | 9 +-
.../Impl/Datastream/StreamReceiverHolder.cs | 2 +-
.../Impl/Events/EventTypeConverter.cs | 3 +
.../Apache.Ignite.Core/Impl/Events/Events.cs | 3 +
.../Apache.Ignite.Core/Impl/ExceptionUtils.cs | 38 +-
.../Apache.Ignite.Core/Impl/Handle/Handle.cs | 12 +-
.../Impl/Handle/HandleRegistry.cs | 19 +-
.../Apache.Ignite.Core/Impl/Handle/IHandle.cs | 5 -
.../dotnet/Apache.Ignite.Core/Impl/Ignite.cs | 161 +-
.../Apache.Ignite.Core/Impl/IgniteManager.cs | 23 +-
.../Apache.Ignite.Core/Impl/IgniteProxy.cs | 83 +-
.../Apache.Ignite.Core/Impl/IgniteUtils.cs | 109 +-
.../Impl/InteropExceptionHolder.cs | 88 -
.../Impl/LifecycleBeanHolder.cs | 2 +-
.../Apache.Ignite.Core/Impl/Log/JavaLogger.cs | 110 +
.../Impl/Memory/PlatformMemoryStream.cs | 3 +-
.../Impl/Memory/PlatformMemoryUtils.cs | 30 -
.../Impl/Memory/PlatformRawMemory.cs | 5 +
.../Impl/Messaging/MessageListenerHolder.cs | 14 +-
.../Apache.Ignite.Core/Impl/NativeMethods.cs | 6 +
.../Apache.Ignite.Core/Impl/PlatformTarget.cs | 135 +-
.../Impl/Services/ServiceDescriptor.cs | 7 +-
.../Impl/Services/ServiceProxyInvoker.cs | 33 +-
.../Impl/Services/ServiceProxySerializer.cs | 63 +-
.../Impl/Services/Services.cs | 28 +-
.../Impl/Unmanaged/IgniteJniNativeMethods.cs | 25 +
.../Impl/Unmanaged/UnmanagedCallbackHandlers.cs | 9 +
.../Impl/Unmanaged/UnmanagedCallbacks.cs | 266 +-
.../Impl/Unmanaged/UnmanagedUtils.cs | 93 +-
.../Apache.Ignite.Core/Interop/JavaObject.cs | 80 +
.../Apache.Ignite.Core/Interop/Package-Info.cs | 26 +
.../Lifecycle/ClientReconnectEventArgs.cs | 47 +
.../Apache.Ignite.Core/Log/CategoryLogger.cs | 82 +
.../dotnet/Apache.Ignite.Core/Log/ILogger.cs | 51 +
.../dotnet/Apache.Ignite.Core/Log/LogLevel.cs | 53 +
.../Apache.Ignite.Core/Log/LoggerExtensions.cs | 320 +
.../NuGet/LINQPad/BinaryModeExample.linq | 94 +
.../NuGet/LINQPad/ComputeExample.linq | 8 +-
.../NuGet/LINQPad/PutGetExample.linq | 8 +-
.../NuGet/LINQPad/QueryExample.linq | 8 +-
.../Properties/AssemblyInfo.cs | 10 +-
.../Transactions/ITransaction.cs | 3 +-
.../Transactions/TransactionConfiguration.cs | 88 +
.../dotnet/Apache.Ignite.Core/build-common.ps1 | 77 +
.../powershell.exe.activation_config | 29 +
modules/platforms/dotnet/Apache.Ignite.FxCop | 6 +-
.../Apache.Ignite.Linq.csproj | 90 +
.../Apache.Ignite.Linq.nuspec | 61 +
.../Apache.Ignite.Linq/Apache.Ignite.Linq.snk | Bin 0 -> 596 bytes
.../Apache.Ignite.Linq/CacheExtensions.cs | 120 +
.../dotnet/Apache.Ignite.Linq/CompiledQuery.cs | 209 +
.../dotnet/Apache.Ignite.Linq/CompiledQuery2.cs | 257 +
.../Apache.Ignite.Linq/ICacheQueryable.cs | 53 +
.../Apache.Ignite.Linq/Impl/AliasDictionary.cs | 148 +
.../Impl/CacheFieldsQueryExecutor.cs | 344 +
.../Impl/CacheFieldsQueryProvider.cs | 239 +
.../Impl/CacheFieldsQueryable.cs | 40 +
.../Impl/CacheQueryExpressionVisitor.cs | 521 ++
.../Impl/CacheQueryModelVisitor.cs | 502 ++
.../Apache.Ignite.Linq/Impl/CacheQueryParser.cs | 56 +
.../Apache.Ignite.Linq/Impl/CacheQueryable.cs | 43 +
.../Impl/CacheQueryableBase.cs | 145 +
.../Apache.Ignite.Linq/Impl/ExpressionWalker.cs | 174 +
.../Impl/ICacheQueryableInternal.cs | 66 +
.../Apache.Ignite.Linq/Impl/MethodVisitor.cs | 250 +
.../dotnet/Apache.Ignite.Linq/Impl/QueryData.cs | 92 +
.../dotnet/Apache.Ignite.Linq/Impl/SqlTypes.cs | 63 +
.../NuGet/LINQPad/QueryExample.linq | 111 +
.../dotnet/Apache.Ignite.Linq/Package-Info.cs | 26 +
.../Properties/AssemblyInfo.cs | 40 +
.../dotnet/Apache.Ignite.Linq/QueryOptions.cs | 91 +
.../dotnet/Apache.Ignite.Linq/packages.config | 22 +
.../Apache.Ignite.NLog.csproj | 69 +
.../Apache.Ignite.NLog.nuspec | 50 +
.../Apache.Ignite.NLog/Apache.Ignite.NLog.snk | Bin 0 -> 596 bytes
.../Apache.Ignite.NLog/IgniteNLogLogger.cs | 125 +
.../Properties/AssemblyInfo.cs | 40 +
.../dotnet/Apache.Ignite.NLog/packages.config | 4 +
modules/platforms/dotnet/Apache.Ignite.dxg | 4 +-
modules/platforms/dotnet/Apache.Ignite.sln | 189 +-
.../dotnet/Apache.Ignite.sln.DotSettings | 11 +-
.../dotnet/Apache.Ignite/Apache.Ignite.csproj | 45 +-
.../Config/AppSettingsConfigurator.cs | 97 +-
.../Apache.Ignite/Config/ArgsConfigurator.cs | 145 +-
.../dotnet/Apache.Ignite/Config/Configurator.cs | 174 +
.../Apache.Ignite/Config/IConfigurator.cs | 34 -
.../dotnet/Apache.Ignite/IgniteRunner.cs | 44 +-
.../Apache.Ignite/Properties/AssemblyInfo.cs | 8 +-
.../Apache.Ignite/Service/IgniteService.cs | 113 +-
.../Service/IgniteServiceInstaller.cs | 64 +
.../Apache.Ignite/Service/NativeMethods.cs | 57 -
modules/platforms/dotnet/DEVNOTES.txt | 7 +-
modules/platforms/dotnet/build.bat | 94 -
.../dotnet/examples/Apache.Ignite.Examples.sln | 32 +-
.../Apache.Ignite.Examples.csproj | 50 +-
.../examples/Apache.Ignite.Examples/App.config | 33 +-
.../Compute/ClosureExample.cs | 22 +-
.../Compute/TaskExample.cs | 21 +-
.../Datagrid/BinaryModeExample.cs | 272 +
.../Datagrid/ContinuousQueryExample.cs | 31 +-
.../Datagrid/DataStreamerExample.cs | 22 +-
.../Datagrid/LinqExample.cs | 339 +
.../Datagrid/PutGetExample.cs | 21 +-
.../Datagrid/QueryExample.cs | 204 +-
.../Datagrid/StoreExample.cs | 37 +-
.../Datagrid/TransactionExample.cs | 30 +-
.../Events/EventsExample.cs | 26 +-
.../Messaging/MessagingExample.cs | 21 +-
.../Misc/LifecycleExample.cs | 27 +-
.../Properties/AssemblyInfo.cs | 8 +-
.../Services/IMapService.cs | 4 +-
.../Services/ServicesExample.cs | 21 +-
.../Apache.Ignite.ExamplesDll.csproj | 44 +-
.../Apache.Ignite.ExamplesDll/Binary/Account.cs | 7 +-
.../Apache.Ignite.ExamplesDll/Binary/Address.cs | 7 +-
.../Binary/Employee.cs | 22 +-
.../Binary/EmployeeKey.cs | 86 -
.../Binary/Organization.cs | 13 +-
.../Binary/OrganizationType.cs | 3 -
.../Compute/AverageSalaryJob.cs | 11 +-
.../Compute/AverageSalaryTask.cs | 9 +-
.../Compute/CharacterCountClosure.cs | 6 +-
.../Compute/CharacterCountReducer.cs | 4 +-
.../Datagrid/ContinuousQueryFilter.cs | 6 +-
.../Datagrid/EmployeeStore.cs | 13 +-
.../Datagrid/EmployeeStoreFactory.cs | 38 +
.../Datagrid/EmployeeStorePredicate.cs | 5 +-
.../Events/LocalListener.cs | 8 +-
.../Messaging/LocalListener.cs | 8 +-
.../Messaging/RemoteOrderedListener.cs | 10 +-
.../Messaging/RemoteUnorderedListener.cs | 10 +-
.../Properties/AssemblyInfo.cs | 8 +-
.../Services/MapService.cs | 12 +-
.../examples/Config/example-cache-query.xml | 118 -
.../examples/Config/example-cache-store.xml | 59 -
.../dotnet/examples/Config/example-cache.xml | 87 -
.../dotnet/examples/Config/example-compute.xml | 70 -
modules/rest-http/pom.xml | 27 +-
.../http/jetty/GridJettyJsonConfig.java | 195 -
.../http/jetty/GridJettyObjectMapper.java | 274 +
.../http/jetty/GridJettyRestHandler.java | 131 +-
.../http/jetty/GridJettyRestProtocol.java | 6 +-
modules/scalar-2.10/pom.xml | 2 +-
modules/scalar/pom.xml | 2 +-
.../scalar/pimps/ScalarProjectionPimp.scala | 4 +-
.../scalar/pimps/ScalarTaskThreadContext.scala | 4 +-
modules/schedule/pom.xml | 2 +-
.../processors/schedule/ScheduleFutureImpl.java | 7 +-
.../schedule/GridScheduleSelfTest.java | 33 +-
modules/schema-import-db/README.txt | 4 +
modules/schema-import-db/pom.xml | 55 +
.../apache/ignite/schema/parser/DbColumn.java | 76 +
.../ignite/schema/parser/DbMetadataReader.java | 147 +
.../apache/ignite/schema/parser/DbTable.java | 82 +
.../parser/dialect/DB2MetadataDialect.java | 33 +
.../parser/dialect/DatabaseMetadataDialect.java | 93 +
.../parser/dialect/JdbcMetadataDialect.java | 194 +
.../parser/dialect/MySQLMetadataDialect.java | 62 +
.../parser/dialect/OracleMetadataDialect.java | 361 ++
modules/schema-import/README.txt | 12 +-
modules/schema-import/pom.xml | 16 +-
.../ignite/schema/generator/CodeGenerator.java | 157 +-
.../ignite/schema/generator/GeneratorUtils.java | 70 +
.../ignite/schema/generator/XmlGenerator.java | 107 +-
.../schema/parser/DatabaseMetadataParser.java | 54 +-
.../apache/ignite/schema/parser/DbColumn.java | 76 -
.../apache/ignite/schema/parser/DbTable.java | 82 -
.../parser/dialect/DB2MetadataDialect.java | 33 -
.../parser/dialect/DatabaseMetadataDialect.java | 75 -
.../parser/dialect/JdbcMetadataDialect.java | 197 -
.../parser/dialect/MySQLMetadataDialect.java | 61 -
.../parser/dialect/OracleMetadataDialect.java | 364 --
.../ignite/schema/ui/SchemaImportApp.java | 744 ++-
.../schema/test/AbstractSchemaImportTest.java | 37 +-
.../test/generator/CodeGeneratorTest.java | 28 +-
.../schema/test/generator/XmlGeneratorTest.java | 24 +-
.../ignite/schema/test/model/CacheConfig.txt | 409 ++
.../apache/ignite/schema/test/model/Objects.txt | 31 +-
.../ignite/schema/test/model/Primitives.txt | 31 +-
.../org/apache/ignite/schema/test/model/Tst.txt | 31 +-
.../schema/test/model/ignite-type-metadata.xml | 136 +-
.../test/parser/DbMetadataParserTest.java | 8 +-
modules/slf4j/pom.xml | 2 +-
.../apache/ignite/logger/slf4j/Slf4jLogger.java | 2 +-
modules/spark-2.10/pom.xml | 2 +-
modules/spark/pom.xml | 2 +-
.../org/apache/ignite/spark/IgniteContext.scala | 85 +-
.../org/apache/ignite/spark/IgniteRDD.scala | 127 +-
.../apache/ignite/spark/JavaIgniteContext.scala | 18 +-
.../org/apache/ignite/spark/JavaIgniteRDD.scala | 17 +-
.../ignite/spark/impl/IgniteAbstractRDD.scala | 17 +-
.../apache/ignite/spark/impl/IgniteSqlRDD.scala | 7 +-
.../spark/impl/JavaIgniteAbstractRDD.scala | 34 -
.../spark/JavaEmbeddedIgniteRDDSelfTest.java | 344 +
.../ignite/spark/JavaIgniteRDDSelfTest.java | 302 -
.../spark/JavaStandaloneIgniteRDDSelfTest.java | 365 ++
.../ignite/testsuites/IgniteRDDTestSuite.java | 40 +
.../ignite/spark/EntityTestAllTypeFields.scala | 60 +
.../org/apache/ignite/spark/IgniteRDDSpec.scala | 179 +-
modules/spring/pom.xml | 9 +-
.../org/apache/ignite/IgniteSpringBean.java | 152 +-
.../apache/ignite/cache/spring/SpringCache.java | 44 +-
.../ignite/cache/spring/SpringCacheManager.java | 22 +-
.../GridResourceSpringBeanInjector.java | 39 +-
.../spring/SpringTransactionManager.java | 59 +-
.../src/test/config/jdbc-pojo-store-builtin.xml | 194 +
.../src/test/config/jdbc-pojo-store-obj.xml | 194 +
.../test/java/config/spring-transactions.xml | 4 +-
.../ignite/TestInjectionLifecycleBean.java | 42 +
.../spring/GridSpringCacheManagerSelfTest.java | 438 ++
.../cache/spring/GridSpringCacheTestKey.java | 61 +
.../spring/GridSpringCacheTestKeyGenerator.java | 40 +
.../spring/GridSpringCacheTestService.java | 181 +
.../GridSpringDynamicCacheTestService.java | 85 +
.../SpringCacheManagerContextInjectionTest.java | 125 +
.../ignite/cache/spring/spring-caching.xml | 57 +
.../jdbc/CacheJdbcPojoStoreFactorySelfTest.java | 11 +-
.../store/jdbc/CachePojoStoreXmlSelfTest.java | 51 +
.../ignite/internal/GridFactorySelfTest.java | 112 +-
.../ignite/internal/IgniteSpringBeanTest.java | 55 +
.../GridSpringResourceInjectionSelfTest.java | 311 +-
.../GridTransformSpringInjectionSelfTest.java | 186 +
.../spring-resource-with-duplicate-beans.xml | 30 +
.../processors/resource/spring-resource.xml | 2 +-
.../org/apache/ignite/spring-injection-test.xml | 43 +
.../spring/GridSpringCacheManagerSelfTest.java | 342 -
.../ignite/spring/GridSpringCacheTestKey.java | 61 -
.../spring/GridSpringCacheTestKeyGenerator.java | 40 -
.../spring/GridSpringCacheTestService.java | 125 -
.../GridSpringDynamicCacheTestService.java | 85 -
.../GridServiceInjectionSpringResourceTest.java | 245 +
.../spring/injection/spring-resource.tmpl.xml | 66 +
.../org/apache/ignite/spring/spring-caching.xml | 57 -
.../testsuites/IgniteSpringTestSuite.java | 15 +-
...gTransactionManagerContextInjectionTest.java | 125 +
modules/ssh/pom.xml | 2 +-
modules/storm/README.txt | 2 +-
modules/storm/pom.xml | 4 +-
.../ignite/stream/storm/StormStreamer.java | 10 +-
.../storm/StormIgniteStreamerSelfTest.java | 20 +-
.../ignite/stream/storm/TestStormSpout.java | 10 +-
modules/tools/pom.xml | 2 +-
modules/twitter/pom.xml | 2 +-
modules/urideploy/pom.xml | 2 +-
.../uri/GridUriDeploymentFileProcessor.java | 2 +-
modules/visor-console-2.10/pom.xml | 2 +-
modules/visor-console/pom.xml | 2 +-
.../ignite/visor/commands/VisorConsole.scala | 6 +-
.../commands/alert/VisorAlertCommand.scala | 378 +-
.../commands/cache/VisorCacheCommand.scala | 123 +-
.../commands/cache/VisorCacheResetCommand.scala | 129 +
.../commands/cache/VisorCacheStopCommand.scala | 7 +-
.../config/VisorConfigurationCommand.scala | 23 +-
.../commands/disco/VisorDiscoveryCommand.scala | 7 +-
.../commands/events/VisorEventsCommand.scala | 36 +-
.../visor/commands/gc/VisorGcCommand.scala | 11 +-
.../visor/commands/kill/VisorKillCommand.scala | 184 +-
.../visor/commands/node/VisorNodeCommand.scala | 13 +-
.../commands/tasks/VisorTasksCommand.scala | 7 +-
.../commands/top/VisorTopologyCommand.scala | 2 +-
.../visor/commands/vvm/VisorVvmCommand.scala | 11 +-
.../scala/org/apache/ignite/visor/visor.scala | 110 +-
.../commands/alert/VisorAlertCommandSpec.scala | 2 +-
.../cache/VisorCacheResetCommandSpec.scala | 114 +
modules/visor-plugins/pom.xml | 2 +-
modules/web-agent/.gitignore | 2 +
modules/web-agent/README.txt | 88 +
.../web-agent/assembly/release-web-agent.xml | 72 +
modules/web-agent/bin/ignite-web-agent.bat | 70 +
modules/web-agent/bin/ignite-web-agent.sh | 87 +
modules/web-agent/demo/README.txt | 4 +
modules/web-agent/demo/db-init.sql | 102 +
modules/web-agent/jdbc-drivers/README.txt | 10 +
modules/web-agent/logs/README.txt | 5 +
modules/web-agent/pom.xml | 189 +
.../console/agent/AgentConfiguration.java | 268 +
.../ignite/console/agent/AgentLauncher.java | 344 +
.../apache/ignite/console/agent/AgentUtils.java | 111 +
.../console/agent/handlers/AbstractHandler.java | 110 +
.../console/agent/handlers/DatabaseHandler.java | 298 +
.../console/agent/handlers/RestHandler.java | 276 +
.../ignite/console/demo/AgentClusterDemo.java | 638 ++
.../ignite/console/demo/AgentMetadataDemo.java | 92 +
.../apache/ignite/console/demo/model/Car.java | 152 +
.../ignite/console/demo/model/Country.java | 152 +
.../ignite/console/demo/model/Department.java | 152 +
.../ignite/console/demo/model/Employee.java | 356 ++
.../ignite/console/demo/model/Parking.java | 152 +
.../src/main/resources/log4j.properties | 53 +
modules/web-console/DEVNOTES.txt | 34 +
modules/web-console/README.txt | 36 +
modules/web-console/licenses/apache-2.0.txt | 202 +
modules/web-console/pom.xml | 69 +
modules/web-console/src/main/js/.babelrc | 3 +
modules/web-console/src/main/js/.eslintrc | 202 +
modules/web-console/src/main/js/.gitignore | 9 +
.../web-console/src/main/js/app/app.config.js | 86 +
modules/web-console/src/main/js/app/app.js | 274 +
.../main/js/app/controllers/auth.controller.js | 30 +
.../js/app/controllers/notebooks.controller.js | 69 +
.../controllers/reset-password.controller.js | 51 +
.../src/main/js/app/data/colors.json | 22 +
.../src/main/js/app/data/countries.json | 94 +
.../src/main/js/app/data/demo-info.json | 14 +
.../src/main/js/app/data/event-types.json | 169 +
.../src/main/js/app/data/getting-started.json | 109 +
.../src/main/js/app/data/java-classes.json | 18 +
.../src/main/js/app/data/java-keywords.json | 55 +
.../src/main/js/app/data/java-primitives.json | 9 +
.../src/main/js/app/data/pom-dependencies.json | 20 +
.../src/main/js/app/decorator/select.js | 77 +
.../src/main/js/app/decorator/tooltip.js | 56 +
.../js/app/directives/auto-focus.directive.js | 26 +
.../app/directives/bs-affix-update.directive.js | 34 +
.../js/app/directives/centered/centered.css | 37 +
.../directives/centered/centered.directive.js | 26 +
.../directives/copy-to-clipboard.directive.js | 29 +
.../hide-on-state-change.directive.js | 31 +
.../information/information.directive.js | 30 +
.../app/directives/information/information.jade | 20 +
.../app/directives/information/information.scss | 56 +
.../main/js/app/directives/match.directive.js | 27 +
.../app/directives/on-click-focus.directive.js | 26 +
.../directives/on-enter-focus-move.directive.js | 29 +
.../js/app/directives/on-enter.directive.js | 32 +
.../js/app/directives/on-escape.directive.js | 32 +
.../ui-ace-docker/ui-ace-docker.controller.js | 33 +
.../ui-ace-docker/ui-ace-docker.directive.js | 46 +
.../directives/ui-ace-docker/ui-ace-docker.jade | 31 +
.../ui-ace-java/ui-ace-java.controller.js | 32 +
.../ui-ace-java/ui-ace-java.directive.js | 133 +
.../app/directives/ui-ace-java/ui-ace-java.jade | 22 +
.../ui-ace-pojos/ui-ace-pojos.controller.js | 95 +
.../ui-ace-pojos/ui-ace-pojos.directive.js | 46 +
.../directives/ui-ace-pojos/ui-ace-pojos.jade | 40 +
.../ui-ace-pom/ui-ace-pom.controller.js | 33 +
.../ui-ace-pom/ui-ace-pom.directive.js | 41 +
.../app/directives/ui-ace-pom/ui-ace-pom.jade | 17 +
.../js/app/directives/ui-ace-tabs.directive.js | 23 +
.../ui-ace-xml/ui-ace-xml.controller.js | 27 +
.../ui-ace-xml/ui-ace-xml.directive.js | 133 +
.../app/directives/ui-ace-xml/ui-ace-xml.jade | 17 +
.../src/main/js/app/filters/byName.filter.js | 23 +
.../js/app/filters/domainsValidation.filter.js | 33 +
.../src/main/js/app/filters/hasPojo.filter.js | 18 +
.../src/main/js/app/helpers/jade/mixins.jade | 588 ++
.../src/main/js/app/modules/Demo/Demo.module.js | 166 +
.../js/app/modules/Version/Version.provider.js | 32 +
.../src/main/js/app/modules/ace.module.js | 269 +
.../main/js/app/modules/agent/agent.module.js | 323 +
.../js/app/modules/branding/branding.module.js | 45 +
.../app/modules/branding/branding.provider.js | 111 +
.../app/modules/branding/features.directive.js | 35 +
.../js/app/modules/branding/footer.directive.js | 34 +
.../modules/branding/header-logo.directive.js | 34 +
.../js/app/modules/branding/header-logo.jade | 18 +
.../modules/branding/header-title.directive.js | 35 +
.../branding/powered-by-apache.directive.js | 35 +
.../app/modules/branding/powered-by-apache.jade | 18 +
.../js/app/modules/branding/terms.directive.js | 30 +
.../configuration/EventGroups.provider.js | 30 +
.../modules/configuration/Sidebar.provider.js | 39 +
.../configuration/configuration.module.js | 41 +
.../configuration/generator/Docker.service.js | 78 +
.../configuration/generator/Java.service.js | 21 +
.../configuration/generator/Pom.service.js | 210 +
.../configuration/generator/Xml.service.js | 21 +
.../modules/configuration/sidebar.directive.js | 30 +
.../modules/dialog/dialog-content.directive.js | 31 +
.../modules/dialog/dialog-title.directive.js | 31 +
.../js/app/modules/dialog/dialog.controller.js | 40 +
.../js/app/modules/dialog/dialog.directive.js | 32 +
.../js/app/modules/dialog/dialog.factory.js | 32 +
.../src/main/js/app/modules/dialog/dialog.jade | 26 +
.../main/js/app/modules/dialog/dialog.module.js | 32 +
.../field/bs-select-placeholder.directive.js | 47 +
.../js/app/modules/form/field/down.directive.js | 43 +
.../modules/form/field/dropdown.directive.js | 83 +
.../js/app/modules/form/field/dropdown.jade | 61 +
.../main/js/app/modules/form/field/field.css | 23 +
.../app/modules/form/field/field.directive.js | 44 +
.../main/js/app/modules/form/field/field.jade | 27 +
.../field/form-control-feedback.directive.js | 40 +
.../form/field/input/autofocus.directive.js | 30 +
.../form/field/input/checkbox.directive.js | 66 +
.../app/modules/form/field/input/checkbox.jade | 30 +
.../form/field/input/datalist.directive.js | 122 +
.../app/modules/form/field/input/datalist.jade | 51 +
.../form/field/input/number.directive.js | 76 +
.../js/app/modules/form/field/input/number.jade | 50 +
.../js/app/modules/form/field/input/text.css | 41 +
.../modules/form/field/input/text.directive.js | 126 +
.../js/app/modules/form/field/input/text.jade | 48 +
.../app/modules/form/field/label.directive.js | 47 +
.../app/modules/form/field/tooltip.directive.js | 49 +
.../js/app/modules/form/field/up.directive.js | 44 +
.../src/main/js/app/modules/form/form.module.js | 101 +
.../js/app/modules/form/group/add.directive.js | 40 +
.../app/modules/form/group/group.directive.js | 81 +
.../main/js/app/modules/form/group/group.jade | 21 +
.../app/modules/form/group/table.directive.js | 29 +
.../main/js/app/modules/form/group/table.jade | 17 +
.../app/modules/form/group/tooltip.directive.js | 40 +
.../app/modules/form/panel/chevron.directive.js | 53 +
.../app/modules/form/panel/panel.directive.js | 37 +
.../app/modules/form/panel/revert.directive.js | 53 +
.../form/validator/ipaddress.directive.js | 86 +
.../validator/java-built-in-class.directive.js | 31 +
.../form/validator/java-identifier.directive.js | 31 +
.../form/validator/java-keywords.directive.js | 42 +
.../validator/java-package-name.directive.js | 31 +
.../java-package-specified.directive.js | 34 +
.../form/validator/property-unique.directive.js | 47 +
.../property-value-specified.directive.js | 31 +
.../modules/form/validator/unique.directive.js | 49 +
.../getting-started/GettingStarted.provider.js | 112 +
.../src/main/js/app/modules/loading/loading.css | 73 +
.../js/app/modules/loading/loading.directive.js | 51 +
.../main/js/app/modules/loading/loading.jade | 23 +
.../js/app/modules/loading/loading.module.js | 26 +
.../js/app/modules/loading/loading.service.js | 48 +
.../js/app/modules/navbar/Navbar.provider.js | 28 +
.../js/app/modules/navbar/Userbar.provider.js | 28 +
.../js/app/modules/navbar/navbar.directive.js | 30 +
.../main/js/app/modules/navbar/navbar.module.js | 33 +
.../js/app/modules/navbar/userbar.directive.js | 48 +
.../query-notebooks/query-notebooks.module.js | 115 +
.../src/main/js/app/modules/socket.module.js | 41 +
.../main/js/app/modules/states/admin.state.js | 34 +
.../app/modules/states/configuration.state.js | 226 +
.../caches/concurrency.directive.js | 27 +
.../configuration/caches/concurrency.jade | 65 +
.../configuration/caches/general.directive.js | 27 +
.../states/configuration/caches/general.jade | 65 +
.../configuration/caches/memory.directive.js | 27 +
.../states/configuration/caches/memory.jade | 88 +
.../configuration/caches/query.directive.js | 27 +
.../states/configuration/caches/query.jade | 93 +
.../configuration/caches/rebalance.directive.js | 27 +
.../states/configuration/caches/rebalance.jade | 65 +
.../caches/server-near-cache.directive.js | 27 +
.../configuration/caches/server-near-cache.jade | 45 +
.../caches/statistics.directive.js | 27 +
.../states/configuration/caches/statistics.jade | 37 +
.../configuration/caches/store.directive.js | 27 +
.../states/configuration/caches/store.jade | 271 +
.../configuration/clusters/atomic.directive.js | 27 +
.../states/configuration/clusters/atomic.jade | 53 +
.../clusters/attributes.directive.js | 27 +
.../configuration/clusters/attributes.jade | 58 +
.../configuration/clusters/binary.directive.js | 27 +
.../states/configuration/clusters/binary.jade | 100 +
.../clusters/collision.directive.js | 27 +
.../configuration/clusters/collision.jade | 60 +
.../clusters/collision/custom.directive.js | 27 +
.../clusters/collision/custom.jade | 24 +
.../clusters/collision/fifo-queue.directive.js | 27 +
.../clusters/collision/fifo-queue.jade | 28 +
.../collision/job-stealing.directive.js | 27 +
.../clusters/collision/job-stealing.jade | 64 +
.../collision/priority-queue.directive.js | 27 +
.../clusters/collision/priority-queue.jade | 43 +
.../clusters/communication.directive.js | 27 +
.../configuration/clusters/communication.jade | 96 +
.../clusters/connector.directive.js | 27 +
.../configuration/clusters/connector.jade | 103 +
.../clusters/deployment.directive.js | 27 +
.../configuration/clusters/deployment.jade | 119 +
.../clusters/discovery.directive.js | 27 +
.../configuration/clusters/discovery.jade | 83 +
.../configuration/clusters/events.directive.js | 27 +
.../states/configuration/clusters/events.jade | 37 +
.../clusters/failover.directive.js | 27 +
.../states/configuration/clusters/failover.jade | 82 +
.../configuration/clusters/general.directive.js | 27 +
.../states/configuration/clusters/general.jade | 68 +
.../general/discovery/cloud.directive.js | 27 +
.../clusters/general/discovery/cloud.jade | 127 +
.../general/discovery/google.directive.js | 27 +
.../clusters/general/discovery/google.jade | 38 +
.../general/discovery/jdbc.directive.js | 27 +
.../clusters/general/discovery/jdbc.jade | 24 +
.../general/discovery/multicast.directive.js | 27 +
.../clusters/general/discovery/multicast.jade | 109 +
.../clusters/general/discovery/s3.directive.js | 27 +
.../clusters/general/discovery/s3.jade | 27 +
.../general/discovery/shared.directive.js | 27 +
.../clusters/general/discovery/shared.jade | 23 +
.../clusters/general/discovery/vm.directive.js | 27 +
.../clusters/general/discovery/vm.jade | 90 +
.../general/discovery/zookeeper.directive.js | 27 +
.../clusters/general/discovery/zookeeper.jade | 74 +
.../bounded-exponential-backoff.directive.js | 27 +
.../bounded-exponential-backoff.jade | 27 +
.../zookeeper/retrypolicy/custom.directive.js | 27 +
.../discovery/zookeeper/retrypolicy/custom.jade | 24 +
.../exponential-backoff.directive.js | 27 +
.../retrypolicy/exponential-backoff.jade | 27 +
.../zookeeper/retrypolicy/forever.directive.js | 27 +
.../zookeeper/retrypolicy/forever.jade | 22 +
.../zookeeper/retrypolicy/n-times.directive.js | 27 +
.../zookeeper/retrypolicy/n-times.jade | 25 +
.../zookeeper/retrypolicy/one-time.directive.js | 27 +
.../zookeeper/retrypolicy/one-time.jade | 23 +
.../retrypolicy/until-elapsed.directive.js | 27 +
.../zookeeper/retrypolicy/until-elapsed.jade | 25 +
.../configuration/clusters/igfs.directive.js | 27 +
.../states/configuration/clusters/igfs.jade | 37 +
.../configuration/clusters/logger.directive.js | 27 +
.../states/configuration/clusters/logger.jade | 65 +
.../clusters/logger/custom.directive.js | 27 +
.../configuration/clusters/logger/custom.jade | 24 +
.../clusters/logger/log4j.directive.js | 27 +
.../configuration/clusters/logger/log4j.jade | 49 +
.../clusters/logger/log4j2.directive.js | 27 +
.../configuration/clusters/logger/log4j2.jade | 38 +
.../clusters/marshaller.directive.js | 27 +
.../configuration/clusters/marshaller.jade | 69 +
.../configuration/clusters/metrics.directive.js | 27 +
.../states/configuration/clusters/metrics.jade | 50 +
.../configuration/clusters/ssl.directive.js | 27 +
.../states/configuration/clusters/ssl.jade | 108 +
.../configuration/clusters/swap.directive.js | 27 +
.../states/configuration/clusters/swap.jade | 67 +
.../configuration/clusters/thread.directive.js | 27 +
.../states/configuration/clusters/thread.jade | 48 +
.../configuration/clusters/time.directive.js | 27 +
.../states/configuration/clusters/time.jade | 47 +
.../clusters/transactions.directive.js | 27 +
.../configuration/clusters/transactions.jade | 59 +
.../configuration/domains/general.directive.js | 27 +
.../states/configuration/domains/general.jade | 46 +
.../configuration/domains/query.directive.js | 27 +
.../states/configuration/domains/query.jade | 169 +
.../configuration/domains/store.directive.js | 27 +
.../states/configuration/domains/store.jade | 126 +
.../states/configuration/igfs/dual.directive.js | 27 +
.../modules/states/configuration/igfs/dual.jade | 42 +
.../igfs/fragmentizer.directive.js | 27 +
.../states/configuration/igfs/fragmentizer.jade | 43 +
.../configuration/igfs/general.directive.js | 27 +
.../states/configuration/igfs/general.jade | 53 +
.../states/configuration/igfs/ipc.directive.js | 27 +
.../modules/states/configuration/igfs/ipc.jade | 57 +
.../states/configuration/igfs/misc.directive.js | 27 +
.../modules/states/configuration/igfs/misc.jade | 108 +
.../configuration/igfs/secondary.directive.js | 27 +
.../states/configuration/igfs/secondary.jade | 44 +
.../configuration/preview-panel.directive.js | 239 +
.../summary/summary-tabs.directive.js | 50 +
.../configuration/summary/summary.controller.js | 359 ++
.../configuration/summary/summary.resource.js | 40 +
.../main/js/app/modules/states/logout.state.js | 36 +
.../js/app/modules/states/password.state.js | 46 +
.../main/js/app/modules/states/profile.state.js | 34 +
.../main/js/app/modules/states/signin.state.js | 53 +
.../src/main/js/app/modules/states/sql.state.js | 46 +
.../main/js/app/modules/user/Auth.service.js | 76 +
.../main/js/app/modules/user/User.service.js | 65 +
.../src/main/js/app/modules/user/user.module.js | 28 +
.../main/js/app/services/ChartColors.service.js | 22 +
.../src/main/js/app/services/Clone.service.js | 64 +
.../src/main/js/app/services/Confirm.service.js | 70 +
.../js/app/services/ConfirmBatch.service.js | 92 +
.../js/app/services/CopyToClipboard.service.js | 50 +
.../main/js/app/services/Countries.service.js | 31 +
.../src/main/js/app/services/Focus.service.js | 33 +
.../main/js/app/services/InetAddress.service.js | 53 +
.../main/js/app/services/JavaTypes.service.js | 84 +
.../main/js/app/services/LegacyTable.service.js | 205 +
.../main/js/app/services/LegacyUtils.service.js | 948 +++
.../main/js/app/services/Messages.service.js | 63 +
.../js/app/services/ModelNormalizer.service.js | 59 +
.../app/services/UnsavedChangesGuard.service.js | 38 +
modules/web-console/src/main/js/app/vendor.js | 54 +
.../src/main/js/controllers/admin-controller.js | 91 +
.../main/js/controllers/caches-controller.js | 470 ++
.../main/js/controllers/clusters-controller.js | 626 ++
.../main/js/controllers/domains-controller.js | 1746 ++++++
.../src/main/js/controllers/igfs-controller.js | 401 ++
.../main/js/controllers/profile-controller.js | 91 +
.../src/main/js/controllers/sql-controller.js | 1588 +++++
.../src/main/js/generator/generator-common.js | 611 ++
.../src/main/js/generator/generator-java.js | 3404 ++++++++++
.../src/main/js/generator/generator-optional.js | 25 +
.../main/js/generator/generator-properties.js | 150 +
.../src/main/js/generator/generator-readme.js | 85 +
.../src/main/js/generator/generator-xml.js | 1978 ++++++
.../src/main/js/gulpfile.babel.js/index.js | 26 +
.../src/main/js/gulpfile.babel.js/paths.js | 70 +
.../main/js/gulpfile.babel.js/tasks/build.js | 21 +
.../main/js/gulpfile.babel.js/tasks/bundle.js | 32 +
.../main/js/gulpfile.babel.js/tasks/clean.js | 32 +
.../src/main/js/gulpfile.babel.js/tasks/copy.js | 33 +
.../gulpfile.babel.js/tasks/ignite-modules.js | 55 +
.../src/main/js/gulpfile.babel.js/tasks/jade.js | 40 +
.../main/js/gulpfile.babel.js/tasks/watch.js | 31 +
.../main/js/gulpfile.babel.js/webpack/common.js | 192 +
.../webpack/environments/development.js | 64 +
.../webpack/environments/production.js | 45 +
.../main/js/gulpfile.babel.js/webpack/index.js | 32 +
.../webpack/plugins/progress.js | 82 +
.../src/main/js/ignite_modules/README.txt | 6 +
.../src/main/js/ignite_modules/index.js | 27 +
modules/web-console/src/main/js/package.json | 128 +
.../web-console/src/main/js/public/favicon.ico | Bin 0 -> 1150 bytes
.../src/main/js/public/images/cache.png | Bin 0 -> 23700 bytes
.../src/main/js/public/images/cluster.png | Bin 0 -> 29376 bytes
.../src/main/js/public/images/docker.png | Bin 0 -> 521 bytes
.../src/main/js/public/images/domains.png | Bin 0 -> 23828 bytes
.../src/main/js/public/images/igfs.png | Bin 0 -> 14307 bytes
.../src/main/js/public/images/ignite-logo.png | Bin 0 -> 1982 bytes
.../main/js/public/images/ignite-logo@2x.png | Bin 0 -> 3325 bytes
.../src/main/js/public/images/ignite-puzzle.png | Bin 0 -> 71974 bytes
.../src/main/js/public/images/java.png | Bin 0 -> 170 bytes
.../src/main/js/public/images/pb-ignite.png | Bin 0 -> 3493 bytes
.../src/main/js/public/images/pb-ignite@2x.png | Bin 0 -> 8558 bytes
.../src/main/js/public/images/query-chart.png | Bin 0 -> 16637 bytes
.../main/js/public/images/query-metadata.png | Bin 0 -> 32298 bytes
.../src/main/js/public/images/query-table.png | Bin 0 -> 29189 bytes
.../src/main/js/public/images/summary.png | Bin 0 -> 31997 bytes
.../src/main/js/public/images/xml.png | Bin 0 -> 232 bytes
.../public/stylesheets/_bootstrap-custom.scss | 65 +
.../stylesheets/_bootstrap-variables.scss | 891 +++
.../stylesheets/_font-awesome-custom.scss | 32 +
.../src/main/js/public/stylesheets/style.scss | 2156 +++++++
.../main/js/public/stylesheets/variables.scss | 28 +
modules/web-console/src/main/js/serve.js | 116 +
modules/web-console/src/main/js/serve/agent.js | 714 +++
.../src/main/js/serve/agent_dists/README.txt | 7 +
modules/web-console/src/main/js/serve/app.js | 42 +
.../web-console/src/main/js/serve/browser.js | 378 ++
.../main/js/serve/config/settings.json.sample | 26 +
.../web-console/src/main/js/serve/configure.js | 84 +
modules/web-console/src/main/js/serve/mail.js | 75 +
modules/web-console/src/main/js/serve/mongo.js | 676 ++
.../src/main/js/serve/routes/admin.js | 126 +
.../src/main/js/serve/routes/agent.js | 81 +
.../src/main/js/serve/routes/caches.js | 132 +
.../src/main/js/serve/routes/clusters.js | 146 +
.../src/main/js/serve/routes/demo.js | 135 +
.../src/main/js/serve/routes/demo/caches.json | 87 +
.../src/main/js/serve/routes/demo/clusters.json | 50 +
.../src/main/js/serve/routes/demo/domains.json | 307 +
.../src/main/js/serve/routes/demo/igfss.json | 10 +
.../src/main/js/serve/routes/domains.js | 195 +
.../src/main/js/serve/routes/igfs.js | 122 +
.../src/main/js/serve/routes/notebooks.js | 121 +
.../src/main/js/serve/routes/profile.js | 102 +
.../src/main/js/serve/routes/public.js | 235 +
.../src/main/js/serve/routes/routes.js | 103 +
.../web-console/src/main/js/serve/settings.js | 84 +
modules/web-console/src/main/js/views/base.jade | 22 +
.../src/main/js/views/configuration/caches.jade | 52 +
.../main/js/views/configuration/clusters.jade | 64 +
.../js/views/configuration/domains-import.jade | 211 +
.../main/js/views/configuration/domains.jade | 66 +
.../src/main/js/views/configuration/igfs.jade | 51 +
.../main/js/views/configuration/sidebar.jade | 29 +
.../summary-project-structure.jade | 27 +
.../js/views/configuration/summary-tabs.jade | 25 +
.../main/js/views/configuration/summary.jade | 152 +
.../src/main/js/views/includes/footer.jade | 23 +
.../src/main/js/views/includes/header.jade | 51 +
.../web-console/src/main/js/views/index.jade | 48 +
.../web-console/src/main/js/views/reset.jade | 48 +
.../src/main/js/views/settings/admin.jade | 76 +
.../src/main/js/views/settings/profile.jade | 76 +
.../web-console/src/main/js/views/signin.jade | 163 +
.../src/main/js/views/sql/cache-metadata.jade | 40 +
.../src/main/js/views/sql/chart-settings.jade | 40 +
.../src/main/js/views/sql/notebook-new.jade | 31 +
.../src/main/js/views/sql/paragraph-rate.jade | 31 +
.../web-console/src/main/js/views/sql/sql.jade | 201 +
.../main/js/views/templates/agent-download.jade | 48 +
.../src/main/js/views/templates/alert.jade | 21 +
.../main/js/views/templates/batch-confirm.jade | 32 +
.../src/main/js/views/templates/clone.jade | 31 +
.../src/main/js/views/templates/confirm.jade | 31 +
.../src/main/js/views/templates/demo-info.jade | 45 +
.../src/main/js/views/templates/dropdown.jade | 21 +
.../js/views/templates/getting-started.jade | 32 +
.../src/main/js/views/templates/message.jade | 26 +
.../src/main/js/views/templates/pagination.jade | 32 +
.../src/main/js/views/templates/select.jade | 26 +
.../js/views/templates/validation-error.jade | 25 +
modules/web-console/src/test/js/routes/agent.js | 94 +
modules/web/ignite-appserver-test/pom.xml | 75 +
.../webapp/META-INF/config/default-config.xml | 37 +
.../src/main/webapp/WEB-INF/web.xml | 52 +
.../src/main/webapp/index.jsp | 36 +
modules/web/ignite-websphere-test/pom.xml | 69 +
.../apache/ignite/webtest/TestJtaTxServlet.java | 106 +
.../webapp/META-INF/config/default-config.xml | 70 +
.../src/main/webapp/WEB-INF/web.xml | 62 +
.../src/main/webapp/index.jsp | 36 +
modules/web/pom.xml | 2 +-
.../ignite/cache/websession/WebSession.java | 105 +-
.../cache/websession/WebSessionFilter.java | 749 ++-
.../cache/websession/WebSessionListener.java | 133 +-
.../ignite/cache/websession/WebSessionV2.java | 409 ++
.../IgniteWebSessionSelfTestSuite.java | 45 +
.../internal/websession/WebSessionSelfTest.java | 940 ++-
.../webapp2/META-INF/ignite-webapp-config.xml | 279 +
modules/web/src/test/webapp2/WEB-INF/web.xml | 45 +
.../config/benchmark-cache-load-win.properties | 60 +
.../config/benchmark-cache-load.properties | 92 +
.../yardstick/config/benchmark-full.properties | 116 +
.../config/ignite-base-load-config.xml | 255 +
.../config/ignite-cache-load-config.xml | 71 +
modules/yardstick/config/queries.sql | 3 +
modules/yardstick/pom.xml | 48 +-
.../yardstick/IgniteBenchmarkArguments.java | 50 +-
.../ignite/yardstick/IgniteBenchmarkUtils.java | 71 +-
.../org/apache/ignite/yardstick/IgniteNode.java | 2 +
.../cache/CacheEntryEventAsyncProbe.java | 61 +
.../yardstick/cache/CacheEntryEventProbe.java | 33 +-
.../cache/IgniteCacheAbstractBenchmark.java | 59 +
.../IgniteInvokeWithInjectionBenchmark.java | 74 +
.../IgniteInvokeWithInjectionTxBenchmark.java | 30 +
.../IgniteSqlQueryDistributedJoinBenchmark.java | 166 +
...lQueryDistributedJoinBroadcastBenchmark.java | 28 +
.../IgniteCacheRandomOperationBenchmark.java | 1246 ++++
.../yardstick/cache/load/model/ModelUtil.java | 185 +
.../cache/load/model/key/Identifier.java | 113 +
.../yardstick/cache/load/model/key/Mark.java | 115 +
.../yardstick/cache/load/model/value/Car.java | 126 +
.../yardstick/cache/load/model/value/Color.java | 50 +
.../yardstick/cache/load/model/value/Truck.java | 69 +
.../ignite/yardstick/cache/model/Account.java | 6 +
.../ignite/yardstick/cache/model/Person1.java | 2 +-
.../ignite/yardstick/cache/model/Person2.java | 2 +-
.../ignite/yardstick/cache/model/SampleKey.java | 2 +-
.../yardstick/cache/model/SampleValue.java | 2 +-
modules/yarn/pom.xml | 2 +-
modules/zookeeper/pom.xml | 49 +-
.../zk/TcpDiscoveryZookeeperIpFinder.java | 84 +-
.../tcp/ipfinder/zk/ZookeeperIpFinderTest.java | 40 +-
parent/pom.xml | 52 +-
pom.xml | 50 +-
3017 files changed, 311082 insertions(+), 56525 deletions(-)
----------------------------------------------------------------------
[31/50] [abbrv] ignite git commit: IGNITE-3798: ODBC: Added literals
support. This closes #1005.
Posted by sb...@apache.org.
IGNITE-3798: ODBC: Added literals support. This closes #1005.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/fbbcaf43
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/fbbcaf43
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/fbbcaf43
Branch: refs/heads/ignite-961
Commit: fbbcaf4322548f61d2f63bf5d4e8f6d5284e73d3
Parents: 3244a5c
Author: Andrey V. Mashenkov <an...@gmail.com>
Authored: Tue Aug 30 13:22:29 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Aug 30 13:22:29 2016 +0300
----------------------------------------------------------------------
.../processors/odbc/escape/OdbcEscapeUtils.java | 87 +++++++++++---------
.../odbc/OdbcEscapeSequenceSelfTest.java | 55 +++++++++++++
2 files changed, 105 insertions(+), 37 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/fbbcaf43/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/escape/OdbcEscapeUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/escape/OdbcEscapeUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/escape/OdbcEscapeUtils.java
index 27120d4..48d4296 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/escape/OdbcEscapeUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/escape/OdbcEscapeUtils.java
@@ -69,60 +69,70 @@ public class OdbcEscapeUtils {
int plainPos = startPos;
int openPos = -1;
+ boolean insideLiteral = false;
+
LinkedList<OdbcEscapeParseResult> nested = null;
while (curPos < text.length()) {
char curChar = text.charAt(curPos);
- if (curChar == '{') {
- if (openPos == -1) {
- // Top-level opening brace. Append previous portion and remember current position.
- res.append(text, plainPos, curPos);
+ if (curChar == '\'') {
+ if (!insideLiteral)
+ insideLiteral = true;
+ else if (text.charAt(curPos - 1) != '\\')
+ insideLiteral = false;
+ }
+ else if (!insideLiteral) {
+ if (curChar == '{') {
+ if (openPos == -1) {
+ // Top-level opening brace. Append previous portion and remember current position.
+ res.append(text, plainPos, curPos);
- openPos = curPos;
- }
- else {
- // Nested opening brace -> perform recursion.
- OdbcEscapeParseResult nestedRes = parse0(text, curPos, true);
+ openPos = curPos;
+ }
+ else {
+ // Nested opening brace -> perform recursion.
+ OdbcEscapeParseResult nestedRes = parse0(text, curPos, true);
- if (nested == null)
- nested = new LinkedList<>();
+ if (nested == null)
+ nested = new LinkedList<>();
- nested.add(nestedRes);
+ nested.add(nestedRes);
- curPos += nestedRes.originalLength() - 1;
+ curPos += nestedRes.originalLength() - 1;
- plainPos = curPos + 1;
+ plainPos = curPos + 1;
+ }
}
- }
- else if (curChar == '}') {
- if (openPos == -1)
- // Close without open -> exception.
- throw new IgniteException("Malformed escape sequence " +
- "(closing curly brace without opening curly brace): " + text);
- else {
- String parseRes;
-
- if (nested == null)
- // Found sequence without nesting, process it.
- parseRes = parseEscapeSequence(text, openPos, curPos + 1 - openPos);
+ else if (curChar == '}') {
+ if (openPos == -1)
+ // Close without open -> exception.
+ throw new IgniteException("Malformed escape sequence " +
+ "(closing curly brace without opening curly brace): " + text);
else {
- // Special case to process nesting.
- String res0 = appendNested(text, openPos, curPos + 1, nested);
+ String parseRes;
- nested = null;
+ if (nested == null)
+ // Found sequence without nesting, process it.
+ parseRes = parseEscapeSequence(text, openPos, curPos + 1 - openPos);
+ else {
+ // Special case to process nesting.
+ String res0 = appendNested(text, openPos, curPos + 1, nested);
- parseRes = parseEscapeSequence(res0, 0, res0.length());
- }
+ nested = null;
- if (earlyExit)
- return new OdbcEscapeParseResult(startPos, curPos + 1 - startPos, parseRes);
- else
- res.append(parseRes);
+ parseRes = parseEscapeSequence(res0, 0, res0.length());
+ }
- openPos = -1;
+ if (earlyExit)
+ return new OdbcEscapeParseResult(startPos, curPos + 1 - startPos, parseRes);
+ else
+ res.append(parseRes);
- plainPos = curPos + 1;
+ openPos = -1;
+
+ plainPos = curPos + 1;
+ }
}
}
@@ -132,6 +142,9 @@ public class OdbcEscapeUtils {
if (openPos != -1)
throw new IgniteException("Malformed escape sequence (closing curly brace missing): " + text);
+ if (insideLiteral)
+ throw new IgniteException("Malformed literal expression (closing quote missing): " + text);
+
if (curPos > plainPos)
res.append(text, plainPos, curPos);
http://git-wip-us.apache.org/repos/asf/ignite/blob/fbbcaf43/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/OdbcEscapeSequenceSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/OdbcEscapeSequenceSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/OdbcEscapeSequenceSelfTest.java
index 4887a67..3fec7d3 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/OdbcEscapeSequenceSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/OdbcEscapeSequenceSelfTest.java
@@ -486,6 +486,61 @@ public class OdbcEscapeSequenceSelfTest extends GridCommonAbstractTest {
}
/**
+ * Test non-escape sequences.
+ */
+ public void testNonEscapeSequence() throws Exception {
+ check("'{fn test()}'", "'{fn test()}'");
+
+ check("select '{fn test()}'", "select '{fn test()}'");
+
+ check(
+ "select '{fn test()}' from table;",
+ "select '{fn test()}' from table;"
+ );
+
+ check(
+ "select test('arg') from table;",
+ "select {fn test('arg')} from table;"
+ );
+
+ check(
+ "select test('{fn func()}') from table;",
+ "select {fn test('{fn func()}')} from table;"
+ );
+
+ check(
+ "'{\\'some literal\\'}'",
+ "'{\\'some literal\\'}'"
+ );
+
+ check(
+ "select '{\\'some literal\\'}'",
+ "select '{\\'some literal\\'}'"
+ );
+
+ check(
+ "select '{\\'some literal\\'}' from table;",
+ "select '{\\'some literal\\'}' from table;"
+ );
+
+ check(
+ "select '{' + func() + '}' from table;",
+ "select '{' + {fn func()} + '}' from table;"
+ );
+
+ check(
+ "select '{\\'{fn test()}\\'}' from table;",
+ "select '{\\'{fn test()}\\'}' from table;"
+ );
+
+ checkFail("'{fn test()}");
+
+ checkFail("{fn func('arg)}");
+
+ checkFail("{fn func(arg')}");
+ }
+
+ /**
* Check parsing logic.
*
* @param exp Expected result.
[30/50] [abbrv] ignite git commit: IGNITE-3742: ODBC: Added support
for OUTER JOIN escape sequence. This closes #1000.
Posted by sb...@apache.org.
IGNITE-3742: ODBC: Added support for OUTER JOIN escape sequence. This closes #1000.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/3244a5c9
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/3244a5c9
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/3244a5c9
Branch: refs/heads/ignite-961
Commit: 3244a5c9dabf6d4fcaa32a661cc0adc6f8ea30de
Parents: f9ff97c
Author: Andrey V. Mashenkov <an...@gmail.com>
Authored: Tue Aug 30 11:49:11 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Aug 30 11:49:11 2016 +0300
----------------------------------------------------------------------
.../processors/odbc/escape/OdbcEscapeUtils.java | 32 +++---
.../odbc/OdbcEscapeSequenceSelfTest.java | 109 ++++++++++++++++++-
2 files changed, 122 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3244a5c9/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/escape/OdbcEscapeUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/escape/OdbcEscapeUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/escape/OdbcEscapeUtils.java
index a4b89c3..27120d4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/escape/OdbcEscapeUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/escape/OdbcEscapeUtils.java
@@ -105,14 +105,14 @@ public class OdbcEscapeUtils {
if (nested == null)
// Found sequence without nesting, process it.
- parseRes = parseExpression(text, openPos, curPos + 1 - openPos);
+ parseRes = parseEscapeSequence(text, openPos, curPos + 1 - openPos);
else {
// Special case to process nesting.
String res0 = appendNested(text, openPos, curPos + 1, nested);
nested = null;
- parseRes = parseExpression(res0, 0, res0.length());
+ parseRes = parseEscapeSequence(res0, 0, res0.length());
}
if (earlyExit)
@@ -139,14 +139,14 @@ public class OdbcEscapeUtils {
}
/**
- * Parse concrete expression.
+ * Parse escape sequence: {escape_sequence}.
*
* @param text Text.
* @param startPos Start position within text.
* @param len Length.
* @return Result.
*/
- private static String parseExpression(String text, int startPos, int len) {
+ private static String parseEscapeSequence(String text, int startPos, int len) {
assert validSubstring(text, startPos, len);
char firstChar = text.charAt(startPos);
@@ -228,7 +228,7 @@ public class OdbcEscapeUtils {
}
/**
- * Parse standard token.
+ * Parse standard expression: {TOKEN expression}
*
* @param text Text.
* @param startPos Start position.
@@ -245,10 +245,13 @@ public class OdbcEscapeUtils {
switch (token.type()) {
case SCALAR_FUNCTION:
- return parseScalarExpression(text, startPos0, len0);
+ return parseExpression(text, startPos0, len0);
+
+ case GUID: {
+ String res = parseExpression(text, startPos0, len0, token.type(), GUID_PATTERN);
- case GUID:
- return parseExpression(text, startPos0, len0, token.type(), GUID_PATTERN);
+ return "CAST(" + res + " AS UUID)";
+ }
case DATE:
return parseExpression(text, startPos0, len0, token.type(), DATE_PATTERN);
@@ -259,6 +262,9 @@ public class OdbcEscapeUtils {
case TIMESTAMP:
return parseExpression(text, startPos0, len0, token.type(), TIMESTAMP_PATTERN);
+ case OUTER_JOIN:
+ return parseExpression(text, startPos0, len0);
+
default:
throw new IgniteException("Unsupported escape sequence token [text=" +
substring(text, startPos, len) + ", token=" + token.type().body() + ']');
@@ -266,19 +272,19 @@ public class OdbcEscapeUtils {
}
/**
- * Parse scalar function expression.
+ * Parse simple expression.
*
* @param text Text.
* @param startPos Start position.
* @param len Length.
* @return Parsed expression.
*/
- private static String parseScalarExpression(String text, int startPos, int len) {
+ private static String parseExpression(String text, int startPos, int len) {
return substring(text, startPos, len).trim();
}
/**
- * Parse concrete expression.
+ * Parse expression and validate against ODBC specification with regex pattern.
*
* @param text Text.
* @param startPos Start position.
@@ -286,12 +292,12 @@ public class OdbcEscapeUtils {
* @return Parsed expression.
*/
private static String parseExpression(String text, int startPos, int len, OdbcEscapeType type, Pattern pattern) {
- String val = substring(text, startPos, len).trim();
+ String val = parseExpression(text, startPos, len);
if (!pattern.matcher(val).matches())
throw new IgniteException("Invalid " + type + " escape sequence: " + substring(text, startPos, len));
- return "CAST(" + val + " AS UUID)";
+ return val;
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/3244a5c9/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/OdbcEscapeSequenceSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/OdbcEscapeSequenceSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/OdbcEscapeSequenceSelfTest.java
index 1aa90fd..4887a67 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/OdbcEscapeSequenceSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/OdbcEscapeSequenceSelfTest.java
@@ -167,17 +167,17 @@ public class OdbcEscapeSequenceSelfTest extends GridCommonAbstractTest {
*/
public void testGuidEscapeSequence() {
check(
- "'12345678-9abc-def0-1234-123456789abc'",
+ "CAST('12345678-9abc-def0-1234-123456789abc' AS UUID)",
"{guid '12345678-9abc-def0-1234-123456789abc'}"
);
check(
- "select '12345678-9abc-def0-1234-123456789abc' from SomeTable;",
+ "select CAST('12345678-9abc-def0-1234-123456789abc' AS UUID) from SomeTable;",
"select {guid '12345678-9abc-def0-1234-123456789abc'} from SomeTable;"
);
check(
- "select '12345678-9abc-def0-1234-123456789abc'",
+ "select CAST('12345678-9abc-def0-1234-123456789abc' AS UUID)",
"select {guid '12345678-9abc-def0-1234-123456789abc'}"
);
}
@@ -212,17 +212,17 @@ public class OdbcEscapeSequenceSelfTest extends GridCommonAbstractTest {
*/
public void testGuidEscapeSequenceWithWhitespaces() throws Exception {
check(
- "'12345678-9abc-def0-1234-123456789abc'",
+ "CAST('12345678-9abc-def0-1234-123456789abc' AS UUID)",
"{ guid '12345678-9abc-def0-1234-123456789abc'}"
);
check(
- "'12345678-9abc-def0-1234-123456789abc'",
+ "CAST('12345678-9abc-def0-1234-123456789abc' AS UUID)",
"{ guid '12345678-9abc-def0-1234-123456789abc'}"
);
check(
- "'12345678-9abc-def0-1234-123456789abc'",
+ "CAST('12345678-9abc-def0-1234-123456789abc' AS UUID)",
"{ \n guid\n'12345678-9abc-def0-1234-123456789abc'}"
);
}
@@ -388,6 +388,103 @@ public class OdbcEscapeSequenceSelfTest extends GridCommonAbstractTest {
checkFail("select {}ts '2016-08-26 13:15:08'} from table;");
}
+
+ /**
+ * Test escape sequence series.
+ */
+ public void testOuterJoinFunction() throws Exception {
+ check(
+ "t OUTER JOIN t2 ON t.id=t2.id",
+ "{oj t OUTER JOIN t2 ON t.id=t2.id}"
+ );
+
+ check(
+ "select * from t OUTER JOIN t2 ON t.id=t2.id",
+ "select * from {oj t OUTER JOIN t2 ON t.id=t2.id}"
+ );
+
+ check(
+ "select * from t OUTER JOIN t2 ON t.id=t2.id ORDER BY t2.id",
+ "select * from {oj t OUTER JOIN t2 ON t.id=t2.id} ORDER BY t2.id"
+ );
+ }
+
+ /**
+ * Test simple nested escape sequences. Depth = 2.
+ */
+ public void testNestedOuterJoin() throws Exception {
+ check(
+ "t OUTER JOIN (t2 OUTER JOIN t3 ON t2.id=t3.id) ON t.id=t2.id",
+ "{oj t OUTER JOIN ({oj t2 OUTER JOIN t3 ON t2.id=t3.id}) ON t.id=t2.id}"
+ );
+
+ check(
+ "select * from t OUTER JOIN (t2 OUTER JOIN t3 ON t2.id=t3.id) ON t.id=t2.id",
+ "select * from {oj t OUTER JOIN ({oj t2 OUTER JOIN t3 ON t2.id=t3.id}) ON t.id=t2.id}"
+ );
+
+ check(
+ "select * from t OUTER JOIN (t2 OUTER JOIN t3 ON t2.id=t3.id) ON t.id=t2.id ORDER BY t2.id",
+ "select * from {oj t OUTER JOIN ({oj t2 OUTER JOIN t3 ON t2.id=t3.id}) ON t.id=t2.id} ORDER BY t2.id"
+ );
+ }
+
+ /**
+ * Test nested escape sequences. Depth > 2.
+ */
+ public void testDeepNestedOuterJoin() {
+ check(
+ "t OUTER JOIN (t2 OUTER JOIN (t3 OUTER JOIN t4 ON t3.id=t4.id) ON t2.id=t3.id) ON t.id=t2.id",
+ "{oj t OUTER JOIN ({oj t2 OUTER JOIN ({oj t3 OUTER JOIN t4 ON t3.id=t4.id}) ON t2.id=t3.id}) ON t.id=t2.id}"
+ );
+
+ check(
+ "select * from " +
+ "t OUTER JOIN (t2 OUTER JOIN (t3 OUTER JOIN t4 ON t3.id=t4.id) ON t2.id=t3.id) ON t.id=t2.id",
+ "select * from " +
+ "{oj t OUTER JOIN ({oj t2 OUTER JOIN ({oj t3 OUTER JOIN t4 ON t3.id=t4.id}) ON t2.id=t3.id})" +
+ " ON t.id=t2.id}"
+ );
+
+ check(
+ "select * from t OUTER JOIN (t2 OUTER JOIN (t3 OUTER JOIN t4 ON t3.id=t4.id) " +
+ "ON t2.id=t3.id) ON t.id=t2.id ORDER BY t4.id",
+ "select * from {oj t OUTER JOIN ({oj t2 OUTER JOIN ({oj t3 OUTER JOIN t4 ON t3.id=t4.id}) " +
+ "ON t2.id=t3.id}) ON t.id=t2.id} ORDER BY t4.id"
+ );
+ }
+
+ /**
+ * Test invalid escape sequence.
+ */
+ public void testFailedOnInvalidOuterJoinSequence() {
+ checkFail("{ojt OUTER JOIN t2 ON t.id=t2.id}");
+
+ checkFail("select {oj t OUTER JOIN ({oj t2 OUTER JOIN t3 ON t2.id=t3.id) ON t.id=t2.id} from SomeTable;");
+
+ checkFail("select oj t OUTER JOIN t2 ON t.id=t2.id} from SomeTable;");
+ }
+
+ /**
+ * Test escape sequences with additional whitespace characters
+ */
+ public void testOuterJoinSequenceWithWhitespaces() throws Exception {
+ check(
+ "t OUTER JOIN t2 ON t.id=t2.id",
+ "{ oj t OUTER JOIN t2 ON t.id=t2.id}"
+ );
+
+ check(
+ "t OUTER JOIN t2 ON t.id=t2.id",
+ "{ oj t OUTER JOIN t2 ON t.id=t2.id}"
+ );
+
+ check(
+ "t OUTER JOIN t2 ON t.id=t2.id",
+ " \n { oj\nt OUTER JOIN t2 ON t.id=t2.id}"
+ );
+ }
+
/**
* Check parsing logic.
*
[41/50] [abbrv] ignite git commit: IGNITE-3789 Test for
EntryProcessor/partition evts
Posted by sb...@apache.org.
IGNITE-3789 Test for EntryProcessor/partition evts
Tests that validate:
1. EntryProcessors execute against partitions that are fully owned/loaded.
2. Expected events are raised when partitions are moved due to a change in cluster topology.
See https://issues.apache.org/jira/browse/IGNITE-3456.
This closes #997.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/6ca7e066
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/6ca7e066
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/6ca7e066
Branch: refs/heads/ignite-961
Commit: 6ca7e0666ef0ed1b70c775a06cee5a58d55a77a7
Parents: 8f69787
Author: Patrick Peralta <pa...@workday.com>
Authored: Thu Sep 1 11:49:08 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Thu Sep 1 11:49:08 2016 +0300
----------------------------------------------------------------------
.../GridCacheRebalancingOrderingTest.java | 916 +++++++++++++++++++
1 file changed, 916 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/6ca7e066/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingOrderingTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingOrderingTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingOrderingTest.java
new file mode 100644
index 0000000..62fc5e9
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingOrderingTest.java
@@ -0,0 +1,916 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache.distributed.rebalancing;
+
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Random;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.CopyOnWriteArraySet;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import javax.cache.processor.EntryProcessor;
+import javax.cache.processor.EntryProcessorException;
+import javax.cache.processor.EntryProcessorResult;
+import javax.cache.processor.MutableEntry;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteEvents;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.cache.CachePeekMode;
+import org.apache.ignite.cache.CacheRebalanceMode;
+import org.apache.ignite.cache.affinity.Affinity;
+import org.apache.ignite.cache.affinity.AffinityKeyMapped;
+import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.events.CacheEvent;
+import org.apache.ignite.events.CacheRebalancingEvent;
+import org.apache.ignite.events.Event;
+import org.apache.ignite.events.EventType;
+import org.apache.ignite.internal.util.typedef.X;
+import org.apache.ignite.lang.IgnitePredicate;
+import org.apache.ignite.services.Service;
+import org.apache.ignite.services.ServiceConfiguration;
+import org.apache.ignite.services.ServiceContext;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+import static org.apache.ignite.cache.CacheAtomicWriteOrderMode.PRIMARY;
+import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
+
+/**
+ * Test to validate cache and partition events raised from entry processors executing against
+ * partitions are are loading/unloading.
+ * <p>
+ * The test consists of two parts:
+ * <p>
+ * 1. The server side that maintains a map of partition id to the set of keys that belong to
+ * that partition for all partitions (primary + backup) owned by the server. This map
+ * is updated by a local listener registered for the following events:
+ * <ul>
+ * <li>EVT_CACHE_OBJECT_PUT</li>
+ * <li>EVT_CACHE_OBJECT_REMOVED</li>
+ * <li>EVT_CACHE_REBALANCE_OBJECT_LOADED</li>
+ * <li>EVT_CACHE_REBALANCE_OBJECT_UNLOADED</li>
+ * <li>EVT_CACHE_REBALANCE_PART_LOADED</li>
+ * <li>EVT_CACHE_REBALANCE_PART_UNLOADED</li>
+ * <li>EVT_CACHE_REBALANCE_PART_DATA_LOST</li>
+ * </ul>
+ * 2. The client side that generates a random number of keys for each partition and populates
+ * the cache. When the cache is loaded, each partition has at least one key assigned to it. The
+ * client then issues an {@code invokeAll} on the cache with a key set consisting of one key
+ * belonging to each partition.
+ * <p>
+ * The test makes the following assertions:
+ * <ol>
+ * <li>EntryProcessors should execute against partitions that are owned/fully loaded.
+ * If a processor executes against a partition that is partially loaded, the message
+ * "Key validation requires a retry for partitions" is logged on the client, and
+ * "Retrying validation for primary partition N due to newly arrived partition..." and
+ * "Retrying validation for primary partition N due to forming partition..." is logged
+ * on the server side.</li>
+ * <li>Events for entries being added/removed and partitions being loaded/unloaded
+ * should always be delivered to the server nodes that own the partition. If this does
+ * not happen, the client will log "For primary partition N expected [...], but
+ * found [...]; missing local keys: []" and "Key validation failed for partitions: [...]".
+ * The server will log "Retrying validation for primary|backup partition N due to
+ * forming partition" and "For primary|backup partition N expected [...], but found [...];"
+ * </li>
+ * </ol>
+ */
+public class GridCacheRebalancingOrderingTest extends GridCommonAbstractTest {
+ /** {@link Random} for test key generation. */
+ private final static Random RANDOM = new Random();
+
+ /** Test cache name. */
+ private static final String TEST_CACHE_NAME = "TestCache";
+
+ /** Flag to configure transactional versus non-transactional cache. */
+ public static final boolean TRANSACTIONAL = false;
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ if (isFirstGrid(gridName)) {
+ cfg.setClientMode(true);
+
+ assert cfg.getDiscoverySpi() instanceof TcpDiscoverySpi : cfg.getDiscoverySpi();
+
+ ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setForceServerMode(true);
+ }
+ else
+ cfg.setServiceConfiguration(getServiceConfiguration());
+
+ cfg.setCacheConfiguration(getCacheConfiguration());
+
+ return cfg;
+ }
+
+ /**
+ * @return service configuration for services used in test cluster
+ * @see #getConfiguration()
+ */
+ private ServiceConfiguration getServiceConfiguration() {
+ ServiceConfiguration cfg = new ServiceConfiguration();
+
+ cfg.setName(PartitionObserver.class.getName());
+ cfg.setService(new PartitionObserverService());
+ cfg.setMaxPerNodeCount(1);
+ cfg.setTotalCount(0); // 1 service per node.
+
+ return cfg;
+ }
+
+ /**
+ * @return Cache configuration used by test.
+ * @see #getConfiguration().
+ */
+ protected CacheConfiguration<IntegerKey, Integer> getCacheConfiguration() {
+ CacheConfiguration<IntegerKey, Integer> cfg = new CacheConfiguration<>();
+
+ cfg.setAtomicityMode(TRANSACTIONAL ? CacheAtomicityMode.TRANSACTIONAL : CacheAtomicityMode.ATOMIC);
+ cfg.setCacheMode(CacheMode.PARTITIONED);
+ cfg.setName(TEST_CACHE_NAME);
+ cfg.setAffinity(new RendezvousAffinityFunction(true /* machine-safe */, 271));
+ cfg.setAtomicWriteOrderMode(PRIMARY);
+ cfg.setBackups(1);
+ cfg.setRebalanceMode(CacheRebalanceMode.SYNC);
+ cfg.setWriteSynchronizationMode(FULL_SYNC);
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected boolean isMultiJvm() {
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected long getTestTimeout() {
+ return 1000 * 60 * 5;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ stopAllGrids();
+
+ super.afterTestsStopped();
+ }
+
+ /**
+ * Convert the given key from binary form, if necessary.
+ *
+ * @param key the key to convert if necessary
+ * @return the key
+ */
+ private static IntegerKey ensureKey(Object key) {
+ Object converted = key instanceof BinaryObject ? ((BinaryObject) key).deserialize() : key;
+ return converted instanceof IntegerKey ? (IntegerKey) converted : null;
+ }
+
+ /**
+ * Determine which of the specified keys (if any) are missing locally from the given cache.
+ *
+ * @param cache The cache to check.
+ * @param exp The expected set of keys.
+ * @return The set of missing keys.
+ */
+ private static Set<IntegerKey> getMissingKeys(IgniteCache<IntegerKey, Integer> cache, Set<IntegerKey> exp) {
+ Set<IntegerKey> missing = new HashSet<>();
+
+ for (IntegerKey key : exp) {
+ if (cache.localPeek(key, CachePeekMode.ALL) == null)
+ missing.add(key);
+ }
+
+ return missing;
+ }
+
+ /**
+ * For an Ignite cache, generate a random {@link IntegerKey} per partition. The number
+ * of partitions is determined by the cache's {@link Affinity}.
+ *
+ * @param ignite Ignite instance.
+ * @param cache Cache to generate keys for.
+ * @return Map of partition number to randomly generated key.
+ */
+ private Map<Integer, IntegerKey> generateKeysForPartitions(Ignite ignite, IgniteCache<IntegerKey, Integer> cache) {
+ Affinity<IntegerKey> affinity = ignite.affinity(cache.getName());
+
+ int parts = affinity.partitions();
+
+ Map<Integer, IntegerKey> keyMap = new HashMap<>(parts);
+
+ for (int i = 0; i < parts; i++) {
+ boolean found = false;
+
+ do {
+ IntegerKey key = new IntegerKey(RANDOM.nextInt(10000));
+
+ if (affinity.partition(key) == i) {
+ keyMap.put(i, key);
+ found = true;
+ }
+ } while (!found);
+ }
+
+ // Sanity check.
+ if (keyMap.size() != affinity.partitions())
+ throw new IllegalStateException("Inconsistent partition count");
+
+ for (int i = 0; i < parts; i++) {
+ IntegerKey key = keyMap.get(i);
+
+ if (affinity.partition(key) != i)
+ throw new IllegalStateException("Inconsistent partition");
+ }
+
+ return keyMap;
+ }
+
+ /**
+ * Starts background thread that launches servers. This method will block
+ * until at least one server is running.
+ *
+ * @return {@link ServerStarter} runnable that starts servers
+ * @throws Exception If failed.
+ */
+ private ServerStarter startServers() throws Exception {
+ ServerStarter srvStarter = new ServerStarter();
+
+ Thread t = new Thread(srvStarter);
+ t.setDaemon(true);
+ t.setName("Server Starter");
+ t.start();
+
+ srvStarter.waitForServerStart();
+
+ return srvStarter;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testEvents() throws Exception {
+ Ignite ignite = startGrid(0);
+
+ ServerStarter srvStarter = startServers();
+
+ IgniteCache<IntegerKey, Integer> cache = ignite.cache(TEST_CACHE_NAME);
+
+ // Generate a key per partition.
+ Map<Integer, IntegerKey> keyMap = generateKeysForPartitions(ignite, cache);
+
+ // Populate a random number of keys per partition.
+ Map<Integer, Set<IntegerKey>> partMap = new HashMap<>(keyMap.size());
+
+ for (Map.Entry<Integer, IntegerKey> entry : keyMap.entrySet()) {
+ Integer part = entry.getKey();
+ int affinity = entry.getValue().getKey();
+ int cnt = RANDOM.nextInt(10) + 1;
+
+ Set<IntegerKey> keys = new HashSet<>(cnt);
+
+ for (int i = 0; i < cnt; i++) {
+ IntegerKey key = new IntegerKey(RANDOM.nextInt(10000), affinity);
+ keys.add(key);
+ cache.put(key, RANDOM.nextInt());
+ }
+
+ partMap.put(part, keys);
+ }
+
+ // Display the partition map.
+ X.println("Partition Map:");
+
+ for (Map.Entry<Integer, Set<IntegerKey>> entry : partMap.entrySet())
+ X.println(entry.getKey() + ": " + entry.getValue());
+
+ // Validate keys across all partitions.
+ Affinity<IntegerKey> affinity = ignite.affinity(cache.getName());
+
+ Map<IntegerKey, KeySetValidator> validatorMap = new HashMap<>(partMap.size());
+
+ for (Map.Entry<Integer, Set<IntegerKey>> partEntry : partMap.entrySet()) {
+ Integer part = partEntry.getKey();
+
+ validatorMap.put(keyMap.get(part), new KeySetValidator(partEntry.getValue()));
+ }
+
+ int i = 0;
+
+ while (!srvStarter.isDone()) {
+ Map<IntegerKey, EntryProcessorResult<KeySetValidator.Result>> results = cache.invokeAll(validatorMap);
+
+ Set<Integer> failures = new HashSet<>();
+ Set<Integer> retries = new HashSet<>();
+
+ for (Map.Entry<IntegerKey, EntryProcessorResult<KeySetValidator.Result>> result : results.entrySet()) {
+ try {
+ if (result.getValue().get() == KeySetValidator.Result.RETRY)
+ retries.add(affinity.partition(result.getKey()));
+ }
+ catch (Exception e) {
+ X.println("!!! " + e.getMessage());
+ e.printStackTrace();
+ failures.add(affinity.partition(result.getKey()));
+ }
+ }
+
+ if (!failures.isEmpty()) {
+ X.println("*** Key validation failed for partitions: " + failures);
+ fail("https://issues.apache.org/jira/browse/IGNITE-3456");
+ }
+ else if (!retries.isEmpty()) {
+ X.println("*** Key validation requires a retry for partitions: " + retries);
+ retries.clear();
+ }
+ else
+ X.println("*** Key validation was successful: " + i);
+
+ i++;
+
+ Thread.sleep(500);
+ }
+ }
+
+ /**
+ * EntryProcessor that validates that the partition associated with the targeted key has a specified set of keys.
+ */
+ public static class KeySetValidator implements EntryProcessor<IntegerKey, Integer, KeySetValidator.Result> {
+ /** */
+ private final Set<IntegerKey> keys;
+
+ /**
+ * Create a new KeySetValidator.
+ *
+ * @param keys the expected keys belonging to the partition that owns the targeted key
+ */
+ KeySetValidator(Set<IntegerKey> keys) {
+ if (keys == null)
+ throw new IllegalArgumentException();
+
+ this.keys = keys;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Result process(MutableEntry<IntegerKey, Integer> entry, Object... objects) {
+ try {
+ Ignite ignite = entry.unwrap(Ignite.class);
+
+ PartitionObserver observer = ignite.services().service(PartitionObserver.class.getName());
+
+ assertNotNull(observer);
+
+ IgniteCache<IntegerKey, Integer> cache = ignite.cache(TEST_CACHE_NAME);
+
+ Affinity<IntegerKey> affinity = ignite.affinity(TEST_CACHE_NAME);
+
+ Set<IntegerKey> exp = this.keys;
+
+ Set<IntegerKey> missing = getMissingKeys(cache, exp);
+
+ IntegerKey key = entry.getKey();
+
+ int part = affinity.partition(key);
+
+ String ownership = affinity.isPrimary(ignite.cluster().localNode(), key) ? "primary" : "backup";
+
+ // Wait for the local listener to sync past events.
+ if (!observer.getIgniteLocalSyncListener().isSynced()) {
+ ignite.log().info("Retrying validation for " + ownership + " partition " + part
+ + " due to initial sync");
+
+ return Result.RETRY;
+ }
+
+ // Determine if the partition is being loaded and wait for it to load completely.
+ if (observer.getLoadingMap().containsKey(part)) {
+ ignite.log().info("Retrying validation due to forming partition [ownership=" + ownership +
+ ", partition=" + part +
+ ", expKeys=" + exp +
+ ", loadedKeys=" + observer.getLoadingMap().get(part) +
+ ", missingLocalKeys=" + missing + ']');
+
+ return Result.RETRY;
+ }
+
+ if (!observer.getPartitionMap().containsKey(part)) {
+ ignite.log().info("Retrying validation due to newly arrived partition [ownership=" + ownership +
+ ", partition=" + part +
+ ", missingLocalKeys=" + missing + ']');
+
+ return Result.RETRY;
+ }
+
+ // Validate the key count.
+ Set<IntegerKey> curr = observer.ensureKeySet(part);
+
+ if (curr.equals(exp) && missing.isEmpty())
+ return Result.OK;
+
+ String msg = String.format("For %s partition %s:\n\texpected %s,\n\t" +
+ "but found %s;\n\tmissing local keys: %s",
+ ownership, part, new TreeSet<>(exp), new TreeSet<>(curr), new TreeSet<>(missing));
+
+ ignite.log().info(">>> " + msg);
+
+ throw new EntryProcessorException(msg);
+ }
+ catch (NullPointerException e) {
+ e.printStackTrace();
+
+ throw e;
+ }
+ }
+
+ /**
+ *
+ */
+ enum Result {
+ /** */
+ OK,
+ /** */
+ RETRY
+ }
+ }
+
+ /**
+ * Integer value that can optionally be associated with another integer.
+ */
+ public static class IntegerKey implements Comparable<IntegerKey> {
+ /**
+ * The integer key value.
+ */
+ private final int val;
+
+ /**
+ * The optional associated integer.
+ */
+ @AffinityKeyMapped
+ private final Integer affinity;
+
+ /**
+ * Create a new IntegerKey for the given integer value.
+ *
+ * @param val the integer key value
+ */
+ IntegerKey(int val) {
+ this.val = val;
+ this.affinity = val;
+ }
+
+ /**
+ * Create a new IntegerKey for the given integer value that is associated with the specified integer.
+ *
+ * @param val the integer key value
+ * @param affinity the associated integer
+ */
+ IntegerKey(int val, int affinity) {
+ this.val = val;
+ this.affinity = affinity;
+ }
+
+ /**
+ * Return the integer key value.
+ *
+ * @return the integer key value
+ */
+ public int getKey() {
+ return this.val;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ return this.val;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object o) {
+ if (o == this)
+ return true;
+ if (o == null)
+ return false;
+
+ if (IntegerKey.class.equals(o.getClass())) {
+ IntegerKey that = (IntegerKey) o;
+ return this.val == that.val;
+ }
+
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ int val = this.val;
+ Integer affinity = this.affinity;
+
+ if (val == affinity)
+ return String.valueOf(val);
+
+ return "IntKey [val=" + val + ", aff=" + affinity + ']';
+ }
+
+ /** {@inheritDoc} */
+ @Override public int compareTo(final IntegerKey that) {
+ int i = this.affinity.compareTo(that.affinity);
+
+ if (i == 0)
+ i = Integer.compare(this.getKey(), that.getKey());
+
+ return i;
+ }
+ }
+
+ /**
+ * Local listener wrapper that brings a delegate listener up to date with the latest events.
+ */
+ private static class IgniteLocalSyncListener implements IgnitePredicate<Event> {
+ /** */
+ private final IgnitePredicate<Event> delegate;
+
+ /** */
+ private final int[] causes;
+
+ /** */
+ private volatile boolean isSynced;
+
+ /** */
+ private volatile long syncedId = Long.MIN_VALUE;
+
+ /**
+ * @param delegate Event listener.
+ * @param causes Event types to listen.
+ */
+ IgniteLocalSyncListener(IgnitePredicate<Event> delegate, int... causes) {
+ this.delegate = delegate;
+ this.causes = causes;
+ }
+
+ /**
+ * @return Local ignite.
+ */
+ protected Ignite ignite() {
+ return Ignition.localIgnite();
+ }
+
+ /**
+ *
+ */
+ public void register() {
+ ignite().events().localListen(this.delegate, this.causes);
+
+ sync();
+ }
+
+ /**
+ *
+ */
+ public void sync() {
+ if (!this.isSynced) {
+ synchronized (this) {
+ if (!this.isSynced) {
+ Collection<Event> evts = ignite().events().localQuery(new IgnitePredicate<Event>() {
+ @Override public boolean apply(final Event evt) {
+ return true;
+ }
+ },
+ this.causes);
+
+ for (Event event : evts) {
+ // Events returned from localQuery() are ordered by increasing local ID. Update the sync ID
+ // within a finally block to avoid applying duplicate events if the delegate listener
+ // throws an exception while processing the event.
+ try {
+ applyInternal(event);
+ }
+ finally {
+ this.syncedId = event.localOrder();
+ }
+ }
+
+ this.isSynced = true;
+
+ notifyAll();
+ }
+ }
+ }
+ }
+
+ /**
+ * @return Synced flag.
+ */
+ boolean isSynced() {
+ return isSynced;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean apply(Event evt) {
+ sync();
+
+ return applyInternal(evt);
+ }
+
+ /**
+ * @param evt Event.
+ * @return See {@link IgniteEvents#localListen}.
+ */
+ boolean applyInternal(Event evt) {
+ // Avoid applying previously recorded events.
+ if (evt.localOrder() > this.syncedId) {
+ try {
+ return this.delegate.apply(evt);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+
+ return false;
+ }
+ }
+
+ return true;
+ }
+ }
+
+ /**
+ * Service interface for server side partition observation.
+ */
+ interface PartitionObserver {
+ /**
+ * @return map of partitions to the keys belonging to that partition
+ */
+ ConcurrentMap<Integer, Set<IntegerKey>> getPartitionMap();
+
+ /**
+ * @return Map of partitions that are in the process of loading and the current keys that belong to that partition.
+ * Currently it seems that an EntryProcessor is not guaranteed to have a "stable" view of a partition and
+ * can see entries as they are being loaded into the partition, so we must batch these events up in the map
+ * and update the {@link #getPartitionMap() partition map} atomically once the partition has been fully loaded.
+ */
+ ConcurrentMap<Integer, Set<IntegerKey>> getLoadingMap();
+
+ /**
+ * Ensure that the {@link #getPartitionMap() partition map} has a set of keys associated with the given
+ * partition, creating one if it doesn't already exist.
+ * @param part the partition
+ * @return the set for the given partition
+ */
+ Set<IntegerKey> ensureKeySet(int part);
+
+ /**
+ * @return listener wrapper that brings a delegate listener up to date with the latest events
+ */
+ IgniteLocalSyncListener getIgniteLocalSyncListener();
+ }
+
+ /**
+ *
+ */
+ private static class PartitionObserverService implements Service, PartitionObserver, Serializable {
+ /** */
+ private final ConcurrentMap<Integer, Set<IntegerKey>> partMap = new ConcurrentHashMap<>();
+
+ /** */
+ private final ConcurrentMap<Integer, Set<IntegerKey>> loadingMap = new ConcurrentHashMap<>();
+
+ /** */
+ private final IgnitePredicate<Event> pred = (IgnitePredicate<Event>) new IgnitePredicate<Event>() {
+ @Override public boolean apply(Event evt) {
+ // Handle:
+ // EVT_CACHE_OBJECT_PUT
+ // EVT_CACHE_REBALANCE_OBJECT_LOADED
+ // EVT_CACHE_OBJECT_REMOVED
+ // EVT_CACHE_REBALANCE_OBJECT_UNLOADED
+ if (evt instanceof CacheEvent) {
+ CacheEvent cacheEvt = (CacheEvent) evt;
+ int part = cacheEvt.partition();
+
+ // Oonly handle events for the test cache.
+ if (TEST_CACHE_NAME.equals(cacheEvt.cacheName())) {
+ switch (evt.type()) {
+ case EventType.EVT_CACHE_OBJECT_PUT: {
+ ensureKeySet(part).add(ensureKey(cacheEvt.key()));
+ break;
+ }
+
+ case EventType.EVT_CACHE_REBALANCE_OBJECT_LOADED: {
+ // Batch up objects that are being loaded.
+ ensureKeySet(part, loadingMap).add(ensureKey(cacheEvt.key()));
+ break;
+ }
+
+ case EventType.EVT_CACHE_OBJECT_REMOVED:
+ case EventType.EVT_CACHE_REBALANCE_OBJECT_UNLOADED: {
+ ensureKeySet(part).remove(ensureKey(cacheEvt.key()));
+ break;
+ }
+ }
+ }
+ }
+ // Handle:
+ // EVT_CACHE_REBALANCE_PART_LOADED
+ // EVT_CACHE_REBALANCE_PART_UNLOADED
+ // EVT_CACHE_REBALANCE_PART_DATA_LOST
+ else if (evt instanceof CacheRebalancingEvent) {
+ CacheRebalancingEvent rebalancingEvt = (CacheRebalancingEvent) evt;
+
+ int part = rebalancingEvt.partition();
+
+ // Only handle events for the test cache.
+ if (TEST_CACHE_NAME.equals(rebalancingEvt.cacheName())) {
+ switch (evt.type()) {
+ case EventType.EVT_CACHE_REBALANCE_PART_UNLOADED: {
+ Set<IntegerKey> keys = partMap.get(part);
+
+ if (keys != null && !keys.isEmpty())
+ X.println("!!! Attempting to unload non-empty partition: " + part + "; keys=" + keys);
+
+ partMap.remove(part);
+
+ X.println("*** Unloaded partition: " + part);
+
+ break;
+ }
+
+ case EventType.EVT_CACHE_REBALANCE_PART_DATA_LOST: {
+ partMap.remove(part);
+
+ X.println("*** Lost partition: " + part);
+
+ break;
+ }
+
+ case EventType.EVT_CACHE_REBALANCE_PART_LOADED: {
+ // Atomically update the key count for the new partition.
+ Set<IntegerKey> keys = loadingMap.get(part);
+ partMap.put(part, keys);
+ loadingMap.remove(part);
+
+ X.println("*** Loaded partition: " + part + "; keys=" + keys);
+
+ break;
+ }
+ }
+ }
+ }
+
+ return true;
+ }
+ };
+
+ /** */
+ private final IgniteLocalSyncListener lsnr = new IgniteLocalSyncListener(pred,
+ EventType.EVT_CACHE_OBJECT_PUT,
+ EventType.EVT_CACHE_OBJECT_REMOVED,
+ EventType.EVT_CACHE_REBALANCE_OBJECT_LOADED,
+ EventType.EVT_CACHE_REBALANCE_OBJECT_UNLOADED,
+ EventType.EVT_CACHE_REBALANCE_PART_LOADED,
+ EventType.EVT_CACHE_REBALANCE_PART_UNLOADED,
+ EventType.EVT_CACHE_REBALANCE_PART_DATA_LOST);
+
+ /** {@inheritDoc} */
+ @Override public ConcurrentMap<Integer, Set<IntegerKey>> getPartitionMap() {
+ return partMap;
+ }
+
+ /** {@inheritDoc} */
+ @Override public ConcurrentMap<Integer, Set<IntegerKey>> getLoadingMap() {
+ return loadingMap;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteLocalSyncListener getIgniteLocalSyncListener() {
+ return lsnr;
+ }
+
+ /**
+ * Ensure that the static partition map has a set of keys associated with the given partition,
+ * creating one if it doesn't already exist.
+ *
+ * @param part the partition
+ * @return the set for the given partition
+ */
+ public Set<IntegerKey> ensureKeySet(final int part) {
+ return ensureKeySet(part, partMap);
+ }
+
+ /**
+ * Ensure that the given partition map has a set of keys associated with the given partition, creating one if it
+ * doesn't already exist.
+ *
+ * @param part the partition
+ * @param map the partition map
+ *
+ * @return the set for the given partition
+ */
+ Set<IntegerKey> ensureKeySet(final int part, final ConcurrentMap<Integer, Set<IntegerKey>> map) {
+ Set<IntegerKey> keys = map.get(part);
+
+ if (keys == null) {
+ map.putIfAbsent(part, new CopyOnWriteArraySet<IntegerKey>());
+
+ keys = map.get(part);
+ }
+
+ return keys;
+ }
+
+
+ /** {@inheritDoc} */
+ @Override public void cancel(final ServiceContext ctx) {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override public void init(final ServiceContext ctx) throws Exception {
+ this.lsnr.register();
+ }
+
+ /** {@inheritDoc} */
+ @Override public void execute(final ServiceContext ctx) throws Exception {
+ // No-op.
+ }
+ }
+
+ /**
+ * Runnable that starts {@value #SERVER_COUNT} servers. This runnable starts
+ * servers every {@value #START_DELAY} milliseconds. The staggered start is intended
+ * to allow partitions to move every time a new server is started.
+ */
+ private class ServerStarter implements Runnable {
+ /** */
+ static final int SERVER_COUNT = 10;
+
+ /** */
+ static final int START_DELAY = 2000;
+
+ /** */
+ private volatile boolean done;
+
+ /** */
+ private final CountDownLatch started = new CountDownLatch(1);
+
+ /** {@inheritDoc} */
+ @Override public void run() {
+ try {
+ for (int i = 1; i <= SERVER_COUNT; i++) {
+ startGrid(i);
+
+ Thread.sleep(START_DELAY);
+
+ awaitPartitionMapExchange();
+
+ started.countDown();
+ }
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+
+ X.println("Shutting down server starter thread");
+ }
+ finally {
+ done = true;
+ }
+ }
+
+ /**
+ * Blocks the executing thread until at least one server has started.
+ *
+ * @throws InterruptedException If interrupted.
+ */
+ void waitForServerStart() throws InterruptedException {
+ started.await(getTestTimeout(), TimeUnit.MILLISECONDS);
+ }
+
+ /** @return true if {@value #SERVER_COUNT} servers have started. */
+ public boolean isDone() {
+ return done;
+ }
+ }
+}
[27/50] [abbrv] ignite git commit: IGNITE-2546 - Transformers for
SCAN queries. Fixes #949.
Posted by sb...@apache.org.
IGNITE-2546 - Transformers for SCAN queries. Fixes #949.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/407071e4
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/407071e4
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/407071e4
Branch: refs/heads/ignite-961
Commit: 407071e466d1a4fcec86571d4791ace8bb206f53
Parents: 0465874
Author: Eduard Shangareev <es...@gridgain.com>
Authored: Mon Aug 29 17:32:31 2016 -0700
Committer: Valentin Kulichenko <va...@gmail.com>
Committed: Mon Aug 29 17:32:31 2016 -0700
----------------------------------------------------------------------
.../java/org/apache/ignite/IgniteCache.java | 15 +
.../processors/cache/IgniteCacheProxy.java | 112 +++-
.../processors/cache/query/CacheQuery.java | 11 +-
.../query/GridCacheDistributedQueryManager.java | 22 +-
.../cache/query/GridCacheLocalQueryManager.java | 3 +-
.../cache/query/GridCacheQueryAdapter.java | 69 ++-
.../cache/query/GridCacheQueryBean.java | 8 +-
.../cache/query/GridCacheQueryInfo.java | 8 +-
.../cache/query/GridCacheQueryManager.java | 125 ++--
.../cache/query/GridCacheQueryRequest.java | 6 +-
.../GridCacheQueryTransformerSelfTest.java | 570 +++++++++++++++++++
.../multijvm/IgniteCacheProcessProxy.java | 6 +
.../IgniteCacheQuerySelfTestSuite.java | 2 +
13 files changed, 832 insertions(+), 125 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/407071e4/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteCache.java b/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
index 40eedaf..2290fc5 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
@@ -56,6 +56,7 @@ import org.apache.ignite.lang.IgniteAsyncSupport;
import org.apache.ignite.lang.IgniteAsyncSupported;
import org.apache.ignite.lang.IgniteBiInClosure;
import org.apache.ignite.lang.IgniteBiPredicate;
+import org.apache.ignite.lang.IgniteClosure;
import org.apache.ignite.lang.IgniteFuture;
import org.apache.ignite.mxbean.CacheMetricsMXBean;
import org.apache.ignite.transactions.TransactionHeuristicException;
@@ -295,6 +296,20 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS
public <R> QueryCursor<R> query(Query<R> qry);
/**
+ * Queries the cache transforming the entries on the server nodes. Can be used, for example,
+ * to avoid network overhead in case only one field out of the large is required by client.
+ * <p>
+ * Currently transformers are supported ONLY for {@link ScanQuery}. Passing any other
+ * subclass of {@link Query} interface to this method will end up with
+ * {@link UnsupportedOperationException}.
+ *
+ * @param qry Query.
+ * @param transformer Transformer.
+ * @return Cursor.
+ */
+ public <T, R> QueryCursor<R> query(Query<T> qry, IgniteClosure<T, R> transformer);
+
+ /**
* Allows for iteration over local cache entries.
*
* @param peekModes Peek modes.
http://git-wip-us.apache.org/repos/asf/ignite/blob/407071e4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
index 0d7bc6a..9b26c1d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
@@ -82,6 +82,7 @@ import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteBiPredicate;
+import org.apache.ignite.lang.IgniteClosure;
import org.apache.ignite.lang.IgniteFuture;
import org.apache.ignite.mxbean.CacheMetricsMXBean;
import org.apache.ignite.plugin.security.SecurityPermission;
@@ -466,50 +467,74 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
}
/**
- * @param filter Filter.
+ * @param scanQry ScanQry.
+ * @param transformer Transformer
* @param grp Optional cluster group.
* @return Cursor.
*/
@SuppressWarnings("unchecked")
- private QueryCursor<Cache.Entry<K, V>> query(final Query filter, @Nullable ClusterGroup grp)
+ private <T, R> QueryCursor<R> query(
+ final ScanQuery scanQry,
+ @Nullable final IgniteClosure<T, R> transformer,
+ @Nullable ClusterGroup grp)
throws IgniteCheckedException {
- final CacheQuery<Map.Entry<K, V>> qry;
+
+ final CacheQuery<R> qry;
boolean isKeepBinary = opCtx != null && opCtx.isKeepBinary();
- if (filter instanceof ScanQuery) {
- IgniteBiPredicate<K, V> p = ((ScanQuery)filter).getFilter();
+ IgniteBiPredicate<K, V> p = scanQry.getFilter();
- qry = ctx.queries().createScanQuery(p, ((ScanQuery)filter).getPartition(), isKeepBinary);
+ qry = ctx.queries().createScanQuery(p, transformer, scanQry.getPartition(), isKeepBinary);
- if (grp != null)
- qry.projection(grp);
+ if (grp != null)
+ qry.projection(grp);
- final GridCloseableIterator<Entry<K, V>> iter = ctx.kernalContext().query().executeQuery(ctx,
- new IgniteOutClosureX<GridCloseableIterator<Entry<K, V>>>() {
- @Override public GridCloseableIterator<Entry<K, V>> applyx() throws IgniteCheckedException {
- final GridCloseableIterator<Map.Entry> iter0 = qry.executeScanQuery();
+ final GridCloseableIterator<R> iter = ctx.kernalContext().query().executeQuery(ctx,
+ new IgniteOutClosureX<GridCloseableIterator<R>>() {
+ @Override public GridCloseableIterator<R> applyx() throws IgniteCheckedException {
+ final GridCloseableIterator iter0 = qry.executeScanQuery();
- return new GridCloseableIteratorAdapter<Cache.Entry<K, V>>() {
- @Override protected Cache.Entry<K, V> onNext() throws IgniteCheckedException {
- Map.Entry<K, V> next = iter0.nextX();
+ final boolean needToConvert = transformer == null;
- return new CacheEntryImpl<>(next.getKey(), next.getValue());
- }
+ return new GridCloseableIteratorAdapter<R>() {
+ @Override protected R onNext() throws IgniteCheckedException {
+ Object next = iter0.nextX();
- @Override protected boolean onHasNext() throws IgniteCheckedException {
- return iter0.hasNextX();
- }
+ if (needToConvert) {
+ Map.Entry<K, V> entry = (Map.Entry<K, V>)next;
- @Override protected void onClose() throws IgniteCheckedException {
- iter0.close();
+ return (R) new CacheEntryImpl<>(entry.getKey(), entry.getValue());
}
- };
- }
- }, false);
- return new QueryCursorImpl<>(iter);
- }
+ return (R)next;
+ }
+
+ @Override protected boolean onHasNext() throws IgniteCheckedException {
+ return iter0.hasNextX();
+ }
+
+ @Override protected void onClose() throws IgniteCheckedException {
+ iter0.close();
+ }
+ };
+ }
+ }, false);
+
+ return new QueryCursorImpl<>(iter);
+ }
+
+ /**
+ * @param filter Filter.
+ * @param grp Optional cluster group.
+ * @return Cursor.
+ */
+ @SuppressWarnings("unchecked")
+ private QueryCursor<Cache.Entry<K, V>> query(final Query filter, @Nullable ClusterGroup grp)
+ throws IgniteCheckedException {
+ final CacheQuery<Map.Entry<K, V>> qry;
+
+ boolean isKeepBinary = opCtx != null && opCtx.isKeepBinary();
final CacheQueryFuture<Map.Entry<K, V>> fut;
@@ -692,6 +717,9 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
return (QueryCursor<R>)ctx.kernalContext().query().queryTwoStep(ctx, p);
}
+ if (qry instanceof ScanQuery)
+ return query((ScanQuery)qry, null, projection(qry.isLocal()));
+
return (QueryCursor<R>)query(qry, projection(qry.isLocal()));
}
catch (Exception e) {
@@ -705,6 +733,36 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
}
}
+ /** {@inheritDoc} */
+ @Override public <T, R> QueryCursor<R> query(Query<T> qry, IgniteClosure<T, R> transformer) {
+ A.notNull(qry, "qry");
+ A.notNull(transformer, "transformer");
+
+ if (!(qry instanceof ScanQuery))
+ throw new UnsupportedOperationException("Transformers are supported only for SCAN queries.");
+
+ GridCacheGateway<K, V> gate = this.gate;
+
+ CacheOperationContext prev = onEnter(gate, opCtx);
+
+ try {
+ ctx.checkSecurity(SecurityPermission.CACHE_READ);
+
+ validate(qry);
+
+ return query((ScanQuery<K, V>)qry, transformer, projection(qry.isLocal()));
+ }
+ catch (Exception e) {
+ if (e instanceof CacheException)
+ throw (CacheException)e;
+
+ throw new CacheException(e);
+ }
+ finally {
+ onLeave(gate, prev);
+ }
+ }
+
/**
* @return {@code true} If this is a replicated cache and we are on a data node.
*/
http://git-wip-us.apache.org/repos/asf/ignite/blob/407071e4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/CacheQuery.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/CacheQuery.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/CacheQuery.java
index 47c6e89..3fa041b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/CacheQuery.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/CacheQuery.java
@@ -273,15 +273,6 @@ public interface CacheQuery<T> {
public <R> CacheQueryFuture<R> execute(IgniteReducer<T, R> rmtReducer, @Nullable Object... args);
/**
- * Executes the query the same way as {@link #execute(Object...)} method but transforms result remotely.
- *
- * @param rmtTransform Remote transformer.
- * @param args Optional arguments.
- * @return Future for the query result.
- */
- public <R> CacheQueryFuture<R> execute(IgniteClosure<T, R> rmtTransform, @Nullable Object... args);
-
- /**
* Gets metrics for this query.
*
* @return Query metrics.
@@ -296,5 +287,5 @@ public interface CacheQuery<T> {
/**
* @return Scan query iterator.
*/
- public <R extends Map.Entry> GridCloseableIterator<R> executeScanQuery() throws IgniteCheckedException;
+ public GridCloseableIterator executeScanQuery() throws IgniteCheckedException;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/407071e4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheDistributedQueryManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheDistributedQueryManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheDistributedQueryManager.java
index 5f6cb8f..d34047e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheDistributedQueryManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheDistributedQueryManager.java
@@ -253,7 +253,7 @@ public class GridCacheDistributedQueryManager<K, V> extends GridCacheQueryManage
*/
@Nullable private GridCacheQueryInfo distributedQueryInfo(UUID sndId, GridCacheQueryRequest req) {
IgniteReducer<Object, Object> rdc = req.reducer();
- IgniteClosure<Object, Object> trans = req.transformer();
+ IgniteClosure<Object, Object> trans = (IgniteClosure<Object, Object>)req.transformer();
ClusterNode sndNode = cctx.node(sndId);
@@ -578,16 +578,16 @@ public class GridCacheDistributedQueryManager<K, V> extends GridCacheQueryManage
/** {@inheritDoc} */
@SuppressWarnings({"unchecked", "serial"})
- @Override public GridCloseableIterator<Map.Entry<K, V>> scanQueryDistributed(final GridCacheQueryAdapter qry,
+ @Override public GridCloseableIterator scanQueryDistributed(final GridCacheQueryAdapter qry,
Collection<ClusterNode> nodes) throws IgniteCheckedException {
assert !cctx.isLocal() : cctx.name();
assert qry.type() == GridCacheQueryType.SCAN: qry;
- GridCloseableIterator<Map.Entry<K, V>> locIter0 = null;
+ GridCloseableIterator locIter0 = null;
for (ClusterNode node : nodes) {
if (node.isLocal()) {
- locIter0 = (GridCloseableIterator)scanQueryLocal(qry, false);
+ locIter0 = scanQueryLocal(qry, false);
Collection<ClusterNode> rmtNodes = new ArrayList<>(nodes.size() - 1);
@@ -603,21 +603,21 @@ public class GridCacheDistributedQueryManager<K, V> extends GridCacheQueryManage
}
}
- final GridCloseableIterator<Map.Entry<K, V>> locIter = locIter0;
+ final GridCloseableIterator locIter = locIter0;
- final GridCacheQueryBean bean = new GridCacheQueryBean(qry, null, null, null);
+ final GridCacheQueryBean bean = new GridCacheQueryBean(qry, null, qry.<K, V>transform(), null);
- final CacheQueryFuture<Map.Entry<K, V>> fut = (CacheQueryFuture<Map.Entry<K, V>>)queryDistributed(bean, nodes);
+ final CacheQueryFuture fut = (CacheQueryFuture)queryDistributed(bean, nodes);
- return new GridCloseableIteratorAdapter<Map.Entry<K, V>>() {
+ return new GridCloseableIteratorAdapter() {
/** */
- private Map.Entry<K, V> cur;
+ private Object cur;
- @Override protected Map.Entry<K, V> onNext() throws IgniteCheckedException {
+ @Override protected Object onNext() throws IgniteCheckedException {
if (!onHasNext())
throw new NoSuchElementException();
- Map.Entry<K, V> e = cur;
+ Object e = cur;
cur = null;
http://git-wip-us.apache.org/repos/asf/ignite/blob/407071e4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheLocalQueryManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheLocalQueryManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheLocalQueryManager.java
index 183abde..147725b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheLocalQueryManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheLocalQueryManager.java
@@ -19,7 +19,6 @@ package org.apache.ignite.internal.processors.cache.query;
import java.util.Collection;
import java.util.List;
-import java.util.Map;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
import org.apache.ignite.cluster.ClusterNode;
@@ -90,7 +89,7 @@ public class GridCacheLocalQueryManager<K, V> extends GridCacheQueryManager<K, V
}
/** {@inheritDoc} */
- @Override public GridCloseableIterator<Map.Entry<K, V>> scanQueryDistributed(GridCacheQueryAdapter qry,
+ @Override public GridCloseableIterator scanQueryDistributed(GridCacheQueryAdapter qry,
Collection<ClusterNode> nodes) throws IgniteCheckedException {
assert cctx.isLocal() : cctx.name();
http://git-wip-us.apache.org/repos/asf/ignite/blob/407071e4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryAdapter.java
index 90e14f4..f65b733 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryAdapter.java
@@ -87,6 +87,9 @@ public class GridCacheQueryAdapter<T> implements CacheQuery<T> {
/** */
private final IgniteBiPredicate<Object, Object> filter;
+ /** Transformer. */
+ private IgniteClosure<?, ?> transform;
+
/** Partition. */
private Integer part;
@@ -126,6 +129,39 @@ public class GridCacheQueryAdapter<T> implements CacheQuery<T> {
/**
* @param cctx Context.
* @param type Query type.
+ * @param filter Scan filter.
+ * @param part Partition.
+ * @param keepBinary Keep binary flag.
+ */
+ public GridCacheQueryAdapter(GridCacheContext<?, ?> cctx,
+ GridCacheQueryType type,
+ @Nullable IgniteBiPredicate<Object, Object> filter,
+ @Nullable IgniteClosure<Map.Entry, Object> transform,
+ @Nullable Integer part,
+ boolean keepBinary) {
+ assert cctx != null;
+ assert type != null;
+ assert part == null || part >= 0;
+
+ this.cctx = cctx;
+ this.type = type;
+ this.filter = filter;
+ this.transform = transform;
+ this.part = part;
+ this.keepBinary = keepBinary;
+
+ log = cctx.logger(getClass());
+
+ metrics = new GridCacheQueryMetricsAdapter();
+
+ this.incMeta = false;
+ this.clsName = null;
+ this.clause = null;
+ }
+
+ /**
+ * @param cctx Context.
+ * @param type Query type.
* @param clsName Class name.
* @param clause Clause.
* @param filter Scan filter.
@@ -376,6 +412,14 @@ public class GridCacheQueryAdapter<T> implements CacheQuery<T> {
}
/**
+ * @return Transformer.
+ */
+ @SuppressWarnings("unchecked")
+ @Nullable public <K, V> IgniteClosure<Map.Entry<K, V>, Object> transform() {
+ return (IgniteClosure<Map.Entry<K, V>, Object>) transform;
+ }
+
+ /**
* @return Partition.
*/
@Nullable public Integer partition() {
@@ -402,17 +446,12 @@ public class GridCacheQueryAdapter<T> implements CacheQuery<T> {
/** {@inheritDoc} */
@Override public CacheQueryFuture<T> execute(@Nullable Object... args) {
- return execute(null, null, args);
+ return execute0(null, args);
}
/** {@inheritDoc} */
@Override public <R> CacheQueryFuture<R> execute(IgniteReducer<T, R> rmtReducer, @Nullable Object... args) {
- return execute(rmtReducer, null, args);
- }
-
- /** {@inheritDoc} */
- @Override public <R> CacheQueryFuture<R> execute(IgniteClosure<T, R> rmtTransform, @Nullable Object... args) {
- return execute(null, rmtTransform, args);
+ return execute0(rmtReducer, args);
}
/** {@inheritDoc} */
@@ -427,13 +466,11 @@ public class GridCacheQueryAdapter<T> implements CacheQuery<T> {
/**
* @param rmtReducer Optional reducer.
- * @param rmtTransform Optional transformer.
* @param args Arguments.
* @return Future.
*/
@SuppressWarnings({"IfMayBeConditional", "unchecked"})
- private <R> CacheQueryFuture<R> execute(@Nullable IgniteReducer<T, R> rmtReducer,
- @Nullable IgniteClosure<T, R> rmtTransform, @Nullable Object... args) {
+ private <R> CacheQueryFuture<R> execute0(@Nullable IgniteReducer<T, R> rmtReducer, @Nullable Object... args) {
assert type != SCAN : this;
Collection<ClusterNode> nodes;
@@ -455,7 +492,7 @@ public class GridCacheQueryAdapter<T> implements CacheQuery<T> {
if (cctx.deploymentEnabled()) {
try {
- cctx.deploy().registerClasses(filter, rmtReducer, rmtTransform);
+ cctx.deploy().registerClasses(filter, rmtReducer);
cctx.deploy().registerClasses(args);
}
catch (IgniteCheckedException e) {
@@ -469,7 +506,7 @@ public class GridCacheQueryAdapter<T> implements CacheQuery<T> {
taskHash = cctx.kernalContext().job().currentTaskNameHash();
final GridCacheQueryBean bean = new GridCacheQueryBean(this, (IgniteReducer<Object, Object>)rmtReducer,
- (IgniteClosure<Object, Object>)rmtTransform, args);
+ null, args);
final GridCacheQueryManager qryMgr = cctx.queries();
@@ -484,8 +521,8 @@ public class GridCacheQueryAdapter<T> implements CacheQuery<T> {
/** {@inheritDoc} */
@SuppressWarnings({"IfMayBeConditional", "unchecked"})
- @Override public <R extends Map.Entry> GridCloseableIterator<R> executeScanQuery() throws IgniteCheckedException {
- assert type == SCAN: "Wrong processing of qyery: " + type;
+ @Override public GridCloseableIterator executeScanQuery() throws IgniteCheckedException {
+ assert type == SCAN : "Wrong processing of qyery: " + type;
Collection<ClusterNode> nodes = nodes();
@@ -508,7 +545,7 @@ public class GridCacheQueryAdapter<T> implements CacheQuery<T> {
final GridCacheQueryManager qryMgr = cctx.queries();
if (part != null && !cctx.isLocal())
- return (GridCloseableIterator<R>)new ScanQueryFallbackClosableIterator(part, this, qryMgr, cctx);
+ return new ScanQueryFallbackClosableIterator(part, this, qryMgr, cctx);
else {
boolean loc = nodes.size() == 1 && F.first(nodes).id().equals(cctx.localNodeId());
@@ -676,7 +713,7 @@ public class GridCacheQueryAdapter<T> implements CacheQuery<T> {
try {
GridCloseableIterator it = qryMgr.scanQueryLocal(qry, true);
- tuple= new T2(it, null);
+ tuple = new T2(it, null);
}
catch (IgniteClientDisconnectedCheckedException e) {
throw CU.convertToCacheException(e);
http://git-wip-us.apache.org/repos/asf/ignite/blob/407071e4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryBean.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryBean.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryBean.java
index 5a4d693..286ddc2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryBean.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryBean.java
@@ -33,7 +33,7 @@ public class GridCacheQueryBean {
private final IgniteReducer<Object, Object> rdc;
/** */
- private final IgniteClosure<Object, Object> trans;
+ private final IgniteClosure<?, ?> trans;
/** */
private final Object[] args;
@@ -45,7 +45,7 @@ public class GridCacheQueryBean {
* @param args Optional arguments.
*/
public GridCacheQueryBean(GridCacheQueryAdapter<?> qry, @Nullable IgniteReducer<Object, Object> rdc,
- @Nullable IgniteClosure<Object, Object> trans, @Nullable Object[] args) {
+ @Nullable IgniteClosure<?, ?> trans, @Nullable Object[] args) {
assert qry != null;
this.qry = qry;
@@ -71,7 +71,7 @@ public class GridCacheQueryBean {
/**
* @return Transformer.
*/
- @Nullable public IgniteClosure<Object, Object> transform() {
+ @Nullable public IgniteClosure<?, ?> transform() {
return trans;
@@ -88,4 +88,4 @@ public class GridCacheQueryBean {
@Override public String toString() {
return S.toString(GridCacheQueryBean.class, this);
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/407071e4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryInfo.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryInfo.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryInfo.java
index 8d2e67d..0a108d5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryInfo.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryInfo.java
@@ -31,7 +31,7 @@ class GridCacheQueryInfo {
private boolean loc;
/** */
- private IgniteClosure<Object, Object> trans;
+ private IgniteClosure<?, ?> trans;
/** */
private IgniteReducer<Object, Object> rdc;
@@ -71,7 +71,7 @@ class GridCacheQueryInfo {
*/
GridCacheQueryInfo(
boolean loc,
- IgniteClosure<Object, Object> trans,
+ IgniteClosure<?, ?> trans,
IgniteReducer<Object, Object> rdc,
GridCacheQueryAdapter<?> qry,
GridCacheLocalQueryFuture<?, ?, ?> locFut,
@@ -117,7 +117,7 @@ class GridCacheQueryInfo {
/**
* @return Transformer.
*/
- IgniteClosure<?, Object> transformer() {
+ IgniteClosure<?, ?> transformer() {
return trans;
}
@@ -167,4 +167,4 @@ class GridCacheQueryInfo {
@Override public String toString() {
return S.toString(GridCacheQueryInfo.class, this);
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/407071e4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
index 163bac5..454ce04 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
@@ -506,7 +506,7 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
* @return Iterator.
* @throws IgniteCheckedException If failed.
*/
- public abstract GridCloseableIterator<Map.Entry<K, V>> scanQueryDistributed(GridCacheQueryAdapter qry,
+ public abstract GridCloseableIterator scanQueryDistributed(GridCacheQueryAdapter qry,
Collection<ClusterNode> nodes) throws IgniteCheckedException;
/**
@@ -1067,13 +1067,13 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
final GridDhtLocalPartition locPart0 = locPart;
return new PeekValueExpiryAwareIterator(keyIter, plc, topVer, keyValFilter, qry.keepBinary(), locNode, true) {
- @Override protected void onClose() {
- super.onClose();
+ @Override protected void onClose() {
+ super.onClose();
- if (locPart0 != null)
- locPart0.release();
- }
- };
+ if (locPart0 != null)
+ locPart0.release();
+ }
+ };
}
/**
@@ -1163,9 +1163,8 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
key = (K)cctx.unwrapBinaryIfNeeded(key, keepBinary);
- if (filter != null || locNode) {
+ if (filter != null || locNode)
val = (V)cctx.unwrapBinaryIfNeeded(val, keepBinary);
- }
if (filter != null && !filter.apply(key, val))
continue;
@@ -1187,14 +1186,14 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
* @param locNode Local node.
* @return Final key-value iterator.
*/
- private GridIterator<IgniteBiTuple<K,V>> scanExpiryIterator(
+ private GridIterator<IgniteBiTuple<K, V>> scanExpiryIterator(
final Iterator<Map.Entry<byte[], byte[]>> it,
AffinityTopologyVersion topVer,
@Nullable final IgniteBiPredicate<K, V> filter,
ExpiryPolicy expPlc,
final boolean keepBinary,
boolean locNode) {
- Iterator <K> keyIter = new Iterator<K>() {
+ Iterator<K> keyIter = new Iterator<K>() {
/** {@inheritDoc} */
@Override public boolean hasNext() {
return it.hasNext();
@@ -1267,10 +1266,8 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
try {
// Preparing query closures.
- IgniteClosure<Object, Object> trans = (IgniteClosure<Object, Object>)qryInfo.transformer();
IgniteReducer<Object, Object> rdc = (IgniteReducer<Object, Object>)qryInfo.reducer();
- injectResources(trans);
injectResources(rdc);
GridCacheQueryAdapter<?> qry = qryInfo.query();
@@ -1289,7 +1286,7 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
res = qryInfo.local() ?
executeFieldsQuery(qry, qryInfo.arguments(), qryInfo.local(), qry.subjectId(), taskName,
- recipient(qryInfo.senderId(), qryInfo.requestId())) :
+ recipient(qryInfo.senderId(), qryInfo.requestId())) :
fieldsQueryResult(qryInfo, taskName);
// If metadata needs to be returned to user and cleaned from internal fields - copy it.
@@ -1460,10 +1457,10 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
try {
// Preparing query closures.
- IgniteClosure<Map.Entry<K, V>, Object> trans =
- (IgniteClosure<Map.Entry<K, V>, Object>)qryInfo.transformer();
+ IgniteClosure<Cache.Entry<K, V>, Object> trans =
+ (IgniteClosure<Cache.Entry<K, V>, Object>)qryInfo.transformer();
- IgniteReducer<Map.Entry<K, V>, Object> rdc = (IgniteReducer<Map.Entry<K, V>, Object>)qryInfo.reducer();
+ IgniteReducer<Cache.Entry<K, V>, Object> rdc = (IgniteReducer<Cache.Entry<K, V>, Object>)qryInfo.reducer();
injectResources(trans);
injectResources(rdc);
@@ -1481,13 +1478,13 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
res = loc ?
executeQuery(qry, qryInfo.arguments(), loc, qry.subjectId(), taskName,
- recipient(qryInfo.senderId(), qryInfo.requestId())) :
+ recipient(qryInfo.senderId(), qryInfo.requestId())) :
queryResult(qryInfo, taskName);
iter = res.iterator(recipient(qryInfo.senderId(), qryInfo.requestId()));
type = res.type();
- GridCacheAdapter<K, V> cache = cctx.cache();
+ final GridCacheAdapter<K, V> cache = cctx.cache();
if (log.isDebugEnabled())
log.debug("Received index iterator [iterHasNext=" + iter.hasNext() +
@@ -1518,7 +1515,7 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
break;
}
- K key = row.getKey();
+ final K key = row.getKey();
// Filter backups for SCAN queries, if it isn't partition scan.
// Other types are filtered in indexing manager.
@@ -1561,8 +1558,8 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
}
if (readEvt) {
- K key0 = (K)cctx.unwrapBinaryIfNeeded(key, qry.keepBinary());
- V val0 = (V)cctx.unwrapBinaryIfNeeded(val, qry.keepBinary());
+ K key0 = (K)cctx.unwrapBinaryIfNeeded(key, qry.keepBinary());
+ V val0 = (V)cctx.unwrapBinaryIfNeeded(val, qry.keepBinary());
switch (type) {
case SQL:
@@ -1630,27 +1627,33 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
}
}
- Map.Entry<K, V> entry = F.t(key, val);
+ if (rdc != null || trans != null) {
+ Cache.Entry<K, V> entry;
- // Unwrap entry for reducer or transformer only.
- if (rdc != null || trans != null)
- entry = (Map.Entry<K, V>)cctx.unwrapBinaryIfNeeded(entry, qry.keepBinary());
+ if (qry.keepBinary())
+ entry = cache.<K, V>keepBinary().getEntry(key);
+ else
+ entry = cache.<K, V>getEntry(key);
- // Reduce.
- if (rdc != null) {
- if (!rdc.collect(entry) || !iter.hasNext()) {
- onPageReady(loc, qryInfo, Collections.singletonList(rdc.reduce()), true, null);
+ // Reduce.
+ if (rdc != null) {
+ if (!rdc.collect(entry) || !iter.hasNext()) {
+ onPageReady(loc, qryInfo, Collections.singletonList(rdc.reduce()), true, null);
- pageSent = true;
+ pageSent = true;
- break;
+ break;
+ }
+ else
+ continue;
}
- else
- continue;
+
+ data.add(trans != null ? trans.apply(entry) :
+ !loc ? new GridCacheQueryResponseEntry<>(key, val) : F.t(key, val));
}
+ else
+ data.add(!loc ? new GridCacheQueryResponseEntry<>(key, val) : F.t(key, val));
- data.add(trans != null ? trans.apply(entry) :
- !loc ? new GridCacheQueryResponseEntry<>(key, val) : F.t(key, val));
if (!loc) {
if (++cnt == pageSize || !iter.hasNext()) {
@@ -1720,7 +1723,7 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
* @param updStatisticsIfNeeded Update statistics flag.
*/
@SuppressWarnings({"unchecked", "serial"})
- protected GridCloseableIterator<IgniteBiTuple<K, V>> scanQueryLocal(final GridCacheQueryAdapter qry,
+ protected GridCloseableIterator scanQueryLocal(final GridCacheQueryAdapter qry,
final boolean updStatisticsIfNeeded) throws IgniteCheckedException {
if (!enterBusy())
throw new IllegalStateException("Failed to process query request (grid is stopping).");
@@ -1769,8 +1772,8 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
final boolean readEvt = cctx.gridEvents().isRecordable(EVT_CACHE_QUERY_OBJECT_READ);
- return new GridCloseableIteratorAdapter<IgniteBiTuple<K, V>>() {
- @Override protected IgniteBiTuple<K, V> onNext() throws IgniteCheckedException {
+ return new GridCloseableIteratorAdapter<Object>() {
+ @Override protected Object onNext() throws IgniteCheckedException {
long start = statsEnabled ? System.nanoTime() : 0L;
IgniteBiTuple<K, V> next = iter.nextX();
@@ -1803,7 +1806,20 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
null));
}
- return next;
+ IgniteClosure transform = qry.transform();
+
+ if (transform == null)
+ return next;
+
+ Cache.Entry<K, V> entry;
+
+ if (qry.keepBinary())
+ entry = cctx.cache().keepBinary().getEntry(next.getKey());
+ else
+ entry = cctx.cache().getEntry(next.getKey());
+
+
+ return transform.apply(entry);
}
@Override protected boolean onHasNext() throws IgniteCheckedException {
@@ -1832,7 +1848,8 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
* @return Iterator.
* @throws IgniteCheckedException In case of error.
*/
- private QueryResult<K, V> queryResult(final GridCacheQueryInfo qryInfo, String taskName) throws IgniteCheckedException {
+ private QueryResult<K, V> queryResult(final GridCacheQueryInfo qryInfo,
+ String taskName) throws IgniteCheckedException {
assert qryInfo != null;
final UUID sndId = qryInfo.senderId();
@@ -2845,7 +2862,7 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
if (locNode)
return new IgniteBiTuple<>(key, val);
- else{
+ else {
if (key instanceof CacheObject)
((CacheObject)key).prepareMarshal(cctx.cacheObjectContext());
@@ -3256,16 +3273,28 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
* @param keepBinary Keep binary flag.
* @return Created query.
*/
- public CacheQuery<Map.Entry<K, V>> createScanQuery(@Nullable IgniteBiPredicate<K, V> filter,
+ public <R> CacheQuery<R> createScanQuery(@Nullable IgniteBiPredicate<K, V> filter,
@Nullable Integer part, boolean keepBinary) {
+ return createScanQuery(filter, null, part, keepBinary);
+ }
- return new GridCacheQueryAdapter<>(cctx,
+ /**
+ * Creates user's predicate based scan query.
+ *
+ * @param filter Scan filter.
+ * @param part Partition.
+ * @param keepBinary Keep binary flag.
+ * @return Created query.
+ */
+ public <T, R> CacheQuery<R> createScanQuery(@Nullable IgniteBiPredicate<K, V> filter,
+ @Nullable IgniteClosure<T, R> trans,
+ @Nullable Integer part, boolean keepBinary) {
+
+ return new GridCacheQueryAdapter(cctx,
SCAN,
- null,
- null,
- (IgniteBiPredicate<Object, Object>)filter,
+ filter,
+ trans,
part,
- false,
keepBinary);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/407071e4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java
index f50fba0..5610bef 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryRequest.java
@@ -84,7 +84,7 @@ public class GridCacheQueryRequest extends GridCacheMessage implements GridCache
/** */
@GridDirectTransient
- private IgniteClosure<Object, Object> trans;
+ private IgniteClosure<?, ?> trans;
/** */
private byte[] transBytes;
@@ -233,7 +233,7 @@ public class GridCacheQueryRequest extends GridCacheMessage implements GridCache
IgniteBiPredicate<Object, Object> keyValFilter,
@Nullable Integer part,
IgniteReducer<Object, Object> rdc,
- IgniteClosure<Object, Object> trans,
+ IgniteClosure<?, ?> trans,
int pageSize,
boolean incBackups,
Object[] args,
@@ -422,7 +422,7 @@ public class GridCacheQueryRequest extends GridCacheMessage implements GridCache
/**
* @return Transformer.
*/
- public IgniteClosure<Object, Object> transformer() {
+ public IgniteClosure<?, ?> transformer() {
return trans;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/407071e4/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryTransformerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryTransformerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryTransformerSelfTest.java
new file mode 100644
index 0000000..6b13e05
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryTransformerSelfTest.java
@@ -0,0 +1,570 @@
+/*
+ * 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.query;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.Callable;
+import javax.cache.Cache;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.cache.query.ContinuousQuery;
+import org.apache.ignite.cache.query.ScanQuery;
+import org.apache.ignite.cache.query.SpiQuery;
+import org.apache.ignite.cache.query.SqlFieldsQuery;
+import org.apache.ignite.cache.query.SqlQuery;
+import org.apache.ignite.cache.query.TextQuery;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.lang.IgniteBiPredicate;
+import org.apache.ignite.lang.IgniteCallable;
+import org.apache.ignite.lang.IgniteClosure;
+import org.apache.ignite.resources.IgniteInstanceResource;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/**
+ * Test for scan query with transformer.
+ */
+public class GridCacheQueryTransformerSelfTest extends GridCommonAbstractTest {
+ /** */
+ private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(IP_FINDER));
+ cfg.setMarshaller(null);
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTestsStarted() throws Exception {
+ startGridsMultiThreaded(3);
+
+ Ignition.setClientMode(true);
+
+ startGrid();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ stopAllGrids();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testGetKeys() throws Exception {
+ IgniteCache<Integer, String> cache = grid().createCache("test-cache");
+
+ try {
+ for (int i = 0; i < 50; i++)
+ cache.put(i, "val" + i);
+
+ IgniteClosure<Cache.Entry<Integer, String>, Integer> transformer =
+ new IgniteClosure<Cache.Entry<Integer, String>, Integer>() {
+ @Override public Integer apply(Cache.Entry<Integer, String> e) {
+ return e.getKey();
+ }
+ };
+
+ List<Integer> keys = cache.query(new ScanQuery<Integer, String>(), transformer).getAll();
+
+ assertEquals(50, keys.size());
+
+ Collections.sort(keys);
+
+ for (int i = 0; i < 50; i++)
+ assertEquals(i, keys.get(i).intValue());
+ }
+ finally {
+ cache.destroy();
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testGetKeysFiltered() throws Exception {
+ IgniteCache<Integer, String> cache = grid().createCache("test-cache");
+
+ try {
+ for (int i = 0; i < 50; i++)
+ cache.put(i, "val" + i);
+
+ IgniteBiPredicate<Integer, String> filter = new IgniteBiPredicate<Integer, String>() {
+ @Override public boolean apply(Integer k, String v) {
+ return k % 10 == 0;
+ }
+ };
+
+ IgniteClosure<Cache.Entry<Integer, String>, Integer> transformer =
+ new IgniteClosure<Cache.Entry<Integer, String>, Integer>() {
+ @Override public Integer apply(Cache.Entry<Integer, String> e) {
+ return e.getKey();
+ }
+ };
+
+ List<Integer> keys = cache.query(new ScanQuery<>(filter), transformer).getAll();
+
+ assertEquals(5, keys.size());
+
+ Collections.sort(keys);
+
+ for (int i = 0; i < 5; i++)
+ assertEquals(i * 10, keys.get(i).intValue());
+ }
+ finally {
+ cache.destroy();
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testGetObjectField() throws Exception {
+ IgniteCache<Integer, Value> cache = grid().createCache("test-cache");
+
+ try {
+ for (int i = 0; i < 50; i++)
+ cache.put(i, new Value("str" + i, i * 100));
+
+ IgniteClosure<Cache.Entry<Integer, Value>, Integer> transformer =
+ new IgniteClosure<Cache.Entry<Integer, Value>, Integer>() {
+ @Override public Integer apply(Cache.Entry<Integer, Value> e) {
+ return e.getValue().idx;
+ }
+ };
+
+ List<Integer> res = cache.query(new ScanQuery<Integer, Value>(), transformer).getAll();
+
+ assertEquals(50, res.size());
+
+ Collections.sort(res);
+
+ for (int i = 0; i < 50; i++)
+ assertEquals(i * 100, res.get(i).intValue());
+ }
+ finally {
+ cache.destroy();
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testGetObjectFieldFiltered() throws Exception {
+ IgniteCache<Integer, Value> cache = grid().createCache("test-cache");
+
+ try {
+ for (int i = 0; i < 50; i++)
+ cache.put(i, new Value("str" + i, i * 100));
+
+ IgniteBiPredicate<Integer, Value> filter = new IgniteBiPredicate<Integer, Value>() {
+ @Override public boolean apply(Integer k, Value v) {
+ return v.idx % 1000 == 0;
+ }
+ };
+
+ IgniteClosure<Cache.Entry<Integer, Value>, Integer> transformer =
+ new IgniteClosure<Cache.Entry<Integer, Value>, Integer>() {
+ @Override public Integer apply(Cache.Entry<Integer, Value> e) {
+ return e.getValue().idx;
+ }
+ };
+
+ List<Integer> res = cache.query(new ScanQuery<>(filter), transformer).getAll();
+
+ assertEquals(5, res.size());
+
+ Collections.sort(res);
+
+ for (int i = 0; i < 5; i++)
+ assertEquals(i * 1000, res.get(i).intValue());
+ }
+ finally {
+ cache.destroy();
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testKeepBinary() throws Exception {
+ IgniteCache<Integer, Value> cache = grid().createCache("test-cache");
+
+ try {
+ for (int i = 0; i < 50; i++)
+ cache.put(i, new Value("str" + i, i * 100));
+
+ IgniteCache<Integer, BinaryObject> binaryCache = cache.withKeepBinary();
+
+ IgniteClosure<Cache.Entry<Integer, BinaryObject>, Integer> transformer =
+ new IgniteClosure<Cache.Entry<Integer, BinaryObject>, Integer>() {
+ @Override public Integer apply(Cache.Entry<Integer, BinaryObject> e) {
+ return e.getValue().field("idx");
+ }
+ };
+
+ List<Integer> res = binaryCache.query(new ScanQuery<Integer, BinaryObject>(), transformer).getAll();
+
+ assertEquals(50, res.size());
+
+ Collections.sort(res);
+
+ for (int i = 0; i < 50; i++)
+ assertEquals(i * 100, res.get(i).intValue());
+ }
+ finally {
+ cache.destroy();
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testKeepBinaryFiltered() throws Exception {
+ IgniteCache<Integer, Value> cache = grid().createCache("test-cache");
+
+ try {
+ for (int i = 0; i < 50; i++)
+ cache.put(i, new Value("str" + i, i * 100));
+
+ IgniteCache<Integer, BinaryObject> binaryCache = cache.withKeepBinary();
+
+ IgniteBiPredicate<Integer, BinaryObject> filter = new IgniteBiPredicate<Integer, BinaryObject>() {
+ @Override public boolean apply(Integer k, BinaryObject v) {
+ return v.<Integer>field("idx") % 1000 == 0;
+ }
+ };
+
+ IgniteClosure<Cache.Entry<Integer, BinaryObject>, Integer> transformer =
+ new IgniteClosure<Cache.Entry<Integer, BinaryObject>, Integer>() {
+ @Override public Integer apply(Cache.Entry<Integer, BinaryObject> e) {
+ return e.getValue().field("idx");
+ }
+ };
+
+ List<Integer> res = binaryCache.query(new ScanQuery<>(filter), transformer).getAll();
+
+ assertEquals(5, res.size());
+
+ Collections.sort(res);
+
+ for (int i = 0; i < 5; i++)
+ assertEquals(i * 1000, res.get(i).intValue());
+ }
+ finally {
+ cache.destroy();
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testLocal() throws Exception {
+ IgniteCache<Integer, Value> cache = grid().createCache("test-cache");
+
+ try {
+ for (int i = 0; i < 50; i++)
+ cache.put(i, new Value("str" + i, i * 100));
+
+ Collection<List<Integer>> lists = grid().compute().broadcast(new IgniteCallable<List<Integer>>() {
+ @IgniteInstanceResource
+ private Ignite ignite;
+
+ @Override public List<Integer> call() throws Exception {
+ IgniteClosure<Cache.Entry<Integer, Value>, Integer> transformer =
+ new IgniteClosure<Cache.Entry<Integer, Value>, Integer>() {
+ @Override public Integer apply(Cache.Entry<Integer, Value> e) {
+ return e.getValue().idx;
+ }
+ };
+
+ return ignite.cache("test-cache").query(new ScanQuery<Integer, Value>().setLocal(true),
+ transformer).getAll();
+ }
+ });
+
+ List<Integer> res = new ArrayList<>(F.flatCollections(lists));
+
+ assertEquals(50, res.size());
+
+ Collections.sort(res);
+
+ for (int i = 0; i < 50; i++)
+ assertEquals(i * 100, res.get(i).intValue());
+ }
+ finally {
+ cache.destroy();
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testLocalFiltered() throws Exception {
+ IgniteCache<Integer, Value> cache = grid().createCache("test-cache");
+
+ try {
+ for (int i = 0; i < 50; i++)
+ cache.put(i, new Value("str" + i, i * 100));
+
+ Collection<List<Integer>> lists = grid().compute().broadcast(new IgniteCallable<List<Integer>>() {
+ @IgniteInstanceResource
+ private Ignite ignite;
+
+ @Override public List<Integer> call() throws Exception {
+ IgniteBiPredicate<Integer, Value> filter = new IgniteBiPredicate<Integer, Value>() {
+ @Override public boolean apply(Integer k, Value v) {
+ return v.idx % 1000 == 0;
+ }
+ };
+
+ IgniteClosure<Cache.Entry<Integer, Value>, Integer> transformer =
+ new IgniteClosure<Cache.Entry<Integer, Value>, Integer>() {
+ @Override public Integer apply(Cache.Entry<Integer, Value> e) {
+ return e.getValue().idx;
+ }
+ };
+
+ return ignite.cache("test-cache").query(new ScanQuery<>(filter).setLocal(true),
+ transformer).getAll();
+ }
+ });
+
+ List<Integer> res = new ArrayList<>(F.flatCollections(lists));
+
+ assertEquals(5, res.size());
+
+ Collections.sort(res);
+
+ for (int i = 0; i < 5; i++)
+ assertEquals(i * 1000, res.get(i).intValue());
+ }
+ finally {
+ cache.destroy();
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testLocalKeepBinary() throws Exception {
+ IgniteCache<Integer, Value> cache = grid().createCache("test-cache");
+
+ try {
+ for (int i = 0; i < 50; i++)
+ cache.put(i, new Value("str" + i, i * 100));
+
+ Collection<List<Integer>> lists = grid().compute().broadcast(new IgniteCallable<List<Integer>>() {
+ @IgniteInstanceResource
+ private Ignite ignite;
+
+ @Override public List<Integer> call() throws Exception {
+ IgniteClosure<Cache.Entry<Integer, BinaryObject>, Integer> transformer =
+ new IgniteClosure<Cache.Entry<Integer, BinaryObject>, Integer>() {
+ @Override public Integer apply(Cache.Entry<Integer, BinaryObject> e) {
+ return e.getValue().field("idx");
+ }
+ };
+
+ return ignite.cache("test-cache").withKeepBinary().query(
+ new ScanQuery<Integer, BinaryObject>().setLocal(true), transformer).getAll();
+ }
+ });
+
+ List<Integer> res = new ArrayList<>(F.flatCollections(lists));
+
+ assertEquals(50, res.size());
+
+ Collections.sort(res);
+
+ for (int i = 0; i < 50; i++)
+ assertEquals(i * 100, res.get(i).intValue());
+ }
+ finally {
+ cache.destroy();
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testLocalKeepBinaryFiltered() throws Exception {
+ IgniteCache<Integer, Value> cache = grid().createCache("test-cache");
+
+ try {
+ for (int i = 0; i < 50; i++)
+ cache.put(i, new Value("str" + i, i * 100));
+
+ Collection<List<Integer>> lists = grid().compute().broadcast(new IgniteCallable<List<Integer>>() {
+ @IgniteInstanceResource
+ private Ignite ignite;
+
+ @Override public List<Integer> call() throws Exception {
+ IgniteBiPredicate<Integer, BinaryObject> filter = new IgniteBiPredicate<Integer, BinaryObject>() {
+ @Override public boolean apply(Integer k, BinaryObject v) {
+ return v.<Integer>field("idx") % 1000 == 0;
+ }
+ };
+
+ IgniteClosure<Cache.Entry<Integer, BinaryObject>, Integer> transformer =
+ new IgniteClosure<Cache.Entry<Integer, BinaryObject>, Integer>() {
+ @Override public Integer apply(Cache.Entry<Integer, BinaryObject> e) {
+ return e.getValue().field("idx");
+ }
+ };
+
+ return ignite.cache("test-cache").withKeepBinary().query(new ScanQuery<>(filter).setLocal(true),
+ transformer).getAll();
+ }
+ });
+
+ List<Integer> res = new ArrayList<>(F.flatCollections(lists));
+
+ assertEquals(5, res.size());
+
+ Collections.sort(res);
+
+ for (int i = 0; i < 5; i++)
+ assertEquals(i * 1000, res.get(i).intValue());
+ }
+ finally {
+ cache.destroy();
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testUnsupported() throws Exception {
+ final IgniteCache<Integer, Integer> cache = grid().createCache("test-cache");
+
+ final IgniteClosure<Cache.Entry<Integer, Integer>, Integer> transformer =
+ new IgniteClosure<Cache.Entry<Integer, Integer>, Integer>() {
+ @Override public Integer apply(Cache.Entry<Integer, Integer> e) {
+ return null;
+ }
+ };
+
+ try {
+ GridTestUtils.assertThrows(
+ log,
+ new Callable<Object>() {
+ @Override public Object call() throws Exception {
+ cache.query(new SqlQuery<Integer, Integer>(Integer.class, "clause"), transformer);
+
+ return null;
+ }
+ },
+ UnsupportedOperationException.class,
+ "Transformers are supported only for SCAN queries."
+ );
+
+ GridTestUtils.assertThrows(
+ log,
+ new Callable<Object>() {
+ @Override public Object call() throws Exception {
+ cache.query(new SqlFieldsQuery("clause"), new IgniteClosure<List<?>, Object>() {
+ @Override public Object apply(List<?> objects) {
+ return null;
+ }
+ });
+
+ return null;
+ }
+ },
+ UnsupportedOperationException.class,
+ "Transformers are supported only for SCAN queries."
+ );
+
+ GridTestUtils.assertThrows(
+ log,
+ new Callable<Object>() {
+ @Override public Object call() throws Exception {
+ cache.query(new TextQuery<Integer, Integer>(Integer.class, "clause"), transformer);
+
+ return null;
+ }
+ },
+ UnsupportedOperationException.class,
+ "Transformers are supported only for SCAN queries."
+ );
+
+ GridTestUtils.assertThrows(
+ log,
+ new Callable<Object>() {
+ @Override public Object call() throws Exception {
+ cache.query(new SpiQuery<Integer, Integer>(), transformer);
+
+ return null;
+ }
+ },
+ UnsupportedOperationException.class,
+ "Transformers are supported only for SCAN queries."
+ );
+
+ GridTestUtils.assertThrows(
+ log,
+ new Callable<Object>() {
+ @Override public Object call() throws Exception {
+ cache.query(new ContinuousQuery<Integer, Integer>(), transformer);
+
+ return null;
+ }
+ },
+ UnsupportedOperationException.class,
+ "Transformers are supported only for SCAN queries."
+ );
+ }
+ finally {
+ cache.destroy();
+ }
+ }
+
+ /**
+ */
+ private static class Value {
+ /** */
+ @SuppressWarnings("unused")
+ private String str;
+
+ /** */
+ private int idx;
+
+ /**
+ * @param str String.
+ * @param idx Integer.
+ */
+ public Value(String str, int idx) {
+ this.str = str;
+ this.idx = idx;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/407071e4/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
index 740b201..71dc964 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
@@ -46,6 +46,7 @@ import org.apache.ignite.internal.processors.cache.CacheEntryImpl;
import org.apache.ignite.internal.util.future.IgniteFinishedFutureImpl;
import org.apache.ignite.lang.IgniteBiPredicate;
import org.apache.ignite.lang.IgniteCallable;
+import org.apache.ignite.lang.IgniteClosure;
import org.apache.ignite.lang.IgniteFuture;
import org.apache.ignite.mxbean.CacheMetricsMXBean;
import org.apache.ignite.resources.IgniteInstanceResource;
@@ -172,6 +173,11 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
}
/** {@inheritDoc} */
+ @Override public <T, R> QueryCursor<R> query(Query<T> qry, IgniteClosure<T, R> transformer) {
+ throw new UnsupportedOperationException("Method should be supported.");
+ }
+
+ /** {@inheritDoc} */
@Override public Iterable<Entry<K, V>> localEntries(CachePeekMode... peekModes) throws CacheException {
return compute.call(new LocalEntriesTask<K, V>(cacheName, isAsync, peekModes));
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/407071e4/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
index 1b1908d..3652acd 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
@@ -55,6 +55,7 @@ import org.apache.ignite.internal.processors.cache.distributed.replicated.Ignite
import org.apache.ignite.internal.processors.cache.distributed.replicated.IgniteCacheReplicatedQuerySelfTest;
import org.apache.ignite.internal.processors.cache.local.IgniteCacheLocalAtomicQuerySelfTest;
import org.apache.ignite.internal.processors.cache.local.IgniteCacheLocalQuerySelfTest;
+import org.apache.ignite.internal.processors.cache.query.GridCacheQueryTransformerSelfTest;
import org.apache.ignite.internal.processors.query.IgniteSqlSchemaIndexingTest;
import org.apache.ignite.internal.processors.query.IgniteSqlSplitterSelfTest;
import org.apache.ignite.internal.processors.query.h2.sql.GridQueryParsingTest;
@@ -115,6 +116,7 @@ public class IgniteCacheQuerySelfTestSuite extends TestSuite {
suite.addTestSuite(IgniteBinaryWrappedObjectFieldsQuerySelfTest.class);
suite.addTestSuite(IgniteCacheQueryH2IndexingLeakTest.class);
suite.addTestSuite(IgniteCacheQueryNoRebalanceSelfTest.class);
+ suite.addTestSuite(GridCacheQueryTransformerSelfTest.class);
return suite;
}
[13/50] [abbrv] ignite git commit: IGNITE-3764: ODBC Added tests for
SQL operators. This closes #986.
Posted by sb...@apache.org.
IGNITE-3764: ODBC Added tests for SQL operators. This closes #986.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/99e3e8a2
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/99e3e8a2
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/99e3e8a2
Branch: refs/heads/ignite-961
Commit: 99e3e8a2d997aa681264460c2845984712ded90e
Parents: 6fd53ea
Author: Igor Sapego <is...@gridgain.com>
Authored: Fri Aug 26 11:23:49 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Fri Aug 26 11:23:49 2016 +0300
----------------------------------------------------------------------
.../cpp/common/src/common/big_integer.cpp | 1 -
modules/platforms/cpp/odbc-test/Makefile.am | 1 +
.../include/sql_function_test_suite_fixture.h | 3 +
.../cpp/odbc-test/project/vs/odbc-test.vcxproj | 1 +
.../project/vs/odbc-test.vcxproj.filters | 3 +
.../src/sql_function_test_suite_fixture.cpp | 10 +
.../cpp/odbc-test/src/sql_operators_test.cpp | 214 +++++++++++++++++++
7 files changed, 232 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/99e3e8a2/modules/platforms/cpp/common/src/common/big_integer.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/src/common/big_integer.cpp b/modules/platforms/cpp/common/src/common/big_integer.cpp
index 475ddc6..6aa6614 100644
--- a/modules/platforms/cpp/common/src/common/big_integer.cpp
+++ b/modules/platforms/cpp/common/src/common/big_integer.cpp
@@ -58,7 +58,6 @@ namespace ignite
assert(val != 0);
assert(len > 0);
assert(sign == 1 || sign == 0 || sign == -1);
- assert(val[0] != 0);
if (bigEndian)
{
http://git-wip-us.apache.org/repos/asf/ignite/blob/99e3e8a2/modules/platforms/cpp/odbc-test/Makefile.am
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/Makefile.am b/modules/platforms/cpp/odbc-test/Makefile.am
index 1f641be..a3f954e 100644
--- a/modules/platforms/cpp/odbc-test/Makefile.am
+++ b/modules/platforms/cpp/odbc-test/Makefile.am
@@ -67,6 +67,7 @@ ignite_odbc_tests_SOURCES = \
src/sql_numeric_functions_test.cpp \
src/sql_aggregate_functions_test.cpp \
src/sql_system_functions_test.cpp \
+ src/sql_operators_test.cpp \
src/sql_value_expressions.cpp \
../odbc/src/cursor.cpp \
../odbc/src/config/connection_info.cpp \
http://git-wip-us.apache.org/repos/asf/ignite/blob/99e3e8a2/modules/platforms/cpp/odbc-test/include/sql_function_test_suite_fixture.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/include/sql_function_test_suite_fixture.h b/modules/platforms/cpp/odbc-test/include/sql_function_test_suite_fixture.h
index eef0a9b..57c3f0f 100644
--- a/modules/platforms/cpp/odbc-test/include/sql_function_test_suite_fixture.h
+++ b/modules/platforms/cpp/odbc-test/include/sql_function_test_suite_fixture.h
@@ -161,6 +161,9 @@ namespace ignite
void SqlFunctionTestSuiteFixture::CheckSingleResult<double>(const char* request, const double& expected);
template<>
+ void SqlFunctionTestSuiteFixture::CheckSingleResult<bool>(const char* request, const bool& expected);
+
+ template<>
void SqlFunctionTestSuiteFixture::CheckSingleResult<std::string>(const char* request);
template<>
http://git-wip-us.apache.org/repos/asf/ignite/blob/99e3e8a2/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj b/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj
index 4d3a9cc..8b4bee6 100644
--- a/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj
+++ b/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj
@@ -171,6 +171,7 @@
<ClCompile Include="..\..\src\sql_aggregate_functions_test.cpp" />
<ClCompile Include="..\..\src\sql_function_test_suite_fixture.cpp" />
<ClCompile Include="..\..\src\sql_numeric_functions_test.cpp" />
+ <ClCompile Include="..\..\src\sql_operators_test.cpp" />
<ClCompile Include="..\..\src\sql_string_functions_test.cpp" />
<ClCompile Include="..\..\src\sql_system_functions_test.cpp" />
<ClCompile Include="..\..\src\sql_value_expressions.cpp" />
http://git-wip-us.apache.org/repos/asf/ignite/blob/99e3e8a2/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters b/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters
index c4d70b7..4756f83 100644
--- a/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters
+++ b/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters
@@ -94,6 +94,9 @@
<ClCompile Include="..\..\src\sql_system_functions_test.cpp">
<Filter>Code</Filter>
</ClCompile>
+ <ClCompile Include="..\..\src\sql_operators_test.cpp">
+ <Filter>Code</Filter>
+ </ClCompile>
<ClCompile Include="..\..\src\sql_value_expressions.cpp">
<Filter>Code</Filter>
</ClCompile>
http://git-wip-us.apache.org/repos/asf/ignite/blob/99e3e8a2/modules/platforms/cpp/odbc-test/src/sql_function_test_suite_fixture.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/sql_function_test_suite_fixture.cpp b/modules/platforms/cpp/odbc-test/src/sql_function_test_suite_fixture.cpp
index 4d8b919..d6b175f 100644
--- a/modules/platforms/cpp/odbc-test/src/sql_function_test_suite_fixture.cpp
+++ b/modules/platforms/cpp/odbc-test/src/sql_function_test_suite_fixture.cpp
@@ -192,6 +192,16 @@ namespace ignite
}
template<>
+ void SqlFunctionTestSuiteFixture::CheckSingleResult<bool>(const char* request, const bool& expected)
+ {
+ SQLCHAR res = 0;
+
+ CheckSingleResult0(request, SQL_C_BIT, &res, 0, 0);
+
+ BOOST_CHECK_EQUAL((res != 0), expected);
+ }
+
+ template<>
void SqlFunctionTestSuiteFixture::CheckSingleResult<std::string>(const char* request)
{
SQLCHAR res[ODBC_BUFFER_SIZE] = { 0 };
http://git-wip-us.apache.org/repos/asf/ignite/blob/99e3e8a2/modules/platforms/cpp/odbc-test/src/sql_operators_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/sql_operators_test.cpp b/modules/platforms/cpp/odbc-test/src/sql_operators_test.cpp
new file mode 100644
index 0000000..db3d3f7
--- /dev/null
+++ b/modules/platforms/cpp/odbc-test/src/sql_operators_test.cpp
@@ -0,0 +1,214 @@
+/*
+ * 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.
+ */
+
+#ifdef _WIN32
+# include <windows.h>
+#endif
+
+#include <vector>
+#include <string>
+
+#ifndef _MSC_VER
+# define BOOST_TEST_DYN_LINK
+#endif
+
+#include <boost/test/unit_test.hpp>
+
+#include "test_type.h"
+#include "sql_function_test_suite_fixture.h"
+#include <ignite/common/decimal.h>
+
+using namespace ignite;
+
+BOOST_FIXTURE_TEST_SUITE(SqlOperatorTestSuite, ignite::SqlFunctionTestSuiteFixture)
+
+BOOST_AUTO_TEST_CASE(TestOperatorAddInt)
+{
+ CheckSingleResult<int32_t>("SELECT 123 + 51", 123 + 51);
+};
+
+BOOST_AUTO_TEST_CASE(TestOperatorSubInt)
+{
+ CheckSingleResult<int32_t>("SELECT 123 - 51", 123 - 51);
+};
+
+BOOST_AUTO_TEST_CASE(TestOperatorDivInt)
+{
+ CheckSingleResult<int32_t>("SELECT 123 / 51", 123 / 51);
+};
+
+BOOST_AUTO_TEST_CASE(TestOperatorModInt)
+{
+ CheckSingleResult<int32_t>("SELECT 123 % 51", 123 % 51);
+};
+
+BOOST_AUTO_TEST_CASE(TestOperatorMultInt)
+{
+ CheckSingleResult<int32_t>("SELECT 123 * 51", 123 * 51);
+};
+
+BOOST_AUTO_TEST_CASE(TestOperatorAddDouble)
+{
+ CheckSingleResult<double>("SELECT 123.0 + 51.0", 123.0 + 51.0);
+};
+
+BOOST_AUTO_TEST_CASE(TestOperatorSubDouble)
+{
+ CheckSingleResult<double>("SELECT 123.0 - 51.0", 123.0 - 51.0);
+};
+
+BOOST_AUTO_TEST_CASE(TestOperatorDivDouble)
+{
+ CheckSingleResult<double>("SELECT 123.0 / 51.0", 123.0 / 51.0);
+};
+
+BOOST_AUTO_TEST_CASE(TestOperatorModDouble)
+{
+ CheckSingleResult<double>("SELECT 123.0 % 51.0", 123 % 51);
+};
+
+BOOST_AUTO_TEST_CASE(TestOperatorMultDouble)
+{
+ CheckSingleResult<double>("SELECT 123.0 * 51.0", 123.0 * 51.0);
+};
+
+BOOST_AUTO_TEST_CASE(TestOperatorConcatString)
+{
+ CheckSingleResult<std::string>("SELECT 'Hello' || ' ' || 'World' || '!'", "Hello World!");
+};
+
+BOOST_AUTO_TEST_CASE(TestOperatorGreaterInt)
+{
+ CheckSingleResult<bool>("SELECT 2 > 3", false);
+ CheckSingleResult<bool>("SELECT 3 > 3", false);
+ CheckSingleResult<bool>("SELECT 34 > 3", true);
+};
+
+BOOST_AUTO_TEST_CASE(TestOperatorLessInt)
+{
+ CheckSingleResult<bool>("SELECT 4 < 4", false);
+ CheckSingleResult<bool>("SELECT 4 < 4", false);
+ CheckSingleResult<bool>("SELECT 8 < 42", true);
+};
+
+BOOST_AUTO_TEST_CASE(TestOperatorGreaterEquealInt)
+{
+ CheckSingleResult<bool>("SELECT 2 >= 3", false);
+ CheckSingleResult<bool>("SELECT 3 >= 3", true);
+ CheckSingleResult<bool>("SELECT 34 >= 3", true);
+};
+
+BOOST_AUTO_TEST_CASE(TestOperatorLessEquealInt)
+{
+ CheckSingleResult<bool>("SELECT 4 <= 3", false);
+ CheckSingleResult<bool>("SELECT 4 <= 4", true);
+ CheckSingleResult<bool>("SELECT 8 <= 42", true);
+};
+
+BOOST_AUTO_TEST_CASE(TestOperatorEquealInt)
+{
+ CheckSingleResult<bool>("SELECT 4 = 3", false);
+ CheckSingleResult<bool>("SELECT 4 = 4", true);
+};
+
+BOOST_AUTO_TEST_CASE(TestOperatorNotEquealInt)
+{
+ CheckSingleResult<bool>("SELECT 4 != 3", true);
+ CheckSingleResult<bool>("SELECT 4 != 4", false);
+};
+
+BOOST_AUTO_TEST_CASE(TestOperatorGreaterDouble)
+{
+ CheckSingleResult<bool>("SELECT 2 > 3", false);
+ CheckSingleResult<bool>("SELECT 3 > 3", false);
+ CheckSingleResult<bool>("SELECT 34 > 3", true);
+};
+
+BOOST_AUTO_TEST_CASE(TestOperatorLessDouble)
+{
+ CheckSingleResult<bool>("SELECT 4.0 < 4.0", false);
+ CheckSingleResult<bool>("SELECT 4.0 < 4.0", false);
+ CheckSingleResult<bool>("SELECT 8.0 < 42.0", true);
+};
+
+BOOST_AUTO_TEST_CASE(TestOperatorGreaterEquealDouble)
+{
+ CheckSingleResult<bool>("SELECT 2.0 >= 3.0", false);
+ CheckSingleResult<bool>("SELECT 3.0 >= 3.0", true);
+ CheckSingleResult<bool>("SELECT 34.0 >= 3.0", true);
+};
+
+BOOST_AUTO_TEST_CASE(TestOperatorLessEquealDouble)
+{
+ CheckSingleResult<bool>("SELECT 4.0 <= 3.0", false);
+ CheckSingleResult<bool>("SELECT 4.0 <= 4.0", true);
+ CheckSingleResult<bool>("SELECT 8.0 <= 42.0", true);
+};
+
+BOOST_AUTO_TEST_CASE(TestOperatorEquealDouble)
+{
+ CheckSingleResult<bool>("SELECT 4.0 = 3.0", false);
+ CheckSingleResult<bool>("SELECT 4.0 = 4.0", true);
+};
+
+BOOST_AUTO_TEST_CASE(TestOperatorNotEquealDouble)
+{
+ CheckSingleResult<bool>("SELECT 4.0 != 3.0", true);
+ CheckSingleResult<bool>("SELECT 4.0 != 4.0", false);
+};
+
+BOOST_AUTO_TEST_CASE(TestOperatorGreaterString)
+{
+ CheckSingleResult<bool>("SELECT 'abc' > 'bcd'", false);
+ CheckSingleResult<bool>("SELECT 'abc' > 'abc'", false);
+ CheckSingleResult<bool>("SELECT 'bcd' > 'abc'", true);
+};
+
+BOOST_AUTO_TEST_CASE(TestOperatorLessString)
+{
+ CheckSingleResult<bool>("SELECT 'bcd' < 'abc'", false);
+ CheckSingleResult<bool>("SELECT 'abc' < 'abc'", false);
+ CheckSingleResult<bool>("SELECT 'abc' < 'bcd'", true);
+};
+
+BOOST_AUTO_TEST_CASE(TestOperatorGreaterEquealString)
+{
+ CheckSingleResult<bool>("SELECT 'abc' >= 'bcd'", false);
+ CheckSingleResult<bool>("SELECT 'abc' >= 'abc'", true);
+ CheckSingleResult<bool>("SELECT 'bcd' >= 'abc'", true);
+};
+
+BOOST_AUTO_TEST_CASE(TestOperatorLessEquealString)
+{
+ CheckSingleResult<bool>("SELECT 'bcd' <= 'abc'", false);
+ CheckSingleResult<bool>("SELECT 'abc' <= 'bcd'", true);
+ CheckSingleResult<bool>("SELECT 'abc' <= 'abc'", true);
+};
+
+BOOST_AUTO_TEST_CASE(TestOperatorEquealString)
+{
+ CheckSingleResult<bool>("SELECT 'bcd' = 'abc'", false);
+ CheckSingleResult<bool>("SELECT 'abc' = 'abc'", true);
+};
+
+BOOST_AUTO_TEST_CASE(TestOperatorNotEquealString)
+{
+ CheckSingleResult<bool>("SELECT 'abc' != 'abc'", false);
+ CheckSingleResult<bool>("SELECT 'bcd' != 'abc'", true);
+};
+
+BOOST_AUTO_TEST_SUITE_END()
[28/50] [abbrv] ignite git commit: ignite-2560 Support resource
injection for entry processor, optimizations for resource injection.
Posted by sb...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f9ff97c9/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
index 32d46e2..3f4d812 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
@@ -17,8 +17,6 @@
package org.apache.ignite.internal.processors.cache;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Sets;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
@@ -34,7 +32,10 @@ import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.Callable;
+import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.Lock;
import javax.cache.Cache;
@@ -46,10 +47,13 @@ import javax.cache.processor.EntryProcessor;
import javax.cache.processor.EntryProcessorException;
import javax.cache.processor.EntryProcessorResult;
import javax.cache.processor.MutableEntry;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Sets;
import junit.framework.AssertionFailedError;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteEvents;
import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.IgniteTransactions;
@@ -61,12 +65,15 @@ import org.apache.ignite.cache.affinity.Affinity;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.events.CacheEvent;
import org.apache.ignite.events.Event;
+import org.apache.ignite.events.EventType;
import org.apache.ignite.internal.IgniteEx;
import org.apache.ignite.internal.IgniteKernal;
import org.apache.ignite.internal.IgnitionEx;
import org.apache.ignite.internal.processors.cache.query.GridCacheQueryManager;
import org.apache.ignite.internal.processors.resource.GridSpringResourceContext;
+import org.apache.ignite.internal.util.future.GridFutureAdapter;
import org.apache.ignite.internal.util.lang.GridAbsPredicate;
import org.apache.ignite.internal.util.lang.GridAbsPredicateX;
import org.apache.ignite.internal.util.lang.IgnitePair;
@@ -76,10 +83,16 @@ import org.apache.ignite.internal.util.typedef.PA;
import org.apache.ignite.internal.util.typedef.internal.A;
import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteBiPredicate;
import org.apache.ignite.lang.IgniteClosure;
import org.apache.ignite.lang.IgniteFuture;
import org.apache.ignite.lang.IgnitePredicate;
+import org.apache.ignite.resources.CacheNameResource;
+import org.apache.ignite.resources.IgniteInstanceResource;
import org.apache.ignite.resources.LoggerResource;
+import org.apache.ignite.resources.ServiceResource;
+import org.apache.ignite.services.Service;
+import org.apache.ignite.services.ServiceContext;
import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
import org.apache.ignite.spi.swapspace.inmemory.GridTestSwapSpaceSpi;
@@ -124,6 +137,9 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
/** Test timeout */
private static final long TEST_TIMEOUT = 60 * 1000;
+ /** Service name. */
+ private static final String SERVICE_NAME1 = "testService1";
+
/** */
public static final CacheEntryProcessor<String, Integer, String> ERR_PROCESSOR =
new CacheEntryProcessor<String, Integer, String>() {
@@ -202,6 +218,21 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
if (memoryMode() == OFFHEAP_TIERED || memoryMode() == OFFHEAP_VALUES)
cfg.setSwapSpaceSpi(new GridTestSwapSpaceSpi());
+ int[] evtTypes = cfg.getIncludeEventTypes();
+
+ if (evtTypes == null || evtTypes.length == 0)
+ cfg.setIncludeEventTypes(EventType.EVT_CACHE_OBJECT_READ);
+ else {
+ for (int evtType : evtTypes) {
+ if (evtType == EventType.EVT_CACHE_OBJECT_READ)
+ return cfg;
+ }
+
+ int[] updatedEvtTypes = Arrays.copyOf(evtTypes, evtTypes.length + 1);
+
+ updatedEvtTypes[updatedEvtTypes.length - 1] = EventType.EVT_CACHE_OBJECT_READ;
+ }
+
return cfg;
}
@@ -261,6 +292,18 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
cacheCfgMap = null;
}
+ // We won't deploy service unless non-client node is configured.
+ for (int i = 0; i < gridCount(); i++) {
+ Boolean clientMode = grid(i).configuration().isClientMode();
+
+ if (clientMode)
+ continue;
+
+ grid(0).services(grid(0).cluster()).deployNodeSingleton(SERVICE_NAME1, new DummyServiceImpl());
+
+ break;
+ }
+
for (int i = 0; i < gridCount(); i++)
info("Grid " + i + ": " + grid(i).localNode().id());
}
@@ -619,9 +662,9 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
cache.put("key1", 1);
cache.put("key2", 2);
- CacheEntry<String, Integer> key1e = cache.getEntry("key1");
- CacheEntry<String, Integer> key2e = cache.getEntry("key2");
- CacheEntry<String, Integer> wrongKeye = cache.getEntry("wrongKey");
+ CacheEntry<String, Integer> key1e = cache.getEntry("key1");
+ CacheEntry<String, Integer> key2e = cache.getEntry("key2");
+ CacheEntry<String, Integer> wrongKeye = cache.getEntry("wrongKey");
assert key1e.getValue() == 1;
assert key1e.getKey().equals("key1");
@@ -781,7 +824,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
boolean b1 = false;
boolean b2 = false;
- for (CacheEntry<String, Integer> e: c1){
+ for (CacheEntry<String, Integer> e : c1) {
if (e.getKey().equals("key1") && e.getValue().equals(1))
b1 = true;
@@ -800,7 +843,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
b1 = false;
b2 = false;
- for (CacheEntry<String, Integer> e: c2){
+ for (CacheEntry<String, Integer> e : c2) {
if (e.getKey().equals("key1") && e.getValue().equals(1))
b1 = true;
@@ -1481,8 +1524,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
private void checkTransformReturnValue(boolean put,
TransactionConcurrency concurrency,
TransactionIsolation isolation)
- throws Exception
- {
+ throws Exception {
IgniteCache<String, Integer> cache = jcache();
if (!put)
@@ -1790,7 +1832,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
cache.put(key, 1);
- assertEquals(1, (int) cache.get(key));
+ assertEquals(1, (int)cache.get(key));
GridTestUtils.assertThrows(log, new Callable<Void>() {
@Override public Void call() throws Exception {
@@ -1808,7 +1850,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
}
}, NullPointerException.class, null);
- assertEquals(1, (int) cache.get(key));
+ assertEquals(1, (int)cache.get(key));
cache.put(key, 2);
@@ -1839,7 +1881,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
assertNull(cache.get("k1"));
assertNull(cache.get("k2"));
- assertEquals(2, (int) cache.get(key));
+ assertEquals(2, (int)cache.get(key));
cache.put(key, 3);
@@ -1890,7 +1932,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
cache.putAll(m);
- assertEquals(3, (int) cache.get("key3"));
+ assertEquals(3, (int)cache.get("key3"));
assertEquals(4, (int)cache.get("key4"));
}
@@ -2215,7 +2257,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
}
/**
- * @param inTx In tx flag.
+ * @param inTx In tx flag.
* @throws Exception If failed.
*/
private void checkPutxIfAbsentAsync(boolean inTx) throws Exception {
@@ -2857,7 +2899,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
/**
* @return Count of entries to be removed in removeAll() test.
*/
- protected long hugeRemoveAllEntryCount(){
+ protected long hugeRemoveAllEntryCount() {
return 1000L;
}
@@ -3627,7 +3669,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
assertNotNull(curEntryTtl.get1());
assertNotNull(curEntryTtl.get2());
- assertEquals(ttl, (long) curEntryTtl.get1());
+ assertEquals(ttl, (long)curEntryTtl.get1());
assertTrue(curEntryTtl.get2() > startTime);
expireTimes[i] = curEntryTtl.get2();
@@ -3656,7 +3698,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
assertNotNull(curEntryTtl.get1());
assertNotNull(curEntryTtl.get2());
- assertEquals(ttl, (long) curEntryTtl.get1());
+ assertEquals(ttl, (long)curEntryTtl.get1());
assertTrue(curEntryTtl.get2() > startTime);
expireTimes[i] = curEntryTtl.get2();
@@ -3685,7 +3727,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
assertNotNull(curEntryTtl.get1());
assertNotNull(curEntryTtl.get2());
- assertEquals(ttl, (long) curEntryTtl.get1());
+ assertEquals(ttl, (long)curEntryTtl.get1());
assertTrue(curEntryTtl.get2() > startTime);
expireTimes[i] = curEntryTtl.get2();
@@ -3897,7 +3939,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
cache.localPromote(Collections.singleton(k2));
- assertEquals((Integer) 2, cache.localPeek(k2, ONHEAP_PEEK_MODES));
+ assertEquals((Integer)2, cache.localPeek(k2, ONHEAP_PEEK_MODES));
cnt++;
}
@@ -5021,7 +5063,6 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
* @param keys Keys list.
* @param txConcurrency Concurrency mode.
* @param txIsolation Isolation mode.
- *
* @throws Exception If failed.
*/
private void checkSkipStoreWithTransaction(IgniteCache<String, Integer> cache,
@@ -5030,8 +5071,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
List<String> keys,
TransactionConcurrency txConcurrency,
TransactionIsolation txIsolation)
- throws Exception
- {
+ throws Exception {
info("Test tx skip store [concurrency=" + txConcurrency + ", isolation=" + txIsolation + ']');
cache.removeAll(data.keySet());
@@ -5043,10 +5083,10 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
// Several put check.
try (Transaction tx = txs.txStart(txConcurrency, txIsolation)) {
- for (String key: keys)
+ for (String key : keys)
cacheSkipStore.put(key, val);
- for (String key: keys) {
+ for (String key : keys) {
assertEquals(val, cacheSkipStore.get(key));
assertEquals(val, cache.get(key));
assertFalse(storeStgy.isInStore(key));
@@ -5055,7 +5095,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
tx.commit();
}
- for (String key: keys) {
+ for (String key : keys) {
assertEquals(val, cacheSkipStore.get(key));
assertEquals(val, cache.get(key));
assertFalse(storeStgy.isInStore(key));
@@ -5070,7 +5110,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
tx.commit();
}
- for (String key: keys) {
+ for (String key : keys) {
val = data.get(key);
assertEquals(val, cacheSkipStore.get(key));
@@ -5086,7 +5126,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
tx.commit();
}
- for (String key: keys) {
+ for (String key : keys) {
assertNull(cacheSkipStore.get(key));
assertNotNull(cache.get(key));
assertTrue(storeStgy.isInStore(key));
@@ -5100,7 +5140,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
try (Transaction tx = txs.txStart(txConcurrency, txIsolation)) {
cache.putAll(data);
- for (String key: keys) {
+ for (String key : keys) {
assertNotNull(cacheSkipStore.get(key));
assertNotNull(cache.get(key));
assertFalse(storeStgy.isInStore(key));
@@ -5108,7 +5148,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
cache.removeAll(data.keySet());
- for (String key: keys) {
+ for (String key : keys) {
assertNull(cacheSkipStore.get(key));
assertNull(cache.get(key));
assertFalse(storeStgy.isInStore(key));
@@ -5135,7 +5175,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
cache.putAll(subMap);
- for (String key: keys) {
+ for (String key : keys) {
assertNotNull(cacheSkipStore.get(key));
assertNotNull(cache.get(key));
assertFalse(storeStgy.isInStore(key));
@@ -5162,7 +5202,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
cache.removeAll(data.keySet());
- for (String key: keys) {
+ for (String key : keys) {
assertNull(cacheSkipStore.get(key));
assertNull(cache.get(key));
assertFalse(storeStgy.isInStore(key));
@@ -5257,7 +5297,6 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
/**
* @param cache Cache instance.
* @param cacheSkipStore Cache skip store projection.
- *
* @throws Exception If failed.
*/
private void checkEmpty(IgniteCache<String, Integer> cache, IgniteCache<String, Integer> cacheSkipStore)
@@ -5426,6 +5465,155 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
}
/**
+ * @throws Exception If failed.
+ */
+ public void testTransformResourceInjection() throws Exception {
+ IgniteCache<String, Integer> cache = jcache();
+ Ignite ignite = ignite(0);
+
+ doTransformResourceInjection(ignite, cache);
+ doTransformResourceInjection(ignite, cache.withAsync());
+
+ if (txEnabled()) {
+ doTransformResourceInjectionInTx(ignite, cache);
+ doTransformResourceInjectionInTx(ignite, cache.withAsync());
+ }
+ }
+
+ /**
+ * @param ignite Node.
+ * @param cache Cache.
+ * @throws Exception If failed.
+ */
+ private void doTransformResourceInjectionInTx(Ignite ignite, IgniteCache<String, Integer> cache) throws Exception {
+ for (TransactionConcurrency concurrency : TransactionConcurrency.values()) {
+ for (TransactionIsolation isolation : TransactionIsolation.values()) {
+ IgniteTransactions txs = ignite.transactions();
+
+ try (Transaction tx = txs.txStart(concurrency, isolation)) {
+ doTransformResourceInjection(ignite, cache);
+
+ tx.commit();
+ }
+ }
+ }
+ }
+
+ /**
+ * @param ignite Node.
+ * @param cache Cache.
+ * @throws Exception If failed.
+ */
+ private void doTransformResourceInjection(Ignite ignite, IgniteCache<String, Integer> cache) throws Exception {
+ final Collection<ResourceType> required = Arrays.asList(ResourceType.IGNITE_INSTANCE,
+ ResourceType.CACHE_NAME,
+ ResourceType.LOGGER,
+ ResourceType.SERVICE);
+
+ final CacheEventListener lsnr = new CacheEventListener();
+
+ IgniteEvents evts = ignite.events(ignite.cluster());
+
+ UUID opId = evts.remoteListen(lsnr, null, EventType.EVT_CACHE_OBJECT_READ);
+
+ try {
+ checkResourceInjectionOnInvoke(cache, required);
+
+ checkResourceInjectionOnInvokeAll(cache, required);
+
+ checkResourceInjectionOnInvokeAllMap(cache, required);
+ }
+ finally {
+ evts.stopRemoteListen(opId);
+ }
+ }
+
+ /**
+ * Tests invokeAll method for map of pairs (key, entryProcessor).
+ *
+ * @param cache Cache.
+ * @param required Expected injected resources.
+ */
+ private void checkResourceInjectionOnInvokeAllMap(IgniteCache<String, Integer> cache,
+ Collection<ResourceType> required) {
+ Map<String, EntryProcessorResult<Integer>> results;
+
+ Map<String, EntryProcessor<String, Integer, Integer>> map = new HashMap<>();
+
+ map.put(UUID.randomUUID().toString(), new ResourceInjectionEntryProcessor());
+ map.put(UUID.randomUUID().toString(), new ResourceInjectionEntryProcessor());
+ map.put(UUID.randomUUID().toString(), new ResourceInjectionEntryProcessor());
+ map.put(UUID.randomUUID().toString(), new ResourceInjectionEntryProcessor());
+
+ results = cache.invokeAll(map);
+
+ if (cache.isAsync())
+ results = cache.<Map<String, EntryProcessorResult<Integer>>>future().get();
+
+ assertEquals(map.size(), results.size());
+
+ for (EntryProcessorResult<Integer> res : results.values()) {
+ Collection<ResourceType> notInjected = ResourceInfoSet.valueOf(res.get()).notInjected(required);
+
+ if (!notInjected.isEmpty())
+ fail("Can't inject resource(s): " + Arrays.toString(notInjected.toArray()));
+ }
+ }
+
+ /**
+ * Tests invokeAll method for set of keys.
+ *
+ * @param cache Cache.
+ * @param required Expected injected resources.
+ */
+ private void checkResourceInjectionOnInvokeAll(IgniteCache<String, Integer> cache,
+ Collection<ResourceType> required) {
+ Set<String> keys = new HashSet<>(Arrays.asList(UUID.randomUUID().toString(),
+ UUID.randomUUID().toString(),
+ UUID.randomUUID().toString(),
+ UUID.randomUUID().toString()));
+
+ Map<String, EntryProcessorResult<Integer>> results = cache.invokeAll(keys,
+ new ResourceInjectionEntryProcessor());
+
+ if (cache.isAsync())
+ results = cache.<Map<String, EntryProcessorResult<Integer>>>future().get();
+
+ assertEquals(keys.size(), results.size());
+
+ for (EntryProcessorResult<Integer> res : results.values()) {
+ Collection<ResourceType> notInjected1 = ResourceInfoSet.valueOf(res.get()).notInjected(required);
+
+ if (!notInjected1.isEmpty())
+ fail("Can't inject resource(s): " + Arrays.toString(notInjected1.toArray()));
+ }
+ }
+
+ /**
+ * Tests invoke for single key.
+ *
+ * @param cache Cache.
+ * @param required Expected injected resources.
+ */
+ private void checkResourceInjectionOnInvoke(IgniteCache<String, Integer> cache,
+ Collection<ResourceType> required) {
+
+ String key = UUID.randomUUID().toString();
+
+ Integer flags = cache.invoke(key, new GridCacheAbstractFullApiSelfTest.ResourceInjectionEntryProcessor());
+
+ if (cache.isAsync())
+ flags = cache.<Integer>future().get();
+
+ assertTrue("Processor result is null", flags != null);
+
+ Collection<ResourceType> notInjected = ResourceInfoSet.valueOf(flags).notInjected(required);
+
+ if (!notInjected.isEmpty())
+ fail("Can't inject resource(s): " + Arrays.toString(notInjected.toArray()));
+ }
+
+ /**
* Sets given value, returns old value.
*/
public static final class SetValueProcessor implements EntryProcessor<String, Integer, Integer> {
@@ -5440,7 +5628,8 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
}
/** {@inheritDoc} */
- @Override public Integer process(MutableEntry<String, Integer> entry, Object... arguments) throws EntryProcessorException {
+ @Override public Integer process(MutableEntry<String, Integer> entry,
+ Object... arguments) throws EntryProcessorException {
Integer val = entry.getValue();
entry.setValue(newVal);
@@ -5498,6 +5687,86 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
/**
*
*/
+ public static class ResourceInjectionEntryProcessor extends ResourceInjectionEntryProcessorBase<String, Integer> {
+ /** */
+ protected transient Ignite ignite;
+
+ /** */
+ protected transient String cacheName;
+
+ /** */
+ protected transient IgniteLogger log;
+
+ /** */
+ protected transient DummyService svc;
+
+ /**
+ * @param ignite Ignite.
+ */
+ @IgniteInstanceResource
+ public void setIgnite(Ignite ignite) {
+ assert ignite != null;
+
+ checkSet();
+
+ infoSet.set(ResourceType.IGNITE_INSTANCE, true);
+
+ this.ignite = ignite;
+ }
+
+ /**
+ * @param cacheName Cache name.
+ */
+ @CacheNameResource
+ public void setCacheName(String cacheName) {
+ checkSet();
+
+ infoSet.set(ResourceType.CACHE_NAME, true);
+
+ this.cacheName = cacheName;
+ }
+
+ /**
+ * @param log Logger.
+ */
+ @LoggerResource
+ public void setLoggerResource(IgniteLogger log) {
+ assert log != null;
+
+ checkSet();
+
+ infoSet.set(ResourceType.LOGGER, true);
+
+ this.log = log;
+ }
+
+ /**
+ * @param svc Service.
+ */
+ @ServiceResource(serviceName = SERVICE_NAME1)
+ public void setDummyService(DummyService svc) {
+ assert svc != null;
+
+ checkSet();
+
+ infoSet.set(ResourceType.SERVICE, true);
+
+ this.svc = svc;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Integer process(MutableEntry<String, Integer> e, Object... args) {
+ Integer oldVal = e.getValue();
+
+ e.setValue(ThreadLocalRandom.current().nextInt() + (oldVal == null ? 0 : oldVal));
+
+ return super.process(e, args);
+ }
+ }
+
+ /**
+ *
+ */
private static class CheckEntriesTask extends TestIgniteIdxRunnable {
/** Keys. */
private final Collection<String> keys;
@@ -5674,6 +5943,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
*
*/
private static class SwapEvtsLocalListener implements IgnitePredicate<Event> {
+ /** */
@LoggerResource
private IgniteLogger log;
@@ -5711,13 +5981,21 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
}
}
+ /**
+ *
+ */
private static class CheckEntriesDeletedTask extends TestIgniteIdxRunnable {
+ /** */
private final int cnt;
+ /**
+ * @param cnt Keys count.
+ */
public CheckEntriesDeletedTask(int cnt) {
this.cnt = cnt;
}
+ /** {@inheritDoc} */
@Override public void run(int idx) throws Exception {
for (int i = 0; i < cnt; i++) {
String key = String.valueOf(i);
@@ -5816,4 +6094,64 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
return val;
}
}
+
+ /**
+ * Dummy Service.
+ */
+ public interface DummyService {
+ /**
+ *
+ */
+ public void noop();
+ }
+
+ /**
+ * No-op test service.
+ */
+ public static class DummyServiceImpl implements DummyService, Service {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** {@inheritDoc} */
+ @Override public void noop() {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override public void cancel(ServiceContext ctx) {
+ System.out.println("Cancelling service: " + ctx.name());
+ }
+
+ /** {@inheritDoc} */
+ @Override public void init(ServiceContext ctx) throws Exception {
+ System.out.println("Initializing service: " + ctx.name());
+ }
+
+ /** {@inheritDoc} */
+ @Override public void execute(ServiceContext ctx) {
+ System.out.println("Executing service: " + ctx.name());
+ }
+ }
+
+ /**
+ *
+ */
+ public static class CacheEventListener implements IgniteBiPredicate<UUID, CacheEvent>, IgnitePredicate<CacheEvent> {
+ /** */
+ public final LinkedBlockingQueue<CacheEvent> evts = new LinkedBlockingQueue<>();
+
+ /** {@inheritDoc} */
+ @Override public boolean apply(UUID uuid, CacheEvent evt) {
+ evts.add(evt);
+
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean apply(CacheEvent evt) {
+ evts.add(evt);
+
+ return true;
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/f9ff97c9/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java
index d58e560..af31635 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java
@@ -17,9 +17,15 @@
package org.apache.ignite.internal.processors.cache;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
import java.util.concurrent.atomic.AtomicInteger;
import javax.cache.Cache;
import javax.cache.configuration.Factory;
+import javax.cache.processor.EntryProcessor;
+import javax.cache.processor.MutableEntry;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.IgniteCheckedException;
@@ -80,6 +86,8 @@ public abstract class GridCacheAbstractSelfTest extends GridCommonAbstractTest {
/** {@inheritDoc} */
@Override protected void beforeTestsStarted() throws Exception {
+ super.beforeTestsStarted();
+
int cnt = gridCount();
assert cnt >= 1 : "At least one grid must be started";
@@ -188,7 +196,8 @@ public abstract class GridCacheAbstractSelfTest extends GridCommonAbstractTest {
assert jcache().unwrap(Ignite.class).transactions().tx() == null;
assertEquals("Cache is not empty", 0, jcache().localSize(CachePeekMode.ALL));
- storeStgy.resetStore();
+ if (storeStgy != null)
+ storeStgy.resetStore();
}
/** {@inheritDoc} */
@@ -410,20 +419,20 @@ public abstract class GridCacheAbstractSelfTest extends GridCommonAbstractTest {
*/
protected static IgnitePredicate<Cache.Entry<String, Integer>> entryKeyFilter =
new P1<Cache.Entry<String, Integer>>() {
- @Override public boolean apply(Cache.Entry<String, Integer> entry) {
- return entry.getKey().contains("key");
- }
- };
+ @Override public boolean apply(Cache.Entry<String, Integer> entry) {
+ return entry.getKey().contains("key");
+ }
+ };
/**
* Filters cache entry projections leaving only ones with keys not containing 'key'.
*/
protected static IgnitePredicate<Cache.Entry<String, Integer>> entryKeyFilterInv =
new P1<Cache.Entry<String, Integer>>() {
- @Override public boolean apply(Cache.Entry<String, Integer> entry) {
- return !entry.getKey().contains("key");
- }
- };
+ @Override public boolean apply(Cache.Entry<String, Integer> entry) {
+ return !entry.getKey().contains("key");
+ }
+ };
/**
* Filters cache entry projections leaving only ones with values less than 50.
@@ -528,4 +537,117 @@ public abstract class GridCacheAbstractSelfTest extends GridCommonAbstractTest {
}
}
+ /** */
+ protected enum ResourceType {
+ /** */
+ IGNITE_INSTANCE,
+
+ /** */
+ CACHE_NAME,
+
+ /** */
+ SPRING_APPLICATION_CONTEXT,
+
+ /** */
+ LOGGER,
+
+ /** */
+ SERVICE,
+
+ /** */
+ SPRING_BEAN,
+
+ }
+
+ /**
+ *
+ */
+ protected static class ResourceInfoSet {
+ /** */
+ int val;
+
+ /** */
+ public ResourceInfoSet() {
+ this(0);
+ }
+
+ /** */
+ public ResourceInfoSet(int val) {
+ this.val = val;
+ }
+
+ /**
+ * @param val Value.
+ */
+ public static ResourceInfoSet valueOf(int val) {
+ return new ResourceInfoSet(val);
+ }
+
+ /** */
+ public int getValue() {
+ return val;
+ }
+
+ /**
+ * @param type Type.
+ * @param injected Injected.
+ */
+ public ResourceInfoSet set(ResourceType type, boolean injected) {
+ int mask = 1 << type.ordinal();
+
+ if (injected)
+ val |= mask;
+ else
+ val &= ~mask;
+
+ return this;
+ }
+
+ /**
+ * @see {@link #set(ResourceType, boolean)}
+ */
+ public ResourceInfoSet set(ResourceType type, Object toCheck) {
+ return set(type, toCheck != null);
+ }
+
+ /**
+ * @return collection of not injected resources
+ */
+ public Collection<ResourceType> notInjected(Collection<ResourceType> exp) {
+ ArrayList<ResourceType> res = null;
+
+ for (ResourceType type : exp) {
+ int mask = 1 << type.ordinal();
+
+ if ((this.val & mask) == 0) {
+ if (res == null)
+ res = new ArrayList<>();
+
+ res.add(type);
+ }
+ }
+
+ return res == null ? Collections.<ResourceType>emptyList() : res;
+ }
+ }
+
+ /**
+ *
+ */
+ protected static abstract class ResourceInjectionEntryProcessorBase<K, V>
+ implements EntryProcessor<K, V, Integer>, Serializable {
+ /** */
+ protected transient ResourceInfoSet infoSet;
+
+ /** {@inheritDoc} */
+ @Override public Integer process(MutableEntry<K, V> e, Object... args) {
+ return infoSet == null ? null : infoSet.getValue();
+ }
+
+ /** */
+ protected void checkSet() {
+ if (infoSet == null)
+ infoSet = new ResourceInfoSet();
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/f9ff97c9/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTransformEventSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTransformEventSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTransformEventSelfTest.java
index a3caba6..f36b060 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTransformEventSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTransformEventSelfTest.java
@@ -38,6 +38,7 @@ import org.apache.ignite.events.CacheEvent;
import org.apache.ignite.events.Event;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.lang.IgnitePredicate;
+import org.apache.ignite.resources.IgniteInstanceResource;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
@@ -74,9 +75,6 @@ public class GridCacheTransformEventSelfTest extends GridCommonAbstractTest {
/** Cache name. */
private static final String CACHE_NAME = "cache";
- /** Closure name. */
- private static final String CLO_NAME = Transformer.class.getName();
-
/** Key 1. */
private Integer key1;
@@ -98,7 +96,7 @@ public class GridCacheTransformEventSelfTest extends GridCommonAbstractTest {
/** Caches. */
private IgniteCache<Integer, Integer>[] caches;
- /** Recorded events.*/
+ /** Recorded events. */
private ConcurrentHashSet<CacheEvent> evts;
/** Cache mode. */
@@ -477,13 +475,25 @@ public class GridCacheTransformEventSelfTest extends GridCommonAbstractTest {
caches[0].invoke(key1, new Transformer());
- checkEventNodeIdsStrict(primaryIdsForKeys(key1));
+ checkEventNodeIdsStrict(Transformer.class.getName(), primaryIdsForKeys(key1));
assert evts.isEmpty();
caches[0].invokeAll(keys, new Transformer());
- checkEventNodeIdsStrict(primaryIdsForKeys(key1, key2));
+ checkEventNodeIdsStrict(Transformer.class.getName(), primaryIdsForKeys(key1, key2));
+
+ assert evts.isEmpty();
+
+ caches[0].invoke(key1, new TransformerWithInjection());
+
+ checkEventNodeIdsStrict(TransformerWithInjection.class.getName(), primaryIdsForKeys(key1));
+
+ assert evts.isEmpty();
+
+ caches[0].invokeAll(keys, new TransformerWithInjection());
+
+ checkEventNodeIdsStrict(TransformerWithInjection.class.getName(), primaryIdsForKeys(key1, key2));
}
/**
@@ -492,7 +502,6 @@ public class GridCacheTransformEventSelfTest extends GridCommonAbstractTest {
* @param cacheMode Cache mode.
* @param txConcurrency TX concurrency.
* @param txIsolation TX isolation.
- *
* @throws Exception If failed.
*/
private void checkTx(CacheMode cacheMode, TransactionConcurrency txConcurrency,
@@ -505,13 +514,29 @@ public class GridCacheTransformEventSelfTest extends GridCommonAbstractTest {
System.out.println("AFTER: " + evts.size());
- checkEventNodeIdsStrict(idsForKeys(key1));
+ checkEventNodeIdsStrict(Transformer.class.getName(), idsForKeys(key1));
assert evts.isEmpty();
caches[0].invokeAll(keys, new Transformer());
- checkEventNodeIdsStrict(idsForKeys(key1, key2));
+ checkEventNodeIdsStrict(Transformer.class.getName(), idsForKeys(key1, key2));
+
+ assert evts.isEmpty();
+
+ System.out.println("BEFORE: " + evts.size());
+
+ caches[0].invoke(key1, new TransformerWithInjection());
+
+ System.out.println("AFTER: " + evts.size());
+
+ checkEventNodeIdsStrict(TransformerWithInjection.class.getName(), idsForKeys(key1));
+
+ assert evts.isEmpty();
+
+ caches[0].invokeAll(keys, new TransformerWithInjection());
+
+ checkEventNodeIdsStrict(TransformerWithInjection.class.getName(), idsForKeys(key1, key2));
}
/**
@@ -572,9 +597,10 @@ public class GridCacheTransformEventSelfTest extends GridCommonAbstractTest {
/**
* Ensure that events were recorded on the given nodes.
*
+ * @param cClsName Entry processor class name.
* @param ids Event IDs.
*/
- private void checkEventNodeIdsStrict(UUID... ids) {
+ private void checkEventNodeIdsStrict(String cClsName, UUID... ids) {
if (ids == null)
assertTrue(evts.isEmpty());
else {
@@ -585,7 +611,7 @@ public class GridCacheTransformEventSelfTest extends GridCommonAbstractTest {
for (CacheEvent evt : evts) {
if (F.eq(id, evt.node().id())) {
- assertEquals(CLO_NAME, evt.closureClassName());
+ assertEquals(cClsName, evt.closureClassName());
foundEvt = evt;
@@ -625,4 +651,22 @@ public class GridCacheTransformEventSelfTest extends GridCommonAbstractTest {
return null;
}
}
+
+ /**
+ * Transform closure.
+ */
+ private static class TransformerWithInjection implements EntryProcessor<Integer, Integer, Void>, Serializable {
+ /** */
+ @IgniteInstanceResource
+ private transient Ignite ignite;
+
+ /** {@inheritDoc} */
+ @Override public Void process(MutableEntry<Integer, Integer> e, Object... args) {
+ assert ignite != null;
+
+ e.setValue(e.getValue() + 1);
+
+ return null;
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/f9ff97c9/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedBasicStoreMultiNodeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedBasicStoreMultiNodeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedBasicStoreMultiNodeSelfTest.java
index e78f329..bcf4ccd 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedBasicStoreMultiNodeSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedBasicStoreMultiNodeSelfTest.java
@@ -70,6 +70,8 @@ public class GridCachePartitionedBasicStoreMultiNodeSelfTest extends GridCommonA
/** {@inheritDoc} */
@Override protected void beforeTestsStarted() throws Exception {
+ super.beforeTestsStarted();
+
stores = Collections.synchronizedList(new ArrayList<GridCacheTestStore>());
startGridsMultiThreaded(GRID_CNT);
http://git-wip-us.apache.org/repos/asf/ignite/blob/f9ff97c9/modules/spring/src/test/java/org/apache/ignite/internal/processors/resource/GridTransformSpringInjectionSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/spring/src/test/java/org/apache/ignite/internal/processors/resource/GridTransformSpringInjectionSelfTest.java b/modules/spring/src/test/java/org/apache/ignite/internal/processors/resource/GridTransformSpringInjectionSelfTest.java
new file mode 100644
index 0000000..cc61514
--- /dev/null
+++ b/modules/spring/src/test/java/org/apache/ignite/internal/processors/resource/GridTransformSpringInjectionSelfTest.java
@@ -0,0 +1,186 @@
+/*
+ * 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.resource;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+import javax.cache.processor.EntryProcessorResult;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteSpring;
+import org.apache.ignite.IgniteTransactions;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.internal.processors.cache.GridCacheAbstractSelfTest;
+import org.apache.ignite.resources.SpringApplicationContextResource;
+import org.apache.ignite.resources.SpringResource;
+import org.apache.ignite.transactions.Transaction;
+import org.apache.ignite.transactions.TransactionConcurrency;
+import org.apache.ignite.transactions.TransactionIsolation;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
+import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+
+/**
+ *
+ */
+public class GridTransformSpringInjectionSelfTest extends GridCacheAbstractSelfTest {
+ /** {@inheritDoc} */
+ @Override protected int gridCount() {
+ return 1;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void beforeTestsStarted() throws Exception {
+ IgniteSpring.start(getConfiguration(getTestGridName(0)),
+ new ClassPathXmlApplicationContext("/org/apache/ignite/internal/processors/resource/spring-resource.xml"));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testTransformResourceInjection() throws Exception {
+ Ignite grid = grid(0);
+
+ IgniteCache<String, Integer> cache = grid.createCache(cacheConfiguration(ATOMIC));
+
+ try {
+ doTransformResourceInjection(cache);
+ }
+ finally {
+ cache.destroy();
+ }
+
+ cache = grid.createCache(cacheConfiguration(TRANSACTIONAL));
+
+ try {
+ doTransformResourceInjection(cache);
+
+ for (TransactionConcurrency concurrency : TransactionConcurrency.values()) {
+ for (TransactionIsolation isolation : TransactionIsolation.values()) {
+ IgniteTransactions txs = grid.transactions();
+
+ try (Transaction tx = txs.txStart(concurrency, isolation)) {
+ doTransformResourceInjection(cache);
+
+ tx.commit();
+ }
+ }
+ }
+ }
+ finally {
+ cache.destroy();
+ }
+ }
+
+ /**
+ * @param atomicityMode Cache atomicity mode.
+ * @return Cache configuration.
+ */
+ private CacheConfiguration<String, Integer> cacheConfiguration(CacheAtomicityMode atomicityMode) {
+ CacheConfiguration<String, Integer> ccfg = new CacheConfiguration<>();
+
+ ccfg.setName(getClass().getSimpleName());
+ ccfg.setAtomicityMode(atomicityMode);
+
+ return ccfg;
+ }
+
+ /**
+ * @param cache Cache.
+ * @throws Exception If failed.
+ */
+ private void doTransformResourceInjection(IgniteCache<String, Integer> cache) throws Exception {
+ final Collection<ResourceType> required = Arrays.asList(
+ ResourceType.SPRING_APPLICATION_CONTEXT,
+ ResourceType.SPRING_BEAN);
+
+ Integer flags = cache.invoke(UUID.randomUUID().toString(), new SpringResourceInjectionEntryProcessor());
+
+ assertTrue("Processor result is null", flags != null);
+
+ log.info("Injection flag: " + Integer.toBinaryString(flags));
+
+ Collection<ResourceType> notInjected = ResourceInfoSet.valueOf(flags).notInjected(required);
+
+ if (!notInjected.isEmpty())
+ fail("Can't inject resource(s): " + Arrays.toString(notInjected.toArray()));
+
+ Set<String> keys = new HashSet<>(Arrays.asList(UUID.randomUUID().toString(),
+ UUID.randomUUID().toString(),
+ UUID.randomUUID().toString(),
+ UUID.randomUUID().toString()));
+
+ Map<String, EntryProcessorResult<Integer>> results = cache.invokeAll(keys,
+ new SpringResourceInjectionEntryProcessor());
+
+ assertEquals(keys.size(), results.size());
+
+ for (EntryProcessorResult<Integer> res : results.values()) {
+ Collection<ResourceType> notInjected1 = ResourceInfoSet.valueOf(res.get()).notInjected(required);
+
+ if (!notInjected1.isEmpty())
+ fail("Can't inject resource(s): " + Arrays.toString(notInjected1.toArray()));
+ }
+ }
+
+ /**
+ *
+ */
+ static class SpringResourceInjectionEntryProcessor extends ResourceInjectionEntryProcessorBase<String, Integer> {
+ /** */
+ private transient ApplicationContext appCtx;
+
+ /** */
+ private transient GridSpringResourceInjectionSelfTest.DummyResourceBean dummyBean;
+
+ /**
+ * @param appCtx Context.
+ */
+ @SpringApplicationContextResource
+ public void setApplicationContext(ApplicationContext appCtx) {
+ assert appCtx != null;
+
+ checkSet();
+
+ infoSet.set(ResourceType.SPRING_APPLICATION_CONTEXT, true);
+
+ this.appCtx = appCtx;
+ }
+
+ /**
+ * @param dummyBean Resource bean.
+ */
+ @SpringResource(resourceName = "dummyResourceBean")
+ public void setDummyBean(GridSpringResourceInjectionSelfTest.DummyResourceBean dummyBean) {
+ assert dummyBean != null;
+
+ checkSet();
+
+ infoSet.set(ResourceType.SPRING_BEAN, true);
+
+ this.dummyBean = dummyBean;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/f9ff97c9/modules/spring/src/test/java/org/apache/ignite/testsuites/IgniteSpringTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/spring/src/test/java/org/apache/ignite/testsuites/IgniteSpringTestSuite.java b/modules/spring/src/test/java/org/apache/ignite/testsuites/IgniteSpringTestSuite.java
index cd5645d..67b117d 100644
--- a/modules/spring/src/test/java/org/apache/ignite/testsuites/IgniteSpringTestSuite.java
+++ b/modules/spring/src/test/java/org/apache/ignite/testsuites/IgniteSpringTestSuite.java
@@ -18,17 +18,18 @@
package org.apache.ignite.testsuites;
import junit.framework.TestSuite;
+import org.apache.ignite.cache.spring.GridSpringCacheManagerSelfTest;
+import org.apache.ignite.cache.spring.SpringCacheManagerContextInjectionTest;
import org.apache.ignite.cache.store.jdbc.CacheJdbcBlobStoreFactorySelfTest;
import org.apache.ignite.cache.store.jdbc.CacheJdbcPojoStoreFactorySelfTest;
import org.apache.ignite.cache.store.spring.CacheSpringStoreSessionListenerSelfTest;
import org.apache.ignite.internal.GridFactorySelfTest;
import org.apache.ignite.internal.GridSpringBeanSerializationSelfTest;
import org.apache.ignite.internal.IgniteDynamicCacheConfigTest;
+import org.apache.ignite.internal.processors.resource.GridTransformSpringInjectionSelfTest;
import org.apache.ignite.p2p.GridP2PUserVersionChangeSelfTest;
-import org.apache.ignite.cache.spring.GridSpringCacheManagerSelfTest;
import org.apache.ignite.spring.IgniteExcludeInConfigurationTest;
import org.apache.ignite.spring.IgniteStartFromStreamConfigurationTest;
-import org.apache.ignite.cache.spring.SpringCacheManagerContextInjectionTest;
import org.apache.ignite.spring.injection.GridServiceInjectionSpringResourceTest;
import org.apache.ignite.transactions.spring.GridSpringTransactionManagerSelfTest;
import org.apache.ignite.transactions.spring.SpringTransactionManagerContextInjectionTest;
@@ -70,6 +71,8 @@ public class IgniteSpringTestSuite extends TestSuite {
suite.addTestSuite(GridServiceInjectionSpringResourceTest.class);
+ suite.addTestSuite(GridTransformSpringInjectionSelfTest.class);
+
suite.addTestSuite(SpringCacheManagerContextInjectionTest.class);
suite.addTestSuite(SpringTransactionManagerContextInjectionTest.class);
http://git-wip-us.apache.org/repos/asf/ignite/blob/f9ff97c9/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteInvokeWithInjectionBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteInvokeWithInjectionBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteInvokeWithInjectionBenchmark.java
new file mode 100644
index 0000000..ef9d17b
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteInvokeWithInjectionBenchmark.java
@@ -0,0 +1,74 @@
+/*
+ * 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.yardstick.cache;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CacheEntryProcessor;
+import org.apache.ignite.resources.IgniteInstanceResource;
+import org.apache.ignite.yardstick.cache.model.SampleValue;
+
+import javax.cache.processor.MutableEntry;
+import java.util.Map;
+
+/**
+ * Ignite benchmark that performs invoke operations.
+ */
+public class IgniteInvokeWithInjectionBenchmark extends IgniteCacheAbstractBenchmark<Integer, Object> {
+ /** {@inheritDoc} */
+ @Override public boolean test(Map<Object, Object> ctx) throws Exception {
+ int key = nextRandom(args.range());
+
+ cache.invoke(key, new SetValueEntryProcessor(new SampleValue(key)));
+
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected IgniteCache<Integer, Object> cache() {
+ return ignite().cache("atomic");
+ }
+
+ /**
+ *
+ */
+ public static class SetValueEntryProcessor implements CacheEntryProcessor<Integer, Object, Object> {
+ /** */
+ @IgniteInstanceResource
+ private transient Ignite ignite;
+
+ /** */
+ private Object val;
+
+ /**
+ * @param val Value.
+ */
+ public SetValueEntryProcessor(Object val) {
+ this.val = val;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Object process(MutableEntry<Integer, Object> entry, Object... args) {
+ assert ignite != null;
+
+ entry.setValue(val);
+
+ return null;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/f9ff97c9/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteInvokeWithInjectionTxBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteInvokeWithInjectionTxBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteInvokeWithInjectionTxBenchmark.java
new file mode 100644
index 0000000..2df93ee
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteInvokeWithInjectionTxBenchmark.java
@@ -0,0 +1,30 @@
+/*
+ * 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.yardstick.cache;
+
+import org.apache.ignite.IgniteCache;
+
+/**
+ * Ignite benchmark that performs invoke operations.
+ */
+public class IgniteInvokeWithInjectionTxBenchmark extends IgniteInvokeWithInjectionBenchmark {
+ /** {@inheritDoc} */
+ @Override protected IgniteCache<Integer, Object> cache() {
+ return ignite().cache("tx");
+ }
+}
[26/50] [abbrv] ignite git commit: Merge branch 'master' of
https://github.com/apache/ignite
Posted by sb...@apache.org.
Merge branch 'master' of https://github.com/apache/ignite
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/d98cd309
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/d98cd309
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/d98cd309
Branch: refs/heads/ignite-961
Commit: d98cd3093f4a494e10ebfe5ee0eb302650716a12
Parents: f89375b 76f26c1
Author: agura <ag...@gridgain.com>
Authored: Mon Aug 29 21:03:05 2016 +0300
Committer: agura <ag...@gridgain.com>
Committed: Mon Aug 29 21:03:05 2016 +0300
----------------------------------------------------------------------
.../Apache.Ignite.Core.Tests.TestDll.csproj | 5 ---
.../Cache/Affinity/AffinityFunctionContext.cs | 4 +--
.../Apache.Ignite.Core/Events/DiscoveryEvent.cs | 4 +--
.../Apache.Ignite.Core/Events/EventReader.cs | 6 ++--
.../Impl/Binary/DateTimeHolder.cs | 4 +--
.../Impl/Binary/Marshaller.cs | 36 ++++++++++----------
.../Impl/Binary/SerializableObjectHolder.cs | 6 ++--
.../Affinity/AffinityFunctionSerializer.cs | 2 +-
.../Impl/Cache/CacheEntryFilterHolder.cs | 10 +++---
.../Impl/Cache/CacheEntryProcessorHolder.cs | 8 ++---
.../Continuous/ContinuousQueryFilterHolder.cs | 8 ++---
.../Impl/Compute/Closure/ComputeActionJob.cs | 6 ++--
.../Impl/Compute/Closure/ComputeFuncJob.cs | 8 ++---
.../Impl/Compute/Closure/ComputeOutFuncJob.cs | 9 ++---
.../Impl/Compute/ComputeFunc.cs | 9 +++--
.../Impl/Compute/ComputeJob.cs | 10 +++---
.../Impl/Compute/ComputeJobHolder.cs | 8 ++---
.../Impl/Compute/ComputeOutFunc.cs | 8 ++---
.../Impl/Datastream/StreamReceiverHolder.cs | 2 +-
.../Apache.Ignite.Core/Impl/IgniteUtils.cs | 5 ++-
.../Impl/Messaging/MessageListenerHolder.cs | 8 ++---
.../Apache.Ignite.Linq.csproj | 5 ---
.../Apache.Ignite.NLog.csproj | 5 ---
.../dotnet/Apache.Ignite/Apache.Ignite.csproj | 5 ---
24 files changed, 70 insertions(+), 111 deletions(-)
----------------------------------------------------------------------
[24/50] [abbrv] ignite git commit: .NET: Get rid of extra
BinaryReader casts
Posted by sb...@apache.org.
.NET: Get rid of extra BinaryReader casts
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/76f26c1e
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/76f26c1e
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/76f26c1e
Branch: refs/heads/ignite-961
Commit: 76f26c1e6e2ec9c221717ccd98b5d92b89c66d14
Parents: db300ba
Author: Pavel Tupitsyn <pt...@apache.org>
Authored: Mon Aug 29 19:53:47 2016 +0300
Committer: Pavel Tupitsyn <pt...@apache.org>
Committed: Mon Aug 29 19:53:47 2016 +0300
----------------------------------------------------------------------
.../Cache/Affinity/AffinityFunctionContext.cs | 4 ++--
.../dotnet/Apache.Ignite.Core/Events/DiscoveryEvent.cs | 4 ++--
.../platforms/dotnet/Apache.Ignite.Core/Events/EventReader.cs | 6 +++---
.../Impl/Cache/Affinity/AffinityFunctionSerializer.cs | 2 +-
.../platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs | 5 ++---
5 files changed, 10 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/76f26c1e/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Affinity/AffinityFunctionContext.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Affinity/AffinityFunctionContext.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Affinity/AffinityFunctionContext.cs
index 6067af4..6f356f9 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Affinity/AffinityFunctionContext.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Affinity/AffinityFunctionContext.cs
@@ -19,10 +19,10 @@ namespace Apache.Ignite.Core.Cache.Affinity
{
using System.Collections.Generic;
using System.Diagnostics;
- using Apache.Ignite.Core.Binary;
using Apache.Ignite.Core.Cluster;
using Apache.Ignite.Core.Events;
using Apache.Ignite.Core.Impl;
+ using Apache.Ignite.Core.Impl.Binary;
/// <summary>
/// Affinity function context.
@@ -48,7 +48,7 @@ namespace Apache.Ignite.Core.Cache.Affinity
/// Initializes a new instance of the <see cref="AffinityFunctionContext"/> class.
/// </summary>
/// <param name="reader">The reader.</param>
- internal AffinityFunctionContext(IBinaryRawReader reader)
+ internal AffinityFunctionContext(BinaryReader reader)
{
Debug.Assert(reader != null);
http://git-wip-us.apache.org/repos/asf/ignite/blob/76f26c1e/modules/platforms/dotnet/Apache.Ignite.Core/Events/DiscoveryEvent.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Events/DiscoveryEvent.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Events/DiscoveryEvent.cs
index 5c163a2..011febf 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Events/DiscoveryEvent.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Events/DiscoveryEvent.cs
@@ -20,9 +20,9 @@ namespace Apache.Ignite.Core.Events
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Globalization;
- using Apache.Ignite.Core.Binary;
using Apache.Ignite.Core.Cluster;
using Apache.Ignite.Core.Impl;
+ using Apache.Ignite.Core.Impl.Binary;
/// <summary>
/// Grid discovery event.
@@ -42,7 +42,7 @@ namespace Apache.Ignite.Core.Events
/// Constructor.
/// </summary>
/// <param name="r">The reader to read data from.</param>
- internal DiscoveryEvent(IBinaryRawReader r) : base(r)
+ internal DiscoveryEvent(BinaryReader r) : base(r)
{
_eventNode = ReadNode(r);
_topologyVersion = r.ReadLong();
http://git-wip-us.apache.org/repos/asf/ignite/blob/76f26c1e/modules/platforms/dotnet/Apache.Ignite.Core/Events/EventReader.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Events/EventReader.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Events/EventReader.cs
index ee1c837..269e0bb 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Events/EventReader.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Events/EventReader.cs
@@ -18,7 +18,7 @@
namespace Apache.Ignite.Core.Events
{
using System;
- using Apache.Ignite.Core.Binary;
+ using Apache.Ignite.Core.Impl.Binary;
/// <summary>
/// Event reader.
@@ -32,7 +32,7 @@ namespace Apache.Ignite.Core.Events
/// <param name="reader">Reader.</param>
/// <returns>Deserialized event.</returns>
/// <exception cref="System.InvalidCastException">Incompatible event type.</exception>
- public static T Read<T>(IBinaryRawReader reader) where T : IEvent
+ public static T Read<T>(BinaryReader reader) where T : IEvent
{
var clsId = reader.ReadInt();
@@ -49,7 +49,7 @@ namespace Apache.Ignite.Core.Events
/// <param name="reader">Reader.</param>
/// <returns>Created and deserialized instance.</returns>
/// <exception cref="System.InvalidOperationException">Invalid event class id: + clsId</exception>
- private static IEvent CreateInstance(int clsId, IBinaryRawReader reader)
+ private static IEvent CreateInstance(int clsId, BinaryReader reader)
{
switch (clsId)
{
http://git-wip-us.apache.org/repos/asf/ignite/blob/76f26c1e/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Affinity/AffinityFunctionSerializer.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Affinity/AffinityFunctionSerializer.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Affinity/AffinityFunctionSerializer.cs
index 888445a..5d940c5 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Affinity/AffinityFunctionSerializer.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Affinity/AffinityFunctionSerializer.cs
@@ -209,7 +209,7 @@ namespace Apache.Ignite.Core.Impl.Cache.Affinity
Debug.Assert(stream != null);
Debug.Assert(marsh != null);
- IBinaryRawReader reader = marsh.StartUnmarshal(stream);
+ var reader = marsh.StartUnmarshal(stream);
var partCnt = reader.ReadInt();
http://git-wip-us.apache.org/repos/asf/ignite/blob/76f26c1e/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
index 04296c7..a5a3129 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
@@ -27,7 +27,6 @@ namespace Apache.Ignite.Core.Impl
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
- using Apache.Ignite.Core.Binary;
using Apache.Ignite.Core.Cluster;
using Apache.Ignite.Core.Common;
using Apache.Ignite.Core.Impl.Binary;
@@ -464,7 +463,7 @@ namespace Apache.Ignite.Core.Impl
/// <param name="reader">Reader.</param>
/// <param name="pred">The predicate.</param>
/// <returns> Nodes list or null. </returns>
- public static List<IClusterNode> ReadNodes(IBinaryRawReader reader, Func<ClusterNodeImpl, bool> pred = null)
+ public static List<IClusterNode> ReadNodes(BinaryReader reader, Func<ClusterNodeImpl, bool> pred = null)
{
var cnt = reader.ReadInt();
@@ -473,7 +472,7 @@ namespace Apache.Ignite.Core.Impl
var res = new List<IClusterNode>(cnt);
- var ignite = ((BinaryReader)reader).Marshaller.Ignite;
+ var ignite = reader.Marshaller.Ignite;
if (pred == null)
{
[17/50] [abbrv] ignite git commit: IGNITE-3773: ODBC: Added tests for
UUID data type. This closes #993.
Posted by sb...@apache.org.
IGNITE-3773: ODBC: Added tests for UUID data type. This closes #993.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/28917034
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/28917034
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/28917034
Branch: refs/heads/ignite-961
Commit: 289170346e40a89243b80d3743c1b66543a117ef
Parents: b575764
Author: Igor Sapego <is...@gridgain.com>
Authored: Mon Aug 29 15:00:08 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Mon Aug 29 15:00:08 2016 +0300
----------------------------------------------------------------------
.../processors/odbc/escape/OdbcEscapeUtils.java | 2 +-
modules/platforms/cpp/odbc-test/Makefile.am | 5 +-
.../platforms/cpp/odbc-test/include/Makefile.am | 2 +-
.../include/sql_function_test_suite_fixture.h | 188 -------------
.../odbc-test/include/sql_test_suite_fixture.h | 191 +++++++++++++
.../cpp/odbc-test/project/vs/odbc-test.vcxproj | 7 +-
.../project/vs/odbc-test.vcxproj.filters | 13 +-
.../src/sql_aggregate_functions_test.cpp | 4 +-
.../src/sql_function_test_suite_fixture.cpp | 252 -----------------
.../src/sql_numeric_functions_test.cpp | 4 +-
.../cpp/odbc-test/src/sql_operators_test.cpp | 4 +-
.../odbc-test/src/sql_string_functions_test.cpp | 4 +-
.../odbc-test/src/sql_system_functions_test.cpp | 4 +-
.../odbc-test/src/sql_test_suite_fixture.cpp | 271 +++++++++++++++++++
.../cpp/odbc-test/src/sql_types_test.cpp | 60 ++++
.../cpp/odbc-test/src/sql_value_expressions.cpp | 94 -------
.../src/sql_value_expressions_test.cpp | 94 +++++++
17 files changed, 643 insertions(+), 556 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/28917034/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/escape/OdbcEscapeUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/escape/OdbcEscapeUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/escape/OdbcEscapeUtils.java
index 4c1deb6..a4b89c3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/escape/OdbcEscapeUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/escape/OdbcEscapeUtils.java
@@ -291,7 +291,7 @@ public class OdbcEscapeUtils {
if (!pattern.matcher(val).matches())
throw new IgniteException("Invalid " + type + " escape sequence: " + substring(text, startPos, len));
- return val;
+ return "CAST(" + val + " AS UUID)";
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/28917034/modules/platforms/cpp/odbc-test/Makefile.am
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/Makefile.am b/modules/platforms/cpp/odbc-test/Makefile.am
index a3f954e..de8fb5d 100644
--- a/modules/platforms/cpp/odbc-test/Makefile.am
+++ b/modules/platforms/cpp/odbc-test/Makefile.am
@@ -62,13 +62,14 @@ ignite_odbc_tests_SOURCES = \
src/utility_test.cpp \
src/queries_test.cpp \
src/test_utils.cpp \
- src/sql_function_test_suite_fixture.cpp \
+ src/sql_test_suite_fixture.cpp \
src/sql_string_functions_test.cpp \
src/sql_numeric_functions_test.cpp \
src/sql_aggregate_functions_test.cpp \
src/sql_system_functions_test.cpp \
src/sql_operators_test.cpp \
- src/sql_value_expressions.cpp \
+ src/sql_value_expressions_test.cpp \
+ src/sql_types_test.cpp \
../odbc/src/cursor.cpp \
../odbc/src/config/connection_info.cpp \
../odbc/src/app/application_data_buffer.cpp \
http://git-wip-us.apache.org/repos/asf/ignite/blob/28917034/modules/platforms/cpp/odbc-test/include/Makefile.am
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/include/Makefile.am b/modules/platforms/cpp/odbc-test/include/Makefile.am
index baca1b7..832103c 100644
--- a/modules/platforms/cpp/odbc-test/include/Makefile.am
+++ b/modules/platforms/cpp/odbc-test/include/Makefile.am
@@ -21,5 +21,5 @@ noinst_HEADERS = \
teamcity/teamcity_messages.h \
test_type.h \
test_utils.h \
- sql_function_test_suite_fixture.h
+ sql_test_suite_fixture.h
http://git-wip-us.apache.org/repos/asf/ignite/blob/28917034/modules/platforms/cpp/odbc-test/include/sql_function_test_suite_fixture.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/include/sql_function_test_suite_fixture.h b/modules/platforms/cpp/odbc-test/include/sql_function_test_suite_fixture.h
deleted file mode 100644
index 57c3f0f..0000000
--- a/modules/platforms/cpp/odbc-test/include/sql_function_test_suite_fixture.h
+++ /dev/null
@@ -1,188 +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.
- */
-
-#ifndef _IGNITE_ODBC_TEST_SQL_FUNCTION_TEST_FIXTURE
-#define _IGNITE_ODBC_TEST_SQL_FUNCTION_TEST_FIXTURE
-
-#ifdef _WIN32
-# include <windows.h>
-#endif
-
-#include <sql.h>
-#include <sqlext.h>
-
-#include <string>
-
-#ifndef _MSC_VER
-# define BOOST_TEST_DYN_LINK
-#endif
-
-#include <boost/test/unit_test.hpp>
-
-#include "ignite/ignite.h"
-#include "ignite/ignition.h"
-
-#include "test_type.h"
-
-namespace ignite
-{
- /**
- * Test setup fixture.
- */
- struct SqlFunctionTestSuiteFixture
- {
- /**
- * Constructor.
- */
- SqlFunctionTestSuiteFixture();
-
- /**
- * Destructor.
- */
- ~SqlFunctionTestSuiteFixture();
-
- /**
- * Run query returning single result and stores it to buffer.
- *
- * @param request SQL request.
- * @param type Result type.
- * @param column Result buffer.
- * @param bufSize Result buffer size.
- * @param resSize Size of received value.
- */
- void CheckSingleResult0(const char* request, SQLSMALLINT type,
- void* column, SQLLEN bufSize, SQLLEN* resSize) const;
-
- /**
- * Run query returning single result and check it to be equal to expected.
- *
- * @param request SQL request.
- * @param expected Expected result.
- */
- template<typename T>
- void CheckSingleResult(const char* request, const T& expected)
- {
- BOOST_FAIL("Function is not defined for the type.");
- }
-
- /**
- * Run query returning single result and check it to be successful.
- *
- * @param request SQL request.
- */
- template<typename T>
- void CheckSingleResult(const char* request)
- {
- BOOST_FAIL("Function is not defined for the type.");
- }
-
- /**
- * Run query returning single result and check it to be equal to expected.
- *
- * @param request SQL request.
- * @param expected Expected result.
- * @param type Result type.
- */
- template<typename T>
- void CheckSingleResultNum0(const char* request, const T& expected, SQLSMALLINT type)
- {
- T res = 0;
-
- CheckSingleResult0(request, type, &res, 0, 0);
-
- BOOST_CHECK_EQUAL(res, expected);
- }
-
- /**
- * Run query returning single result and check it to be equal to expected.
- *
- * @param request SQL request.
- * @param expected Expected result.
- * @param type Result type.
- */
- template<typename T>
- void CheckSingleResultNum0(const char* request, SQLSMALLINT type)
- {
- T res = 0;
-
- CheckSingleResult0(request, type, &res, 0, 0);
- }
-
-
- /** Node started during the test. */
- Ignite grid;
-
- /** Test cache instance. */
- cache::Cache<int64_t, TestType> testCache;
-
- /** ODBC Environment. */
- SQLHENV env;
-
- /** ODBC Connect. */
- SQLHDBC dbc;
-
- /** ODBC Statement. */
- SQLHSTMT stmt;
- };
-
- template<>
- void SqlFunctionTestSuiteFixture::CheckSingleResult<std::string>(const char* request, const std::string& expected);
-
- template<>
- void SqlFunctionTestSuiteFixture::CheckSingleResult<int64_t>(const char* request, const int64_t& expected);
-
- template<>
- void SqlFunctionTestSuiteFixture::CheckSingleResult<int32_t>(const char* request, const int32_t& expected);
-
- template<>
- void SqlFunctionTestSuiteFixture::CheckSingleResult<int16_t>(const char* request, const int16_t& expected);
-
- template<>
- void SqlFunctionTestSuiteFixture::CheckSingleResult<int8_t>(const char* request, const int8_t& expected);
-
- template<>
- void SqlFunctionTestSuiteFixture::CheckSingleResult<float>(const char* request, const float& expected);
-
- template<>
- void SqlFunctionTestSuiteFixture::CheckSingleResult<double>(const char* request, const double& expected);
-
- template<>
- void SqlFunctionTestSuiteFixture::CheckSingleResult<bool>(const char* request, const bool& expected);
-
- template<>
- void SqlFunctionTestSuiteFixture::CheckSingleResult<std::string>(const char* request);
-
- template<>
- void SqlFunctionTestSuiteFixture::CheckSingleResult<int64_t>(const char* request);
-
- template<>
- void SqlFunctionTestSuiteFixture::CheckSingleResult<int32_t>(const char* request);
-
- template<>
- void SqlFunctionTestSuiteFixture::CheckSingleResult<int16_t>(const char* request);
-
- template<>
- void SqlFunctionTestSuiteFixture::CheckSingleResult<int8_t>(const char* request);
-
- template<>
- void SqlFunctionTestSuiteFixture::CheckSingleResult<float>(const char* request);
-
- template<>
- void SqlFunctionTestSuiteFixture::CheckSingleResult<double>(const char* request);
-}
-
-#endif //_IGNITE_ODBC_TEST_SQL_FUNCTION_TEST_FIXTURE
http://git-wip-us.apache.org/repos/asf/ignite/blob/28917034/modules/platforms/cpp/odbc-test/include/sql_test_suite_fixture.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/include/sql_test_suite_fixture.h b/modules/platforms/cpp/odbc-test/include/sql_test_suite_fixture.h
new file mode 100644
index 0000000..9e482da
--- /dev/null
+++ b/modules/platforms/cpp/odbc-test/include/sql_test_suite_fixture.h
@@ -0,0 +1,191 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_ODBC_TEST_SQL_TEST_SUIT_FIXTURE
+#define _IGNITE_ODBC_TEST_SQL_TEST_SUIT_FIXTURE
+
+#ifdef _WIN32
+# include <windows.h>
+#endif
+
+#include <sql.h>
+#include <sqlext.h>
+
+#include <string>
+
+#ifndef _MSC_VER
+# define BOOST_TEST_DYN_LINK
+#endif
+
+#include <boost/test/unit_test.hpp>
+
+#include "ignite/ignite.h"
+#include "ignite/ignition.h"
+
+#include "test_type.h"
+
+namespace ignite
+{
+ /**
+ * Test setup fixture.
+ */
+ struct SqlTestSuiteFixture
+ {
+ /**
+ * Constructor.
+ */
+ SqlTestSuiteFixture();
+
+ /**
+ * Destructor.
+ */
+ ~SqlTestSuiteFixture();
+
+ /**
+ * Run query returning single result and stores it to buffer.
+ *
+ * @param request SQL request.
+ * @param type Result type.
+ * @param column Result buffer.
+ * @param bufSize Result buffer size.
+ * @param resSize Size of received value.
+ */
+ void CheckSingleResult0(const char* request, SQLSMALLINT type,
+ void* column, SQLLEN bufSize, SQLLEN* resSize) const;
+
+ /**
+ * Run query returning single result and check it to be equal to expected.
+ *
+ * @param request SQL request.
+ * @param expected Expected result.
+ */
+ template<typename T>
+ void CheckSingleResult(const char* request, const T& expected)
+ {
+ BOOST_FAIL("Function is not defined for the type.");
+ }
+
+ /**
+ * Run query returning single result and check it to be successful.
+ *
+ * @param request SQL request.
+ */
+ template<typename T>
+ void CheckSingleResult(const char* request)
+ {
+ BOOST_FAIL("Function is not defined for the type.");
+ }
+
+ /**
+ * Run query returning single result and check it to be equal to expected.
+ *
+ * @param request SQL request.
+ * @param expected Expected result.
+ * @param type Result type.
+ */
+ template<typename T>
+ void CheckSingleResultNum0(const char* request, const T& expected, SQLSMALLINT type)
+ {
+ T res = 0;
+
+ CheckSingleResult0(request, type, &res, 0, 0);
+
+ BOOST_CHECK_EQUAL(res, expected);
+ }
+
+ /**
+ * Run query returning single result and check it to be equal to expected.
+ *
+ * @param request SQL request.
+ * @param expected Expected result.
+ * @param type Result type.
+ */
+ template<typename T>
+ void CheckSingleResultNum0(const char* request, SQLSMALLINT type)
+ {
+ T res = 0;
+
+ CheckSingleResult0(request, type, &res, 0, 0);
+ }
+
+
+ /** Node started during the test. */
+ Ignite grid;
+
+ /** Test cache instance. */
+ cache::Cache<int64_t, TestType> testCache;
+
+ /** ODBC Environment. */
+ SQLHENV env;
+
+ /** ODBC Connect. */
+ SQLHDBC dbc;
+
+ /** ODBC Statement. */
+ SQLHSTMT stmt;
+ };
+
+ template<>
+ void SqlTestSuiteFixture::CheckSingleResult<std::string>(const char* request, const std::string& expected);
+
+ template<>
+ void SqlTestSuiteFixture::CheckSingleResult<int64_t>(const char* request, const int64_t& expected);
+
+ template<>
+ void SqlTestSuiteFixture::CheckSingleResult<int32_t>(const char* request, const int32_t& expected);
+
+ template<>
+ void SqlTestSuiteFixture::CheckSingleResult<int16_t>(const char* request, const int16_t& expected);
+
+ template<>
+ void SqlTestSuiteFixture::CheckSingleResult<int8_t>(const char* request, const int8_t& expected);
+
+ template<>
+ void SqlTestSuiteFixture::CheckSingleResult<float>(const char* request, const float& expected);
+
+ template<>
+ void SqlTestSuiteFixture::CheckSingleResult<double>(const char* request, const double& expected);
+
+ template<>
+ void SqlTestSuiteFixture::CheckSingleResult<bool>(const char* request, const bool& expected);
+
+ template<>
+ void SqlTestSuiteFixture::CheckSingleResult<ignite::Guid>(const char* request, const ignite::Guid& expected);
+
+ template<>
+ void SqlTestSuiteFixture::CheckSingleResult<std::string>(const char* request);
+
+ template<>
+ void SqlTestSuiteFixture::CheckSingleResult<int64_t>(const char* request);
+
+ template<>
+ void SqlTestSuiteFixture::CheckSingleResult<int32_t>(const char* request);
+
+ template<>
+ void SqlTestSuiteFixture::CheckSingleResult<int16_t>(const char* request);
+
+ template<>
+ void SqlTestSuiteFixture::CheckSingleResult<int8_t>(const char* request);
+
+ template<>
+ void SqlTestSuiteFixture::CheckSingleResult<float>(const char* request);
+
+ template<>
+ void SqlTestSuiteFixture::CheckSingleResult<double>(const char* request);
+}
+
+#endif //_IGNITE_ODBC_TEST_SQL_TEST_SUIT_FIXTURE
http://git-wip-us.apache.org/repos/asf/ignite/blob/28917034/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj b/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj
index 8b4bee6..a9423ca 100644
--- a/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj
+++ b/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj
@@ -169,19 +169,20 @@
<ClCompile Include="..\..\src\parser_test.cpp" />
<ClCompile Include="..\..\src\row_test.cpp" />
<ClCompile Include="..\..\src\sql_aggregate_functions_test.cpp" />
- <ClCompile Include="..\..\src\sql_function_test_suite_fixture.cpp" />
+ <ClCompile Include="..\..\src\sql_test_suite_fixture.cpp" />
<ClCompile Include="..\..\src\sql_numeric_functions_test.cpp" />
<ClCompile Include="..\..\src\sql_operators_test.cpp" />
<ClCompile Include="..\..\src\sql_string_functions_test.cpp" />
<ClCompile Include="..\..\src\sql_system_functions_test.cpp" />
- <ClCompile Include="..\..\src\sql_value_expressions.cpp" />
+ <ClCompile Include="..\..\src\sql_types_test.cpp" />
+ <ClCompile Include="..\..\src\sql_value_expressions_test.cpp" />
<ClCompile Include="..\..\src\teamcity\teamcity_boost.cpp" />
<ClCompile Include="..\..\src\teamcity\teamcity_messages.cpp" />
<ClCompile Include="..\..\src\test_utils.cpp" />
<ClCompile Include="..\..\src\utility_test.cpp" />
</ItemGroup>
<ItemGroup>
- <ClInclude Include="..\..\include\sql_function_test_suite_fixture.h" />
+ <ClInclude Include="..\..\include\sql_test_suite_fixture.h" />
<ClInclude Include="..\..\include\teamcity\teamcity_messages.h" />
<ClInclude Include="..\..\include\test_type.h" />
<ClInclude Include="..\..\include\test_utils.h" />
http://git-wip-us.apache.org/repos/asf/ignite/blob/28917034/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters b/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters
index 4756f83..84f5a29 100644
--- a/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters
+++ b/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters
@@ -85,9 +85,6 @@
<ClCompile Include="..\..\src\sql_numeric_functions_test.cpp">
<Filter>Code</Filter>
</ClCompile>
- <ClCompile Include="..\..\src\sql_function_test_suite_fixture.cpp">
- <Filter>Code</Filter>
- </ClCompile>
<ClCompile Include="..\..\src\sql_aggregate_functions_test.cpp">
<Filter>Code</Filter>
</ClCompile>
@@ -97,7 +94,13 @@
<ClCompile Include="..\..\src\sql_operators_test.cpp">
<Filter>Code</Filter>
</ClCompile>
- <ClCompile Include="..\..\src\sql_value_expressions.cpp">
+ <ClCompile Include="..\..\src\sql_types_test.cpp">
+ <Filter>Code</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\sql_test_suite_fixture.cpp">
+ <Filter>Code</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\sql_value_expressions_test.cpp">
<Filter>Code</Filter>
</ClCompile>
</ItemGroup>
@@ -111,7 +114,7 @@
<ClInclude Include="..\..\include\test_utils.h">
<Filter>Code</Filter>
</ClInclude>
- <ClInclude Include="..\..\include\sql_function_test_suite_fixture.h">
+ <ClInclude Include="..\..\include\sql_test_suite_fixture.h">
<Filter>Code</Filter>
</ClInclude>
</ItemGroup>
http://git-wip-us.apache.org/repos/asf/ignite/blob/28917034/modules/platforms/cpp/odbc-test/src/sql_aggregate_functions_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/sql_aggregate_functions_test.cpp b/modules/platforms/cpp/odbc-test/src/sql_aggregate_functions_test.cpp
index 6254913..3fa4d97 100644
--- a/modules/platforms/cpp/odbc-test/src/sql_aggregate_functions_test.cpp
+++ b/modules/platforms/cpp/odbc-test/src/sql_aggregate_functions_test.cpp
@@ -41,7 +41,7 @@
#include "test_type.h"
#include "test_utils.h"
-#include "sql_function_test_suite_fixture.h"
+#include "sql_test_suite_fixture.h"
using namespace ignite;
using namespace ignite::cache;
@@ -52,7 +52,7 @@ using namespace boost::unit_test;
using ignite::impl::binary::BinaryUtils;
-BOOST_FIXTURE_TEST_SUITE(SqlAggregateFunctionTestSuite, ignite::SqlFunctionTestSuiteFixture)
+BOOST_FIXTURE_TEST_SUITE(SqlAggregateFunctionTestSuite, ignite::SqlTestSuiteFixture)
BOOST_AUTO_TEST_CASE(TestAggregateFunctionAvgInt)
{
http://git-wip-us.apache.org/repos/asf/ignite/blob/28917034/modules/platforms/cpp/odbc-test/src/sql_function_test_suite_fixture.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/sql_function_test_suite_fixture.cpp b/modules/platforms/cpp/odbc-test/src/sql_function_test_suite_fixture.cpp
deleted file mode 100644
index d6b175f..0000000
--- a/modules/platforms/cpp/odbc-test/src/sql_function_test_suite_fixture.cpp
+++ /dev/null
@@ -1,252 +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.
- */
-
-#include "sql_function_test_suite_fixture.h"
-
-#include "test_utils.h"
-
-namespace ignite
-{
- SqlFunctionTestSuiteFixture::SqlFunctionTestSuiteFixture():
- testCache(0),
- env(NULL),
- dbc(NULL),
- stmt(NULL)
- {
- IgniteConfiguration cfg;
-
- cfg.jvmOpts.push_back("-Xdebug");
- cfg.jvmOpts.push_back("-Xnoagent");
- cfg.jvmOpts.push_back("-Djava.compiler=NONE");
- cfg.jvmOpts.push_back("-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005");
- cfg.jvmOpts.push_back("-XX:+HeapDumpOnOutOfMemoryError");
-
-#ifdef IGNITE_TESTS_32
- cfg.jvmInitMem = 256;
- cfg.jvmMaxMem = 768;
-#else
- cfg.jvmInitMem = 1024;
- cfg.jvmMaxMem = 4096;
-#endif
-
- char* cfgPath = getenv("IGNITE_NATIVE_TEST_ODBC_CONFIG_PATH");
-
- BOOST_REQUIRE(cfgPath != 0) ;
-
- cfg.springCfgPath.assign(cfgPath).append("/queries-test.xml");
-
- IgniteError err;
-
- grid = Ignition::Start(cfg, &err);
-
- if (err.GetCode() != IgniteError::IGNITE_SUCCESS)
- BOOST_FAIL(err.GetText()) ;
-
- testCache = grid.GetCache<int64_t, TestType>("cache");
-
- // Allocate an environment handle
- SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env);
-
- BOOST_REQUIRE(env != NULL) ;
-
- // We want ODBC 3 support
- SQLSetEnvAttr(env, SQL_ATTR_ODBC_VERSION, reinterpret_cast<void*>(SQL_OV_ODBC3), 0);
-
- // Allocate a connection handle
- SQLAllocHandle(SQL_HANDLE_DBC, env, &dbc);
-
- BOOST_REQUIRE(dbc != NULL) ;
-
- // Connect string
- SQLCHAR connectStr[] = "DRIVER={Apache Ignite};SERVER=localhost;PORT=10800;CACHE=cache";
-
- SQLCHAR outstr[ODBC_BUFFER_SIZE];
- SQLSMALLINT outstrlen;
-
- // Connecting to ODBC server.
- SQLRETURN ret = SQLDriverConnect(dbc, NULL, connectStr, static_cast<SQLSMALLINT>(sizeof(connectStr)),
- outstr, sizeof(outstr), &outstrlen, SQL_DRIVER_COMPLETE);
-
- if (!SQL_SUCCEEDED(ret))
- {
- Ignition::Stop(grid.GetName(), true);
-
- BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_DBC, dbc)) ;
- }
-
- // Allocate a statement handle
- SQLAllocHandle(SQL_HANDLE_STMT, dbc, &stmt);
-
- BOOST_REQUIRE(stmt != NULL) ;
- }
-
- SqlFunctionTestSuiteFixture::~SqlFunctionTestSuiteFixture()
- {
- // Releasing statement handle.
- SQLFreeHandle(SQL_HANDLE_STMT, stmt);
-
- // Disconneting from the server.
- SQLDisconnect(dbc);
-
- // Releasing allocated handles.
- SQLFreeHandle(SQL_HANDLE_DBC, dbc);
- SQLFreeHandle(SQL_HANDLE_ENV, env);
-
- ignite::Ignition::Stop(grid.GetName(), true);
- }
-
- void SqlFunctionTestSuiteFixture::CheckSingleResult0(const char* request,
- SQLSMALLINT type, void* column, SQLLEN bufSize, SQLLEN* resSize) const
- {
- SQLRETURN ret;
-
- ret = SQLBindCol(stmt, 1, type, column, bufSize, resSize);
-
- if (!SQL_SUCCEEDED(ret))
- BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt)) ;
-
- ret = SQLExecDirect(stmt, reinterpret_cast<SQLCHAR*>(const_cast<char*>(request)), SQL_NTS);
- if (!SQL_SUCCEEDED(ret))
- BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt)) ;
-
- ret = SQLFetch(stmt);
- if (!SQL_SUCCEEDED(ret))
- BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt)) ;
-
- ret = SQLFetch(stmt);
- BOOST_CHECK(ret == SQL_NO_DATA) ;
- }
-
- template<>
- void SqlFunctionTestSuiteFixture::CheckSingleResult<std::string>(const char* request, const std::string& expected)
- {
- SQLCHAR res[ODBC_BUFFER_SIZE] = { 0 };
- SQLLEN resLen = 0;
-
- CheckSingleResult0(request, SQL_C_CHAR, res, ODBC_BUFFER_SIZE, &resLen);
-
- std::string actual;
-
- if (resLen > 0)
- actual.assign(reinterpret_cast<char*>(res), static_cast<size_t>(resLen));
-
- BOOST_CHECK_EQUAL(actual, expected);
- }
-
- template<>
- void SqlFunctionTestSuiteFixture::CheckSingleResult<int64_t>(const char* request, const int64_t& expected)
- {
- CheckSingleResultNum0<int64_t>(request, expected, SQL_C_SBIGINT);
- }
-
- template<>
- void SqlFunctionTestSuiteFixture::CheckSingleResult<int32_t>(const char* request, const int32_t& expected)
- {
- CheckSingleResultNum0<int32_t>(request, expected, SQL_C_SLONG);
- }
-
- template<>
- void SqlFunctionTestSuiteFixture::CheckSingleResult<int16_t>(const char* request, const int16_t& expected)
- {
- CheckSingleResultNum0<int16_t>(request, expected, SQL_C_SSHORT);
- }
-
- template<>
- void SqlFunctionTestSuiteFixture::CheckSingleResult<int8_t>(const char* request, const int8_t& expected)
- {
- CheckSingleResultNum0<int8_t>(request, expected, SQL_C_STINYINT);
- }
-
- template<>
- void SqlFunctionTestSuiteFixture::CheckSingleResult<float>(const char* request, const float& expected)
- {
- SQLFLOAT res = 0;
-
- CheckSingleResult0(request, SQL_C_FLOAT, &res, 0, 0);
-
- BOOST_CHECK_CLOSE(static_cast<float>(res), expected, 1E-6f);
- }
-
- template<>
- void SqlFunctionTestSuiteFixture::CheckSingleResult<double>(const char* request, const double& expected)
- {
- SQLDOUBLE res = 0;
-
- CheckSingleResult0(request, SQL_C_DOUBLE, &res, 0, 0);
-
- BOOST_CHECK_CLOSE(static_cast<double>(res), expected, 1E-6);
- }
-
- template<>
- void SqlFunctionTestSuiteFixture::CheckSingleResult<bool>(const char* request, const bool& expected)
- {
- SQLCHAR res = 0;
-
- CheckSingleResult0(request, SQL_C_BIT, &res, 0, 0);
-
- BOOST_CHECK_EQUAL((res != 0), expected);
- }
-
- template<>
- void SqlFunctionTestSuiteFixture::CheckSingleResult<std::string>(const char* request)
- {
- SQLCHAR res[ODBC_BUFFER_SIZE] = { 0 };
- SQLLEN resLen = 0;
-
- CheckSingleResult0(request, SQL_C_CHAR, res, ODBC_BUFFER_SIZE, &resLen);
- }
-
- template<>
- void SqlFunctionTestSuiteFixture::CheckSingleResult<int64_t>(const char* request)
- {
- CheckSingleResultNum0<int64_t>(request, SQL_C_SBIGINT);
- }
-
- template<>
- void SqlFunctionTestSuiteFixture::CheckSingleResult<int32_t>(const char* request)
- {
- CheckSingleResultNum0<int32_t>(request, SQL_C_SLONG);
- }
-
- template<>
- void SqlFunctionTestSuiteFixture::CheckSingleResult<int16_t>(const char* request)
- {
- CheckSingleResultNum0<int16_t>(request, SQL_C_SSHORT);
- }
-
- template<>
- void SqlFunctionTestSuiteFixture::CheckSingleResult<int8_t>(const char* request)
- {
- CheckSingleResultNum0<int8_t>(request, SQL_C_STINYINT);
- }
-
- template<>
- void SqlFunctionTestSuiteFixture::CheckSingleResult<float>(const char* request)
- {
- SQLFLOAT res = 0;
-
- CheckSingleResult0(request, SQL_C_FLOAT, &res, 0, 0);
- }
-
- template<>
- void SqlFunctionTestSuiteFixture::CheckSingleResult<double>(const char* request)
- {
- SQLDOUBLE res = 0;
-
- CheckSingleResult0(request, SQL_C_DOUBLE, &res, 0, 0);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/28917034/modules/platforms/cpp/odbc-test/src/sql_numeric_functions_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/sql_numeric_functions_test.cpp b/modules/platforms/cpp/odbc-test/src/sql_numeric_functions_test.cpp
index 80ffd83..e16d8c1 100644
--- a/modules/platforms/cpp/odbc-test/src/sql_numeric_functions_test.cpp
+++ b/modules/platforms/cpp/odbc-test/src/sql_numeric_functions_test.cpp
@@ -41,7 +41,7 @@
#include "test_type.h"
#include "test_utils.h"
-#include "sql_function_test_suite_fixture.h"
+#include "sql_test_suite_fixture.h"
using namespace ignite;
using namespace ignite::cache;
@@ -52,7 +52,7 @@ using namespace boost::unit_test;
using ignite::impl::binary::BinaryUtils;
-BOOST_FIXTURE_TEST_SUITE(SqlNumericFunctionTestSuite, ignite::SqlFunctionTestSuiteFixture)
+BOOST_FIXTURE_TEST_SUITE(SqlNumericFunctionTestSuite, ignite::SqlTestSuiteFixture)
BOOST_AUTO_TEST_CASE(TestNumericFunctionAbs)
{
http://git-wip-us.apache.org/repos/asf/ignite/blob/28917034/modules/platforms/cpp/odbc-test/src/sql_operators_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/sql_operators_test.cpp b/modules/platforms/cpp/odbc-test/src/sql_operators_test.cpp
index db3d3f7..de884ca 100644
--- a/modules/platforms/cpp/odbc-test/src/sql_operators_test.cpp
+++ b/modules/platforms/cpp/odbc-test/src/sql_operators_test.cpp
@@ -29,12 +29,12 @@
#include <boost/test/unit_test.hpp>
#include "test_type.h"
-#include "sql_function_test_suite_fixture.h"
+#include "sql_test_suite_fixture.h"
#include <ignite/common/decimal.h>
using namespace ignite;
-BOOST_FIXTURE_TEST_SUITE(SqlOperatorTestSuite, ignite::SqlFunctionTestSuiteFixture)
+BOOST_FIXTURE_TEST_SUITE(SqlOperatorTestSuite, ignite::SqlTestSuiteFixture)
BOOST_AUTO_TEST_CASE(TestOperatorAddInt)
{
http://git-wip-us.apache.org/repos/asf/ignite/blob/28917034/modules/platforms/cpp/odbc-test/src/sql_string_functions_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/sql_string_functions_test.cpp b/modules/platforms/cpp/odbc-test/src/sql_string_functions_test.cpp
index d22bb83..d1ce194 100644
--- a/modules/platforms/cpp/odbc-test/src/sql_string_functions_test.cpp
+++ b/modules/platforms/cpp/odbc-test/src/sql_string_functions_test.cpp
@@ -37,7 +37,7 @@
#include "test_type.h"
#include "test_utils.h"
-#include "sql_function_test_suite_fixture.h"
+#include "sql_test_suite_fixture.h"
using namespace ignite;
using namespace ignite::cache;
@@ -48,7 +48,7 @@ using namespace boost::unit_test;
using ignite::impl::binary::BinaryUtils;
-BOOST_FIXTURE_TEST_SUITE(SqlStringFunctionTestSuite, ignite::SqlFunctionTestSuiteFixture)
+BOOST_FIXTURE_TEST_SUITE(SqlStringFunctionTestSuite, ignite::SqlTestSuiteFixture)
BOOST_AUTO_TEST_CASE(TestStringFunctionAscii)
{
http://git-wip-us.apache.org/repos/asf/ignite/blob/28917034/modules/platforms/cpp/odbc-test/src/sql_system_functions_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/sql_system_functions_test.cpp b/modules/platforms/cpp/odbc-test/src/sql_system_functions_test.cpp
index 752925d..30fa036 100644
--- a/modules/platforms/cpp/odbc-test/src/sql_system_functions_test.cpp
+++ b/modules/platforms/cpp/odbc-test/src/sql_system_functions_test.cpp
@@ -21,13 +21,13 @@
#include <boost/test/unit_test.hpp>
-#include "sql_function_test_suite_fixture.h"
+#include "sql_test_suite_fixture.h"
using namespace ignite;
using namespace boost::unit_test;
-BOOST_FIXTURE_TEST_SUITE(SqlSystemFunctionTestSuite, ignite::SqlFunctionTestSuiteFixture)
+BOOST_FIXTURE_TEST_SUITE(SqlSystemFunctionTestSuite, ignite::SqlTestSuiteFixture)
BOOST_AUTO_TEST_CASE(TestSystemFunctionDatabase)
{
http://git-wip-us.apache.org/repos/asf/ignite/blob/28917034/modules/platforms/cpp/odbc-test/src/sql_test_suite_fixture.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/sql_test_suite_fixture.cpp b/modules/platforms/cpp/odbc-test/src/sql_test_suite_fixture.cpp
new file mode 100644
index 0000000..16e5ea0
--- /dev/null
+++ b/modules/platforms/cpp/odbc-test/src/sql_test_suite_fixture.cpp
@@ -0,0 +1,271 @@
+/*
+ * 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.
+ */
+
+#include "sql_test_suite_fixture.h"
+
+#include "test_utils.h"
+
+namespace ignite
+{
+ SqlTestSuiteFixture::SqlTestSuiteFixture():
+ testCache(0),
+ env(NULL),
+ dbc(NULL),
+ stmt(NULL)
+ {
+ IgniteConfiguration cfg;
+
+ cfg.jvmOpts.push_back("-Xdebug");
+ cfg.jvmOpts.push_back("-Xnoagent");
+ cfg.jvmOpts.push_back("-Djava.compiler=NONE");
+ cfg.jvmOpts.push_back("-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005");
+ cfg.jvmOpts.push_back("-XX:+HeapDumpOnOutOfMemoryError");
+
+#ifdef IGNITE_TESTS_32
+ cfg.jvmInitMem = 256;
+ cfg.jvmMaxMem = 768;
+#else
+ cfg.jvmInitMem = 1024;
+ cfg.jvmMaxMem = 4096;
+#endif
+
+ char* cfgPath = getenv("IGNITE_NATIVE_TEST_ODBC_CONFIG_PATH");
+
+ BOOST_REQUIRE(cfgPath != 0) ;
+
+ cfg.springCfgPath.assign(cfgPath).append("/queries-test.xml");
+
+ IgniteError err;
+
+ grid = Ignition::Start(cfg, &err);
+
+ if (err.GetCode() != IgniteError::IGNITE_SUCCESS)
+ BOOST_FAIL(err.GetText()) ;
+
+ testCache = grid.GetCache<int64_t, TestType>("cache");
+
+ // Allocate an environment handle
+ SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env);
+
+ BOOST_REQUIRE(env != NULL) ;
+
+ // We want ODBC 3 support
+ SQLSetEnvAttr(env, SQL_ATTR_ODBC_VERSION, reinterpret_cast<void*>(SQL_OV_ODBC3), 0);
+
+ // Allocate a connection handle
+ SQLAllocHandle(SQL_HANDLE_DBC, env, &dbc);
+
+ BOOST_REQUIRE(dbc != NULL) ;
+
+ // Connect string
+ SQLCHAR connectStr[] = "DRIVER={Apache Ignite};SERVER=localhost;PORT=10800;CACHE=cache";
+
+ SQLCHAR outstr[ODBC_BUFFER_SIZE];
+ SQLSMALLINT outstrlen;
+
+ // Connecting to ODBC server.
+ SQLRETURN ret = SQLDriverConnect(dbc, NULL, connectStr, static_cast<SQLSMALLINT>(sizeof(connectStr)),
+ outstr, sizeof(outstr), &outstrlen, SQL_DRIVER_COMPLETE);
+
+ if (!SQL_SUCCEEDED(ret))
+ {
+ Ignition::Stop(grid.GetName(), true);
+
+ BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_DBC, dbc)) ;
+ }
+
+ // Allocate a statement handle
+ SQLAllocHandle(SQL_HANDLE_STMT, dbc, &stmt);
+
+ BOOST_REQUIRE(stmt != NULL) ;
+ }
+
+ SqlTestSuiteFixture::~SqlTestSuiteFixture()
+ {
+ // Releasing statement handle.
+ SQLFreeHandle(SQL_HANDLE_STMT, stmt);
+
+ // Disconneting from the server.
+ SQLDisconnect(dbc);
+
+ // Releasing allocated handles.
+ SQLFreeHandle(SQL_HANDLE_DBC, dbc);
+ SQLFreeHandle(SQL_HANDLE_ENV, env);
+
+ ignite::Ignition::Stop(grid.GetName(), true);
+ }
+
+ void SqlTestSuiteFixture::CheckSingleResult0(const char* request,
+ SQLSMALLINT type, void* column, SQLLEN bufSize, SQLLEN* resSize) const
+ {
+ SQLRETURN ret;
+
+ ret = SQLBindCol(stmt, 1, type, column, bufSize, resSize);
+
+ if (!SQL_SUCCEEDED(ret))
+ BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt)) ;
+
+ ret = SQLExecDirect(stmt, reinterpret_cast<SQLCHAR*>(const_cast<char*>(request)), SQL_NTS);
+
+ if (!SQL_SUCCEEDED(ret))
+ BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt)) ;
+
+ ret = SQLFetch(stmt);
+
+ if (!SQL_SUCCEEDED(ret))
+ BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt)) ;
+
+ ret = SQLFetch(stmt);
+ BOOST_CHECK(ret == SQL_NO_DATA) ;
+ }
+
+ template<>
+ void SqlTestSuiteFixture::CheckSingleResult<std::string>(const char* request, const std::string& expected)
+ {
+ SQLCHAR res[ODBC_BUFFER_SIZE] = { 0 };
+ SQLLEN resLen = 0;
+
+ CheckSingleResult0(request, SQL_C_CHAR, res, ODBC_BUFFER_SIZE, &resLen);
+
+ std::string actual;
+
+ if (resLen > 0)
+ actual.assign(reinterpret_cast<char*>(res), static_cast<size_t>(resLen));
+
+ BOOST_CHECK_EQUAL(actual, expected);
+ }
+
+ template<>
+ void SqlTestSuiteFixture::CheckSingleResult<int64_t>(const char* request, const int64_t& expected)
+ {
+ CheckSingleResultNum0<int64_t>(request, expected, SQL_C_SBIGINT);
+ }
+
+ template<>
+ void SqlTestSuiteFixture::CheckSingleResult<int32_t>(const char* request, const int32_t& expected)
+ {
+ CheckSingleResultNum0<int32_t>(request, expected, SQL_C_SLONG);
+ }
+
+ template<>
+ void SqlTestSuiteFixture::CheckSingleResult<int16_t>(const char* request, const int16_t& expected)
+ {
+ CheckSingleResultNum0<int16_t>(request, expected, SQL_C_SSHORT);
+ }
+
+ template<>
+ void SqlTestSuiteFixture::CheckSingleResult<int8_t>(const char* request, const int8_t& expected)
+ {
+ CheckSingleResultNum0<int8_t>(request, expected, SQL_C_STINYINT);
+ }
+
+ template<>
+ void SqlTestSuiteFixture::CheckSingleResult<float>(const char* request, const float& expected)
+ {
+ SQLFLOAT res = 0;
+
+ CheckSingleResult0(request, SQL_C_FLOAT, &res, 0, 0);
+
+ BOOST_CHECK_CLOSE(static_cast<float>(res), expected, 1E-6f);
+ }
+
+ template<>
+ void SqlTestSuiteFixture::CheckSingleResult<double>(const char* request, const double& expected)
+ {
+ SQLDOUBLE res = 0;
+
+ CheckSingleResult0(request, SQL_C_DOUBLE, &res, 0, 0);
+
+ BOOST_CHECK_CLOSE(static_cast<double>(res), expected, 1E-6);
+ }
+
+ template<>
+ void SqlTestSuiteFixture::CheckSingleResult<bool>(const char* request, const bool& expected)
+ {
+ SQLCHAR res = 0;
+
+ CheckSingleResult0(request, SQL_C_BIT, &res, 0, 0);
+
+ BOOST_CHECK_EQUAL((res != 0), expected);
+ }
+
+ template<>
+ void SqlTestSuiteFixture::CheckSingleResult<ignite::Guid>(const char* request, const ignite::Guid& expected)
+ {
+ SQLGUID res;
+
+ memset(&res, 0, sizeof(res));
+
+ CheckSingleResult0(request, SQL_C_GUID, &res, 0, 0);
+
+ BOOST_CHECK_EQUAL(res.Data1, expected.GetMostSignificantBits() & 0xFFFFFFFF00000000ULL >> 32);
+ BOOST_CHECK_EQUAL(res.Data2, expected.GetMostSignificantBits() & 0x00000000FFFF0000ULL >> 16);
+ BOOST_CHECK_EQUAL(res.Data3, expected.GetMostSignificantBits() & 0x000000000000FFFFULL);
+
+ for (int i = 0; i < sizeof(res.Data4); ++i)
+ BOOST_CHECK_EQUAL(res.Data4[i], (expected.GetLeastSignificantBits() & (0xFFULL << (8 * i))) >> (8 * i));
+ }
+
+ template<>
+ void SqlTestSuiteFixture::CheckSingleResult<std::string>(const char* request)
+ {
+ SQLCHAR res[ODBC_BUFFER_SIZE] = { 0 };
+ SQLLEN resLen = 0;
+
+ CheckSingleResult0(request, SQL_C_CHAR, res, ODBC_BUFFER_SIZE, &resLen);
+ }
+
+ template<>
+ void SqlTestSuiteFixture::CheckSingleResult<int64_t>(const char* request)
+ {
+ CheckSingleResultNum0<int64_t>(request, SQL_C_SBIGINT);
+ }
+
+ template<>
+ void SqlTestSuiteFixture::CheckSingleResult<int32_t>(const char* request)
+ {
+ CheckSingleResultNum0<int32_t>(request, SQL_C_SLONG);
+ }
+
+ template<>
+ void SqlTestSuiteFixture::CheckSingleResult<int16_t>(const char* request)
+ {
+ CheckSingleResultNum0<int16_t>(request, SQL_C_SSHORT);
+ }
+
+ template<>
+ void SqlTestSuiteFixture::CheckSingleResult<int8_t>(const char* request)
+ {
+ CheckSingleResultNum0<int8_t>(request, SQL_C_STINYINT);
+ }
+
+ template<>
+ void SqlTestSuiteFixture::CheckSingleResult<float>(const char* request)
+ {
+ SQLFLOAT res = 0;
+
+ CheckSingleResult0(request, SQL_C_FLOAT, &res, 0, 0);
+ }
+
+ template<>
+ void SqlTestSuiteFixture::CheckSingleResult<double>(const char* request)
+ {
+ SQLDOUBLE res = 0;
+
+ CheckSingleResult0(request, SQL_C_DOUBLE, &res, 0, 0);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/28917034/modules/platforms/cpp/odbc-test/src/sql_types_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/sql_types_test.cpp b/modules/platforms/cpp/odbc-test/src/sql_types_test.cpp
new file mode 100644
index 0000000..ccbb917
--- /dev/null
+++ b/modules/platforms/cpp/odbc-test/src/sql_types_test.cpp
@@ -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.
+ */
+
+#ifndef _MSC_VER
+# define BOOST_TEST_DYN_LINK
+#endif
+
+#include <boost/test/unit_test.hpp>
+
+#include "sql_test_suite_fixture.h"
+
+using namespace ignite;
+
+using namespace boost::unit_test;
+
+BOOST_FIXTURE_TEST_SUITE(SqlTypesTestSuite, ignite::SqlTestSuiteFixture)
+
+BOOST_AUTO_TEST_CASE(TestGuidTrivial)
+{
+ CheckSingleResult<std::string>("SELECT {guid '04CC382A-0B82-F520-08D0-07A0620C0004'}",
+ "04cc382a-0b82-f520-08d0-07a0620c0004");
+
+ CheckSingleResult<std::string>("SELECT {guid '63802467-9f4a-4f71-8fc8-cf2d99a28ddf'}",
+ "63802467-9f4a-4f71-8fc8-cf2d99a28ddf");
+}
+
+BOOST_AUTO_TEST_CASE(TestGuidEqualsToColumn)
+{
+ TestType in1;
+ TestType in2;
+
+ in1.guidField = Guid(0x638024679f4a4f71, 0x8fc8cf2d99a28ddf);
+ in2.guidField = Guid(0x04cc382a0b82f520, 0x08d007a0620c0004);
+
+ in1.i32Field = 1;
+ in2.i32Field = 2;
+
+ testCache.Put(1, in1);
+ testCache.Put(2, in2);
+
+ CheckSingleResult<int32_t>(
+ "SELECT i32Field FROM TestType WHERE guidField = {guid '04cc382a-0b82-f520-08d0-07a0620c0004'}", in2.i32Field);
+}
+
+
+BOOST_AUTO_TEST_SUITE_END()
http://git-wip-us.apache.org/repos/asf/ignite/blob/28917034/modules/platforms/cpp/odbc-test/src/sql_value_expressions.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/sql_value_expressions.cpp b/modules/platforms/cpp/odbc-test/src/sql_value_expressions.cpp
deleted file mode 100644
index e7d6598..0000000
--- a/modules/platforms/cpp/odbc-test/src/sql_value_expressions.cpp
+++ /dev/null
@@ -1,94 +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.
- */
-
-#ifndef _MSC_VER
-# define BOOST_TEST_DYN_LINK
-#endif
-
-#include <boost/test/unit_test.hpp>
-
-#include "sql_function_test_suite_fixture.h"
-
-using namespace ignite;
-
-using namespace boost::unit_test;
-
-BOOST_FIXTURE_TEST_SUITE(SqlValueExpressionTestSuite, ignite::SqlFunctionTestSuiteFixture)
-
-BOOST_AUTO_TEST_CASE(TestCase)
-{
- TestType in;
-
- in.i32Field = 82;
-
- testCache.Put(1, in);
-
- CheckSingleResult<int32_t>(
- "SELECT "
- "CASE i32Field WHEN 82 "
- "THEN (i32Field / 2) "
- "ELSE (i32Field / 3) "
- "END "
- "FROM TestType", in.i32Field / 2);
-
-
- CheckSingleResult<int32_t>(
- "SELECT "
- "CASE i32Field WHEN 22 "
- "THEN (i32Field / 2) "
- "ELSE (i32Field / 3) "
- "END "
- "FROM TestType", in.i32Field / 3);;
-}
-
-BOOST_AUTO_TEST_CASE(TestCast)
-{
- TestType in;
-
- in.i32Field = 12345;
- in.strField = "54321";
-
- testCache.Put(1, in);
-
- CheckSingleResult<int32_t>("SELECT CAST(strField AS INT) + i32Field FROM TestType",
- common::LexicalCast<int32_t>(in.strField) + in.i32Field);
-
- CheckSingleResult<std::string>("SELECT CAST(i32Field AS VARCHAR) || strField FROM TestType",
- common::LexicalCast<std::string>(in.i32Field) + in.strField);
-}
-
-BOOST_AUTO_TEST_CASE(TestCoalesce)
-{
- CheckSingleResult<std::string>("SELECT COALESCE('One', 'Two', 'Three')", "One");
- CheckSingleResult<std::string>("SELECT COALESCE(NULL, 'Two', 'Three')", "Two");
- CheckSingleResult<std::string>("SELECT COALESCE(NULL, 'Two', NULL)", "Two");
- CheckSingleResult<std::string>("SELECT COALESCE(NULL, NULL, 'Three')", "Three");
-}
-
-BOOST_AUTO_TEST_CASE(TestNullif)
-{
- TestType in;
-
- in.strField = "SomeValue";
-
- testCache.Put(1, in);
-
- CheckSingleResult<std::string>("SELECT NULLIF(strField, 'blablabla') FROM TestType", in.strField);
- CheckSingleResult<std::string>("SELECT NULLIF(strField, 'SomeValue') FROM TestType", "");
-}
-
-BOOST_AUTO_TEST_SUITE_END()
http://git-wip-us.apache.org/repos/asf/ignite/blob/28917034/modules/platforms/cpp/odbc-test/src/sql_value_expressions_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/sql_value_expressions_test.cpp b/modules/platforms/cpp/odbc-test/src/sql_value_expressions_test.cpp
new file mode 100644
index 0000000..eb9b6ea
--- /dev/null
+++ b/modules/platforms/cpp/odbc-test/src/sql_value_expressions_test.cpp
@@ -0,0 +1,94 @@
+/*
+ * 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.
+ */
+
+#ifndef _MSC_VER
+# define BOOST_TEST_DYN_LINK
+#endif
+
+#include <boost/test/unit_test.hpp>
+
+#include "sql_test_suite_fixture.h"
+
+using namespace ignite;
+
+using namespace boost::unit_test;
+
+BOOST_FIXTURE_TEST_SUITE(SqlValueExpressionTestSuite, ignite::SqlTestSuiteFixture)
+
+BOOST_AUTO_TEST_CASE(TestCase)
+{
+ TestType in;
+
+ in.i32Field = 82;
+
+ testCache.Put(1, in);
+
+ CheckSingleResult<int32_t>(
+ "SELECT "
+ "CASE i32Field WHEN 82 "
+ "THEN (i32Field / 2) "
+ "ELSE (i32Field / 3) "
+ "END "
+ "FROM TestType", in.i32Field / 2);
+
+
+ CheckSingleResult<int32_t>(
+ "SELECT "
+ "CASE i32Field WHEN 22 "
+ "THEN (i32Field / 2) "
+ "ELSE (i32Field / 3) "
+ "END "
+ "FROM TestType", in.i32Field / 3);;
+}
+
+BOOST_AUTO_TEST_CASE(TestCast)
+{
+ TestType in;
+
+ in.i32Field = 12345;
+ in.strField = "54321";
+
+ testCache.Put(1, in);
+
+ CheckSingleResult<int32_t>("SELECT CAST(strField AS INT) + i32Field FROM TestType",
+ common::LexicalCast<int32_t>(in.strField) + in.i32Field);
+
+ CheckSingleResult<std::string>("SELECT CAST(i32Field AS VARCHAR) || strField FROM TestType",
+ common::LexicalCast<std::string>(in.i32Field) + in.strField);
+}
+
+BOOST_AUTO_TEST_CASE(TestCoalesce)
+{
+ CheckSingleResult<std::string>("SELECT COALESCE('One', 'Two', 'Three')", "One");
+ CheckSingleResult<std::string>("SELECT COALESCE(NULL, 'Two', 'Three')", "Two");
+ CheckSingleResult<std::string>("SELECT COALESCE(NULL, 'Two', NULL)", "Two");
+ CheckSingleResult<std::string>("SELECT COALESCE(NULL, NULL, 'Three')", "Three");
+}
+
+BOOST_AUTO_TEST_CASE(TestNullif)
+{
+ TestType in;
+
+ in.strField = "SomeValue";
+
+ testCache.Put(1, in);
+
+ CheckSingleResult<std::string>("SELECT NULLIF(strField, 'blablabla') FROM TestType", in.strField);
+ CheckSingleResult<std::string>("SELECT NULLIF(strField, 'SomeValue') FROM TestType", "");
+}
+
+BOOST_AUTO_TEST_SUITE_END()
[19/50] [abbrv] ignite git commit: ignite-2968 Deadlock detection for
optimistic tx and near caches
Posted by sb...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/0465874d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
index 63c9919..f9357f9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
@@ -50,7 +50,6 @@ import org.apache.ignite.internal.processors.cache.GridCacheMessage;
import org.apache.ignite.internal.processors.cache.GridCacheMvccCandidate;
import org.apache.ignite.internal.processors.cache.GridCacheMvccFuture;
import org.apache.ignite.internal.processors.cache.GridCacheSharedManagerAdapter;
-import org.apache.ignite.internal.processors.cache.KeyCacheObject;
import org.apache.ignite.internal.processors.cache.distributed.GridCacheMappedVersion;
import org.apache.ignite.internal.processors.cache.distributed.GridCacheTxFinishSync;
import org.apache.ignite.internal.processors.cache.distributed.GridCacheTxRecoveryFuture;
@@ -62,6 +61,8 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxRemo
import org.apache.ignite.internal.processors.cache.distributed.dht.colocated.GridDhtColocatedLockFuture;
import org.apache.ignite.internal.processors.cache.distributed.near.GridNearCacheAdapter;
import org.apache.ignite.internal.processors.cache.distributed.near.GridNearCacheEntry;
+import org.apache.ignite.internal.processors.cache.distributed.near.GridNearLockFuture;
+import org.apache.ignite.internal.processors.cache.distributed.near.GridNearOptimisticTxPrepareFuture;
import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal;
import org.apache.ignite.internal.processors.cache.transactions.TxDeadlockDetection.TxDeadlockFuture;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
@@ -126,7 +127,7 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
public static final IgniteProductVersion TX_DEADLOCK_DETECTION_SINCE = IgniteProductVersion.fromString("1.5.19");
/** Deadlock detection maximum iterations. */
- static final int DEADLOCK_MAX_ITERS =
+ static int DEADLOCK_MAX_ITERS =
IgniteSystemProperties.getInteger(IGNITE_TX_DEADLOCK_DETECTION_MAX_ITERS, 1000);
/** Committing transactions. */
@@ -389,7 +390,13 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
* {@code false} otherwise.
*/
public boolean isCompleted(IgniteInternalTx tx) {
- return completedVersHashMap.containsKey(tx.xidVersion());
+ boolean completed = completedVersHashMap.containsKey(tx.xidVersion());
+
+ // Need check that for tx with timeout rollback message was not received before lock.
+ if (!completed && tx.local() && tx.dht() && tx.timeout() > 0)
+ return completedVersHashMap.containsKey(tx.nearXidVersion());
+
+ return completed;
}
/**
@@ -495,13 +502,6 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
return null;
}
- if (tx.timeout() > 0) {
- cctx.time().addTimeoutObject(tx);
-
- if (log.isDebugEnabled())
- log.debug("Registered transaction with timeout processor: " + tx);
- }
-
if (log.isDebugEnabled())
log.debug("Transaction created: " + tx);
@@ -786,7 +786,7 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
*/
public void prepareTx(IgniteInternalTx tx) throws IgniteCheckedException {
if (tx.state() == MARKED_ROLLBACK) {
- if (tx.timedOut())
+ if (tx.remainingTime() == -1)
throw new IgniteTxTimeoutCheckedException("Transaction timed out: " + this);
throw new IgniteCheckedException("Transaction is marked for rollback: " + tx);
@@ -1081,13 +1081,6 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
if (log.isDebugEnabled())
log.debug("Committing from TM [locNodeId=" + cctx.localNodeId() + ", tx=" + tx + ']');
- if (tx.timeout() > 0) {
- cctx.time().removeTimeoutObject(tx);
-
- if (log.isDebugEnabled())
- log.debug("Unregistered transaction with timeout processor: " + tx);
- }
-
/*
* Note that write phase is handled by transaction adapter itself,
* so we don't do it here.
@@ -2006,17 +1999,45 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
if (!(nearTxLoc || tx instanceof GridDhtTxLocal) || !hasKeys(tx, txKeys))
continue;
- Collection<IgniteTxEntry> txEntries = tx.allEntries();
+ IgniteTxState state = tx.txState();
+
+ assert state instanceof IgniteTxStateImpl || state instanceof IgniteTxImplicitSingleStateImpl;
+
+ Collection<IgniteTxEntry> txEntries =
+ state instanceof IgniteTxStateImpl ? ((IgniteTxStateImpl)state).allEntriesCopy() : state.allEntries();
- Set<KeyCacheObject> requestedKeys = null;
+ Set<IgniteTxKey> requestedKeys = null;
// Try to get info about requested keys for detached entries in case of GridNearTxLocal transaction
// in order to reduce amount of requests to remote nodes.
if (nearTxLoc) {
- GridDhtColocatedLockFuture fut = colocatedLockFuture(tx);
+ if (tx.pessimistic()) {
+ GridDhtColocatedLockFuture fut =
+ (GridDhtColocatedLockFuture)mvccFuture(tx, GridDhtColocatedLockFuture.class);
+
+ if (fut != null)
+ requestedKeys = fut.requestedKeys();
+
+ GridNearLockFuture nearFut = (GridNearLockFuture)mvccFuture(tx, GridNearLockFuture.class);
- if (fut != null)
- requestedKeys = fut.requestedKeys();
+ if (nearFut != null) {
+ Set<IgniteTxKey> nearRequestedKeys = nearFut.requestedKeys();
+
+ if (nearRequestedKeys != null) {
+ if (requestedKeys == null)
+ requestedKeys = nearRequestedKeys;
+ else
+ requestedKeys = nearRequestedKeys;
+ }
+ }
+ }
+ else {
+ GridNearOptimisticTxPrepareFuture fut =
+ (GridNearOptimisticTxPrepareFuture)mvccFuture(tx, GridNearOptimisticTxPrepareFuture.class);
+
+ if (fut != null)
+ requestedKeys = fut.requestedKeys();
+ }
}
for (IgniteTxEntry txEntry : txEntries) {
@@ -2073,17 +2094,18 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
/**
* @param tx Tx. Must be instance of {@link GridNearTxLocal}.
- * @return Colocated future.
+ * @param cls Future class.
+ * @return Cache future.
*/
- private GridDhtColocatedLockFuture colocatedLockFuture(IgniteInternalTx tx) {
+ private IgniteInternalFuture mvccFuture(IgniteInternalTx tx, Class<? extends IgniteInternalFuture> cls) {
assert tx instanceof GridNearTxLocal : tx;
Collection<GridCacheMvccFuture<?>> futs = cctx.mvcc().mvccFutures(tx.nearXidVersion());
if (futs != null) {
for (GridCacheMvccFuture<?> fut : futs) {
- if (fut instanceof GridDhtColocatedLockFuture)
- return (GridDhtColocatedLockFuture)fut;
+ if (fut.getClass().equals(cls))
+ return fut;
}
}
@@ -2115,6 +2137,16 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
}
/**
+ * @return Collection of active transaction deadlock detection futures.
+ */
+ @SuppressWarnings("unchecked")
+ public Collection<IgniteInternalFuture<?>> deadlockDetectionFutures() {
+ Collection<? extends IgniteInternalFuture<?>> values = deadlockDetectFuts.values();
+
+ return (Collection<IgniteInternalFuture<?>>)values;
+ }
+
+ /**
* Timeout object for node failure handler.
*/
private final class NodeFailureTimeoutObject extends GridTimeoutObjectAdapter {
http://git-wip-us.apache.org/repos/asf/ignite/blob/0465874d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxStateImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxStateImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxStateImpl.java
index c116d0d..f23cca9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxStateImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxStateImpl.java
@@ -20,6 +20,7 @@ package org.apache.ignite.internal.processors.cache.transactions;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
+import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.apache.ignite.IgniteCheckedException;
@@ -39,6 +40,7 @@ import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.jetbrains.annotations.Nullable;
+import org.jsr166.ConcurrentLinkedHashMap;
import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_ASYNC;
import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
@@ -362,6 +364,13 @@ public class IgniteTxStateImpl extends IgniteTxLocalStateAdapter {
return txMap == null ? Collections.<IgniteTxEntry>emptySet() : txMap.values();
}
+ /**
+ * @return All entries. Returned collection is copy of internal collection.
+ */
+ public synchronized Collection<IgniteTxEntry> allEntriesCopy() {
+ return txMap == null ? Collections.<IgniteTxEntry>emptySet() : new HashSet<>(txMap.values());
+ }
+
/** {@inheritDoc} */
@Override public IgniteTxEntry entry(IgniteTxKey key) {
return txMap == null ? null : txMap.get(key);
@@ -408,7 +417,7 @@ public class IgniteTxStateImpl extends IgniteTxLocalStateAdapter {
}
/** {@inheritDoc} */
- @Override public void addEntry(IgniteTxEntry entry) {
+ @Override public synchronized void addEntry(IgniteTxEntry entry) {
txMap.put(entry.txKey(), entry);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/0465874d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlockDetection.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlockDetection.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlockDetection.java
index 36843dd..70d938e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlockDetection.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlockDetection.java
@@ -36,8 +36,11 @@ import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
import org.apache.ignite.internal.processors.timeout.GridTimeoutObjectAdapter;
import org.apache.ignite.internal.util.future.GridFutureAdapter;
+import org.apache.ignite.internal.util.tostring.GridToStringExclude;
+import org.apache.ignite.internal.util.tostring.GridToStringInclude;
import org.apache.ignite.internal.util.typedef.T2;
import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.internal.util.typedef.internal.U;
import org.jetbrains.annotations.Nullable;
import static org.apache.ignite.IgniteSystemProperties.IGNITE_TX_DEADLOCK_DETECTION_TIMEOUT;
@@ -106,22 +109,30 @@ public class TxDeadlockDetection {
stack.push(txId);
while (!stack.isEmpty()) {
- GridCacheVersion v = stack.pop();
+ GridCacheVersion v = stack.peek();
+
+ if (visited.contains(v)) {
+ stack.pop();
+ inPath.remove(v);
- if (visited.contains(v))
continue;
+ }
visited.add(v);
Set<GridCacheVersion> children = wfg.get(v);
- if (children == null || children.isEmpty())
+ if (children == null || children.isEmpty()) {
+ stack.pop();
+ inPath.remove(v);
+
continue;
+ }
inPath.add(v);
for (GridCacheVersion w : children) {
- if (inPath.contains(w)) {
+ if (inPath.contains(w) && visited.contains(w)) {
List<GridCacheVersion> cycle = new ArrayList<>();
for (GridCacheVersion x = v; !x.equals(w); x = edgeTo.get(x))
@@ -158,15 +169,18 @@ public class TxDeadlockDetection {
private final Set<IgniteTxKey> keys;
/** Processed keys. */
+ @GridToStringInclude
private final Set<IgniteTxKey> processedKeys = new HashSet<>();
/** Processed nodes. */
private final Set<UUID> processedNodes = new HashSet<>();
/** Pending keys. */
+ @GridToStringInclude
private Map<UUID, Set<IgniteTxKey>> pendingKeys = new HashMap<>();
/** Nodes queue. */
+ @GridToStringInclude
private final UniqueDeque<UUID> nodesQueue = new UniqueDeque<>();
/** Preferred nodes. */
@@ -194,6 +208,7 @@ public class TxDeadlockDetection {
private int itersCnt;
/** Timeout object. */
+ @GridToStringExclude
private DeadlockTimeoutObject timeoutObj;
/** Timed out flag. */
@@ -252,8 +267,8 @@ public class TxDeadlockDetection {
if (topVer == null) // Tx manager already stopped
onDone();
-
- map(keys, Collections.<IgniteTxKey, TxLockList>emptyMap());
+ else
+ map(keys, Collections.<IgniteTxKey, TxLockList>emptyMap());
}
/**
@@ -441,14 +456,17 @@ public class TxDeadlockDetection {
* @param txLocks Tx locks.
*/
private void updateWaitForGraph(Map<IgniteTxKey, TxLockList> txLocks) {
+ if (txLocks == null || txLocks.isEmpty())
+ return;
+
for (Map.Entry<IgniteTxKey, TxLockList> e : txLocks.entrySet()) {
GridCacheVersion txOwner = null;
for (TxLock lock : e.getValue().txLocks()) {
- if (lock.owner()) {
- assert txOwner == null;
-
+ if (lock.owner() && txOwner == null) {
+ // Actually we can get lock list with more than one owner. In this case ignore all owners
+ // except first because likely the first owner was cause of deadlock.
txOwner = lock.txId();
if (keys.contains(e.getKey()) && !txId.equals(lock.txId())) {
@@ -463,7 +481,7 @@ public class TxDeadlockDetection {
continue;
}
- if (lock.candiate()) {
+ if (lock.candiate() || lock.owner()) {
GridCacheVersion txId0 = lock.txId();
Set<GridCacheVersion> waitForTxs = wfg.get(txId0);
@@ -485,9 +503,9 @@ public class TxDeadlockDetection {
if (res != null && set) {
if (res.classError() != null) {
- IgniteLogger log = cctx.logger(TxDeadlockDetection.class);
+ IgniteLogger log = cctx.kernalContext().log(this.getClass());
- log.warning("Failed to finish deadlock detection due to an error: " + nodeId);
+ U.warn(log, "Failed to finish deadlock detection due to an error: " + nodeId);
onDone();
}
@@ -528,6 +546,11 @@ public class TxDeadlockDetection {
return false;
}
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(TxDeadlockFuture.class, this);
+ }
+
/**
* Lock request timeout object.
*/
@@ -543,6 +566,10 @@ public class TxDeadlockDetection {
@Override public void onTimeout() {
timedOut = true;
+ IgniteLogger log = cctx.kernalContext().log(this.getClass());
+
+ U.warn(log, "Deadlock detection was timed out [timeout=" + DEADLOCK_TIMEOUT + ", fut=" + this + ']');
+
onDone();
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/0465874d/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxConfigCacheSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxConfigCacheSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxConfigCacheSelfTest.java
index 94b5620..2b524e8 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxConfigCacheSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxConfigCacheSelfTest.java
@@ -18,15 +18,29 @@
package org.apache.ignite.internal.processors.cache;
+import javax.cache.CacheException;
+import javax.cache.processor.EntryProcessor;
+import javax.cache.processor.EntryProcessorException;
+import javax.cache.processor.MutableEntry;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteException;
import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.configuration.TransactionConfiguration;
+import org.apache.ignite.internal.IgniteInterruptedCheckedException;
import org.apache.ignite.internal.IgniteKernal;
+import org.apache.ignite.internal.managers.communication.GridIoMessage;
+import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxPrepareRequest;
import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx;
import org.apache.ignite.internal.util.typedef.internal.CU;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteInClosure;
+import org.apache.ignite.plugin.extensions.communication.Message;
+import org.apache.ignite.spi.IgniteSpiException;
+import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
@@ -34,11 +48,6 @@ import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import org.apache.ignite.transactions.Transaction;
import org.apache.ignite.transactions.TransactionTimeoutException;
-import javax.cache.CacheException;
-import javax.cache.processor.EntryProcessor;
-import javax.cache.processor.EntryProcessorException;
-import javax.cache.processor.MutableEntry;
-
import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
import static org.apache.ignite.transactions.TransactionIsolation.READ_COMMITTED;
@@ -62,6 +71,10 @@ public class IgniteTxConfigCacheSelfTest extends GridCommonAbstractTest {
((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER);
+ TcpCommunicationSpi commSpi = new TestCommunicationSpi();
+
+ cfg.setCommunicationSpi(commSpi);
+
CacheConfiguration ccfg = new CacheConfiguration();
ccfg.setAtomicityMode(atomicityMode());
@@ -87,7 +100,7 @@ public class IgniteTxConfigCacheSelfTest extends GridCommonAbstractTest {
/** {@inheritDoc} */
@Override protected void beforeTestsStarted() throws Exception {
- startGrids(1);
+ startGrids(2);
}
/** {@inheritDoc} */
@@ -98,7 +111,7 @@ public class IgniteTxConfigCacheSelfTest extends GridCommonAbstractTest {
/**
* Success if user tx was timed out.
*
- * @throws Exception
+ * @throws Exception If failed.
*/
public void testUserTxTimeout() throws Exception {
final Ignite ignite = grid(0);
@@ -112,7 +125,7 @@ public class IgniteTxConfigCacheSelfTest extends GridCommonAbstractTest {
/**
* Success if system caches weren't timed out.
*
- * @throws Exception
+ * @throws Exception If failed.
*/
public void testSystemCacheTx() throws Exception {
final Ignite ignite = grid(0);
@@ -143,27 +156,23 @@ public class IgniteTxConfigCacheSelfTest extends GridCommonAbstractTest {
* Success if implicit tx fails.
*
* @param cache Cache name.
- * @throws Exception
+ * @throws Exception If failed.
*/
protected void checkImplicitTxTimeout(final IgniteCache<Object, Object> cache) throws Exception {
- try {
- cache.invoke("key", new EntryProcessor<Object, Object, Object>() {
- @Override public Object process(final MutableEntry<Object, Object> entry, final Object... args)
- throws EntryProcessorException {
- try {
- sleepForTxFailure();
- } catch (InterruptedException e) {
- throw new EntryProcessorException(e);
- }
+ TestCommunicationSpi.delay = true;
- return null;
- }
- });
+ Integer key = primaryKey(ignite(1).cache(CACHE_NAME));
+
+ try {
+ cache.put(key, 0);
fail("Timeout exception must be thrown");
}
catch (CacheException e) {
- // OK
+ // No-op.
+ }
+ finally {
+ TestCommunicationSpi.delay = false;
}
cache.clear();
@@ -174,7 +183,7 @@ public class IgniteTxConfigCacheSelfTest extends GridCommonAbstractTest {
*
* @param cache Cache name.
* @param ignite Ignite instance.
- * @throws Exception
+ * @throws Exception If failed.
*/
protected void checkExplicitTxTimeout(final IgniteCache<Object, Object> cache, final Ignite ignite)
throws Exception {
@@ -198,7 +207,7 @@ public class IgniteTxConfigCacheSelfTest extends GridCommonAbstractTest {
* Success if explicit tx doesn't fail.
*
* @param cache Cache instance.
- * @throws Exception
+ * @throws Exception If failed.
*/
protected void checkStartTxSuccess(final IgniteInternalCache<Object, Object> cache) throws Exception {
try (final IgniteInternalTx tx = CU.txStartInternal(cache.context(), cache, PESSIMISTIC, READ_COMMITTED)) {
@@ -220,7 +229,7 @@ public class IgniteTxConfigCacheSelfTest extends GridCommonAbstractTest {
* Success if implicit tx fails.
*
* @param cache Cache instance.
- * @throws Exception
+ * @throws Exception If failed.
*/
protected void checkImplicitTxSuccess(final IgniteInternalCache<Object, Object> cache) throws Exception {
cache.invoke("key", new EntryProcessor<Object, Object, Object>() {
@@ -241,9 +250,39 @@ public class IgniteTxConfigCacheSelfTest extends GridCommonAbstractTest {
/**
* Sleep multiple {@link #TX_TIMEOUT} times.
*
- * @throws InterruptedException
+ * @throws InterruptedException If interrupted.
*/
private void sleepForTxFailure() throws InterruptedException {
Thread.sleep(TX_TIMEOUT * 3);
}
+
+ /**
+ *
+ */
+ private static class TestCommunicationSpi extends TcpCommunicationSpi {
+ /** Delay. */
+ private static volatile boolean delay;
+
+ /** {@inheritDoc} */
+ @Override public void sendMessage(
+ final ClusterNode node,
+ final Message msg,
+ final IgniteInClosure<IgniteException> ackC
+ ) throws IgniteSpiException {
+ if (msg instanceof GridIoMessage) {
+ Message msg0 = ((GridIoMessage)msg).message();
+
+ if (msg0 instanceof GridNearTxPrepareRequest && delay) {
+ try {
+ U.sleep(TX_TIMEOUT * 2);
+ }
+ catch (IgniteInterruptedCheckedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ super.sendMessage(node, msg, ackC);
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/0465874d/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxTimeoutAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxTimeoutAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxTimeoutAbstractTest.java
index c417821..8475175 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxTimeoutAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxTimeoutAbstractTest.java
@@ -20,10 +20,10 @@ package org.apache.ignite.internal.processors.cache.distributed;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
-import javax.cache.CacheException;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.internal.util.typedef.X;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import org.apache.ignite.transactions.Transaction;
import org.apache.ignite.transactions.TransactionConcurrency;
@@ -154,8 +154,8 @@ public class IgniteTxTimeoutAbstractTest extends GridCommonAbstractTest {
assert false : "Timeout never happened for transaction: " + tx;
}
- catch (CacheException e) {
- if (!(e.getCause() instanceof TransactionTimeoutException))
+ catch (Exception e) {
+ if (!(X.hasCause(e, TransactionTimeoutException.class)))
throw e;
info("Received expected timeout exception [msg=" + e.getMessage() + ", tx=" + tx + ']');
@@ -164,4 +164,4 @@ public class IgniteTxTimeoutAbstractTest extends GridCommonAbstractTest {
tx.close();
}
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/0465874d/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/CachePartitionedMultiNodeLongTxTimeoutFullApiTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/CachePartitionedMultiNodeLongTxTimeoutFullApiTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/CachePartitionedMultiNodeLongTxTimeoutFullApiTest.java
new file mode 100644
index 0000000..89fe8e0
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/CachePartitionedMultiNodeLongTxTimeoutFullApiTest.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache.distributed.near;
+
+import org.apache.ignite.configuration.IgniteConfiguration;
+
+/**
+ *
+ */
+public class CachePartitionedMultiNodeLongTxTimeoutFullApiTest extends GridCachePartitionedMultiNodeFullApiSelfTest {
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ cfg.getTransactionConfiguration().setDefaultTxTimeout(Long.MAX_VALUE);
+
+ return cfg;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/0465874d/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/CachePartitionedNearEnabledMultiNodeLongTxTimeoutFullApiTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/CachePartitionedNearEnabledMultiNodeLongTxTimeoutFullApiTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/CachePartitionedNearEnabledMultiNodeLongTxTimeoutFullApiTest.java
new file mode 100644
index 0000000..3e3b84e
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/CachePartitionedNearEnabledMultiNodeLongTxTimeoutFullApiTest.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache.distributed.near;
+
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.NearCacheConfiguration;
+
+/**
+ *
+ */
+public class CachePartitionedNearEnabledMultiNodeLongTxTimeoutFullApiTest extends
+ GridCachePartitionedMultiNodeFullApiSelfTest {
+ /** {@inheritDoc} */
+ @Override protected NearCacheConfiguration nearConfiguration() {
+ return new NearCacheConfiguration();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ cfg.getTransactionConfiguration().setDefaultTxTimeout(Long.MAX_VALUE);
+
+ return cfg;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/0465874d/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalTxTimeoutSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalTxTimeoutSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalTxTimeoutSelfTest.java
index cfa93ac..e27207d 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalTxTimeoutSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalTxTimeoutSelfTest.java
@@ -17,7 +17,6 @@
package org.apache.ignite.internal.processors.cache.local;
-import javax.cache.CacheException;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.IgniteCheckedException;
@@ -154,7 +153,7 @@ public class GridCacheLocalTxTimeoutSelfTest extends GridCommonAbstractTest {
tx.commit();
}
- catch (CacheException e) {
+ catch (Exception e) {
assertTrue(X.hasCause(e, TransactionTimeoutException.class));
info("Received expected optimistic exception: " + e.getMessage());
@@ -166,4 +165,4 @@ public class GridCacheLocalTxTimeoutSelfTest extends GridCommonAbstractTest {
assert wasEx;
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/0465874d/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/DepthFirstSearchTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/DepthFirstSearchTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/DepthFirstSearchTest.java
index 20467c2..b0a407c 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/DepthFirstSearchTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/DepthFirstSearchTest.java
@@ -24,10 +24,12 @@ import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
+import java.util.Random;
import java.util.Set;
import junit.framework.TestCase;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.internal.U;
import static org.apache.ignite.internal.processors.cache.transactions.TxDeadlockDetection.findCycle;
@@ -95,6 +97,14 @@ public class DepthFirstSearchTest extends TestCase {
wfg = new HashMap<GridCacheVersion, Set<GridCacheVersion>>() {{
put(T1, new HashSet<GridCacheVersion>(){{add(T2);}});
+ put(T2, new HashSet<GridCacheVersion>(){{add(T3);}});
+ put(T4, new HashSet<GridCacheVersion>(){{add(T1); add(T2); add(T3);}});
+ }};
+
+ assertAllNull(wfg);
+
+ wfg = new HashMap<GridCacheVersion, Set<GridCacheVersion>>() {{
+ put(T1, new HashSet<GridCacheVersion>(){{add(T2);}});
put(T3, new HashSet<GridCacheVersion>(){{add(T4);}});
put(T4, new HashSet<GridCacheVersion>(){{add(T1);}});
}};
@@ -228,6 +238,94 @@ public class DepthFirstSearchTest extends TestCase {
}
/**
+ * @throws Exception If failed.
+ */
+ public void testFindCycle4() throws Exception {
+ Map<GridCacheVersion, Set<GridCacheVersion>> wfg = new HashMap<GridCacheVersion, Set<GridCacheVersion>>() {{
+ put(T1, Collections.singleton(T2));
+ put(T2, asLinkedHashSet(T3, T4));
+ put(T3, Collections.singleton(T4));
+ put(T4, Collections.singleton(T5));
+ put(T6, Collections.singleton(T3));
+ }};
+
+ assertNull(findCycle(wfg, T1));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testRandomNoExceptions() throws Exception {
+ int maxNodesCnt = 100;
+ int minNodesCnt = 10;
+ int maxWaitForNodesCnt = 20;
+
+ int cyclesFound = 0;
+ int cyclesNotFound = 0;
+
+ Random seedRnd = new Random();
+
+ Random rnd = new Random();
+
+ for (int i = 0; i < 50000; i++) {
+ long seed = seedRnd.nextLong();
+
+ rnd.setSeed(seed);
+
+ System.out.println(">>> Iteration " + i + " with seed " + seed);
+
+ int nodesCnt = rnd.nextInt(maxNodesCnt - minNodesCnt) + minNodesCnt;
+
+ Map<GridCacheVersion, Set<GridCacheVersion>> wfg = new HashMap<>();
+
+ for (int j = 0; j < nodesCnt; j++) {
+ if (rnd.nextInt(100) > 30) {
+ int waitForNodesCnt = rnd.nextInt(maxWaitForNodesCnt);
+
+ Set<GridCacheVersion> waitForNodes = null;
+
+ if (waitForNodesCnt > 0) {
+ waitForNodes = new LinkedHashSet<>();
+
+ for (int k = 0; k < waitForNodesCnt;) {
+ int n = rnd.nextInt(nodesCnt);
+
+ if (n != j) {
+ waitForNodes.add(new GridCacheVersion(n, 0, 0, 0));
+ k++;
+ }
+ }
+ }
+
+ wfg.put(new GridCacheVersion(j, 0, 0, 0), waitForNodes);
+ }
+ }
+
+ for (int j = 0; j < nodesCnt; j++) {
+ try {
+ List<GridCacheVersion> cycle = findCycle(wfg, new GridCacheVersion(j, 0, 0, 0));
+
+ if (cycle == null)
+ cyclesNotFound++;
+ else
+ cyclesFound++;
+ }
+ catch (Throwable e) {
+ U.error(null, "Error during finding cycle in graph: ", e);
+
+ U.warn(null, "Seed: " + seed);
+
+ U.warn(null, "Wait-for-graph: " + wfg);
+
+ fail();
+ }
+ }
+ }
+
+ System.out.println(">>> Test finished. Cycles found: " + cyclesFound + ", cycles not found: " + cyclesNotFound);
+ }
+
+ /**
* @param wfg Wait-for-graph.
*/
private static void assertAllNull(Map<GridCacheVersion, Set<GridCacheVersion>> wfg, GridCacheVersion... ignore) {
@@ -249,4 +347,4 @@ public class DepthFirstSearchTest extends TestCase {
return set;
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/0465874d/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlockDetectionNoHangsTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlockDetectionNoHangsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlockDetectionNoHangsTest.java
new file mode 100644
index 0000000..c9d18eb
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlockDetectionNoHangsTest.java
@@ -0,0 +1,246 @@
+/*
+ * 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.transactions;
+
+import java.util.Collection;
+import java.util.concurrent.ThreadLocalRandom;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteSystemProperties;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.IgniteKernal;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.apache.ignite.transactions.Transaction;
+import org.apache.ignite.transactions.TransactionConcurrency;
+
+import static org.apache.ignite.IgniteSystemProperties.IGNITE_TX_DEADLOCK_DETECTION_MAX_ITERS;
+import static org.apache.ignite.IgniteSystemProperties.IGNITE_TX_DEADLOCK_DETECTION_TIMEOUT;
+import static org.apache.ignite.IgniteSystemProperties.getInteger;
+import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC;
+import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
+import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ;
+
+/**
+ *
+ */
+public class TxDeadlockDetectionNoHangsTest extends GridCommonAbstractTest {
+ /** Nodes count. */
+ private static final int NODES_CNT = 3;
+
+ /** Cache. */
+ private static final String CACHE = "cache";
+
+ /** {@inheritDoc} */
+ @SuppressWarnings("unchecked")
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ CacheConfiguration ccfg = defaultCacheConfiguration();
+
+ ccfg.setName(CACHE);
+ ccfg.setCacheMode(CacheMode.PARTITIONED);
+ ccfg.setBackups(1);
+ ccfg.setNearConfiguration(null);
+
+ cfg.setCacheConfiguration(ccfg);
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTest() throws Exception {
+ super.beforeTest();
+
+ startGridsMultiThreaded(NODES_CNT);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ super.afterTest();
+
+ stopAllGrids();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTestsStarted() throws Exception {
+ super.beforeTestsStarted();
+
+ GridTestUtils.setFieldValue(null, TxDeadlockDetection.class, "DEADLOCK_TIMEOUT", (int)(getTestTimeout() * 2));
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ super.afterTestsStopped();
+
+ GridTestUtils.setFieldValue(null, TxDeadlockDetection.class, "DEADLOCK_TIMEOUT",
+ getInteger(IGNITE_TX_DEADLOCK_DETECTION_TIMEOUT, 60000));
+ }
+
+ /** {@inheritDoc} */
+ @Override protected long getTestTimeout() {
+ return 10 * 60 * 1000;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testNoHangsPessimistic() throws Exception {
+ assertTrue(grid(0).context().cache().context().tm().deadlockDetectionEnabled());
+
+ doTest(PESSIMISTIC);
+
+ try {
+ GridTestUtils.setFieldValue(null, IgniteTxManager.class, "DEADLOCK_MAX_ITERS", 0);
+
+ assertFalse(grid(0).context().cache().context().tm().deadlockDetectionEnabled());
+
+ doTest(PESSIMISTIC);
+ }
+ finally {
+ GridTestUtils.setFieldValue(null, IgniteTxManager.class, "DEADLOCK_MAX_ITERS",
+ IgniteSystemProperties.getInteger(IGNITE_TX_DEADLOCK_DETECTION_MAX_ITERS, 1000));
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testNoHangsOptimistic() throws Exception {
+ assertTrue(grid(0).context().cache().context().tm().deadlockDetectionEnabled());
+
+ doTest(OPTIMISTIC);
+
+ try {
+ GridTestUtils.setFieldValue(null, IgniteTxManager.class, "DEADLOCK_MAX_ITERS", 0);
+
+ assertFalse(grid(0).context().cache().context().tm().deadlockDetectionEnabled());
+
+ doTest(OPTIMISTIC);
+ }
+ finally {
+ GridTestUtils.setFieldValue(null, IgniteTxManager.class, "DEADLOCK_MAX_ITERS",
+ IgniteSystemProperties.getInteger(IGNITE_TX_DEADLOCK_DETECTION_MAX_ITERS, 1000));
+ }
+ }
+
+ /**
+ * @param concurrency Concurrency.
+ * @throws IgniteCheckedException If failed.
+ */
+ private void doTest(final TransactionConcurrency concurrency) throws IgniteCheckedException {
+ final AtomicBoolean stop = new AtomicBoolean();
+
+ IgniteInternalFuture<Long> restartFut = null;
+
+ try {
+ restartFut = GridTestUtils.runMultiThreadedAsync(new Runnable() {
+ @Override public void run() {
+ while (!stop.get()) {
+ try {
+ U.sleep(500);
+
+ startGrid(NODES_CNT);
+
+ awaitPartitionMapExchange();
+
+ U.sleep(500);
+
+ stopGrid(NODES_CNT);
+ }
+ catch (Exception e) {
+ // No-op.
+ }
+ }
+ }
+ }, 1, "restart-thread");
+
+ long stopTime = System.currentTimeMillis() + 2 * 60_000L;
+
+ for (int i = 0; System.currentTimeMillis() < stopTime; i++) {
+ boolean detectionEnabled = grid(0).context().cache().context().tm().deadlockDetectionEnabled();
+
+ log.info(">>> Iteration " + i + " (detection is " + (detectionEnabled ? "enabled" : "disabled") + ')');
+
+ final AtomicInteger threadCnt = new AtomicInteger();
+
+ IgniteInternalFuture<Long> fut = GridTestUtils.runMultiThreadedAsync(new Runnable() {
+ @Override public void run() {
+ int threadNum = threadCnt.getAndIncrement();
+
+ Ignite ignite = ignite(threadNum % NODES_CNT);
+
+ IgniteCache<Integer, Integer> cache = ignite.cache(CACHE);
+
+ try (Transaction tx = ignite.transactions().txStart(concurrency, REPEATABLE_READ, 500, 0)) {
+ ThreadLocalRandom rnd = ThreadLocalRandom.current();
+
+ for (int i = 0; i < 50; i++) {
+ int key = rnd.nextInt(50);
+
+ if (log.isDebugEnabled()) {
+ log.info(">>> Performs put [node=" + ((IgniteKernal)ignite).localNode() +
+ ", tx=" + tx + ", key=" + key + ']');
+ }
+
+ cache.put(key, 0);
+ }
+
+ tx.commit();
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }, NODES_CNT * 3, "tx-thread");
+
+ fut.get();
+ }
+ }
+ finally {
+ stop.set(true);
+
+ if (restartFut != null)
+ restartFut.get();
+
+ checkDetectionFutures();
+ }
+ }
+
+ /**
+ *
+ */
+ private void checkDetectionFutures() {
+ for (int i = 0; i < NODES_CNT ; i++) {
+ Ignite ignite = ignite(i);
+
+ IgniteTxManager txMgr = ((IgniteKernal)ignite).context().cache().context().tm();
+
+ Collection<IgniteInternalFuture<?>> futs = txMgr.deadlockDetectionFutures();
+
+ assertTrue(futs.isEmpty());
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/0465874d/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlockDetectionTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlockDetectionTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlockDetectionTest.java
index 3d0beac..87bc70f 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlockDetectionTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxDeadlockDetectionTest.java
@@ -21,8 +21,9 @@ import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
-import java.util.concurrent.ConcurrentMap;
+import java.util.Collection;
import java.util.concurrent.CyclicBarrier;
+import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
@@ -47,7 +48,6 @@ import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import org.apache.ignite.transactions.Transaction;
import org.apache.ignite.transactions.TransactionDeadlockException;
import org.apache.ignite.transactions.TransactionTimeoutException;
-import org.jsr166.ThreadLocalRandom8;
import static org.apache.ignite.internal.util.typedef.X.hasCause;
import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
@@ -152,7 +152,7 @@ public class TxDeadlockDetectionTest extends GridCommonAbstractTest {
IgniteCache<Integer, Integer> cache = ignite.cache(CACHE);
try (Transaction tx = ignite.transactions().txStart(PESSIMISTIC, REPEATABLE_READ, 700, 0)) {
- ThreadLocalRandom8 rnd = ThreadLocalRandom8.current();
+ ThreadLocalRandom rnd = ThreadLocalRandom.current();
for (int i = 0; i < 50; i++) {
int key = rnd.nextInt(50);
@@ -217,7 +217,7 @@ public class TxDeadlockDetectionTest extends GridCommonAbstractTest {
cache.put(key, 0);
- barrier.await(timeout + 100, TimeUnit.MILLISECONDS);
+ barrier.await(timeout + 1000, TimeUnit.MILLISECONDS);
tx.commit();
}
@@ -281,7 +281,7 @@ public class TxDeadlockDetectionTest extends GridCommonAbstractTest {
log.info(">>> Performs sleep. [node=" + ((IgniteKernal)ignite).localNode() +
", tx=" + tx + ']');
- U.sleep(timeout * 2);
+ U.sleep(timeout * 3);
}
else {
int key2 = threadNum + 1;
@@ -406,8 +406,7 @@ public class TxDeadlockDetectionTest extends GridCommonAbstractTest {
IgniteTxManager txMgr = ((IgniteKernal)ignite).context().cache().context().tm();
- ConcurrentMap<Long, TxDeadlockDetection.TxDeadlockFuture> futs =
- GridTestUtils.getFieldValue(txMgr, IgniteTxManager.class, "deadlockDetectFuts");
+ Collection<IgniteInternalFuture<?>> futs = txMgr.deadlockDetectionFutures();
assertTrue(futs.isEmpty());
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/0465874d/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxOptimisticDeadlockDetectionCrossCacheTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxOptimisticDeadlockDetectionCrossCacheTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxOptimisticDeadlockDetectionCrossCacheTest.java
new file mode 100644
index 0000000..7b40da2
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxOptimisticDeadlockDetectionCrossCacheTest.java
@@ -0,0 +1,257 @@
+/*
+ * 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.transactions;
+
+import java.util.Collection;
+import java.util.Set;
+import java.util.concurrent.CyclicBarrier;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.IgniteInterruptedCheckedException;
+import org.apache.ignite.internal.IgniteKernal;
+import org.apache.ignite.internal.managers.communication.GridIoMessage;
+import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxPrepareRequest;
+import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxPrepareResponse;
+import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
+import org.apache.ignite.internal.util.GridConcurrentHashSet;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteInClosure;
+import org.apache.ignite.plugin.extensions.communication.Message;
+import org.apache.ignite.spi.IgniteSpiException;
+import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.apache.ignite.transactions.Transaction;
+import org.apache.ignite.transactions.TransactionDeadlockException;
+import org.apache.ignite.transactions.TransactionTimeoutException;
+
+import static org.apache.ignite.internal.util.typedef.X.hasCause;
+import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC;
+import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ;
+
+/**
+ *
+ */
+public class TxOptimisticDeadlockDetectionCrossCacheTest extends GridCommonAbstractTest {
+ /** Nodes count. */
+ private static final int NODES_CNT = 2;
+
+ /** {@inheritDoc} */
+ @SuppressWarnings("unchecked")
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ if (isDebug()) {
+ TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
+
+ discoSpi.failureDetectionTimeoutEnabled(false);
+
+ cfg.setDiscoverySpi(discoSpi);
+ }
+
+ TcpCommunicationSpi commSpi = new TestCommunicationSpi();
+
+ cfg.setCommunicationSpi(commSpi);
+
+ CacheConfiguration ccfg0 = defaultCacheConfiguration();
+
+ ccfg0.setName("cache0");
+ ccfg0.setCacheMode(CacheMode.PARTITIONED);
+ ccfg0.setBackups(1);
+ ccfg0.setNearConfiguration(null);
+
+ CacheConfiguration ccfg1 = defaultCacheConfiguration();
+
+ ccfg1.setName("cache1");
+ ccfg1.setCacheMode(CacheMode.PARTITIONED);
+ ccfg1.setBackups(1);
+ ccfg1.setNearConfiguration(null);
+
+ cfg.setCacheConfiguration(ccfg0, ccfg1);
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTestsStarted() throws Exception {
+ super.beforeTestsStarted();
+
+ startGrids(NODES_CNT);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ super.afterTestsStopped();
+
+ stopAllGrids();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDeadlock() throws Exception {
+ // Sometimes boh transactions perform commit, so we repeat attempt.
+ while (!doTestDeadlock()) {}
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ private boolean doTestDeadlock() throws Exception {
+ TestCommunicationSpi.init(2);
+
+ final CyclicBarrier barrier = new CyclicBarrier(2);
+
+ final AtomicInteger threadCnt = new AtomicInteger();
+
+ final AtomicBoolean deadlock = new AtomicBoolean();
+
+ final AtomicInteger commitCnt = new AtomicInteger();
+
+ IgniteInternalFuture<Long> fut = GridTestUtils.runMultiThreadedAsync(new Runnable() {
+ @Override public void run() {
+ int threadNum = threadCnt.getAndIncrement();
+
+ Ignite ignite = ignite(0);
+
+ IgniteCache<Integer, Integer> cache1 = ignite.cache("cache" + (threadNum == 0 ? 0 : 1));
+
+ IgniteCache<Integer, Integer> cache2 = ignite.cache("cache" + (threadNum == 0 ? 1 : 0));
+
+ try (Transaction tx =
+ ignite.transactions().txStart(OPTIMISTIC, REPEATABLE_READ, 500, 0)
+ ) {
+ int key1 = primaryKey(cache1);
+
+ log.info(">>> Performs put [node=" + ((IgniteKernal)ignite).localNode() +
+ ", tx=" + tx + ", key=" + key1 + ", cache=" + cache1.getName() + ']');
+
+ cache1.put(key1, 0);
+
+ barrier.await();
+
+ int key2 = primaryKey(cache2);
+
+ log.info(">>> Performs put [node=" + ((IgniteKernal)ignite).localNode() +
+ ", tx=" + tx + ", key=" + key2 + ", cache=" + cache2.getName() + ']');
+
+ cache2.put(key2, 1);
+
+ tx.commit();
+
+ commitCnt.incrementAndGet();
+ }
+ catch (Throwable e) {
+ // At least one stack trace should contain TransactionDeadlockException.
+ if (hasCause(e, TransactionTimeoutException.class) &&
+ hasCause(e, TransactionDeadlockException.class)
+ ) {
+ if (deadlock.compareAndSet(false, true))
+ U.error(log, "At least one stack trace should contain " +
+ TransactionDeadlockException.class.getSimpleName(), e);
+ }
+ }
+ }
+ }, 2, "tx-thread");
+
+ fut.get();
+
+ if (commitCnt.get() == 2)
+ return false;
+
+ assertTrue(deadlock.get());
+
+ for (int i = 0; i < NODES_CNT ; i++) {
+ Ignite ignite = ignite(i);
+
+ IgniteTxManager txMgr = ((IgniteKernal)ignite).context().cache().context().tm();
+
+ Collection<IgniteInternalFuture<?>> futs = txMgr.deadlockDetectionFutures();
+
+ assertTrue(futs.isEmpty());
+ }
+
+ return true;
+ }
+
+ /**
+ *
+ */
+ private static class TestCommunicationSpi extends TcpCommunicationSpi {
+ /** Tx count. */
+ private static volatile int TX_CNT;
+
+ /** Tx ids. */
+ private static final Set<GridCacheVersion> TX_IDS = new GridConcurrentHashSet<>();
+
+ /**
+ * @param txCnt Tx count.
+ */
+ private static void init(int txCnt) {
+ TX_CNT = txCnt;
+ TX_IDS.clear();
+ }
+
+ /** {@inheritDoc} */
+ @Override public void sendMessage(
+ final ClusterNode node,
+ final Message msg,
+ final IgniteInClosure<IgniteException> ackC
+ ) throws IgniteSpiException {
+ if (msg instanceof GridIoMessage) {
+ Message msg0 = ((GridIoMessage)msg).message();
+
+ if (msg0 instanceof GridNearTxPrepareRequest) {
+ final GridNearTxPrepareRequest req = (GridNearTxPrepareRequest)msg0;
+
+ GridCacheVersion txId = req.version();
+
+ if (TX_IDS.contains(txId)) {
+ while (TX_IDS.size() < TX_CNT) {
+ try {
+ U.sleep(50);
+ }
+ catch (IgniteInterruptedCheckedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+ else if (msg0 instanceof GridNearTxPrepareResponse) {
+ GridNearTxPrepareResponse res = (GridNearTxPrepareResponse)msg0;
+
+ GridCacheVersion txId = res.version();
+
+ TX_IDS.add(txId);
+ }
+ }
+
+ super.sendMessage(node, msg, ackC);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/0465874d/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxOptimisticDeadlockDetectionTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxOptimisticDeadlockDetectionTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxOptimisticDeadlockDetectionTest.java
new file mode 100644
index 0000000..aa240aa
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/TxOptimisticDeadlockDetectionTest.java
@@ -0,0 +1,574 @@
+/*
+ * 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.transactions;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.CyclicBarrier;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicReference;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.cache.CacheWriteSynchronizationMode;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.NearCacheConfiguration;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.IgniteInterruptedCheckedException;
+import org.apache.ignite.internal.IgniteKernal;
+import org.apache.ignite.internal.managers.communication.GridIoMessage;
+import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
+import org.apache.ignite.internal.processors.cache.GridCacheConcurrentMap;
+import org.apache.ignite.internal.processors.cache.GridCacheMapEntry;
+import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
+import org.apache.ignite.internal.processors.cache.IgniteCacheProxy;
+import org.apache.ignite.internal.processors.cache.KeyCacheObject;
+import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxPrepareRequest;
+import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxPrepareResponse;
+import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
+import org.apache.ignite.internal.util.GridConcurrentHashSet;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteClosure;
+import org.apache.ignite.lang.IgniteInClosure;
+import org.apache.ignite.plugin.extensions.communication.Message;
+import org.apache.ignite.spi.IgniteSpiException;
+import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.apache.ignite.transactions.Transaction;
+import org.apache.ignite.transactions.TransactionDeadlockException;
+import org.apache.ignite.transactions.TransactionTimeoutException;
+
+import static org.apache.ignite.cache.CacheMode.PARTITIONED;
+import static org.apache.ignite.cache.CacheMode.REPLICATED;
+import static org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion.NONE;
+import static org.apache.ignite.internal.util.typedef.X.cause;
+import static org.apache.ignite.internal.util.typedef.X.hasCause;
+import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC;
+import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ;
+
+/**
+ *
+ */
+public class TxOptimisticDeadlockDetectionTest extends GridCommonAbstractTest {
+ /** Cache name. */
+ private static final String CACHE_NAME = "cache";
+
+ /** Nodes count (actually two times more nodes will started: server + client). */
+ private static final int NODES_CNT = 4;
+
+ /** No op transformer. */
+ private static final NoOpTransformer NO_OP_TRANSFORMER = new NoOpTransformer();
+
+ /** Wrapping transformer. */
+ private static final WrappingTransformer WRAPPING_TRANSFORMER = new WrappingTransformer();
+
+ /** Client mode flag. */
+ private static boolean client;
+
+ /** {@inheritDoc} */
+ @SuppressWarnings("unchecked")
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ if (isDebug()) {
+ TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
+
+ discoSpi.failureDetectionTimeoutEnabled(false);
+
+ cfg.setDiscoverySpi(discoSpi);
+ }
+
+ TcpCommunicationSpi commSpi = new TestCommunicationSpi();
+
+ cfg.setCommunicationSpi(commSpi);
+
+ cfg.setClientMode(client);
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTestsStarted() throws Exception {
+ super.beforeTestsStarted();
+
+ client = false;
+
+ startGrids(NODES_CNT);
+
+ client = true;
+
+ for (int i = 0; i < NODES_CNT; i++)
+ startGrid(i + NODES_CNT);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ super.afterTestsStopped();
+
+ stopAllGrids();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDeadlocksPartitioned() throws Exception {
+ for (CacheWriteSynchronizationMode syncMode : CacheWriteSynchronizationMode.values()) {
+ doTestDeadlocks(createCache(PARTITIONED, syncMode, false), NO_OP_TRANSFORMER);
+ doTestDeadlocks(createCache(PARTITIONED, syncMode, false), WRAPPING_TRANSFORMER);
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDeadlocksPartitionedNear() throws Exception {
+ for (CacheWriteSynchronizationMode syncMode : CacheWriteSynchronizationMode.values()) {
+ doTestDeadlocks(createCache(PARTITIONED, syncMode, true), NO_OP_TRANSFORMER);
+ doTestDeadlocks(createCache(PARTITIONED, syncMode, true), WRAPPING_TRANSFORMER);
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDeadlocksReplicated() throws Exception {
+ for (CacheWriteSynchronizationMode syncMode : CacheWriteSynchronizationMode.values()) {
+ doTestDeadlocks(createCache(REPLICATED, syncMode, false), NO_OP_TRANSFORMER);
+ doTestDeadlocks(createCache(REPLICATED, syncMode, false), WRAPPING_TRANSFORMER);
+ }
+ }
+
+ /**
+ * @param cacheMode Cache mode.
+ * @param syncMode Write sync mode.
+ * @param near Near.
+ * @return Created cache.
+ */
+ @SuppressWarnings("unchecked")
+ private IgniteCache createCache(CacheMode cacheMode, CacheWriteSynchronizationMode syncMode, boolean near) {
+ CacheConfiguration ccfg = defaultCacheConfiguration();
+
+ ccfg.setName(CACHE_NAME);
+ ccfg.setCacheMode(cacheMode);
+ ccfg.setBackups(1);
+ ccfg.setNearConfiguration(near ? new NearCacheConfiguration() : null);
+ ccfg.setWriteSynchronizationMode(syncMode);
+
+ IgniteCache cache = ignite(0).createCache(ccfg);
+
+ if (near) {
+ for (int i = 0; i < NODES_CNT; i++) {
+ Ignite client = ignite(i + NODES_CNT);
+
+ assertTrue(client.configuration().isClientMode());
+
+ client.createNearCache(ccfg.getName(), new NearCacheConfiguration<>());
+ }
+ }
+
+ return cache;
+ }
+
+ /**
+ * @param cache Cache.
+ * @param transformer Transformer closure.
+ * @throws Exception If failed.
+ */
+ private void doTestDeadlocks(IgniteCache cache, IgniteClosure<Integer, Object> transformer) throws Exception {
+ try {
+ awaitPartitionMapExchange();
+
+ doTestDeadlock(3, false, true, true, transformer);
+ doTestDeadlock(3, false, false, false, transformer);
+ doTestDeadlock(3, false, false, true, transformer);
+
+ doTestDeadlock(4, false, true, true, transformer);
+ doTestDeadlock(4, false, false, false, transformer);
+ doTestDeadlock(4, false, false, true, transformer);
+ }
+ catch (Throwable e) {
+ U.error(log, "Unexpected exception: ", e);
+
+ fail();
+ }
+ finally {
+ if (cache != null)
+ cache.destroy();
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ private void doTestDeadlock(
+ final int txCnt,
+ final boolean loc,
+ boolean lockPrimaryFirst,
+ final boolean clientTx,
+ final IgniteClosure<Integer, Object> transformer
+ ) throws Exception {
+ log.info(">>> Test deadlock [txCnt=" + txCnt + ", loc=" + loc + ", lockPrimaryFirst=" + lockPrimaryFirst +
+ ", clientTx=" + clientTx + ", transformer=" + transformer.getClass().getName() + ']');
+
+ TestCommunicationSpi.init(txCnt);
+
+ final AtomicInteger threadCnt = new AtomicInteger();
+
+ final CyclicBarrier barrier = new CyclicBarrier(txCnt);
+
+ final AtomicReference<TransactionDeadlockException> deadlockErr = new AtomicReference<>();
+
+ final List<List<Integer>> keySets = generateKeys(txCnt, loc, !lockPrimaryFirst);
+
+ final Set<Integer> involvedKeys = new GridConcurrentHashSet<>();
+ final Set<Integer> involvedLockedKeys = new GridConcurrentHashSet<>();
+ final Set<IgniteInternalTx> involvedTxs = new GridConcurrentHashSet<>();
+
+ IgniteInternalFuture<Long> fut = GridTestUtils.runMultiThreadedAsync(new Runnable() {
+ @Override public void run() {
+ int threadNum = threadCnt.incrementAndGet();
+
+ Ignite ignite = loc ? ignite(0) : ignite(clientTx ? threadNum - 1 + txCnt : threadNum - 1);
+
+ IgniteCache<Object, Integer> cache = ignite.cache(CACHE_NAME);
+
+ List<Integer> keys = keySets.get(threadNum - 1);
+
+ int txTimeout = 500 + txCnt * 100;
+
+ try (Transaction tx = ignite.transactions().txStart(OPTIMISTIC, REPEATABLE_READ, txTimeout, 0)) {
+ IgniteInternalTx tx0 = ((TransactionProxyImpl)tx).tx();
+
+ involvedTxs.add(tx0);
+
+ Integer key = keys.get(0);
+
+ involvedKeys.add(key);
+
+ Object k;
+
+ log.info(">>> Performs put [node=" + ((IgniteKernal)ignite).localNode() +
+ ", tx=" + tx + ", key=" + transformer.apply(key) + ']');
+
+ cache.put(transformer.apply(key), 0);
+
+ involvedLockedKeys.add(key);
+
+ barrier.await();
+
+ key = keys.get(1);
+
+ ClusterNode primaryNode =
+ ((IgniteCacheProxy)cache).context().affinity().primary(key, NONE);
+
+ List<Integer> primaryKeys =
+ primaryKeys(grid(primaryNode).cache(CACHE_NAME), 5, key + (100 * threadNum));
+
+ Map<Object, Integer> entries = new HashMap<>();
+
+ involvedKeys.add(key);
+
+ entries.put(transformer.apply(key), 0);
+
+ for (Integer i : primaryKeys) {
+ involvedKeys.add(i);
+
+ entries.put(transformer.apply(i), 1);
+
+ k = transformer.apply(i + 13);
+
+ involvedKeys.add(i + 13);
+
+ entries.put(k, 2);
+ }
+
+ log.info(">>> Performs put [node=" + ((IgniteKernal)ignite).localNode() +
+ ", tx=" + tx + ", entries=" + entries + ']');
+
+ cache.putAll(entries);
+
+ tx.commit();
+ }
+ catch (Throwable e) {
+ U.error(log, "Expected exception: ", e);
+
+ // At least one stack trace should contain TransactionDeadlockException.
+ if (hasCause(e, TransactionTimeoutException.class) &&
+ hasCause(e, TransactionDeadlockException.class)
+ ) {
+ if (deadlockErr.compareAndSet(null, cause(e, TransactionDeadlockException.class)))
+ U.error(log, "At least one stack trace should contain " +
+ TransactionDeadlockException.class.getSimpleName(), e);
+ }
+ }
+ }
+ }, loc ? 2 : txCnt, "tx-thread");
+
+ try {
+ fut.get();
+ }
+ catch (IgniteCheckedException e) {
+ U.error(null, "Unexpected exception", e);
+
+ fail();
+ }
+
+ U.sleep(1000);
+
+ TransactionDeadlockException deadlockE = deadlockErr.get();
+
+ assertNotNull(deadlockE);
+
+ boolean fail = false;
+
+ // Check transactions, futures and entry locks state.
+ for (int i = 0; i < NODES_CNT * 2; i++) {
+ Ignite ignite = ignite(i);
+
+ int cacheId = ((IgniteCacheProxy)ignite.cache(CACHE_NAME)).context().cacheId();
+
+ GridCacheSharedContext<Object, Object> cctx = ((IgniteKernal)ignite).context().cache().context();
+
+ IgniteTxManager txMgr = cctx.tm();
+
+ Collection<IgniteInternalTx> activeTxs = txMgr.activeTransactions();
+
+ for (IgniteInternalTx tx : activeTxs) {
+ Collection<IgniteTxEntry> entries = tx.allEntries();
+
+ for (IgniteTxEntry entry : entries) {
+ if (entry.cacheId() == cacheId) {
+ fail = true;
+
+ U.error(log, "Transaction still exists: " + "\n" + tx.xidVersion() +
+ "\n" + tx.nearXidVersion() + "\n nodeId=" + cctx.localNodeId() + "\n tx=" + tx);
+ }
+ }
+ }
+
+ Collection<IgniteInternalFuture<?>> futs = txMgr.deadlockDetectionFutures();
+
+ assertTrue(futs.isEmpty());
+
+ GridCacheAdapter<Object, Integer> intCache = internalCache(i, CACHE_NAME);
+
+ GridCacheConcurrentMap map = intCache.map();
+
+ for (Integer key : involvedKeys) {
+ Object key0 = transformer.apply(key);
+
+ KeyCacheObject keyCacheObj = intCache.context().toCacheKeyObject(key0);
+
+ GridCacheMapEntry entry = map.getEntry(keyCacheObj);
+
+ if (entry != null)
+ assertNull("Entry still has locks " + entry, entry.mvccAllLocal());
+ }
+ }
+
+ if (fail)
+ fail("Some transactions still exist");
+
+ // Check deadlock report
+ String msg = deadlockE.getMessage();
+
+ for (IgniteInternalTx tx : involvedTxs)
+ assertTrue(msg.contains(
+ "[txId=" + tx.xidVersion() + ", nodeId=" + tx.nodeId() + ", threadId=" + tx.threadId() + ']'));
+
+ for (Integer key : involvedKeys) {
+ if (involvedLockedKeys.contains(key))
+ assertTrue(msg.contains("[key=" + transformer.apply(key) + ", cache=" + CACHE_NAME + ']'));
+ else
+ assertFalse(msg.contains("[key=" + transformer.apply(key)));
+ }
+ }
+
+ /**
+ * @param nodesCnt Nodes count.
+ * @param loc Local cache.
+ */
+ private List<List<Integer>> generateKeys(int nodesCnt, boolean loc, boolean reverse) throws IgniteCheckedException {
+ List<List<Integer>> keySets = new ArrayList<>();
+
+ if (loc) {
+ List<Integer> keys = primaryKeys(ignite(0).cache(CACHE_NAME), 2);
+
+ keySets.add(new ArrayList<>(keys));
+
+ Collections.reverse(keys);
+
+ keySets.add(keys);
+ }
+ else {
+ for (int i = 0; i < nodesCnt; i++) {
+ List<Integer> keys = new ArrayList<>(2);
+
+ int n1 = i + 1;
+ int n2 = n1 + 1;
+
+ int i1 = n1 < nodesCnt ? n1 : n1 - nodesCnt;
+ int i2 = n2 < nodesCnt ? n2 : n2 - nodesCnt;
+
+ keys.add(primaryKey(ignite(i1).cache(CACHE_NAME)));
+ keys.add(primaryKey(ignite(i2).cache(CACHE_NAME)));
+
+ if (reverse)
+ Collections.reverse(keys);
+
+ keySets.add(keys);
+ }
+ }
+
+ return keySets;
+ }
+
+ /**
+ *
+ */
+ private static class NoOpTransformer implements IgniteClosure<Integer, Object> {
+ /** {@inheritDoc} */
+ @Override public Object apply(Integer val) {
+ return val;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class WrappingTransformer implements IgniteClosure<Integer, Object> {
+ /** {@inheritDoc} */
+ @Override public Object apply(Integer val) {
+ return new KeyObject(val);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class KeyObject implements Serializable {
+ /** Id. */
+ private int id;
+
+ /** Name. */
+ private String name;
+
+ /**
+ * @param id Id.
+ */
+ public KeyObject(int id) {
+ this.id = id;
+ this.name = "KeyObject" + id;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return "KeyObject{" +
+ "id=" + id +
+ ", name='" + name + '\'' +
+ '}';
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object o) {
+ if (this == o)
+ return true;
+
+ if (o == null || getClass() != o.getClass())
+ return false;
+
+ KeyObject obj = (KeyObject)o;
+
+ return id == obj.id && name.equals(obj.name);
+
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ return id;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class TestCommunicationSpi extends TcpCommunicationSpi {
+ /** Tx count. */
+ private static volatile int TX_CNT;
+
+ /** Tx ids. */
+ private static final Set<GridCacheVersion> TX_IDS = new GridConcurrentHashSet<>();
+
+ /**
+ * @param txCnt Tx count.
+ */
+ private static void init(int txCnt) {
+ TX_CNT = txCnt;
+ TX_IDS.clear();
+ }
+
+ /** {@inheritDoc} */
+ @Override public void sendMessage(
+ final ClusterNode node,
+ final Message msg,
+ final IgniteInClosure<IgniteException> ackC
+ ) throws IgniteSpiException {
+ if (msg instanceof GridIoMessage) {
+ Message msg0 = ((GridIoMessage)msg).message();
+
+ if (msg0 instanceof GridNearTxPrepareRequest) {
+ final GridNearTxPrepareRequest req = (GridNearTxPrepareRequest)msg0;
+
+ GridCacheVersion txId = req.version();
+
+ if (TX_IDS.contains(txId)) {
+ while (TX_IDS.size() < TX_CNT) {
+ try {
+ U.sleep(50);
+ }
+ catch (IgniteInterruptedCheckedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+ else if (msg0 instanceof GridNearTxPrepareResponse) {
+ GridNearTxPrepareResponse res = (GridNearTxPrepareResponse)msg0;
+
+ GridCacheVersion txId = res.version();
+
+ TX_IDS.add(txId);
+ }
+ }
+
+ super.sendMessage(node, msg, ackC);
+ }
+ }
+}
[37/50] [abbrv] ignite git commit: IGNITE-3390: Added DSN
configuration window.
Posted by sb...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc/src/protocol_version.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/protocol_version.cpp b/modules/platforms/cpp/odbc/src/protocol_version.cpp
new file mode 100644
index 0000000..818df88
--- /dev/null
+++ b/modules/platforms/cpp/odbc/src/protocol_version.cpp
@@ -0,0 +1,131 @@
+/*
+ * 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.
+ */
+#include <ignite/common/concurrent.h>
+#include <ignite/common/utils.h>
+#include <ignite/ignite_error.h>
+
+#include "ignite/odbc/protocol_version.h"
+#include "ignite/odbc/utility.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ const ProtocolVersion ProtocolVersion::VERSION_1_6_0(1);
+ const ProtocolVersion ProtocolVersion::VERSION_UNKNOWN(INT64_MIN);
+
+ ProtocolVersion::StringToVersionMap::value_type s2vInitVals[] = {
+ std::make_pair("1.6.0", ProtocolVersion::VERSION_1_6_0)
+ };
+
+ const ProtocolVersion::StringToVersionMap ProtocolVersion::stringToVersionMap(s2vInitVals,
+ s2vInitVals + (sizeof(s2vInitVals) / sizeof(s2vInitVals[0])));
+
+ ProtocolVersion::VersionToStringMap::value_type v2sInitVals[] = {
+ std::make_pair(ProtocolVersion::VERSION_1_6_0, "1.6.0")
+ };
+
+ const ProtocolVersion::VersionToStringMap ProtocolVersion::versionToStringMap(v2sInitVals,
+ v2sInitVals + (sizeof(v2sInitVals) / sizeof(v2sInitVals[0])));
+
+ ProtocolVersion::ProtocolVersion(int64_t val) :
+ val(val)
+ {
+ // No-op.
+ }
+
+ const ProtocolVersion::StringToVersionMap& ProtocolVersion::GetMap()
+ {
+ return stringToVersionMap;
+ }
+
+ const ProtocolVersion& ProtocolVersion::GetCurrent()
+ {
+ return VERSION_1_6_0;
+ }
+
+ ProtocolVersion ProtocolVersion::FromString(const std::string& version)
+ {
+ StringToVersionMap::const_iterator it = stringToVersionMap.find(common::ToLower(version));
+
+ if (it == stringToVersionMap.end())
+ {
+ throw IgniteError(IgniteError::IGNITE_ERR_GENERIC,
+ "Invalid version format. Valid format is X.Y.Z, where X, Y and Z are major "
+ "and minor versions and revision of Ignite since which protocol is introduced.");
+ }
+
+ return it->second;
+ }
+
+ const std::string& ProtocolVersion::ToString() const
+ {
+ VersionToStringMap::const_iterator it = versionToStringMap.find(*this);
+
+ if (it == versionToStringMap.end())
+ {
+ throw IgniteError(IgniteError::IGNITE_ERR_GENERIC,
+ "Unknown protocol version can not be converted to string.");
+ }
+
+ return it->second;
+ }
+
+ int64_t ProtocolVersion::GetIntValue() const
+ {
+ assert(!IsUnknown());
+
+ return val;
+ }
+
+ bool ProtocolVersion::IsUnknown() const
+ {
+ return *this == VERSION_UNKNOWN;
+ }
+
+ bool operator==(const ProtocolVersion& val1, const ProtocolVersion& val2)
+ {
+ return val1.val == val2.val;
+ }
+
+ bool operator!=(const ProtocolVersion& val1, const ProtocolVersion& val2)
+ {
+ return val1.val != val2.val;
+ }
+
+ bool operator<(const ProtocolVersion& val1, const ProtocolVersion& val2)
+ {
+ return val1.val < val2.val;
+ }
+
+ bool operator<=(const ProtocolVersion& val1, const ProtocolVersion& val2)
+ {
+ return val1.val <= val2.val;
+ }
+
+ bool operator>(const ProtocolVersion& val1, const ProtocolVersion& val2)
+ {
+ return val1.val > val2.val;
+ }
+
+ bool operator>=(const ProtocolVersion& val1, const ProtocolVersion& val2)
+ {
+ return val1.val >= val2.val;
+ }
+ }
+}
+
[39/50] [abbrv] ignite git commit: IGNITE-3390: Added DSN
configuration window.
Posted by sb...@apache.org.
IGNITE-3390: Added DSN configuration window.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/70e69cb7
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/70e69cb7
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/70e69cb7
Branch: refs/heads/ignite-961
Commit: 70e69cb7aa08c268b07920838add4a40e28fe25d
Parents: dabd86c
Author: isapego <is...@gridgain.com>
Authored: Wed Aug 31 16:47:11 2016 +0300
Committer: isapego <is...@gridgain.com>
Committed: Wed Aug 31 16:47:11 2016 +0300
----------------------------------------------------------------------
.../processors/odbc/OdbcHandshakeRequest.java | 8 +-
.../processors/odbc/OdbcHandshakeResult.java | 17 +-
.../processors/odbc/OdbcMessageParser.java | 22 +-
.../processors/odbc/OdbcProtocolVersion.java | 106 ++++++++
.../processors/odbc/OdbcRequestHandler.java | 17 +-
.../cpp/common/include/ignite/common/utils.h | 25 ++
.../cpp/common/os/win/src/common/utils.cpp | 20 ++
modules/platforms/cpp/odbc-test/Makefile.am | 1 +
.../odbc-test/config/queries-test-noodbc.xml | 103 +++++++
.../cpp/odbc-test/config/queries-test.xml | 31 ++-
.../cpp/odbc-test/project/vs/odbc-test.vcxproj | 2 +
.../project/vs/odbc-test.vcxproj.filters | 6 +
.../cpp/odbc-test/src/configuration_test.cpp | 156 ++++++++---
.../cpp/odbc-test/src/queries_test.cpp | 122 ++++++---
.../odbc-test/src/sql_test_suite_fixture.cpp | 14 +-
modules/platforms/cpp/odbc/Makefile.am | 2 +
modules/platforms/cpp/odbc/include/Makefile.am | 2 +
.../cpp/odbc/include/ignite/odbc/common_types.h | 3 +
.../include/ignite/odbc/config/configuration.h | 207 +++++++++++++--
.../cpp/odbc/include/ignite/odbc/connection.h | 47 ++--
.../ignite/odbc/diagnostic/diagnostic_record.h | 2 +-
.../cpp/odbc/include/ignite/odbc/dsn_config.h | 61 +++++
.../cpp/odbc/include/ignite/odbc/parser.h | 3 -
.../odbc/include/ignite/odbc/protocol_version.h | 168 ++++++++++++
.../include/ignite/odbc/system/odbc_constants.h | 4 -
.../odbc/system/ui/dsn_configuration_window.h | 136 ++++++++++
.../ignite/odbc/system/ui/custom_window.h | 189 +++++++++++++
.../win/include/ignite/odbc/system/ui/window.h | 201 ++++++++++++++
.../odbc/os/win/src/system/ui/custom_window.cpp | 184 +++++++++++++
.../src/system/ui/dsn_configuration_window.cpp | 212 +++++++++++++++
.../cpp/odbc/os/win/src/system/ui/window.cpp | 192 +++++++++++++
.../cpp/odbc/os/win/src/system_dsn.cpp | 218 +++++++++++++++
.../platforms/cpp/odbc/project/vs/odbc.vcxproj | 27 +-
.../cpp/odbc/project/vs/odbc.vcxproj.filters | 36 +++
.../cpp/odbc/src/config/configuration.cpp | 266 +++++++++++--------
modules/platforms/cpp/odbc/src/connection.cpp | 66 +++--
.../odbc/src/diagnostic/diagnostic_record.cpp | 8 +-
.../diagnostic/diagnostic_record_storage.cpp | 2 +-
modules/platforms/cpp/odbc/src/dsn_config.cpp | 111 ++++++++
modules/platforms/cpp/odbc/src/entry_points.cpp | 8 -
modules/platforms/cpp/odbc/src/odbc.cpp | 83 ++----
.../platforms/cpp/odbc/src/protocol_version.cpp | 131 +++++++++
42 files changed, 2822 insertions(+), 397 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcHandshakeRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcHandshakeRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcHandshakeRequest.java
index 5e09041..2ffd8cd 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcHandshakeRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcHandshakeRequest.java
@@ -24,21 +24,21 @@ import org.apache.ignite.internal.util.typedef.internal.S;
*/
public class OdbcHandshakeRequest extends OdbcRequest {
/** Protocol version. */
- private final long ver;
+ private final OdbcProtocolVersion ver;
/**
- * @param ver Protocol version.
+ * @param ver Long value for protocol version.
*/
public OdbcHandshakeRequest(long ver) {
super(HANDSHAKE);
- this.ver = ver;
+ this.ver = OdbcProtocolVersion.fromLong(ver);
}
/**
* @return Protocol version.
*/
- public long version() {
+ public OdbcProtocolVersion version() {
return ver;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcHandshakeResult.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcHandshakeResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcHandshakeResult.java
index bf1c61e..74c5bd4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcHandshakeResult.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcHandshakeResult.java
@@ -17,7 +17,7 @@
package org.apache.ignite.internal.processors.odbc;
-import org.jetbrains.annotations.Nullable;
+import org.apache.ignite.internal.util.typedef.internal.S;
/**
* ODBC handshake result.
@@ -33,11 +33,13 @@ public class OdbcHandshakeResult {
private final String curVer;
/**
- * @param accepted Handshake accepted.
+ * Constructor.
+ *
+ * @param accepted Indicates whether handshake accepted or not.
* @param protoVerSince Apache Ignite version when protocol version has been introduced.
* @param curVer Current Apache Ignite version.
*/
- public OdbcHandshakeResult(boolean accepted, @Nullable String protoVerSince, @Nullable String curVer) {
+ public OdbcHandshakeResult(boolean accepted, String protoVerSince, String curVer) {
this.accepted = accepted;
this.protoVerSince = protoVerSince;
this.curVer = curVer;
@@ -53,14 +55,19 @@ public class OdbcHandshakeResult {
/**
* @return Apache Ignite version when protocol version has been introduced.
*/
- @Nullable public String protoVerSince() {
+ public String protocolVersionSince() {
return protoVerSince;
}
/**
* @return Current Apache Ignite version.
*/
- @Nullable public String currentVer() {
+ public String currentVersion() {
return curVer;
}
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(OdbcHandshakeResult.class, this);
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcMessageParser.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcMessageParser.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcMessageParser.java
index fce8b1b..a751eb2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcMessageParser.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcMessageParser.java
@@ -34,12 +34,6 @@ import java.util.Collection;
* ODBC message parser.
*/
public class OdbcMessageParser {
- /** Current ODBC communication protocol version. */
- public static final long PROTO_VER = 1;
-
- /** Apache Ignite version when ODBC communication protocol version has been introduced. */
- public static final String PROTO_VER_SINCE = "1.6.0";
-
/** Initial output stream capacity. */
private static final int INIT_CAP = 1024;
@@ -82,10 +76,14 @@ public class OdbcMessageParser {
// we has not confirmed that the remote client uses the same protocol version.
if (!verConfirmed) {
if (cmd == OdbcRequest.HANDSHAKE)
- return new OdbcHandshakeRequest(reader.readLong());
+ {
+ long longVersion = reader.readLong();
+
+ return new OdbcHandshakeRequest(longVersion);
+ }
else
- throw new IgniteException("Unexpected ODBC command (first message is not a handshake request): [cmd=" +
- cmd + ']');
+ throw new IgniteException("Unexpected ODBC command " +
+ "(first message is not a handshake request): [cmd=" + cmd + ']');
}
OdbcRequest res;
@@ -174,6 +172,8 @@ public class OdbcMessageParser {
Object res0 = msg.response();
+ if (res0 == null)
+ return writer.array();
if (res0 instanceof OdbcHandshakeResult) {
OdbcHandshakeResult res = (OdbcHandshakeResult) res0;
@@ -189,8 +189,8 @@ public class OdbcMessageParser {
}
else {
writer.writeBoolean(false);
- writer.writeString(res.protoVerSince());
- writer.writeString(res.currentVer());
+ writer.writeString(res.protocolVersionSince());
+ writer.writeString(res.currentVersion());
}
}
else if (res0 instanceof OdbcQueryExecuteResult) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcProtocolVersion.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcProtocolVersion.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcProtocolVersion.java
new file mode 100644
index 0000000..97a1306
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcProtocolVersion.java
@@ -0,0 +1,106 @@
+/*
+ * 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.odbc;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * ODBC protocol version.
+ */
+public enum OdbcProtocolVersion {
+ /** First version of the ODBC. Released with Ignite 1.6 */
+ VERSION_1_6_0(1),
+
+ /** Unknown version. */
+ VERSION_UNKNOWN(Long.MIN_VALUE);
+
+ /** Long value to enum map. */
+ private static final Map<Long, OdbcProtocolVersion> versions = new HashMap<>();
+
+ /** Enum value to Ignite version map */
+ private static final Map<OdbcProtocolVersion, String> since = new HashMap<>();
+
+ /**
+ * Map long values to version.
+ */
+ static {
+ for (OdbcProtocolVersion version : values())
+ versions.put(version.longValue(), version);
+
+ since.put(VERSION_1_6_0, "1.6.0");
+ }
+
+ /** Long value for version. */
+ private final long longVal;
+
+ /**
+ * @param longVal Long value.
+ */
+ OdbcProtocolVersion(long longVal) {
+ this.longVal = longVal;
+ }
+
+ /**
+ * @param longVal Long value.
+ * @return Protocol version.
+ */
+ public static OdbcProtocolVersion fromLong(long longVal) {
+ OdbcProtocolVersion res = versions.get(longVal);
+
+ return res == null ? VERSION_UNKNOWN : res;
+ }
+
+ /**
+ * @return Current version.
+ */
+ public static OdbcProtocolVersion current() {
+ return VERSION_1_6_0;
+ }
+
+ /**
+ * @return Long value.
+ */
+ public long longValue() {
+ return longVal;
+ }
+
+ /**
+ * @return {@code true} if this version is unknown.
+ */
+ public boolean isUnknown() {
+ return longVal == VERSION_UNKNOWN.longVal;
+ }
+
+ /**
+ * @return {@code true} if this version supports distributed joins.
+ */
+ public boolean isDistributedJoinsSupported() {
+ assert !isUnknown();
+
+ return longVal >= VERSION_1_6_0.longVal;
+ }
+
+ /**
+ * @return Ignite version when introduced.
+ */
+ public String since() {
+ assert !isUnknown();
+
+ return since.get(this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcRequestHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcRequestHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcRequestHandler.java
index ce98720..3f7d505 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcRequestHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcRequestHandler.java
@@ -91,7 +91,7 @@ public class OdbcRequestHandler {
try {
switch (req.command()) {
case HANDSHAKE:
- return performHandshake(reqId, (OdbcHandshakeRequest)req);
+ return performHandshake((OdbcHandshakeRequest)req);
case EXECUTE_SQL_QUERY:
return executeQuery(reqId, (OdbcQueryExecuteRequest)req);
@@ -119,23 +119,24 @@ public class OdbcRequestHandler {
/**
* {@link OdbcHandshakeRequest} command handler.
*
- * @param reqId Request ID.
* @param req Handshake request.
* @return Response.
*/
- private OdbcResponse performHandshake(long reqId, OdbcHandshakeRequest req) {
- OdbcHandshakeResult res;
+ private OdbcResponse performHandshake(OdbcHandshakeRequest req) {
+ OdbcProtocolVersion version = req.version();
- if (req.version() == OdbcMessageParser.PROTO_VER)
- res = new OdbcHandshakeResult(true, null, null);
- else {
+ if (version.isUnknown()) {
IgniteProductVersion ver = ctx.grid().version();
String verStr = Byte.toString(ver.major()) + '.' + ver.minor() + '.' + ver.maintenance();
- res = new OdbcHandshakeResult(false, OdbcMessageParser.PROTO_VER_SINCE, verStr);
+ OdbcHandshakeResult res = new OdbcHandshakeResult(false, OdbcProtocolVersion.current().since(), verStr);
+
+ return new OdbcResponse(res);
}
+ OdbcHandshakeResult res = new OdbcHandshakeResult(true, null, null);
+
return new OdbcResponse(res);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/common/include/ignite/common/utils.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/include/ignite/common/utils.h b/modules/platforms/cpp/common/include/ignite/common/utils.h
index c1046e2..f4d2a9f 100644
--- a/modules/platforms/cpp/common/include/ignite/common/utils.h
+++ b/modules/platforms/cpp/common/include/ignite/common/utils.h
@@ -60,6 +60,13 @@ namespace ignite
}
/**
+ * Strips leading and trailing whitespaces from string.
+ *
+ * @param str String to be transformed.
+ */
+ IGNITE_IMPORT_EXPORT void StripSurroundingWhitespaces(std::string& str);
+
+ /**
* Get string representation of long in decimal form.
*
* @param val Long value to be converted to string.
@@ -179,6 +186,24 @@ namespace ignite
return res;
}
+
+ /**
+ * Check if the predicate returns true for all the elements of the
+ * sequence.
+ *
+ * @return True if the predicate returns true for all the elements
+ * of the sequence and false otherwise.
+ */
+ template<typename Iter, typename Pred>
+ bool AllOf(Iter begin, Iter end, Pred pred)
+ {
+ Iter i = begin;
+
+ while (i != end && pred(*i))
+ ++i;
+
+ return i == end;
+ }
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/common/os/win/src/common/utils.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/os/win/src/common/utils.cpp b/modules/platforms/cpp/common/os/win/src/common/utils.cpp
index 47d7f43..77c90b8 100644
--- a/modules/platforms/cpp/common/os/win/src/common/utils.cpp
+++ b/modules/platforms/cpp/common/os/win/src/common/utils.cpp
@@ -40,6 +40,26 @@ namespace ignite
return false;
}
+ void StripSurroundingWhitespaces(std::string& str)
+ {
+ std::string::size_type newBegin = 0;
+ while (newBegin < str.size() && ::isspace(str[newBegin]))
+ ++newBegin;
+
+ if (newBegin == str.size())
+ {
+ str.clear();
+
+ return;
+ }
+
+ std::string::size_type newEnd = str.size() - 1;
+ while (::isspace(str[newEnd]))
+ --newEnd;
+
+ str.assign(str, newBegin, (newEnd - newBegin) + 1);
+ }
+
time_t IgniteTimeGm(const tm& time)
{
tm tmc = time;
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc-test/Makefile.am
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/Makefile.am b/modules/platforms/cpp/odbc-test/Makefile.am
index de8fb5d..1ca85a7 100644
--- a/modules/platforms/cpp/odbc-test/Makefile.am
+++ b/modules/platforms/cpp/odbc-test/Makefile.am
@@ -75,6 +75,7 @@ ignite_odbc_tests_SOURCES = \
../odbc/src/app/application_data_buffer.cpp \
../odbc/src/config/configuration.cpp \
../odbc/src/row.cpp \
+ ../odbc/src/protocol_version.cpp \
../odbc/src/column.cpp \
../odbc/src/utility.cpp \
../odbc/src/result_page.cpp
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc-test/config/queries-test-noodbc.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/config/queries-test-noodbc.xml b/modules/platforms/cpp/odbc-test/config/queries-test-noodbc.xml
new file mode 100644
index 0000000..db19669
--- /dev/null
+++ b/modules/platforms/cpp/odbc-test/config/queries-test-noodbc.xml
@@ -0,0 +1,103 @@
+<?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.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:util="http://www.springframework.org/schema/util"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/util
+ http://www.springframework.org/schema/util/spring-util.xsd">
+ <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+ <property name="localHost" value="127.0.0.1"/>
+ <property name="connectorConfiguration"><null/></property>
+ <property name="odbcConfiguration"><null/></property>
+
+ <property name="cacheConfiguration">
+ <list>
+ <bean class="org.apache.ignite.configuration.CacheConfiguration">
+ <property name="name" value="cache"/>
+ <property name="cacheMode" value="PARTITIONED"/>
+ <property name="atomicityMode" value="TRANSACTIONAL"/>
+ <property name="writeSynchronizationMode" value="FULL_SYNC"/>
+
+ <!-- Configure type metadata to enable queries. -->
+ <property name="queryEntities">
+ <list>
+ <bean class="org.apache.ignite.cache.QueryEntity">
+ <property name="keyType" value="java.lang.Long"/>
+ <property name="valueType" value="TestType"/>
+
+ <property name="fields">
+ <map>
+ <entry key="i8Field" value="java.lang.Byte"/>
+ <entry key="i16Field" value="java.lang.Short"/>
+ <entry key="i32Field" value="java.lang.Integer"/>
+ <entry key="i64Field" value="java.lang.Long"/>
+ <entry key="strField" value="java.lang.String"/>
+ <entry key="floatField" value="java.lang.Float"/>
+ <entry key="doubleField" value="java.lang.Double"/>
+ <entry key="boolField" value="java.lang.Boolean"/>
+ <entry key="guidField" value="java.util.UUID"/>
+ <entry key="dateField" value="java.util.Date"/>
+ <entry key="timestampField" value="java.sql.Timestamp"/>
+ </map>
+ </property>
+
+ <property name="indexes">
+ <list>
+ <bean class="org.apache.ignite.cache.QueryIndex">
+ <constructor-arg value="i32Field"/>
+ </bean>
+ <bean class="org.apache.ignite.cache.QueryIndex">
+ <constructor-arg value="i64Field"/>
+ </bean>
+ </list>
+ </property>
+ </bean>
+ </list>
+ </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.
+ -->
+ <!-- Uncomment static IP finder to enable static-based discovery of initial nodes. -->
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
+ <property name="addresses">
+ <list>
+ <!-- In distributed environment, replace with actual host IP address. -->
+ <value>127.0.0.1:47500</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ <property name="socketTimeout" value="300" />
+ </bean>
+ </property>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc-test/config/queries-test.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/config/queries-test.xml b/modules/platforms/cpp/odbc-test/config/queries-test.xml
index 67415fb..26e6341 100644
--- a/modules/platforms/cpp/odbc-test/config/queries-test.xml
+++ b/modules/platforms/cpp/odbc-test/config/queries-test.xml
@@ -31,7 +31,9 @@
<!-- Enabling ODBC. -->
<property name="odbcConfiguration">
- <bean class="org.apache.ignite.configuration.OdbcConfiguration"></bean>
+ <bean class="org.apache.ignite.configuration.OdbcConfiguration">
+ <property name="endpointAddress" value="127.0.0.1:11110"/>
+ </bean>
</property>
<property name="cacheConfiguration">
@@ -39,16 +41,17 @@
<bean class="org.apache.ignite.configuration.CacheConfiguration">
<property name="name" value="cache"/>
<property name="cacheMode" value="PARTITIONED"/>
- <property name="atomicityMode" value="ATOMIC"/>
- <property name="writeSynchronizationMode" value="PRIMARY_SYNC"/>
-
+ <property name="atomicityMode" value="TRANSACTIONAL"/>
+ <property name="writeSynchronizationMode" value="FULL_SYNC"/>
+
<!-- Configure type metadata to enable queries. -->
- <property name="typeMetadata">
+ <property name="queryEntities">
<list>
- <bean class="org.apache.ignite.cache.CacheTypeMetadata">
+ <bean class="org.apache.ignite.cache.QueryEntity">
<property name="keyType" value="java.lang.Long"/>
<property name="valueType" value="TestType"/>
- <property name="queryFields">
+
+ <property name="fields">
<map>
<entry key="i8Field" value="java.lang.Byte"/>
<entry key="i16Field" value="java.lang.Short"/>
@@ -63,6 +66,17 @@
<entry key="timestampField" value="java.sql.Timestamp"/>
</map>
</property>
+
+ <property name="indexes">
+ <list>
+ <bean class="org.apache.ignite.cache.QueryIndex">
+ <constructor-arg value="i32Field"/>
+ </bean>
+ <bean class="org.apache.ignite.cache.QueryIndex">
+ <constructor-arg value="i64Field"/>
+ </bean>
+ </list>
+ </property>
</bean>
</list>
</property>
@@ -79,8 +93,7 @@
instead os static IP based discovery.
-->
<!-- 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">
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
<property name="addresses">
<list>
<!-- In distributed environment, replace with actual host IP address. -->
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj b/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj
index a9423ca..cb5735f 100644
--- a/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj
+++ b/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj
@@ -157,6 +157,7 @@
<ClCompile Include="..\..\..\odbc\src\config\configuration.cpp" />
<ClCompile Include="..\..\..\odbc\src\config\connection_info.cpp" />
<ClCompile Include="..\..\..\odbc\src\cursor.cpp" />
+ <ClCompile Include="..\..\..\odbc\src\protocol_version.cpp" />
<ClCompile Include="..\..\..\odbc\src\result_page.cpp" />
<ClCompile Include="..\..\..\odbc\src\row.cpp" />
<ClCompile Include="..\..\..\odbc\src\utility.cpp" />
@@ -202,6 +203,7 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
+ <None Include="..\..\config\queries-test-noodbc.xml" />
<None Include="..\..\config\queries-test.xml" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters b/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters
index 84f5a29..270bdd6 100644
--- a/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters
+++ b/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters
@@ -76,6 +76,9 @@
<ClCompile Include="..\..\src\queries_test.cpp">
<Filter>Code</Filter>
</ClCompile>
+ <ClCompile Include="..\..\..\odbc\src\protocol_version.cpp">
+ <Filter>Externals</Filter>
+ </ClCompile>
<ClCompile Include="..\..\src\sql_string_functions_test.cpp">
<Filter>Code</Filter>
</ClCompile>
@@ -122,5 +125,8 @@
<None Include="..\..\config\queries-test.xml">
<Filter>Configs</Filter>
</None>
+ <None Include="..\..\config\queries-test-noodbc.xml">
+ <Filter>Configs</Filter>
+ </None>
</ItemGroup>
</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc-test/src/configuration_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/configuration_test.cpp b/modules/platforms/cpp/odbc-test/src/configuration_test.cpp
index 85aa3ff..0fd3277 100644
--- a/modules/platforms/cpp/odbc-test/src/configuration_test.cpp
+++ b/modules/platforms/cpp/odbc-test/src/configuration_test.cpp
@@ -20,51 +20,93 @@
#endif
#include <iostream>
+#include <set>
#include <boost/test/unit_test.hpp>
#include <ignite/odbc/config/configuration.h>
+#include <ignite/ignite_error.h>
+#include <ignite/common/utils.h>
using namespace ignite::odbc::config;
namespace
{
- const char* testDriverName = "Ignite";
- const char* testServerHost = "testhost.com";
+ const std::string testDriverName = "Ignite Driver";
+ const std::string testServerHost = "testhost.com";
const uint16_t testServerPort = 4242;
- const char* testCacheName = "TestCache";
- const char* testDsn = "Ignite DSN";
+ const std::string testCacheName = "TestCache";
+ const std::string testDsn = "Ignite DSN";
+
+ const std::string testAddress = testServerHost + ':' + ignite::common::LexicalCast<std::string>(testServerPort);
}
-BOOST_AUTO_TEST_SUITE(ConfigurationTestSuite)
+void CheckValidAddress(const char* connectStr, uint16_t port)
+{
+ Configuration cfg;
+
+ BOOST_CHECK_NO_THROW(cfg.FillFromConnectString(connectStr));
+
+ BOOST_CHECK_EQUAL(cfg.GetTcpPort(), port);
+}
+
+void CheckValidProtocolVersion(const char* connectStr, ignite::odbc::ProtocolVersion version)
+{
+ Configuration cfg;
+
+ BOOST_CHECK_NO_THROW(cfg.FillFromConnectString(connectStr));
+
+ BOOST_CHECK(cfg.GetProtocolVersion() == version);
+}
+
+void CheckInvalidProtocolVersion(const char* connectStr)
+{
+ Configuration cfg;
+
+ cfg.FillFromConnectString(connectStr);
+
+ BOOST_CHECK_THROW(cfg.GetProtocolVersion(), ignite::IgniteError);
+}
void CheckConnectionConfig(const Configuration& cfg)
{
- BOOST_REQUIRE(cfg.GetDriver() == testDriverName);
- BOOST_REQUIRE(cfg.GetHost() == testServerHost);
- BOOST_REQUIRE(cfg.GetPort() == testServerPort);
- BOOST_REQUIRE(cfg.GetCache() == testCacheName);
- BOOST_REQUIRE(cfg.GetDsn().empty());
+ BOOST_CHECK_EQUAL(cfg.GetDriver(), testDriverName);
+ BOOST_CHECK_EQUAL(cfg.GetHost(), testServerHost);
+ BOOST_CHECK_EQUAL(cfg.GetTcpPort(), testServerPort);
+ BOOST_CHECK_EQUAL(cfg.GetAddress(), testAddress);
+ BOOST_CHECK_EQUAL(cfg.GetCache(), testCacheName);
+ BOOST_CHECK_EQUAL(cfg.GetDsn(), std::string());
std::stringstream constructor;
- constructor << "driver={" << testDriverName << "};"
- << "server=" << testServerHost << ";"
- << "port=" << testServerPort << ";"
- << "cache=" << testCacheName << ";";
+ constructor << "address=" << testAddress << ';'
+ << "cache=" << testCacheName << ';'
+ << "driver={" << testDriverName << "};";
const std::string& expectedStr = constructor.str();
- BOOST_REQUIRE(cfg.ToConnectString() == expectedStr);
+ BOOST_CHECK_EQUAL(ignite::common::ToLower(cfg.ToConnectString()), ignite::common::ToLower(expectedStr));
}
void CheckDsnConfig(const Configuration& cfg)
{
- BOOST_REQUIRE(cfg.GetDriver() == testDriverName);
- BOOST_REQUIRE(cfg.GetDsn() == testDsn);
- BOOST_REQUIRE(cfg.GetHost().empty());
- BOOST_REQUIRE(cfg.GetCache().empty());
- BOOST_REQUIRE(cfg.GetPort() == 0);
+ BOOST_CHECK_EQUAL(cfg.GetDriver(), testDriverName);
+ BOOST_CHECK_EQUAL(cfg.GetDsn(), testDsn);
+ BOOST_CHECK_EQUAL(cfg.GetCache(), Configuration::DefaultValue::cache);
+ BOOST_CHECK_EQUAL(cfg.GetAddress(), Configuration::DefaultValue::address);
+ BOOST_CHECK_EQUAL(cfg.GetHost(), std::string());
+ BOOST_CHECK_EQUAL(cfg.GetTcpPort(), Configuration::DefaultValue::port);
+}
+
+BOOST_AUTO_TEST_SUITE(ConfigurationTestSuite)
+
+BOOST_AUTO_TEST_CASE(CheckTestValuesNotEquealDefault)
+{
+ BOOST_CHECK_NE(testDriverName, Configuration::DefaultValue::driver);
+ BOOST_CHECK_NE(testAddress, Configuration::DefaultValue::address);
+ BOOST_CHECK_NE(testServerPort, Configuration::DefaultValue::port);
+ BOOST_CHECK_NE(testCacheName, Configuration::DefaultValue::cache);
+ BOOST_CHECK_NE(testDsn, Configuration::DefaultValue::dsn);
}
BOOST_AUTO_TEST_CASE(TestConnectStringUppercase)
@@ -74,13 +116,12 @@ BOOST_AUTO_TEST_CASE(TestConnectStringUppercase)
std::stringstream constructor;
constructor << "DRIVER={" << testDriverName << "};"
- << "SERVER=" << testServerHost <<";"
- << "PORT=" << testServerPort << ";"
+ << "ADDRESS=" << testAddress << ';'
<< "CACHE=" << testCacheName;
const std::string& connectStr = constructor.str();
- cfg.FillFromConnectString(connectStr.c_str(), connectStr.size());
+ cfg.FillFromConnectString(connectStr);
CheckConnectionConfig(cfg);
}
@@ -92,13 +133,12 @@ BOOST_AUTO_TEST_CASE(TestConnectStringLowercase)
std::stringstream constructor;
constructor << "driver={" << testDriverName << "};"
- << "server=" << testServerHost << ";"
- << "port=" << testServerPort << ";"
- << "cache=" << testCacheName;
+ << "address=" << testAddress << ';'
+ << "cache=" << testCacheName << ';';
const std::string& connectStr = constructor.str();
- cfg.FillFromConnectString(connectStr.c_str(), connectStr.size());
+ cfg.FillFromConnectString(connectStr);
CheckConnectionConfig(cfg);
}
@@ -110,9 +150,8 @@ BOOST_AUTO_TEST_CASE(TestConnectStringZeroTerminated)
std::stringstream constructor;
constructor << "driver={" << testDriverName << "};"
- << "server=" << testServerHost << ";"
- << "port=" << testServerPort << ";"
- << "cache=" << testCacheName;
+ << "address=" << testAddress << ';'
+ << "cache=" << testCacheName << ';';
const std::string& connectStr = constructor.str();
@@ -128,13 +167,12 @@ BOOST_AUTO_TEST_CASE(TestConnectStringMixed)
std::stringstream constructor;
constructor << "Driver={" << testDriverName << "};"
- << "Server=" << testServerHost << ";"
- << "Port=" << testServerPort << ";"
- << "Cache=" << testCacheName;
+ << "Address=" << testAddress << ';'
+ << "Cache=" << testCacheName << ';';
const std::string& connectStr = constructor.str();
- cfg.FillFromConnectString(connectStr.c_str(), connectStr.size());
+ cfg.FillFromConnectString(connectStr);
CheckConnectionConfig(cfg);
}
@@ -146,17 +184,53 @@ BOOST_AUTO_TEST_CASE(TestConnectStringWhitepaces)
std::stringstream constructor;
constructor << "DRIVER = {" << testDriverName << "} ;\n"
- << " SERVER =" << testServerHost << " ; \n"
- << "PORT= " << testServerPort << "; "
- << "CACHE = \n\r" << testCacheName;
+ << " ADDRESS =" << testAddress << "; "
+ << "CACHE = \n\r" << testCacheName << ';';
const std::string& connectStr = constructor.str();
- cfg.FillFromConnectString(connectStr.c_str(), connectStr.size());
+ cfg.FillFromConnectString(connectStr);
CheckConnectionConfig(cfg);
}
+BOOST_AUTO_TEST_CASE(TestConnectStringInvalidAddress)
+{
+ Configuration cfg;
+
+ BOOST_CHECK_THROW(cfg.FillFromConnectString("Address=example.com:0;"), ignite::IgniteError);
+ BOOST_CHECK_THROW(cfg.FillFromConnectString("Address=example.com:00000;"), ignite::IgniteError);
+ BOOST_CHECK_THROW(cfg.FillFromConnectString("Address=example.com:fdsf;"), ignite::IgniteError);
+ BOOST_CHECK_THROW(cfg.FillFromConnectString("Address=example.com:123:1;"), ignite::IgniteError);
+ BOOST_CHECK_THROW(cfg.FillFromConnectString("Address=example.com:12322221;"), ignite::IgniteError);
+ BOOST_CHECK_THROW(cfg.FillFromConnectString("Address=example.com:12322a;"), ignite::IgniteError);
+ BOOST_CHECK_THROW(cfg.FillFromConnectString("Address=example.com:;"), ignite::IgniteError);
+}
+
+BOOST_AUTO_TEST_CASE(TestConnectStringValidAddress)
+{
+ CheckValidAddress("Address=example.com:1;", 1);
+ CheckValidAddress("Address=example.com:31242;", 31242);
+ CheckValidAddress("Address=example.com:55555;", 55555);
+ CheckValidAddress("Address=example.com:110;", 110);
+ CheckValidAddress("Address=example.com;", Configuration::DefaultValue::port);
+}
+
+BOOST_AUTO_TEST_CASE(TestConnectStringInvalidVersion)
+{
+ CheckInvalidProtocolVersion("Protocol_Version=0;");
+ CheckInvalidProtocolVersion("Protocol_Version=1;");
+ CheckInvalidProtocolVersion("Protocol_Version=2;");
+ CheckInvalidProtocolVersion("Protocol_Version=1.6.1;");
+ CheckInvalidProtocolVersion("Protocol_Version=1.7.0;");
+ CheckInvalidProtocolVersion("Protocol_Version=1.8.1;");
+}
+
+BOOST_AUTO_TEST_CASE(TestConnectStringValidVersion)
+{
+ CheckValidProtocolVersion("Protocol_Version=1.6.0;", ignite::odbc::ProtocolVersion::VERSION_1_6_0);
+}
+
BOOST_AUTO_TEST_CASE(TestDsnStringUppercase)
{
Configuration cfg;
@@ -173,7 +247,7 @@ BOOST_AUTO_TEST_CASE(TestDsnStringUppercase)
CheckDsnConfig(cfg);
}
-BOOST_AUTO_TEST_CASE(TestDsnStrinLowercase)
+BOOST_AUTO_TEST_CASE(TestDsnStringLowercase)
{
Configuration cfg;
@@ -189,7 +263,7 @@ BOOST_AUTO_TEST_CASE(TestDsnStrinLowercase)
CheckDsnConfig(cfg);
}
-BOOST_AUTO_TEST_CASE(TestDsnStrinMixed)
+BOOST_AUTO_TEST_CASE(TestDsnStringMixed)
{
Configuration cfg;
@@ -205,7 +279,7 @@ BOOST_AUTO_TEST_CASE(TestDsnStrinMixed)
CheckDsnConfig(cfg);
}
-BOOST_AUTO_TEST_CASE(TestDsnStrinWhitespaces)
+BOOST_AUTO_TEST_CASE(TestDsnStringWhitespaces)
{
Configuration cfg;
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc-test/src/queries_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/queries_test.cpp b/modules/platforms/cpp/odbc-test/src/queries_test.cpp
index 2d9bd58..4ba3a63 100644
--- a/modules/platforms/cpp/odbc-test/src/queries_test.cpp
+++ b/modules/platforms/cpp/odbc-test/src/queries_test.cpp
@@ -24,6 +24,7 @@
#include <vector>
#include <string>
+#include <algorithm>
#ifndef _MSC_VER
# define BOOST_TEST_DYN_LINK
@@ -53,41 +54,12 @@ using ignite::impl::binary::BinaryUtils;
struct QueriesTestSuiteFixture
{
/**
- * Constructor.
+ * Establish connection to node.
+ *
+ * @param connectStr Connection string.
*/
- QueriesTestSuiteFixture() : testCache(0), env(NULL), dbc(NULL), stmt(NULL)
+ void Connect(const std::string& connectStr)
{
- IgniteConfiguration cfg;
-
- cfg.jvmOpts.push_back("-Xdebug");
- cfg.jvmOpts.push_back("-Xnoagent");
- cfg.jvmOpts.push_back("-Djava.compiler=NONE");
- cfg.jvmOpts.push_back("-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005");
- cfg.jvmOpts.push_back("-XX:+HeapDumpOnOutOfMemoryError");
-
-#ifdef IGNITE_TESTS_32
- cfg.jvmInitMem = 256;
- cfg.jvmMaxMem = 768;
-#else
- cfg.jvmInitMem = 1024;
- cfg.jvmMaxMem = 4096;
-#endif
-
- char* cfgPath = getenv("IGNITE_NATIVE_TEST_ODBC_CONFIG_PATH");
-
- BOOST_REQUIRE(cfgPath != 0);
-
- cfg.springCfgPath.assign(cfgPath).append("/queries-test.xml");
-
- IgniteError err;
-
- grid = Ignition::Start(cfg, &err);
-
- if (err.GetCode() != IgniteError::IGNITE_SUCCESS)
- BOOST_FAIL(err.GetText());
-
- testCache = grid.GetCache<int64_t, TestType>("cache");
-
// Allocate an environment handle
SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env);
@@ -102,13 +74,16 @@ struct QueriesTestSuiteFixture
BOOST_REQUIRE(dbc != NULL);
// Connect string
- SQLCHAR connectStr[] = "DRIVER={Apache Ignite};SERVER=localhost;PORT=10800;CACHE=cache";
+ std::vector<SQLCHAR> connectStr0;
+
+ connectStr0.reserve(connectStr.size() + 1);
+ std::copy(connectStr.begin(), connectStr.end(), std::back_inserter(connectStr0));
SQLCHAR outstr[ODBC_BUFFER_SIZE];
SQLSMALLINT outstrlen;
// Connecting to ODBC server.
- SQLRETURN ret = SQLDriverConnect(dbc, NULL, connectStr, static_cast<SQLSMALLINT>(sizeof(connectStr)),
+ SQLRETURN ret = SQLDriverConnect(dbc, NULL, &connectStr0[0], static_cast<SQLSMALLINT>(connectStr0.size()),
outstr, sizeof(outstr), &outstrlen, SQL_DRIVER_COMPLETE);
if (!SQL_SUCCEEDED(ret))
@@ -124,10 +99,7 @@ struct QueriesTestSuiteFixture
BOOST_REQUIRE(stmt != NULL);
}
- /**
- * Destructor.
- */
- ~QueriesTestSuiteFixture()
+ void Disconnect()
{
// Releasing statement handle.
SQLFreeHandle(SQL_HANDLE_STMT, stmt);
@@ -138,13 +110,67 @@ struct QueriesTestSuiteFixture
// Releasing allocated handles.
SQLFreeHandle(SQL_HANDLE_DBC, dbc);
SQLFreeHandle(SQL_HANDLE_ENV, env);
+ }
+
+ static Ignite StartNode(const char* name, const char* config)
+ {
+ IgniteConfiguration cfg;
- Ignition::Stop(grid.GetName(), true);
+ cfg.jvmOpts.push_back("-Xdebug");
+ cfg.jvmOpts.push_back("-Xnoagent");
+ cfg.jvmOpts.push_back("-Djava.compiler=NONE");
+ cfg.jvmOpts.push_back("-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005");
+ cfg.jvmOpts.push_back("-XX:+HeapDumpOnOutOfMemoryError");
+
+#ifdef IGNITE_TESTS_32
+ cfg.jvmInitMem = 256;
+ cfg.jvmMaxMem = 768;
+#else
+ cfg.jvmInitMem = 1024;
+ cfg.jvmMaxMem = 4096;
+#endif
+
+ char* cfgPath = getenv("IGNITE_NATIVE_TEST_ODBC_CONFIG_PATH");
+
+ BOOST_REQUIRE(cfgPath != 0);
+
+ cfg.springCfgPath.assign(cfgPath).append("/").append(config);
+
+ IgniteError err;
+
+ return Ignition::Start(cfg, name);
+ }
+
+ static Ignite StartAdditionalNode(const char* name)
+ {
+ return StartNode(name, "queries-test-noodbc.xml");
+ }
+
+ /**
+ * Constructor.
+ */
+ QueriesTestSuiteFixture() : testCache(0), env(NULL), dbc(NULL), stmt(NULL)
+ {
+ grid = StartNode("NodeMain", "queries-test.xml");
+
+ testCache = grid.GetCache<int64_t, TestType>("cache");
+ }
+
+ /**
+ * Destructor.
+ */
+ ~QueriesTestSuiteFixture()
+ {
+ Disconnect();
+
+ Ignition::StopAll(true);
}
template<typename T>
void CheckTwoRowsInt(SQLSMALLINT type)
{
+ Connect("DRIVER={Apache Ignite};ADDRESS=127.0.0.1:11110;CACHE=cache");
+
SQLRETURN ret;
TestType in1(1, 2, 3, 4, "5", 6.0f, 7.0, true, Guid(8, 9), BinaryUtils::MakeDateGmt(1987, 6, 5), BinaryUtils::MakeTimestampGmt(1998, 12, 27, 1, 2, 3, 456));
@@ -252,6 +278,16 @@ struct QueriesTestSuiteFixture
BOOST_FIXTURE_TEST_SUITE(QueriesTestSuite, QueriesTestSuiteFixture)
+BOOST_AUTO_TEST_CASE(TestLegacyConnection)
+{
+ Connect("DRIVER={Apache Ignite};SERVER=127.0.0.1;PORT=11110;CACHE=cache");
+}
+
+BOOST_AUTO_TEST_CASE(TestConnectionProtocolVersion_1_6_0)
+{
+ Connect("DRIVER={Apache Ignite};ADDRESS=127.0.0.1:11110;CACHE=cache;PROTOCOL_VERSION=1.6.0");
+}
+
BOOST_AUTO_TEST_CASE(TestTwoRowsInt8)
{
CheckTwoRowsInt<int8_t>(SQL_C_STINYINT);
@@ -294,6 +330,8 @@ BOOST_AUTO_TEST_CASE(TestTwoRowsUint64)
BOOST_AUTO_TEST_CASE(TestTwoRowsString)
{
+ Connect("DRIVER={Apache Ignite};ADDRESS=127.0.0.1:11110;CACHE=cache");
+
SQLRETURN ret;
TestType in1(1, 2, 3, 4, "5", 6.0f, 7.0, true, Guid(8, 9), BinaryUtils::MakeDateGmt(1987, 6, 5), BinaryUtils::MakeTimestampGmt(1998, 12, 27, 1, 2, 3, 456));
@@ -387,6 +425,8 @@ BOOST_AUTO_TEST_CASE(TestTwoRowsString)
BOOST_AUTO_TEST_CASE(TestOneRowString)
{
+ Connect("DRIVER={Apache Ignite};ADDRESS=127.0.0.1:11110;CACHE=cache");
+
SQLRETURN ret;
TestType in(1, 2, 3, 4, "5", 6.0f, 7.0, true, Guid(8, 9), BinaryUtils::MakeDateGmt(1987, 6, 5), BinaryUtils::MakeTimestampGmt(1998, 12, 27, 1, 2, 3, 456));
@@ -448,6 +488,8 @@ BOOST_AUTO_TEST_CASE(TestOneRowString)
BOOST_AUTO_TEST_CASE(TestOneRowStringLen)
{
+ Connect("DRIVER={Apache Ignite};ADDRESS=127.0.0.1:11110;CACHE=cache");
+
SQLRETURN ret;
TestType in(1, 2, 3, 4, "5", 6.0f, 7.0, true, Guid(8, 9), BinaryUtils::MakeDateGmt(1987, 6, 5), BinaryUtils::MakeTimestampGmt(1998, 12, 27, 1, 2, 3, 456));
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc-test/src/sql_test_suite_fixture.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/sql_test_suite_fixture.cpp b/modules/platforms/cpp/odbc-test/src/sql_test_suite_fixture.cpp
index 16e5ea0..69b4bfa 100644
--- a/modules/platforms/cpp/odbc-test/src/sql_test_suite_fixture.cpp
+++ b/modules/platforms/cpp/odbc-test/src/sql_test_suite_fixture.cpp
@@ -45,7 +45,7 @@ namespace ignite
char* cfgPath = getenv("IGNITE_NATIVE_TEST_ODBC_CONFIG_PATH");
- BOOST_REQUIRE(cfgPath != 0) ;
+ BOOST_REQUIRE(cfgPath != 0);
cfg.springCfgPath.assign(cfgPath).append("/queries-test.xml");
@@ -54,14 +54,14 @@ namespace ignite
grid = Ignition::Start(cfg, &err);
if (err.GetCode() != IgniteError::IGNITE_SUCCESS)
- BOOST_FAIL(err.GetText()) ;
+ BOOST_FAIL(err.GetText()) ;
testCache = grid.GetCache<int64_t, TestType>("cache");
// Allocate an environment handle
SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env);
- BOOST_REQUIRE(env != NULL) ;
+ BOOST_REQUIRE(env != NULL);
// We want ODBC 3 support
SQLSetEnvAttr(env, SQL_ATTR_ODBC_VERSION, reinterpret_cast<void*>(SQL_OV_ODBC3), 0);
@@ -69,10 +69,10 @@ namespace ignite
// Allocate a connection handle
SQLAllocHandle(SQL_HANDLE_DBC, env, &dbc);
- BOOST_REQUIRE(dbc != NULL) ;
+ BOOST_REQUIRE(dbc != NULL);
// Connect string
- SQLCHAR connectStr[] = "DRIVER={Apache Ignite};SERVER=localhost;PORT=10800;CACHE=cache";
+ SQLCHAR connectStr[] = "DRIVER={Apache Ignite};ADDRESS=127.0.0.1:11110;CACHE=cache";
SQLCHAR outstr[ODBC_BUFFER_SIZE];
SQLSMALLINT outstrlen;
@@ -85,13 +85,13 @@ namespace ignite
{
Ignition::Stop(grid.GetName(), true);
- BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_DBC, dbc)) ;
+ BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_DBC, dbc));
}
// Allocate a statement handle
SQLAllocHandle(SQL_HANDLE_STMT, dbc, &stmt);
- BOOST_REQUIRE(stmt != NULL) ;
+ BOOST_REQUIRE(stmt != NULL);
}
SqlTestSuiteFixture::~SqlTestSuiteFixture()
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc/Makefile.am
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/Makefile.am b/modules/platforms/cpp/odbc/Makefile.am
index 29f0ef4..1781bc0 100644
--- a/modules/platforms/cpp/odbc/Makefile.am
+++ b/modules/platforms/cpp/odbc/Makefile.am
@@ -62,6 +62,7 @@ libignite_odbc_la_SOURCES = \
src/meta/table_meta.cpp \
src/odbc.cpp \
src/entry_points.cpp \
+ src/dsn_config.cpp \
src/query/column_metadata_query.cpp \
src/query/data_query.cpp \
src/query/foreign_keys_query.cpp \
@@ -69,6 +70,7 @@ libignite_odbc_la_SOURCES = \
src/query/table_metadata_query.cpp \
src/query/type_info_query.cpp \
src/query/special_columns_query.cpp \
+ src/protocol_version.cpp \
src/result_page.cpp \
src/row.cpp \
src/column.cpp \
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc/include/Makefile.am
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/Makefile.am b/modules/platforms/cpp/odbc/include/Makefile.am
index 192021d..073dcaa 100644
--- a/modules/platforms/cpp/odbc/include/Makefile.am
+++ b/modules/platforms/cpp/odbc/include/Makefile.am
@@ -27,6 +27,7 @@ noinst_HEADERS = \
ignite/odbc/query/column_metadata_query.h \
ignite/odbc/query/query.h \
ignite/odbc/query/primary_keys_query.h \
+ ignite/odbc/protocol_version.h \
ignite/odbc/statement.h \
ignite/odbc/config/configuration.h \
ignite/odbc/config/connection_info.h \
@@ -37,6 +38,7 @@ noinst_HEADERS = \
ignite/odbc/row.h \
ignite/odbc/utility.h \
ignite/odbc/environment.h \
+ ignite/odbc/dsn_config.h \
ignite/odbc/system/odbc_constants.h \
ignite/odbc/system/socket_client.h \
ignite/odbc/meta/primary_key_meta.h \
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc/include/ignite/odbc/common_types.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/common_types.h b/modules/platforms/cpp/odbc/include/ignite/odbc/common_types.h
index 6636ca4..250eaf2 100644
--- a/modules/platforms/cpp/odbc/include/ignite/odbc/common_types.h
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/common_types.h
@@ -60,6 +60,9 @@ namespace ignite
/** Output data has been truncated. */
SQL_STATE_01004_DATA_TRUNCATED,
+ /** Invalid connection string attribute. */
+ SQL_STATE_01S00_INVALID_CONNECTION_STRING_ATTRIBUTE,
+
/** Error in row. */
SQL_STATE_01S01_ERROR_IN_ROW,
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc/include/ignite/odbc/config/configuration.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/config/configuration.h b/modules/platforms/cpp/odbc/include/ignite/odbc/config/configuration.h
index d6d7944..f90fa2d 100644
--- a/modules/platforms/cpp/odbc/include/ignite/odbc/config/configuration.h
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/config/configuration.h
@@ -23,6 +23,8 @@
#include <map>
#include <ignite/common/common.h>
+#include <ignite/common/utils.h>
+#include "ignite/odbc/protocol_version.h"
namespace ignite
{
@@ -36,6 +38,71 @@ namespace ignite
class Configuration
{
public:
+ /** Map containing connect arguments. */
+ typedef std::map<std::string, std::string> ArgumentMap;
+
+ /** Connection attribute keywords. */
+ struct Key
+ {
+ /** Connection attribute keyword for DSN attribute. */
+ static const std::string dsn;
+
+ /** Connection attribute keyword for Driver attribute. */
+ static const std::string driver;
+
+ /** Connection attribute keyword for cache attribute. */
+ static const std::string cache;
+
+ /** Connection attribute keyword for address attribute. */
+ static const std::string address;
+
+ /** Connection attribute keyword for server attribute. */
+ static const std::string server;
+
+ /** Connection attribute keyword for port attribute. */
+ static const std::string port;
+
+ /** Connection attribute keyword for protocol version attribute. */
+ static const std::string protocolVersion;
+ };
+
+ /** Default values for configuration. */
+ struct DefaultValue
+ {
+ /** Default value for DSN attribute. */
+ static const std::string dsn;
+
+ /** Default value for Driver attribute. */
+ static const std::string driver;
+
+ /** Default value for cache attribute. */
+ static const std::string cache;
+
+ /** Default value for address attribute. */
+ static const std::string address;
+
+ /** Default value for server attribute. */
+ static const std::string server;
+
+ /** Default value for protocol version. */
+ static const ProtocolVersion& protocolVersion;
+
+ /** Default value for port attribute. */
+ static const uint16_t port;
+ };
+
+ /**
+ * Connection end point structure.
+ */
+ struct EndPoint
+ {
+ /** Remote host. */
+ std::string host;
+
+ /** TCP port. */
+ uint16_t port;
+ };
+
/**
* Default constructor.
*/
@@ -81,19 +148,36 @@ namespace ignite
*
* @return Server port.
*/
- uint16_t GetPort() const
+ uint16_t GetTcpPort() const
{
- return port;
+ return endPoint.port;
}
/**
+ * Set server port.
+ *
+ * @param port Server port.
+ */
+ void SetTcpPort(uint16_t port);
+
+ /**
* Get DSN.
*
* @return Data Source Name.
*/
const std::string& GetDsn() const
{
- return dsn;
+ return GetStringValue(Key::dsn, DefaultValue::dsn);
+ }
+
+ /**
+ * Set DSN.
+ *
+ * @param dsn Data Source Name.
+ */
+ void SetDsn(const std::string& dsn)
+ {
+ arguments[Key::dsn] = dsn;
}
/**
@@ -103,7 +187,7 @@ namespace ignite
*/
const std::string& GetDriver() const
{
- return driver;
+ return GetStringValue(Key::driver, DefaultValue::driver);
}
/**
@@ -113,7 +197,17 @@ namespace ignite
*/
const std::string& GetHost() const
{
- return host;
+ return endPoint.host;
+ }
+
+ /**
+ * Set server host.
+ *
+ * @param server Server host.
+ */
+ void SetHost(const std::string& server)
+ {
+ arguments[Key::server] = server;
}
/**
@@ -123,38 +217,105 @@ namespace ignite
*/
const std::string& GetCache() const
{
- return cache;
+ return GetStringValue(Key::cache, DefaultValue::cache);
}
- private:
- IGNITE_NO_COPY_ASSIGNMENT(Configuration);
+ /**
+ * Set cache.
+ *
+ * @param cache Cache name.
+ */
+ void SetCache(const std::string& cache)
+ {
+ arguments[Key::cache] = cache;
+ }
- /** Map containing connect arguments. */
- typedef std::map<std::string, std::string> ArgumentMap;
+ /**
+ * Get address.
+ *
+ * @return Address.
+ */
+ const std::string& GetAddress() const
+ {
+ return GetStringValue(Key::address, DefaultValue::address);
+ }
+
+ /**
+ * Set address.
+ *
+ * @param address Address.
+ */
+ void SetAddress(const std::string& address)
+ {
+ arguments[Key::address] = address;
+ }
/**
+ * Get argument map.
+ *
+ * @return Argument map.
+ */
+ const ArgumentMap& GetMap() const
+ {
+ return arguments;
+ }
+
+ /**
+ * Get protocol version.
+ *
+ * @return Protocol version.
+ */
+ ProtocolVersion GetProtocolVersion() const;
+
+ /**
+ * Set protocol version.
+ *
+ * @param version Version to set.
+ */
+ void SetProtocolVersion(const std::string& version);
+
+ /**
+ * Get string value from the config.
+ *
+ * @param key Configuration key.
+ * @param dflt Default value to be returned if there is no value stored.
+ * @return Found or default value.
+ */
+ const std::string& GetStringValue(const std::string& key, const std::string& dflt) const;
+
+ /**
+ * Get int value from the config.
+ *
+ * @param key Configuration key.
+ * @param dflt Default value to be returned if there is no value stored.
+ * @return Found or default value.
+ */
+ int64_t GetIntValue(const std::string& key, int64_t dflt) const;
+
+ private:
+ /**
* Parse connect string into key-value storage.
*
* @param str String to parse.
* @param len String length.
* @param params Parsing result.
*/
- void ParseAttributeList(const char* str, size_t len, char delimeter, ArgumentMap& args) const;
+ static void ParseAttributeList(const char* str, size_t len, char delimeter, ArgumentMap& args);
- /** Data Source Name. */
- std::string dsn;
-
- /** Driver name. */
- std::string driver;
-
- /** Server hostname. */
- std::string host;
+ /**
+ * Parse address and extract connection end-point.
+ *
+ * @throw IgniteException if address can not be parsed.
+ * @param address Address string to parse.
+ * @param res Result is placed here.
+ */
+ static void ParseAddress(const std::string& address, EndPoint& res);
- /** Port of the server. */
- uint16_t port;
+ /** Arguments. */
+ ArgumentMap arguments;
- /** Cache name. */
- std::string cache;
+ /** Connection end-point. */
+ EndPoint endPoint;
};
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc/include/ignite/odbc/connection.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/connection.h b/modules/platforms/cpp/odbc/include/ignite/odbc/connection.h
index 10ceb19..acf82ba 100644
--- a/modules/platforms/cpp/odbc/include/ignite/odbc/connection.h
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/connection.h
@@ -25,6 +25,7 @@
#include "ignite/odbc/parser.h"
#include "ignite/odbc/system/socket_client.h"
#include "ignite/odbc/config/connection_info.h"
+#include "ignite/odbc/config/configuration.h"
#include "ignite/odbc/diagnostic/diagnosable_adapter.h"
namespace ignite
@@ -40,15 +41,6 @@ namespace ignite
{
friend class Environment;
public:
- /** ODBC communication protocol version. */
- enum { PROTOCOL_VERSION = 1 };
-
- /**
- * Apache Ignite version when the current ODBC communication
- * protocol version has been introduced.
- */
- static const std::string PROTOCOL_VERSION_SINCE;
-
/**
* Destructor.
*/
@@ -74,18 +66,16 @@ namespace ignite
/**
* Establish connection to ODBC server.
*
- * @param server Server (DSN).
+ * @param connectStr Connection string.
*/
- void Establish(const std::string& server);
+ void Establish(const std::string& connectStr);
/**
* Establish connection to ODBC server.
*
- * @param host Host.
- * @param port Port.
- * @param cache Cache name to connect to.
+ * @param cfg Configuration.
*/
- void Establish(const std::string& host, uint16_t port, const std::string& cache);
+ void Establish(const config::Configuration cfg);
/**
* Release established connection.
@@ -124,6 +114,13 @@ namespace ignite
const std::string& GetCache() const;
/**
+ * Get configuration.
+ *
+ * @return Connection configuration.
+ */
+ const config::Configuration& GetConfiguration() const;
+
+ /**
* Create diagnostic record associated with the Connection instance.
*
* @param sqlState SQL state.
@@ -132,8 +129,8 @@ namespace ignite
* @param columnNum Associated column number.
* @return DiagnosticRecord associated with the instance.
*/
- diagnostic::DiagnosticRecord CreateStatusRecord(SqlState sqlState,
- const std::string& message, int32_t rowNum = 0, int32_t columnNum = 0) const;
+ static diagnostic::DiagnosticRecord CreateStatusRecord(SqlState sqlState,
+ const std::string& message, int32_t rowNum = 0, int32_t columnNum = 0);
/**
* Synchronously send request message and receive response.
@@ -172,21 +169,19 @@ namespace ignite
* Establish connection to ODBC server.
* Internal call.
*
- * @param server Server (DNS).
+ * @param connectStr Connection string.
* @return Operation result.
*/
- SqlResult InternalEstablish(const std::string& server);
+ SqlResult InternalEstablish(const std::string& connectStr);
/**
* Establish connection to ODBC server.
* Internal call.
*
- * @param host Host.
- * @param port Port.
- * @param cache Cache name to connect to.
+ * @param cfg Configuration.
* @return Operation result.
*/
- SqlResult InternalEstablish(const std::string& host, uint16_t port, const std::string& cache);
+ SqlResult InternalEstablish(const config::Configuration cfg);
/**
* Release established connection.
@@ -269,11 +264,11 @@ namespace ignite
/** State flag. */
bool connected;
- /** Cache name. */
- std::string cache;
-
/** Message parser. */
Parser parser;
+
+ /** Configuration. */
+ config::Configuration config;
};
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc/include/ignite/odbc/diagnostic/diagnostic_record.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/diagnostic/diagnostic_record.h b/modules/platforms/cpp/odbc/include/ignite/odbc/diagnostic/diagnostic_record.h
index bfb4f4c..670e0aa 100644
--- a/modules/platforms/cpp/odbc/include/ignite/odbc/diagnostic/diagnostic_record.h
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/diagnostic/diagnostic_record.h
@@ -84,7 +84,7 @@ namespace ignite
*
* @return An informational message on the error or warning.
*/
- const std::string& GetMessage() const;
+ const std::string& GetMessageText() const;
/**
* Get connection name.
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc/include/ignite/odbc/dsn_config.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/dsn_config.h b/modules/platforms/cpp/odbc/include/ignite/odbc/dsn_config.h
new file mode 100644
index 0000000..dbad9b5
--- /dev/null
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/dsn_config.h
@@ -0,0 +1,61 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_ODBC_DSN_CONFIG
+#define _IGNITE_ODBC_DSN_CONFIG
+
+#include "ignite/odbc/config/configuration.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ /**
+ * Extract last setup error and throw it like IgniteError.
+ */
+ void ThrowLastSetupError();
+
+ /**
+ * Add new string to the DSN file.
+ *
+ * @param dsn DSN name.
+ * @param key Key.
+ * @param value Value.
+ */
+ void WriteDsnString(const char* dsn, const char* key, const char* value);
+
+ /**
+ * Get string from the DSN file.
+ *
+ * @param dsn DSN name.
+ * @param key Key.
+ * @param dflt Default value.
+ * @return Value.
+ */
+ std::string ReadDsnString(const char* dsn, const char* key, const char* dflt);
+
+ /**
+ * Read DSN to fill the configuration.
+ *
+ * @param dsn DSN name.
+ * @param config Configuration.
+ */
+ void ReadDsnConfiguration(const char* dsn, config::Configuration& config);
+ }
+}
+
+#endif //_IGNITE_ODBC_DSN_CONFIG
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc/include/ignite/odbc/parser.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/parser.h b/modules/platforms/cpp/odbc/include/ignite/odbc/parser.h
index c19e08c..a91af22 100644
--- a/modules/platforms/cpp/odbc/include/ignite/odbc/parser.h
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/parser.h
@@ -42,9 +42,6 @@ namespace ignite
/** Default initial size of operational memory. */
enum { DEFAULT_MEM_ALLOCATION = 4096 };
- /** ODBC communication protocol version. */
- enum { PROTOCOL_VERSION = 1 };
-
/**
* Constructor.
*/
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc/include/ignite/odbc/protocol_version.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/protocol_version.h b/modules/platforms/cpp/odbc/include/ignite/odbc/protocol_version.h
new file mode 100644
index 0000000..8682119
--- /dev/null
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/protocol_version.h
@@ -0,0 +1,168 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_ODBC_PROTOCOL_VERSION
+#define _IGNITE_ODBC_PROTOCOL_VERSION
+
+#include <stdint.h>
+
+#include <string>
+#include <map>
+
+namespace ignite
+{
+ namespace odbc
+ {
+ /** Protocol version. */
+ class ProtocolVersion
+ {
+ public:
+ /** String to version map type alias. */
+ typedef std::map<std::string, ProtocolVersion> StringToVersionMap;
+
+ /** Version to string map type alias. */
+ typedef std::map<ProtocolVersion, std::string> VersionToStringMap;
+
+ /** First version of the protocol that was introduced in Ignite 1.6.0. */
+ static const ProtocolVersion VERSION_1_6_0;
+
+ /** Unknown version of the protocol. */
+ static const ProtocolVersion VERSION_UNKNOWN;
+
+ /**
+ * Get string to version map.
+ *
+ * @return String to version map.
+ */
+ static const StringToVersionMap& GetMap();
+
+ /**
+ * Get current version.
+ *
+ * @return Current version.
+ */
+ static const ProtocolVersion& GetCurrent();
+
+ /**
+ * Parse string and extract protocol version.
+ *
+ * @throw IgniteException if version can not be parsed.
+ * @param version Version string to parse.
+ * @return Protocol version.
+ */
+ static ProtocolVersion FromString(const std::string& version);
+
+ /**
+ * Convert to string value.
+ *
+ * @throw IgniteException if version is unknow parsed.
+ * @param version Version string to parse.
+ * @return Protocol version.
+ */
+ const std::string& ToString() const;
+
+ /**
+ * Get int value.
+ *
+ * @return Integer value.
+ */
+ int64_t GetIntValue() const;
+
+ /**
+ * Check if the version is unknown.
+ *
+ * @return True if the version is unknown.
+ */
+ bool IsUnknown() const;
+
+ /**
+ * Comparison operator.
+ *
+ * @param val1 First value.
+ * @param val2 Second value.
+ * @return True if equal.
+ */
+ friend bool operator==(const ProtocolVersion& val1, const ProtocolVersion& val2);
+
+ /**
+ * Comparison operator.
+ *
+ * @param val1 First value.
+ * @param val2 Second value.
+ * @return True if not equal.
+ */
+ friend bool operator!=(const ProtocolVersion& val1, const ProtocolVersion& val2);
+
+ /**
+ * Comparison operator.
+ *
+ * @param val1 First value.
+ * @param val2 Second value.
+ * @return True if less.
+ */
+ friend bool operator<(const ProtocolVersion& val1, const ProtocolVersion& val2);
+
+ /**
+ * Comparison operator.
+ *
+ * @param val1 First value.
+ * @param val2 Second value.
+ * @return True if less or equal.
+ */
+ friend bool operator<=(const ProtocolVersion& val1, const ProtocolVersion& val2);
+
+ /**
+ * Comparison operator.
+ *
+ * @param val1 First value.
+ * @param val2 Second value.
+ * @return True if gretter.
+ */
+ friend bool operator>(const ProtocolVersion& val1, const ProtocolVersion& val2);
+
+ /**
+ * Comparison operator.
+ *
+ * @param val1 First value.
+ * @param val2 Second value.
+ * @return True if gretter or equal.
+ */
+ friend bool operator>=(const ProtocolVersion& val1, const ProtocolVersion& val2);
+
+ private:
+ /**
+ * Constructor.
+ *
+ * @param val Underlying value.
+ */
+ explicit ProtocolVersion(int64_t val);
+
+ ProtocolVersion();
+
+ /** String to version map. */
+ static const StringToVersionMap stringToVersionMap;
+
+ /** Version to string map. */
+ static const VersionToStringMap versionToStringMap;
+
+ /** Underlying int value. */
+ int64_t val;
+ };
+ }
+}
+
+#endif //_IGNITE_ODBC_PROTOCOL_VERSION
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc/include/ignite/odbc/system/odbc_constants.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/system/odbc_constants.h b/modules/platforms/cpp/odbc/include/ignite/odbc/system/odbc_constants.h
index 60a6552..ecd1a55 100644
--- a/modules/platforms/cpp/odbc/include/ignite/odbc/system/odbc_constants.h
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/system/odbc_constants.h
@@ -27,10 +27,6 @@
# undef min
#endif // min
-#ifdef GetMessage
-# undef GetMessage
-#endif // GetMessage
-
#endif //_WIN32
#define ODBCVER 0x0380
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc/include/ignite/odbc/system/ui/dsn_configuration_window.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/system/ui/dsn_configuration_window.h b/modules/platforms/cpp/odbc/include/ignite/odbc/system/ui/dsn_configuration_window.h
new file mode 100644
index 0000000..034de82
--- /dev/null
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/system/ui/dsn_configuration_window.h
@@ -0,0 +1,136 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_ODBC_SYSTEM_UI_DSN_CONFIGURATION_WINDOW
+#define _IGNITE_ODBC_SYSTEM_UI_DSN_CONFIGURATION_WINDOW
+
+#include "ignite/odbc/config/configuration.h"
+#include "ignite/odbc/system/ui/custom_window.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ namespace system
+ {
+ namespace ui
+ {
+ /**
+ * DSN configuration window class.
+ */
+ class DsnConfigurationWindow : public CustomWindow
+ {
+ /**
+ * Children windows ids.
+ */
+ enum ChildId
+ {
+ ID_CONNECTION_SETTINGS_GROUP_BOX,
+ ID_NAME_EDIT,
+ ID_NAME_LABEL,
+ ID_ADDRESS_EDIT,
+ ID_ADDRESS_LABEL,
+ ID_CACHE_EDIT,
+ ID_CACHE_LABEL,
+ ID_OK_BUTTON,
+ ID_CANCEL_BUTTON
+ };
+
+ public:
+ /**
+ * Constructor.
+ *
+ * @param parent Parent window handle.
+ */
+ explicit DsnConfigurationWindow(Window* parent, config::Configuration& config);
+
+ /**
+ * Destructor.
+ */
+ virtual ~DsnConfigurationWindow();
+
+ /**
+ * Create window in the center of the parent window.
+ */
+ void Create();
+
+ /**
+ * @copedoc ignite::odbc::system::ui::CustomWindow::OnCreate
+ */
+ virtual void OnCreate();
+
+ /**
+ * @copedoc ignite::odbc::system::ui::CustomWindow::OnMessage
+ */
+ virtual bool OnMessage(UINT msg, WPARAM wParam, LPARAM lParam);
+
+ private:
+ IGNITE_NO_COPY_ASSIGNMENT(DsnConfigurationWindow)
+
+ /**
+ * Retrieves current values from the children and stores
+ * them to the specified configuration.
+ *
+ * @param cfg Configuration.
+ */
+ void RetrieveParameters(config::Configuration& cfg) const;
+
+ /** Window width. */
+ int width;
+
+ /** Window height. */
+ int height;
+
+ /** Connection settings group box. */
+ std::auto_ptr<Window> connectionSettingsGroupBox;
+
+ /** DSN name edit field label. */
+ std::auto_ptr<Window> nameLabel;
+
+ /** DSN name edit field. */
+ std::auto_ptr<Window> nameEdit;
+
+ /** DSN address edit field label. */
+ std::auto_ptr<Window> addressLabel;
+
+ /** DSN address edit field. */
+ std::auto_ptr<Window> addressEdit;
+
+ /** DSN cache edit field label. */
+ std::auto_ptr<Window> cacheLabel;
+
+ /** DSN cache edit field. */
+ std::auto_ptr<Window> cacheEdit;
+
+ /** Ok button. */
+ std::auto_ptr<Window> okButton;
+
+ /** Cancel button. */
+ std::auto_ptr<Window> cancelButton;
+
+ /** Configuration. */
+ config::Configuration& config;
+
+ /** Flag indicating whether OK option was selected. */
+ bool accepted;
+ };
+ }
+ }
+ }
+}
+
+#endif //_IGNITE_ODBC_SYSTEM_UI_DSN_CONFIGURATION_WINDOW
\ No newline at end of file
[36/50] [abbrv] ignite git commit: IGNITE-3811 Fixed query for merge
with complex key on SQL Server.
Posted by sb...@apache.org.
IGNITE-3811 Fixed query for merge with complex key on SQL Server.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/dabd86c6
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/dabd86c6
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/dabd86c6
Branch: refs/heads/ignite-961
Commit: dabd86c62e39eb983ef3d198c8b8ee96d2623c84
Parents: 1ef150e
Author: Andrey Novikov <an...@apache.org>
Authored: Wed Aug 31 16:00:19 2016 +0700
Committer: Andrey Novikov <an...@apache.org>
Committed: Wed Aug 31 16:00:19 2016 +0700
----------------------------------------------------------------------
.../apache/ignite/cache/store/jdbc/dialect/SQLServerDialect.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/dabd86c6/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/dialect/SQLServerDialect.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/dialect/SQLServerDialect.java b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/dialect/SQLServerDialect.java
index 0082617..9831aa8 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/dialect/SQLServerDialect.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/dialect/SQLServerDialect.java
@@ -44,7 +44,7 @@ public class SQLServerDialect extends BasicJdbcDialect {
@Override public String apply(String col) {
return String.format("t.%s=v.%s", col, col);
}
- }, "", ", ", "");
+ }, "", " AND ", "");
String setCols = mkString(uniqCols, new C1<String, String>() {
@Override public String apply(String col) {
[16/50] [abbrv] ignite git commit: IGNITE-3670 IGFS: Improved symlink
handling for delete operation and added more tests. This closes #975.
Posted by sb...@apache.org.
IGNITE-3670 IGFS: Improved symlink handling for delete operation and added more tests. This closes #975.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/b5757642
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/b5757642
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/b5757642
Branch: refs/heads/ignite-961
Commit: b5757642e135908d9baa027a605035dd0d4acfc9
Parents: 92f18bf
Author: tledkov-gridgain <tl...@gridgain.com>
Authored: Fri Aug 26 15:47:02 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Fri Aug 26 15:47:02 2016 +0300
----------------------------------------------------------------------
.../local/LocalIgfsSecondaryFileSystem.java | 38 +-
.../igfs/IgfsAbstractBaseSelfTest.java | 1067 ++++++++++++++++++
.../processors/igfs/IgfsAbstractSelfTest.java | 1012 +----------------
...SecondaryFileSystemDualAbstractSelfTest.java | 143 +++
4 files changed, 1239 insertions(+), 1021 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/b5757642/modules/core/src/main/java/org/apache/ignite/igfs/secondary/local/LocalIgfsSecondaryFileSystem.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/igfs/secondary/local/LocalIgfsSecondaryFileSystem.java b/modules/core/src/main/java/org/apache/ignite/igfs/secondary/local/LocalIgfsSecondaryFileSystem.java
index 3d3a350..519f472 100644
--- a/modules/core/src/main/java/org/apache/ignite/igfs/secondary/local/LocalIgfsSecondaryFileSystem.java
+++ b/modules/core/src/main/java/org/apache/ignite/igfs/secondary/local/LocalIgfsSecondaryFileSystem.java
@@ -41,6 +41,8 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.file.Files;
+import java.nio.file.LinkOption;
+import java.nio.file.attribute.BasicFileAttributes;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
@@ -108,35 +110,43 @@ public class LocalIgfsSecondaryFileSystem implements IgfsSecondaryFileSystem, Li
@Override public boolean delete(IgfsPath path, boolean recursive) {
File f = fileForPath(path);
- if (!recursive || !f.isDirectory())
+ if (!recursive)
return f.delete();
else
- return deleteDirectory(f);
+ return deleteRecursive(f);
}
/**
* Delete directory recursively.
*
- * @param dir Directory.
+ * @param f Directory.
* @return {@code true} if successful.
*/
- private boolean deleteDirectory(File dir) {
- File[] entries = dir.listFiles();
+ private boolean deleteRecursive(File f) {
+ BasicFileAttributes attrs;
+
+ try {
+ attrs = Files.readAttributes(f.toPath(), BasicFileAttributes.class, LinkOption.NOFOLLOW_LINKS);
+ }
+ catch (IOException ignore) {
+ return false;
+ }
+
+ if (!attrs.isDirectory() || attrs.isSymbolicLink())
+ return f.delete();
+
+ File[] entries = f.listFiles();
if (entries != null) {
for (File entry : entries) {
- if (entry.isDirectory())
- deleteDirectory(entry);
- else if (entry.isFile()) {
- if (!entry.delete())
- return false;
- }
- else
- throw new UnsupportedOperationException("Symlink deletion is not yet supported: " + entry);
+ boolean res = deleteRecursive(entry);
+
+ if (!res)
+ return false;
}
}
- return dir.delete();
+ return f.delete();
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/b5757642/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractBaseSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractBaseSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractBaseSelfTest.java
new file mode 100644
index 0000000..9575bd0
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractBaseSelfTest.java
@@ -0,0 +1,1067 @@
+/*
+ * 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.igfs;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.lang.reflect.Field;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.Callable;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.IgniteFileSystem;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cache.CacheMemoryMode;
+import org.apache.ignite.cache.CacheWriteSynchronizationMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.FileSystemConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.igfs.IgfsGroupDataBlocksKeyMapper;
+import org.apache.ignite.igfs.IgfsInputStream;
+import org.apache.ignite.igfs.IgfsIpcEndpointConfiguration;
+import org.apache.ignite.igfs.IgfsIpcEndpointType;
+import org.apache.ignite.igfs.IgfsMode;
+import org.apache.ignite.igfs.IgfsOutputStream;
+import org.apache.ignite.igfs.IgfsPath;
+import org.apache.ignite.igfs.secondary.IgfsSecondaryFileSystem;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.IgniteKernal;
+import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
+import org.apache.ignite.internal.processors.cache.GridCacheEntryEx;
+import org.apache.ignite.internal.util.future.GridFutureAdapter;
+import org.apache.ignite.internal.util.typedef.G;
+import org.apache.ignite.internal.util.typedef.X;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.marshaller.optimized.OptimizedMarshaller;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.jetbrains.annotations.Nullable;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+import static org.apache.ignite.cache.CacheMemoryMode.ONHEAP_TIERED;
+import static org.apache.ignite.cache.CacheMode.PARTITIONED;
+import static org.apache.ignite.cache.CacheMode.REPLICATED;
+import static org.apache.ignite.igfs.IgfsMode.PRIMARY;
+import static org.apache.ignite.igfs.IgfsMode.PROXY;
+
+/**
+ * Test fo regular igfs operations.
+ */
+@SuppressWarnings({"ThrowableResultOfMethodCallIgnored", "ConstantConditions"})
+public abstract class IgfsAbstractBaseSelfTest extends IgfsCommonAbstractTest {
+ /** IGFS block size. */
+ protected static final int IGFS_BLOCK_SIZE = 512 * 1024;
+
+ /** Default block size (32Mb). */
+ protected static final long BLOCK_SIZE = 32 * 1024 * 1024;
+
+ /** Default repeat count. */
+ protected static final int REPEAT_CNT = 5; // Diagnostic: up to 500; Regression: 5
+
+ /** Concurrent operations count. */
+ protected static final int OPS_CNT = 16;
+
+ /** Renames count. */
+ protected static final int RENAME_CNT = OPS_CNT;
+
+ /** Deletes count. */
+ protected static final int DELETE_CNT = OPS_CNT;
+
+ /** Updates count. */
+ protected static final int UPDATE_CNT = OPS_CNT;
+
+ /** Mkdirs count. */
+ protected static final int MKDIRS_CNT = OPS_CNT;
+
+ /** Create count. */
+ protected static final int CREATE_CNT = OPS_CNT;
+
+ /** Time to wait until the caches get empty after format. */
+ private static final long CACHE_EMPTY_TIMEOUT = 30_000L;
+
+ /** Seed to generate random numbers. */
+ protected static final long SEED = System.currentTimeMillis();
+
+ /** Amount of blocks to prefetch. */
+ protected static final int PREFETCH_BLOCKS = 1;
+
+ /** Amount of sequential block reads before prefetch is triggered. */
+ protected static final int SEQ_READS_BEFORE_PREFETCH = 2;
+
+ /** Primary file system REST endpoint configuration map. */
+ protected static final IgfsIpcEndpointConfiguration PRIMARY_REST_CFG;
+
+ /** Secondary file system REST endpoint configuration map. */
+ protected static final IgfsIpcEndpointConfiguration SECONDARY_REST_CFG;
+
+ /** Directory. */
+ protected static final IgfsPath DIR = new IgfsPath("/dir");
+
+ /** Sub-directory. */
+ protected static final IgfsPath SUBDIR = new IgfsPath(DIR, "subdir");
+
+ /** Another sub-directory in the same directory. */
+ protected static final IgfsPath SUBDIR2 = new IgfsPath(DIR, "subdir2");
+
+ /** Sub-directory of the sub-directory. */
+ protected static final IgfsPath SUBSUBDIR = new IgfsPath(SUBDIR, "subsubdir");
+
+ /** File. */
+ protected static final IgfsPath FILE = new IgfsPath(SUBDIR, "file");
+
+ /** Another file in the same directory. */
+ protected static final IgfsPath FILE2 = new IgfsPath(SUBDIR, "file2");
+
+ /** Other directory. */
+ protected static final IgfsPath DIR_NEW = new IgfsPath("/dirNew");
+
+ /** Other subdirectory. */
+ protected static final IgfsPath SUBDIR_NEW = new IgfsPath(DIR_NEW, "subdirNew");
+
+ /** Other sub-directory of the sub-directory. */
+ protected static final IgfsPath SUBSUBDIR_NEW = new IgfsPath(SUBDIR_NEW, "subsubdirNew");
+
+ /** Other file. */
+ protected static final IgfsPath FILE_NEW = new IgfsPath(SUBDIR_NEW, "fileNew");
+
+ /** Default data chunk (128 bytes). */
+ protected static final byte[] chunk = createChunk(128);
+
+ /** Primary IGFS. */
+ protected static IgfsImpl igfs;
+
+ /** Secondary IGFS */
+ protected static IgfsSecondaryFileSystem igfsSecondaryFileSystem;
+
+ /** Secondary file system lower layer "backdoor" wrapped in UniversalFileSystemAdapter: */
+ protected static IgfsSecondaryFileSystemTestAdapter igfsSecondary;
+
+ /** IGFS mode. */
+ protected final IgfsMode mode;
+
+ /** Dual mode flag. */
+ protected final boolean dual;
+
+ /** Memory mode. */
+ protected final CacheMemoryMode memoryMode;
+
+ /** IP finder for primary topology. */
+ protected final TcpDiscoveryVmIpFinder primaryIpFinder = new TcpDiscoveryVmIpFinder(true);
+
+ /** IP finder for secondary topology. */
+ protected final TcpDiscoveryVmIpFinder secondaryIpFinder = new TcpDiscoveryVmIpFinder(true);
+
+ /** Ignite nodes of cluster, excluding the secondary file system node, if any. */
+ protected Ignite[] nodes;
+
+ static {
+ PRIMARY_REST_CFG = new IgfsIpcEndpointConfiguration();
+
+ PRIMARY_REST_CFG.setType(IgfsIpcEndpointType.TCP);
+ PRIMARY_REST_CFG.setPort(10500);
+
+ SECONDARY_REST_CFG = new IgfsIpcEndpointConfiguration();
+
+ SECONDARY_REST_CFG.setType(IgfsIpcEndpointType.TCP);
+ SECONDARY_REST_CFG.setPort(11500);
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param mode IGFS mode.
+ */
+ protected IgfsAbstractBaseSelfTest(IgfsMode mode) {
+ this(mode, ONHEAP_TIERED);
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param mode IGFS mode.
+ * @param memoryMode Memory mode.
+ */
+ protected IgfsAbstractBaseSelfTest(IgfsMode mode, CacheMemoryMode memoryMode) {
+ assert mode != null && mode != PROXY;
+
+ this.mode = mode;
+ this.memoryMode = memoryMode;
+
+ dual = mode != PRIMARY;
+ }
+
+ /**
+ * @return Relaxed consistency flag.
+ */
+ protected boolean relaxedConsistency() {
+ return false;
+ }
+
+ /**
+ * @return Relaxed consistency flag.
+ */
+ protected boolean initializeDefaultPathModes() {
+ return false;
+ }
+
+ /**
+ * @return Client flag.
+ */
+ protected boolean client() {
+ return false;
+ }
+
+ /**
+ * @return Use optimized marshaller flag.
+ */
+ protected boolean useOptimizedMarshaller() {
+ return false;
+ }
+
+ /**
+ * @return Whether append is supported.
+ */
+ protected boolean appendSupported() {
+ return true;
+ }
+
+ /**
+ * @return Whether permissions are supported.
+ */
+ protected boolean permissionsSupported() {
+ return true;
+ }
+
+ /**
+ * @return Whether properties are supported.
+ */
+ protected boolean propertiesSupported() {
+ return true;
+ }
+
+ /**
+ * @return Whether times are supported.
+ */
+ protected boolean timesSupported() {
+ return true;
+ }
+
+ /**
+ * @return Amount of nodes to start.
+ */
+ protected int nodeCount() {
+ return 1;
+ }
+
+ /**
+ * Data chunk.
+ *
+ * @param len Length.
+ * @return Data chunk.
+ */
+ static byte[] createChunk(int len) {
+ byte[] chunk = new byte[len];
+
+ for (int i = 0; i < chunk.length; i++)
+ chunk[i] = (byte)i;
+
+ return chunk;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTestsStarted() throws Exception {
+ igfsSecondaryFileSystem = createSecondaryFileSystemStack();
+
+ nodes = new Ignite[nodeCount()];
+
+ for (int i = 0; i < nodes.length; i++) {
+ String nodeName = i == 0 ? "ignite" : "ignite" + i;
+
+ nodes[i] = startGridWithIgfs(nodeName, "igfs", mode, igfsSecondaryFileSystem, PRIMARY_REST_CFG,
+ primaryIpFinder);
+ }
+
+ igfs = (IgfsImpl) nodes[0].fileSystem("igfs");
+
+ if (client()) {
+ // Start client.
+ Ignition.setClientMode(true);
+
+ try {
+ Ignite ignite = startGridWithIgfs("ignite-client", "igfs", mode, igfsSecondaryFileSystem,
+ PRIMARY_REST_CFG, primaryIpFinder);
+
+ igfs = (IgfsImpl) ignite.fileSystem("igfs");
+ }
+ finally {
+ Ignition.setClientMode(false);
+ }
+ }
+ }
+
+ /**
+ * Creates secondary file system stack.
+ *
+ * @return The secondary file system.
+ * @throws Exception On error.
+ */
+ protected IgfsSecondaryFileSystem createSecondaryFileSystemStack() throws Exception {
+ Ignite igniteSecondary = startGridWithIgfs("ignite-secondary", "igfs-secondary", PRIMARY, null,
+ SECONDARY_REST_CFG, secondaryIpFinder);
+
+ IgfsEx secondaryIgfsImpl = (IgfsEx) igniteSecondary.fileSystem("igfs-secondary");
+
+ igfsSecondary = new DefaultIgfsSecondaryFileSystemTestAdapter(secondaryIgfsImpl);
+
+ return secondaryIgfsImpl.asSecondary();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ clear(igfs, igfsSecondary);
+
+ assert igfs.listFiles(new IgfsPath("/")).isEmpty();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ G.stopAll(true);
+ }
+
+ /**
+ * Start grid with IGFS.
+ *
+ * @param gridName Grid name.
+ * @param igfsName IGFS name
+ * @param mode IGFS mode.
+ * @param secondaryFs Secondary file system (optional).
+ * @param restCfg Rest configuration string (optional).
+ * @param ipFinder IP finder.
+ * @return Started grid instance.
+ * @throws Exception If failed.
+ */
+ @SuppressWarnings("unchecked")
+ protected Ignite startGridWithIgfs(String gridName, String igfsName, IgfsMode mode,
+ @Nullable IgfsSecondaryFileSystem secondaryFs, @Nullable IgfsIpcEndpointConfiguration restCfg,
+ TcpDiscoveryIpFinder ipFinder) throws Exception {
+ FileSystemConfiguration igfsCfg = new FileSystemConfiguration();
+
+ igfsCfg.setDataCacheName("dataCache");
+ igfsCfg.setMetaCacheName("metaCache");
+ igfsCfg.setName(igfsName);
+ igfsCfg.setBlockSize(IGFS_BLOCK_SIZE);
+ igfsCfg.setDefaultMode(mode);
+ igfsCfg.setIpcEndpointConfiguration(restCfg);
+ igfsCfg.setSecondaryFileSystem(secondaryFs);
+ igfsCfg.setPrefetchBlocks(PREFETCH_BLOCKS);
+ igfsCfg.setSequentialReadsBeforePrefetch(SEQ_READS_BEFORE_PREFETCH);
+ igfsCfg.setRelaxedConsistency(relaxedConsistency());
+
+ igfsCfg.setInitializeDefaultPathModes(initializeDefaultPathModes());
+
+ CacheConfiguration dataCacheCfg = defaultCacheConfiguration();
+
+ dataCacheCfg.setName("dataCache");
+ dataCacheCfg.setNearConfiguration(null);
+ dataCacheCfg.setCacheMode(PARTITIONED);
+ dataCacheCfg.setNearConfiguration(null);
+ dataCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
+ dataCacheCfg.setAffinityMapper(new IgfsGroupDataBlocksKeyMapper(2));
+ dataCacheCfg.setBackups(0);
+ dataCacheCfg.setAtomicityMode(TRANSACTIONAL);
+ dataCacheCfg.setMemoryMode(memoryMode);
+ dataCacheCfg.setOffHeapMaxMemory(0);
+
+ CacheConfiguration metaCacheCfg = defaultCacheConfiguration();
+
+ metaCacheCfg.setName("metaCache");
+ metaCacheCfg.setNearConfiguration(null);
+ metaCacheCfg.setCacheMode(REPLICATED);
+ metaCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
+ metaCacheCfg.setAtomicityMode(TRANSACTIONAL);
+
+ IgniteConfiguration cfg = new IgniteConfiguration();
+
+ if (useOptimizedMarshaller())
+ cfg.setMarshaller(new OptimizedMarshaller());
+
+ cfg.setGridName(gridName);
+
+ TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
+
+ discoSpi.setIpFinder(ipFinder);
+
+ prepareCacheConfigurations(dataCacheCfg, metaCacheCfg);
+
+ cfg.setDiscoverySpi(discoSpi);
+ cfg.setCacheConfiguration(dataCacheCfg, metaCacheCfg);
+ cfg.setFileSystemConfiguration(igfsCfg);
+
+ cfg.setLocalHost("127.0.0.1");
+ cfg.setConnectorConfiguration(null);
+
+ return G.start(cfg);
+ }
+
+ /**
+ * Prepare cache configuration.
+ *
+ * @param dataCacheCfg Data cache configuration.
+ * @param metaCacheCfg Meta cache configuration.
+ */
+ protected void prepareCacheConfigurations(CacheConfiguration dataCacheCfg, CacheConfiguration metaCacheCfg) {
+ // Noop
+ }
+
+ /**
+ * Execute provided task in a separate thread.
+ *
+ * @param task Task to execute.
+ * @return Result.
+ */
+ protected static <T> IgniteInternalFuture<T> execute(final Callable<T> task) {
+ final GridFutureAdapter<T> fut = new GridFutureAdapter<>();
+
+ new Thread(new Runnable() {
+ @Override public void run() {
+ try {
+ fut.onDone(task.call());
+ }
+ catch (Throwable e) {
+ fut.onDone(e);
+ }
+ }
+ }).start();
+
+ return fut;
+ }
+
+
+ /**
+ * Create the given directories and files in the given IGFS.
+ *
+ * @param igfs IGFS.
+ * @param dirs Directories.
+ * @param files Files.
+ * @throws Exception If failed.
+ */
+ @SuppressWarnings("EmptyTryBlock")
+ public static void create(IgfsImpl igfs, @Nullable IgfsPath[] dirs, @Nullable IgfsPath[] files) throws Exception {
+ if (dirs != null) {
+ for (IgfsPath dir : dirs)
+ igfs.mkdirs(dir);
+ }
+
+ if (files != null) {
+ for (IgfsPath file : files) {
+ try (OutputStream ignored = igfs.create(file, true)) {
+ // No-op.
+ }
+
+ igfs.await(file);
+ }
+ }
+ }
+
+ /**
+ * Creates specified files/directories
+ *
+ * @param uni The file system to operate on.
+ * @param dirs The directories to create.
+ * @param files The files to create.
+ * @throws Exception On error.
+ */
+ @SuppressWarnings("EmptyTryBlock")
+ public void create(IgfsSecondaryFileSystemTestAdapter uni, @Nullable IgfsPath[] dirs, @Nullable IgfsPath[] files)
+ throws Exception {
+ if (dirs != null) {
+ for (IgfsPath dir : dirs)
+ uni.mkdirs(dir.toString());
+ }
+
+ if (files != null) {
+ for (IgfsPath file : files)
+ try (OutputStream ignore = uni.openOutputStream(file.toString(), false)) {
+ // No-op
+ }
+ }
+ }
+
+ /**
+ * Create the file in the given IGFS and write provided data chunks to it.
+ *
+ * @param igfs IGFS.
+ * @param file File.
+ * @param overwrite Overwrite flag.
+ * @param chunks Data chunks.
+ * @throws IOException In case of IO exception.
+ */
+ protected static void createFile(IgfsEx igfs, IgfsPath file, boolean overwrite, @Nullable byte[]... chunks)
+ throws IOException {
+ OutputStream os = null;
+
+ try {
+ os = igfs.create(file, overwrite);
+
+ writeFileChunks(os, chunks);
+ }
+ finally {
+ U.closeQuiet(os);
+
+ awaitFileClose(igfs, file);
+ }
+ }
+
+ /**
+ * Create the file in the given IGFS and write provided data chunks to it.
+ *
+ * @param file File.
+ * @param chunks Data chunks.
+ * @throws IOException In case of IO exception.
+ */
+ protected static void createFile(IgfsSecondaryFileSystemTestAdapter uni, IgfsPath file, @Nullable byte[]... chunks)
+ throws IOException {
+ OutputStream os = null;
+
+ try {
+ os = uni.openOutputStream(file.toString(), false);
+
+ writeFileChunks(os, chunks);
+ }
+ finally {
+ U.closeQuiet(os);
+
+ IgfsEx igfsEx = uni.igfs();
+
+ if (igfsEx != null)
+ awaitFileClose(igfsEx, file);
+ }
+ }
+
+ /**
+ * Create the file in the given IGFS and write provided data chunks to it.
+ *
+ * @param igfs IGFS.
+ * @param file File.
+ * @param overwrite Overwrite flag.
+ * @param blockSize Block size.
+ * @param chunks Data chunks.
+ * @throws Exception If failed.
+ */
+ protected static void createFile(IgfsImpl igfs, IgfsPath file, boolean overwrite, long blockSize,
+ @Nullable byte[]... chunks) throws Exception {
+ IgfsOutputStream os = null;
+
+ try {
+ os = igfs.create(file, 256, overwrite, null, 0, blockSize, null);
+
+ writeFileChunks(os, chunks);
+ }
+ finally {
+ U.closeQuiet(os);
+
+ awaitFileClose(igfs, file);
+ }
+ }
+
+ /**
+ * Append to the file in the given IGFS provided data chunks.
+ *
+ * @param igfs IGFS.
+ * @param file File.
+ * @param chunks Data chunks.
+ * @throws Exception If failed.
+ */
+ protected static void appendFile(IgfsImpl igfs, IgfsPath file, @Nullable byte[]... chunks)
+ throws Exception {
+ IgfsOutputStream os = null;
+
+ try {
+ os = igfs.append(file, false);
+
+ writeFileChunks(os, chunks);
+ }
+ finally {
+ U.closeQuiet(os);
+
+ awaitFileClose(igfs, file);
+ }
+ }
+
+ /**
+ * Write provided data chunks to the file output stream.
+ *
+ * @param os Output stream.
+ * @param chunks Data chunks.
+ * @throws IOException If failed.
+ */
+ protected static void writeFileChunks(OutputStream os, @Nullable byte[]... chunks) throws IOException {
+ if (chunks != null && chunks.length > 0) {
+ for (byte[] chunk : chunks)
+ os.write(chunk);
+ }
+ }
+
+ /**
+ * Await for previously opened output stream to close. This is achieved by requesting dummy update on the file.
+ *
+ * @param igfs IGFS.
+ * @param file File.
+ */
+ public static void awaitFileClose(IgfsSecondaryFileSystem igfs, IgfsPath file) {
+ try {
+ igfs.update(file, Collections.singletonMap("prop", "val"));
+ }
+ catch (IgniteException ignore) {
+ // No-op.
+ }
+ }
+
+ /**
+ * Await for previously opened output stream to close.
+ *
+ * @param igfs IGFS.
+ * @param file File.
+ */
+ public static void awaitFileClose(@Nullable IgfsEx igfs, IgfsPath file) {
+ igfs.await(file);
+ }
+
+ /**
+ * Ensure that the given paths exist in the given IGFSs.
+ *
+ * @param igfs First IGFS.
+ * @param igfsSecondary Second IGFS.
+ * @param paths Paths.
+ * @throws Exception If failed.
+ */
+ protected void checkExist(IgfsImpl igfs, IgfsSecondaryFileSystemTestAdapter igfsSecondary, IgfsPath... paths)
+ throws Exception {
+ checkExist(igfs, paths);
+
+ if (dual)
+ checkExist(igfsSecondary, paths);
+ }
+
+ /**
+ * Ensure that the given paths exist in the given IGFS.
+ *
+ * @param igfs IGFS.
+ * @param paths Paths.
+ * @throws IgniteCheckedException If failed.
+ */
+ protected static void checkExist(IgfsImpl igfs, IgfsPath... paths) throws IgniteCheckedException {
+ for (IgfsPath path : paths)
+ assert igfs.exists(path) : "Path doesn't exist [igfs=" + igfs.name() + ", path=" + path + ']';
+ }
+
+ /**
+ * Ensure that the given paths exist in the given IGFS.
+ *
+ * @param uni filesystem.
+ * @param paths Paths.
+ * @throws IgniteCheckedException If failed.
+ */
+ protected void checkExist(IgfsSecondaryFileSystemTestAdapter uni, IgfsPath... paths) throws IgniteCheckedException {
+ IgfsEx ex = uni.igfs();
+
+ for (IgfsPath path : paths) {
+ if (ex != null)
+ assert ex.context().meta().fileId(path) != null : "Path doesn't exist [igfs=" + ex.name() +
+ ", path=" + path + ']';
+
+ try {
+ assert uni.exists(path.toString()) : "Path doesn't exist [igfs=" + uni.name() + ", path=" + path + ']';
+ }
+ catch (IOException ioe) {
+ throw new IgniteCheckedException(ioe);
+ }
+ }
+ }
+
+ /**
+ * Ensure that the given paths don't exist in the given IGFSs.
+ *
+ * @param igfs First IGFS.
+ * @param igfsSecondary Second IGFS.
+ * @param paths Paths.
+ * @throws Exception If failed.
+ */
+ protected void checkNotExist(IgfsImpl igfs, IgfsSecondaryFileSystemTestAdapter igfsSecondary, IgfsPath... paths)
+ throws Exception {
+ checkNotExist(igfs, paths);
+
+ if (dual)
+ checkNotExist(igfsSecondary, paths);
+ }
+
+ /**
+ * Ensure that the given paths don't exist in the given IGFS.
+ *
+ * @param igfs IGFS.
+ * @param paths Paths.
+ * @throws Exception If failed.
+ */
+ protected void checkNotExist(IgfsImpl igfs, IgfsPath... paths) throws Exception {
+ for (IgfsPath path : paths)
+ assert !igfs.exists(path) : "Path exists [igfs=" + igfs.name() + ", path=" + path + ']';
+ }
+
+ /**
+ * Ensure that the given paths don't exist in the given IGFS.
+ *
+ * @param uni secondary FS.
+ * @param paths Paths.
+ * @throws Exception If failed.
+ */
+ protected void checkNotExist(IgfsSecondaryFileSystemTestAdapter uni, IgfsPath... paths) throws Exception {
+ IgfsEx ex = uni.igfs();
+
+ for (IgfsPath path : paths) {
+ if (ex != null)
+ assert !ex.exists(path) : "Path exists [igfs=" + ex.name() + ", path=" + path + ']';
+
+ assert !uni.exists(path.toString()) : "Path exists [igfs=" + uni.name() + ", path=" + path + ']';
+ }
+ }
+
+ /**
+ * Ensure that the given file exists in the given IGFSs and that it has exactly the same content as provided in the
+ * "data" parameter.
+ *
+ * @param igfs First IGFS.
+ * @param igfsSecondary Second IGFS.
+ * @param file File.
+ * @param chunks Expected data.
+ * @throws Exception If failed.
+ */
+ protected void checkFile(@Nullable IgfsImpl igfs, IgfsSecondaryFileSystemTestAdapter igfsSecondary, IgfsPath file,
+ @Nullable byte[]... chunks) throws Exception {
+ if (igfs != null) {
+ checkExist(igfs, file);
+ checkFileContent(igfs, file, chunks);
+ }
+
+ if (dual) {
+ checkExist(igfsSecondary, file);
+ checkFileContent(igfsSecondary, file.toString(), chunks);
+ }
+ }
+
+ /**
+ * Ensure that the given file has exactly the same content as provided in the "data" parameter.
+ *
+ * @param igfs IGFS.
+ * @param file File.
+ * @param chunks Expected data.
+ * @throws IOException In case of IO exception.
+ * @throws IgniteCheckedException In case of Grid exception.
+ */
+ protected static void checkFileContent(IgfsImpl igfs, IgfsPath file, @Nullable byte[]... chunks)
+ throws IOException, IgniteCheckedException {
+ if (chunks != null && chunks.length > 0) {
+ IgfsInputStream is = null;
+
+ try {
+ is = igfs.open(file);
+
+ int chunkIdx = 0;
+ int pos = 0;
+
+ for (byte[] chunk : chunks) {
+ byte[] buf = new byte[chunk.length];
+
+ is.readFully(pos, buf);
+
+ assert Arrays.equals(chunk, buf) : "Bad chunk [igfs=" + igfs.name() + ", chunkIdx=" + chunkIdx +
+ ", expected=" + Arrays.toString(chunk) + ", actual=" + Arrays.toString(buf) + ']';
+
+ chunkIdx++;
+ pos += chunk.length;
+ }
+
+ is.close();
+ }
+ finally {
+ U.closeQuiet(is);
+ }
+ }
+ }
+
+ /**
+ * Ensure that the given file has exactly the same content as provided in the "data" parameter.
+ *
+ * @param uni FS.
+ * @param path File.
+ * @param chunks Expected data.
+ * @throws IOException In case of IO exception.
+ * @throws IgniteCheckedException In case of Grid exception.
+ */
+ protected void checkFileContent(IgfsSecondaryFileSystemTestAdapter uni, String path, @Nullable byte[]... chunks)
+ throws IOException, IgniteCheckedException {
+ if (chunks != null && chunks.length > 0) {
+ InputStream is = null;
+
+ try {
+ is = uni.openInputStream(path);
+
+ int chunkIdx = 0;
+
+ int read;
+ for (byte[] chunk: chunks) {
+ byte[] buf = new byte[chunk.length];
+
+ read = 0;
+
+ while (true) {
+ int r = is.read(buf, read, buf.length - read);
+
+ read += r;
+
+ if (read == buf.length || r <= 0)
+ break;
+ }
+
+ assert read == chunk.length : "Chunk #" + chunkIdx + " was not read fully:" +
+ " read=" + read + ", expected=" + chunk.length;
+ assert Arrays.equals(chunk, buf) : "Bad chunk [igfs=" + uni.name() + ", chunkIdx=" + chunkIdx +
+ ", expected=" + Arrays.toString(chunk) + ", actual=" + Arrays.toString(buf) + ']';
+
+ chunkIdx++;
+ }
+
+ is.close();
+ }
+ finally {
+ U.closeQuiet(is);
+ }
+ }
+ }
+
+ /**
+ * Create map with properties.
+ *
+ * @param username User name.
+ * @param grpName Group name.
+ * @param perm Permission.
+ * @return Map with properties.
+ */
+ protected Map<String, String> properties(@Nullable String username, @Nullable String grpName,
+ @Nullable String perm) {
+ Map<String, String> props = new HashMap<>();
+
+ if (username != null)
+ props.put(IgfsUtils.PROP_USER_NAME, username);
+
+ if (grpName != null)
+ props.put(IgfsUtils.PROP_GROUP_NAME, grpName);
+
+ if (perm != null)
+ props.put(IgfsUtils.PROP_PERMISSION, perm);
+
+ return props;
+ }
+
+ /**
+ * Convenient method to group paths.
+ *
+ * @param paths Paths to group.
+ * @return Paths as array.
+ */
+ protected static IgfsPath[] paths(IgfsPath... paths) {
+ return paths;
+ }
+
+ /**
+ * Safely clear IGFSs.
+ *
+ * @param igfs First IGFS.
+ * @param igfsSecondary Second IGFS.
+ * @throws Exception If failed.
+ */
+ protected void clear(IgniteFileSystem igfs, IgfsSecondaryFileSystemTestAdapter igfsSecondary) throws Exception {
+ clear(igfs);
+
+ if (dual)
+ clear(igfsSecondary);
+ }
+
+ /**
+ * Gets the data cache instance for this IGFS instance.
+ *
+ * @param igfs The IGFS unstance.
+ * @return The data cache.
+ */
+ protected static GridCacheAdapter<IgfsBlockKey, byte[]> getDataCache(IgniteFileSystem igfs) {
+ String dataCacheName = igfs.configuration().getDataCacheName();
+
+ IgniteEx igniteEx = ((IgfsEx)igfs).context().kernalContext().grid();
+
+ return ((IgniteKernal)igniteEx).internalCache(dataCacheName);
+ }
+
+ /**
+ * Gets meta cache.
+ *
+ * @param igfs The IGFS instance.
+ * @return The data cache.
+ */
+ protected static GridCacheAdapter<IgniteUuid, IgfsEntryInfo> getMetaCache(IgniteFileSystem igfs) {
+ String dataCacheName = igfs.configuration().getMetaCacheName();
+
+ IgniteEx igniteEx = ((IgfsEx)igfs).context().kernalContext().grid();
+
+ return ((IgniteKernal)igniteEx).internalCache(dataCacheName);
+ }
+
+ /**
+ * Clear particular IGFS.
+ *
+ * @param igfs IGFS.
+ * @throws Exception If failed.
+ */
+ @SuppressWarnings("unchecked")
+ public static void clear(IgniteFileSystem igfs) throws Exception {
+ Field workerMapFld = IgfsImpl.class.getDeclaredField("workerMap");
+
+ workerMapFld.setAccessible(true);
+
+ // Wait for all workers to finish.
+ Map<IgfsPath, IgfsFileWorkerBatch> workerMap = (Map<IgfsPath, IgfsFileWorkerBatch>)workerMapFld.get(igfs);
+
+ for (Map.Entry<IgfsPath, IgfsFileWorkerBatch> entry : workerMap.entrySet()) {
+ entry.getValue().cancel();
+
+ try {
+ entry.getValue().await();
+ }
+ catch (IgniteCheckedException e) {
+ if (!(e instanceof IgfsFileWorkerBatchCancelledException))
+ throw e;
+ }
+ }
+
+ // Clear igfs.
+ igfs.format();
+
+ int prevDifferentSize = Integer.MAX_VALUE; // Previous different size.
+ int constCnt = 0, totalCnt = 0;
+ final int constThreshold = 20;
+ final long sleepPeriod = 500L;
+ final long totalThreshold = CACHE_EMPTY_TIMEOUT / sleepPeriod;
+
+ while (true) {
+ int metaSize = 0;
+
+ for (IgniteUuid metaId : getMetaCache(igfs).keySet()) {
+ if (!IgfsUtils.isRootOrTrashId(metaId))
+ metaSize++;
+ }
+
+ int dataSize = getDataCache(igfs).size();
+
+ int size = metaSize + dataSize;
+
+ if (size <= 2)
+ return; // Caches are cleared, we're done. (2 because ROOT & TRASH always exist).
+
+ X.println("Sum size: " + size);
+
+ if (size > prevDifferentSize) {
+ X.println("Summary cache size has grown unexpectedly: size=" + size + ", prevSize=" + prevDifferentSize);
+
+ break;
+ }
+
+ if (totalCnt > totalThreshold) {
+ X.println("Timeout exceeded.");
+
+ break;
+ }
+
+ if (size == prevDifferentSize) {
+ constCnt++;
+
+ if (constCnt == constThreshold) {
+ X.println("Summary cache size stays unchanged for too long: size=" + size);
+
+ break;
+ }
+ } else {
+ constCnt = 0;
+
+ prevDifferentSize = size; // renew;
+ }
+
+ Thread.sleep(sleepPeriod);
+
+ totalCnt++;
+ }
+
+ dumpCache("MetaCache" , getMetaCache(igfs));
+
+ dumpCache("DataCache" , getDataCache(igfs));
+
+ fail("Caches are not empty.");
+ }
+
+ /**
+ * Dumps given cache for diagnostic purposes.
+ *
+ * @param cacheName Name.
+ * @param cache The cache.
+ */
+ private static void dumpCache(String cacheName, GridCacheAdapter<?,?> cache) {
+ X.println("=============================== " + cacheName + " cache dump: ");
+
+ Iterable<? extends GridCacheEntryEx> entries = cache.entries();
+
+ for (GridCacheEntryEx e: entries)
+ X.println("Lost " + cacheName + " entry = " + e);
+ }
+
+ /**
+ * Clear particular {@link IgfsSecondaryFileSystemTestAdapter}.
+ *
+ * @param uni IGFS.
+ * @throws Exception If failed.
+ */
+ @SuppressWarnings("unchecked")
+ public static void clear(IgfsSecondaryFileSystemTestAdapter uni) throws Exception {
+ IgfsEx igfsEx = uni.igfs();
+
+ if (igfsEx != null)
+ clear(igfsEx);
+
+ // Clear the filesystem.
+ uni.format();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTest() throws Exception {
+ clear(igfs, igfsSecondary);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/b5757642/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java
index 86c2449..c9b08d9 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java
@@ -17,55 +17,32 @@
package org.apache.ignite.internal.processors.igfs;
-import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
-import org.apache.ignite.IgniteFileSystem;
-import org.apache.ignite.Ignition;
import org.apache.ignite.cache.CacheMemoryMode;
import org.apache.ignite.cache.CachePeekMode;
-import org.apache.ignite.cache.CacheWriteSynchronizationMode;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.configuration.FileSystemConfiguration;
-import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.igfs.IgfsDirectoryNotEmptyException;
import org.apache.ignite.igfs.IgfsException;
import org.apache.ignite.igfs.IgfsFile;
-import org.apache.ignite.igfs.IgfsGroupDataBlocksKeyMapper;
import org.apache.ignite.igfs.IgfsInputStream;
-import org.apache.ignite.igfs.IgfsIpcEndpointConfiguration;
-import org.apache.ignite.igfs.IgfsIpcEndpointType;
import org.apache.ignite.igfs.IgfsMode;
import org.apache.ignite.igfs.IgfsOutputStream;
import org.apache.ignite.igfs.IgfsParentNotDirectoryException;
import org.apache.ignite.igfs.IgfsPath;
import org.apache.ignite.igfs.IgfsPathNotFoundException;
-import org.apache.ignite.igfs.secondary.IgfsSecondaryFileSystem;
-import org.apache.ignite.internal.IgniteEx;
import org.apache.ignite.internal.IgniteInternalFuture;
-import org.apache.ignite.internal.IgniteKernal;
import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
import org.apache.ignite.internal.processors.cache.GridCacheEntryEx;
-import org.apache.ignite.internal.util.future.GridFutureAdapter;
import org.apache.ignite.internal.util.lang.GridAbsPredicate;
import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.internal.util.typedef.G;
import org.apache.ignite.internal.util.typedef.T2;
import org.apache.ignite.internal.util.typedef.X;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteBiTuple;
import org.apache.ignite.lang.IgniteUuid;
-import org.apache.ignite.marshaller.optimized.OptimizedMarshaller;
-import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
import org.apache.ignite.testframework.GridTestUtils;
-import org.jetbrains.annotations.Nullable;
import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.lang.reflect.Field;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
@@ -84,142 +61,18 @@ import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
-import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
-import static org.apache.ignite.cache.CacheMemoryMode.ONHEAP_TIERED;
-import static org.apache.ignite.cache.CacheMode.PARTITIONED;
-import static org.apache.ignite.cache.CacheMode.REPLICATED;
-import static org.apache.ignite.igfs.IgfsMode.PRIMARY;
-import static org.apache.ignite.igfs.IgfsMode.PROXY;
-
/**
* Test fo regular igfs operations.
*/
@SuppressWarnings({"ThrowableResultOfMethodCallIgnored", "ConstantConditions"})
-public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
- /** IGFS block size. */
- protected static final int IGFS_BLOCK_SIZE = 512 * 1024;
-
- /** Default block size (32Mb). */
- protected static final long BLOCK_SIZE = 32 * 1024 * 1024;
-
- /** Default repeat count. */
- protected static final int REPEAT_CNT = 5; // Diagnostic: up to 500; Regression: 5
-
- /** Concurrent operations count. */
- protected static final int OPS_CNT = 16;
-
- /** Renames count. */
- protected static final int RENAME_CNT = OPS_CNT;
-
- /** Deletes count. */
- protected static final int DELETE_CNT = OPS_CNT;
-
- /** Updates count. */
- protected static final int UPDATE_CNT = OPS_CNT;
-
- /** Mkdirs count. */
- protected static final int MKDIRS_CNT = OPS_CNT;
-
- /** Create count. */
- protected static final int CREATE_CNT = OPS_CNT;
-
- /** Time to wait until the caches get empty after format. */
- private static final long CACHE_EMPTY_TIMEOUT = 30_000L;
-
- /** Seed to generate random numbers. */
- protected static final long SEED = System.currentTimeMillis();
-
- /** Amount of blocks to prefetch. */
- protected static final int PREFETCH_BLOCKS = 1;
-
- /** Amount of sequential block reads before prefetch is triggered. */
- protected static final int SEQ_READS_BEFORE_PREFETCH = 2;
-
- /** Primary file system REST endpoint configuration map. */
- protected static final IgfsIpcEndpointConfiguration PRIMARY_REST_CFG;
-
- /** Secondary file system REST endpoint configuration map. */
- protected static final IgfsIpcEndpointConfiguration SECONDARY_REST_CFG;
-
- /** Directory. */
- protected static final IgfsPath DIR = new IgfsPath("/dir");
-
- /** Sub-directory. */
- protected static final IgfsPath SUBDIR = new IgfsPath(DIR, "subdir");
-
- /** Another sub-directory in the same directory. */
- protected static final IgfsPath SUBDIR2 = new IgfsPath(DIR, "subdir2");
-
- /** Sub-directory of the sub-directory. */
- protected static final IgfsPath SUBSUBDIR = new IgfsPath(SUBDIR, "subsubdir");
-
- /** File. */
- protected static final IgfsPath FILE = new IgfsPath(SUBDIR, "file");
-
- /** Another file in the same directory. */
- protected static final IgfsPath FILE2 = new IgfsPath(SUBDIR, "file2");
-
- /** Other directory. */
- protected static final IgfsPath DIR_NEW = new IgfsPath("/dirNew");
-
- /** Other subdirectory. */
- protected static final IgfsPath SUBDIR_NEW = new IgfsPath(DIR_NEW, "subdirNew");
-
- /** Other sub-directory of the sub-directory. */
- protected static final IgfsPath SUBSUBDIR_NEW = new IgfsPath(SUBDIR_NEW, "subsubdirNew");
-
- /** Other file. */
- protected static final IgfsPath FILE_NEW = new IgfsPath(SUBDIR_NEW, "fileNew");
-
- /** Default data chunk (128 bytes). */
- protected static final byte[] chunk = createChunk(128);
-
- /** Primary IGFS. */
- protected static IgfsImpl igfs;
-
- /** Secondary IGFS */
- protected static IgfsSecondaryFileSystem igfsSecondaryFileSystem;
-
- /** Secondary file system lower layer "backdoor" wrapped in UniversalFileSystemAdapter: */
- protected static IgfsSecondaryFileSystemTestAdapter igfsSecondary;
-
- /** IGFS mode. */
- protected final IgfsMode mode;
-
- /** Dual mode flag. */
- protected final boolean dual;
-
- /** Memory mode. */
- protected final CacheMemoryMode memoryMode;
-
- /** IP finder for primary topology. */
- protected final TcpDiscoveryVmIpFinder primaryIpFinder = new TcpDiscoveryVmIpFinder(true);
-
- /** IP finder for secondary topology. */
- protected final TcpDiscoveryVmIpFinder secondaryIpFinder = new TcpDiscoveryVmIpFinder(true);
-
- /** Ignite nodes of cluster, excluding the secondary file system node, if any. */
- protected Ignite[] nodes;
-
- static {
- PRIMARY_REST_CFG = new IgfsIpcEndpointConfiguration();
-
- PRIMARY_REST_CFG.setType(IgfsIpcEndpointType.TCP);
- PRIMARY_REST_CFG.setPort(10500);
-
- SECONDARY_REST_CFG = new IgfsIpcEndpointConfiguration();
-
- SECONDARY_REST_CFG.setType(IgfsIpcEndpointType.TCP);
- SECONDARY_REST_CFG.setPort(11500);
- }
-
+public abstract class IgfsAbstractSelfTest extends IgfsAbstractBaseSelfTest {
/**
* Constructor.
*
* @param mode IGFS mode.
*/
protected IgfsAbstractSelfTest(IgfsMode mode) {
- this(mode, ONHEAP_TIERED);
+ super(mode);
}
/**
@@ -229,258 +82,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
* @param memoryMode Memory mode.
*/
protected IgfsAbstractSelfTest(IgfsMode mode, CacheMemoryMode memoryMode) {
- assert mode != null && mode != PROXY;
-
- this.mode = mode;
- this.memoryMode = memoryMode;
-
- dual = mode != PRIMARY;
- }
-
- /**
- * @return Relaxed consistency flag.
- */
- protected boolean relaxedConsistency() {
- return false;
- }
-
- /**
- * @return Relaxed consistency flag.
- */
- protected boolean initializeDefaultPathModes() {
- return false;
- }
-
- /**
- * @return Client flag.
- */
- protected boolean client() {
- return false;
- }
-
- /**
- * @return Use optimized marshaller flag.
- */
- protected boolean useOptimizedMarshaller() {
- return false;
- }
-
- /**
- * @return Whether append is supported.
- */
- protected boolean appendSupported() {
- return true;
- }
-
- /**
- * @return Whether permissions are supported.
- */
- protected boolean permissionsSupported() {
- return true;
- }
-
- /**
- * @return Whether properties are supported.
- */
- protected boolean propertiesSupported() {
- return true;
- }
-
- /**
- * @return Whether times are supported.
- */
- protected boolean timesSupported() {
- return true;
- }
-
- /**
- * @return Amount of nodes to start.
- */
- protected int nodeCount() {
- return 1;
- }
-
- /**
- * Data chunk.
- *
- * @param len Length.
- * @return Data chunk.
- */
- static byte[] createChunk(int len) {
- byte[] chunk = new byte[len];
-
- for (int i = 0; i < chunk.length; i++)
- chunk[i] = (byte)i;
-
- return chunk;
- }
-
- /** {@inheritDoc} */
- @Override protected void beforeTestsStarted() throws Exception {
- igfsSecondaryFileSystem = createSecondaryFileSystemStack();
-
- nodes = new Ignite[nodeCount()];
-
- for (int i = 0; i < nodes.length; i++) {
- String nodeName = i == 0 ? "ignite" : "ignite" + i;
-
- nodes[i] = startGridWithIgfs(nodeName, "igfs", mode, igfsSecondaryFileSystem, PRIMARY_REST_CFG,
- primaryIpFinder);
- }
-
- igfs = (IgfsImpl) nodes[0].fileSystem("igfs");
-
- if (client()) {
- // Start client.
- Ignition.setClientMode(true);
-
- try {
- Ignite ignite = startGridWithIgfs("ignite-client", "igfs", mode, igfsSecondaryFileSystem,
- PRIMARY_REST_CFG, primaryIpFinder);
-
- igfs = (IgfsImpl) ignite.fileSystem("igfs");
- }
- finally {
- Ignition.setClientMode(false);
- }
- }
- }
-
- /**
- * Creates secondary file system stack.
- *
- * @return The secondary file system.
- * @throws Exception On error.
- */
- protected IgfsSecondaryFileSystem createSecondaryFileSystemStack() throws Exception {
- Ignite igniteSecondary = startGridWithIgfs("ignite-secondary", "igfs-secondary", PRIMARY, null,
- SECONDARY_REST_CFG, secondaryIpFinder);
-
- IgfsEx secondaryIgfsImpl = (IgfsEx) igniteSecondary.fileSystem("igfs-secondary");
-
- igfsSecondary = new DefaultIgfsSecondaryFileSystemTestAdapter(secondaryIgfsImpl);
-
- return secondaryIgfsImpl.asSecondary();
- }
-
- /** {@inheritDoc} */
- @Override protected void afterTest() throws Exception {
- clear(igfs, igfsSecondary);
-
- assert igfs.listFiles(new IgfsPath("/")).isEmpty();
- }
-
- /** {@inheritDoc} */
- @Override protected void afterTestsStopped() throws Exception {
- G.stopAll(true);
- }
-
- /**
- * Start grid with IGFS.
- *
- * @param gridName Grid name.
- * @param igfsName IGFS name
- * @param mode IGFS mode.
- * @param secondaryFs Secondary file system (optional).
- * @param restCfg Rest configuration string (optional).
- * @param ipFinder IP finder.
- * @return Started grid instance.
- * @throws Exception If failed.
- */
- @SuppressWarnings("unchecked")
- protected Ignite startGridWithIgfs(String gridName, String igfsName, IgfsMode mode,
- @Nullable IgfsSecondaryFileSystem secondaryFs, @Nullable IgfsIpcEndpointConfiguration restCfg,
- TcpDiscoveryIpFinder ipFinder) throws Exception {
- FileSystemConfiguration igfsCfg = new FileSystemConfiguration();
-
- igfsCfg.setDataCacheName("dataCache");
- igfsCfg.setMetaCacheName("metaCache");
- igfsCfg.setName(igfsName);
- igfsCfg.setBlockSize(IGFS_BLOCK_SIZE);
- igfsCfg.setDefaultMode(mode);
- igfsCfg.setIpcEndpointConfiguration(restCfg);
- igfsCfg.setSecondaryFileSystem(secondaryFs);
- igfsCfg.setPrefetchBlocks(PREFETCH_BLOCKS);
- igfsCfg.setSequentialReadsBeforePrefetch(SEQ_READS_BEFORE_PREFETCH);
- igfsCfg.setRelaxedConsistency(relaxedConsistency());
-
- igfsCfg.setInitializeDefaultPathModes(initializeDefaultPathModes());
-
- CacheConfiguration dataCacheCfg = defaultCacheConfiguration();
-
- dataCacheCfg.setName("dataCache");
- dataCacheCfg.setNearConfiguration(null);
- dataCacheCfg.setCacheMode(PARTITIONED);
- dataCacheCfg.setNearConfiguration(null);
- dataCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
- dataCacheCfg.setAffinityMapper(new IgfsGroupDataBlocksKeyMapper(2));
- dataCacheCfg.setBackups(0);
- dataCacheCfg.setAtomicityMode(TRANSACTIONAL);
- dataCacheCfg.setMemoryMode(memoryMode);
- dataCacheCfg.setOffHeapMaxMemory(0);
-
- CacheConfiguration metaCacheCfg = defaultCacheConfiguration();
-
- metaCacheCfg.setName("metaCache");
- metaCacheCfg.setNearConfiguration(null);
- metaCacheCfg.setCacheMode(REPLICATED);
- metaCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
- metaCacheCfg.setAtomicityMode(TRANSACTIONAL);
-
- IgniteConfiguration cfg = new IgniteConfiguration();
-
- if (useOptimizedMarshaller())
- cfg.setMarshaller(new OptimizedMarshaller());
-
- cfg.setGridName(gridName);
-
- TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
-
- discoSpi.setIpFinder(ipFinder);
-
- prepareCacheConfigurations(dataCacheCfg, metaCacheCfg);
-
- cfg.setDiscoverySpi(discoSpi);
- cfg.setCacheConfiguration(dataCacheCfg, metaCacheCfg);
- cfg.setFileSystemConfiguration(igfsCfg);
-
- cfg.setLocalHost("127.0.0.1");
- cfg.setConnectorConfiguration(null);
-
- return G.start(cfg);
- }
-
- /**
- * Prepare cache configuration.
- *
- * @param dataCacheCfg Data cache configuration.
- * @param metaCacheCfg Meta cache configuration.
- */
- protected void prepareCacheConfigurations(CacheConfiguration dataCacheCfg, CacheConfiguration metaCacheCfg) {
- // Noop
- }
-
- /**
- * Execute provided task in a separate thread.
- *
- * @param task Task to execute.
- * @return Result.
- */
- protected static <T> IgniteInternalFuture<T> execute(final Callable<T> task) {
- final GridFutureAdapter<T> fut = new GridFutureAdapter<>();
-
- new Thread(new Runnable() {
- @Override public void run() {
- try {
- fut.onDone(task.call());
- }
- catch (Throwable e) {
- fut.onDone(e);
- }
- }
- }).start();
-
- return fut;
+ super(mode, memoryMode);
}
/**
@@ -1138,8 +740,9 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
}
/**
+ * Check root property update.
*
- * @throws Exception
+ * @throws Exception If failed.
*/
private void checkRootPropertyUpdate(String prop, String setVal, String expGetVal) throws Exception {
final IgfsPath rootPath = new IgfsPath("/");
@@ -2945,609 +2548,4 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
U.joinThreads(threads, null);
}
-
- /**
- * Create the given directories and files in the given IGFS.
- *
- * @param igfs IGFS.
- * @param dirs Directories.
- * @param files Files.
- * @throws Exception If failed.
- */
- @SuppressWarnings("EmptyTryBlock")
- public static void create(IgfsImpl igfs, @Nullable IgfsPath[] dirs, @Nullable IgfsPath[] files) throws Exception {
- if (dirs != null) {
- for (IgfsPath dir : dirs)
- igfs.mkdirs(dir);
- }
-
- if (files != null) {
- for (IgfsPath file : files) {
- try (OutputStream os = igfs.create(file, true)) {
- // No-op.
- }
-
- igfs.await(file);
- }
- }
- }
-
- /**
- * Creates specified files/directories
- *
- * @param uni The file system to operate on.
- * @param dirs The directories to create.
- * @param files The files to create.
- * @throws Exception On error.
- */
- @SuppressWarnings("EmptyTryBlock")
- public void create(IgfsSecondaryFileSystemTestAdapter uni, @Nullable IgfsPath[] dirs, @Nullable IgfsPath[] files)
- throws Exception {
- if (dirs != null) {
- for (IgfsPath dir : dirs)
- uni.mkdirs(dir.toString());
- }
-
- if (files != null) {
- for (IgfsPath file : files)
- try (OutputStream ignore = uni.openOutputStream(file.toString(), false)) {
- // No-op
- }
- }
- }
-
- /**
- * Create the file in the given IGFS and write provided data chunks to it.
- *
- * @param igfs IGFS.
- * @param file File.
- * @param overwrite Overwrite flag.
- * @param chunks Data chunks.
- * @throws IOException In case of IO exception.
- */
- protected static void createFile(IgfsEx igfs, IgfsPath file, boolean overwrite, @Nullable byte[]... chunks)
- throws IOException {
- OutputStream os = null;
-
- try {
- os = igfs.create(file, overwrite);
-
- writeFileChunks(os, chunks);
- }
- finally {
- U.closeQuiet(os);
-
- awaitFileClose(igfs, file);
- }
- }
-
- /**
- * Create the file in the given IGFS and write provided data chunks to it.
- *
- * @param file File.
- * @param chunks Data chunks.
- * @throws IOException In case of IO exception.
- */
- protected static void createFile(IgfsSecondaryFileSystemTestAdapter uni, IgfsPath file, @Nullable byte[]... chunks)
- throws IOException {
- OutputStream os = null;
-
- try {
- os = uni.openOutputStream(file.toString(), false);
-
- writeFileChunks(os, chunks);
- }
- finally {
- U.closeQuiet(os);
-
- IgfsEx igfsEx = uni.igfs();
-
- if (igfsEx != null)
- awaitFileClose(igfsEx, file);
- }
- }
-
- /**
- * Create the file in the given IGFS and write provided data chunks to it.
- *
- * @param igfs IGFS.
- * @param file File.
- * @param overwrite Overwrite flag.
- * @param blockSize Block size.
- * @param chunks Data chunks.
- * @throws Exception If failed.
- */
- protected static void createFile(IgfsImpl igfs, IgfsPath file, boolean overwrite, long blockSize,
- @Nullable byte[]... chunks) throws Exception {
- IgfsOutputStream os = null;
-
- try {
- os = igfs.create(file, 256, overwrite, null, 0, blockSize, null);
-
- writeFileChunks(os, chunks);
- }
- finally {
- U.closeQuiet(os);
-
- awaitFileClose(igfs, file);
- }
- }
-
- /**
- * Append to the file in the given IGFS provided data chunks.
- *
- * @param igfs IGFS.
- * @param file File.
- * @param chunks Data chunks.
- * @throws Exception If failed.
- */
- protected static void appendFile(IgfsImpl igfs, IgfsPath file, @Nullable byte[]... chunks)
- throws Exception {
- IgfsOutputStream os = null;
-
- try {
- os = igfs.append(file, false);
-
- writeFileChunks(os, chunks);
- }
- finally {
- U.closeQuiet(os);
-
- awaitFileClose(igfs, file);
- }
- }
-
- /**
- * Write provided data chunks to the file output stream.
- *
- * @param os Output stream.
- * @param chunks Data chunks.
- * @throws IOException If failed.
- */
- protected static void writeFileChunks(OutputStream os, @Nullable byte[]... chunks) throws IOException {
- if (chunks != null && chunks.length > 0) {
- for (byte[] chunk : chunks)
- os.write(chunk);
- }
- }
-
- /**
- * Await for previously opened output stream to close. This is achieved by requesting dummy update on the file.
- *
- * @param igfs IGFS.
- * @param file File.
- */
- public static void awaitFileClose(IgfsSecondaryFileSystem igfs, IgfsPath file) {
- try {
- igfs.update(file, Collections.singletonMap("prop", "val"));
- }
- catch (IgniteException ignore) {
- // No-op.
- }
- }
-
- /**
- * Await for previously opened output stream to close.
- *
- * @param igfs IGFS.
- * @param file File.
- */
- public static void awaitFileClose(@Nullable IgfsEx igfs, IgfsPath file) {
- igfs.await(file);
- }
-
- /**
- * Ensure that the given paths exist in the given IGFSs.
- *
- * @param igfs First IGFS.
- * @param igfsSecondary Second IGFS.
- * @param paths Paths.
- * @throws Exception If failed.
- */
- protected void checkExist(IgfsImpl igfs, IgfsSecondaryFileSystemTestAdapter igfsSecondary, IgfsPath... paths)
- throws Exception {
- checkExist(igfs, paths);
-
- if (dual)
- checkExist(igfsSecondary, paths);
- }
-
- /**
- * Ensure that the given paths exist in the given IGFS.
- *
- * @param igfs IGFS.
- * @param paths Paths.
- * @throws IgniteCheckedException If failed.
- */
- protected static void checkExist(IgfsImpl igfs, IgfsPath... paths) throws IgniteCheckedException {
- for (IgfsPath path : paths)
- assert igfs.exists(path) : "Path doesn't exist [igfs=" + igfs.name() + ", path=" + path + ']';
- }
-
- /**
- * Ensure that the given paths exist in the given IGFS.
- *
- * @param uni filesystem.
- * @param paths Paths.
- * @throws IgniteCheckedException If failed.
- */
- protected void checkExist(IgfsSecondaryFileSystemTestAdapter uni, IgfsPath... paths) throws IgniteCheckedException {
- IgfsEx ex = uni.igfs();
-
- for (IgfsPath path : paths) {
- if (ex != null)
- assert ex.context().meta().fileId(path) != null : "Path doesn't exist [igfs=" + ex.name() +
- ", path=" + path + ']';
-
- try {
- assert uni.exists(path.toString()) : "Path doesn't exist [igfs=" + uni.name() + ", path=" + path + ']';
- }
- catch (IOException ioe) {
- throw new IgniteCheckedException(ioe);
- }
- }
- }
-
- /**
- * Ensure that the given paths don't exist in the given IGFSs.
- *
- * @param igfs First IGFS.
- * @param igfsSecondary Second IGFS.
- * @param paths Paths.
- * @throws Exception If failed.
- */
- protected void checkNotExist(IgfsImpl igfs, IgfsSecondaryFileSystemTestAdapter igfsSecondary, IgfsPath... paths)
- throws Exception {
- checkNotExist(igfs, paths);
-
- if (dual)
- checkNotExist(igfsSecondary, paths);
- }
-
- /**
- * Ensure that the given paths don't exist in the given IGFS.
- *
- * @param igfs IGFS.
- * @param paths Paths.
- * @throws Exception If failed.
- */
- protected void checkNotExist(IgfsImpl igfs, IgfsPath... paths) throws Exception {
- for (IgfsPath path : paths)
- assert !igfs.exists(path) : "Path exists [igfs=" + igfs.name() + ", path=" + path + ']';
- }
-
- /**
- * Ensure that the given paths don't exist in the given IGFS.
- *
- * @param uni secondary FS.
- * @param paths Paths.
- * @throws Exception If failed.
- */
- protected void checkNotExist(IgfsSecondaryFileSystemTestAdapter uni, IgfsPath... paths) throws Exception {
- IgfsEx ex = uni.igfs();
-
- for (IgfsPath path : paths) {
- if (ex != null)
- assert !ex.exists(path) : "Path exists [igfs=" + ex.name() + ", path=" + path + ']';
-
- assert !uni.exists(path.toString()) : "Path exists [igfs=" + uni.name() + ", path=" + path + ']';
- }
- }
-
- /**
- * Ensure that the given file exists in the given IGFSs and that it has exactly the same content as provided in the
- * "data" parameter.
- *
- * @param igfs First IGFS.
- * @param igfsSecondary Second IGFS.
- * @param file File.
- * @param chunks Expected data.
- * @throws Exception If failed.
- */
- protected void checkFile(@Nullable IgfsImpl igfs, IgfsSecondaryFileSystemTestAdapter igfsSecondary, IgfsPath file,
- @Nullable byte[]... chunks) throws Exception {
- if (igfs != null) {
- checkExist(igfs, file);
- checkFileContent(igfs, file, chunks);
- }
-
- if (dual) {
- checkExist(igfsSecondary, file);
- checkFileContent(igfsSecondary, file.toString(), chunks);
- }
- }
-
- /**
- * Ensure that the given file has exactly the same content as provided in the "data" parameter.
- *
- * @param igfs IGFS.
- * @param file File.
- * @param chunks Expected data.
- * @throws IOException In case of IO exception.
- * @throws IgniteCheckedException In case of Grid exception.
- */
- protected static void checkFileContent(IgfsImpl igfs, IgfsPath file, @Nullable byte[]... chunks)
- throws IOException, IgniteCheckedException {
- if (chunks != null && chunks.length > 0) {
- IgfsInputStream is = null;
-
- try {
- is = igfs.open(file);
-
- int chunkIdx = 0;
- int pos = 0;
-
- for (byte[] chunk : chunks) {
- byte[] buf = new byte[chunk.length];
-
- is.readFully(pos, buf);
-
- assert Arrays.equals(chunk, buf) : "Bad chunk [igfs=" + igfs.name() + ", chunkIdx=" + chunkIdx +
- ", expected=" + Arrays.toString(chunk) + ", actual=" + Arrays.toString(buf) + ']';
-
- chunkIdx++;
- pos += chunk.length;
- }
-
- is.close();
- }
- finally {
- U.closeQuiet(is);
- }
- }
- }
-
- /**
- * Ensure that the given file has exactly the same content as provided in the "data" parameter.
- *
- * @param uni FS.
- * @param path File.
- * @param chunks Expected data.
- * @throws IOException In case of IO exception.
- * @throws IgniteCheckedException In case of Grid exception.
- */
- protected void checkFileContent(IgfsSecondaryFileSystemTestAdapter uni, String path, @Nullable byte[]... chunks)
- throws IOException, IgniteCheckedException {
- if (chunks != null && chunks.length > 0) {
- InputStream is = null;
-
- try {
- is = uni.openInputStream(path);
-
- int chunkIdx = 0;
-
- int read;
- for (byte[] chunk: chunks) {
- byte[] buf = new byte[chunk.length];
-
- read = 0;
-
- while (true) {
- int r = is.read(buf, read, buf.length - read);
-
- read += r;
-
- if (read == buf.length || r <= 0)
- break;
- }
-
- assert read == chunk.length : "Chunk #" + chunkIdx + " was not read fully:" +
- " read=" + read + ", expected=" + chunk.length;
- assert Arrays.equals(chunk, buf) : "Bad chunk [igfs=" + uni.name() + ", chunkIdx=" + chunkIdx +
- ", expected=" + Arrays.toString(chunk) + ", actual=" + Arrays.toString(buf) + ']';
-
- chunkIdx++;
- }
-
- is.close();
- }
- finally {
- U.closeQuiet(is);
- }
- }
- }
-
- /**
- * Create map with properties.
- *
- * @param username User name.
- * @param grpName Group name.
- * @param perm Permission.
- * @return Map with properties.
- */
- protected Map<String, String> properties(@Nullable String username, @Nullable String grpName,
- @Nullable String perm) {
- Map<String, String> props = new HashMap<>();
-
- if (username != null)
- props.put(IgfsUtils.PROP_USER_NAME, username);
-
- if (grpName != null)
- props.put(IgfsUtils.PROP_GROUP_NAME, grpName);
-
- if (perm != null)
- props.put(IgfsUtils.PROP_PERMISSION, perm);
-
- return props;
- }
-
- /**
- * Convenient method to group paths.
- *
- * @param paths Paths to group.
- * @return Paths as array.
- */
- protected static IgfsPath[] paths(IgfsPath... paths) {
- return paths;
- }
-
- /**
- * Safely clear IGFSs.
- *
- * @param igfs First IGFS.
- * @param igfsSecondary Second IGFS.
- * @throws Exception If failed.
- */
- protected void clear(IgniteFileSystem igfs, IgfsSecondaryFileSystemTestAdapter igfsSecondary) throws Exception {
- clear(igfs);
-
- if (dual)
- clear(igfsSecondary);
- }
-
- /**
- * Gets the data cache instance for this IGFS instance.
- *
- * @param igfs The IGFS unstance.
- * @return The data cache.
- */
- protected static GridCacheAdapter<IgfsBlockKey, byte[]> getDataCache(IgniteFileSystem igfs) {
- String dataCacheName = igfs.configuration().getDataCacheName();
-
- IgniteEx igniteEx = ((IgfsEx)igfs).context().kernalContext().grid();
-
- return ((IgniteKernal)igniteEx).internalCache(dataCacheName);
- }
-
- /**
- * Gets meta cache.
- *
- * @param igfs The IGFS instance.
- * @return The data cache.
- */
- protected static GridCacheAdapter<IgniteUuid, IgfsEntryInfo> getMetaCache(IgniteFileSystem igfs) {
- String dataCacheName = igfs.configuration().getMetaCacheName();
-
- IgniteEx igniteEx = ((IgfsEx)igfs).context().kernalContext().grid();
-
- return ((IgniteKernal)igniteEx).internalCache(dataCacheName);
- }
-
- /**
- * Clear particular IGFS.
- *
- * @param igfs IGFS.
- * @throws Exception If failed.
- */
- @SuppressWarnings("unchecked")
- public static void clear(IgniteFileSystem igfs) throws Exception {
- Field workerMapFld = IgfsImpl.class.getDeclaredField("workerMap");
-
- workerMapFld.setAccessible(true);
-
- // Wait for all workers to finish.
- Map<IgfsPath, IgfsFileWorkerBatch> workerMap = (Map<IgfsPath, IgfsFileWorkerBatch>)workerMapFld.get(igfs);
-
- for (Map.Entry<IgfsPath, IgfsFileWorkerBatch> entry : workerMap.entrySet()) {
- entry.getValue().cancel();
-
- try {
- entry.getValue().await();
- }
- catch (IgniteCheckedException e) {
- if (!(e instanceof IgfsFileWorkerBatchCancelledException))
- throw e;
- }
- }
-
- // Clear igfs.
- igfs.format();
-
- int prevDifferentSize = Integer.MAX_VALUE; // Previous different size.
- int constCnt = 0, totalCnt = 0;
- final int constThreshold = 20;
- final long sleepPeriod = 500L;
- final long totalThreshold = CACHE_EMPTY_TIMEOUT / sleepPeriod;
-
- while (true) {
- int metaSize = 0;
-
- for (IgniteUuid metaId : getMetaCache(igfs).keySet()) {
- if (!IgfsUtils.isRootOrTrashId(metaId))
- metaSize++;
- }
-
- int dataSize = getDataCache(igfs).size();
-
- int size = metaSize + dataSize;
-
- if (size <= 2)
- return; // Caches are cleared, we're done. (2 because ROOT & TRASH always exist).
-
- X.println("Sum size: " + size);
-
- if (size > prevDifferentSize) {
- X.println("Summary cache size has grown unexpectedly: size=" + size + ", prevSize=" + prevDifferentSize);
-
- break;
- }
-
- if (totalCnt > totalThreshold) {
- X.println("Timeout exceeded.");
-
- break;
- }
-
- if (size == prevDifferentSize) {
- constCnt++;
-
- if (constCnt == constThreshold) {
- X.println("Summary cache size stays unchanged for too long: size=" + size);
-
- break;
- }
- } else {
- constCnt = 0;
-
- prevDifferentSize = size; // renew;
- }
-
- Thread.sleep(sleepPeriod);
-
- totalCnt++;
- }
-
- dumpCache("MetaCache" , getMetaCache(igfs));
-
- dumpCache("DataCache" , getDataCache(igfs));
-
- fail("Caches are not empty.");
- }
-
- /**
- * Dumps given cache for diagnostic purposes.
- *
- * @param cacheName Name.
- * @param cache The cache.
- */
- private static void dumpCache(String cacheName, GridCacheAdapter<?,?> cache) {
- X.println("=============================== " + cacheName + " cache dump: ");
-
- Iterable<? extends GridCacheEntryEx> entries = cache.entries();
-
- for (GridCacheEntryEx e: entries)
- X.println("Lost " + cacheName + " entry = " + e);
- }
-
- /**
- * Clear particular {@link IgfsSecondaryFileSystemTestAdapter}.
- *
- * @param uni IGFS.
- * @throws Exception If failed.
- */
- @SuppressWarnings("unchecked")
- public static void clear(IgfsSecondaryFileSystemTestAdapter uni) throws Exception {
- IgfsEx igfsEx = uni.igfs();
-
- if (igfsEx != null)
- clear(igfsEx);
-
- // Clear the filesystem.
- uni.format();
- }
-
- /** {@inheritDoc} */
- @Override protected void beforeTest() throws Exception {
- clear(igfs, igfsSecondary);
- }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/b5757642/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsLocalSecondaryFileSystemDualAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsLocalSecondaryFileSystemDualAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsLocalSecondaryFileSystemDualAbstractSelfTest.java
index c2f5633..1d1ce8d 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsLocalSecondaryFileSystemDualAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsLocalSecondaryFileSystemDualAbstractSelfTest.java
@@ -17,12 +17,21 @@
package org.apache.ignite.internal.processors.igfs;
+import org.apache.ignite.igfs.IgfsFile;
import org.apache.ignite.igfs.IgfsMode;
+import org.apache.ignite.igfs.IgfsPath;
import org.apache.ignite.igfs.secondary.IgfsSecondaryFileSystem;
import org.apache.ignite.igfs.secondary.local.LocalIgfsSecondaryFileSystem;
+import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.U;
+import org.jetbrains.annotations.Nullable;
import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.nio.file.Files;
+import java.util.Collection;
/**
* Abstract test for Hadoop 1.0 file system stack.
@@ -32,6 +41,24 @@ public abstract class IgfsLocalSecondaryFileSystemDualAbstractSelfTest extends I
private static final String FS_WORK_DIR = U.getIgniteHome() + File.separatorChar + "work"
+ File.separatorChar + "fs";
+ /** */
+ private static final String FS_EXT_DIR = U.getIgniteHome() + File.separatorChar + "work"
+ + File.separatorChar + "ext";
+
+ /** */
+ private final File dirLinkDest = new File(FS_EXT_DIR + File.separatorChar + "extdir");
+
+ /** */
+ private final File fileLinkDest =
+ new File(FS_EXT_DIR + File.separatorChar + "extdir" + File.separatorChar + "filedest");
+
+ /** */
+ private final File dirLinkSrc = new File(FS_WORK_DIR + File.separatorChar + "dir");
+
+ /** */
+ private final File fileLinkSrc = new File(FS_WORK_DIR + File.separatorChar + "file");
+
+
/** Constructor.
* @param mode IGFS mode.
*/
@@ -39,6 +66,19 @@ public abstract class IgfsLocalSecondaryFileSystemDualAbstractSelfTest extends I
super(mode);
}
+ /** {@inheritDoc} */
+ @Override protected void beforeTest() throws Exception {
+ super.beforeTest();
+
+ final File extDir = new File(FS_EXT_DIR);
+
+ if (!extDir.exists())
+ assert extDir.mkdirs();
+ else
+ cleanDirectory(extDir);
+ }
+
+
/**
* Creates secondary filesystems.
* @return IgfsSecondaryFileSystem
@@ -73,4 +113,107 @@ public abstract class IgfsLocalSecondaryFileSystemDualAbstractSelfTest extends I
@Override protected boolean timesSupported() {
return false;
}
+
+ /**
+ *
+ * @throws Exception If failed.
+ */
+ @SuppressWarnings("ConstantConditions")
+ public void testListPathForSymlink() throws Exception {
+ if (U.isWindows())
+ return;
+
+ createSymlinks();
+
+ assertTrue(igfs.info(DIR).isDirectory());
+
+ Collection<IgfsPath> pathes = igfs.listPaths(DIR);
+ Collection<IgfsFile> files = igfs.listFiles(DIR);
+
+ assertEquals(1, pathes.size());
+ assertEquals(1, files.size());
+
+ assertEquals("filedest", F.first(pathes).name());
+ assertEquals("filedest", F.first(files).path().name());
+ }
+
+ /**
+ *
+ * @throws Exception If failed.
+ */
+ public void testDeleteSymlinkDir() throws Exception {
+ if (U.isWindows())
+ return;
+
+ createSymlinks();
+
+ // Only symlink must be deleted. Destination content must be exist.
+ igfs.delete(DIR, true);
+
+ assertTrue(fileLinkDest.exists());
+ }
+
+ /**
+ *
+ * @throws Exception If failed.
+ */
+ public void testSymlinkToFile() throws Exception {
+ if (U.isWindows())
+ return;
+
+ createSymlinks();
+
+ checkFileContent(igfs, new IgfsPath("/file"), chunk);
+ }
+
+ /**
+ *
+ * @throws Exception If failed.
+ */
+ private void createSymlinks() throws Exception {
+ assert dirLinkDest.mkdir();
+
+ createFile(fileLinkDest, true, chunk);
+
+ Files.createSymbolicLink(dirLinkSrc.toPath(), dirLinkDest.toPath());
+ Files.createSymbolicLink(fileLinkSrc.toPath(), fileLinkDest.toPath());
+ }
+
+ /**
+ * @param dir Directory to clean.
+ */
+ private static void cleanDirectory(File dir){
+ File[] entries = dir.listFiles();
+
+ if (entries != null) {
+ for (File entry : entries) {
+ if (entry.isDirectory()) {
+ cleanDirectory(entry);
+
+ assert entry.delete();
+ }
+ else
+ assert entry.delete();
+ }
+ }
+ }
+
+ /**
+ * @param f File object.
+ * @param overwrite Overwrite flag.
+ * @param chunks File content.
+ * @throws IOException If failed.
+ */
+ private static void createFile(File f, boolean overwrite, @Nullable byte[]... chunks) throws IOException {
+ OutputStream os = null;
+
+ try {
+ os = new FileOutputStream(f, overwrite);
+
+ writeFileChunks(os, chunks);
+ }
+ finally {
+ U.closeQuiet(os);
+ }
+ }
}
\ No newline at end of file
[46/50] [abbrv] ignite git commit: IGNITE-3687: Updated StormStreamer
dependencies. - Fixes #959.
Posted by sb...@apache.org.
IGNITE-3687: Updated StormStreamer dependencies. - Fixes #959.
Signed-off-by: shtykh_roman <rs...@yahoo.com>
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/b640b8ed
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/b640b8ed
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/b640b8ed
Branch: refs/heads/ignite-961
Commit: b640b8ed7f9ce0fdf24392404eedbc1f54c9063c
Parents: 857a1ea
Author: shtykh_roman <rs...@yahoo.com>
Authored: Mon Sep 5 17:43:06 2016 +0900
Committer: shtykh_roman <rs...@yahoo.com>
Committed: Mon Sep 5 17:43:06 2016 +0900
----------------------------------------------------------------------
modules/storm/pom.xml | 2 +-
.../ignite/stream/storm/StormStreamer.java | 10 +++++-----
.../storm/StormIgniteStreamerSelfTest.java | 20 ++++++++++----------
.../ignite/stream/storm/TestStormSpout.java | 10 +++++-----
4 files changed, 21 insertions(+), 21 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/b640b8ed/modules/storm/pom.xml
----------------------------------------------------------------------
diff --git a/modules/storm/pom.xml b/modules/storm/pom.xml
index 17d92cd..19165be 100644
--- a/modules/storm/pom.xml
+++ b/modules/storm/pom.xml
@@ -35,7 +35,7 @@
<url>http://ignite.apache.org</url>
<properties>
- <storm.version>0.10.0</storm.version>
+ <storm.version>1.0.2</storm.version>
</properties>
<dependencies>
http://git-wip-us.apache.org/repos/asf/ignite/blob/b640b8ed/modules/storm/src/main/java/org/apache/ignite/stream/storm/StormStreamer.java
----------------------------------------------------------------------
diff --git a/modules/storm/src/main/java/org/apache/ignite/stream/storm/StormStreamer.java b/modules/storm/src/main/java/org/apache/ignite/stream/storm/StormStreamer.java
index bdaec0b..1cba8ad 100644
--- a/modules/storm/src/main/java/org/apache/ignite/stream/storm/StormStreamer.java
+++ b/modules/storm/src/main/java/org/apache/ignite/stream/storm/StormStreamer.java
@@ -17,11 +17,6 @@
package org.apache.ignite.stream.storm;
-import backtype.storm.task.OutputCollector;
-import backtype.storm.task.TopologyContext;
-import backtype.storm.topology.IRichBolt;
-import backtype.storm.topology.OutputFieldsDeclarer;
-import backtype.storm.tuple.Tuple;
import java.util.Map;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteDataStreamer;
@@ -30,6 +25,11 @@ import org.apache.ignite.IgniteLogger;
import org.apache.ignite.Ignition;
import org.apache.ignite.internal.util.typedef.internal.A;
import org.apache.ignite.stream.StreamAdapter;
+import org.apache.storm.task.OutputCollector;
+import org.apache.storm.task.TopologyContext;
+import org.apache.storm.topology.IRichBolt;
+import org.apache.storm.topology.OutputFieldsDeclarer;
+import org.apache.storm.tuple.Tuple;
/**
* Apache Storm streamer implemented as a Storm bolt.
http://git-wip-us.apache.org/repos/asf/ignite/blob/b640b8ed/modules/storm/src/test/java/org/apache/ignite/stream/storm/StormIgniteStreamerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/storm/src/test/java/org/apache/ignite/stream/storm/StormIgniteStreamerSelfTest.java b/modules/storm/src/test/java/org/apache/ignite/stream/storm/StormIgniteStreamerSelfTest.java
index 0ce4c6e..e2547b1 100644
--- a/modules/storm/src/test/java/org/apache/ignite/stream/storm/StormIgniteStreamerSelfTest.java
+++ b/modules/storm/src/test/java/org/apache/ignite/stream/storm/StormIgniteStreamerSelfTest.java
@@ -17,16 +17,6 @@
package org.apache.ignite.stream.storm;
-import backtype.storm.Config;
-import backtype.storm.ILocalCluster;
-import backtype.storm.Testing;
-import backtype.storm.generated.StormTopology;
-import backtype.storm.testing.CompleteTopologyParam;
-import backtype.storm.testing.MkClusterParam;
-import backtype.storm.testing.MockedSources;
-import backtype.storm.testing.TestJob;
-import backtype.storm.topology.TopologyBuilder;
-import backtype.storm.tuple.Values;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Map;
@@ -41,6 +31,16 @@ import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.events.CacheEvent;
import org.apache.ignite.lang.IgniteBiPredicate;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.apache.storm.Config;
+import org.apache.storm.ILocalCluster;
+import org.apache.storm.Testing;
+import org.apache.storm.generated.StormTopology;
+import org.apache.storm.testing.CompleteTopologyParam;
+import org.apache.storm.testing.MkClusterParam;
+import org.apache.storm.testing.MockedSources;
+import org.apache.storm.testing.TestJob;
+import org.apache.storm.topology.TopologyBuilder;
+import org.apache.storm.tuple.Values;
import org.jetbrains.annotations.NotNull;
import static org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_PUT;
http://git-wip-us.apache.org/repos/asf/ignite/blob/b640b8ed/modules/storm/src/test/java/org/apache/ignite/stream/storm/TestStormSpout.java
----------------------------------------------------------------------
diff --git a/modules/storm/src/test/java/org/apache/ignite/stream/storm/TestStormSpout.java b/modules/storm/src/test/java/org/apache/ignite/stream/storm/TestStormSpout.java
index a006ca7..117b44b 100644
--- a/modules/storm/src/test/java/org/apache/ignite/stream/storm/TestStormSpout.java
+++ b/modules/storm/src/test/java/org/apache/ignite/stream/storm/TestStormSpout.java
@@ -17,13 +17,13 @@
package org.apache.ignite.stream.storm;
-import backtype.storm.spout.SpoutOutputCollector;
-import backtype.storm.task.TopologyContext;
-import backtype.storm.topology.IRichSpout;
-import backtype.storm.topology.OutputFieldsDeclarer;
-import backtype.storm.tuple.Fields;
import java.util.Map;
import java.util.TreeMap;
+import org.apache.storm.spout.SpoutOutputCollector;
+import org.apache.storm.task.TopologyContext;
+import org.apache.storm.topology.IRichSpout;
+import org.apache.storm.topology.OutputFieldsDeclarer;
+import org.apache.storm.tuple.Fields;
/**
* Testing Storm spout.