You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ak...@apache.org on 2017/02/13 10:31:58 UTC
[01/31] ignite git commit: IGNITE-4142: Fixed assertion while update
metrics. This closes #1372.
Repository: ignite
Updated Branches:
refs/heads/ignite-4436-2 1848faeef -> ce374cd9e
IGNITE-4142: Fixed assertion while update metrics. This closes #1372.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/626f1d56
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/626f1d56
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/626f1d56
Branch: refs/heads/ignite-4436-2
Commit: 626f1d5614930bca0ab744a6049e5f83f321d46a
Parents: 6c38eb2
Author: Andrey V. Mashenkov <an...@gmail.com>
Authored: Fri Dec 23 12:18:07 2016 +0300
Committer: Andrey V. Mashenkov <an...@gmail.com>
Committed: Mon Jan 9 12:36:41 2017 +0300
----------------------------------------------------------------------
.../main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java | 2 +-
.../main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/626f1d56/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 8928f28..0f5f741 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
@@ -1920,7 +1920,7 @@ class ClientImpl extends TcpDiscoveryImpl {
TcpDiscoveryHeartbeatMessage.MetricsSet metricsSet = e.getValue();
- Map<Integer, CacheMetrics> cacheMetrics = msg.hasCacheMetrics() ?
+ Map<Integer, CacheMetrics> cacheMetrics = msg.hasCacheMetrics(nodeId) ?
msg.cacheMetrics().get(nodeId) : Collections.<Integer, CacheMetrics>emptyMap();
updateMetrics(nodeId, metricsSet.metrics(), cacheMetrics, tstamp);
http://git-wip-us.apache.org/repos/asf/ignite/blob/626f1d56/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
index 204b685..c791333 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
@@ -4927,7 +4927,7 @@ class ServerImpl extends TcpDiscoveryImpl {
TcpDiscoveryHeartbeatMessage.MetricsSet metricsSet = e.getValue();
- Map<Integer, CacheMetrics> cacheMetrics = msg.hasCacheMetrics() ?
+ Map<Integer, CacheMetrics> cacheMetrics = msg.hasCacheMetrics(nodeId) ?
msg.cacheMetrics().get(nodeId) : Collections.<Integer, CacheMetrics>emptyMap();
updateMetrics(nodeId, metricsSet.metrics(), cacheMetrics, tstamp);
[29/31] ignite git commit: IGNITE-4425 .NET: Support
"ICollection.Contains" in LINQ
Posted by ak...@apache.org.
IGNITE-4425 .NET: Support "ICollection.Contains" in LINQ
This closes #1502
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/d949b739
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/d949b739
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/d949b739
Branch: refs/heads/ignite-4436-2
Commit: d949b739d1fc47a13dcbf8fe107276bc603b6d92
Parents: 2f4bdbb
Author: Sergey Stronchinskiy <gu...@gmail.com>
Authored: Fri Feb 10 15:38:01 2017 +0300
Committer: Pavel Tupitsyn <pt...@apache.org>
Committed: Fri Feb 10 15:38:52 2017 +0300
----------------------------------------------------------------------
.../Cache/Query/CacheLinqTest.cs | 96 ++++++++++++++
.../Impl/CacheQueryExpressionVisitor.cs | 127 ++++++++++++++++++-
.../Impl/CacheQueryModelVisitor.cs | 3 +
3 files changed, 224 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/d949b739/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 798e7e8..931fdd4 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,6 +28,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
{
using System;
using System.Collections;
+ using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text.RegularExpressions;
@@ -106,6 +107,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
orgCache[1000] = new Organization {Id = 1000, Name = "Org_0"};
orgCache[1001] = new Organization {Id = 1001, Name = "Org_1"};
+ orgCache[1002] = new Organization {Id = 1002, Name = null};
var roleCache = GetRoleCache();
@@ -747,6 +749,74 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
}
/// <summary>
+ /// Tests IEnumerable.Contains.
+ /// </summary>
+ [Test]
+ public void TestContains()
+ {
+ var cache = GetPersonCache().AsCacheQueryable();
+ var orgCache = GetOrgCache().AsCacheQueryable();
+
+ var keys = new[] { 1, 2, 3 };
+ var emptyKeys = new int[0];
+
+ var bigNumberOfKeys = 10000;
+ var aLotOfKeys = Enumerable.Range(-bigNumberOfKeys + 10 - PersonCount, bigNumberOfKeys + PersonCount)
+ .ToArray();
+ var hashSetKeys = new HashSet<int>(keys);
+
+ CheckWhereFunc(cache, e => new[] { 1, 2, 3 }.Contains(e.Key));
+ CheckWhereFunc(cache, e => emptyKeys.Contains(e.Key));
+ CheckWhereFunc(cache, e => new int[0].Contains(e.Key));
+ CheckWhereFunc(cache, e => new int[0].Contains(e.Key));
+ CheckWhereFunc(cache, e => new List<int> { 1, 2, 3 }.Contains(e.Key));
+ CheckWhereFunc(cache, e => new List<int>(keys).Contains(e.Key));
+ CheckWhereFunc(cache, e => aLotOfKeys.Contains(e.Key));
+ CheckWhereFunc(cache, e => hashSetKeys.Contains(e.Key));
+ CheckWhereFunc(cache, e => !keys.Contains(e.Key));
+ CheckWhereFunc(orgCache, e => new[] { "Org_1", "NonExistentName", null }.Contains(e.Value.Name));
+ CheckWhereFunc(orgCache, e => !new[] { "Org_1", "NonExistentName", null }.Contains(e.Value.Name));
+ CheckWhereFunc(orgCache, e => new[] { "Org_1", null, null }.Contains(e.Value.Name));
+ CheckWhereFunc(orgCache, e => !new[] { "Org_1", null, null }.Contains(e.Value.Name));
+ CheckWhereFunc(orgCache, e => new string[] { null }.Contains(e.Value.Name));
+ CheckWhereFunc(orgCache, e => !new string[] { null }.Contains(e.Value.Name));
+ CheckWhereFunc(orgCache, e => !new string[] { null, null }.Contains(e.Value.Name));
+ CheckWhereFunc(orgCache, e => new string[] { null, null }.Contains(e.Value.Name));
+
+ //check passing a null object as collection
+ int[] nullKeys = null;
+ var nullKeysEntries = cache
+ .Where(e => nullKeys.Contains(e.Key))
+ .ToArray();
+ Assert.AreEqual(0, nullKeysEntries.Length, "Evaluating 'null.Contains' should return zero results");
+
+
+ Func<int[]> getKeysFunc = () => null;
+ var funcNullKeyEntries = cache
+ .Where(e => getKeysFunc().Contains(e.Key))
+ .ToArray();
+ Assert.AreEqual(0, funcNullKeyEntries.Length, "Evaluating 'null.Contains' should return zero results");
+
+
+ // Check subselect from other cache
+ var subSelectCount = cache
+ .Count(entry => orgCache
+ .Where(orgEntry => orgEntry.Value.Name == "Org_1")
+ .Select(orgEntry => orgEntry.Key)
+ .Contains(entry.Value.OrganizationId));
+ var orgNumberOne = orgCache
+ .Where(orgEntry => orgEntry.Value.Name == "Org_1")
+ .Select(orgEntry => orgEntry.Key)
+ .First();
+ var subSelectCheckCount = cache.Count(entry => entry.Value.OrganizationId == orgNumberOne);
+ Assert.AreEqual(subSelectCheckCount, subSelectCount, "subselecting another CacheQueryable failed");
+
+ var ex = Assert.Throws<NotSupportedException>(() =>
+ CompiledQuery2.Compile((int[] k) => cache.Where(x => k.Contains(x.Key))));
+ Assert.AreEqual("'Contains' clause coming from compiled query parameter is not supported.", ex.Message);
+ }
+
+ /// <summary>
/// Tests nulls.
/// </summary>
[Test]
@@ -1412,6 +1482,32 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
CollectionAssert.AreEqual(expected, actual, new NumericComparer());
}
+ /// <summary>
+ /// Checks that function used in Where Clause maps to SQL function properly
+ /// </summary>
+ private static void CheckWhereFunc<TKey, TEntry>(IQueryable<ICacheEntry<TKey,TEntry>> query, Expression<Func<ICacheEntry<TKey, TEntry>,bool>> whereExpression)
+ {
+ // Calculate result locally, using real method invocation
+ var expected = query
+ .ToArray()
+ .AsQueryable()
+ .Where(whereExpression)
+ .Select(entry => entry.Key)
+ .OrderBy(x => x)
+ .ToArray();
+
+ // Perform SQL query
+ var actual = query
+ .Where(whereExpression)
+ .Select(entry => entry.Key)
+ .ToArray()
+ .OrderBy(x => x)
+ .ToArray();
+
+ // Compare results
+ CollectionAssert.AreEqual(expected, actual, new NumericComparer());
+ }
+
public interface IPerson
{
int Age { get; set; }
http://git-wip-us.apache.org/repos/asf/ignite/blob/d949b739/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheQueryExpressionVisitor.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheQueryExpressionVisitor.cs b/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheQueryExpressionVisitor.cs
index 1f9da1c..94e59fa 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheQueryExpressionVisitor.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheQueryExpressionVisitor.cs
@@ -20,6 +20,7 @@ using System.Text;
namespace Apache.Ignite.Linq.Impl
{
+ using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
@@ -29,6 +30,7 @@ namespace Apache.Ignite.Linq.Impl
using Apache.Ignite.Core.Cache;
using Apache.Ignite.Core.Cache.Configuration;
using Apache.Ignite.Core.Impl.Common;
+ using Remotion.Linq;
using Remotion.Linq.Clauses;
using Remotion.Linq.Clauses.Expressions;
using Remotion.Linq.Clauses.ResultOperators;
@@ -470,15 +472,136 @@ namespace Apache.Ignite.Linq.Impl
}
/** <inheritdoc /> */
+
[SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods")]
protected override Expression VisitSubQuery(SubQueryExpression expression)
{
- // This happens when New expression uses a subquery, in a GroupBy.
- _modelVisitor.VisitSelectors(expression.QueryModel, false);
+ var subQueryModel = expression.QueryModel;
+
+ var contains = subQueryModel.ResultOperators.FirstOrDefault() as ContainsResultOperator;
+
+ // Check if IEnumerable.Contains is used.
+ if (subQueryModel.ResultOperators.Count == 1 && contains != null)
+ {
+ VisitContains(subQueryModel, contains);
+ }
+ else
+ {
+ // This happens when New expression uses a subquery, in a GroupBy.
+ _modelVisitor.VisitSelectors(expression.QueryModel, false);
+ }
return expression;
}
+ /// <summary>
+ /// Visits IEnumerable.Contains
+ /// </summary>
+ private void VisitContains(QueryModel subQueryModel, ContainsResultOperator contains)
+ {
+ ResultBuilder.Append("(");
+
+ var fromExpression = subQueryModel.MainFromClause.FromExpression;
+
+ var queryable = ExpressionWalker.GetCacheQueryable(fromExpression, false);
+
+ if (queryable != null)
+ {
+ Visit(contains.Item);
+
+ ResultBuilder.Append(" IN (");
+ _modelVisitor.VisitQueryModel(subQueryModel);
+ ResultBuilder.Append(")");
+ }
+ else
+ {
+ var inValues = GetInValues(fromExpression).ToArray();
+
+ var hasNulls = inValues.Any(o => o == null);
+
+ if (hasNulls)
+ {
+ ResultBuilder.Append("(");
+ }
+
+ Visit(contains.Item);
+
+ ResultBuilder.Append(" IN (");
+ AppendInParameters(inValues);
+ ResultBuilder.Append(")");
+
+ if (hasNulls)
+ {
+ ResultBuilder.Append(") OR ");
+ Visit(contains.Item);
+ ResultBuilder.Append(" IS NULL");
+ }
+ }
+
+ ResultBuilder.Append(")");
+ }
+
+ /// <summary>
+ /// Gets values for IN expression.
+ /// </summary>
+ private static IEnumerable<object> GetInValues(Expression fromExpression)
+ {
+ IEnumerable result;
+ switch (fromExpression.NodeType)
+ {
+ case ExpressionType.MemberAccess:
+ var memberExpression = (MemberExpression) fromExpression;
+ result = ExpressionWalker.EvaluateExpression<IEnumerable>(memberExpression);
+ break;
+ case ExpressionType.ListInit:
+ var listInitExpression = (ListInitExpression) fromExpression;
+ result = listInitExpression.Initializers
+ .SelectMany(init => init.Arguments)
+ .Select(ExpressionWalker.EvaluateExpression<object>);
+ break;
+ case ExpressionType.NewArrayInit:
+ var newArrayExpression = (NewArrayExpression) fromExpression;
+ result = newArrayExpression.Expressions
+ .Select(ExpressionWalker.EvaluateExpression<object>);
+ break;
+ case ExpressionType.Parameter:
+ // This should happen only when 'IEnumerable.Contains' is called on parameter of compiled query
+ throw new NotSupportedException("'Contains' clause coming from compiled query parameter is not supported.");
+ default:
+ result = Expression.Lambda(fromExpression).Compile().DynamicInvoke() as IEnumerable;
+ break;
+ }
+
+ result = result ?? Enumerable.Empty<object>();
+
+ return result
+ .Cast<object>()
+ .ToArray();
+ }
+
+ /// <summary>
+ /// Appends not null parameters using ", " as delimeter.
+ /// </summary>
+ private void AppendInParameters(IEnumerable<object> values)
+ {
+ var first = true;
+
+ foreach (var val in values)
+ {
+ if (val == null)
+ continue;
+
+ if (!first)
+ {
+ ResultBuilder.Append(", ");
+ }
+
+ first = false;
+
+ AppendParameter(val);
+ }
+ }
+
/** <inheritdoc /> */
protected override Exception CreateUnhandledItemException<T>(T unhandledItem, string visitMethod)
{
http://git-wip-us.apache.org/repos/asf/ignite/blob/d949b739/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheQueryModelVisitor.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheQueryModelVisitor.cs b/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheQueryModelVisitor.cs
index ae94cfb..7cc9265 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheQueryModelVisitor.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Linq/Impl/CacheQueryModelVisitor.cs
@@ -184,6 +184,9 @@ namespace Apache.Ignite.Linq.Impl
|| op is DefaultIfEmptyResultOperator || op is SkipResultOperator || op is TakeResultOperator)
// Will be processed later
break;
+ else if (op is ContainsResultOperator)
+ // Should be processed already
+ break;
else
throw new NotSupportedException("Operator is not supported: " + op);
}
[17/31] ignite git commit: Minor fix test for Ignite-4247.
Posted by ak...@apache.org.
Minor fix test for Ignite-4247.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/ecf4b8b5
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/ecf4b8b5
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/ecf4b8b5
Branch: refs/heads/ignite-4436-2
Commit: ecf4b8b5bd05a5c1120e08d9951cddd26d0e924c
Parents: 2305e38
Author: Andrey V. Mashenkov <an...@gmail.com>
Authored: Wed Jan 18 17:22:14 2017 +0300
Committer: Andrey V. Mashenkov <an...@gmail.com>
Committed: Wed Jan 18 17:22:14 2017 +0300
----------------------------------------------------------------------
.../processors/cache/IgniteCacheAbstractQuerySelfTest.java | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/ecf4b8b5/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java
index 9f56877..7e0d20b 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java
@@ -633,7 +633,7 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
assertEquals(2, qry.getAll().size());
- GridTestUtils.assertThrows(log, new GridPlainCallable<Void>() {
+ Throwable throwable = GridTestUtils.assertThrowsInherited(log, new GridPlainCallable<Void>() {
@Override public Void call() throws Exception {
QueryCursor<Cache.Entry<Integer, Type1>> qry =
cache.query(new SqlQuery<Integer, Type1>(Type1.class, "FROM Type1"));
@@ -642,7 +642,11 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
return null;
}
- }, CacheException.class, null);
+ }, RuntimeException.class, null);
+
+ assertNotNull(throwable);
+
+ assertTrue(throwable instanceof IgniteException || throwable instanceof CacheException);
}
/**
[13/31] ignite git commit: IGNITE-3867: Fixed ScanQuery ignores
pageSize property. This closes #1406.
Posted by ak...@apache.org.
IGNITE-3867: Fixed ScanQuery ignores pageSize property. This closes #1406.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/d0c0bcec
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/d0c0bcec
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/d0c0bcec
Branch: refs/heads/ignite-4436-2
Commit: d0c0bcece7d8e9d373aaf13a210f6d890e5ad48b
Parents: a922ac9
Author: Andrey V. Mashenkov <an...@gmail.com>
Authored: Tue Jan 17 16:19:02 2017 +0300
Committer: Andrey V. Mashenkov <an...@gmail.com>
Committed: Tue Jan 17 16:19:02 2017 +0300
----------------------------------------------------------------------
.../processors/cache/IgniteCacheProxy.java | 3 +
.../IgniteCachePartitionedQuerySelfTest.java | 87 ++++++++++++++++++++
2 files changed, 90 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/d0c0bcec/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 b9737c6..873c822 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
@@ -491,6 +491,9 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
qry = ctx.queries().createScanQuery(p, transformer, scanQry.getPartition(), isKeepBinary);
+ if (scanQry.getPageSize() > 0)
+ qry.pageSize(scanQry.getPageSize());
+
if (grp != null)
qry.projection(grp);
http://git-wip-us.apache.org/repos/asf/ignite/blob/d0c0bcec/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCachePartitionedQuerySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCachePartitionedQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCachePartitionedQuerySelfTest.java
index 78fd914..b9f21da 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCachePartitionedQuerySelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCachePartitionedQuerySelfTest.java
@@ -20,15 +20,28 @@ package org.apache.ignite.internal.processors.cache.distributed.near;
import java.util.Collection;
import java.util.List;
import java.util.UUID;
+import java.util.concurrent.atomic.AtomicInteger;
import javax.cache.Cache;
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.cache.query.QueryCursor;
+import org.apache.ignite.cache.query.ScanQuery;
import org.apache.ignite.cache.query.SqlFieldsQuery;
import org.apache.ignite.cache.query.SqlQuery;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.managers.communication.GridIoMessage;
import org.apache.ignite.internal.processors.cache.IgniteCacheAbstractQuerySelfTest;
+import org.apache.ignite.internal.processors.cache.query.GridCacheQueryRequest;
+import org.apache.ignite.internal.processors.cache.query.GridCacheQueryResponse;
import org.apache.ignite.internal.util.typedef.F;
+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.CommunicationSpi;
+import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
import static org.apache.ignite.cache.CacheMode.PARTITIONED;
import static org.apache.ignite.cache.CachePeekMode.ALL;
@@ -47,6 +60,11 @@ public class IgniteCachePartitionedQuerySelfTest extends IgniteCacheAbstractQuer
return PARTITIONED;
}
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ return super.getConfiguration(gridName).setCommunicationSpi(new TestTcpCommunicationSpi());
+ }
+
/**
* @throws Exception If failed.
*/
@@ -135,4 +153,73 @@ public class IgniteCachePartitionedQuerySelfTest extends IgniteCacheAbstractQuer
assert F.asList(persons).contains(entry.getValue());
}
}
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testScanQueryPagination() throws Exception {
+ final int pageSize = 5;
+
+ final AtomicInteger pages = new AtomicInteger(0);
+
+ IgniteCache<Integer, Integer> cache = ignite().cache(null);
+
+ for (int i = 0; i < 50; i++)
+ cache.put(i, i);
+
+ CommunicationSpi spi = ignite().configuration().getCommunicationSpi();
+
+ assert spi instanceof TestTcpCommunicationSpi;
+
+ TestTcpCommunicationSpi commSpi = (TestTcpCommunicationSpi)spi;
+
+ commSpi.filter = new IgniteInClosure<Message>() {
+ @Override public void apply(Message msg) {
+ if (!(msg instanceof GridIoMessage))
+ return;
+
+ Message msg0 = ((GridIoMessage)msg).message();
+
+ if (msg0 instanceof GridCacheQueryRequest) {
+ assertEquals(pageSize, ((GridCacheQueryRequest)msg0).pageSize());
+
+ pages.incrementAndGet();
+ }
+ else if (msg0 instanceof GridCacheQueryResponse) {
+ assertTrue(((GridCacheQueryResponse)msg0).data().size() <= pageSize);
+ }
+ }
+ };
+
+ try {
+ ScanQuery<Integer, Integer> qry = new ScanQuery<Integer, Integer>();
+
+ qry.setPageSize(pageSize);
+
+ List<Cache.Entry<Integer, Integer>> all = cache.query(qry).getAll();
+
+ assertTrue(pages.get() > ignite().cluster().forDataNodes(null).nodes().size());
+
+ assertEquals(50, all.size());
+ }
+ finally {
+ commSpi.filter = null;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class TestTcpCommunicationSpi extends TcpCommunicationSpi {
+ volatile IgniteInClosure<Message> filter;
+
+ /** {@inheritDoc} */
+ @Override public void sendMessage(ClusterNode node, Message msg, IgniteInClosure<IgniteException> ackClosure)
+ throws IgniteSpiException {
+ if(filter != null)
+ filter.apply(msg);
+
+ super.sendMessage(node, msg, ackClosure);
+ }
+ }
}
\ No newline at end of file
[30/31] ignite git commit: Merge branches 'ignite-4436-2' and
'master' of https://git-wip-us.apache.org/repos/asf/ignite into ignite-4436-2
Posted by ak...@apache.org.
Merge branches 'ignite-4436-2' and 'master' of https://git-wip-us.apache.org/repos/asf/ignite into ignite-4436-2
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/58cf839e
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/58cf839e
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/58cf839e
Branch: refs/heads/ignite-4436-2
Commit: 58cf839e842125c51e1075515a06e278f80cc09a
Parents: 1848fae d949b73
Author: Alexey Kuznetsov <ak...@apache.org>
Authored: Mon Feb 13 15:23:22 2017 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Mon Feb 13 15:23:22 2017 +0700
----------------------------------------------------------------------
.../apache/ignite/IgniteSystemProperties.java | 3 +
.../org/apache/ignite/cache/QueryEntity.java | 21 +
.../org/apache/ignite/cache/query/SqlQuery.java | 25 +
.../internal/GridEventConsumeHandler.java | 5 +
.../internal/GridMessageListenHandler.java | 5 +
.../processors/cache/EntryGetResult.java | 65 +++
.../processors/cache/GridCacheAdapter.java | 125 +++--
.../processors/cache/GridCacheContext.java | 4 +-
.../processors/cache/GridCacheEntryEx.java | 42 +-
.../processors/cache/GridCacheMapEntry.java | 140 +++++-
.../processors/cache/GridCacheUtils.java | 3 +
.../processors/cache/IgniteCacheProxy.java | 3 +
.../processors/cache/ReaderArguments.java | 74 +++
.../distributed/dht/GridDhtCacheAdapter.java | 9 +-
.../cache/distributed/dht/GridDhtGetFuture.java | 83 ++--
.../distributed/dht/GridDhtGetSingleFuture.java | 75 ++-
.../dht/GridPartitionedGetFuture.java | 10 +-
.../dht/GridPartitionedSingleGetFuture.java | 10 +-
.../dht/atomic/GridDhtAtomicCache.java | 12 +-
.../dht/colocated/GridDhtColocatedCache.java | 10 +-
.../distributed/near/GridNearGetFuture.java | 19 +-
.../local/atomic/GridLocalAtomicCache.java | 11 +-
.../cache/query/GridCacheQueryManager.java | 83 +++-
.../continuous/CacheContinuousQueryHandler.java | 97 +++-
.../cache/transactions/IgniteTxHandler.java | 2 +-
.../transactions/IgniteTxLocalAdapter.java | 65 +--
.../continuous/GridContinuousHandler.java | 5 +
.../continuous/GridContinuousProcessor.java | 3 +
.../processors/query/GridQueryIndexing.java | 4 +-
.../processors/query/GridQueryProcessor.java | 79 ++-
.../query/GridQueryTypeDescriptor.java | 7 +
.../communication/tcp/TcpCommunicationSpi.java | 16 +
.../ignite/spi/discovery/tcp/ClientImpl.java | 90 +++-
.../ignite/spi/discovery/tcp/ServerImpl.java | 63 ++-
.../messages/TcpDiscoveryAbstractMessage.java | 21 +
modules/core/src/test/config/log4j-test.xml | 6 +
.../cache/CacheConcurrentReadThroughTest.java | 184 +++++++
.../processors/cache/GridCacheTestEntryEx.java | 30 +-
.../near/GridNearCacheStoreUpdateTest.java | 466 ++++++++++++++++++
.../GridNearOffheapCacheStoreUpdateTest.java | 35 ++
.../cache/query/IndexingSpiQuerySelfTest.java | 69 ++-
.../IndexingSpiQueryWithH2IndexingSelfTest.java | 36 ++
.../ClientReconnectContinuousQueryTest.java | 201 ++++++++
.../tcp/TcpCommunicationSpiDropNodesTest.java | 322 +++++++++++++
.../TcpCommunicationSpiFaultyClientTest.java | 265 +++++++++++
.../ignite/testframework/GridTestNode.java | 1 +
.../testframework/junits/GridAbstractTest.java | 2 +
.../testsuites/IgniteCacheTestSuite2.java | 7 +
.../IgniteSpiCommunicationSelfTestSuite.java | 5 +
.../IgniteSpiDiscoverySelfTestSuite.java | 2 +-
.../processors/query/h2/IgniteH2Indexing.java | 30 +-
...CacheScanPartitionQueryFallbackSelfTest.java | 2 +-
.../cache/IgniteCacheAbstractQuerySelfTest.java | 294 ++++++++++++
.../IgniteCachePartitionedQuerySelfTest.java | 85 ++++
.../h2/GridIndexingSpiAbstractSelfTest.java | 29 +-
.../IgniteCacheQuerySelfTestSuite3.java | 2 +
.../Cache/Query/CacheLinqTest.cs | 96 ++++
.../Cache/Store/CacheStoreTest.cs | 30 +-
.../Impl/CacheQueryExpressionVisitor.cs | 127 ++++-
.../Impl/CacheQueryModelVisitor.cs | 3 +
modules/web-console/backend/app/agent.js | 34 ++
modules/web-console/backend/app/browser.js | 26 +
modules/web-console/frontend/package.json | 2 +-
.../ignite/console/demo/AgentClusterDemo.java | 475 +------------------
.../ignite/console/demo/AgentDemoUtils.java | 79 +++
.../demo/service/DemoCachesLoadService.java | 456 ++++++++++++++++++
.../service/DemoRandomCacheLoadService.java | 120 +++++
.../service/DemoServiceClusterSingleton.java | 41 ++
.../demo/service/DemoServiceKeyAffinity.java | 41 ++
.../service/DemoServiceMultipleInstances.java | 41 ++
.../demo/service/DemoServiceNodeSingleton.java | 41 ++
modules/yardstick/DEVNOTES-standalone.txt | 15 +
modules/yardstick/DEVNOTES.txt | 20 +-
modules/yardstick/README.txt | 119 +++--
.../config/benchmark-sample.properties | 62 +++
modules/yardstick/pom.xml | 4 +-
pom.xml | 1 +
77 files changed, 4277 insertions(+), 918 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/58cf839e/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryIndexing.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/58cf839e/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/58cf839e/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/58cf839e/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexingSpiAbstractSelfTest.java
----------------------------------------------------------------------
[23/31] ignite git commit: IGNITE-4212 Ignite Benchmarking
Simplification and Automation / IGNITE-4478 Fixing documentation and
resolving lack of usability
Posted by ak...@apache.org.
IGNITE-4212 Ignite Benchmarking Simplification and Automation / IGNITE-4478 Fixing documentation and resolving lack of usability
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/605d946a
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/605d946a
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/605d946a
Branch: refs/heads/ignite-4436-2
Commit: 605d946ada5ca4e562e256fa0edb29cc25dea7dc
Parents: e1c3dda
Author: oleg-ostanin <oo...@gridgain.com>
Authored: Thu Feb 9 20:08:57 2017 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Thu Feb 9 20:08:57 2017 +0300
----------------------------------------------------------------------
modules/yardstick/DEVNOTES-standalone.txt | 15 +++
modules/yardstick/DEVNOTES.txt | 20 ++--
modules/yardstick/README.txt | 119 +++++++++++++------
.../config/benchmark-sample.properties | 62 ++++++++++
modules/yardstick/pom.xml | 4 +-
pom.xml | 1 +
6 files changed, 172 insertions(+), 49 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/605d946a/modules/yardstick/DEVNOTES-standalone.txt
----------------------------------------------------------------------
diff --git a/modules/yardstick/DEVNOTES-standalone.txt b/modules/yardstick/DEVNOTES-standalone.txt
new file mode 100644
index 0000000..d14dde2
--- /dev/null
+++ b/modules/yardstick/DEVNOTES-standalone.txt
@@ -0,0 +1,15 @@
+Building from standalone sources
+================================
+
+Run
+
+mvn clean package
+
+Artifacts can be found in `/target/assembly directory.`
+
+
+Writing Ignite Benchmarks
+=========================
+
+All benchmarks extend `AbstractBenchmark` class. A new benchmark should also extend this abstract class
+and implement `test` method. This is the method which actually tests performance.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/605d946a/modules/yardstick/DEVNOTES.txt
----------------------------------------------------------------------
diff --git a/modules/yardstick/DEVNOTES.txt b/modules/yardstick/DEVNOTES.txt
index 6921243..b8b1f53 100644
--- a/modules/yardstick/DEVNOTES.txt
+++ b/modules/yardstick/DEVNOTES.txt
@@ -1,16 +1,20 @@
-Yardstick Ignite Maven Build Instructions
+Building from Ignite sources
=========================================
-Yardstick can be build from standalone sources using following maven command:
+Run
-mvn clean package
+mvn clean package -Pyardstick -pl modules/yardstick -am -DskipTests
-Artifacts can be found in /target/assembly directory.
+in the Apache Ignite root directory.
-To build yardstick from Apache Ignite sources use:
+This command will compile the project and also unpack scripts from `yardstick-resources.zip` file to
+`modules/yardstick/target/assembly/bin` directory.
-mvn clean package -Pyardstick -pl modules/yardstick -am -DskipTests
+Artifacts can be found in `modules/yardstick/target/assembly` directory.
+
+Writing Ignite Benchmarks
+=========================
-in Apache Ignite root directory
+All benchmarks extend `AbstractBenchmark` class. A new benchmark should also extend this abstract class
+and implement `test` method. This is the method which actually tests performance.
-Artifacts can be found in modules/yardstick/target/assembly directory.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/605d946a/modules/yardstick/README.txt
----------------------------------------------------------------------
diff --git a/modules/yardstick/README.txt b/modules/yardstick/README.txt
index 353ddd8..dcfe0e6 100644
--- a/modules/yardstick/README.txt
+++ b/modules/yardstick/README.txt
@@ -1,55 +1,92 @@
Yardstick Ignite Benchmarks
===========================
-Yardstick Ignite is a set of Ignite Grid (http://ignite.apache.org/) benchmarks written on top of Yardstick framework.
+Apache Ignite benchmarks are written on top of Yardstick Framework (https://github.com/gridgain/yardstick) and allow
+you to measure performance of various Apache Ignite components and modules.
-Yardstick Framework
-===================
-Visit Yardstick Repository (https://github.com/gridgain/yardstick) for detailed information on how to run Yardstick benchmarks and how to generate graphs.
+The documentation below describes how to execute and configure already assembled benchmarks. If you need to add new
+benchmarks or build existing one then refer to instruction from `DEVNOTES.txt` in source directory.
-The documentation below describes configuration parameters in addition to standard Yardstick parameters.
+Visit Yardstick Repository (https://github.com/gridgain/yardstick) for detailed information in regards resulting graphs
+generation and how the frameworks works.
-Building from Ignite sources
-============
-1. Create a local clone of Ignite repository
-2. Run
-mvn package
+Running Ignite Benchmarks Locally
+==========================================
-command for Yardstick Ignite POM
+The simplest way to start with benchmarking is to use one of the executable scripts available under `benchmarks\bin` directory:
-Building from standalone sources
-=====================
-Run
+./bin/benchmark-run-all.sh config/benchmark-atomic-put.properties
-mvn package
+The command above will benchmark the cache put operation for a distributed atomic cache. The results of the benchmark will be added
+to auto-generated `results-{DATE-TIME}` directory.
-command for Yardstick Ignite POM
+If `./bin/benchmark-run-all.sh` command is executed as is without any parameters and modifications in configurations files then
+all the available benchmarks will be executed on a local machine using `config/benchmark.properties` configuration.
-Provided Benchmarks
-===================
-The following benchmarks are provided:
+To get more information about available benchmarks and configuration parameters refer to \u201cProvided Benchmarks\u201d and
+\u201cProperties And Command Line Arguments\u201d sections below.
+
+
+Running Ignite Benchmarks Remotely
+=========================================
+
+For running Ignite benchmarks on remote hosts you need to upload Ignite-Yardstick to each one of your remote hosts.
+
+NOTE: The path to the uploaded Ignite-Yardstick should be exactly the same on each host.
+
+Then you need to make some changes in config files:
-1. `GetBenchmark` - benchmarks atomic distributed cache get operation
-2. `PutBenchmark` - benchmarks atomic distributed cache put operation
-3. `PutGetBenchmark` - benchmarks atomic distributed cache put and get operations together
-4. `PutTxBenchmark` - benchmarks transactional distributed cache put operation
-5. `PutGetTxBenchmark` - benchmarks transactional distributed cache put and get operations together
-6. `SqlQueryBenchmark` - benchmarks distributed SQL query over cached data
-7. `SqlQueryJoinBenchmark` - benchmarks distributed SQL query with a Join over cached data
-8. `SqlQueryPutBenchmark` - benchmarks distributed SQL query with simultaneous cache updates
+1. You need to comment or delete the
+ <property name="localHost" value="127.0.0.1"/>
+line in `config/ignite-localhost-config.xml` file.
-Writing Ignite Benchmarks
-=========================
-All benchmarks extend `AbstractBenchmark` class. A new benchmark should also extend this abstract class
-and implement `test` method. This is the method that is actually benchmarked.
+2. You need to replace all the `127.0.0.1` addresses in `ignite-localhost-config.xml` file by actual IPs of your remote
+servers. You can add or delete lines with IP addresses if you want to run benchmarks on different number of hosts.
+There must be at least one IP address in the list.
-Running Ignite Benchmarks
-=========================
-Before running Ignite benchmarks, run:
+3. You need to replace the `localhost` strings by actual IP of your servers in the lines
+SERVERS='localhost,localhost'
+DRIVERS='localhost'
+in `config/benchmark-atomic-put.properties` file.
+
+Then use the following command:
+
+./bin/benchmark-run-all.sh config/benchmark-atomic-put.properties
+
+
+It is recommended to create some copies of original config files, edit these copies and then use as a
+parameter for `./bin/benchmark-run-all.sh` script.
+
+
+Provided Benchmarks
+===================
+The following benchmarks are provided:
-mvn package
+1. `GetBenchmark` - benchmarks atomic distributed cache get operation
+2. `PutBenchmark` - benchmarks atomic distributed cache put operation
+3. `PutGetBenchmark` - benchmarks atomic distributed cache put and get operations together
+4. `PutTxBenchmark` - benchmarks transactional distributed cache put operation
+5. `PutGetTxBenchmark` - benchmarks transactional distributed cache put and get operations together
+6. `SqlQueryBenchmark` - benchmarks distributed SQL query over cached data
+7. `SqlQueryJoinBenchmark` - benchmarks distributed SQL query with a Join over cached data
+8. `SqlQueryPutBenchmark` - benchmarks distributed SQL query with simultaneous cache updates
+9. `AffinityCallBenchmark` - benchmarks affinity call operation
+10. `ApplyBenchmark` - benchmarks apply operation
+11. `BroadcastBenchmark` - benchmarks broadcast operations
+12. `ExecuteBenchmark` - benchmarks execute operations
+13. `RunBenchmark` - benchmarks running task operations
+14. `PutGetOffHeapBenchmark` - benchmarks atomic distributed cache put and get operations together off heap
+15. `PutGetOffHeapValuesBenchmark` - benchmarks atomic distributed cache put value operations off heap
+16. `PutOffHeapBenchmark` - benchmarks atomic distributed cache put operations off heap
+17. `PutOffHeapValuesBenchmark` - benchmarks atomic distributed cache get value operations off heap
+18. `PutTxOffHeapBenchmark` - benchmarks transactional distributed cache put operation off heap
+19. `PutTxOffHeapValuesBenchmark` - benchmarks transactional distributed cache put value operation off heap
+20. `SqlQueryOffHeapBenchmark` -benchmarks distributed SQL query over cached data off heap
+21. `SqlQueryJoinOffHeapBenchmark` - benchmarks distributed SQL query with a Join over cached data off heap
+22. `SqlQueryPutOffHeapBenchmark` - benchmarks distributed SQL query with simultaneous cache updates off heap
+23. `PutAllBenchmark` - benchmarks atomic distributed cache batch put operation
+24. `PutAllTxBenchmark` - benchmarks transactional distributed cache batch put operation
-command. This command will compile the project and also will unpack scripts from `yardstick-resources.zip` file to `bin` directory.
Properties And Command Line Arguments
=====================================
@@ -67,15 +104,19 @@ The following Ignite benchmark properties can be defined in the benchmark config
* `-cs` or `--cacheStore` - Enable or disable cache store readThrough, writeThrough
* `-cl` or `--client` - Client flag
* `-nc` or `--nearCache` - Near cache flag
-* `-nn <num>` or `--nodeNumber <num>` - Number of nodes (automatically set in `benchmark.properties`), used to wait for the specified number of nodes to start
+* `-nn <num>` or `--nodeNumber <num>` - Number of nodes (automatically set in `benchmark.properties`), used to wait for
+ the specified number of nodes to start
* `-sm <mode>` or `-syncMode <mode>` - Synchronization mode (defined in `CacheWriteSynchronizationMode`)
* `-ot` or `--offheapTiered` - Flag indicating whether tiered off-heap mode is on
* `-ov` or `--offheapValuesOnly` - Flag indicating whether off-heap mode is on and only cache values are stored off-heap
* `-r <num>` or `--range` - Range of keys that are randomly generated for cache operations
+* `-rd or --restartdelay` - Restart delay in seconds
+* `-rs or --restartsleep` - Restart sleep in seconds
* `-rth <host>` or `--restHost <host>` - REST TCP host
* `-rtp <num>` or `--restPort <num>` - REST TCP port, indicates that a Ignite node is ready to process Ignite Clients
* `-ss` or `--syncSend` - Flag indicating whether synchronous send is used in `TcpCommunicationSpi`
-* `-txc <value>` or `--txConcurrency <value>` - Cache transaction concurrency control, either `OPTIMISTIC` or `PESSIMISTIC` (defined in `CacheTxConcurrency`)
+* `-txc <value>` or `--txConcurrency <value>` - Cache transaction concurrency control, either `OPTIMISTIC` or
+ `PESSIMISTIC` (defined in `CacheTxConcurrency`)
* `-txi <value>` or `--txIsolation <value>` - Cache transaction isolation (defined in `CacheTxIsolation`)
* `-wb` or `--writeBehind` - Enable or disable writeBehind for cache store
* `-wom <mode>` or `--writeOrderMode <mode>` - Write order mode for ATOMIC caches (defined in `CacheAtomicWriteOrderMode`)
@@ -91,7 +132,7 @@ SERVER_HOSTS=localhost,localhost
Note that -dn and -sn, which stand for data node and server node, are native Yardstick parameters and are documented in Yardstick framework.
===========================================================================================================================================
-CONFIGS="-b 1 -sm PRIMARY_SYNC -dn PutBenchmark -sn IgniteNode"
+CONFIGS="-b 1 -sm PRIMARY_SYNC -dn PutBenchmark`IgniteNode"
```
Issues
http://git-wip-us.apache.org/repos/asf/ignite/blob/605d946a/modules/yardstick/config/benchmark-sample.properties
----------------------------------------------------------------------
diff --git a/modules/yardstick/config/benchmark-sample.properties b/modules/yardstick/config/benchmark-sample.properties
new file mode 100644
index 0000000..fee7cbb
--- /dev/null
+++ b/modules/yardstick/config/benchmark-sample.properties
@@ -0,0 +1,62 @@
+# 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.
+
+#
+# Contains benchmarks for ATOMIC cache.
+#
+
+# JVM options.
+JVM_OPTS=${JVM_OPTS}" -DIGNITE_QUIET=false"
+
+# Uncomment to enable concurrent garbage collection (GC) if you encounter long GC pauses.
+# JVM_OPTS=${JVM_OPTS}" \
+# -XX:+UseParNewGC \
+# -XX:+UseConcMarkSweepGC \
+# -XX:+UseTLAB \
+# -XX:NewSize=128m \
+# -XX:MaxNewSize=128m \
+# -XX:MaxTenuringThreshold=0 \
+# -XX:SurvivorRatio=1024 \
+# -XX:+UseCMSInitiatingOccupancyOnly \
+# -XX:CMSInitiatingOccupancyFraction=60 \
+#"
+
+# List of default probes.
+# Add DStatProbe or VmStatProbe if your OS supports it (e.g. if running on Linux).
+BENCHMARK_DEFAULT_PROBES=ThroughputLatencyProbe,PercentileProbe
+
+# Packages where the specified benchmark is searched by reflection mechanism.
+BENCHMARK_PACKAGES=org.yardstickframework,org.apache.ignite.yardstick
+
+# Probe point writer class name.
+# BENCHMARK_WRITER=
+
+# Comma-separated list of the hosts to run BenchmarkServers on. 2 nodes on local host are enabled by default.
+SERVER_HOSTS=localhost,localhost
+
+# Comma-separated list of the hosts to run BenchmarkDrivers on. 1 node on local host is enabled by default.
+DRIVER_HOSTS=localhost
+
+# Remote username.
+# REMOTE_USER=
+
+# Number of nodes, used to wait for the specified number of nodes to start.
+nodesNum=$((`echo ${SERVER_HOSTS} | tr ',' '\n' | wc -l` + `echo ${DRIVER_HOSTS} | tr ',' '\n' | wc -l`))
+
+# Run configuration.
+# Note that each benchmark is set to run for 300 seconds (5 mins) with warm-up set to 60 seconds (1 minute).
+CONFIGS="\
+-cfg ${SCRIPT_DIR}/../config/ignite-localhost-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -dn IgnitePutBenchmark -sn IgniteNode -ds atomic-put-1-backup,\
+"
http://git-wip-us.apache.org/repos/asf/ignite/blob/605d946a/modules/yardstick/pom.xml
----------------------------------------------------------------------
diff --git a/modules/yardstick/pom.xml b/modules/yardstick/pom.xml
index 4c4d138..d96fcc6 100644
--- a/modules/yardstick/pom.xml
+++ b/modules/yardstick/pom.xml
@@ -35,7 +35,7 @@
<url>http://ignite.apache.org</url>
<properties>
- <yardstick.version>0.8.0</yardstick.version>
+ <yardstick.version>0.8.2</yardstick.version>
<spring.version>4.1.0.RELEASE</spring.version>
</properties>
@@ -56,7 +56,7 @@
<groupId>org.apache.ignite</groupId>
<artifactId>ignite-indexing</artifactId>
<version>${project.version}</version>
- </dependency>
+ </dependency>
<dependency>
<groupId>org.apache.ignite</groupId>
http://git-wip-us.apache.org/repos/asf/ignite/blob/605d946a/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 790cd4b..ea76053 100644
--- a/pom.xml
+++ b/pom.xml
@@ -506,6 +506,7 @@
<fileset dir="${basedir}/target/release-package/benchmarks/config/">
<include name="*.*" />
<exclude name="benchmark.properties"/>
+ <exclude name="benchmark-sample.properties"/>
<exclude name="benchmark-multicast.properties"/>
<exclude name="ignite-base-config.xml"/>
<exclude name="ignite-localhost-config.xml"/>
[19/31] ignite git commit: ignite-4314 cache.clear should not destroy
offheap map
Posted by ak...@apache.org.
ignite-4314 cache.clear should not destroy offheap map
(cherry picked from commit 88c06ec)
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/d396398c
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/d396398c
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/d396398c
Branch: refs/heads/ignite-4436-2
Commit: d396398c1b4660b3bca24d2650a10f6c0677b4df
Parents: f9aaf03
Author: sboikov <sb...@gridgain.com>
Authored: Fri Dec 2 10:36:41 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Thu Jan 19 10:41:10 2017 +0300
----------------------------------------------------------------------
.../cache/GridCacheClearAllRunnable.java | 58 +++++++++-----------
.../processors/cache/GridCacheSwapManager.java | 8 ---
.../cache/transactions/IgniteTxHandler.java | 2 +-
3 files changed, 26 insertions(+), 42 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/d396398c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheClearAllRunnable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheClearAllRunnable.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheClearAllRunnable.java
index 4f97e7b..9e7f329 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheClearAllRunnable.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheClearAllRunnable.java
@@ -87,48 +87,40 @@ public class GridCacheClearAllRunnable<K, V> implements Runnable {
// Clear swapped entries.
if (!ctx.isNear()) {
if (ctx.swap().offHeapEnabled()) {
- if (GridQueryProcessor.isEnabled(ctx.config())) {
- for (Iterator<KeyCacheObject> it =
- ctx.swap().offHeapKeyIterator(true, true, AffinityTopologyVersion.NONE); it.hasNext();) {
- KeyCacheObject key = it.next();
-
- if (owns(key))
- clearEntry(cache.entryEx(key));
+ for (Iterator<KeyCacheObject> it = ctx.swap().offHeapKeyIterator(true, true, AffinityTopologyVersion.NONE); it.hasNext();) {
+ KeyCacheObject key = it.next();
- }
+ if (owns(key))
+ clearEntry(cache.entryEx(key));
}
- else if (id == 0)
- ctx.swap().clearOffHeap();
}
- if (ctx.isSwapOrOffheapEnabled()) {
- if (ctx.swap().swapEnabled()) {
- if (GridQueryProcessor.isEnabled(ctx.config())) {
- Iterator<KeyCacheObject> it = null;
+ if (ctx.swap().swapEnabled()) {
+ if (GridQueryProcessor.isEnabled(ctx.config())) {
+ Iterator<KeyCacheObject> it = null;
- try {
- it = ctx.swap().swapKeyIterator(true, true, AffinityTopologyVersion.NONE);
- }
- catch (IgniteCheckedException e) {
- U.error(log, "Failed to get iterator over swap.", e);
- }
+ try {
+ it = ctx.swap().swapKeyIterator(true, true, AffinityTopologyVersion.NONE);
+ }
+ catch (IgniteCheckedException e) {
+ U.error(log, "Failed to get iterator over swap.", e);
+ }
- if (it != null) {
- while (it.hasNext()) {
- KeyCacheObject key = it.next();
+ if (it != null) {
+ while (it.hasNext()) {
+ KeyCacheObject key = it.next();
- if (owns(key))
- clearEntry(cache.entryEx(key));
- }
+ if (owns(key))
+ clearEntry(cache.entryEx(key));
}
}
- else if (id == 0) {
- try {
- ctx.swap().clearSwap();
- }
- catch (IgniteCheckedException e) {
- U.error(log, "Failed to clearLocally entries from swap storage.", e);
- }
+ }
+ else if (id == 0) {
+ try {
+ ctx.swap().clearSwap();
+ }
+ catch (IgniteCheckedException e) {
+ U.error(log, "Failed to clearLocally entries from swap storage.", e);
}
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d396398c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java
index fd0b471..d4499b3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java
@@ -1416,14 +1416,6 @@ public class GridCacheSwapManager extends GridCacheManagerAdapter {
}
/**
- * Clears off-heap.
- */
- public void clearOffHeap() {
- if (offheapEnabled)
- initOffHeap();
- }
-
- /**
* Clears swap.
*
* @throws IgniteCheckedException If failed.
http://git-wip-us.apache.org/repos/asf/ignite/blob/d396398c/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 f784ba2..d564156 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
@@ -1507,7 +1507,7 @@ public class IgniteTxHandler {
if (log.isDebugEnabled())
log.debug("Got entry removed exception, will retry: " + entry.txKey());
- entry.cached(null);
+ entry.cached(cacheCtx.cache().entryEx(entry.key(), req.topologyVersion()));
}
}
}
[27/31] ignite git commit: .NET: Extract exceptions tests in
CacheStoreTest and ignore due to IGNITE-4657
Posted by ak...@apache.org.
.NET: Extract exceptions tests in CacheStoreTest and ignore due to IGNITE-4657
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/543a65fb
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/543a65fb
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/543a65fb
Branch: refs/heads/ignite-4436-2
Commit: 543a65fbac20a6961f8d23baaeb6ff8c6c61f20d
Parents: a600caf
Author: Pavel Tupitsyn <pt...@apache.org>
Authored: Mon Feb 6 18:07:28 2017 +0300
Committer: Pavel Tupitsyn <pt...@apache.org>
Committed: Fri Feb 10 12:45:07 2017 +0300
----------------------------------------------------------------------
.../Cache/Store/CacheStoreTest.cs | 30 ++++++++++++++++++--
1 file changed, 28 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/543a65fb/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs
index 869336c..a66aea8 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs
@@ -208,12 +208,38 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
Assert.AreEqual("val", cache.Get(1));
Assert.AreEqual(1, cache.GetSize());
+ }
+
+ [Test]
+ public void TestExceptions()
+ {
+ var cache = GetCache();
+
+ cache.Put(1, "val");
- // Test errors
CacheTestStore.ThrowError = true;
CheckCustomStoreError(Assert.Throws<CacheStoreException>(() => cache.Put(-2, "fail")).InnerException);
- cache.LocalEvict(new[] { 1 });
+ cache.LocalEvict(new[] {1});
+ CheckCustomStoreError(Assert.Throws<CacheStoreException>(() => cache.Get(1)).InnerException);
+
+ CacheTestStore.ThrowError = false;
+
+ cache.Remove(1);
+ }
+
+ [Test]
+ [Ignore("IGNITE-4657")]
+ public void TestExceptionsNoRemove()
+ {
+ var cache = GetCache();
+
+ cache.Put(1, "val");
+
+ CacheTestStore.ThrowError = true;
+ CheckCustomStoreError(Assert.Throws<CacheStoreException>(() => cache.Put(-2, "fail")).InnerException);
+
+ cache.LocalEvict(new[] {1});
CheckCustomStoreError(Assert.Throws<CacheStoreException>(() => cache.Get(1)).InnerException);
}
[02/31] ignite git commit: ignite-4293 Do not need store deserialized
value for BinaryMarshaller
Posted by ak...@apache.org.
ignite-4293 Do not need store deserialized value for BinaryMarshaller
(cherry picked from commit d10946b)
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/55f7594f
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/55f7594f
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/55f7594f
Branch: refs/heads/ignite-4436-2
Commit: 55f7594fd0595a4269c3972446ba4ebe30c12442
Parents: 626f1d5
Author: Alexandr Kuramshin <ak...@gridgain.com>
Authored: Fri Jan 13 12:26:39 2017 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Mon Jan 16 11:28:09 2017 +0300
----------------------------------------------------------------------
.../processors/cacheobject/IgniteCacheObjectProcessorImpl.java | 5 ++---
.../java/org/apache/ignite/cache/store/jdbc/model/Person.java | 2 +-
.../processors/cache/CacheEntryProcessorCopySelfTest.java | 6 ++++--
.../processors/cache/GridCacheBasicStoreAbstractTest.java | 2 +-
.../distributed/dht/GridCacheDhtEvictionsDisabledSelfTest.java | 5 +----
5 files changed, 9 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/55f7594f/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
index 208ec62..614c612 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
@@ -244,9 +244,8 @@ public class IgniteCacheObjectProcessorImpl extends GridProcessorAdapter impleme
CacheMemoryMode memMode = ccfg.getMemoryMode();
- boolean storeVal = ctx.config().isPeerClassLoadingEnabled() ||
- GridQueryProcessor.isEnabled(ccfg) ||
- !ccfg.isCopyOnRead();
+ boolean storeVal = !ccfg.isCopyOnRead() || (!isBinaryEnabled(ccfg) &&
+ (GridQueryProcessor.isEnabled(ccfg) || ctx.config().isPeerClassLoadingEnabled()));
CacheObjectContext res = new CacheObjectContext(ctx,
ccfg.getName(),
http://git-wip-us.apache.org/repos/asf/ignite/blob/55f7594f/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/model/Person.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/model/Person.java b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/model/Person.java
index ddf309b..52ddfc8 100644
--- a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/model/Person.java
+++ b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/model/Person.java
@@ -196,7 +196,7 @@ public class Person implements Serializable {
@Override public String toString() {
return "Person [id=" + id +
", orgId=" + orgId +
- ", birthday=" + birthday.getTime() +
+ ", birthday=" + (birthday == null ? null : birthday.getTime()) +
", name=" + name +
"]";
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/55f7594f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheEntryProcessorCopySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheEntryProcessorCopySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheEntryProcessorCopySelfTest.java
index 21395e6..f44889b 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheEntryProcessorCopySelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheEntryProcessorCopySelfTest.java
@@ -30,6 +30,7 @@ import org.apache.ignite.cache.CacheAtomicityMode;
import org.apache.ignite.cache.CacheEntryProcessor;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.binary.BinaryMarshaller;
import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
@@ -93,8 +94,9 @@ public class CacheEntryProcessorCopySelfTest extends GridCommonAbstractTest {
doTest(true, false, OLD_VAL, 1);
// One deserialization due to copyOnRead == true.
- // Additional deserialization in case p2p enabled due to storeValue == true on update entry.
- doTest(true, true, NEW_VAL, p2pEnabled ? 2 : 1);
+ // Additional deserialization in case p2p enabled and not BinaryMarshaller due to storeValue == true on update entry.
+ doTest(true, true, NEW_VAL, p2pEnabled &&
+ !(grid.configuration().getMarshaller() instanceof BinaryMarshaller) ? 2 : 1);
// No deserialization.
doTest(false, false, NEW_VAL, 0);
http://git-wip-us.apache.org/repos/asf/ignite/blob/55f7594f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheBasicStoreAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheBasicStoreAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheBasicStoreAbstractTest.java
index 8ddd737..026b618 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheBasicStoreAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheBasicStoreAbstractTest.java
@@ -571,7 +571,7 @@ public abstract class GridCacheBasicStoreAbstractTest extends GridCommonAbstract
assert cached != null;
- assert cached == val : "Cached value mismatch [expected=" + val + ", cached=" + cached + ']';
+ assert cached.equals(val) : "Cached value mismatch [expected=" + val + ", cached=" + cached + ']';
// Make sure that value is coming from cache, not from store.
checkLastMethod(null);
http://git-wip-us.apache.org/repos/asf/ignite/blob/55f7594f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtEvictionsDisabledSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtEvictionsDisabledSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtEvictionsDisabledSelfTest.java
index 3f3f84f..e8a6cfb 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtEvictionsDisabledSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtEvictionsDisabledSelfTest.java
@@ -117,10 +117,7 @@ public class GridCacheDhtEvictionsDisabledSelfTest extends GridCommonAbstractTes
assertNotNull(v1);
assertNotNull(v2);
- if (affinity(cache).mapKeyToNode(key).isLocal())
- assertSame(v1, v2);
- else
- assertEquals(v1, v2);
+ assertEquals(v1, v2);
}
}
}
\ No newline at end of file
[21/31] ignite git commit: ignite-4147 - Rollback due to test failing
on many restarts, should be improved to be more durable
Posted by ak...@apache.org.
ignite-4147 - Rollback due to test failing on many restarts, should be improved to be more durable
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/9c9175d4
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/9c9175d4
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/9c9175d4
Branch: refs/heads/ignite-4436-2
Commit: 9c9175d4a84194a224a4020e6185d1e2aee0a5aa
Parents: 51e1f87
Author: dkarachentsev <dk...@gridgain.com>
Authored: Thu Jan 19 11:19:18 2017 +0300
Committer: dkarachentsev <dk...@gridgain.com>
Committed: Thu Jan 19 11:19:18 2017 +0300
----------------------------------------------------------------------
.../ignite/spi/discovery/tcp/ClientImpl.java | 20 +----
.../ignite/spi/discovery/tcp/ServerImpl.java | 9 --
.../TcpDiscoverySslSecuredUnsecuredTest.java | 93 --------------------
.../IgniteSpiDiscoverySelfTestSuite.java | 2 -
4 files changed, 1 insertion(+), 123 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/9c9175d4/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 35f0908..39c539c 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
@@ -20,7 +20,6 @@ package org.apache.ignite.spi.discovery.tcp;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.io.StreamCorruptedException;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.SocketTimeoutException;
@@ -45,7 +44,6 @@ import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.atomic.AtomicReference;
-import javax.net.ssl.SSLException;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteClientDisconnectedException;
import org.apache.ignite.IgniteException;
@@ -664,14 +662,6 @@ class ClientImpl extends TcpDiscoveryImpl {
errs.add(e);
- if (X.hasCause(e, SSLException.class))
- throw new IgniteSpiException("Unable to establish secure connection. " +
- "Was remote cluster configured with SSL? [rmtAddr=" + addr + ", errMsg=\"" + e.getMessage() + "\"]", e);
-
- if (X.hasCause(e, StreamCorruptedException.class))
- throw new IgniteSpiException("Unable to establish plain connection. " +
- "Was remote cluster configured with SSL? [rmtAddr=" + addr + ", errMsg=\"" + e.getMessage() + "\"]", e);
-
if (timeoutHelper.checkFailureTimeoutReached(e))
break;
@@ -1603,15 +1593,7 @@ class ClientImpl extends TcpDiscoveryImpl {
joinCnt++;
- T2<SocketStream, Boolean> joinRes;
- try {
- joinRes = joinTopology(false, spi.joinTimeout);
- }
- catch (IgniteSpiException e) {
- joinError(e);
-
- return;
- }
+ T2<SocketStream, Boolean> joinRes = joinTopology(false, spi.joinTimeout);
if (joinRes == null) {
if (join)
http://git-wip-us.apache.org/repos/asf/ignite/blob/9c9175d4/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
index f33566c..d462ac2 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
@@ -24,7 +24,6 @@ import java.io.InputStream;
import java.io.ObjectStreamException;
import java.io.OutputStream;
import java.io.Serializable;
-import java.io.StreamCorruptedException;
import java.net.ConnectException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
@@ -1221,14 +1220,6 @@ class ServerImpl extends TcpDiscoveryImpl {
errs.add(e);
- if (X.hasCause(e, SSLException.class))
- throw new IgniteException("Unable to establish secure connection. " +
- "Was remote cluster configured with SSL? [rmtAddr=" + addr + ", errMsg=\"" + e.getMessage() + "\"]", e);
-
- if (X.hasCause(e, StreamCorruptedException.class))
- throw new IgniteException("Unable to establish plain connection. " +
- "Was remote cluster configured with SSL? [rmtAddr=" + addr + ", errMsg=\"" + e.getMessage() + "\"]", e);
-
if (timeoutHelper.checkFailureTimeoutReached(e))
break;
http://git-wip-us.apache.org/repos/asf/ignite/blob/9c9175d4/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySslSecuredUnsecuredTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySslSecuredUnsecuredTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySslSecuredUnsecuredTest.java
deleted file mode 100644
index 2296165..0000000
--- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySslSecuredUnsecuredTest.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.spi.discovery.tcp;
-
-import java.util.concurrent.Callable;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.testframework.GridTestUtils;
-import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-
-/**
- * Tests cases when node connects to cluster with different SSL configuration.
- * Exception with meaningful message should be thrown.
- */
-public class TcpDiscoverySslSecuredUnsecuredTest extends GridCommonAbstractTest {
- /** {@inheritDoc} */
- @Override protected IgniteConfiguration getConfiguration(final String gridName) throws Exception {
- final IgniteConfiguration cfg = super.getConfiguration(gridName);
-
- cfg.setClientMode(gridName.contains("client"));
-
- if (gridName.contains("ssl"))
- cfg.setSslContextFactory(GridTestUtils.sslFactory());
-
- return cfg;
- }
-
- /** {@inheritDoc} */
- @Override protected void afterTest() throws Exception {
- stopAllGrids();
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testSecuredUnsecuredServerConnection() throws Exception {
- checkConnection("plain-server", "ssl-server");
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testUnsecuredSecuredServerConnection() throws Exception {
- checkConnection("ssl-server", "plain-server");
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testSecuredClientUnsecuredServerConnection() throws Exception {
- checkConnection("plain-server", "ssl-client");
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testUnsecuredClientSecuredServerConnection() throws Exception {
- checkConnection("ssl-server", "plain-client");
- }
-
- /**
- * @param name1 First grid name.
- * @param name2 Second grid name.
- * @throws Exception If failed.
- */
- @SuppressWarnings("ThrowableNotThrown")
- private void checkConnection(final String name1, final String name2) throws Exception {
- startGrid(name1);
-
- GridTestUtils.assertThrows(null, new Callable<Object>() {
- @Override public Object call() throws Exception {
- startGrid(name2);
-
- return null;
- }
- }, IgniteCheckedException.class, null);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9c9175d4/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiDiscoverySelfTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiDiscoverySelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiDiscoverySelfTestSuite.java
index 98bf6da..5f870a4 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiDiscoverySelfTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiDiscoverySelfTestSuite.java
@@ -34,7 +34,6 @@ import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpiConfigSelfTest;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpiFailureTimeoutSelfTest;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpiSelfTest;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpiStartStopSelfTest;
-import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySslSecuredUnsecuredTest;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySslSelfTest;
import org.apache.ignite.spi.discovery.tcp.ipfinder.jdbc.TcpDiscoveryJdbcIpFinderSelfTest;
import org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinderSelfTest;
@@ -87,7 +86,6 @@ public class IgniteSpiDiscoverySelfTestSuite extends TestSuite {
// SSL.
suite.addTest(new TestSuite(TcpDiscoverySslSelfTest.class));
- suite.addTest(new TestSuite(TcpDiscoverySslSecuredUnsecuredTest.class));
return suite;
}
[14/31] ignite git commit: ignite-4525 - Near reader is created when
value is loaded from store.
Posted by ak...@apache.org.
ignite-4525 - Near reader is created when value is loaded from store.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/b54a4813
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/b54a4813
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/b54a4813
Branch: refs/heads/ignite-4436-2
Commit: b54a481315a45c7a6c8f70534f655e14b25cc439
Parents: d0c0bce
Author: dkarachentsev <dk...@gridgain.com>
Authored: Wed Jan 18 12:05:22 2017 +0300
Committer: dkarachentsev <dk...@gridgain.com>
Committed: Wed Jan 18 12:05:22 2017 +0300
----------------------------------------------------------------------
.../processors/cache/GridCacheAdapter.java | 33 +-
.../processors/cache/GridCacheContext.java | 4 +-
.../processors/cache/GridCacheEntryEx.java | 20 +-
.../processors/cache/GridCacheMapEntry.java | 56 ++-
.../processors/cache/ReaderArguments.java | 74 +++
.../distributed/dht/GridDhtCacheAdapter.java | 9 +-
.../cache/distributed/dht/GridDhtGetFuture.java | 85 ++--
.../distributed/dht/GridDhtGetSingleFuture.java | 75 ++-
.../dht/GridPartitionedGetFuture.java | 3 +-
.../dht/GridPartitionedSingleGetFuture.java | 3 +-
.../dht/atomic/GridDhtAtomicCache.java | 5 +-
.../dht/colocated/GridDhtColocatedCache.java | 3 +-
.../distributed/near/GridNearGetFuture.java | 6 +-
.../local/atomic/GridLocalAtomicCache.java | 5 +-
.../transactions/IgniteTxLocalAdapter.java | 35 +-
.../processors/cache/GridCacheTestEntryEx.java | 11 +-
.../near/GridNearCacheStoreUpdateTest.java | 466 +++++++++++++++++++
.../GridNearOffheapCacheStoreUpdateTest.java | 35 ++
.../testsuites/IgniteCacheTestSuite2.java | 5 +
19 files changed, 770 insertions(+), 163 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/b54a4813/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
index fd9f396..59665bb 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
@@ -1789,6 +1789,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
subjId = ctx.subjectIdPerCall(subjId, opCtx);
return getAllAsync(keys,
+ null,
opCtx == null || !opCtx.skipStore(),
!skipTx,
subjId,
@@ -1803,6 +1804,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
/**
* @param keys Keys.
+ * @param readerArgs Near cache reader will be added if not null.
* @param readThrough Read through.
* @param checkTx Check tx.
* @param subjId Subj Id.
@@ -1817,6 +1819,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
* @see GridCacheAdapter#getAllAsync(Collection)
*/
public final IgniteInternalFuture<Map<K, V>> getAllAsync(@Nullable final Collection<? extends K> keys,
+ @Nullable final ReaderArguments readerArgs,
boolean readThrough,
boolean checkTx,
@Nullable final UUID subjId,
@@ -1834,6 +1837,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
validateCacheKeys(keys);
return getAllAsync0(ctx.cacheKeysView(keys),
+ readerArgs,
readThrough,
checkTx,
subjId,
@@ -1848,6 +1852,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
/**
* @param keys Keys.
+ * @param readerArgs Near cache reader will be added if not null.
* @param readThrough Read-through flag.
* @param checkTx Check local transaction flag.
* @param subjId Subject ID.
@@ -1862,6 +1867,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
*/
protected final <K1, V1> IgniteInternalFuture<Map<K1, V1>> getAllAsync0(
@Nullable final Collection<KeyCacheObject> keys,
+ @Nullable final ReaderArguments readerArgs,
final boolean readThrough,
boolean checkTx,
@Nullable final UUID subjId,
@@ -1932,7 +1938,8 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
subjId,
taskName,
expiry,
- !deserializeBinary);
+ !deserializeBinary,
+ readerArgs);
assert res != null;
@@ -1957,7 +1964,8 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
null,
taskName,
expiry,
- !deserializeBinary);
+ !deserializeBinary,
+ readerArgs);
if (res == null)
ctx.evicts().touch(entry, topVer);
@@ -2015,29 +2023,28 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
GridCacheEntryEx entry = entryEx(key);
try {
- GridCacheVersion verSet = entry.versionedValue(cacheVal,
+ T2<CacheObject, GridCacheVersion> verVal = entry.versionedValue(
+ cacheVal,
res.version(),
- null);
-
- boolean set = verSet != null;
+ null,
+ readerArgs);
if (log.isDebugEnabled())
log.debug("Set value loaded from store into entry [" +
- "set=" + set +
- ", curVer=" + res.version() +
- ", newVer=" + verSet + ", " +
+ "oldVer=" + res.version() +
+ ", newVer=" + verVal.get2() + ", " +
"entry=" + entry + ']');
// Don't put key-value pair into result map if value is null.
- if (val != null) {
+ if (verVal.get1() != null) {
ctx.addResult(map,
key,
- cacheVal,
+ verVal.get1(),
skipVals,
keepCacheObjects,
deserializeBinary,
- false,
- needVer ? set ? verSet : res.version() : null);
+ true,
+ needVer ? verVal.get2() : null);
}
if (tx0 == null || (!tx0.implicit() &&
http://git-wip-us.apache.org/repos/asf/ignite/blob/b54a4813/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
index 66b71b4..424e325 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
@@ -1900,9 +1900,9 @@ public class GridCacheContext<K, V> implements Externalizable {
assert val != null || skipVals;
if (!keepCacheObjects) {
- Object key0 = unwrapBinaryIfNeeded(key, !deserializeBinary);
+ Object key0 = unwrapBinaryIfNeeded(key, !deserializeBinary, cpy);
- Object val0 = skipVals ? true : unwrapBinaryIfNeeded(val, !deserializeBinary);
+ Object val0 = skipVals ? true : unwrapBinaryIfNeeded(val, !deserializeBinary, cpy);
assert key0 != null : key;
assert val0 != null : val;
http://git-wip-us.apache.org/repos/asf/ignite/blob/b54a4813/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java
index b1d632f..51f423a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java
@@ -34,6 +34,7 @@ import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersionedEntryEx;
import org.apache.ignite.internal.processors.dr.GridDrType;
import org.apache.ignite.internal.util.lang.GridTuple3;
+import org.apache.ignite.internal.util.typedef.T2;
import org.jetbrains.annotations.Nullable;
/**
@@ -318,11 +319,12 @@ public interface GridCacheEntryEx {
* @param taskName Task name.
* @param expiryPlc Expiry policy.
* @param keepBinary Keep binary flag.
+ * @param readerArgs Reader will be added if not null.
* @return Cached value and entry version.
* @throws IgniteCheckedException If loading value failed.
* @throws GridCacheEntryRemovedException If entry was removed.
*/
- @Nullable public EntryGetResult innerGetVersioned(
+ public EntryGetResult innerGetVersioned(
@Nullable GridCacheVersion ver,
IgniteInternalTx tx,
boolean readSwap,
@@ -333,7 +335,8 @@ public interface GridCacheEntryEx {
Object transformClo,
String taskName,
@Nullable IgniteCacheExpiryPolicy expiryPlc,
- boolean keepBinary)
+ boolean keepBinary,
+ @Nullable ReaderArguments readerArgs)
throws IgniteCheckedException, GridCacheEntryRemovedException;
/**
@@ -344,7 +347,7 @@ public interface GridCacheEntryEx {
* @param taskName Task name.
* @param expiryPlc Expiry policy.
* @param keepBinary Keep binary flag.
- * @return Cached value and entry version.
+ * @param readerArgs Reader will be added if not null.
* @throws IgniteCheckedException If loading value failed.
* @throws GridCacheEntryRemovedException If entry was removed.
* @return Cached value, entry version and flag indicating if entry was reserved.
@@ -355,7 +358,8 @@ public interface GridCacheEntryEx {
UUID subjId,
String taskName,
@Nullable IgniteCacheExpiryPolicy expiryPlc,
- boolean keepBinary) throws IgniteCheckedException, GridCacheEntryRemovedException;
+ boolean keepBinary,
+ @Nullable ReaderArguments readerArgs) throws IgniteCheckedException, GridCacheEntryRemovedException;
/**
* @param ver Expected entry version.
@@ -751,13 +755,15 @@ public interface GridCacheEntryEx {
* @param val New value.
* @param curVer Version to match or {@code null} if match is not required.
* @param newVer Version to set.
- * @return Non null version if value was set.
+ * @param readerArgs Reader will be added if not null.
+ * @return Current version and value.
* @throws IgniteCheckedException If index could not be updated.
* @throws GridCacheEntryRemovedException If entry was removed.
*/
- public GridCacheVersion versionedValue(CacheObject val,
+ public T2<CacheObject, GridCacheVersion> versionedValue(CacheObject val,
@Nullable GridCacheVersion curVer,
- @Nullable GridCacheVersion newVer)
+ @Nullable GridCacheVersion newVer,
+ @Nullable ReaderArguments readerArgs)
throws IgniteCheckedException, GridCacheEntryRemovedException;
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/b54a4813/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 9f0c2b0..59e4181 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
@@ -778,7 +778,8 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
expirePlc,
false,
keepBinary,
- false);
+ false,
+ null);
}
/** {@inheritDoc} */
@@ -788,7 +789,8 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
UUID subjId,
String taskName,
@Nullable IgniteCacheExpiryPolicy expiryPlc,
- boolean keepBinary) throws IgniteCheckedException, GridCacheEntryRemovedException {
+ boolean keepBinary,
+ @Nullable ReaderArguments readerArgs) throws IgniteCheckedException, GridCacheEntryRemovedException {
return (EntryGetResult)innerGet0(
/*ver*/null,
/*tx*/null,
@@ -803,11 +805,12 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
expiryPlc,
true,
keepBinary,
- /*reserve*/true);
+ /*reserve*/true,
+ readerArgs);
}
/** {@inheritDoc} */
- @Nullable @Override public EntryGetResult innerGetVersioned(
+ @Override public EntryGetResult innerGetVersioned(
@Nullable GridCacheVersion ver,
IgniteInternalTx tx,
boolean readSwap,
@@ -818,7 +821,8 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
Object transformClo,
String taskName,
@Nullable IgniteCacheExpiryPolicy expiryPlc,
- boolean keepBinary)
+ boolean keepBinary,
+ @Nullable ReaderArguments readerArgs)
throws IgniteCheckedException, GridCacheEntryRemovedException {
return (EntryGetResult)innerGet0(ver,
tx,
@@ -833,7 +837,8 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
expiryPlc,
true,
keepBinary,
- false);
+ false,
+ readerArgs);
}
/** {@inheritDoc} */
@@ -852,7 +857,8 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
@Nullable IgniteCacheExpiryPolicy expiryPlc,
boolean retVer,
boolean keepBinary,
- boolean reserveForLoad
+ boolean reserveForLoad,
+ @Nullable ReaderArguments readerArgs
) throws IgniteCheckedException, GridCacheEntryRemovedException {
assert !(retVer && readThrough);
assert !(reserveForLoad && readThrough);
@@ -961,6 +967,8 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
// Cache version for optimistic check.
startVer = ver;
+ addReaderIfNeed(readerArgs);
+
if (ret != null) {
assert tmp || !(ret instanceof BinaryObjectOffheapImpl);
assert !obsolete;
@@ -1051,6 +1059,8 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
if (cctx.deferredDelete() && deletedUnlocked() && !isInternal() && !detached())
deletedUnlocked(false);
+
+ assert readerArgs == null;
}
if (evt && cctx.events().isRecordable(EVT_CACHE_OBJECT_READ)) {
@@ -3611,19 +3621,22 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
}
/** {@inheritDoc} */
- @Override public synchronized GridCacheVersion versionedValue(CacheObject val,
+ @Override public synchronized T2<CacheObject, GridCacheVersion> versionedValue(CacheObject val,
GridCacheVersion curVer,
- GridCacheVersion newVer)
+ GridCacheVersion newVer,
+ @Nullable ReaderArguments readerArgs)
throws IgniteCheckedException, GridCacheEntryRemovedException
{
checkObsolete();
+ addReaderIfNeed(readerArgs);
+
if (curVer == null || curVer.equals(ver)) {
if (val != this.val) {
GridCacheMvcc mvcc = mvccExtras();
if (mvcc != null && !mvcc.isEmpty())
- return null;
+ return new T2<>(this.val, ver);
if (newVer == null)
newVer = cctx.versions().next();
@@ -3647,13 +3660,32 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
// Version does not change for load ops.
update(val, expTime, ttl, newVer, true);
- return newVer;
+ return new T2<>(val, newVer);
}
assert !evictionDisabled() : this;
}
- return null;
+ return new T2<>(this.val, ver);
+ }
+
+ /**
+ * @param readerArgs Reader arguments
+ */
+ private void addReaderIfNeed(@Nullable ReaderArguments readerArgs) {
+ if (readerArgs != null) {
+ assert this instanceof GridDhtCacheEntry : this;
+ assert Thread.holdsLock(this);
+
+ try {
+ ((GridDhtCacheEntry)this).addReader(readerArgs.reader(),
+ readerArgs.messageId(),
+ readerArgs.topologyVersion());
+ }
+ catch (GridCacheEntryRemovedException e) {
+ assert false : this;
+ }
+ }
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/b54a4813/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ReaderArguments.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ReaderArguments.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ReaderArguments.java
new file mode 100644
index 0000000..b8b5e64
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ReaderArguments.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.internal.processors.cache;
+
+import java.util.UUID;
+import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
+import org.apache.ignite.internal.util.typedef.internal.S;
+
+/**
+ * Arguments required for adding near cache reader to entry.
+ */
+public class ReaderArguments {
+ /** */
+ private final UUID reader;
+
+ /** */
+ private final long msgId;
+
+ /** */
+ private final AffinityTopologyVersion topVer;
+
+ /**
+ * @param reader Near cache node ID.
+ * @param msgId Message ID.
+ * @param topVer Topology version.
+ */
+ public ReaderArguments(final UUID reader, final long msgId,
+ final AffinityTopologyVersion topVer) {
+ this.reader = reader;
+ this.msgId = msgId;
+ this.topVer = topVer;
+ }
+
+ /**
+ * @return Reader node ID.
+ */
+ public UUID reader() {
+ return reader;
+ }
+
+ /**
+ * @return Message ID.
+ */
+ public long messageId() {
+ return msgId;
+ }
+
+ /**
+ * @return Topology version.
+ */
+ public AffinityTopologyVersion topologyVersion() {
+ return topVer;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(ReaderArguments.class, this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/b54a4813/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
index b2fb7b4..543cee1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
@@ -35,8 +35,8 @@ import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.internal.IgniteInternalFuture;
-import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
import org.apache.ignite.internal.NodeStoppingException;
+import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
import org.apache.ignite.internal.processors.cache.CacheObject;
import org.apache.ignite.internal.processors.cache.CacheOperationContext;
@@ -53,6 +53,7 @@ import org.apache.ignite.internal.processors.cache.GridCacheMapEntryFactory;
import org.apache.ignite.internal.processors.cache.GridCachePreloader;
import org.apache.ignite.internal.processors.cache.IgniteCacheExpiryPolicy;
import org.apache.ignite.internal.processors.cache.KeyCacheObject;
+import org.apache.ignite.internal.processors.cache.ReaderArguments;
import org.apache.ignite.internal.processors.cache.distributed.GridCacheTtlUpdateRequest;
import org.apache.ignite.internal.processors.cache.distributed.GridDistributedCacheAdapter;
import org.apache.ignite.internal.processors.cache.distributed.GridDistributedCacheEntry;
@@ -623,6 +624,7 @@ public abstract class GridDhtCacheAdapter<K, V> extends GridDistributedCacheAdap
CacheOperationContext opCtx = ctx.operationContextPerCall();
return getAllAsync(keys,
+ null,
opCtx == null || !opCtx.skipStore(),
/*don't check local tx. */false,
subjId,
@@ -637,6 +639,7 @@ public abstract class GridDhtCacheAdapter<K, V> extends GridDistributedCacheAdap
/**
* @param keys Keys to get
+ * @param readerArgs Reader will be added if not null.
* @param readThrough Read through flag.
* @param subjId Subject ID.
* @param taskName Task name.
@@ -647,6 +650,7 @@ public abstract class GridDhtCacheAdapter<K, V> extends GridDistributedCacheAdap
*/
IgniteInternalFuture<Map<KeyCacheObject, T2<CacheObject, GridCacheVersion>>> getDhtAllAsync(
Collection<KeyCacheObject> keys,
+ @Nullable final ReaderArguments readerArgs,
boolean readThrough,
@Nullable UUID subjId,
String taskName,
@@ -655,6 +659,7 @@ public abstract class GridDhtCacheAdapter<K, V> extends GridDistributedCacheAdap
boolean canRemap
) {
return getAllAsync0(keys,
+ readerArgs,
readThrough,
/*don't check local tx. */false,
subjId,
@@ -694,7 +699,6 @@ public abstract class GridDhtCacheAdapter<K, V> extends GridDistributedCacheAdap
reader,
keys,
readThrough,
- /*tx*/null,
topVer,
subjId,
taskNameHash,
@@ -738,7 +742,6 @@ public abstract class GridDhtCacheAdapter<K, V> extends GridDistributedCacheAdap
key,
addRdr,
readThrough,
- /*tx*/null,
topVer,
subjId,
taskNameHash,
http://git-wip-us.apache.org/repos/asf/ignite/blob/b54a4813/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetFuture.java
index 913580f..3bf4489 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetFuture.java
@@ -29,7 +29,6 @@ import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.internal.IgniteInternalFuture;
-import org.apache.ignite.internal.NodeStoppingException;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
import org.apache.ignite.internal.processors.cache.CacheObject;
import org.apache.ignite.internal.processors.cache.GridCacheContext;
@@ -37,7 +36,7 @@ import org.apache.ignite.internal.processors.cache.GridCacheEntryInfo;
import org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedException;
import org.apache.ignite.internal.processors.cache.IgniteCacheExpiryPolicy;
import org.apache.ignite.internal.processors.cache.KeyCacheObject;
-import org.apache.ignite.internal.processors.cache.transactions.IgniteTxLocalEx;
+import org.apache.ignite.internal.processors.cache.ReaderArguments;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
import org.apache.ignite.internal.util.future.GridCompoundFuture;
import org.apache.ignite.internal.util.future.GridCompoundIdentityFuture;
@@ -50,7 +49,6 @@ import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.T2;
import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.lang.IgniteBiClosure;
import org.apache.ignite.lang.IgniteUuid;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -96,9 +94,6 @@ public final class GridDhtGetFuture<K, V> extends GridCompoundIdentityFuture<Col
/** Topology version .*/
private AffinityTopologyVersion topVer;
- /** Transaction. */
- private IgniteTxLocalEx tx;
-
/** Retries because ownership changed. */
private Collection<Integer> retries;
@@ -120,7 +115,6 @@ public final class GridDhtGetFuture<K, V> extends GridCompoundIdentityFuture<Col
* @param reader Reader.
* @param keys Keys.
* @param readThrough Read through flag.
- * @param tx Transaction.
* @param topVer Topology version.
* @param subjId Subject ID.
* @param taskNameHash Task name hash code.
@@ -133,7 +127,6 @@ public final class GridDhtGetFuture<K, V> extends GridCompoundIdentityFuture<Col
UUID reader,
Map<KeyCacheObject, Boolean> keys,
boolean readThrough,
- @Nullable IgniteTxLocalEx tx,
@NotNull AffinityTopologyVersion topVer,
@Nullable UUID subjId,
int taskNameHash,
@@ -150,7 +143,6 @@ public final class GridDhtGetFuture<K, V> extends GridCompoundIdentityFuture<Col
this.msgId = msgId;
this.keys = keys;
this.readThrough = readThrough;
- this.tx = tx;
this.topVer = topVer;
this.subjId = subjId;
this.taskNameHash = taskNameHash;
@@ -159,7 +151,7 @@ public final class GridDhtGetFuture<K, V> extends GridCompoundIdentityFuture<Col
futId = IgniteUuid.randomUuid();
- ver = tx == null ? cctx.versions().next() : tx.xidVersion();
+ ver = cctx.versions().next();
if (log == null)
log = U.logger(cctx.kernalContext(), logRef, GridDhtGetFuture.class);
@@ -340,6 +332,8 @@ public final class GridDhtGetFuture<K, V> extends GridCompoundIdentityFuture<Col
ClusterNode readerNode = cctx.discovery().node(reader);
+ ReaderArguments readerArgs = null;
+
if (readerNode != null && !readerNode.isLocal() && cctx.discovery().cacheNearNode(readerNode, cctx.name())) {
for (Map.Entry<KeyCacheObject, Boolean> k : keys.entrySet()) {
while (true) {
@@ -351,12 +345,19 @@ public final class GridDhtGetFuture<K, V> extends GridCompoundIdentityFuture<Col
boolean addReader = (!e.deleted() && k.getValue() && !skipVals);
- if (addReader)
+ if (addReader) {
e.unswap(false);
+ // Entry will be removed on touch() if no data in cache,
+ // but they could be loaded from store,
+ // we have to add reader again later.
+ if (readerArgs == null)
+ readerArgs = new ReaderArguments(reader, msgId, topVer);
+ }
+
// Register reader. If there are active transactions for this entry,
// then will wait for their completion before proceeding.
- // TODO: GG-4003:
+ // TODO: IGNITE-3498:
// TODO: What if any transaction we wait for actually removes this entry?
// TODO: In this case seems like we will be stuck with untracked near entry.
// TODO: To fix, check that reader is contained in the list of readers once
@@ -392,28 +393,19 @@ public final class GridDhtGetFuture<K, V> extends GridCompoundIdentityFuture<Col
IgniteInternalFuture<Map<KeyCacheObject, T2<CacheObject, GridCacheVersion>>> fut;
if (txFut == null || txFut.isDone()) {
- if (tx == null) {
- fut = cache().getDhtAllAsync(
- keys.keySet(),
- readThrough,
- subjId,
- taskName,
- expiryPlc,
- skipVals,
- /*can remap*/true);
- }
- else {
- fut = tx.getAllAsync(cctx,
- null,
- keys.keySet(),
- /*deserialize binary*/false,
- skipVals,
- /*keep cache objects*/true,
- /*skip store*/!readThrough,
- false);
- }
+ fut = cache().getDhtAllAsync(
+ keys.keySet(),
+ readerArgs,
+ readThrough,
+ subjId,
+ taskName,
+ expiryPlc,
+ skipVals,
+ /*can remap*/true);
}
else {
+ final ReaderArguments args = readerArgs;
+
// If we are here, then there were active transactions for some entries
// when we were adding the reader. In that case we must wait for those
// transactions to complete.
@@ -424,26 +416,15 @@ public final class GridDhtGetFuture<K, V> extends GridCompoundIdentityFuture<Col
if (e != null)
throw new GridClosureException(e);
- if (tx == null) {
- return cache().getDhtAllAsync(
- keys.keySet(),
- readThrough,
- subjId,
- taskName,
- expiryPlc,
- skipVals,
- /*can remap*/true);
- }
- else {
- return tx.getAllAsync(cctx,
- null,
- keys.keySet(),
- /*deserialize binary*/false,
- skipVals,
- /*keep cache objects*/true,
- /*skip store*/!readThrough,
- false);
- }
+ return cache().getDhtAllAsync(
+ keys.keySet(),
+ args,
+ readThrough,
+ subjId,
+ taskName,
+ expiryPlc,
+ skipVals,
+ /*can remap*/true);
}
}
);
http://git-wip-us.apache.org/repos/asf/ignite/blob/b54a4813/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetSingleFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetSingleFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetSingleFuture.java
index 9394937..49bebd6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetSingleFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetSingleFuture.java
@@ -35,7 +35,7 @@ import org.apache.ignite.internal.processors.cache.GridCacheEntryInfo;
import org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedException;
import org.apache.ignite.internal.processors.cache.IgniteCacheExpiryPolicy;
import org.apache.ignite.internal.processors.cache.KeyCacheObject;
-import org.apache.ignite.internal.processors.cache.transactions.IgniteTxLocalEx;
+import org.apache.ignite.internal.processors.cache.ReaderArguments;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
import org.apache.ignite.internal.util.future.GridFutureAdapter;
import org.apache.ignite.internal.util.typedef.F;
@@ -90,9 +90,6 @@ public final class GridDhtGetSingleFuture<K, V> extends GridFutureAdapter<GridCa
/** Topology version .*/
private AffinityTopologyVersion topVer;
- /** Transaction. */
- private IgniteTxLocalEx tx;
-
/** Retries because ownership changed. */
private Collection<Integer> retries;
@@ -115,7 +112,6 @@ public final class GridDhtGetSingleFuture<K, V> extends GridFutureAdapter<GridCa
* @param key Key.
* @param addRdr Add reader flag.
* @param readThrough Read through flag.
- * @param tx Transaction.
* @param topVer Topology version.
* @param subjId Subject ID.
* @param taskNameHash Task name hash code.
@@ -129,7 +125,6 @@ public final class GridDhtGetSingleFuture<K, V> extends GridFutureAdapter<GridCa
KeyCacheObject key,
Boolean addRdr,
boolean readThrough,
- @Nullable IgniteTxLocalEx tx,
@NotNull AffinityTopologyVersion topVer,
@Nullable UUID subjId,
int taskNameHash,
@@ -145,7 +140,6 @@ public final class GridDhtGetSingleFuture<K, V> extends GridFutureAdapter<GridCa
this.key = key;
this.addRdr = addRdr;
this.readThrough = readThrough;
- this.tx = tx;
this.topVer = topVer;
this.subjId = subjId;
this.taskNameHash = taskNameHash;
@@ -154,7 +148,7 @@ public final class GridDhtGetSingleFuture<K, V> extends GridFutureAdapter<GridCa
futId = IgniteUuid.randomUuid();
- ver = tx == null ? cctx.versions().next() : tx.xidVersion();
+ ver = cctx.versions().next();
if (log == null)
log = U.logger(cctx.kernalContext(), logRef, GridDhtGetSingleFuture.class);
@@ -306,6 +300,8 @@ public final class GridDhtGetSingleFuture<K, V> extends GridFutureAdapter<GridCa
ClusterNode readerNode = cctx.discovery().node(reader);
+ ReaderArguments readerArgs = null;
+
if (readerNode != null && !readerNode.isLocal() && cctx.discovery().cacheNearNode(readerNode, cctx.name())) {
while (true) {
GridDhtCacheEntry e = cache().entryExx(key, topVer);
@@ -314,14 +310,21 @@ public final class GridDhtGetSingleFuture<K, V> extends GridFutureAdapter<GridCa
if (e.obsolete())
continue;
- boolean addReader = (!e.deleted() && addRdr && !skipVals);
+ boolean addReader = (!e.deleted() && this.addRdr && !skipVals);
- if (addReader)
+ if (addReader) {
e.unswap(false);
+ // Entry will be removed on touch() if no data in cache,
+ // but they could be loaded from store,
+ // we have to add reader again later.
+ if (readerArgs == null)
+ readerArgs = new ReaderArguments(reader, msgId, topVer);
+ }
+
// Register reader. If there are active transactions for this entry,
// then will wait for their completion before proceeding.
- // TODO: GG-4003:
+ // TODO: IGNITE-3498:
// TODO: What if any transaction we wait for actually removes this entry?
// TODO: In this case seems like we will be stuck with untracked near entry.
// TODO: To fix, check that reader is contained in the list of readers once
@@ -348,28 +351,19 @@ public final class GridDhtGetSingleFuture<K, V> extends GridFutureAdapter<GridCa
IgniteInternalFuture<Map<KeyCacheObject, T2<CacheObject, GridCacheVersion>>> fut;
if (rdrFut == null || rdrFut.isDone()) {
- if (tx == null) {
- fut = cache().getDhtAllAsync(
- Collections.singleton(key),
- readThrough,
- subjId,
- taskName,
- expiryPlc,
- skipVals,
- /*can remap*/true);
- }
- else {
- fut = tx.getAllAsync(cctx,
- null,
- Collections.singleton(key),
- /*deserialize binary*/false,
- skipVals,
- /*keep cache objects*/true,
- /*skip store*/!readThrough,
- false);
- }
+ fut = cache().getDhtAllAsync(
+ Collections.singleton(key),
+ readerArgs,
+ readThrough,
+ subjId,
+ taskName,
+ expiryPlc,
+ skipVals,
+ /*can remap*/true);
}
else {
+ final ReaderArguments args = readerArgs;
+
rdrFut.listen(
new IgniteInClosure<IgniteInternalFuture<Boolean>>() {
@Override public void apply(IgniteInternalFuture<Boolean> fut) {
@@ -381,29 +375,16 @@ public final class GridDhtGetSingleFuture<K, V> extends GridFutureAdapter<GridCa
return;
}
- IgniteInternalFuture<Map<KeyCacheObject, T2<CacheObject, GridCacheVersion>>> fut0;
-
- if (tx == null) {
- fut0 = cache().getDhtAllAsync(
+ IgniteInternalFuture<Map<KeyCacheObject, T2<CacheObject, GridCacheVersion>>> fut0 =
+ cache().getDhtAllAsync(
Collections.singleton(key),
+ args,
readThrough,
subjId,
taskName,
expiryPlc,
skipVals,
/*can remap*/true);
- }
- else {
- fut0 = tx.getAllAsync(cctx,
- null,
- Collections.singleton(key),
- /*deserialize binary*/false,
- skipVals,
- /*keep cache objects*/true,
- /*skip store*/!readThrough,
- false
- );
- }
fut0.listen(createGetFutureListener());
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/b54a4813/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java
index d0f209d..c8e2cf3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java
@@ -461,7 +461,8 @@ public class GridPartitionedGetFuture<K, V> extends CacheDistributedGetFutureAda
null,
taskName,
expiryPlc,
- !deserializeBinary);
+ !deserializeBinary,
+ null);
if (res != null) {
v = res.value();
http://git-wip-us.apache.org/repos/asf/ignite/blob/b54a4813/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java
index e188a35..e369bfa 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java
@@ -385,7 +385,8 @@ public class GridPartitionedSingleGetFuture extends GridFutureAdapter<Object> im
null,
taskName,
expiryPlc,
- true);
+ true,
+ null);
if (res != null) {
v = res.value();
http://git-wip-us.apache.org/repos/asf/ignite/blob/b54a4813/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
index 94a049e..f601e0a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
@@ -1505,7 +1505,8 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
null,
taskName,
expiry,
- true);
+ true,
+ null);
if (res != null) {
v = res.value();
@@ -2292,7 +2293,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
try {
GridCacheVersion ver = entry.version();
- entry.versionedValue(ctx.toCacheObject(v), null, ver);
+ entry.versionedValue(ctx.toCacheObject(v), null, ver, null);
}
catch (GridCacheEntryRemovedException e) {
assert false : "Entry should not get obsolete while holding lock [entry=" + entry +
http://git-wip-us.apache.org/repos/asf/ignite/blob/b54a4813/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
index 56af95e..29f0607 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
@@ -496,7 +496,8 @@ public class GridDhtColocatedCache<K, V> extends GridDhtTransactionalCacheAdapte
null,
taskName,
expiryPlc,
- !deserializeBinary);
+ !deserializeBinary,
+ null);
if (res != null) {
v = res.value();
http://git-wip-us.apache.org/repos/asf/ignite/blob/b54a4813/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java
index ab0e88c..8bc513e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java
@@ -449,7 +449,8 @@ public final class GridNearGetFuture<K, V> extends CacheDistributedGetFutureAdap
null,
taskName,
expiryPlc,
- !deserializeBinary);
+ !deserializeBinary,
+ null);
if (res != null) {
v = res.value();
@@ -589,7 +590,8 @@ public final class GridNearGetFuture<K, V> extends CacheDistributedGetFutureAdap
null,
taskName,
expiryPlc,
- !deserializeBinary);
+ !deserializeBinary,
+ null);
if (res != null) {
v = res.value();
http://git-wip-us.apache.org/repos/asf/ignite/blob/b54a4813/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 d1acada..ad818a6 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
@@ -59,7 +59,6 @@ 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;
@@ -528,7 +527,8 @@ public class GridLocalAtomicCache<K, V> extends GridLocalCache<K, V> {
null,
taskName,
expiry,
- !deserializeBinary);
+ !deserializeBinary,
+ null);
if (res != null) {
v = res.value();
@@ -602,6 +602,7 @@ public class GridLocalAtomicCache<K, V> extends GridLocalCache<K, V> {
return getAllAsync(
keys,
+ null,
opCtx == null || !opCtx.skipStore(),
false,
subjId,
http://git-wip-us.apache.org/repos/asf/ignite/blob/b54a4813/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 91c9c92..f05d90d 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
@@ -438,7 +438,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
null,
resolveTaskName(),
expiryPlc,
- txEntry == null ? keepBinary : txEntry.keepBinary());
+ txEntry == null ? keepBinary : txEntry.keepBinary(),
+ null);
if (res == null) {
if (misses == null)
@@ -477,17 +478,19 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
GridCacheEntryEx entry = cacheCtx.cache().entryEx(key);
try {
- GridCacheVersion setVer = entry.versionedValue(cacheVal, ver, null);
-
- boolean set = setVer != null;
+ T2<CacheObject, GridCacheVersion> verVal = entry.versionedValue(cacheVal,
+ ver,
+ null,
+ null);
- if (set)
- ver = setVer;
+ if (log.isDebugEnabled()) {
+ log.debug("Set value loaded from store into entry [" +
+ "oldVer=" + ver +
+ ", newVer=" + verVal.get2() +
+ ", entry=" + entry + ']');
+ }
- if (log.isDebugEnabled())
- log.debug("Set value loaded from store into entry [set=" + set +
- ", curVer=" + ver + ", newVer=" + setVer + ", " +
- "entry=" + entry + ']');
+ ver = verVal.get2();
break;
}
@@ -1232,7 +1235,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
transformClo,
resolveTaskName(),
null,
- txEntry.keepBinary());
+ txEntry.keepBinary(),
+ null);
if (res != null) {
val = res.value();
@@ -1316,7 +1320,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
null,
resolveTaskName(),
accessPlc,
- !deserializeBinary) : null;
+ !deserializeBinary,
+ null) : null;
if (res != null) {
val = res.value();
@@ -1666,7 +1671,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
transformClo,
resolveTaskName(),
null,
- txEntry.keepBinary());
+ txEntry.keepBinary(),
+ null);
if (res != null) {
val = res.value();
@@ -2390,7 +2396,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
entryProcessor,
resolveTaskName(),
null,
- keepBinary) : null;
+ keepBinary,
+ null) : null;
if (res != null) {
old = res.value();
http://git-wip-us.apache.org/repos/asf/ignite/blob/b54a4813/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java
index b03e9c8..8db68b4 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java
@@ -430,7 +430,8 @@ public class GridCacheTestEntryEx extends GridMetadataAwareAdapter implements Gr
UUID subjId,
String taskName,
@Nullable IgniteCacheExpiryPolicy expiryPlc,
- boolean keepBinary) throws IgniteCheckedException, GridCacheEntryRemovedException {
+ boolean keepBinary,
+ @Nullable ReaderArguments args) throws IgniteCheckedException, GridCacheEntryRemovedException {
assert false;
return null;
@@ -448,7 +449,8 @@ public class GridCacheTestEntryEx extends GridMetadataAwareAdapter implements Gr
Object transformClo,
String taskName,
@Nullable IgniteCacheExpiryPolicy expiryPlc,
- boolean keepBinary) {
+ boolean keepBinary,
+ @Nullable ReaderArguments readerArgs) {
assert false;
return null;
@@ -684,9 +686,10 @@ public class GridCacheTestEntryEx extends GridMetadataAwareAdapter implements Gr
}
/** @inheritDoc */
- @Override public GridCacheVersion versionedValue(CacheObject val,
+ @Override public T2<CacheObject, GridCacheVersion> versionedValue(CacheObject val,
GridCacheVersion curVer,
- GridCacheVersion newVer) {
+ GridCacheVersion newVer,
+ @Nullable ReaderArguments readerArgs) {
assert false;
return null;
http://git-wip-us.apache.org/repos/asf/ignite/blob/b54a4813/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheStoreUpdateTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheStoreUpdateTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheStoreUpdateTest.java
new file mode 100644
index 0000000..183b9ca
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheStoreUpdateTest.java
@@ -0,0 +1,466 @@
+/*
+ * 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 java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Random;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CountDownLatch;
+import javax.cache.Cache;
+import javax.cache.configuration.Factory;
+import javax.cache.integration.CacheLoaderException;
+import javax.cache.integration.CacheWriterException;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheWriteSynchronizationMode;
+import org.apache.ignite.cache.store.CacheStore;
+import org.apache.ignite.cache.store.CacheStoreAdapter;
+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.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.apache.ignite.transactions.TransactionConcurrency;
+import org.apache.ignite.transactions.TransactionIsolation;
+
+/**
+ * Check that near cache is updated when entry loaded from store.
+ */
+public class GridNearCacheStoreUpdateTest extends GridCommonAbstractTest {
+ /** */
+ private static final String CACHE_NAME = "cache";
+
+ /** */
+ private Ignite srv;
+
+ /** */
+ private Ignite client;
+
+ /** */
+ private IgniteCache<String, String> cache;
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(final String gridName) throws Exception {
+ final IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ if (gridName.contains("client"))
+ cfg.setClientMode(true);
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTest() throws Exception {
+ srv = startGrid("server");
+ client = startGrid("client");
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ stopAllGrids();
+ }
+
+ /**
+ * @throws Exception If fail.
+ */
+ public void testAtomicUpdateNear() throws Exception {
+ cache = client.createCache(cacheConfiguration(), new NearCacheConfiguration<String, String>());
+
+ checkNear(null, null);
+ }
+
+ /**
+ * @throws Exception If fail.
+ */
+ public void testTransactionAtomicUpdateNear() throws Exception {
+ cache = client.createCache(cacheConfiguration(), new NearCacheConfiguration<String, String>());
+
+ checkNear(TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ);
+ }
+
+ /**
+ * @throws Exception If fail.
+ */
+ public void testPessimisticRepeatableReadUpdateNear() throws Exception {
+ cache = client.createCache(cacheConfiguration().setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL),
+ new NearCacheConfiguration<String, String>());
+
+ checkNear(TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ);
+ }
+
+ /**
+ * @throws Exception If fail.
+ */
+ public void testPessimisticReadCommittedUpdateNear() throws Exception {
+ cache = client.createCache(cacheConfiguration().setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL),
+ new NearCacheConfiguration<String, String>());
+
+ checkNear(TransactionConcurrency.PESSIMISTIC, TransactionIsolation.READ_COMMITTED);
+ }
+
+ /**
+ * @throws Exception If fail.
+ */
+ public void testOptimisticSerializableUpdateNear() throws Exception {
+ cache = client.createCache(cacheConfiguration().setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL),
+ new NearCacheConfiguration<String, String>());
+
+ checkNear(TransactionConcurrency.OPTIMISTIC, TransactionIsolation.SERIALIZABLE);
+ }
+
+ /**
+ * @param txConc Transaction concurrency.
+ * @param txIsolation Transaction isolation.
+ * @throws Exception If fail.
+ */
+ private void checkNear(TransactionConcurrency txConc, TransactionIsolation txIsolation) throws Exception {
+ checkNearSingle(txConc, txIsolation);
+ checkNearSingleConcurrent(txConc, txIsolation);
+ checkNearBatch(txConc, txIsolation);
+ checkNearBatchConcurrent(txConc, txIsolation);
+ }
+
+ /**
+ * @param txConc Transaction concurrency.
+ * @param txIsolation Transaction isolation.
+ * @throws Exception If fail.
+ */
+ private void checkNearSingle(TransactionConcurrency txConc, TransactionIsolation txIsolation) throws Exception {
+ final String key = "key";
+
+ boolean tx = txConc != null && txIsolation != null;
+
+ final IgniteCache<String, String> clientCache = this.cache;
+ final IgniteCache<String, String> srvCache = srv.<String, String>cache(CACHE_NAME);
+
+ if (tx) {
+ doInTransaction(client, txConc, txIsolation, new Callable<Object>() {
+ @Override public Object call() throws Exception {
+ // Read from store.
+ assertEquals(key, clientCache.get(key));
+
+ return null;
+ }
+ });
+ }
+ else
+ assertEquals(key, clientCache.get(key));
+
+ final String updatedVal = "key_updated";
+
+ if (tx) {
+ doInTransaction(srv, txConc, txIsolation, new Callable<Object>() {
+ @Override public Object call() throws Exception {
+ // Update value.
+ srvCache.put(key, updatedVal);
+
+ return null;
+ }
+ });
+ }
+ else
+ srvCache.put(key, updatedVal);
+
+ if (tx) {
+ doInTransaction(client, txConc, txIsolation, new Callable<Object>() {
+ @Override public Object call() throws Exception {
+ assertEquals(updatedVal, clientCache.get(key));
+
+ return null;
+ }
+ });
+ }
+ else
+ assertEquals(updatedVal, clientCache.get(key));
+ }
+
+ /**
+ * @param txConc Transaction concurrency.
+ * @param txIsolation Transaction isolation.
+ * @throws Exception If fail.
+ */
+ private void checkNearSingleConcurrent(final TransactionConcurrency txConc, final TransactionIsolation txIsolation) throws Exception {
+ for (int i = 0; i < 10; i++) {
+ final String key = String.valueOf(-((new Random().nextInt(99) + 1)));
+
+ boolean tx = txConc != null && txIsolation != null;
+
+ final IgniteCache<String, String> clientCache = this.cache;
+ final IgniteCache<String, String> srvCache = srv.cache(CACHE_NAME);
+
+ final CountDownLatch storeLatch = new CountDownLatch(1);
+
+ final IgniteInternalFuture<Object> fut1 = GridTestUtils.runAsync(new Callable<Object>() {
+ @Override public Object call() throws Exception {
+ storeLatch.await();
+
+ clientCache.get(key);
+
+ return null;
+ }
+ });
+
+
+// IgniteInternalFuture<Object> fut2 = null;
+
+ // TODO Sometimes Near cache becomes inconsistent
+// if (!tx) {
+// // TODO: IGNITE-3498
+// // TODO: Doesn't work on transactional cache.
+// fut2 = GridTestUtils.runAsync(new Callable<Object>() {
+// @Override public Object call() throws Exception {
+// storeLatch.await();
+//
+// srvCache.remove(key);
+//
+// return null;
+// }
+// });
+// }
+
+ final IgniteInternalFuture<Object> fut3 = GridTestUtils.runAsync(new Callable<Object>() {
+ @Override public Object call() throws Exception {
+ storeLatch.await();
+
+ srvCache.put(key, "other");
+
+ return null;
+ }
+ });
+
+ storeLatch.countDown();
+
+ fut1.get();
+
+// if (!tx)
+// fut2.get();
+
+ fut3.get();
+
+ final String srvVal = srvCache.get(key);
+ final String clientVal = clientCache.get(key);
+
+ assertEquals(srvVal, clientVal);
+ }
+ }
+
+ /**
+ * @param txConc Transaction concurrency.
+ * @param txIsolation Transaction isolation.
+ * @throws Exception If fail.
+ */
+ private void checkNearBatch(TransactionConcurrency txConc, TransactionIsolation txIsolation) throws Exception {
+ final Map<String, String> data1 = new HashMap<>();
+ final Map<String, String> data2 = new HashMap<>();
+
+ for (int i = 0; i < 10; i++) {
+ data1.put(String.valueOf(i), String.valueOf(i));
+ data2.put(String.valueOf(i), "other");
+ }
+
+ final IgniteCache<String, String> clientCache = this.cache;
+ final IgniteCache<String, String> srvCache = srv.cache(CACHE_NAME);
+
+ boolean tx = txConc != null && txIsolation != null;
+
+ // Read from store.
+ if (tx) {
+ doInTransaction(client, txConc, txIsolation, new Callable<Object>() {
+ @Override public Object call() throws Exception {
+ assertEquals(data1, clientCache.getAll(data1.keySet()));
+
+ return null;
+ }
+ });
+ }
+ else
+ assertEquals(data1, clientCache.getAll(data1.keySet()));
+
+ // Update value.
+ if (tx) {
+ doInTransaction(srv, txConc, txIsolation, new Callable<Object>() {
+ @Override public Object call() throws Exception {
+ srvCache.putAll(data2);
+
+ return null;
+ }
+ });
+ }
+ else
+ srvCache.putAll(data2);
+
+ if (tx) {
+ doInTransaction(client, txConc, txIsolation, new Callable<Object>() {
+ @Override public Object call() throws Exception {
+ assertEquals(data2, clientCache.getAll(data2.keySet()));
+
+ return null;
+ }
+ });
+ }
+ else
+ assertEquals(data2, clientCache.getAll(data2.keySet()));
+ }
+
+ /**
+ * @param txConc Transaction concurrency.
+ * @param txIsolation Transaction isolation.
+ * @throws Exception If fail.
+ */
+ private void checkNearBatchConcurrent(TransactionConcurrency txConc, TransactionIsolation txIsolation)
+ throws Exception {
+ final Map<String, String> data1 = new HashMap<>();
+ final Map<String, String> data2 = new HashMap<>();
+
+ for (int j = 0; j < 10; j++) {
+ data1.clear();
+ data2.clear();
+
+ for (int i = j * 10; i < j * 10 + 10; i++) {
+ data1.put(String.valueOf(i), String.valueOf(i));
+ data2.put(String.valueOf(i), "other");
+ }
+
+ final IgniteCache<String, String> clientCache = this.cache;
+ final IgniteCache<String, String> srvCache = srv.cache(CACHE_NAME);
+
+ boolean tx = txConc != null && txIsolation != null;
+
+ final CountDownLatch latch = new CountDownLatch(1);
+
+ final IgniteInternalFuture<Object> fut1 = GridTestUtils.runAsync(new Callable<Object>() {
+ @Override public Object call() throws Exception {
+ latch.await();
+
+ clientCache.getAll(data1.keySet());
+
+ return null;
+ }
+ });
+
+ IgniteInternalFuture<Object> fut2 = GridTestUtils.runAsync(new Callable<Object>() {
+ @Override public Object call() throws Exception {
+ latch.await();
+
+ srvCache.putAll(data2);
+
+ return null;
+ }
+ });
+
+// IgniteInternalFuture<Object> fut3 = null;
+//
+// // TODO Sometimes Near cache becomes inconsistent
+// if (!tx) {
+// // TODO: IGNITE-3498
+// // TODO: Doesn't work on transactional cache.
+// fut3 = GridTestUtils.runAsync(new Callable<Object>() {
+// @Override public Object call() throws Exception {
+// latch.await();
+//
+// srvCache.removeAll(data1.keySet());
+//
+// return null;
+// }
+// });
+// }
+
+ latch.countDown();
+
+// if (!tx)
+// fut3.get();
+
+ fut1.get();
+ fut2.get();
+
+ final Map<String, String> srvVals = srvCache.getAll(data1.keySet());
+ final Map<String, String> clientVals = clientCache.getAll(data1.keySet());
+
+ assertEquals(srvVals, clientVals);
+ }
+ }
+
+ /**
+ * @return Cache configuration.
+ */
+ protected CacheConfiguration<String, String> cacheConfiguration() {
+ CacheConfiguration<String, String> cfg = new CacheConfiguration<>(CACHE_NAME);
+
+ cfg.setCacheStoreFactory(new StoreFactory());
+
+ cfg.setReadThrough(true);
+ cfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
+
+ return cfg;
+ }
+
+ /**
+ *
+ */
+ private static class StoreFactory implements Factory<CacheStore<? super String, ? super String>> {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** {@inheritDoc} */
+ @Override public CacheStore<? super String, ? super String> create() {
+ return new TestStore();
+ }
+ }
+
+ /**
+ *
+ */
+ private static class TestStore extends CacheStoreAdapter<String, String> implements Serializable {
+ /** */
+ private final ConcurrentHashMap<String, String> map = new ConcurrentHashMap<>();
+
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /**
+ *
+ */
+ public TestStore() {
+ for (int i = -100; i < 1000; i++)
+ map.put(String.valueOf(i), String.valueOf(i));
+
+ map.put("key", "key");
+ }
+
+ /** {@inheritDoc} */
+ @Override public String load(String key) throws CacheLoaderException {
+ return map.get(key);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void write(Cache.Entry<? extends String, ? extends String> entry) throws CacheWriterException {
+ map.put(entry.getKey(), entry.getValue());
+ }
+
+ /** {@inheritDoc} */
+ @SuppressWarnings("SuspiciousMethodCalls")
+ @Override public void delete(Object key) throws CacheWriterException {
+ map.remove(key);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/b54a4813/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOffheapCacheStoreUpdateTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOffheapCacheStoreUpdateTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOffheapCacheStoreUpdateTest.java
new file mode 100644
index 0000000..ae3f695
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOffheapCacheStoreUpdateTest.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache.distributed.near;
+
+import org.apache.ignite.cache.CacheMemoryMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+
+/**
+ * Check that near cache is updated when entry loaded from store.
+ */
+public class GridNearOffheapCacheStoreUpdateTest extends GridNearCacheStoreUpdateTest {
+ /** {@inheritDoc} */
+ @Override protected CacheConfiguration<String, String> cacheConfiguration() {
+ final CacheConfiguration<String, String> ccfg = super.cacheConfiguration();
+
+ ccfg.setMemoryMode(CacheMemoryMode.OFFHEAP_TIERED);
+
+ return ccfg;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/b54a4813/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite2.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite2.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite2.java
index 8792ea1..af46c57 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite2.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite2.java
@@ -114,8 +114,10 @@ import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePar
import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePartitionedTxTimeoutSelfTest;
import org.apache.ignite.internal.processors.cache.distributed.near.GridCacheRendezvousAffinityClientSelfTest;
import org.apache.ignite.internal.processors.cache.distributed.near.GridPartitionedBackupLoadSelfTest;
+import org.apache.ignite.internal.processors.cache.distributed.near.GridNearCacheStoreUpdateTest;
import org.apache.ignite.internal.processors.cache.distributed.near.NearCacheSyncUpdateTest;
import org.apache.ignite.internal.processors.cache.distributed.near.NoneRebalanceModeSelfTest;
+import org.apache.ignite.internal.processors.cache.distributed.near.GridNearOffheapCacheStoreUpdateTest;
import org.apache.ignite.internal.processors.cache.distributed.replicated.GridCacheReplicatedEvictionSelfTest;
import org.apache.ignite.internal.processors.cache.distributed.replicated.GridCacheReplicatedJobExecutionTest;
import org.apache.ignite.internal.processors.cache.local.GridCacheLocalAtomicBasicStoreSelfTest;
@@ -271,6 +273,9 @@ public class IgniteCacheTestSuite2 extends TestSuite {
suite.addTest(new TestSuite(OffheapCacheOnClientsTest.class));
suite.addTest(new TestSuite(CacheConcurrentReadThroughTest.class));
+ suite.addTest(new TestSuite(GridNearCacheStoreUpdateTest.class));
+ suite.addTest(new TestSuite(GridNearOffheapCacheStoreUpdateTest.class));
+
return suite;
}
}
[09/31] ignite git commit: Merge remote-tracking branch
'remotes/community/ignite-1.7.5-p1' into ignite-1.7.6
Posted by ak...@apache.org.
Merge remote-tracking branch 'remotes/community/ignite-1.7.5-p1' into ignite-1.7.6
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/67225b24
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/67225b24
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/67225b24
Branch: refs/heads/ignite-4436-2
Commit: 67225b24dbc77ed70f5aa6bac6d750623c67045d
Parents: 22b7e76 496fb17
Author: sboikov <sb...@gridgain.com>
Authored: Tue Jan 17 12:46:28 2017 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Tue Jan 17 12:46:28 2017 +0300
----------------------------------------------------------------------
.../processors/cache/GridCacheUtils.java | 3 +
.../continuous/CacheContinuousQueryHandler.java | 81 +++++++++++++++++---
modules/core/src/test/config/log4j-test.xml | 6 ++
3 files changed, 79 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
[25/31] ignite git commit: Merge branch 'master' of
https://github.com/apache/ignite
Posted by ak...@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/3bf880c1
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/3bf880c1
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/3bf880c1
Branch: refs/heads/ignite-4436-2
Commit: 3bf880c16e2787c44f62c4f1daf4c9f0fdab2dba
Parents: aaeda72 605d946
Author: agura <ag...@apache.org>
Authored: Thu Feb 9 20:34:53 2017 +0300
Committer: agura <ag...@apache.org>
Committed: Thu Feb 9 20:34:53 2017 +0300
----------------------------------------------------------------------
modules/yardstick/DEVNOTES-standalone.txt | 15 +++
modules/yardstick/DEVNOTES.txt | 20 ++--
modules/yardstick/README.txt | 119 +++++++++++++------
.../config/benchmark-sample.properties | 62 ++++++++++
modules/yardstick/pom.xml | 4 +-
pom.xml | 1 +
6 files changed, 172 insertions(+), 49 deletions(-)
----------------------------------------------------------------------
[18/31] ignite git commit: ignite-4499 Drop node from topology in
case when connection creation is impossible
Posted by ak...@apache.org.
ignite-4499 Drop node from topology in case when connection creation is impossible
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/f9aaf035
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/f9aaf035
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/f9aaf035
Branch: refs/heads/ignite-4436-2
Commit: f9aaf0353cea54afefea4caac74b1583eb17969b
Parents: ecf4b8b
Author: agura <agura>
Authored: Wed Jan 18 18:04:45 2017 +0300
Committer: agura <agura>
Committed: Wed Jan 18 18:04:45 2017 +0300
----------------------------------------------------------------------
.../apache/ignite/IgniteSystemProperties.java | 3 +
.../communication/tcp/TcpCommunicationSpi.java | 16 +
.../ignite/spi/discovery/tcp/ClientImpl.java | 88 ++++-
.../ignite/spi/discovery/tcp/ServerImpl.java | 61 ++--
.../messages/TcpDiscoveryAbstractMessage.java | 21 ++
.../tcp/TcpCommunicationSpiDropNodesTest.java | 322 +++++++++++++++++++
.../TcpCommunicationSpiFaultyClientTest.java | 270 ++++++++++++++++
.../ignite/testframework/GridTestNode.java | 1 +
.../testframework/junits/GridAbstractTest.java | 2 +
.../IgniteSpiCommunicationSelfTestSuite.java | 5 +
.../cache/IgniteCacheAbstractQuerySelfTest.java | 8 +-
11 files changed, 758 insertions(+), 39 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/f9aaf035/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java b/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
index 0da0f49..d77b2fb 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
@@ -65,6 +65,9 @@ public final class IgniteSystemProperties {
*/
public static final String IGNITE_NO_DISCO_ORDER = "IGNITE_NO_DISCO_ORDER";
+ /** Defines reconnect delay in milliseconds for client node that was failed forcible. */
+ public static final String IGNITE_DISCO_FAILED_CLIENT_RECONNECT_DELAY = "IGNITE_DISCO_FAILED_CLIENT_RECONNECT_DELAY";
+
/**
* If this system property is set to {@code false} - no checks for new versions will
* be performed by Ignite. By default, Ignite periodically checks for the new
http://git-wip-us.apache.org/repos/asf/ignite/blob/f9aaf035/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
index 1fe437c..94b7efe 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
@@ -94,6 +94,7 @@ import org.apache.ignite.internal.util.nio.ssl.GridSslMeta;
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;
import org.apache.ignite.internal.util.typedef.internal.LT;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
@@ -2550,6 +2551,21 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter
"operating system firewall is disabled on local and remote hosts) " +
"[addrs=" + addrs + ']');
+ if (getSpiContext().node(node.id()) != null && (CU.clientNode(node) || !CU.clientNode(getLocalNode())) &&
+ X.hasCause(errs, ConnectException.class, SocketTimeoutException.class, HandshakeTimeoutException.class,
+ IgniteSpiOperationTimeoutException.class)) {
+ LT.warn(log, "TcpCommunicationSpi failed to establish connection to node, node will be dropped from " +
+ "cluster [" +
+ "rmtNode=" + node +
+ ", err=" + errs +
+ ", connectErrs=" + Arrays.toString(errs.getSuppressed()) + ']');
+
+ getSpiContext().failNode(node.id(), "TcpCommunicationSpi failed to establish connection to node [" +
+ "rmtNode=" + node +
+ ", errs=" + errs +
+ ", connectErrs=" + Arrays.toString(errs.getSuppressed()) + ']');
+ }
+
throw errs;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/f9aaf035/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 9a1261c..35f0908 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
@@ -50,6 +50,7 @@ import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteClientDisconnectedException;
import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.IgniteSystemProperties;
import org.apache.ignite.cache.CacheMetrics;
import org.apache.ignite.cluster.ClusterMetrics;
import org.apache.ignite.cluster.ClusterNode;
@@ -100,6 +101,7 @@ import org.jetbrains.annotations.Nullable;
import org.jsr166.ConcurrentHashMap8;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
+import static org.apache.ignite.IgniteSystemProperties.IGNITE_DISCO_FAILED_CLIENT_RECONNECT_DELAY;
import static org.apache.ignite.events.EventType.EVT_CLIENT_NODE_DISCONNECTED;
import static org.apache.ignite.events.EventType.EVT_CLIENT_NODE_RECONNECTED;
import static org.apache.ignite.events.EventType.EVT_NODE_FAILED;
@@ -166,6 +168,9 @@ class ClientImpl extends TcpDiscoveryImpl {
/** */
protected MessageWorker msgWorker;
+ /** Force fail message for local node. */
+ private TcpDiscoveryNodeFailedMessage forceFailMsg;
+
/** */
@GridToStringExclude
private int joinCnt;
@@ -450,6 +455,8 @@ class ClientImpl extends TcpDiscoveryImpl {
msg.warning(warning);
+ msg.force(true);
+
msgWorker.addMessage(msg);
}
}
@@ -1396,6 +1403,14 @@ class ClientImpl extends TcpDiscoveryImpl {
else
leaveLatch.countDown();
}
+ else if (msg instanceof TcpDiscoveryNodeFailedMessage &&
+ ((TcpDiscoveryNodeFailedMessage)msg).failedNodeId().equals(locNode.id())) {
+ TcpDiscoveryNodeFailedMessage msg0 = (TcpDiscoveryNodeFailedMessage)msg;
+
+ assert msg0.force() : msg0;
+
+ forceFailMsg = msg0;
+ }
else if (msg instanceof SocketClosedMessage) {
if (((SocketClosedMessage)msg).sock == currSock) {
currSock = null;
@@ -1412,25 +1427,45 @@ class ClientImpl extends TcpDiscoveryImpl {
}
}
else {
- if (log.isDebugEnabled())
- log.debug("Connection closed, will try to restore connection.");
+ if (forceFailMsg != null) {
+ if (log.isDebugEnabled()) {
+ log.debug("Connection closed, local node received force fail message, " +
+ "will not try to restore connection");
+ }
+
+ queue.addFirst(SPI_RECONNECT_FAILED);
+ }
+ else {
+ if (log.isDebugEnabled())
+ log.debug("Connection closed, will try to restore connection.");
- assert reconnector == null;
+ assert reconnector == null;
- final Reconnector reconnector = new Reconnector(join);
- this.reconnector = reconnector;
- reconnector.start();
+ final Reconnector reconnector = new Reconnector(join);
+ this.reconnector = reconnector;
+ reconnector.start();
+ }
}
}
}
else if (msg == SPI_RECONNECT_FAILED) {
- reconnector.cancel();
- reconnector.join();
+ if (reconnector != null) {
+ reconnector.cancel();
+ reconnector.join();
- reconnector = null;
+ reconnector = null;
+ }
+ else
+ assert forceFailMsg != null;
if (spi.isClientReconnectDisabled()) {
if (state != SEGMENTED && state != STOPPED) {
+ if (forceFailMsg != null) {
+ U.quietAndWarn(log, "Local node was dropped from cluster due to network problems " +
+ "[nodeInitiatedFail=" + forceFailMsg.creatorNodeId() +
+ ", msg=" + forceFailMsg.warning() + ']');
+ }
+
if (log.isDebugEnabled()) {
log.debug("Failed to restore closed connection, reconnect disabled, " +
"local node segmented [networkTimeout=" + spi.netTimeout + ']');
@@ -1445,7 +1480,9 @@ class ClientImpl extends TcpDiscoveryImpl {
if (state == STARTING || state == CONNECTED) {
if (log.isDebugEnabled()) {
log.debug("Failed to restore closed connection, will try to reconnect " +
- "[networkTimeout=" + spi.netTimeout + ", joinTimeout=" + spi.joinTimeout + ']');
+ "[networkTimeout=" + spi.netTimeout +
+ ", joinTimeout=" + spi.joinTimeout +
+ ", failMsg=" + forceFailMsg + ']');
}
state = DISCONNECTED;
@@ -1468,7 +1505,36 @@ class ClientImpl extends TcpDiscoveryImpl {
UUID newId = UUID.randomUUID();
- if (log.isInfoEnabled()) {
+ if (forceFailMsg != null) {
+ long delay = IgniteSystemProperties.getLong(IGNITE_DISCO_FAILED_CLIENT_RECONNECT_DELAY,
+ 10_000);
+
+ if (delay > 0) {
+ U.quietAndWarn(log, "Local node was dropped from cluster due to network problems, " +
+ "will try to reconnect with new id after " + delay + "ms (reconnect delay " +
+ "can be changed using IGNITE_DISCO_FAILED_CLIENT_RECONNECT_DELAY system " +
+ "property) [" +
+ "newId=" + newId +
+ ", prevId=" + locNode.id() +
+ ", locNode=" + locNode +
+ ", nodeInitiatedFail=" + forceFailMsg.creatorNodeId() +
+ ", msg=" + forceFailMsg.warning() + ']');
+
+ Thread.sleep(delay);
+ }
+ else {
+ U.quietAndWarn(log, "Local node was dropped from cluster due to network problems, " +
+ "will try to reconnect with new id [" +
+ "newId=" + newId +
+ ", prevId=" + locNode.id() +
+ ", locNode=" + locNode +
+ ", nodeInitiatedFail=" + forceFailMsg.creatorNodeId() +
+ ", msg=" + forceFailMsg.warning() + ']');
+ }
+
+ forceFailMsg = null;
+ }
+ else if (log.isInfoEnabled()) {
log.info("Client node disconnected from cluster, will try to reconnect with new id " +
"[newId=" + newId + ", prevId=" + locNode.id() + ", locNode=" + locNode + ']');
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/f9aaf035/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
index 40da281..f33566c 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
@@ -775,6 +775,8 @@ class ServerImpl extends TcpDiscoveryImpl {
msg.warning(warning);
+ msg.force(true);
+
msgWorker.addMessage(msg);
}
}
@@ -4610,8 +4612,12 @@ class ServerImpl extends TcpDiscoveryImpl {
else {
boolean contains;
+ UUID creatorId = msg.creatorNodeId();
+
+ assert creatorId != null : msg;
+
synchronized (mux) {
- contains = failedNodes.containsKey(sndNode);
+ contains = failedNodes.containsKey(sndNode) || ring.node(creatorId) == null;
}
if (contains) {
@@ -4623,25 +4629,29 @@ class ServerImpl extends TcpDiscoveryImpl {
}
}
- UUID nodeId = msg.failedNodeId();
+ UUID failedNodeId = msg.failedNodeId();
long order = msg.order();
- TcpDiscoveryNode node = ring.node(nodeId);
+ TcpDiscoveryNode failedNode = ring.node(failedNodeId);
- if (node != null && node.internalOrder() != order) {
+ if (failedNode != null && failedNode.internalOrder() != order) {
if (log.isDebugEnabled())
log.debug("Ignoring node failed message since node internal order does not match " +
- "[msg=" + msg + ", node=" + node + ']');
+ "[msg=" + msg + ", node=" + failedNode + ']');
return;
}
- if (node != null) {
- assert !node.isLocal() || !msg.verified() : msg;
+ if (failedNode != null) {
+ assert !failedNode.isLocal() || !msg.verified() : msg;
- synchronized (mux) {
- if (!failedNodes.containsKey(node))
- failedNodes.put(node, msg.senderNodeId() != null ? msg.senderNodeId() : getLocalNodeId());
+ boolean skipUpdateFailedNodes = msg.force() && !msg.verified();
+
+ if (!skipUpdateFailedNodes) {
+ synchronized (mux) {
+ if (!failedNodes.containsKey(failedNode))
+ failedNodes.put(failedNode, msg.senderNodeId() != null ? msg.senderNodeId() : getLocalNodeId());
+ }
}
}
else {
@@ -4668,11 +4678,11 @@ class ServerImpl extends TcpDiscoveryImpl {
}
if (msg.verified()) {
- node = ring.removeNode(nodeId);
+ failedNode = ring.removeNode(failedNodeId);
- interruptPing(node);
+ interruptPing(failedNode);
- assert node != null;
+ assert failedNode != null;
long topVer;
@@ -4698,16 +4708,18 @@ class ServerImpl extends TcpDiscoveryImpl {
}
synchronized (mux) {
- failedNodes.remove(node);
+ failedNodes.remove(failedNode);
- leavingNodes.remove(node);
+ leavingNodes.remove(failedNode);
- failedNodesMsgSent.remove(node.id());
+ failedNodesMsgSent.remove(failedNode.id());
- ClientMessageWorker worker = clientMsgWorkers.remove(node.id());
+ if (!msg.force()) { // ClientMessageWorker will stop after sending force fail message.
+ ClientMessageWorker worker = clientMsgWorkers.remove(failedNode.id());
- if (worker != null)
- worker.interrupt();
+ if (worker != null)
+ worker.interrupt();
+ }
}
if (msg.warning() != null && !msg.creatorNodeId().equals(getLocalNodeId())) {
@@ -4719,10 +4731,10 @@ class ServerImpl extends TcpDiscoveryImpl {
}
synchronized (mux) {
- joiningNodes.remove(node.id());
+ joiningNodes.remove(failedNode.id());
}
- notifyDiscovery(EVT_NODE_FAILED, topVer, node);
+ notifyDiscovery(EVT_NODE_FAILED, topVer, failedNode);
spi.stats.onNodeFailed();
}
@@ -6317,7 +6329,12 @@ class ServerImpl extends TcpDiscoveryImpl {
spi.failureDetectionTimeout() : spi.getSocketTimeout());
}
- success = true;
+ boolean clientFailed = msg instanceof TcpDiscoveryNodeFailedMessage &&
+ ((TcpDiscoveryNodeFailedMessage)msg).failedNodeId().equals(clientNodeId);
+
+ assert !clientFailed || msg.force() : msg;
+
+ success = !clientFailed;
}
catch (IgniteCheckedException | IOException e) {
if (log.isDebugEnabled())
http://git-wip-us.apache.org/repos/asf/ignite/blob/f9aaf035/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryAbstractMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryAbstractMessage.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryAbstractMessage.java
index 783a113..e982b2f 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryAbstractMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryAbstractMessage.java
@@ -48,6 +48,9 @@ public abstract class TcpDiscoveryAbstractMessage implements Serializable {
/** */
protected static final int CLIENT_ACK_FLAG_POS = 4;
+ /** */
+ protected static final int FORCE_FAIL_FLAG_POS = 8;
+
/** Sender of the message (transient). */
private transient UUID sndNodeId;
@@ -205,6 +208,24 @@ public abstract class TcpDiscoveryAbstractMessage implements Serializable {
}
/**
+ * Get force fail node flag.
+ *
+ * @return Force fail node flag.
+ */
+ public boolean force() {
+ return getFlag(FORCE_FAIL_FLAG_POS);
+ }
+
+ /**
+ * Sets force fail node flag.
+ *
+ * @param force Force fail node flag.
+ */
+ public void force(boolean force) {
+ setFlag(FORCE_FAIL_FLAG_POS, force);
+ }
+
+ /**
* @return Pending message index.
*/
public short pendingIndex() {
http://git-wip-us.apache.org/repos/asf/ignite/blob/f9aaf035/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpiDropNodesTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpiDropNodesTest.java b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpiDropNodesTest.java
new file mode 100644
index 0000000..d29231e
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpiDropNodesTest.java
@@ -0,0 +1,322 @@
+/*
+ * 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.spi.communication.tcp;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.Callable;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.CyclicBarrier;
+import java.util.concurrent.TimeUnit;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.events.Event;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.util.lang.GridAbsPredicate;
+import org.apache.ignite.internal.util.nio.GridCommunicationClient;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteBiPredicate;
+import org.apache.ignite.lang.IgnitePredicate;
+import org.apache.ignite.lang.IgniteRunnable;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryNode;
+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;
+
+import static org.apache.ignite.events.EventType.EVT_NODE_FAILED;
+
+/**
+ *
+ */
+public class TcpCommunicationSpiDropNodesTest extends GridCommonAbstractTest {
+ /** IP finder. */
+ private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+ /** Nodes count. */
+ private static final int NODES_CNT = 4;
+
+ /** Block. */
+ private static volatile boolean block;
+
+ /** Predicate. */
+ private static IgniteBiPredicate<ClusterNode, ClusterNode> pred;
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ cfg.setClockSyncFrequency(300000);
+ cfg.setFailureDetectionTimeout(1000);
+
+ TestCommunicationSpi spi = new TestCommunicationSpi();
+
+ spi.setIdleConnectionTimeout(100);
+ spi.setSharedMemoryPort(-1);
+
+ TcpDiscoverySpi discoSpi = (TcpDiscoverySpi) cfg.getDiscoverySpi();
+ discoSpi.setIpFinder(IP_FINDER);
+
+ cfg.setCommunicationSpi(spi);
+ cfg.setDiscoverySpi(discoSpi);
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTest() throws Exception {
+ super.beforeTest();
+
+ block = false;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ super.afterTest();
+
+ stopAllGrids();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testOneNode() throws Exception {
+ pred = new IgniteBiPredicate<ClusterNode, ClusterNode>() {
+ @Override public boolean apply(ClusterNode locNode, ClusterNode rmtNode) {
+ return block && rmtNode.order() == 3;
+ }
+ };
+
+ startGrids(NODES_CNT);
+
+ final CountDownLatch latch = new CountDownLatch(1);
+
+ grid(0).events().localListen(new IgnitePredicate<Event>() {
+ @Override
+ public boolean apply(Event event) {
+ latch.countDown();
+
+ return true;
+ }
+ }, EVT_NODE_FAILED);
+
+ U.sleep(1000); // Wait for write timeout and closing idle connections.
+
+ block = true;
+
+ grid(0).compute().broadcast(new IgniteRunnable() {
+ @Override public void run() {
+ // No-op.
+ }
+ });
+
+ assertTrue(latch.await(15, TimeUnit.SECONDS));
+
+ assertTrue(GridTestUtils.waitForCondition(new GridAbsPredicate() {
+ @Override public boolean apply() {
+ return grid(3).cluster().topologyVersion() == NODES_CNT + 1;
+ }
+ }, 5000));
+
+ for (int i = 0; i < 10; i++) {
+ U.sleep(1000);
+
+ assertEquals(NODES_CNT - 1, grid(0).cluster().nodes().size());
+
+ int liveNodesCnt = 0;
+
+ for (int j = 0; j < NODES_CNT; j++) {
+ IgniteEx ignite;
+
+ try {
+ ignite = grid(j);
+
+ log.info("Checking topology for grid(" + j + "): " + ignite.cluster().nodes());
+
+ ClusterNode locNode = ignite.localNode();
+
+ if (locNode.order() != 3) {
+ assertEquals(NODES_CNT - 1, ignite.cluster().nodes().size());
+
+ for (ClusterNode node : ignite.cluster().nodes())
+ assertTrue(node.order() != 3);
+
+ liveNodesCnt++;
+ }
+ }
+ catch (Exception e) {
+ log.info("Checking topology for grid(" + j + "): no grid in topology.");
+ }
+ }
+
+ assertEquals(NODES_CNT - 1, liveNodesCnt);
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testTwoNodesEachOther() throws Exception {
+ pred = new IgniteBiPredicate<ClusterNode, ClusterNode>() {
+ @Override public boolean apply(ClusterNode locNode, ClusterNode rmtNode) {
+ return block && (locNode.order() == 2 || locNode.order() == 4) &&
+ (rmtNode.order() == 2 || rmtNode.order() == 4);
+ }
+ };
+
+ startGrids(NODES_CNT);
+
+ final CountDownLatch latch = new CountDownLatch(1);
+
+ grid(0).events().localListen(new IgnitePredicate<Event>() {
+ @Override
+ public boolean apply(Event event) {
+ latch.countDown();
+
+ return true;
+ }
+ }, EVT_NODE_FAILED);
+
+ U.sleep(1000); // Wait for write timeout and closing idle connections.
+
+ block = true;
+
+ final CyclicBarrier barrier = new CyclicBarrier(2);
+
+ IgniteInternalFuture<Void> fut1 = GridTestUtils.runAsync(new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ barrier.await();
+
+ grid(1).compute().withNoFailover().broadcast(new IgniteRunnable() {
+ @Override public void run() {
+ // No-op.
+ }
+ });
+
+ return null;
+ }
+ });
+
+ IgniteInternalFuture<Void> fut2 = GridTestUtils.runAsync(new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ barrier.await();
+
+ grid(3).compute().withNoFailover().broadcast(new IgniteRunnable() {
+ @Override public void run() {
+ // No-op.
+ }
+ });
+
+ return null;
+ }
+ });
+
+ assertTrue(latch.await(5, TimeUnit.SECONDS));
+
+ GridTestUtils.waitForCondition(new GridAbsPredicate() {
+ @Override public boolean apply() {
+ return grid(2).cluster().nodes().size() == NODES_CNT - 1;
+ }
+ }, 5000);
+
+ try {
+ fut1.get();
+ }
+ catch (IgniteCheckedException e) {
+ // No-op.
+ }
+
+ try {
+ fut2.get();
+ }
+ catch (IgniteCheckedException e) {
+ // No-op.
+ }
+
+ long failedNodeOrder = 1 + 2 + 3 + 4;
+
+ for (ClusterNode node : grid(0).cluster().nodes())
+ failedNodeOrder -= node.order();
+
+ for (int i = 0; i < 10; i++) {
+ U.sleep(1000);
+
+ assertEquals(NODES_CNT - 1, grid(0).cluster().nodes().size());
+
+ int liveNodesCnt = 0;
+
+ for (int j = 0; j < NODES_CNT; j++) {
+ IgniteEx ignite;
+
+ try {
+ ignite = grid(j);
+
+ log.info("Checking topology for grid(" + j + "): " + ignite.cluster().nodes());
+
+ ClusterNode locNode = ignite.localNode();
+
+ if (locNode.order() != failedNodeOrder) {
+ assertEquals(NODES_CNT - 1, ignite.cluster().nodes().size());
+
+ for (ClusterNode node : ignite.cluster().nodes())
+ assertTrue(node.order() != failedNodeOrder);
+
+ liveNodesCnt++;
+ }
+ }
+ catch (Exception e) {
+ log.info("Checking topology for grid(" + j + "): no grid in topology.");
+ }
+ }
+
+ assertEquals(NODES_CNT - 1, liveNodesCnt);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class TestCommunicationSpi extends TcpCommunicationSpi {
+ /** {@inheritDoc} */
+ @Override protected GridCommunicationClient createTcpClient(ClusterNode node) throws IgniteCheckedException {
+ if (pred.apply(getLocalNode(), node)) {
+ Map<String, Object> attrs = new HashMap<>(node.attributes());
+
+ attrs.put(createAttributeName(ATTR_ADDRS), Collections.singleton("127.0.0.1"));
+ attrs.put(createAttributeName(ATTR_PORT), 47200);
+ attrs.put(createAttributeName(ATTR_EXT_ADDRS), Collections.emptyList());
+ attrs.put(createAttributeName(ATTR_HOST_NAMES), Collections.emptyList());
+
+ ((TcpDiscoveryNode)node).setAttributes(attrs);
+ }
+
+ return super.createTcpClient(node);
+ }
+
+ /**
+ * @param name Name.
+ */
+ private String createAttributeName(String name) {
+ return getClass().getSimpleName() + '.' + name;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/f9aaf035/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpiFaultyClientTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpiFaultyClientTest.java b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpiFaultyClientTest.java
new file mode 100644
index 0000000..6e99487
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpiFaultyClientTest.java
@@ -0,0 +1,270 @@
+/*
+ * 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.spi.communication.tcp;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.InetAddress;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.events.Event;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.IgniteInterruptedCheckedException;
+import org.apache.ignite.internal.util.lang.GridAbsPredicate;
+import org.apache.ignite.internal.util.nio.GridCommunicationClient;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgnitePredicate;
+import org.apache.ignite.lang.IgniteRunnable;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryNode;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage;
+import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryNodeFailedMessage;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+import static org.apache.ignite.events.EventType.EVT_NODE_FAILED;
+
+/**
+ * Tests that faulty client will be failed if connection can't be established.
+ */
+public class TcpCommunicationSpiFaultyClientTest extends GridCommonAbstractTest {
+ /** */
+ private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+ /** Predicate. */
+ private static final IgnitePredicate<ClusterNode> PRED = new IgnitePredicate<ClusterNode>() {
+ @Override public boolean apply(ClusterNode node) {
+ return block && node.order() == 3;
+ }
+ };
+
+ /** Client mode. */
+ private static boolean clientMode;
+
+ /** Block. */
+ private static volatile boolean block;
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ cfg.setClockSyncFrequency(300000);
+ cfg.setFailureDetectionTimeout(1000);
+ cfg.setClientMode(clientMode);
+
+ TestCommunicationSpi spi = new TestCommunicationSpi();
+
+ spi.setIdleConnectionTimeout(100);
+ spi.setSharedMemoryPort(-1);
+
+ TcpDiscoverySpi discoSpi = (TcpDiscoverySpi) cfg.getDiscoverySpi();
+
+ discoSpi.setIpFinder(IP_FINDER);
+ discoSpi.setClientReconnectDisabled(true);
+
+ cfg.setCommunicationSpi(spi);
+ cfg.setDiscoverySpi(discoSpi);
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTest() throws Exception {
+ super.beforeTest();
+
+ block = false;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ super.afterTest();
+
+ stopAllGrids();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testNoServerOnHost() throws Exception {
+ testFailClient(null);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testNotAcceptedConnection() throws Exception {
+ testFailClient(new FakeServer());
+ }
+
+ /**
+ * @param srv Server.
+ * @throws Exception If failed.
+ */
+ private void testFailClient(FakeServer srv) throws Exception {
+ IgniteInternalFuture<Long> fut = null;
+
+ try {
+ if (srv != null)
+ fut = GridTestUtils.runMultiThreadedAsync(srv, 1, "fake-server");
+
+ clientMode = false;
+
+ startGrids(2);
+
+ clientMode = true;
+
+ startGrid(2);
+ startGrid(3);
+
+ U.sleep(1000); // Wait for write timeout and closing idle connections.
+
+ final CountDownLatch latch = new CountDownLatch(1);
+
+ grid(0).events().localListen(new IgnitePredicate<Event>() {
+ @Override
+ public boolean apply(Event event) {
+ latch.countDown();
+
+ return true;
+ }
+ }, EVT_NODE_FAILED);
+
+ block = true;
+
+ try {
+ grid(0).compute(grid(0).cluster().forClients()).withNoFailover().broadcast(new IgniteRunnable() {
+ @Override public void run() {
+ // No-op.
+ }
+ });
+ }
+ catch (IgniteException e) {
+ // No-op.
+ }
+
+ assertTrue(latch.await(3, TimeUnit.SECONDS));
+
+ assertTrue(GridTestUtils.waitForCondition(new GridAbsPredicate() {
+ @Override public boolean apply() {
+ return grid(0).cluster().forClients().nodes().size() == 1;
+ }
+ }, 5000));
+
+ for (int i = 0; i < 5; i++) {
+ U.sleep(1000);
+
+ log.info("Check topology (" + (i + 1) + "): " + grid(0).cluster().nodes());
+
+ assertEquals(1, grid(0).cluster().forClients().nodes().size());
+ }
+ }
+ finally {
+ if (srv != null) {
+ srv.stop();
+
+ assert fut != null;
+
+ fut.get();
+ }
+
+ stopAllGrids();
+ }
+ }
+
+ /**
+ * Server that emulates connection troubles.
+ */
+ private static class FakeServer implements Runnable {
+ /** Server. */
+ private final ServerSocket srv;
+
+ /** Stop. */
+ private volatile boolean stop;
+
+ /**
+ * Default constructor.
+ */
+ FakeServer() throws IOException {
+ this.srv = new ServerSocket(47200, 50, InetAddress.getByName("127.0.0.1"));
+ }
+
+ /**
+ *
+ */
+ public void stop() {
+ stop = true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void run() {
+ try {
+ while (!stop) {
+ try {
+ U.sleep(10);
+ }
+ catch (IgniteInterruptedCheckedException e) {
+ // No-op.
+ }
+ }
+ }
+ finally {
+ U.closeQuiet(srv);
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ private static class TestCommunicationSpi extends TcpCommunicationSpi {
+ /** {@inheritDoc} */
+ @Override protected GridCommunicationClient createTcpClient(ClusterNode node) throws IgniteCheckedException {
+ if (PRED.apply(node)) {
+ Map<String, Object> attrs = new HashMap<>(node.attributes());
+
+ attrs.put(createAttributeName(ATTR_ADDRS), Collections.singleton("127.0.0.1"));
+ attrs.put(createAttributeName(ATTR_PORT), 47200);
+ attrs.put(createAttributeName(ATTR_EXT_ADDRS), Collections.emptyList());
+ attrs.put(createAttributeName(ATTR_HOST_NAMES), Collections.emptyList());
+
+ ((TcpDiscoveryNode)node).setAttributes(attrs);
+ }
+
+ return super.createTcpClient(node);
+ }
+
+ /**
+ * @param name Name.
+ */
+ private String createAttributeName(String name) {
+ return getClass().getSimpleName() + '.' + name;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/f9aaf035/modules/core/src/test/java/org/apache/ignite/testframework/GridTestNode.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/GridTestNode.java b/modules/core/src/test/java/org/apache/ignite/testframework/GridTestNode.java
index e0e8eba..6365443 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/GridTestNode.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/GridTestNode.java
@@ -82,6 +82,7 @@ public class GridTestNode extends GridMetadataAwareAdapter implements ClusterNod
private void initAttributes() {
attrs.put(IgniteNodeAttributes.ATTR_BUILD_VER, "10");
attrs.put(IgniteNodeAttributes.ATTR_GRID_NAME, "null");
+ attrs.put(IgniteNodeAttributes.ATTR_CLIENT_MODE, false);
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/f9aaf035/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
index 9f507e6..ffaec4f 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
@@ -102,6 +102,7 @@ import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;
+import static org.apache.ignite.IgniteSystemProperties.IGNITE_DISCO_FAILED_CLIENT_RECONNECT_DELAY;
import static org.apache.ignite.cache.CacheAtomicWriteOrderMode.PRIMARY;
import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
@@ -173,6 +174,7 @@ public abstract class GridAbstractTest extends TestCase {
static {
System.setProperty(IgniteSystemProperties.IGNITE_ATOMIC_CACHE_DELETE_HISTORY_SIZE, "10000");
System.setProperty(IgniteSystemProperties.IGNITE_UPDATE_NOTIFIER, "false");
+ System.setProperty(IGNITE_DISCO_FAILED_CLIENT_RECONNECT_DELAY, "1");
if (BINARY_MARSHALLER)
GridTestProperties.setProperty(GridTestProperties.MARSH_CLASS_NAME, BinaryMarshaller.class.getName());
http://git-wip-us.apache.org/repos/asf/ignite/blob/f9aaf035/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiCommunicationSelfTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiCommunicationSelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiCommunicationSelfTestSuite.java
index c557fbb..ddc2551 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiCommunicationSelfTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiCommunicationSelfTestSuite.java
@@ -35,6 +35,8 @@ import org.apache.ignite.spi.communication.tcp.GridTcpCommunicationSpiTcpFailure
import org.apache.ignite.spi.communication.tcp.GridTcpCommunicationSpiTcpNoDelayOffSelfTest;
import org.apache.ignite.spi.communication.tcp.GridTcpCommunicationSpiTcpSelfTest;
import org.apache.ignite.spi.communication.tcp.IgniteTcpCommunicationRecoveryAckClosureSelfTest;
+import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpiDropNodesTest;
+import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpiFaultyClientTest;
/**
* Test suite for all communication SPIs.
@@ -72,6 +74,9 @@ public class IgniteSpiCommunicationSelfTestSuite extends TestSuite {
suite.addTest(new TestSuite(GridTcpCommunicationSpiConfigSelfTest.class));
+ suite.addTest(new TestSuite(TcpCommunicationSpiFaultyClientTest.class));
+ suite.addTest(new TestSuite(TcpCommunicationSpiDropNodesTest.class));
+
return suite;
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/f9aaf035/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java
index 7e0d20b..9f56877 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java
@@ -633,7 +633,7 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
assertEquals(2, qry.getAll().size());
- Throwable throwable = GridTestUtils.assertThrowsInherited(log, new GridPlainCallable<Void>() {
+ GridTestUtils.assertThrows(log, new GridPlainCallable<Void>() {
@Override public Void call() throws Exception {
QueryCursor<Cache.Entry<Integer, Type1>> qry =
cache.query(new SqlQuery<Integer, Type1>(Type1.class, "FROM Type1"));
@@ -642,11 +642,7 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
return null;
}
- }, RuntimeException.class, null);
-
- assertNotNull(throwable);
-
- assertTrue(throwable instanceof IgniteException || throwable instanceof CacheException);
+ }, CacheException.class, null);
}
/**
[28/31] ignite git commit: ignite-3994 GridContinuousHandler cleanup
on client disconnect. This closes #1496.
Posted by ak...@apache.org.
ignite-3994 GridContinuousHandler cleanup on client disconnect.
This closes #1496.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/2f4bdbb6
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/2f4bdbb6
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/2f4bdbb6
Branch: refs/heads/ignite-4436-2
Commit: 2f4bdbb674e5634ce4c1a3432dede4c865977fde
Parents: 543a65f
Author: vdpyatkov <vp...@gridgain.com>
Authored: Fri Feb 10 15:08:45 2017 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Fri Feb 10 15:09:53 2017 +0300
----------------------------------------------------------------------
.../internal/GridEventConsumeHandler.java | 5 +
.../internal/GridMessageListenHandler.java | 5 +
.../continuous/CacheContinuousQueryHandler.java | 16 ++
.../continuous/GridContinuousHandler.java | 5 +
.../continuous/GridContinuousProcessor.java | 3 +
.../ClientReconnectContinuousQueryTest.java | 201 +++++++++++++++++++
.../IgniteCacheQuerySelfTestSuite3.java | 2 +
7 files changed, 237 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/2f4bdbb6/modules/core/src/main/java/org/apache/ignite/internal/GridEventConsumeHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridEventConsumeHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/GridEventConsumeHandler.java
index 68d34ce..0395434 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/GridEventConsumeHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/GridEventConsumeHandler.java
@@ -392,6 +392,11 @@ class GridEventConsumeHandler implements GridContinuousHandler {
}
/** {@inheritDoc} */
+ @Override public void onClientDisconnected() {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
@Override public void onBatchAcknowledged(UUID routineId, GridContinuousBatch batch, GridKernalContext ctx) {
// No-op.
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2f4bdbb6/modules/core/src/main/java/org/apache/ignite/internal/GridMessageListenHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridMessageListenHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/GridMessageListenHandler.java
index 0eeaa8a..88d4450 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/GridMessageListenHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/GridMessageListenHandler.java
@@ -199,6 +199,11 @@ public class GridMessageListenHandler implements GridContinuousHandler {
}
/** {@inheritDoc} */
+ @Override public void onClientDisconnected() {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
@Override public void onBatchAcknowledged(UUID routineId, GridContinuousBatch batch, GridKernalContext ctx) {
// No-op.
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2f4bdbb6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
index a9a7d7c..b3f0684 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
@@ -854,6 +854,15 @@ public class CacheContinuousQueryHandler<K, V> implements GridContinuousHandler
return ctx.security().enabled() ? ctx.task().resolveTaskName(taskHash) : null;
}
+ /** {@inheritDoc} */
+ @Override public void onClientDisconnected() {
+ if (internal)
+ return;
+
+ for (PartitionRecovery rec : rcvs.values())
+ rec.resetTopologyCache();
+ }
+
/**
* @param ctx Context.
* @param partId Partition id.
@@ -972,6 +981,13 @@ public class CacheContinuousQueryHandler<K, V> implements GridContinuousHandler
}
/**
+ * Resets cached topology.
+ */
+ void resetTopologyCache() {
+ curTop = AffinityTopologyVersion.NONE;
+ }
+
+ /**
* Add continuous entry.
*
* @param cctx Cache context.
http://git-wip-us.apache.org/repos/asf/ignite/blob/2f4bdbb6/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousHandler.java
index f14b450..2a3a052 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousHandler.java
@@ -99,6 +99,11 @@ public interface GridContinuousHandler extends Externalizable, Cloneable {
public GridContinuousBatch createBatch();
/**
+ * Client node disconnected callback.
+ */
+ public void onClientDisconnected();
+
+ /**
* Called when ack for a batch is received from client.
*
* @param routineId Routine ID.
http://git-wip-us.apache.org/repos/asf/ignite/blob/2f4bdbb6/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java
index 9fd9b6d..b9f42e1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java
@@ -912,6 +912,9 @@ public class GridContinuousProcessor extends GridProcessorAdapter {
unregisterRemote(e.getKey());
}
+ for (LocalRoutineInfo routine : locInfos.values())
+ routine.hnd.onClientDisconnected();
+
rmtInfos.clear();
clientInfos.clear();
http://git-wip-us.apache.org/repos/asf/ignite/blob/2f4bdbb6/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/ClientReconnectContinuousQueryTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/ClientReconnectContinuousQueryTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/ClientReconnectContinuousQueryTest.java
new file mode 100644
index 0000000..feded14
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/ClientReconnectContinuousQueryTest.java
@@ -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.
+ */
+
+package org.apache.ignite.internal.processors.cache.query.continuous;
+
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import javax.cache.event.CacheEntryListenerException;
+import javax.cache.event.CacheEntryUpdatedListener;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.query.ContinuousQuery;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.events.Event;
+import org.apache.ignite.events.EventType;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.managers.communication.GridIoManager;
+import org.apache.ignite.internal.util.nio.GridNioServer;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgnitePredicate;
+import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/**
+ *
+ */
+public class ClientReconnectContinuousQueryTest extends GridCommonAbstractTest {
+ /** Client index. */
+ private static final int CLIENT_IDX = 1;
+
+ /** Puts before reconnect. */
+ private static final int PUTS_BEFORE_RECONNECT = 50;
+
+ /** Puts after reconnect. */
+ private static final int PUTS_AFTER_RECONNECT = 50;
+
+ /** Recon latch. */
+ private static final CountDownLatch reconLatch = new CountDownLatch(1);
+
+ /** Discon latch. */
+ private static final CountDownLatch disconLatch = new CountDownLatch(1);
+
+ /** Updater received. */
+ private static final CountDownLatch updaterReceived = new CountDownLatch(PUTS_BEFORE_RECONNECT);
+
+ /** Receiver after reconnect. */
+ private static final CountDownLatch receiverAfterReconnect = new CountDownLatch(PUTS_AFTER_RECONNECT);
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ TcpCommunicationSpi commSpi = (TcpCommunicationSpi)cfg.getCommunicationSpi();
+
+ commSpi.setSlowClientQueueLimit(50);
+ commSpi.setIdleConnectionTimeout(300_000);
+
+ if (getTestGridName(CLIENT_IDX).equals(gridName))
+ cfg.setClientMode(true);
+ else {
+ CacheConfiguration ccfg = defaultCacheConfiguration();
+
+ cfg.setCacheConfiguration(ccfg);
+ }
+
+ return cfg;
+ }
+
+ /**
+ * Test client reconnect to alive grid.
+ *
+ * @throws Exception If failed.
+ */
+ public void testClientReconnect() throws Exception {
+ try {
+ startGrids(2);
+
+ IgniteEx client = grid(CLIENT_IDX);
+
+ client.events().localListen(new DisconnectListener(), EventType.EVT_CLIENT_NODE_DISCONNECTED);
+
+ client.events().localListen(new ReconnectListener(), EventType.EVT_CLIENT_NODE_RECONNECTED);
+
+ IgniteCache cache = client.cache(null);
+
+ ContinuousQuery qry = new ContinuousQuery();
+
+ qry.setLocalListener(new CQListener());
+
+ cache.query(qry);
+
+ putSomeKeys(PUTS_BEFORE_RECONNECT);
+
+ info("updaterReceived Count: " + updaterReceived.getCount());
+
+ assertTrue(updaterReceived.await(10_000, TimeUnit.MILLISECONDS));
+
+ skipRead(client, true);
+
+ putSomeKeys(1_000);
+
+ assertTrue(disconLatch.await(10_000, TimeUnit.MILLISECONDS));
+
+ skipRead(client, false);
+
+ assertTrue(reconLatch.await(10_000, TimeUnit.MILLISECONDS));
+
+ putSomeKeys(PUTS_AFTER_RECONNECT);
+
+ info("receiverAfterReconnect Count: " + receiverAfterReconnect.getCount());
+
+ assertTrue(receiverAfterReconnect.await(10_000, TimeUnit.MILLISECONDS));
+ }
+ finally {
+ stopAllGrids();
+ }
+
+ }
+
+ /**
+ *
+ */
+ private static class ReconnectListener implements IgnitePredicate<Event> {
+ /** {@inheritDoc} */
+ @Override public boolean apply(Event evt) {
+ reconLatch.countDown();
+
+ return false;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class DisconnectListener implements IgnitePredicate<Event> {
+ /** {@inheritDoc} */
+ @Override public boolean apply(Event evt) {
+ disconLatch.countDown();
+
+ return false;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class CQListener implements CacheEntryUpdatedListener {
+ /** {@inheritDoc} */
+ @Override public void onUpdated(Iterable iterable) throws CacheEntryListenerException {
+ if (reconLatch.getCount() != 0) {
+ for (Object o : iterable)
+ updaterReceived.countDown();
+ }
+ else {
+ for (Object o : iterable)
+ receiverAfterReconnect.countDown();
+ }
+ }
+ }
+
+ /**
+ * @param cnt Number of keys.
+ */
+ private void putSomeKeys(int cnt) {
+ IgniteEx ignite = grid(0);
+
+ IgniteCache<Object, Object> srvCache = ignite.cache(null);
+
+ for (int i = 0; i < cnt; i++)
+ srvCache.put(0, i);
+ }
+
+ /**
+ * @param igniteClient Ignite client.
+ * @param skip Skip.
+ */
+ private void skipRead(IgniteEx igniteClient, boolean skip) {
+ GridIoManager ioMgr = igniteClient.context().io();
+
+ TcpCommunicationSpi commSpi = (TcpCommunicationSpi)((Object[])U.field(ioMgr, "spis"))[0];
+
+ GridNioServer nioSrvr = U.field(commSpi, "nioSrvr");
+
+ GridTestUtils.setFieldValue(nioSrvr, "skipRead", skip);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2f4bdbb6/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite3.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite3.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite3.java
index a865788..07125a6 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite3.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite3.java
@@ -34,6 +34,7 @@ import org.apache.ignite.internal.processors.cache.query.continuous.CacheKeepBin
import org.apache.ignite.internal.processors.cache.query.continuous.CacheKeepBinaryIterationTest;
import org.apache.ignite.internal.processors.cache.query.continuous.CacheKeepBinaryIterationStoreEnabledTest;
import org.apache.ignite.internal.processors.cache.query.continuous.CacheKeepBinaryIterationSwapEnabledTest;
+import org.apache.ignite.internal.processors.cache.query.continuous.ClientReconnectContinuousQueryTest;
import org.apache.ignite.internal.processors.cache.query.continuous.ContinuousQueryRemoteFilterMissingInClassPathSelfTest;
import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryAtomicNearEnabledSelfTest;
import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryAtomicOffheapTieredTest;
@@ -123,6 +124,7 @@ public class IgniteCacheQuerySelfTestSuite3 extends TestSuite {
suite.addTestSuite(CacheKeepBinaryIterationNearEnabledTest.class);
suite.addTestSuite(IgniteCacheContinuousQueryBackupQueueTest.class);
suite.addTestSuite(IgniteCacheContinuousQueryNoUnsubscribeTest.class);
+ suite.addTestSuite(ClientReconnectContinuousQueryTest.class);
return suite;
}
[11/31] ignite git commit: IGNITE-4247: Sql queries supports table
alias. This closes #1297.
Posted by ak...@apache.org.
IGNITE-4247: Sql queries supports table alias. This closes #1297.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/8e622e41
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/8e622e41
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/8e622e41
Branch: refs/heads/ignite-4436-2
Commit: 8e622e41de4acf365da7f933a08b6d31bae11124
Parents: 74d0dcc
Author: Andrey V. Mashenkov <an...@gmail.com>
Authored: Tue Jan 17 15:18:33 2017 +0300
Committer: Andrey V. Mashenkov <an...@gmail.com>
Committed: Tue Jan 17 15:18:33 2017 +0300
----------------------------------------------------------------------
.../org/apache/ignite/cache/query/SqlQuery.java | 25 +++++++++++++
.../processors/query/GridQueryIndexing.java | 4 ++-
.../processors/query/GridQueryProcessor.java | 5 +--
.../processors/query/h2/IgniteH2Indexing.java | 14 +++++---
.../cache/IgniteCacheAbstractQuerySelfTest.java | 37 ++++++++++++++++++++
.../h2/GridIndexingSpiAbstractSelfTest.java | 24 ++++++-------
6 files changed, 89 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/8e622e41/modules/core/src/main/java/org/apache/ignite/cache/query/SqlQuery.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/query/SqlQuery.java b/modules/core/src/main/java/org/apache/ignite/cache/query/SqlQuery.java
index 83e171d..5e36d20 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/query/SqlQuery.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/query/SqlQuery.java
@@ -37,6 +37,9 @@ public final class SqlQuery<K, V> extends Query<Cache.Entry<K, V>> {
/** */
private String type;
+ /** Table alias */
+ private String alias;
+
/** SQL clause. */
private String sql;
@@ -138,6 +141,27 @@ public final class SqlQuery<K, V> extends Query<Cache.Entry<K, V>> {
}
/**
+ * Sets table alias for type.
+ *
+ * @return Table alias.
+ */
+ public String getAlias() {
+ return alias;
+ }
+
+ /**
+ * Gets table alias for type.
+ *
+ * @param alias table alias for type that is used in query.
+ * @return {@code this} For chaining.
+ */
+ public SqlQuery<K, V> setAlias(String alias) {
+ this.alias = alias;
+
+ return this;
+ }
+
+ /**
* Gets the query execution timeout in milliseconds.
*
* @return Timeout value.
@@ -148,6 +172,7 @@ public final class SqlQuery<K, V> extends Query<Cache.Entry<K, V>> {
/**
* Sets the query execution timeout. Query will be automatically cancelled if the execution timeout is exceeded.
+ *
* @param timeout Timeout value. Zero value disables timeout.
* @param timeUnit Time granularity.
* @return {@code this} For chaining.
http://git-wip-us.apache.org/repos/asf/ignite/blob/8e622e41/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryIndexing.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryIndexing.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryIndexing.java
index 6bffa5d..539ebc0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryIndexing.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryIndexing.java
@@ -95,6 +95,7 @@ public interface GridQueryIndexing {
*
* @param spaceName Space name.
* @param qry Query.
+ * @param alias Table alias used in Query.
* @param params Query parameters.
* @param type Query return type.
* @param filter Space name and key filter.
@@ -102,7 +103,8 @@ public interface GridQueryIndexing {
* @throws IgniteCheckedException If failed.
*/
public <K, V> GridCloseableIterator<IgniteBiTuple<K, V>> queryLocalSql(@Nullable String spaceName, String qry,
- Collection<Object> params, GridQueryTypeDescriptor type, IndexingQueryFilter filter) throws IgniteCheckedException;
+ String alias, Collection<Object> params, GridQueryTypeDescriptor type, IndexingQueryFilter filter)
+ throws IgniteCheckedException;
/**
* Executes text query.
http://git-wip-us.apache.org/repos/asf/ignite/blob/8e622e41/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
index 0f2bc9a..f4ac4ae 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
@@ -796,7 +796,7 @@ public class GridQueryProcessor extends GridProcessorAdapter {
if (type == null || !type.registered())
throw new CacheException("Failed to find SQL table for type: " + resType);
- return idx.queryLocalSql(space, clause, params, type, filters);
+ return idx.queryLocalSql(space, clause, null, params, type, filters);
}
}, false);
}
@@ -890,7 +890,8 @@ public class GridQueryProcessor extends GridProcessorAdapter {
final GridCloseableIterator<IgniteBiTuple<K, V>> i = idx.queryLocalSql(
space,
- sqlQry,
+ qry.getSql(),
+ qry.getAlias(),
F.asList(params),
typeDesc,
idx.backupFilter(requestTopVer.get(), null));
http://git-wip-us.apache.org/repos/asf/ignite/blob/8e622e41/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
index bc51552..cbf2ebd 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
@@ -1046,14 +1046,14 @@ public class IgniteH2Indexing implements GridQueryIndexing {
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override public <K, V> GridCloseableIterator<IgniteBiTuple<K, V>> queryLocalSql(@Nullable String spaceName,
- final String qry, @Nullable final Collection<Object> params, GridQueryTypeDescriptor type,
+ final String qry, String alias, @Nullable final Collection<Object> params, GridQueryTypeDescriptor type,
final IndexingQueryFilter filter) throws IgniteCheckedException {
final TableDescriptor tbl = tableDescriptor(spaceName, type);
if (tbl == null)
throw new CacheException("Failed to find SQL table for type: " + type.name());
- String sql = generateQuery(qry, tbl);
+ String sql = generateQuery(qry, alias, tbl);
Connection conn = connectionForThread(tbl.schemaName());
@@ -1103,7 +1103,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
String sql;
try {
- sql = generateQuery(qry.getSql(), tblDesc);
+ sql = generateQuery(qry.getSql(), qry.getAlias(), tblDesc);
}
catch (IgniteCheckedException e) {
throw new IgniteException(e);
@@ -1300,11 +1300,12 @@ public class IgniteH2Indexing implements GridQueryIndexing {
* Prepares statement for query.
*
* @param qry Query string.
+ * @param tableAlias table alias.
* @param tbl Table to use.
* @return Prepared statement.
* @throws IgniteCheckedException In case of error.
*/
- private String generateQuery(String qry, TableDescriptor tbl) throws IgniteCheckedException {
+ private String generateQuery(String qry, String tableAlias, TableDescriptor tbl) throws IgniteCheckedException {
assert tbl != null;
final String qry0 = qry;
@@ -1341,10 +1342,13 @@ public class IgniteH2Indexing implements GridQueryIndexing {
}
if (!upper.startsWith("FROM"))
- from = " FROM " + t +
+ from = " FROM " + t + (tableAlias != null ? " as " + tableAlias : "") +
(upper.startsWith("WHERE") || upper.startsWith("ORDER") || upper.startsWith("LIMIT") ?
" " : " WHERE ");
+ if(tableAlias != null)
+ t = tableAlias;
+
qry = "SELECT " + t + "." + KEY_FIELD_NAME + ", " + t + "." + VAL_FIELD_NAME + from + qry;
return qry;
http://git-wip-us.apache.org/repos/asf/ignite/blob/8e622e41/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java
index ad6922c..c5a241e 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java
@@ -348,6 +348,43 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
}
/**
+ * Test table alias in SqlQuery.
+ *
+ * @throws Exception In case of error.
+ */
+ public void testTableAliasInSqlQuery() throws Exception {
+ IgniteCache<Integer, Integer> cache = ignite().cache(null);
+
+ int key = 898;
+
+ int val = 2;
+
+ cache.put(key, val);
+
+ SqlQuery<Integer, Integer> sqlQry = new SqlQuery<>(Integer.class, "t1._key = ? and t1._val > 1");
+
+ QueryCursor<Cache.Entry<Integer, Integer>> qry = cache.query(sqlQry.setAlias("t1").setArgs(key));
+
+ Cache.Entry<Integer, Integer> entry = F.first(qry.getAll());
+
+ assert entry != null;
+
+ assertEquals(key, entry.getKey().intValue());
+ assertEquals(val, entry.getValue().intValue());
+
+ sqlQry = new SqlQuery<>(Integer.class, "FROM Integer as t1 WHERE t1._key = ? and t1._val > 1");
+
+ qry = cache.query(sqlQry.setAlias("t1").setArgs(key));
+
+ entry = F.first(qry.getAll());
+
+ assert entry != null;
+
+ assertEquals(key, entry.getKey().intValue());
+ assertEquals(val, entry.getValue().intValue());
+ }
+
+ /**
* Tests UDFs.
*
* @throws IgniteCheckedException If failed.
http://git-wip-us.apache.org/repos/asf/ignite/blob/8e622e41/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexingSpiAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexingSpiAbstractSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexingSpiAbstractSelfTest.java
index 81e34d6..ad8a7e3 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexingSpiAbstractSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexingSpiAbstractSelfTest.java
@@ -223,15 +223,15 @@ public abstract class GridIndexingSpiAbstractSelfTest extends GridCommonAbstract
assertEquals(0, spi.size(typeAB.space(), typeAB));
assertEquals(0, spi.size(typeBA.space(), typeBA));
- assertFalse(spi.queryLocalSql(typeAA.space(), "select * from A.A", Collections.emptySet(), typeAA, null).hasNext());
- assertFalse(spi.queryLocalSql(typeAB.space(), "select * from A.B", Collections.emptySet(), typeAB, null).hasNext());
- assertFalse(spi.queryLocalSql(typeBA.space(), "select * from B.A", Collections.emptySet(), typeBA, null).hasNext());
+ assertFalse(spi.queryLocalSql(typeAA.space(), "select * from A.A", null, Collections.emptySet(), typeAA, null).hasNext());
+ assertFalse(spi.queryLocalSql(typeAB.space(), "select * from A.B", null, Collections.emptySet(), typeAB, null).hasNext());
+ assertFalse(spi.queryLocalSql(typeBA.space(), "select * from B.A", null, Collections.emptySet(), typeBA, null).hasNext());
- assertFalse(spi.queryLocalSql(typeBA.space(), "select * from B.A, A.B, A.A",
+ assertFalse(spi.queryLocalSql(typeBA.space(), "select * from B.A, A.B, A.A", null,
Collections.emptySet(), typeBA, null).hasNext());
try {
- spi.queryLocalSql(typeBA.space(), "select aa.*, ab.*, ba.* from A.A aa, A.B ab, B.A ba",
+ spi.queryLocalSql(typeBA.space(), "select aa.*, ab.*, ba.* from A.A aa, A.B ab, B.A ba", null,
Collections.emptySet(), typeBA, null).hasNext();
fail("Enumerations of aliases in select block must be prohibited");
@@ -240,10 +240,10 @@ public abstract class GridIndexingSpiAbstractSelfTest extends GridCommonAbstract
// all fine
}
- assertFalse(spi.queryLocalSql(typeAB.space(), "select ab.* from A.B ab",
+ assertFalse(spi.queryLocalSql(typeAB.space(), "select ab.* from A.B ab", null,
Collections.emptySet(), typeAB, null).hasNext());
- assertFalse(spi.queryLocalSql(typeBA.space(), "select ba.* from B.A as ba",
+ assertFalse(spi.queryLocalSql(typeBA.space(), "select ba.* from B.A as ba", null,
Collections.emptySet(), typeBA, null).hasNext());
// Nothing to remove.
@@ -298,7 +298,7 @@ public abstract class GridIndexingSpiAbstractSelfTest extends GridCommonAbstract
// Query data.
Iterator<IgniteBiTuple<Integer, Map<String, Object>>> res =
- spi.queryLocalSql(typeAA.space(), "from a order by age", Collections.emptySet(), typeAA, null);
+ spi.queryLocalSql(typeAA.space(), "from a order by age", null, Collections.emptySet(), typeAA, null);
assertTrue(res.hasNext());
assertEquals(aa(3, "Borya", 18).value(null, false), value(res.next()));
@@ -306,7 +306,7 @@ public abstract class GridIndexingSpiAbstractSelfTest extends GridCommonAbstract
assertEquals(aa(2, "Valera", 19).value(null, false), value(res.next()));
assertFalse(res.hasNext());
- res = spi.queryLocalSql(typeAA.space(), "select aa.* from a aa order by aa.age",
+ res = spi.queryLocalSql(typeAA.space(), "select aa.* from a aa order by aa.age", null,
Collections.emptySet(), typeAA, null);
assertTrue(res.hasNext());
@@ -315,7 +315,7 @@ public abstract class GridIndexingSpiAbstractSelfTest extends GridCommonAbstract
assertEquals(aa(2, "Valera", 19).value(null, false), value(res.next()));
assertFalse(res.hasNext());
- res = spi.queryLocalSql(typeAB.space(), "from b order by name", Collections.emptySet(), typeAB, null);
+ res = spi.queryLocalSql(typeAB.space(), "from b order by name", null, Collections.emptySet(), typeAB, null);
assertTrue(res.hasNext());
assertEquals(ab(1, "Vasya", 20, "Some text about Vasya goes here.").value(null, false), value(res.next()));
@@ -323,7 +323,7 @@ public abstract class GridIndexingSpiAbstractSelfTest extends GridCommonAbstract
assertEquals(ab(4, "Vitalya", 20, "Very Good guy").value(null, false), value(res.next()));
assertFalse(res.hasNext());
- res = spi.queryLocalSql(typeAB.space(), "select bb.* from b as bb order by bb.name",
+ res = spi.queryLocalSql(typeAB.space(), "select bb.* from b as bb order by bb.name", null,
Collections.emptySet(), typeAB, null);
assertTrue(res.hasNext());
@@ -333,7 +333,7 @@ public abstract class GridIndexingSpiAbstractSelfTest extends GridCommonAbstract
assertFalse(res.hasNext());
- res = spi.queryLocalSql(typeBA.space(), "from a", Collections.emptySet(), typeBA, null);
+ res = spi.queryLocalSql(typeBA.space(), "from a", null, Collections.emptySet(), typeBA, null);
assertTrue(res.hasNext());
assertEquals(ba(2, "Kolya", 25, true).value(null, false), value(res.next()));
[31/31] ignite git commit: IGNITE-4436 WIP.
Posted by ak...@apache.org.
IGNITE-4436 WIP.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/ce374cd9
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/ce374cd9
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/ce374cd9
Branch: refs/heads/ignite-4436-2
Commit: ce374cd9e3707458aaf39dc81a824b01879cc36f
Parents: 58cf839
Author: Alexey Kuznetsov <ak...@apache.org>
Authored: Mon Feb 13 17:31:39 2017 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Mon Feb 13 17:31:39 2017 +0700
----------------------------------------------------------------------
.../processors/query/GridQueryIndexing.java | 4 +---
.../processors/query/GridQueryProcessor.java | 3 +--
.../visor/query/VisorCancelQueriesTask.java | 22 +++++++-------------
.../query/VisorCollectRunningQueriesTask.java | 8 +++++--
.../internal/visor/query/VisorRunningQuery.java | 21 +++++++++++++++----
.../processors/query/h2/IgniteH2Indexing.java | 17 ++++++++-------
.../h2/twostep/GridReduceQueryExecutor.java | 2 +-
7 files changed, 43 insertions(+), 34 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/ce374cd9/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryIndexing.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryIndexing.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryIndexing.java
index 133bd76..ca04724 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryIndexing.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryIndexing.java
@@ -21,8 +21,6 @@ import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Collection;
import java.util.List;
-import java.util.Set;
-import java.util.UUID;
import javax.cache.Cache;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.cache.query.QueryCursor;
@@ -255,7 +253,7 @@ public interface GridQueryIndexing {
*
* @param queries Queries ID's to cancel.
*/
- public void cancelQueries(Set<Long> queries);
+ public void cancelQueries(Collection<Long> queries);
/**
* Cancels all executing queries.
http://git-wip-us.apache.org/repos/asf/ignite/blob/ce374cd9/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
index 5d415a2..ee9224b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
@@ -44,7 +44,6 @@ import javax.cache.Cache;
import javax.cache.CacheException;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
-import org.apache.ignite.IgniteSystemProperties;
import org.apache.ignite.binary.BinaryField;
import org.apache.ignite.binary.BinaryObject;
import org.apache.ignite.binary.BinaryObjectBuilder;
@@ -937,7 +936,7 @@ public class GridQueryProcessor extends GridProcessorAdapter {
*
* @param queries Queries ID's to cancel.
*/
- public void cancelQueries(Set<Long> queries) {
+ public void cancelQueries(Collection<Long> queries) {
if (moduleEnabled())
idx.cancelQueries(queries);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ce374cd9/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorCancelQueriesTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorCancelQueriesTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorCancelQueriesTask.java
index 7b3c33c..a6f2d82 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorCancelQueriesTask.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorCancelQueriesTask.java
@@ -17,28 +17,25 @@
package org.apache.ignite.internal.visor.query;
+import java.util.Collection;
import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
import org.apache.ignite.IgniteException;
import org.apache.ignite.compute.ComputeJobResult;
import org.apache.ignite.internal.processors.task.GridInternal;
-import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.visor.VisorJob;
-import org.apache.ignite.internal.visor.VisorMultiNodeTask;
+import org.apache.ignite.internal.visor.VisorOneNodeTask;
import org.jetbrains.annotations.Nullable;
/**
* Task to cancel queries.
*/
@GridInternal
-public class VisorCancelQueriesTask extends VisorMultiNodeTask<Map<UUID, Set<Long>>, Void, Void> {
+public class VisorCancelQueriesTask extends VisorOneNodeTask<Collection<Long>, Void> {
/** */
private static final long serialVersionUID = 0L;
/** {@inheritDoc} */
- @Override protected VisorCancelQueriesJob job(Map<UUID, Set<Long>> arg) {
+ @Override protected VisorCancelQueriesJob job(Collection<Long> arg) {
return new VisorCancelQueriesJob(arg, debug);
}
@@ -50,7 +47,7 @@ public class VisorCancelQueriesTask extends VisorMultiNodeTask<Map<UUID, Set<Lon
/**
* Job to cancel queries on node.
*/
- private static class VisorCancelQueriesJob extends VisorJob<Map<UUID, Set<Long>>, Void> {
+ private static class VisorCancelQueriesJob extends VisorJob<Collection<Long>, Void> {
/** */
private static final long serialVersionUID = 0L;
@@ -60,16 +57,13 @@ public class VisorCancelQueriesTask extends VisorMultiNodeTask<Map<UUID, Set<Lon
* @param arg Job argument.
* @param debug Flag indicating whether debug information should be printed into node log.
*/
- protected VisorCancelQueriesJob(@Nullable Map<UUID, Set<Long>> arg, boolean debug) {
+ protected VisorCancelQueriesJob(@Nullable Collection<Long> arg, boolean debug) {
super(arg, debug);
}
/** {@inheritDoc} */
- @Override protected Void run(@Nullable Map<UUID, Set<Long>> arg) throws IgniteException {
- Set<Long> queries = arg.get(ignite.localNode().id());
-
- if (!F.isEmpty(queries))
- ignite.context().query().cancelQueries(queries);
+ @Override protected Void run(@Nullable Collection<Long> queries) throws IgniteException {
+ ignite.context().query().cancelQueries(queries);
return null;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ce374cd9/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorCollectRunningQueriesTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorCollectRunningQueriesTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorCollectRunningQueriesTask.java
index 8ac8ace..2b40e61 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorCollectRunningQueriesTask.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorCollectRunningQueriesTask.java
@@ -27,6 +27,7 @@ import org.apache.ignite.IgniteException;
import org.apache.ignite.compute.ComputeJobResult;
import org.apache.ignite.internal.processors.query.GridRunningQueryInfo;
import org.apache.ignite.internal.processors.task.GridInternal;
+import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.internal.visor.VisorJob;
import org.apache.ignite.internal.visor.VisorMultiNodeTask;
import org.jetbrains.annotations.Nullable;
@@ -49,7 +50,7 @@ public class VisorCollectRunningQueriesTask extends VisorMultiNodeTask<Long, Map
Map<UUID, Collection<VisorRunningQuery>> map = new HashMap<>();
for (ComputeJobResult res : results)
- if (res.getException() != null) {
+ if (res.getException() == null) {
Collection<VisorRunningQuery> queries = res.getData();
map.put(res.getNode().id(), queries);
@@ -82,8 +83,11 @@ public class VisorCollectRunningQueriesTask extends VisorMultiNodeTask<Long, Map
Collection<VisorRunningQuery> res = new ArrayList<>(queries.size());
+ long curTime = U.currentTimeMillis();
+
for (GridRunningQueryInfo qry : queries)
- res.add(new VisorRunningQuery(qry.id(), qry.query(), qry.queryType(), qry.cache(), qry.startTime(),
+ res.add(new VisorRunningQuery(qry.id(), qry.query(), qry.queryType(), qry.cache(),
+ qry.startTime(), curTime - qry.startTime(),
qry.cancelable(), qry.local()));
return res;
http://git-wip-us.apache.org/repos/asf/ignite/blob/ce374cd9/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorRunningQuery.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorRunningQuery.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorRunningQuery.java
index 5605ea2..fc6bc7a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorRunningQuery.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorRunningQuery.java
@@ -43,6 +43,9 @@ public class VisorRunningQuery implements Serializable {
private long startTime;
/** */
+ private long duration;
+
+ /** */
private boolean cancellable;
/** */
@@ -54,16 +57,19 @@ public class VisorRunningQuery implements Serializable {
* @param qryType Query type.
* @param cache Cache where query was executed.
* @param startTime Query start time.
+ * @param duration Query current duration.
* @param cancellable {@code true} if query can be canceled.
* @param loc {@code true} if query is local.
*/
- public VisorRunningQuery(long id, String qry, GridCacheQueryType qryType, String cache, long startTime,
+ public VisorRunningQuery(long id, String qry, GridCacheQueryType qryType, String cache,
+ long startTime, long duration,
boolean cancellable, boolean loc) {
this.id = id;
this.qry = qry;
this.qryType = qryType;
this.cache = cache;
this.startTime = startTime;
+ this.duration = duration;
this.cancellable = cancellable;
this.loc = loc;
}
@@ -71,21 +77,21 @@ public class VisorRunningQuery implements Serializable {
/**
* @return Query ID.
*/
- public long id() {
+ public long getId() {
return id;
}
/**
* @return Query txt.
*/
- public String query() {
+ public String getQuery() {
return qry;
}
/**
* @return Query type.
*/
- public GridCacheQueryType queryType() {
+ public GridCacheQueryType getQueryType() {
return qryType;
}
@@ -104,6 +110,13 @@ public class VisorRunningQuery implements Serializable {
}
/**
+ * @return Query duration.
+ */
+ public long getDuration() {
+ return duration;
+ }
+
+ /**
* @return {@code true} if query can be cancelled.
*/
public boolean isCancelable() {
http://git-wip-us.apache.org/repos/asf/ignite/blob/ce374cd9/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
index e64c735..e4b0c1f 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
@@ -48,7 +48,6 @@ import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
@@ -2298,15 +2297,17 @@ public class IgniteH2Indexing implements GridQueryIndexing {
}
/** {@inheritDoc} */
- @Override public void cancelQueries(Set<Long> queries) {
- for (Long qryId : queries) {
- GridRunningQueryInfo run = runs.get(qryId);
+ @Override public void cancelQueries(Collection<Long> queries) {
+ if (!F.isEmpty(queries)) {
+ for (Long qryId : queries) {
+ GridRunningQueryInfo run = runs.get(qryId);
- if (run != null)
- run.cancel();
- }
+ if (run != null)
+ run.cancel();
+ }
- rdcQryExec.cancelQueries(queries);
+ rdcQryExec.cancelQueries(queries);
+ }
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/ce374cd9/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java
index 3540141..78cadd2 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java
@@ -1332,7 +1332,7 @@ public class GridReduceQueryExecutor {
*
* @param queries Queries IDs to cancel.
*/
- public void cancelQueries(Set<Long> queries) {
+ public void cancelQueries(Collection<Long> queries) {
for (Long qryId : queries) {
QueryRun run = runs.get(qryId);
[20/31] ignite git commit: Throw CacheException from queries API.
Posted by ak...@apache.org.
Throw CacheException from queries API.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/51e1f874
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/51e1f874
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/51e1f874
Branch: refs/heads/ignite-4436-2
Commit: 51e1f874624c428cc93e9c16407ec5a8b4cf8420
Parents: d396398
Author: sboikov <sb...@gridgain.com>
Authored: Thu Jan 19 10:52:42 2017 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Thu Jan 19 10:52:42 2017 +0300
----------------------------------------------------------------------
.../internal/processors/query/GridQueryProcessor.java | 2 +-
.../cache/query/IndexingSpiQuerySelfTest.java | 3 +--
.../cache/IgniteCacheAbstractQuerySelfTest.java | 2 --
.../near/IgniteCachePartitionedQuerySelfTest.java | 12 +++++-------
4 files changed, 7 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/51e1f874/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
index 48ca2b5..c2e5717 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
@@ -905,7 +905,7 @@ public class GridQueryProcessor extends GridProcessorAdapter {
}, true);
}
catch (IgniteCheckedException e) {
- throw new IgniteException(e);
+ throw new CacheException(e);
}
finally {
busyLock.leaveBusy();
http://git-wip-us.apache.org/repos/asf/ignite/blob/51e1f874/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/IndexingSpiQuerySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/IndexingSpiQuerySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/IndexingSpiQuerySelfTest.java
index 84a13df..e780fdc 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/IndexingSpiQuerySelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/IndexingSpiQuerySelfTest.java
@@ -328,8 +328,7 @@ public class IndexingSpiQuerySelfTest extends TestCase {
}
/** {@inheritDoc} */
- @Override
- public void onUnswap(@Nullable String spaceName, Object key, Object val) throws IgniteSpiException {
+ @Override public void onUnswap(@Nullable String spaceName, Object key, Object val) throws IgniteSpiException {
assertTrue(key instanceof BinaryObject);
assertTrue(val instanceof BinaryObject);
http://git-wip-us.apache.org/repos/asf/ignite/blob/51e1f874/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java
index 9f56877..751d954 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java
@@ -46,7 +46,6 @@ import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteBinary;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.IgniteException;
import org.apache.ignite.binary.BinaryObject;
import org.apache.ignite.cache.CacheAtomicityMode;
import org.apache.ignite.cache.CacheMode;
@@ -264,7 +263,6 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
stopAllGrids();
-
store.reset();
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/51e1f874/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCachePartitionedQuerySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCachePartitionedQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCachePartitionedQuerySelfTest.java
index b9f21da..d5a9faf 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCachePartitionedQuerySelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCachePartitionedQuerySelfTest.java
@@ -39,7 +39,6 @@ import org.apache.ignite.internal.processors.cache.query.GridCacheQueryResponse;
import org.apache.ignite.internal.util.typedef.F;
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.CommunicationSpi;
import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
@@ -185,9 +184,8 @@ public class IgniteCachePartitionedQuerySelfTest extends IgniteCacheAbstractQuer
pages.incrementAndGet();
}
- else if (msg0 instanceof GridCacheQueryResponse) {
+ else if (msg0 instanceof GridCacheQueryResponse)
assertTrue(((GridCacheQueryResponse)msg0).data().size() <= pageSize);
- }
}
};
@@ -211,15 +209,15 @@ public class IgniteCachePartitionedQuerySelfTest extends IgniteCacheAbstractQuer
*
*/
private static class TestTcpCommunicationSpi extends TcpCommunicationSpi {
+ /** */
volatile IgniteInClosure<Message> filter;
/** {@inheritDoc} */
- @Override public void sendMessage(ClusterNode node, Message msg, IgniteInClosure<IgniteException> ackClosure)
- throws IgniteSpiException {
- if(filter != null)
+ @Override public void sendMessage(ClusterNode node, Message msg, IgniteInClosure<IgniteException> ackC) {
+ if (filter != null)
filter.apply(msg);
- super.sendMessage(node, msg, ackClosure);
+ super.sendMessage(node, msg, ackC);
}
}
}
\ No newline at end of file
[15/31] ignite git commit: ignite-4147 - Fail if joining node has
different of cluster SSL configuration.
Posted by ak...@apache.org.
ignite-4147 - Fail if joining node has different of cluster SSL configuration.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/2eb24cad
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/2eb24cad
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/2eb24cad
Branch: refs/heads/ignite-4436-2
Commit: 2eb24cad277e14322cf42155697cae78e0f80e13
Parents: b54a481
Author: dkarachentsev <dk...@gridgain.com>
Authored: Wed Jan 18 13:00:25 2017 +0300
Committer: dkarachentsev <dk...@gridgain.com>
Committed: Wed Jan 18 13:00:25 2017 +0300
----------------------------------------------------------------------
.../ignite/spi/discovery/tcp/ClientImpl.java | 20 ++++-
.../ignite/spi/discovery/tcp/ServerImpl.java | 9 ++
.../TcpDiscoverySslSecuredUnsecuredTest.java | 93 ++++++++++++++++++++
.../IgniteSpiDiscoverySelfTestSuite.java | 4 +-
4 files changed, 124 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/2eb24cad/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 0f5f741..9a1261c 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
@@ -20,6 +20,7 @@ package org.apache.ignite.spi.discovery.tcp;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.StreamCorruptedException;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.SocketTimeoutException;
@@ -44,6 +45,7 @@ import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.atomic.AtomicReference;
+import javax.net.ssl.SSLException;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteClientDisconnectedException;
import org.apache.ignite.IgniteException;
@@ -655,6 +657,14 @@ class ClientImpl extends TcpDiscoveryImpl {
errs.add(e);
+ if (X.hasCause(e, SSLException.class))
+ throw new IgniteSpiException("Unable to establish secure connection. " +
+ "Was remote cluster configured with SSL? [rmtAddr=" + addr + ", errMsg=\"" + e.getMessage() + "\"]", e);
+
+ if (X.hasCause(e, StreamCorruptedException.class))
+ throw new IgniteSpiException("Unable to establish plain connection. " +
+ "Was remote cluster configured with SSL? [rmtAddr=" + addr + ", errMsg=\"" + e.getMessage() + "\"]", e);
+
if (timeoutHelper.checkFailureTimeoutReached(e))
break;
@@ -1527,7 +1537,15 @@ class ClientImpl extends TcpDiscoveryImpl {
joinCnt++;
- T2<SocketStream, Boolean> joinRes = joinTopology(false, spi.joinTimeout);
+ T2<SocketStream, Boolean> joinRes;
+ try {
+ joinRes = joinTopology(false, spi.joinTimeout);
+ }
+ catch (IgniteSpiException e) {
+ joinError(e);
+
+ return;
+ }
if (joinRes == null) {
if (join)
http://git-wip-us.apache.org/repos/asf/ignite/blob/2eb24cad/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
index c791333..40da281 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
@@ -24,6 +24,7 @@ import java.io.InputStream;
import java.io.ObjectStreamException;
import java.io.OutputStream;
import java.io.Serializable;
+import java.io.StreamCorruptedException;
import java.net.ConnectException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
@@ -1218,6 +1219,14 @@ class ServerImpl extends TcpDiscoveryImpl {
errs.add(e);
+ if (X.hasCause(e, SSLException.class))
+ throw new IgniteException("Unable to establish secure connection. " +
+ "Was remote cluster configured with SSL? [rmtAddr=" + addr + ", errMsg=\"" + e.getMessage() + "\"]", e);
+
+ if (X.hasCause(e, StreamCorruptedException.class))
+ throw new IgniteException("Unable to establish plain connection. " +
+ "Was remote cluster configured with SSL? [rmtAddr=" + addr + ", errMsg=\"" + e.getMessage() + "\"]", e);
+
if (timeoutHelper.checkFailureTimeoutReached(e))
break;
http://git-wip-us.apache.org/repos/asf/ignite/blob/2eb24cad/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySslSecuredUnsecuredTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySslSecuredUnsecuredTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySslSecuredUnsecuredTest.java
new file mode 100644
index 0000000..2296165
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySslSecuredUnsecuredTest.java
@@ -0,0 +1,93 @@
+/*
+ * 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.spi.discovery.tcp;
+
+import java.util.concurrent.Callable;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/**
+ * Tests cases when node connects to cluster with different SSL configuration.
+ * Exception with meaningful message should be thrown.
+ */
+public class TcpDiscoverySslSecuredUnsecuredTest extends GridCommonAbstractTest {
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(final String gridName) throws Exception {
+ final IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ cfg.setClientMode(gridName.contains("client"));
+
+ if (gridName.contains("ssl"))
+ cfg.setSslContextFactory(GridTestUtils.sslFactory());
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ stopAllGrids();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testSecuredUnsecuredServerConnection() throws Exception {
+ checkConnection("plain-server", "ssl-server");
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testUnsecuredSecuredServerConnection() throws Exception {
+ checkConnection("ssl-server", "plain-server");
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testSecuredClientUnsecuredServerConnection() throws Exception {
+ checkConnection("plain-server", "ssl-client");
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testUnsecuredClientSecuredServerConnection() throws Exception {
+ checkConnection("ssl-server", "plain-client");
+ }
+
+ /**
+ * @param name1 First grid name.
+ * @param name2 Second grid name.
+ * @throws Exception If failed.
+ */
+ @SuppressWarnings("ThrowableNotThrown")
+ private void checkConnection(final String name1, final String name2) throws Exception {
+ startGrid(name1);
+
+ GridTestUtils.assertThrows(null, new Callable<Object>() {
+ @Override public Object call() throws Exception {
+ startGrid(name2);
+
+ return null;
+ }
+ }, IgniteCheckedException.class, null);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2eb24cad/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiDiscoverySelfTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiDiscoverySelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiDiscoverySelfTestSuite.java
index af7eb7e..98bf6da 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiDiscoverySelfTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiDiscoverySelfTestSuite.java
@@ -34,6 +34,7 @@ import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpiConfigSelfTest;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpiFailureTimeoutSelfTest;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpiSelfTest;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpiStartStopSelfTest;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySslSecuredUnsecuredTest;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySslSelfTest;
import org.apache.ignite.spi.discovery.tcp.ipfinder.jdbc.TcpDiscoveryJdbcIpFinderSelfTest;
import org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinderSelfTest;
@@ -86,7 +87,8 @@ public class IgniteSpiDiscoverySelfTestSuite extends TestSuite {
// SSL.
suite.addTest(new TestSuite(TcpDiscoverySslSelfTest.class));
+ suite.addTest(new TestSuite(TcpDiscoverySslSecuredUnsecuredTest.class));
return suite;
}
-}
\ No newline at end of file
+}
[12/31] ignite git commit: IGNITE-4540: IndexingSPI can be used
without have default H2 Indexing enabled. This closes #1423.
Posted by ak...@apache.org.
IGNITE-4540: IndexingSPI can be used without have default H2 Indexing enabled. This closes #1423.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/a922ac9d
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/a922ac9d
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/a922ac9d
Branch: refs/heads/ignite-4436-2
Commit: a922ac9d17f91f25aaa2bac9f0a2622dbd04c9bb
Parents: 8e622e4
Author: Andrey V. Mashenkov <an...@gmail.com>
Authored: Tue Jan 17 15:31:04 2017 +0300
Committer: Andrey V. Mashenkov <an...@gmail.com>
Committed: Tue Jan 17 15:31:04 2017 +0300
----------------------------------------------------------------------
.../cache/query/GridCacheQueryManager.java | 83 ++++++++++++++++++--
.../processors/query/GridQueryProcessor.java | 46 -----------
.../cache/query/IndexingSpiQuerySelfTest.java | 66 ++++++++--------
.../IndexingSpiQueryWithH2IndexingSelfTest.java | 36 +++++++++
4 files changed, 145 insertions(+), 86 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/a922ac9d/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 85c01d9..d64dff4 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
@@ -1,4 +1,4 @@
-/*
+ /*
* 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.
@@ -45,6 +45,7 @@ import javax.cache.expiry.ExpiryPolicy;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
+import org.apache.ignite.IgniteSystemProperties;
import org.apache.ignite.cache.query.QueryMetrics;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.configuration.CacheConfiguration;
@@ -60,6 +61,7 @@ import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
import org.apache.ignite.internal.processors.cache.CacheEntryImpl;
import org.apache.ignite.internal.processors.cache.CacheMetricsImpl;
import org.apache.ignite.internal.processors.cache.CacheObject;
+import org.apache.ignite.internal.processors.cache.CacheObjectContext;
import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
import org.apache.ignite.internal.processors.cache.GridCacheEntryEx;
import org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedException;
@@ -167,6 +169,9 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
}
};
+ /** Default is @{code true} */
+ private final boolean isIndexingSpiAllowsBinary = !IgniteSystemProperties.getBoolean(IgniteSystemProperties.IGNITE_UNWRAP_BINARY_FOR_INDEXING_SPI);
+
/** */
private GridQueryProcessor qryProc;
@@ -205,15 +210,24 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
private boolean enabled;
/** */
+ private boolean qryProcEnabled;
+
+
+ /** */
private AffinityTopologyVersion qryTopVer;
/** {@inheritDoc} */
@Override public void start0() throws IgniteCheckedException {
CacheConfiguration ccfg = cctx.config();
+ qryProcEnabled = GridQueryProcessor.isEnabled(ccfg);
+
qryProc = cctx.kernalContext().query();
+
space = cctx.name();
+ enabled = qryProcEnabled || (isIndexingSpiEnabled() && !CU.isSystemCache(space));
+
maxIterCnt = ccfg.getMaxQueryIteratorsCount();
detailMetricsSz = ccfg.getQueryDetailMetricsSize();
@@ -259,8 +273,6 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
cctx.events().addListener(lsnr, EVT_NODE_LEFT, EVT_NODE_FAILED);
- enabled = GridQueryProcessor.isEnabled(ccfg);
-
qryTopVer = cctx.startTopologyVersion();
if (qryTopVer == null)
@@ -369,11 +381,21 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
* @throws IgniteCheckedException If failed.
*/
public void onSwap(CacheObject key) throws IgniteCheckedException {
+ if(!enabled)
+ return;
+
if (!enterBusy())
return; // Ignore index update when node is stopping.
try {
- qryProc.onSwap(space, key);
+ if (isIndexingSpiEnabled()) {
+ Object key0 = unwrapIfNeeded(key, cctx.cacheObjectContext());
+
+ cctx.kernalContext().indexing().onSwap(space, key0);
+ }
+
+ if(qryProcEnabled)
+ qryProc.onSwap(space, key);
}
finally {
leaveBusy();
@@ -381,6 +403,14 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
}
/**
+ * Checks if IndexinSPI is enabled.
+ * @return IndexingSPI enabled flag.
+ */
+ private boolean isIndexingSpiEnabled() {
+ return cctx.kernalContext().indexing().enabled();
+ }
+
+ /**
* Entry for given key unswapped.
*
* @param key Key.
@@ -388,11 +418,25 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
* @throws IgniteCheckedException If failed.
*/
public void onUnswap(CacheObject key, CacheObject val) throws IgniteCheckedException {
+ if(!enabled)
+ return;
+
if (!enterBusy())
return; // Ignore index update when node is stopping.
try {
- qryProc.onUnswap(space, key, val);
+ if (isIndexingSpiEnabled()) {
+ CacheObjectContext coctx = cctx.cacheObjectContext();
+
+ Object key0 = unwrapIfNeeded(key, coctx);
+
+ Object val0 = unwrapIfNeeded(val, coctx);
+
+ cctx.kernalContext().indexing().onUnswap(space, key0, val0);
+ }
+
+ if(qryProcEnabled)
+ qryProc.onUnswap(space, key, val);
}
finally {
leaveBusy();
@@ -429,7 +473,18 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
return; // Ignore index update when node is stopping.
try {
- qryProc.store(space, key, val, CU.versionToBytes(ver), expirationTime);
+ if (isIndexingSpiEnabled()) {
+ CacheObjectContext coctx = cctx.cacheObjectContext();
+
+ Object key0 = unwrapIfNeeded(key, coctx);
+
+ Object val0 = unwrapIfNeeded(val, coctx);
+
+ cctx.kernalContext().indexing().store(space, key0, val0, expirationTime);
+ }
+
+ if(qryProcEnabled)
+ qryProc.store(space, key, val, CU.versionToBytes(ver), expirationTime);
}
finally {
invalidateResultCache();
@@ -454,7 +509,14 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
return; // Ignore index update when node is stopping.
try {
- qryProc.remove(space, key, val);
+ if (isIndexingSpiEnabled()) {
+ Object key0 = unwrapIfNeeded(key, cctx.cacheObjectContext());
+
+ cctx.kernalContext().indexing().remove(space, key0);
+ }
+
+ if(qryProcEnabled)
+ qryProc.remove(space, key, val);
}
finally {
invalidateResultCache();
@@ -561,6 +623,13 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
public abstract CacheQueryFuture<?> queryFieldsDistributed(GridCacheQueryBean qry, Collection<ClusterNode> nodes);
/**
+ * Unwrap CacheObject if needed.
+ */
+ private Object unwrapIfNeeded(CacheObject obj, CacheObjectContext coctx) {
+ return isIndexingSpiAllowsBinary && cctx.cacheObjects().isBinaryObject(obj) ? obj : obj.value(coctx, false);
+ }
+
+ /**
* Performs query.
*
* @param qry Query.
http://git-wip-us.apache.org/repos/asf/ignite/blob/a922ac9d/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
index f4ac4ae..48ca2b5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
@@ -160,9 +160,6 @@ public class GridQueryProcessor extends GridProcessorAdapter {
/** */
private static final ThreadLocal<AffinityTopologyVersion> requestTopVer = new ThreadLocal<>();
- /** Default is @{true} */
- private final boolean isIndexingSpiAllowsBinary = !IgniteSystemProperties.getBoolean(IgniteSystemProperties.IGNITE_UNWRAP_BINARY_FOR_INDEXING_SPI);
-
/**
* @param ctx Kernal context.
*/
@@ -682,16 +679,6 @@ public class GridQueryProcessor extends GridProcessorAdapter {
CacheObjectContext coctx = null;
- if (ctx.indexing().enabled()) {
- coctx = cacheObjectContext(space);
-
- Object key0 = unwrap(key, coctx);
-
- Object val0 = unwrap(val, coctx);
-
- ctx.indexing().store(space, key0, val0, expirationTime);
- }
-
if (idx == null)
return;
@@ -745,13 +732,6 @@ public class GridQueryProcessor extends GridProcessorAdapter {
}
/**
- * Unwrap CacheObject if needed.
- */
- private Object unwrap(CacheObject obj, CacheObjectContext coctx) {
- return isIndexingSpiAllowsBinary && ctx.cacheObjects().isBinaryObject(obj) ? obj : obj.value(coctx, false);
- }
-
- /**
* @throws IgniteCheckedException If failed.
*/
private void checkEnabled() throws IgniteCheckedException {
@@ -1039,14 +1019,6 @@ public class GridQueryProcessor extends GridProcessorAdapter {
if (log.isDebugEnabled())
log.debug("Remove [space=" + space + ", key=" + key + ", val=" + val + "]");
- if (ctx.indexing().enabled()) {
- CacheObjectContext coctx = cacheObjectContext(space);
-
- Object key0 = unwrap(key, coctx);
-
- ctx.indexing().remove(space, key0);
- }
-
if (idx == null)
return;
@@ -1184,14 +1156,6 @@ public class GridQueryProcessor extends GridProcessorAdapter {
if (log.isDebugEnabled())
log.debug("Swap [space=" + spaceName + ", key=" + key + "]");
- if (ctx.indexing().enabled()) {
- CacheObjectContext coctx = cacheObjectContext(spaceName);
-
- Object key0 = unwrap(key, coctx);
-
- ctx.indexing().onSwap(spaceName, key0);
- }
-
if (idx == null)
return;
@@ -1221,16 +1185,6 @@ public class GridQueryProcessor extends GridProcessorAdapter {
if (log.isDebugEnabled())
log.debug("Unswap [space=" + spaceName + ", key=" + key + ", val=" + val + "]");
- if (ctx.indexing().enabled()) {
- CacheObjectContext coctx = cacheObjectContext(spaceName);
-
- Object key0 = unwrap(key, coctx);
-
- Object val0 = unwrap(val, coctx);
-
- ctx.indexing().onUnswap(spaceName, key0, val0);
- }
-
if (idx == null)
return;
http://git-wip-us.apache.org/repos/asf/ignite/blob/a922ac9d/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/IndexingSpiQuerySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/IndexingSpiQuerySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/IndexingSpiQuerySelfTest.java
index f66b99e..84a13df 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/IndexingSpiQuerySelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/IndexingSpiQuerySelfTest.java
@@ -55,15 +55,40 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
- * Indexing Spi query test
+ * Indexing Spi query only test
*/
public class IndexingSpiQuerySelfTest extends TestCase {
+ public static final String CACHE_NAME = "test-cache";
+
/** {@inheritDoc} */
@Override public void tearDown() throws Exception {
Ignition.stopAll(true);
}
/**
+ * @return Configuration.
+ */
+ protected IgniteConfiguration configuration() {
+ IgniteConfiguration cfg = new IgniteConfiguration();
+
+ TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
+ TcpDiscoverySpi disco = new TcpDiscoverySpi();
+
+ disco.setMaxMissedHeartbeats(Integer.MAX_VALUE);
+
+ disco.setIpFinder(ipFinder);
+
+ cfg.setDiscoverySpi(disco);
+
+ return cfg;
+ }
+
+ /** */
+ protected <K,V> CacheConfiguration<K, V> cacheConfiguration(String cacheName) {
+ return new CacheConfiguration<>(cacheName);
+ }
+
+ /**
* @throws Exception If failed.
*/
public void testSimpleIndexingSpi() throws Exception {
@@ -73,9 +98,7 @@ public class IndexingSpiQuerySelfTest extends TestCase {
Ignite ignite = Ignition.start(cfg);
- CacheConfiguration<Integer, Integer> ccfg = new CacheConfiguration<>("test-cache");
-
- ccfg.setIndexedTypes(Integer.class, Integer.class);
+ CacheConfiguration<Integer, Integer> ccfg = cacheConfiguration(CACHE_NAME);
IgniteCache<Integer, Integer> cache = ignite.createCache(ccfg);
@@ -98,7 +121,7 @@ public class IndexingSpiQuerySelfTest extends TestCase {
Ignite ignite = Ignition.start(cfg);
- CacheConfiguration<Integer, Integer> ccfg = new CacheConfiguration<>("test-cache");
+ CacheConfiguration<Integer, Integer> ccfg = cacheConfiguration(CACHE_NAME);
IgniteCache<Integer, Integer> cache = ignite.createCache(ccfg);
@@ -121,9 +144,7 @@ public class IndexingSpiQuerySelfTest extends TestCase {
Ignite ignite = Ignition.start(cfg);
- CacheConfiguration<PersonKey, Person> ccfg = new CacheConfiguration<>("test-binary-cache");
-
- ccfg.setIndexedTypes(PersonKey.class, Person.class);
+ CacheConfiguration<PersonKey, Person> ccfg = cacheConfiguration(CACHE_NAME);
IgniteCache<PersonKey, Person> cache = ignite.createCache(ccfg);
@@ -155,9 +176,7 @@ public class IndexingSpiQuerySelfTest extends TestCase {
Ignite ignite = Ignition.start(cfg);
- CacheConfiguration<PersonKey, Person> ccfg = new CacheConfiguration<>("test-binary-cache");
-
- ccfg.setIndexedTypes(PersonKey.class, Person.class);
+ CacheConfiguration<PersonKey, Person> ccfg = cacheConfiguration(CACHE_NAME);
IgniteCache<PersonKey, Person> cache = ignite.createCache(ccfg);
@@ -187,10 +206,9 @@ public class IndexingSpiQuerySelfTest extends TestCase {
Ignite ignite = Ignition.start(cfg);
- CacheConfiguration<Integer, Integer> ccfg = new CacheConfiguration<>("test-cache");
+ CacheConfiguration<Integer, Integer> ccfg = cacheConfiguration(CACHE_NAME);
ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
- ccfg.setIndexedTypes(Integer.class, Integer.class);
final IgniteCache<Integer, Integer> cache = ignite.createCache(ccfg);
@@ -219,24 +237,6 @@ public class IndexingSpiQuerySelfTest extends TestCase {
}
/**
- * @return Configuration.
- */
- private IgniteConfiguration configuration() {
- IgniteConfiguration cfg = new IgniteConfiguration();
-
- TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
- TcpDiscoverySpi disco = new TcpDiscoverySpi();
-
- disco.setMaxMissedHeartbeats(Integer.MAX_VALUE);
-
- disco.setIpFinder(ipFinder);
-
- cfg.setDiscoverySpi(disco);
-
- return cfg;
- }
-
- /**
* Indexing Spi implementation for test
*/
private static class MyIndexingSpi extends IgniteSpiAdapter implements IndexingSpi {
@@ -350,7 +350,7 @@ public class IndexingSpiQuerySelfTest extends TestCase {
/**
*
*/
- private static class PersonKey implements Serializable, Comparable<PersonKey> {
+ static class PersonKey implements Serializable, Comparable<PersonKey> {
/** */
private int id;
@@ -385,7 +385,7 @@ public class IndexingSpiQuerySelfTest extends TestCase {
/**
*
*/
- private static class Person implements Serializable {
+ static class Person implements Serializable {
/** */
private String name;
http://git-wip-us.apache.org/repos/asf/ignite/blob/a922ac9d/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/IndexingSpiQueryWithH2IndexingSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/IndexingSpiQueryWithH2IndexingSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/IndexingSpiQueryWithH2IndexingSelfTest.java
new file mode 100644
index 0000000..800c5a2
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/IndexingSpiQueryWithH2IndexingSelfTest.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache.query;
+
+import org.apache.ignite.configuration.CacheConfiguration;
+
+/**
+ * Indexing Spi query with configured default indexer test
+ */
+public class IndexingSpiQueryWithH2IndexingSelfTest extends IndexingSpiQuerySelfTest {
+ /** */
+ protected <K, V> CacheConfiguration<K, V> cacheConfiguration(String cacheName) {
+ CacheConfiguration<K, V> ccfg = super.cacheConfiguration(cacheName);
+
+ ccfg.setIndexedTypes(PersonKey.class, Person.class);
+
+ ccfg.setIndexedTypes(Integer.class, Integer.class);
+
+ return ccfg;
+ }
+}
\ No newline at end of file
[16/31] ignite git commit: Minor fixes in tests.
Posted by ak...@apache.org.
Minor fixes in tests.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/2305e383
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/2305e383
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/2305e383
Branch: refs/heads/ignite-4436-2
Commit: 2305e38345d8a7ca812d265d00eaca5bb7d6adb1
Parents: 2eb24ca
Author: Andrey V. Mashenkov <an...@gmail.com>
Authored: Wed Jan 18 14:57:53 2017 +0300
Committer: Andrey V. Mashenkov <an...@gmail.com>
Committed: Wed Jan 18 14:57:53 2017 +0300
----------------------------------------------------------------------
.../processors/cache/IgniteCacheAbstractQuerySelfTest.java | 4 ++--
...IgniteCacheDistributedQueryStopOnCancelOrTimeoutSelfTest.java | 3 ++-
...teCacheQueryStopOnCancelOrTimeoutDistributedJoinSelfTest.java | 3 ++-
3 files changed, 6 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/2305e383/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java
index c5a241e..9f56877 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java
@@ -642,7 +642,7 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
return null;
}
- }, IgniteException.class, null);
+ }, CacheException.class, null);
}
/**
@@ -688,7 +688,7 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
return null;
}
- }, IgniteException.class, null);
+ }, CacheException.class, null);
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/2305e383/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedQueryStopOnCancelOrTimeoutSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedQueryStopOnCancelOrTimeoutSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedQueryStopOnCancelOrTimeoutSelfTest.java
index 80c4a08..50fb034 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedQueryStopOnCancelOrTimeoutSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedQueryStopOnCancelOrTimeoutSelfTest.java
@@ -32,6 +32,7 @@ import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.IgniteEx;
import org.apache.ignite.cache.query.QueryCancelledException;
+import org.apache.ignite.internal.processors.GridProcessor;
import org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing;
import org.apache.ignite.internal.util.typedef.G;
import org.apache.ignite.internal.util.typedef.internal.U;
@@ -244,7 +245,7 @@ public class IgniteCacheDistributedQueryStopOnCancelOrTimeoutSelfTest extends Gr
IgniteEx grid = grid(i);
// Validate everything was cleaned up.
- ConcurrentMap<UUID, ?> map = U.field(((IgniteH2Indexing)U.field(U.field(
+ ConcurrentMap<UUID, ?> map = U.field(((IgniteH2Indexing)U.field((GridProcessor)U.field(
grid.context(), "qryProc"), "idx")).mapQueryExecutor(), "qryRess");
String msg = "Map executor state is not cleared";
http://git-wip-us.apache.org/repos/asf/ignite/blob/2305e383/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryStopOnCancelOrTimeoutDistributedJoinSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryStopOnCancelOrTimeoutDistributedJoinSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryStopOnCancelOrTimeoutDistributedJoinSelfTest.java
index 4baaf8f..3263b41 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryStopOnCancelOrTimeoutDistributedJoinSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryStopOnCancelOrTimeoutDistributedJoinSelfTest.java
@@ -29,6 +29,7 @@ import org.apache.ignite.cache.query.QueryCancelledException;
import org.apache.ignite.cache.query.QueryCursor;
import org.apache.ignite.cache.query.SqlFieldsQuery;
import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.processors.GridProcessor;
import org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing;
import org.apache.ignite.internal.util.typedef.internal.U;
@@ -122,7 +123,7 @@ public class IgniteCacheQueryStopOnCancelOrTimeoutDistributedJoinSelfTest extend
IgniteEx grid = grid(i);
// Validate everything was cleaned up.
- ConcurrentMap<UUID, ?> map = U.field(((IgniteH2Indexing) U.field(U.field(
+ ConcurrentMap<UUID, ?> map = U.field(((IgniteH2Indexing)U.field((GridProcessor)U.field(
grid.context(), "qryProc"), "idx")).mapQueryExecutor(), "qryRess");
String msg = "Map executor state is not cleared";
[06/31] ignite git commit: IGNITE-4518 Fixed parallel load of cache.
- Fixes #1426.
Posted by ak...@apache.org.
IGNITE-4518 Fixed parallel load of cache. - Fixes #1426.
Signed-off-by: Andrey Novikov <an...@gridgain.com>
(cherry picked from commit 79401b2)
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/c3eae9fe
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/c3eae9fe
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/c3eae9fe
Branch: refs/heads/ignite-4436-2
Commit: c3eae9fecff5ad01390170c034dca39c216a097c
Parents: 80f7325
Author: Andrey Novikov <an...@gridgain.com>
Authored: Mon Jan 16 10:33:16 2017 +0700
Committer: Andrey Novikov <an...@gridgain.com>
Committed: Tue Jan 17 12:43:01 2017 +0700
----------------------------------------------------------------------
.../store/jdbc/dialect/BasicJdbcDialect.java | 31 ++++++++-----
.../store/jdbc/CacheJdbcPojoStoreTest.java | 48 +++++++++++++++++++-
2 files changed, 66 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/c3eae9fe/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/dialect/BasicJdbcDialect.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/dialect/BasicJdbcDialect.java b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/dialect/BasicJdbcDialect.java
index 3ab112a..139f3fc 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/dialect/BasicJdbcDialect.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/dialect/BasicJdbcDialect.java
@@ -173,13 +173,15 @@ public class BasicJdbcDialect implements JdbcDialect {
if (appendLowerBound) {
sb.a("(");
- for (int cnt = keyCols.size(); cnt > 0; cnt--) {
- for (int j = 0; j < cnt; j++)
- if (j == cnt - 1)
- sb.a(cols[j]).a(" > ? ");
+ for (int keyCnt = keyCols.size(); keyCnt > 0; keyCnt--) {
+ for (int idx = 0; idx < keyCnt; idx++) {
+ if (idx == keyCnt - 1)
+ sb.a(cols[idx]).a(" > ? ");
else
- sb.a(cols[j]).a(" = ? AND ");
- if (cnt != 1)
+ sb.a(cols[idx]).a(" = ? AND ");
+ }
+
+ if (keyCnt != 1)
sb.a("OR ");
}
@@ -192,13 +194,18 @@ public class BasicJdbcDialect implements JdbcDialect {
if (appendUpperBound) {
sb.a("(");
- for (int cnt = keyCols.size(); cnt > 0; cnt--) {
- for (int j = 0; j < cnt; j++)
- if (j == cnt - 1)
- sb.a(cols[j]).a(" <= ? ");
+ for (int keyCnt = keyCols.size(); keyCnt > 0; keyCnt--) {
+ for (int idx = 0, lastIdx = keyCnt - 1; idx < keyCnt; idx++) {
+ sb.a(cols[idx]);
+
+ // For composite key when not all of the key columns are constrained should use < (strictly less).
+ if (idx == lastIdx)
+ sb.a(keyCnt == keyCols.size() ? " <= ? " : " < ? ");
else
- sb.a(cols[j]).a(" = ? AND ");
- if (cnt != 1)
+ sb.a(" = ? AND ");
+ }
+
+ if (keyCnt != 1)
sb.a(" OR ");
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c3eae9fe/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreTest.java b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreTest.java
index d8f75d3..4a0b1da 100644
--- a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreTest.java
@@ -216,7 +216,7 @@ public class CacheJdbcPojoStoreTest extends GridAbstractCacheStoreSelfTest<Cache
stmt.executeUpdate("CREATE TABLE IF NOT EXISTS " +
"Person_Complex (id integer not null, org_id integer not null, city_id integer not null, " +
- "name varchar(50), salary integer, PRIMARY KEY(id))");
+ "name varchar(50), salary integer, PRIMARY KEY(id, org_id, city_id))");
conn.commit();
@@ -352,6 +352,52 @@ public class CacheJdbcPojoStoreTest extends GridAbstractCacheStoreSelfTest<Cache
/**
* @throws Exception If failed.
*/
+ public void testParallelLoad() throws Exception {
+ Connection conn = store.openConnection(false);
+
+ PreparedStatement prnComplexStmt = conn.prepareStatement("INSERT INTO Person_Complex(id, org_id, city_id, name, salary) VALUES (?, ?, ?, ?, ?)");
+
+ for (int i = 0; i < 8; i++) {
+
+ prnComplexStmt.setInt(1, (i >> 2) & 1);
+ prnComplexStmt.setInt(2, (i >> 1) & 1);
+ prnComplexStmt.setInt(3, i % 2);
+
+ prnComplexStmt.setString(4, "name");
+ prnComplexStmt.setInt(5, 1000 + i * 500);
+
+ prnComplexStmt.addBatch();
+ }
+
+ prnComplexStmt.executeBatch();
+
+ U.closeQuiet(prnComplexStmt);
+
+ conn.commit();
+
+ U.closeQuiet(conn);
+
+ final Collection<PersonComplexKey> prnComplexKeys = new ConcurrentLinkedQueue<>();
+
+ IgniteBiInClosure<Object, Object> c = new CI2<Object, Object>() {
+ @Override public void apply(Object k, Object v) {
+ if (k instanceof PersonComplexKey && v instanceof Person)
+ prnComplexKeys.add((PersonComplexKey)k);
+ else
+ fail("Unexpected entry [key=" + k + ", value=" + v + "]");
+ }
+ };
+
+ store.setParallelLoadCacheMinimumThreshold(2);
+
+ store.loadCache(c);
+
+ assertEquals(8, prnComplexKeys.size());
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
public void testWriteRetry() throws Exception {
CacheJdbcPojoStore<Object, Object> store = store();
[08/31] ignite git commit: ignite-4465 Prevent cache entry eviction
while it is loaded from store (otherwise loaded value can be not stored in
cache).
Posted by ak...@apache.org.
ignite-4465 Prevent cache entry eviction while it is loaded from store (otherwise loaded value can be not stored in cache).
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/22b7e76c
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/22b7e76c
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/22b7e76c
Branch: refs/heads/ignite-4436-2
Commit: 22b7e76c00a77a06388bcef869f29d1a572a306a
Parents: 7117647
Author: sboikov <sb...@gridgain.com>
Authored: Tue Jan 17 12:33:32 2017 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Tue Jan 17 12:33:32 2017 +0300
----------------------------------------------------------------------
.../processors/cache/EntryGetResult.java | 65 +++++++
.../processors/cache/GridCacheAdapter.java | 104 ++++++-----
.../processors/cache/GridCacheEntryEx.java | 30 ++-
.../processors/cache/GridCacheMapEntry.java | 100 ++++++++--
.../dht/GridPartitionedGetFuture.java | 7 +-
.../dht/GridPartitionedSingleGetFuture.java | 7 +-
.../dht/atomic/GridDhtAtomicCache.java | 7 +-
.../dht/colocated/GridDhtColocatedCache.java | 7 +-
.../distributed/near/GridNearGetFuture.java | 13 +-
.../local/atomic/GridLocalAtomicCache.java | 7 +-
.../cache/transactions/IgniteTxHandler.java | 2 +-
.../transactions/IgniteTxLocalAdapter.java | 29 +--
.../cache/CacheConcurrentReadThroughTest.java | 184 +++++++++++++++++++
.../cache/CrossCacheTxRandomOperationsTest.java | 28 ++-
.../processors/cache/GridCacheTestEntryEx.java | 21 ++-
.../testsuites/IgniteCacheTestSuite2.java | 2 +
16 files changed, 512 insertions(+), 101 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/22b7e76c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/EntryGetResult.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/EntryGetResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/EntryGetResult.java
new file mode 100644
index 0000000..a34ddae
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/EntryGetResult.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache;
+
+import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
+
+/**
+ *
+ */
+public class EntryGetResult {
+ /** */
+ private final CacheObject val;
+
+ /** */
+ private final GridCacheVersion ver;
+
+ /** */
+ private final boolean reserved;
+
+ /**
+ * @param val Value.
+ * @param ver Version.
+ */
+ EntryGetResult(CacheObject val, GridCacheVersion ver, boolean reserved) {
+ this.val = val;
+ this.ver = ver;
+ this.reserved = reserved;
+ }
+
+ /**
+ * @return Value.
+ */
+ public CacheObject value() {
+ return val;
+ }
+
+ /**
+ * @return Version.
+ */
+ public GridCacheVersion version() {
+ return ver;
+ }
+
+ /**
+ * @return Reserved flag,
+ */
+ public boolean reserved() {
+ return reserved;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/22b7e76c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
index 965c6d1..fd9f396 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
@@ -1860,7 +1860,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
* @param needVer If {@code true} returns values as tuples containing value and version.
* @return Future.
*/
- public final <K1, V1> IgniteInternalFuture<Map<K1, V1>> getAllAsync0(
+ protected final <K1, V1> IgniteInternalFuture<Map<K1, V1>> getAllAsync0(
@Nullable final Collection<KeyCacheObject> keys,
final boolean readThrough,
boolean checkTx,
@@ -1906,7 +1906,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
final boolean needEntry = storeEnabled || ctx.isSwapOrOffheapEnabled();
- Map<KeyCacheObject, GridCacheVersion> misses = null;
+ Map<KeyCacheObject, EntryGetResult> misses = null;
for (KeyCacheObject key : keys) {
while (true) {
@@ -1920,40 +1920,58 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
}
try {
- T2<CacheObject, GridCacheVersion> res = entry.innerGetVersioned(
- null,
- null,
- ctx.isSwapOrOffheapEnabled(),
- /*unmarshal*/true,
- /*update-metrics*/!skipVals,
- /*event*/!skipVals,
- subjId,
- null,
- taskName,
- expiry,
- !deserializeBinary);
-
- if (res == null) {
- if (storeEnabled) {
- GridCacheVersion ver = entry.version();
+ EntryGetResult res;
+ boolean evt = !skipVals;
+ boolean updateMetrics = !skipVals;
+
+ if (storeEnabled) {
+ res = entry.innerGetAndReserveForLoad(ctx.isSwapOrOffheapEnabled(),
+ updateMetrics,
+ evt,
+ subjId,
+ taskName,
+ expiry,
+ !deserializeBinary);
+
+ assert res != null;
+
+ if (res.value() == null) {
if (misses == null)
misses = new HashMap<>();
- misses.put(key, ver);
+ misses.put(key, res);
+
+ res = null;
}
- else
- ctx.evicts().touch(entry, topVer);
}
else {
+ res = entry.innerGetVersioned(
+ null,
+ null,
+ ctx.isSwapOrOffheapEnabled(),
+ /*unmarshal*/true,
+ updateMetrics,
+ evt,
+ subjId,
+ null,
+ taskName,
+ expiry,
+ !deserializeBinary);
+
+ if (res == null)
+ ctx.evicts().touch(entry, topVer);
+ }
+
+ if (res != null) {
ctx.addResult(map,
key,
- res.get1(),
+ res.value(),
skipVals,
keepCacheObjects,
deserializeBinary,
true,
- needVer ? res.get2() : null);
+ needVer ? res.version() : null);
if (tx == null || (!tx.implicit() && tx.isolation() == READ_COMMITTED))
ctx.evicts().touch(entry, topVer);
@@ -1973,7 +1991,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
}
if (storeEnabled && misses != null) {
- final Map<KeyCacheObject, GridCacheVersion> loadKeys = misses;
+ final Map<KeyCacheObject, EntryGetResult> loadKeys = misses;
final IgniteTxLocalAdapter tx0 = tx;
@@ -1984,15 +2002,10 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
@Override public Map<K1, V1> call() throws Exception {
ctx.store().loadAll(null/*tx*/, loadKeys.keySet(), new CI2<KeyCacheObject, Object>() {
@Override public void apply(KeyCacheObject key, Object val) {
- GridCacheVersion ver = loadKeys.get(key);
-
- if (ver == null) {
- if (log.isDebugEnabled())
- log.debug("Value from storage was never asked for [key=" + key +
- ", val=" + val + ']');
+ EntryGetResult res = loadKeys.get(key);
+ if (res == null || val == null)
return;
- }
loaded.add(key);
@@ -2002,14 +2015,16 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
GridCacheEntryEx entry = entryEx(key);
try {
- GridCacheVersion verSet = entry.versionedValue(cacheVal, ver, null);
+ GridCacheVersion verSet = entry.versionedValue(cacheVal,
+ res.version(),
+ null);
boolean set = verSet != null;
if (log.isDebugEnabled())
log.debug("Set value loaded from store into entry [" +
"set=" + set +
- ", curVer=" + ver +
+ ", curVer=" + res.version() +
", newVer=" + verSet + ", " +
"entry=" + entry + ']');
@@ -2022,7 +2037,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
keepCacheObjects,
deserializeBinary,
false,
- needVer ? set ? verSet : ver : null);
+ needVer ? set ? verSet : res.version() : null);
}
if (tx0 == null || (!tx0.implicit() &&
@@ -2045,16 +2060,23 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
});
if (loaded.size() != loadKeys.size()) {
- for (KeyCacheObject key : loadKeys.keySet()) {
- if (loaded.contains(key))
+ boolean needTouch =
+ tx0 == null || (!tx0.implicit() && tx0.isolation() == READ_COMMITTED);
+
+ for (Map.Entry<KeyCacheObject, EntryGetResult> e : loadKeys.entrySet()) {
+ if (loaded.contains(e.getKey()))
continue;
- if (tx0 == null || (!tx0.implicit() &&
- tx0.isolation() == READ_COMMITTED)) {
- GridCacheEntryEx entry = peekEx(key);
+ if (needTouch || e.getValue().reserved()) {
+ GridCacheEntryEx entry = peekEx(e.getKey());
- if (entry != null)
- ctx.evicts().touch(entry, topVer);
+ if (entry != null) {
+ if (e.getValue().reserved())
+ entry.clearReserveForLoad(e.getValue().version());
+
+ if (needTouch)
+ ctx.evicts().touch(entry, topVer);
+ }
}
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/22b7e76c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java
index d8194fc..b1d632f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java
@@ -34,7 +34,6 @@ import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersionedEntryEx;
import org.apache.ignite.internal.processors.dr.GridDrType;
import org.apache.ignite.internal.util.lang.GridTuple3;
-import org.apache.ignite.internal.util.typedef.T2;
import org.jetbrains.annotations.Nullable;
/**
@@ -323,7 +322,7 @@ public interface GridCacheEntryEx {
* @throws IgniteCheckedException If loading value failed.
* @throws GridCacheEntryRemovedException If entry was removed.
*/
- @Nullable public T2<CacheObject, GridCacheVersion> innerGetVersioned(
+ @Nullable public EntryGetResult innerGetVersioned(
@Nullable GridCacheVersion ver,
IgniteInternalTx tx,
boolean readSwap,
@@ -338,6 +337,33 @@ public interface GridCacheEntryEx {
throws IgniteCheckedException, GridCacheEntryRemovedException;
/**
+ * @param readSwap Flag indicating whether to check swap memory.
+ * @param updateMetrics If {@code true} then metrics should be updated.
+ * @param evt Flag to signal event notification.
+ * @param subjId Subject ID initiated this read.
+ * @param taskName Task name.
+ * @param expiryPlc Expiry policy.
+ * @param keepBinary Keep binary flag.
+ * @return Cached value and entry version.
+ * @throws IgniteCheckedException If loading value failed.
+ * @throws GridCacheEntryRemovedException If entry was removed.
+ * @return Cached value, entry version and flag indicating if entry was reserved.
+ */
+ public EntryGetResult innerGetAndReserveForLoad(boolean readSwap,
+ boolean updateMetrics,
+ boolean evt,
+ UUID subjId,
+ String taskName,
+ @Nullable IgniteCacheExpiryPolicy expiryPlc,
+ boolean keepBinary) throws IgniteCheckedException, GridCacheEntryRemovedException;
+
+ /**
+ * @param ver Expected entry version.
+ * @throws IgniteCheckedException If failed.
+ */
+ public void clearReserveForLoad(GridCacheVersion ver) throws IgniteCheckedException;
+
+ /**
* Reloads entry from underlying storage.
*
* @return Reloaded value.
http://git-wip-us.apache.org/repos/asf/ignite/blob/22b7e76c/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 31baeda..9f0c2b0 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
@@ -106,6 +106,9 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
private static final byte IS_SWAPPING_REQUIRED = 0x08;
/** */
+ private static final byte IS_EVICT_DISABLED = 0x10;
+
+ /** */
public static final GridCacheAtomicVersionComparator ATOMIC_VER_COMPARATOR = new GridCacheAtomicVersionComparator();
/**
@@ -774,11 +777,37 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
taskName,
expirePlc,
false,
- keepBinary);
+ keepBinary,
+ false);
}
/** {@inheritDoc} */
- @Nullable @Override public T2<CacheObject, GridCacheVersion> innerGetVersioned(
+ @Override public EntryGetResult innerGetAndReserveForLoad(boolean readSwap,
+ boolean updateMetrics,
+ boolean evt,
+ UUID subjId,
+ String taskName,
+ @Nullable IgniteCacheExpiryPolicy expiryPlc,
+ boolean keepBinary) throws IgniteCheckedException, GridCacheEntryRemovedException {
+ return (EntryGetResult)innerGet0(
+ /*ver*/null,
+ /*tx*/null,
+ readSwap,
+ /*readThrough*/false,
+ evt,
+ updateMetrics,
+ /*tmp*/false,
+ subjId,
+ /*transformClo*/null,
+ taskName,
+ expiryPlc,
+ true,
+ keepBinary,
+ /*reserve*/true);
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public EntryGetResult innerGetVersioned(
@Nullable GridCacheVersion ver,
IgniteInternalTx tx,
boolean readSwap,
@@ -791,7 +820,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
@Nullable IgniteCacheExpiryPolicy expiryPlc,
boolean keepBinary)
throws IgniteCheckedException, GridCacheEntryRemovedException {
- return (T2<CacheObject, GridCacheVersion>)innerGet0(ver,
+ return (EntryGetResult)innerGet0(ver,
tx,
readSwap,
false,
@@ -803,7 +832,8 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
taskName,
expiryPlc,
true,
- keepBinary);
+ keepBinary,
+ false);
}
/** {@inheritDoc} */
@@ -821,16 +851,16 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
String taskName,
@Nullable IgniteCacheExpiryPolicy expiryPlc,
boolean retVer,
- boolean keepBinary
+ boolean keepBinary,
+ boolean reserveForLoad
) throws IgniteCheckedException, GridCacheEntryRemovedException {
assert !(retVer && readThrough);
+ assert !(reserveForLoad && readThrough);
// Disable read-through if there is no store.
if (readThrough && !cctx.readThrough())
readThrough = false;
- CacheObject ret;
-
GridCacheVersion startVer;
GridCacheVersion resVer = null;
@@ -838,6 +868,8 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
boolean deferred = false;
GridCacheVersion ver0 = null;
+ Object res = null;
+
synchronized (this) {
checkObsolete();
@@ -881,7 +913,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
else
val = null;
- ret = val;
+ CacheObject ret = val;
if (ret == null) {
if (updateMetrics && cctx.cache().configuration().isStatisticsEnabled())
@@ -928,15 +960,26 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
// Cache version for optimistic check.
startVer = ver;
- }
- if (ret != null) {
- assert tmp || !(ret instanceof BinaryObjectOffheapImpl);
- assert !obsolete;
- assert !deferred;
+ if (ret != null) {
+ assert tmp || !(ret instanceof BinaryObjectOffheapImpl);
+ assert !obsolete;
+ assert !deferred;
+
+ // If return value is consistent, then done.
+ res = retVer ? new EntryGetResult(ret, resVer, false) : ret;
+ }
+ else if (reserveForLoad && !obsolete) {
+ assert !readThrough;
+ assert retVer;
+
+ boolean reserve = !evictionDisabled();
- // If return value is consistent, then done.
- return retVer ? new T2<>(ret, resVer) : ret;
+ if (reserve)
+ flags |= IS_EVICT_DISABLED;
+
+ res = new EntryGetResult(null, resVer, reserve);
+ }
}
if (obsolete) {
@@ -948,6 +991,11 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
if (deferred)
cctx.onDeferredDelete(this, ver0);
+ if (res != null)
+ return res;
+
+ CacheObject ret = null;
+
if (readThrough) {
IgniteInternalTx tx0 = null;
@@ -2926,7 +2974,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
* @return {@code True} if this entry should not be evicted from cache.
*/
protected boolean evictionDisabled() {
- return false;
+ return (flags & IS_EVICT_DISABLED) != 0;
}
/**
@@ -3008,6 +3056,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
value(null);
ver = newVer;
+ flags &= ~IS_EVICT_DISABLED;
if (log.isTraceEnabled()) {
log.trace("invalidate releaseSwap [key=" + key +
@@ -3096,6 +3145,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
ttlAndExpireTimeExtras(ttl, expireTime);
this.ver = ver;
+ flags &= ~IS_EVICT_DISABLED;
if (addTracked && expireTime != 0 && (expireTime != oldExpireTime || isStartVersion()) && cctx.config().isEagerTtl())
cctx.ttl().addTrackedEntry(this);
@@ -3549,11 +3599,23 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
}
/** {@inheritDoc} */
+ @Override public synchronized void clearReserveForLoad(GridCacheVersion ver) throws IgniteCheckedException {
+ if (obsoleteVersionExtras() != null)
+ return;
+
+ if (ver.equals(this.ver)) {
+ assert evictionDisabled() : this;
+
+ flags &= ~IS_EVICT_DISABLED;
+ }
+ }
+
+ /** {@inheritDoc} */
@Override public synchronized GridCacheVersion versionedValue(CacheObject val,
GridCacheVersion curVer,
GridCacheVersion newVer)
- throws IgniteCheckedException, GridCacheEntryRemovedException {
-
+ throws IgniteCheckedException, GridCacheEntryRemovedException
+ {
checkObsolete();
if (curVer == null || curVer.equals(ver)) {
@@ -3587,6 +3649,8 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
return newVer;
}
+
+ assert !evictionDisabled() : this;
}
return null;
http://git-wip-us.apache.org/repos/asf/ignite/blob/22b7e76c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java
index 2e22d9e..d0f209d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java
@@ -33,6 +33,7 @@ import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
import org.apache.ignite.internal.cluster.ClusterTopologyServerNotFoundException;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
import org.apache.ignite.internal.processors.cache.CacheObject;
+import org.apache.ignite.internal.processors.cache.EntryGetResult;
import org.apache.ignite.internal.processors.cache.GridCacheContext;
import org.apache.ignite.internal.processors.cache.GridCacheEntryEx;
import org.apache.ignite.internal.processors.cache.GridCacheEntryInfo;
@@ -449,7 +450,7 @@ public class GridPartitionedGetFuture<K, V> extends CacheDistributedGetFutureAda
GridCacheVersion ver = null;
if (needVer) {
- T2<CacheObject, GridCacheVersion> res = entry.innerGetVersioned(
+ EntryGetResult res = entry.innerGetVersioned(
null,
null,
/*swap*/true,
@@ -463,8 +464,8 @@ public class GridPartitionedGetFuture<K, V> extends CacheDistributedGetFutureAda
!deserializeBinary);
if (res != null) {
- v = res.get1();
- ver = res.get2();
+ v = res.value();
+ ver = res.version();
}
}
else {
http://git-wip-us.apache.org/repos/asf/ignite/blob/22b7e76c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java
index aeb7eba..e188a35 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java
@@ -31,6 +31,7 @@ import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
import org.apache.ignite.internal.cluster.ClusterTopologyServerNotFoundException;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
import org.apache.ignite.internal.processors.cache.CacheObject;
+import org.apache.ignite.internal.processors.cache.EntryGetResult;
import org.apache.ignite.internal.processors.cache.GridCacheContext;
import org.apache.ignite.internal.processors.cache.GridCacheEntryEx;
import org.apache.ignite.internal.processors.cache.GridCacheEntryInfo;
@@ -373,7 +374,7 @@ public class GridPartitionedSingleGetFuture extends GridFutureAdapter<Object> im
GridCacheVersion ver = null;
if (needVer) {
- T2<CacheObject, GridCacheVersion> res = entry.innerGetVersioned(
+ EntryGetResult res = entry.innerGetVersioned(
null,
null,
/*swap*/true,
@@ -387,8 +388,8 @@ public class GridPartitionedSingleGetFuture extends GridFutureAdapter<Object> im
true);
if (res != null) {
- v = res.get1();
- ver = res.get2();
+ v = res.value();
+ ver = res.version();
}
}
else {
http://git-wip-us.apache.org/repos/asf/ignite/blob/22b7e76c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
index 940c74e..94a049e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
@@ -48,6 +48,7 @@ import org.apache.ignite.internal.processors.cache.CacheMetricsImpl;
import org.apache.ignite.internal.processors.cache.CacheObject;
import org.apache.ignite.internal.processors.cache.CacheOperationContext;
import org.apache.ignite.internal.processors.cache.CacheStorePartialUpdateException;
+import org.apache.ignite.internal.processors.cache.EntryGetResult;
import org.apache.ignite.internal.processors.cache.GridCacheConcurrentMap;
import org.apache.ignite.internal.processors.cache.GridCacheContext;
import org.apache.ignite.internal.processors.cache.GridCacheEntryEx;
@@ -1493,7 +1494,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
GridCacheVersion ver = null;
if (needVer) {
- T2<CacheObject, GridCacheVersion> res = entry.innerGetVersioned(
+ EntryGetResult res = entry.innerGetVersioned(
null,
null,
/*swap*/true,
@@ -1507,8 +1508,8 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
true);
if (res != null) {
- v = res.get1();
- ver = res.get2();
+ v = res.value();
+ ver = res.version();
}
}
else {
http://git-wip-us.apache.org/repos/asf/ignite/blob/22b7e76c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
index 176a90f..56af95e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
@@ -32,6 +32,7 @@ import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
import org.apache.ignite.internal.processors.cache.CacheEntryPredicate;
import org.apache.ignite.internal.processors.cache.CacheObject;
import org.apache.ignite.internal.processors.cache.CacheOperationContext;
+import org.apache.ignite.internal.processors.cache.EntryGetResult;
import org.apache.ignite.internal.processors.cache.GridCacheConcurrentMap;
import org.apache.ignite.internal.processors.cache.GridCacheContext;
import org.apache.ignite.internal.processors.cache.GridCacheEntryEx;
@@ -484,7 +485,7 @@ public class GridDhtColocatedCache<K, V> extends GridDhtTransactionalCacheAdapte
GridCacheVersion ver = null;
if (needVer) {
- T2<CacheObject, GridCacheVersion> res = entry.innerGetVersioned(
+ EntryGetResult res = entry.innerGetVersioned(
null,
null,
/*swap*/true,
@@ -498,8 +499,8 @@ public class GridDhtColocatedCache<K, V> extends GridDhtTransactionalCacheAdapte
!deserializeBinary);
if (res != null) {
- v = res.get1();
- ver = res.get2();
+ v = res.value();
+ ver = res.version();
}
}
else {
http://git-wip-us.apache.org/repos/asf/ignite/blob/22b7e76c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java
index b7fcbbd..ab0e88c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java
@@ -33,6 +33,7 @@ import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
import org.apache.ignite.internal.cluster.ClusterTopologyServerNotFoundException;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
import org.apache.ignite.internal.processors.cache.CacheObject;
+import org.apache.ignite.internal.processors.cache.EntryGetResult;
import org.apache.ignite.internal.processors.cache.GridCacheContext;
import org.apache.ignite.internal.processors.cache.GridCacheEntryEx;
import org.apache.ignite.internal.processors.cache.GridCacheEntryInfo;
@@ -437,7 +438,7 @@ public final class GridNearGetFuture<K, V> extends CacheDistributedGetFutureAdap
// First we peek into near cache.
if (isNear) {
if (needVer) {
- T2<CacheObject, GridCacheVersion> res = entry.innerGetVersioned(
+ EntryGetResult res = entry.innerGetVersioned(
null,
null,
/*swap*/true,
@@ -451,8 +452,8 @@ public final class GridNearGetFuture<K, V> extends CacheDistributedGetFutureAdap
!deserializeBinary);
if (res != null) {
- v = res.get1();
- ver = res.get2();
+ v = res.value();
+ ver = res.version();
}
}
else {
@@ -577,7 +578,7 @@ public final class GridNearGetFuture<K, V> extends CacheDistributedGetFutureAdap
boolean isNew = dhtEntry.isNewLocked() || !dhtEntry.valid(topVer);
if (needVer) {
- T2<CacheObject, GridCacheVersion> res = dhtEntry.innerGetVersioned(
+ EntryGetResult res = dhtEntry.innerGetVersioned(
null,
null,
/*swap*/true,
@@ -591,8 +592,8 @@ public final class GridNearGetFuture<K, V> extends CacheDistributedGetFutureAdap
!deserializeBinary);
if (res != null) {
- v = res.get1();
- ver = res.get2();
+ v = res.value();
+ ver = res.version();
}
}
else {
http://git-wip-us.apache.org/repos/asf/ignite/blob/22b7e76c/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 a419887..d1acada 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
@@ -45,6 +45,7 @@ import org.apache.ignite.internal.processors.cache.CacheObject;
import org.apache.ignite.internal.processors.cache.CacheOperationContext;
import org.apache.ignite.internal.processors.cache.CachePartialUpdateCheckedException;
import org.apache.ignite.internal.processors.cache.CacheStorePartialUpdateException;
+import org.apache.ignite.internal.processors.cache.EntryGetResult;
import org.apache.ignite.internal.processors.cache.GridCacheContext;
import org.apache.ignite.internal.processors.cache.GridCacheEntryEx;
import org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedException;
@@ -516,7 +517,7 @@ public class GridLocalAtomicCache<K, V> extends GridLocalCache<K, V> {
GridCacheVersion ver;
if (needVer) {
- T2<CacheObject, GridCacheVersion> res = entry.innerGetVersioned(
+ EntryGetResult res = entry.innerGetVersioned(
null,
null,
/*swap*/swapOrOffheap,
@@ -530,8 +531,8 @@ public class GridLocalAtomicCache<K, V> extends GridLocalCache<K, V> {
!deserializeBinary);
if (res != null) {
- v = res.get1();
- ver = res.get2();
+ v = res.value();
+ ver = res.version();
ctx.addResult(
vals,
http://git-wip-us.apache.org/repos/asf/ignite/blob/22b7e76c/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 cf69264..f784ba2 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
@@ -1141,7 +1141,7 @@ public class IgniteTxHandler {
else
sendReply(nodeId, req, true, null);
- assert req.txState() != null || (ctx.tm().tx(req.version()) == null && ctx.tm().nearTx(req.version()) == null);
+ assert req.txState() != null || (ctx.tm().tx(req.version()) == null && ctx.tm().nearTx(req.version()) == null) : req;
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/22b7e76c/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 e2f8438..91c9c92 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.EntryGetResult;
import org.apache.ignite.internal.processors.cache.EntryProcessorResourceInjectorProxy;
import org.apache.ignite.internal.processors.cache.GridCacheContext;
import org.apache.ignite.internal.processors.cache.GridCacheEntryEx;
@@ -426,7 +427,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
continue;
try {
- T2<CacheObject, GridCacheVersion> res = entry.innerGetVersioned(
+ EntryGetResult res = entry.innerGetVersioned(
null,
this,
/*readSwap*/true,
@@ -446,7 +447,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
misses.put(key, entry.version());
}
else
- c.apply(key, skipVals ? true : res.get1(), res.get2());
+ c.apply(key, skipVals ? true : res.value(), res.version());
break;
}
@@ -1220,7 +1221,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
F.first(txEntry.entryProcessors()) : null;
if (needVer) {
- T2<CacheObject, GridCacheVersion> res = txEntry.cached().innerGetVersioned(
+ EntryGetResult res = txEntry.cached().innerGetVersioned(
null,
this,
/*swap*/true,
@@ -1234,8 +1235,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
txEntry.keepBinary());
if (res != null) {
- val = res.get1();
- readVer = res.get2();
+ val = res.value();
+ readVer = res.version();
}
}
else {
@@ -1303,7 +1304,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
optimistic() ? accessPolicy(cacheCtx, txKey, expiryPlc) : null;
if (needReadVer) {
- T2<CacheObject, GridCacheVersion> res = primaryLocal(entry) ?
+ EntryGetResult res = primaryLocal(entry) ?
entry.innerGetVersioned(
null,
this,
@@ -1318,8 +1319,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
!deserializeBinary) : null;
if (res != null) {
- val = res.get1();
- readVer = res.get2();
+ val = res.value();
+ readVer = res.version();
}
}
else {
@@ -1654,7 +1655,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
F.first(txEntry.entryProcessors()) : null;
if (needVer) {
- T2<CacheObject, GridCacheVersion> res = cached.innerGetVersioned(
+ EntryGetResult res = cached.innerGetVersioned(
null,
IgniteTxLocalAdapter.this,
/*swap*/cacheCtx.isSwapOrOffheapEnabled(),
@@ -1668,8 +1669,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
txEntry.keepBinary());
if (res != null) {
- val = res.get1();
- readVer = res.get2();
+ val = res.value();
+ readVer = res.version();
}
}
else{
@@ -2377,7 +2378,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
if (optimistic() && !implicit()) {
try {
if (needReadVer) {
- T2<CacheObject, GridCacheVersion> res = primaryLocal(entry) ?
+ EntryGetResult res = primaryLocal(entry) ?
entry.innerGetVersioned(
null,
this,
@@ -2392,8 +2393,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
keepBinary) : null;
if (res != null) {
- old = res.get1();
- readVer = res.get2();
+ old = res.value();
+ readVer = res.version();
}
}
else {
http://git-wip-us.apache.org/repos/asf/ignite/blob/22b7e76c/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheConcurrentReadThroughTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheConcurrentReadThroughTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheConcurrentReadThroughTest.java
new file mode 100644
index 0000000..87baa49
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheConcurrentReadThroughTest.java
@@ -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.
+ */
+
+package org.apache.ignite.internal.processors.cache;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.concurrent.atomic.AtomicInteger;
+import javax.cache.Cache;
+import javax.cache.configuration.Factory;
+import javax.cache.integration.CacheLoaderException;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCompute;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.cache.store.CacheStoreAdapter;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.lang.IgniteFuture;
+import org.apache.ignite.lang.IgniteRunnable;
+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.junits.common.GridCommonAbstractTest;
+
+/**
+ * Test was added to check fix for IGNITE-4465.
+ */
+public class CacheConcurrentReadThroughTest extends GridCommonAbstractTest {
+ /** */
+ private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
+
+ /** */
+ private static final int SYS_THREADS = 16;
+
+ /** */
+ private boolean client;
+
+ /** {@inheritDoc} */
+ @SuppressWarnings("unchecked")
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder);
+
+ cfg.setClientMode(client);
+
+ if (!client) {
+ cfg.setPublicThreadPoolSize(SYS_THREADS);
+ cfg.setSystemThreadPoolSize(SYS_THREADS);
+ }
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ super.afterTest();
+
+ stopAllGrids();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testConcurrentReadThrough() throws Exception {
+ startGrid(0);
+
+ client = true;
+
+ Ignite client = startGrid(1);
+
+ assertTrue(client.configuration().isClientMode());
+
+ IgniteCompute compute = client.compute().withAsync();
+
+ for (int iter = 0; iter < 10; iter++) {
+ CacheConfiguration ccfg = new CacheConfiguration();
+
+ final String cacheName = "test-" + iter;
+
+ ccfg.setName(cacheName);
+ ccfg.setReadThrough(true);
+ ccfg.setCacheStoreFactory(new TestStoreFactory());
+ ccfg.setStatisticsEnabled(true);
+
+ client.createCache(ccfg);
+
+ final Integer key = 1;
+
+ TestCacheStore.loadCnt.set(0);
+
+ Collection<IgniteFuture<?>> futs = new ArrayList<>();
+
+ for (int i = 0; i < SYS_THREADS * 3; i++) {
+ compute.run(new IgniteRunnable() {
+ @IgniteInstanceResource
+ private transient Ignite ignite;
+
+ @Override public void run() {
+ assertFalse(ignite.configuration().isClientMode());
+
+ Object v = ignite.<Integer, Integer>cache(cacheName).get(key);
+
+ if (v == null)
+ throw new IgniteException("Failed to get value");
+ }
+ });
+
+ futs.add(compute.future());
+ }
+
+ for (IgniteFuture<?> fut : futs)
+ fut.get();
+
+ int loadCnt = TestCacheStore.loadCnt.get();
+
+ long misses = ignite(1).cache(cacheName).metrics().getCacheMisses();
+
+ log.info("Iteration [iter=" + iter + ", loadCnt=" + loadCnt + ", misses=" + misses + ']');
+
+ assertTrue("Unexpected loadCnt: " + loadCnt, loadCnt > 0 && loadCnt <= SYS_THREADS);
+ assertTrue("Unexpected misses: " + misses, misses > 0 && misses <= SYS_THREADS);
+
+ client.destroyCache(cacheName);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class TestStoreFactory implements Factory<TestCacheStore> {
+ /** {@inheritDoc} */
+ @Override public TestCacheStore create() {
+ return new TestCacheStore();
+ }
+ }
+
+ /**
+ *
+ */
+ private static class TestCacheStore extends CacheStoreAdapter<Integer, Integer> {
+ /** */
+ private static final AtomicInteger loadCnt = new AtomicInteger();
+
+ /** {@inheritDoc} */
+ @Override public Integer load(Integer key) throws CacheLoaderException {
+ loadCnt.incrementAndGet();
+
+ try {
+ Thread.sleep(1000);
+ }
+ catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+
+ return key;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void write(Cache.Entry<? extends Integer, ? extends Integer> entry) {
+ throw new UnsupportedOperationException();
+ }
+
+ /** {@inheritDoc} */
+ @Override public void delete(Object key) {
+ // No-op.
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/22b7e76c/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CrossCacheTxRandomOperationsTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CrossCacheTxRandomOperationsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CrossCacheTxRandomOperationsTest.java
index 67ec371..e7df3c0 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CrossCacheTxRandomOperationsTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CrossCacheTxRandomOperationsTest.java
@@ -86,6 +86,11 @@ public class CrossCacheTxRandomOperationsTest extends GridCommonAbstractTest {
}
/** {@inheritDoc} */
+ @Override protected long getTestTimeout() {
+ return 6 * 60 * 1000;
+ }
+
+ /** {@inheritDoc} */
@Override protected void beforeTestsStarted() throws Exception {
super.beforeTestsStarted();
@@ -170,9 +175,17 @@ public class CrossCacheTxRandomOperationsTest extends GridCommonAbstractTest {
}
/**
+ * @param cacheMode Cache mode.
+ * @param writeSync Write synchronization mode.
+ * @param fairAff Fair affinity flag.
+ * @param ignite Node to use.
+ * @param name Cache name.
*/
- protected void createCache(CacheMode cacheMode, CacheWriteSynchronizationMode writeSync, boolean fairAff,
- Ignite ignite, String name) {
+ protected void createCache(CacheMode cacheMode,
+ CacheWriteSynchronizationMode writeSync,
+ boolean fairAff,
+ Ignite ignite,
+ String name) {
ignite.createCache(cacheConfiguration(name, cacheMode, writeSync, fairAff));
}
@@ -269,9 +282,18 @@ public class CrossCacheTxRandomOperationsTest extends GridCommonAbstractTest {
boolean checkData = fullSync && !optimistic;
+ long stopTime = System.currentTimeMillis() + 10_000;
+
for (int i = 0; i < 10_000; i++) {
- if (i % 100 == 0)
+ if (i % 100 == 0) {
+ if (System.currentTimeMillis() > stopTime) {
+ log.info("Stop on timeout, iteration: " + i);
+
+ break;
+ }
+
log.info("Iteration: " + i);
+ }
boolean rollback = i % 10 == 0;
http://git-wip-us.apache.org/repos/asf/ignite/blob/22b7e76c/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java
index 48621af..b03e9c8 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java
@@ -418,7 +418,26 @@ public class GridCacheTestEntryEx extends GridMetadataAwareAdapter implements Gr
}
/** @inheritDoc */
- @Nullable @Override public T2<CacheObject, GridCacheVersion> innerGetVersioned(
+ @Override public void clearReserveForLoad(GridCacheVersion ver) {
+ assert false;
+ }
+
+ /** @inheritDoc */
+ @Override public EntryGetResult innerGetAndReserveForLoad(
+ boolean readSwap,
+ boolean updateMetrics,
+ boolean evt,
+ UUID subjId,
+ String taskName,
+ @Nullable IgniteCacheExpiryPolicy expiryPlc,
+ boolean keepBinary) throws IgniteCheckedException, GridCacheEntryRemovedException {
+ assert false;
+
+ return null;
+ }
+
+ /** @inheritDoc */
+ @Nullable @Override public EntryGetResult innerGetVersioned(
@Nullable GridCacheVersion ver,
IgniteInternalTx tx,
boolean readSwap,
http://git-wip-us.apache.org/repos/asf/ignite/blob/22b7e76c/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite2.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite2.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite2.java
index f632f67..8792ea1 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite2.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite2.java
@@ -22,6 +22,7 @@ import org.apache.ignite.cache.affinity.fair.FairAffinityFunctionBackupFilterSel
import org.apache.ignite.cache.affinity.fair.FairAffinityFunctionExcludeNeighborsSelfTest;
import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunctionBackupFilterSelfTest;
import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunctionExcludeNeighborsSelfTest;
+import org.apache.ignite.internal.processors.cache.CacheConcurrentReadThroughTest;
import org.apache.ignite.internal.processors.cache.CacheConfigurationLeakTest;
import org.apache.ignite.internal.processors.cache.CacheDhtLocalPartitionAfterRemoveSelfTest;
import org.apache.ignite.internal.processors.cache.CacheEnumOperationsSingleNodeTest;
@@ -268,6 +269,7 @@ public class IgniteCacheTestSuite2 extends TestSuite {
suite.addTest(new TestSuite(CacheExchangeMessageDuplicatedStateTest.class));
suite.addTest(new TestSuite(OffheapCacheOnClientsTest.class));
+ suite.addTest(new TestSuite(CacheConcurrentReadThroughTest.class));
return suite;
}
[22/31] ignite git commit: CacheScanPartitionQueryFallbackSelfTest
fixed to use default page size.
Posted by ak...@apache.org.
CacheScanPartitionQueryFallbackSelfTest fixed to use default page size.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/f3505783
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/f3505783
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/f3505783
Branch: refs/heads/ignite-4436-2
Commit: f35057833900ba028b3a9a8bd547df61f42a45ed
Parents: 9c9175d
Author: sboikov <sb...@gridgain.com>
Authored: Thu Jan 19 12:44:57 2017 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Thu Jan 19 12:44:57 2017 +0300
----------------------------------------------------------------------
.../processors/cache/CacheScanPartitionQueryFallbackSelfTest.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/f3505783/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheScanPartitionQueryFallbackSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheScanPartitionQueryFallbackSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheScanPartitionQueryFallbackSelfTest.java
index 02b213e..efa9ce5 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheScanPartitionQueryFallbackSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheScanPartitionQueryFallbackSelfTest.java
@@ -248,7 +248,7 @@ public class CacheScanPartitionQueryFallbackSelfTest extends GridCommonAbstractT
info("Running query [node=" + nodeId + ", part=" + part + ']');
try (QueryCursor<Cache.Entry<Integer, Integer>> cur0 =
- cache.query(new ScanQuery<Integer, Integer>(part).setPageSize(5))) {
+ cache.query(new ScanQuery<Integer, Integer>(part))) {
if (cur)
doTestScanQueryCursor(cur0, part);
[04/31] ignite git commit: Merge branch 'ignite-1.7.5-p1' into
ignite-1.7.6
Posted by ak...@apache.org.
Merge branch 'ignite-1.7.5-p1' into ignite-1.7.6
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/80f73252
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/80f73252
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/80f73252
Branch: refs/heads/ignite-4436-2
Commit: 80f7325211f6adb8a9f3cc0bd1192ded28aeff77
Parents: 55f7594 1665a61
Author: Anton Vinogradov <av...@apache.org>
Authored: Mon Jan 16 12:15:17 2017 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Mon Jan 16 12:15:17 2017 +0300
----------------------------------------------------------------------
.../GridNearAtomicAbstractUpdateFuture.java | 34 ++-
.../GridNearAtomicSingleUpdateFuture.java | 44 ++--
.../dht/atomic/GridNearAtomicUpdateFuture.java | 57 ++---
.../AtomicPutAllChangingTopologyTest.java | 212 +++++++++++++++++++
.../IgniteCacheFailoverTestSuite.java | 3 +
5 files changed, 284 insertions(+), 66 deletions(-)
----------------------------------------------------------------------
[10/31] ignite git commit: IGNITE-3964: SQL: add support for custom
table name. This closes #1301.
Posted by ak...@apache.org.
IGNITE-3964: SQL: add support for custom table name. This closes #1301.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/74d0dcc6
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/74d0dcc6
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/74d0dcc6
Branch: refs/heads/ignite-4436-2
Commit: 74d0dcc6c56118f9e4fdaa4aa70d25d1abe7b80e
Parents: 67225b2
Author: Andrey V. Mashenkov <an...@gmail.com>
Authored: Tue Jan 17 15:00:08 2017 +0300
Committer: Andrey V. Mashenkov <an...@gmail.com>
Committed: Tue Jan 17 15:04:21 2017 +0300
----------------------------------------------------------------------
.../org/apache/ignite/cache/QueryEntity.java | 21 ++
.../processors/query/GridQueryProcessor.java | 26 +-
.../query/GridQueryTypeDescriptor.java | 7 +
.../processors/query/h2/IgniteH2Indexing.java | 16 +-
.../cache/IgniteCacheAbstractQuerySelfTest.java | 260 ++++++++++++++++++-
.../h2/GridIndexingSpiAbstractSelfTest.java | 5 +
6 files changed, 325 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/74d0dcc6/modules/core/src/main/java/org/apache/ignite/cache/QueryEntity.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/QueryEntity.java b/modules/core/src/main/java/org/apache/ignite/cache/QueryEntity.java
index 9758cfc..3d02478 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/QueryEntity.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/QueryEntity.java
@@ -48,6 +48,9 @@ public class QueryEntity implements Serializable {
/** Collection of query indexes. */
private Map<String, QueryIndex> idxs = new HashMap<>();
+ /** Table name. */
+ private String tableName;
+
/**
* Creates an empty query entity.
*/
@@ -169,6 +172,24 @@ public class QueryEntity implements Serializable {
}
}
+
+ /**
+ * Gets table name for this query entity.
+ *
+ * @return table name
+ */
+ public String getTableName() {
+ return tableName;
+ }
+
+ /**
+ * Sets table name for this query entity.
+ * @param tableName table name
+ */
+ public void setTableName(String tableName) {
+ this.tableName = tableName;
+ }
+
/**
* Utility method for building query entities programmatically.
*/
http://git-wip-us.apache.org/repos/asf/ignite/blob/74d0dcc6/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
index 6c093ee..0f2bc9a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
@@ -253,10 +253,12 @@ public class GridQueryProcessor extends GridProcessorAdapter {
if (keyCls == null)
keyCls = Object.class;
- String simpleValType = valCls == null ? typeName(qryEntity.getValueType()) : typeName(valCls);
+ String simpleValType = ((valCls == null) ? typeName(qryEntity.getValueType()) : typeName(valCls));
desc.name(simpleValType);
+ desc.tableName(qryEntity.getTableName());
+
if (binaryEnabled && !keyOrValMustDeserialize) {
// Safe to check null.
if (SQL_TYPES.contains(valCls))
@@ -466,7 +468,7 @@ public class GridQueryProcessor extends GridProcessorAdapter {
* @param desc Type descriptor.
* @throws IgniteCheckedException If failed.
*/
- private void addTypeByName(CacheConfiguration<?,?> ccfg, TypeDescriptor desc) throws IgniteCheckedException {
+ private void addTypeByName(CacheConfiguration<?, ?> ccfg, TypeDescriptor desc) throws IgniteCheckedException {
if (typesByName.putIfAbsent(new TypeName(ccfg.getName(), desc.name()), desc) != null)
throw new IgniteCheckedException("Type with name '" + desc.name() + "' already indexed " +
"in cache '" + ccfg.getName() + "'.");
@@ -2108,6 +2110,9 @@ public class GridQueryProcessor extends GridProcessorAdapter {
/** */
private String name;
+ /** */
+ private String tblName;
+
/** Value field names and types with preserved order. */
@GridToStringInclude
private final Map<String, Class<?>> fields = new LinkedHashMap<>();
@@ -2166,6 +2171,23 @@ public class GridQueryProcessor extends GridProcessorAdapter {
this.name = name;
}
+ /**
+ * Gets table name for type.
+ * @return Table name.
+ */
+ public String tableName() {
+ return tblName;
+ }
+
+ /**
+ * Sets table name for type.
+ *
+ * @param tblName Table name.
+ */
+ public void tableName(String tblName) {
+ this.tblName = tblName;
+ }
+
/** {@inheritDoc} */
@Override public Map<String, Class<?>> fields() {
return fields;
http://git-wip-us.apache.org/repos/asf/ignite/blob/74d0dcc6/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryTypeDescriptor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryTypeDescriptor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryTypeDescriptor.java
index b636841..e939525 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryTypeDescriptor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryTypeDescriptor.java
@@ -32,6 +32,13 @@ public interface GridQueryTypeDescriptor {
public String name();
/**
+ * Gets table name for type.
+ *
+ * @return Table name.
+ */
+ public String tableName();
+
+ /**
* Gets mapping from field name to its type.
*
* @return Fields that can be indexed, participate in queries and can be queried using method.
http://git-wip-us.apache.org/repos/asf/ignite/blob/74d0dcc6/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
index 362ddd8..bc51552 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
@@ -741,7 +741,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
tbl.onDrop();
- tbl.schema.tbls.remove(tbl.name());
+ tbl.schema.tbls.remove(tbl.typeName());
}
/** {@inheritDoc} */
@@ -2397,7 +2397,9 @@ public class IgniteH2Indexing implements GridQueryIndexing {
this.type = type;
this.schema = schema;
- fullTblName = schema.schemaName + "." + escapeName(type.name(), schema.escapeAll());
+ String tblName = escapeName(type.tableName() != null ? type.tableName() : type.name(), schema.escapeAll());
+
+ fullTblName = schema.schemaName + "." + tblName;
}
/**
@@ -2408,16 +2410,16 @@ public class IgniteH2Indexing implements GridQueryIndexing {
}
/**
- * @return Database table name.
+ * @return Database full table name.
*/
String fullTableName() {
return fullTblName;
}
/**
- * @return Database table name.
+ * @return type name.
*/
- String name() {
+ String typeName() {
return type.name();
}
@@ -2739,8 +2741,8 @@ public class IgniteH2Indexing implements GridQueryIndexing {
* @param tbl Table descriptor.
*/
public void add(TableDescriptor tbl) {
- if (tbls.putIfAbsent(tbl.name(), tbl) != null)
- throw new IllegalStateException("Table already registered: " + tbl.name());
+ if (tbls.putIfAbsent(tbl.typeName(), tbl) != null)
+ throw new IllegalStateException("Table already registered: " + tbl.fullTableName());
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/74d0dcc6/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java
index 7c5b472..ad6922c 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java
@@ -23,6 +23,7 @@ import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.io.Serializable;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
@@ -45,10 +46,13 @@ import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteBinary;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteException;
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.QueryEntity;
+import org.apache.ignite.cache.QueryIndex;
import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
import org.apache.ignite.cache.query.QueryCursor;
import org.apache.ignite.cache.query.ScanQuery;
@@ -66,11 +70,11 @@ import org.apache.ignite.configuration.NearCacheConfiguration;
import org.apache.ignite.events.CacheQueryExecutedEvent;
import org.apache.ignite.events.CacheQueryReadEvent;
import org.apache.ignite.events.Event;
-import org.apache.ignite.internal.IgniteKernal;
import org.apache.ignite.internal.binary.BinaryMarshaller;
import org.apache.ignite.internal.processors.cache.distributed.replicated.IgniteCacheReplicatedQuerySelfTest;
import org.apache.ignite.internal.processors.cache.query.QueryCursorEx;
import org.apache.ignite.internal.processors.query.GridQueryFieldMetadata;
+import org.apache.ignite.internal.util.lang.GridPlainCallable;
import org.apache.ignite.internal.util.tostring.GridToStringExclude;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.G;
@@ -180,6 +184,32 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
Long.class, EnumObject.class
);
+ List<QueryEntity> entityList = new ArrayList<>();
+
+ QueryEntity qryEntity = new QueryEntity();
+
+ qryEntity.setKeyType(Integer.class.getName());
+ qryEntity.setValueType(Type1.class.getName());
+ qryEntity.addQueryField("id", Integer.class.getName(), null);
+ qryEntity.addQueryField("name", String.class.getName(), null);
+ qryEntity.setTableName("Type2");
+ qryEntity.setIndexes(Arrays.asList(new QueryIndex("id")));
+
+ entityList.add(qryEntity);
+
+ qryEntity = new QueryEntity();
+
+ qryEntity.setKeyType(Integer.class.getName());
+ qryEntity.setValueType(Type2.class.getName());
+ qryEntity.addQueryField("id", Integer.class.getName(), null);
+ qryEntity.addQueryField("name", String.class.getName(), null);
+ qryEntity.setTableName("Type1");
+ qryEntity.setIndexes(Arrays.asList(new QueryIndex("id")));
+
+ entityList.add(qryEntity);
+
+ cc.setQueryEntities(entityList);
+
if (cacheMode() != CacheMode.LOCAL)
cc.setAffinity(new RendezvousAffinityFunction());
@@ -234,6 +264,7 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
stopAllGrids();
+
store.reset();
}
@@ -548,6 +579,113 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
*
* @throws Exception In case of error.
*/
+ public void testSimpleCustomTableName() throws Exception {
+ final IgniteCache<Integer, Object> cache = ignite().cache(null);
+
+ cache.put(10, new Type1(1, "Type1 record #1"));
+ cache.put(20, new Type1(2, "Type1 record #2"));
+
+ QueryCursor<Cache.Entry<Integer, Type1>> qry1 =
+ cache.query(new SqlQuery<Integer, Type1>(Type1.class, "FROM Type2"));
+
+ List<Cache.Entry<Integer, Type1>> all = qry1.getAll();
+
+ assertEquals(2, all.size());
+
+ QueryCursor<List<?>> qry = cache.query(new SqlFieldsQuery("SELECT name FROM Type2"));
+
+ assertEquals(2, qry.getAll().size());
+
+ GridTestUtils.assertThrows(log, new GridPlainCallable<Void>() {
+ @Override public Void call() throws Exception {
+ QueryCursor<Cache.Entry<Integer, Type1>> qry =
+ cache.query(new SqlQuery<Integer, Type1>(Type1.class, "FROM Type1"));
+
+ qry.getAll();
+
+ return null;
+ }
+ }, IgniteException.class, null);
+ }
+
+ /**
+ * JUnit.
+ *
+ * @throws Exception In case of error.
+ */
+ public void testMixedCustomTableName() throws Exception {
+ final IgniteCache<Integer, Object> cache = ignite().cache(null);
+
+ cache.put(10, new Type1(1, "Type1 record #1"));
+ cache.put(20, new Type1(2, "Type1 record #2"));
+ cache.put(30, new Type2(1, "Type2 record #1"));
+ cache.put(40, new Type2(2, "Type2 record #2"));
+ cache.put(50, new Type2(3, "Type2 record #3"));
+
+ QueryCursor<Cache.Entry<Integer, Type1>> qry1 =
+ cache.query(new SqlQuery<Integer, Type1>(Type1.class, "FROM Type2"));
+
+ List<Cache.Entry<Integer, Type1>> all = qry1.getAll();
+
+ assertEquals(2, all.size());
+
+ QueryCursor<Cache.Entry<Integer, Type2>> qry2 =
+ cache.query(new SqlQuery<Integer, Type2>(Type2.class, "FROM Type1"));
+
+ assertEquals(3, qry2.getAll().size());
+
+ QueryCursor<List<?>> qry = cache.query(new SqlFieldsQuery("SELECT name FROM Type1"));
+
+ assertEquals(3, qry.getAll().size());
+
+ qry = cache.query(new SqlFieldsQuery("SELECT name FROM Type2"));
+
+ assertEquals(2, qry.getAll().size());
+
+ GridTestUtils.assertThrows(log, new GridPlainCallable<Void>() {
+ @Override public Void call() throws Exception {
+ QueryCursor<Cache.Entry<Integer, Type1>> qry1 =
+ cache.query(new SqlQuery<Integer, Type1>(Type1.class, "FROM Type1"));
+
+ qry1.getAll().size();
+
+ return null;
+ }
+ }, IgniteException.class, null);
+ }
+
+ /**
+ * JUnit.
+ *
+ * @throws Exception In case of error.
+ */
+ public void testDistributedJoinCustomTableName() throws Exception {
+ IgniteCache<Integer, Object> cache = ignite().cache(null);
+
+ cache.put(10, new Type1(1, "Type1 record #1"));
+ cache.put(20, new Type1(2, "Type1 record #2"));
+ cache.put(30, new Type2(1, "Type2 record #1"));
+ cache.put(40, new Type2(2, "Type2 record #2"));
+ cache.put(50, new Type2(3, "Type2 record #3"));
+
+ QueryCursor<List<?>> query = cache.query(
+ new SqlFieldsQuery("SELECT t2.name, t1.name FROM Type2 as t2 LEFT JOIN Type1 as t1 ON t1.id = t2.id")
+ .setDistributedJoins(cacheMode() == PARTITIONED));
+
+ assertEquals(2, query.getAll().size());
+
+ query = cache.query(
+ new SqlFieldsQuery("SELECT t2.name, t1.name FROM Type2 as t2 RIGHT JOIN Type1 as t1 ON t1.id = t2.id")
+ .setDistributedJoins(cacheMode() == PARTITIONED));
+
+ assertEquals(3, query.getAll().size());
+ }
+
+ /**
+ * JUnit.
+ *
+ * @throws Exception In case of error.
+ */
public void testObjectQuery() throws Exception {
IgniteCache<Integer, ObjectValue> cache = ignite().cache(null);
@@ -1654,6 +1792,126 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
}
/**
+ *
+ */
+ public static class Type1 implements Serializable {
+ /** */
+ private int id;
+
+ /** */
+ private String name;
+
+ /**
+ * @param id ID.
+ * @param name Name.
+ */
+ Type1(int id, String name) {
+ assert name != null;
+ assert id > 0;
+
+ this.name = name;
+ this.id = id;
+ }
+
+ /**
+ * @return Name.
+ */
+ public String name() {
+ return name;
+ }
+
+ /**
+ * @return ID.
+ */
+ public int id() {
+ return id;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ return name.hashCode() + 31 * id;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object obj) {
+ if (obj == this)
+ return true;
+
+ if (!(obj instanceof Type1))
+ return false;
+
+ Type1 that = (Type1)obj;
+
+ return that.name.equals(name) && that.id == id;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(Type1.class, this);
+ }
+ }
+
+ /**
+ *
+ */
+ public static class Type2 implements Serializable {
+ /** */
+ private int id;
+
+ /** */
+ private String name;
+
+ /**
+ * @param id ID.
+ * @param name Name.
+ */
+ Type2(int id, String name) {
+ assert name != null;
+ assert id > 0;
+
+ this.name = name;
+ this.id = id;
+ }
+
+ /**
+ * @return Name.
+ */
+ public String name() {
+ return name;
+ }
+
+ /**
+ * @return ID.
+ */
+ public int id() {
+ return id;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ return name.hashCode() + 31 * id;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object obj) {
+ if (obj == this)
+ return true;
+
+ if (!(obj instanceof Type2))
+ return false;
+
+ Type2 that = (Type2)obj;
+
+ return that.name.equals(name) && that.id == id;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(Type2.class, this);
+ }
+ }
+
+ /**
* Test value object.
*/
@SuppressWarnings("PublicInnerClass")
http://git-wip-us.apache.org/repos/asf/ignite/blob/74d0dcc6/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexingSpiAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexingSpiAbstractSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexingSpiAbstractSelfTest.java
index bcf8f9d..81e34d6 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexingSpiAbstractSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexingSpiAbstractSelfTest.java
@@ -539,6 +539,11 @@ public abstract class GridIndexingSpiAbstractSelfTest extends GridCommonAbstract
return name;
}
+ /** {@inheritDoc} */
+ @Override public String tableName() {
+ return null;
+ }
+
/**
* @return Space name.
*/
[24/31] ignite git commit: Merge branch 'ignite-1.7.6'
Posted by ak...@apache.org.
Merge branch 'ignite-1.7.6'
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/aaeda721
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/aaeda721
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/aaeda721
Branch: refs/heads/ignite-4436-2
Commit: aaeda7214f738dff2fbd865e83250413a9b7cc0f
Parents: e1c3dda f350578
Author: agura <ag...@apache.org>
Authored: Thu Feb 9 20:29:48 2017 +0300
Committer: agura <ag...@apache.org>
Committed: Thu Feb 9 20:29:48 2017 +0300
----------------------------------------------------------------------
.../apache/ignite/IgniteSystemProperties.java | 3 +
.../org/apache/ignite/cache/QueryEntity.java | 21 +
.../org/apache/ignite/cache/query/SqlQuery.java | 25 +
.../processors/cache/EntryGetResult.java | 65 +++
.../processors/cache/GridCacheAdapter.java | 125 +++--
.../processors/cache/GridCacheContext.java | 4 +-
.../processors/cache/GridCacheEntryEx.java | 42 +-
.../processors/cache/GridCacheMapEntry.java | 140 +++++-
.../processors/cache/GridCacheUtils.java | 3 +
.../processors/cache/IgniteCacheProxy.java | 3 +
.../processors/cache/ReaderArguments.java | 74 +++
.../distributed/dht/GridDhtCacheAdapter.java | 9 +-
.../cache/distributed/dht/GridDhtGetFuture.java | 83 ++--
.../distributed/dht/GridDhtGetSingleFuture.java | 75 ++-
.../dht/GridPartitionedGetFuture.java | 10 +-
.../dht/GridPartitionedSingleGetFuture.java | 10 +-
.../dht/atomic/GridDhtAtomicCache.java | 12 +-
.../dht/colocated/GridDhtColocatedCache.java | 10 +-
.../distributed/near/GridNearGetFuture.java | 19 +-
.../local/atomic/GridLocalAtomicCache.java | 11 +-
.../cache/query/GridCacheQueryManager.java | 83 +++-
.../continuous/CacheContinuousQueryHandler.java | 81 +++-
.../cache/transactions/IgniteTxHandler.java | 2 +-
.../transactions/IgniteTxLocalAdapter.java | 65 +--
.../processors/query/GridQueryIndexing.java | 4 +-
.../processors/query/GridQueryProcessor.java | 79 ++--
.../query/GridQueryTypeDescriptor.java | 7 +
.../communication/tcp/TcpCommunicationSpi.java | 16 +
.../ignite/spi/discovery/tcp/ClientImpl.java | 90 +++-
.../ignite/spi/discovery/tcp/ServerImpl.java | 63 ++-
.../messages/TcpDiscoveryAbstractMessage.java | 21 +
modules/core/src/test/config/log4j-test.xml | 6 +
.../cache/CacheConcurrentReadThroughTest.java | 184 ++++++++
.../processors/cache/GridCacheTestEntryEx.java | 30 +-
.../near/GridNearCacheStoreUpdateTest.java | 466 +++++++++++++++++++
.../GridNearOffheapCacheStoreUpdateTest.java | 35 ++
.../cache/query/IndexingSpiQuerySelfTest.java | 69 ++-
.../IndexingSpiQueryWithH2IndexingSelfTest.java | 36 ++
.../tcp/TcpCommunicationSpiDropNodesTest.java | 322 +++++++++++++
.../TcpCommunicationSpiFaultyClientTest.java | 265 +++++++++++
.../ignite/testframework/GridTestNode.java | 1 +
.../testframework/junits/GridAbstractTest.java | 2 +
.../testsuites/IgniteCacheTestSuite2.java | 7 +
.../IgniteSpiCommunicationSelfTestSuite.java | 5 +
.../IgniteSpiDiscoverySelfTestSuite.java | 2 +-
.../processors/query/h2/IgniteH2Indexing.java | 30 +-
...CacheScanPartitionQueryFallbackSelfTest.java | 2 +-
.../cache/IgniteCacheAbstractQuerySelfTest.java | 294 ++++++++++++
.../IgniteCachePartitionedQuerySelfTest.java | 85 ++++
.../h2/GridIndexingSpiAbstractSelfTest.java | 29 +-
50 files changed, 2719 insertions(+), 406 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/aaeda721/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/aaeda721/modules/core/src/main/java/org/apache/ignite/cache/QueryEntity.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/aaeda721/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
index 8d0a962,59665bb..264fa14
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
@@@ -1995,12 -2023,11 +2016,12 @@@ public abstract class GridCacheAdapter<
GridCacheEntryEx entry = entryEx(key);
try {
- GridCacheVersion verSet = entry.versionedValue(cacheVal,
- ver,
+ T2<CacheObject, GridCacheVersion> verVal = entry.versionedValue(
+ cacheVal,
+ res.version(),
null,
- expiry);
-
- boolean set = verSet != null;
++ expiry,
+ readerArgs);
if (log.isDebugEnabled())
log.debug("Set value loaded from store into entry [" +
http://git-wip-us.apache.org/repos/asf/ignite/blob/aaeda721/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/aaeda721/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java
index 9e9b496,51f423a..f26288f
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java
@@@ -725,15 -755,15 +755,17 @@@ public interface GridCacheEntryEx
* @param val New value.
* @param curVer Version to match or {@code null} if match is not required.
* @param newVer Version to set.
+ * @param loadExpiryPlc Expiry policy if entry is loaded from store.
- * @return Non null version if value was set.
+ * @param readerArgs Reader will be added if not null.
+ * @return Current version and value.
* @throws IgniteCheckedException If index could not be updated.
* @throws GridCacheEntryRemovedException If entry was removed.
*/
- public GridCacheVersion versionedValue(CacheObject val,
+ public T2<CacheObject, GridCacheVersion> versionedValue(CacheObject val,
@Nullable GridCacheVersion curVer,
@Nullable GridCacheVersion newVer,
- @Nullable IgniteCacheExpiryPolicy loadExpiryPlc)
++ @Nullable IgniteCacheExpiryPolicy loadExpiryPlc,
+ @Nullable ReaderArguments readerArgs)
throws IgniteCheckedException, GridCacheEntryRemovedException;
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/aaeda721/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
index 52b779d,59e4181..942ae21
--- 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
@@@ -3549,14 -3609,28 +3609,29 @@@ public abstract class GridCacheMapEntr
}
/** {@inheritDoc} */
- @Override public synchronized GridCacheVersion versionedValue(CacheObject val,
+ @Override public synchronized void clearReserveForLoad(GridCacheVersion ver) throws IgniteCheckedException {
+ if (obsoleteVersionExtras() != null)
+ return;
+
+ if (ver.equals(this.ver)) {
+ assert evictionDisabled() : this;
+
+ flags &= ~IS_EVICT_DISABLED;
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public synchronized T2<CacheObject, GridCacheVersion> versionedValue(CacheObject val,
GridCacheVersion curVer,
GridCacheVersion newVer,
- @Nullable IgniteCacheExpiryPolicy loadExpiryPlc)
++ @Nullable IgniteCacheExpiryPolicy loadExpiryPlc,
+ @Nullable ReaderArguments readerArgs)
- throws IgniteCheckedException, GridCacheEntryRemovedException
- {
+ throws IgniteCheckedException, GridCacheEntryRemovedException {
+
checkObsolete();
+ addReaderIfNeed(readerArgs);
+
if (curVer == null || curVer.equals(ver)) {
if (val != this.val) {
GridCacheMvcc mvcc = mvccExtras();
http://git-wip-us.apache.org/repos/asf/ignite/blob/aaeda721/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/aaeda721/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/aaeda721/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/aaeda721/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetFuture.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/aaeda721/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetSingleFuture.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/aaeda721/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/aaeda721/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/aaeda721/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
index e657f32,f601e0a..1b6179e
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
@@@ -2381,7 -2293,7 +2383,7 @@@ public class GridDhtAtomicCache<K, V> e
try {
GridCacheVersion ver = entry.version();
-- entry.versionedValue(ctx.toCacheObject(v), null, ver, null);
++ entry.versionedValue(ctx.toCacheObject(v), null, ver, null, null);
}
catch (GridCacheEntryRemovedException e) {
assert false : "Entry should not get obsolete while holding lock [entry=" + entry +
http://git-wip-us.apache.org/repos/asf/ignite/blob/aaeda721/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/aaeda721/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/aaeda721/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/aaeda721/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/aaeda721/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
index 63b0717,83edab4..a9a7d7c
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
@@@ -1253,8 -1312,8 +1312,8 @@@ public class CacheContinuousQueryHandle
try {
cctx.io().send(node, msg, GridIoPolicy.SYSTEM_POOL);
}
- catch (ClusterTopologyCheckedException e) {
+ catch (ClusterTopologyCheckedException ignored) {
- IgniteLogger log = ctx.log(getClass());
+ IgniteLogger log = ctx.log(CU.CONTINUOUS_QRY_LOG_CATEGORY);
if (log.isDebugEnabled())
log.debug("Failed to send acknowledge message, node left " +
http://git-wip-us.apache.org/repos/asf/ignite/blob/aaeda721/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/aaeda721/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
index 7ceb701,f05d90d..cd4c55c
--- 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
@@@ -439,8 -437,9 +440,9 @@@ public abstract class IgniteTxLocalAdap
CU.subjectId(this, cctx),
null,
resolveTaskName(),
- expiryPlc,
+ expiryPlc0,
- txEntry == null ? keepBinary : txEntry.keepBinary());
+ txEntry == null ? keepBinary : txEntry.keepBinary(),
+ null);
if (res == null) {
if (misses == null)
@@@ -476,20 -475,22 +478,23 @@@
CacheObject cacheVal = cacheCtx.toCacheObject(val);
while (true) {
- GridCacheEntryEx entry = cacheCtx.cache().entryEx(key);
+ GridCacheEntryEx entry = cacheCtx.cache().entryEx(key, topVer);
try {
- GridCacheVersion setVer = entry.versionedValue(cacheVal, ver, null, null);
-
- boolean set = setVer != null;
+ T2<CacheObject, GridCacheVersion> verVal = entry.versionedValue(cacheVal,
+ ver,
+ null,
++ null,
+ null);
- if (set)
- ver = setVer;
+ if (log.isDebugEnabled()) {
+ log.debug("Set value loaded from store into entry [" +
+ "oldVer=" + ver +
+ ", newVer=" + verVal.get2() +
+ ", entry=" + entry + ']');
+ }
- if (log.isDebugEnabled())
- log.debug("Set value loaded from store into entry [set=" + set +
- ", curVer=" + ver + ", newVer=" + setVer + ", " +
- "entry=" + entry + ']');
+ ver = verVal.get2();
break;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/aaeda721/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryIndexing.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/aaeda721/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/aaeda721/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryTypeDescriptor.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/aaeda721/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/aaeda721/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/aaeda721/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/aaeda721/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java
----------------------------------------------------------------------
diff --cc modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java
index 9fdadf3,8db68b4..e76ab40
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java
@@@ -664,10 -686,10 +685,11 @@@ public class GridCacheTestEntryEx exten
}
/** @inheritDoc */
- @Override public GridCacheVersion versionedValue(CacheObject val,
+ @Override public T2<CacheObject, GridCacheVersion> versionedValue(CacheObject val,
GridCacheVersion curVer,
GridCacheVersion newVer,
- IgniteCacheExpiryPolicy loadExpiryPlc) {
++ @Nullable IgniteCacheExpiryPolicy loadExpiryPlc,
+ @Nullable ReaderArguments readerArgs) {
assert false;
return null;
http://git-wip-us.apache.org/repos/asf/ignite/blob/aaeda721/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpiDropNodesTest.java
----------------------------------------------------------------------
diff --cc modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpiDropNodesTest.java
index 0000000,d29231e..b530e36
mode 000000,100644..100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpiDropNodesTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpiDropNodesTest.java
@@@ -1,0 -1,322 +1,322 @@@
+ /*
+ * 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.spi.communication.tcp;
+
+ import java.util.Collections;
+ import java.util.HashMap;
+ import java.util.Map;
+ import java.util.concurrent.Callable;
+ import java.util.concurrent.CountDownLatch;
+ import java.util.concurrent.CyclicBarrier;
+ import java.util.concurrent.TimeUnit;
+ import org.apache.ignite.IgniteCheckedException;
+ import org.apache.ignite.cluster.ClusterNode;
+ import org.apache.ignite.configuration.IgniteConfiguration;
+ import org.apache.ignite.events.Event;
+ import org.apache.ignite.internal.IgniteEx;
+ import org.apache.ignite.internal.IgniteInternalFuture;
+ import org.apache.ignite.internal.util.lang.GridAbsPredicate;
+ import org.apache.ignite.internal.util.nio.GridCommunicationClient;
+ import org.apache.ignite.internal.util.typedef.internal.U;
+ import org.apache.ignite.lang.IgniteBiPredicate;
+ import org.apache.ignite.lang.IgnitePredicate;
+ import org.apache.ignite.lang.IgniteRunnable;
+ import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+ import org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryNode;
+ 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;
+
+ import static org.apache.ignite.events.EventType.EVT_NODE_FAILED;
+
+ /**
+ *
+ */
+ public class TcpCommunicationSpiDropNodesTest extends GridCommonAbstractTest {
+ /** IP finder. */
+ private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+ /** Nodes count. */
+ private static final int NODES_CNT = 4;
+
+ /** Block. */
+ private static volatile boolean block;
+
+ /** Predicate. */
+ private static IgniteBiPredicate<ClusterNode, ClusterNode> pred;
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ cfg.setClockSyncFrequency(300000);
+ cfg.setFailureDetectionTimeout(1000);
+
+ TestCommunicationSpi spi = new TestCommunicationSpi();
+
+ spi.setIdleConnectionTimeout(100);
+ spi.setSharedMemoryPort(-1);
+
+ TcpDiscoverySpi discoSpi = (TcpDiscoverySpi) cfg.getDiscoverySpi();
+ discoSpi.setIpFinder(IP_FINDER);
+
+ cfg.setCommunicationSpi(spi);
+ cfg.setDiscoverySpi(discoSpi);
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTest() throws Exception {
+ super.beforeTest();
+
+ block = false;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ super.afterTest();
+
+ stopAllGrids();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testOneNode() throws Exception {
+ pred = new IgniteBiPredicate<ClusterNode, ClusterNode>() {
+ @Override public boolean apply(ClusterNode locNode, ClusterNode rmtNode) {
+ return block && rmtNode.order() == 3;
+ }
+ };
+
+ startGrids(NODES_CNT);
+
+ final CountDownLatch latch = new CountDownLatch(1);
+
+ grid(0).events().localListen(new IgnitePredicate<Event>() {
+ @Override
+ public boolean apply(Event event) {
+ latch.countDown();
+
+ return true;
+ }
+ }, EVT_NODE_FAILED);
+
+ U.sleep(1000); // Wait for write timeout and closing idle connections.
+
+ block = true;
+
+ grid(0).compute().broadcast(new IgniteRunnable() {
+ @Override public void run() {
+ // No-op.
+ }
+ });
+
+ assertTrue(latch.await(15, TimeUnit.SECONDS));
+
+ assertTrue(GridTestUtils.waitForCondition(new GridAbsPredicate() {
+ @Override public boolean apply() {
+ return grid(3).cluster().topologyVersion() == NODES_CNT + 1;
+ }
+ }, 5000));
+
+ for (int i = 0; i < 10; i++) {
+ U.sleep(1000);
+
+ assertEquals(NODES_CNT - 1, grid(0).cluster().nodes().size());
+
+ int liveNodesCnt = 0;
+
+ for (int j = 0; j < NODES_CNT; j++) {
+ IgniteEx ignite;
+
+ try {
+ ignite = grid(j);
+
+ log.info("Checking topology for grid(" + j + "): " + ignite.cluster().nodes());
+
+ ClusterNode locNode = ignite.localNode();
+
+ if (locNode.order() != 3) {
+ assertEquals(NODES_CNT - 1, ignite.cluster().nodes().size());
+
+ for (ClusterNode node : ignite.cluster().nodes())
+ assertTrue(node.order() != 3);
+
+ liveNodesCnt++;
+ }
+ }
+ catch (Exception e) {
+ log.info("Checking topology for grid(" + j + "): no grid in topology.");
+ }
+ }
+
+ assertEquals(NODES_CNT - 1, liveNodesCnt);
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testTwoNodesEachOther() throws Exception {
+ pred = new IgniteBiPredicate<ClusterNode, ClusterNode>() {
+ @Override public boolean apply(ClusterNode locNode, ClusterNode rmtNode) {
+ return block && (locNode.order() == 2 || locNode.order() == 4) &&
+ (rmtNode.order() == 2 || rmtNode.order() == 4);
+ }
+ };
+
+ startGrids(NODES_CNT);
+
+ final CountDownLatch latch = new CountDownLatch(1);
+
+ grid(0).events().localListen(new IgnitePredicate<Event>() {
+ @Override
+ public boolean apply(Event event) {
+ latch.countDown();
+
+ return true;
+ }
+ }, EVT_NODE_FAILED);
+
+ U.sleep(1000); // Wait for write timeout and closing idle connections.
+
+ block = true;
+
+ final CyclicBarrier barrier = new CyclicBarrier(2);
+
+ IgniteInternalFuture<Void> fut1 = GridTestUtils.runAsync(new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ barrier.await();
+
+ grid(1).compute().withNoFailover().broadcast(new IgniteRunnable() {
+ @Override public void run() {
+ // No-op.
+ }
+ });
+
+ return null;
+ }
+ });
+
+ IgniteInternalFuture<Void> fut2 = GridTestUtils.runAsync(new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ barrier.await();
+
+ grid(3).compute().withNoFailover().broadcast(new IgniteRunnable() {
+ @Override public void run() {
+ // No-op.
+ }
+ });
+
+ return null;
+ }
+ });
+
+ assertTrue(latch.await(5, TimeUnit.SECONDS));
+
+ GridTestUtils.waitForCondition(new GridAbsPredicate() {
+ @Override public boolean apply() {
+ return grid(2).cluster().nodes().size() == NODES_CNT - 1;
+ }
+ }, 5000);
+
+ try {
+ fut1.get();
+ }
+ catch (IgniteCheckedException e) {
+ // No-op.
+ }
+
+ try {
+ fut2.get();
+ }
+ catch (IgniteCheckedException e) {
+ // No-op.
+ }
+
+ long failedNodeOrder = 1 + 2 + 3 + 4;
+
+ for (ClusterNode node : grid(0).cluster().nodes())
+ failedNodeOrder -= node.order();
+
+ for (int i = 0; i < 10; i++) {
+ U.sleep(1000);
+
+ assertEquals(NODES_CNT - 1, grid(0).cluster().nodes().size());
+
+ int liveNodesCnt = 0;
+
+ for (int j = 0; j < NODES_CNT; j++) {
+ IgniteEx ignite;
+
+ try {
+ ignite = grid(j);
+
+ log.info("Checking topology for grid(" + j + "): " + ignite.cluster().nodes());
+
+ ClusterNode locNode = ignite.localNode();
+
+ if (locNode.order() != failedNodeOrder) {
+ assertEquals(NODES_CNT - 1, ignite.cluster().nodes().size());
+
+ for (ClusterNode node : ignite.cluster().nodes())
+ assertTrue(node.order() != failedNodeOrder);
+
+ liveNodesCnt++;
+ }
+ }
+ catch (Exception e) {
+ log.info("Checking topology for grid(" + j + "): no grid in topology.");
+ }
+ }
+
+ assertEquals(NODES_CNT - 1, liveNodesCnt);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class TestCommunicationSpi extends TcpCommunicationSpi {
+ /** {@inheritDoc} */
- @Override protected GridCommunicationClient createTcpClient(ClusterNode node) throws IgniteCheckedException {
++ @Override protected GridCommunicationClient createTcpClient(ClusterNode node, int connIdx) throws IgniteCheckedException {
+ if (pred.apply(getLocalNode(), node)) {
+ Map<String, Object> attrs = new HashMap<>(node.attributes());
+
+ attrs.put(createAttributeName(ATTR_ADDRS), Collections.singleton("127.0.0.1"));
+ attrs.put(createAttributeName(ATTR_PORT), 47200);
+ attrs.put(createAttributeName(ATTR_EXT_ADDRS), Collections.emptyList());
+ attrs.put(createAttributeName(ATTR_HOST_NAMES), Collections.emptyList());
+
+ ((TcpDiscoveryNode)node).setAttributes(attrs);
+ }
+
- return super.createTcpClient(node);
++ return super.createTcpClient(node, connIdx);
+ }
+
+ /**
+ * @param name Name.
+ */
+ private String createAttributeName(String name) {
+ return getClass().getSimpleName() + '.' + name;
+ }
+ }
+ }
http://git-wip-us.apache.org/repos/asf/ignite/blob/aaeda721/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpiFaultyClientTest.java
----------------------------------------------------------------------
diff --cc modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpiFaultyClientTest.java
index 0000000,6e99487..c21e6ce
mode 000000,100644..100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpiFaultyClientTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpiFaultyClientTest.java
@@@ -1,0 -1,270 +1,265 @@@
+ /*
+ * 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.spi.communication.tcp;
+
+ import java.io.IOException;
-import java.io.OutputStream;
+ import java.net.InetAddress;
+ import java.net.ServerSocket;
-import java.net.Socket;
+ import java.util.Collections;
+ import java.util.HashMap;
+ import java.util.Map;
+ import java.util.concurrent.CountDownLatch;
+ import java.util.concurrent.TimeUnit;
-import org.apache.ignite.Ignite;
+ import org.apache.ignite.IgniteCheckedException;
+ import org.apache.ignite.IgniteException;
+ import org.apache.ignite.cluster.ClusterNode;
+ import org.apache.ignite.configuration.IgniteConfiguration;
+ import org.apache.ignite.events.Event;
+ import org.apache.ignite.internal.IgniteInternalFuture;
+ import org.apache.ignite.internal.IgniteInterruptedCheckedException;
+ import org.apache.ignite.internal.util.lang.GridAbsPredicate;
+ import org.apache.ignite.internal.util.nio.GridCommunicationClient;
+ import org.apache.ignite.internal.util.typedef.internal.U;
+ import org.apache.ignite.lang.IgnitePredicate;
+ import org.apache.ignite.lang.IgniteRunnable;
+ import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+ import org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryNode;
+ import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
+ import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
-import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage;
-import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryNodeFailedMessage;
+ import org.apache.ignite.testframework.GridTestUtils;
+ import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+ import static org.apache.ignite.events.EventType.EVT_NODE_FAILED;
+
+ /**
+ * Tests that faulty client will be failed if connection can't be established.
+ */
+ public class TcpCommunicationSpiFaultyClientTest extends GridCommonAbstractTest {
+ /** */
+ private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+ /** Predicate. */
+ private static final IgnitePredicate<ClusterNode> PRED = new IgnitePredicate<ClusterNode>() {
+ @Override public boolean apply(ClusterNode node) {
+ return block && node.order() == 3;
+ }
+ };
+
+ /** Client mode. */
+ private static boolean clientMode;
+
+ /** Block. */
+ private static volatile boolean block;
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ cfg.setClockSyncFrequency(300000);
+ cfg.setFailureDetectionTimeout(1000);
+ cfg.setClientMode(clientMode);
+
+ TestCommunicationSpi spi = new TestCommunicationSpi();
+
+ spi.setIdleConnectionTimeout(100);
+ spi.setSharedMemoryPort(-1);
+
+ TcpDiscoverySpi discoSpi = (TcpDiscoverySpi) cfg.getDiscoverySpi();
+
+ discoSpi.setIpFinder(IP_FINDER);
+ discoSpi.setClientReconnectDisabled(true);
+
+ cfg.setCommunicationSpi(spi);
+ cfg.setDiscoverySpi(discoSpi);
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTest() throws Exception {
+ super.beforeTest();
+
+ block = false;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ super.afterTest();
+
+ stopAllGrids();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testNoServerOnHost() throws Exception {
+ testFailClient(null);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testNotAcceptedConnection() throws Exception {
+ testFailClient(new FakeServer());
+ }
+
+ /**
+ * @param srv Server.
+ * @throws Exception If failed.
+ */
+ private void testFailClient(FakeServer srv) throws Exception {
+ IgniteInternalFuture<Long> fut = null;
+
+ try {
+ if (srv != null)
+ fut = GridTestUtils.runMultiThreadedAsync(srv, 1, "fake-server");
+
+ clientMode = false;
+
+ startGrids(2);
+
+ clientMode = true;
+
+ startGrid(2);
+ startGrid(3);
+
+ U.sleep(1000); // Wait for write timeout and closing idle connections.
+
+ final CountDownLatch latch = new CountDownLatch(1);
+
+ grid(0).events().localListen(new IgnitePredicate<Event>() {
+ @Override
+ public boolean apply(Event event) {
+ latch.countDown();
+
+ return true;
+ }
+ }, EVT_NODE_FAILED);
+
+ block = true;
+
+ try {
+ grid(0).compute(grid(0).cluster().forClients()).withNoFailover().broadcast(new IgniteRunnable() {
+ @Override public void run() {
+ // No-op.
+ }
+ });
+ }
+ catch (IgniteException e) {
+ // No-op.
+ }
+
+ assertTrue(latch.await(3, TimeUnit.SECONDS));
+
+ assertTrue(GridTestUtils.waitForCondition(new GridAbsPredicate() {
+ @Override public boolean apply() {
+ return grid(0).cluster().forClients().nodes().size() == 1;
+ }
+ }, 5000));
+
+ for (int i = 0; i < 5; i++) {
+ U.sleep(1000);
+
+ log.info("Check topology (" + (i + 1) + "): " + grid(0).cluster().nodes());
+
+ assertEquals(1, grid(0).cluster().forClients().nodes().size());
+ }
+ }
+ finally {
+ if (srv != null) {
+ srv.stop();
+
+ assert fut != null;
+
+ fut.get();
+ }
+
+ stopAllGrids();
+ }
+ }
+
+ /**
+ * Server that emulates connection troubles.
+ */
+ private static class FakeServer implements Runnable {
+ /** Server. */
+ private final ServerSocket srv;
+
+ /** Stop. */
+ private volatile boolean stop;
+
+ /**
+ * Default constructor.
+ */
+ FakeServer() throws IOException {
+ this.srv = new ServerSocket(47200, 50, InetAddress.getByName("127.0.0.1"));
+ }
+
+ /**
+ *
+ */
+ public void stop() {
+ stop = true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void run() {
+ try {
+ while (!stop) {
+ try {
+ U.sleep(10);
+ }
+ catch (IgniteInterruptedCheckedException e) {
+ // No-op.
+ }
+ }
+ }
+ finally {
+ U.closeQuiet(srv);
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ private static class TestCommunicationSpi extends TcpCommunicationSpi {
+ /** {@inheritDoc} */
- @Override protected GridCommunicationClient createTcpClient(ClusterNode node) throws IgniteCheckedException {
++ @Override protected GridCommunicationClient createTcpClient(ClusterNode node, int connIdx) throws IgniteCheckedException {
+ if (PRED.apply(node)) {
+ Map<String, Object> attrs = new HashMap<>(node.attributes());
+
+ attrs.put(createAttributeName(ATTR_ADDRS), Collections.singleton("127.0.0.1"));
+ attrs.put(createAttributeName(ATTR_PORT), 47200);
+ attrs.put(createAttributeName(ATTR_EXT_ADDRS), Collections.emptyList());
+ attrs.put(createAttributeName(ATTR_HOST_NAMES), Collections.emptyList());
+
+ ((TcpDiscoveryNode)node).setAttributes(attrs);
+ }
+
- return super.createTcpClient(node);
++ return super.createTcpClient(node, connIdx);
+ }
+
+ /**
+ * @param name Name.
+ */
+ private String createAttributeName(String name) {
+ return getClass().getSimpleName() + '.' + name;
+ }
+ }
+ }
http://git-wip-us.apache.org/repos/asf/ignite/blob/aaeda721/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/aaeda721/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite2.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/aaeda721/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiCommunicationSelfTestSuite.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/aaeda721/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
----------------------------------------------------------------------
diff --cc modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
index 69a65fe,cbf2ebd..9416621
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
@@@ -1077,10 -1051,9 +1077,10 @@@ public class IgniteH2Indexing implement
final TableDescriptor tbl = tableDescriptor(spaceName, type);
if (tbl == null)
- throw new CacheException("Failed to find SQL table for type: " + type.name());
+ throw new IgniteSQLException("Failed to find SQL table for type: " + type.name(),
+ IgniteQueryErrorCode.TABLE_NOT_FOUND);
- String sql = generateQuery(qry, tbl);
+ String sql = generateQuery(qry, alias, tbl);
Connection conn = connectionForThread(tbl.schemaName());
http://git-wip-us.apache.org/repos/asf/ignite/blob/aaeda721/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/aaeda721/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexingSpiAbstractSelfTest.java
----------------------------------------------------------------------
[07/31] ignite git commit: IGNITE-4545 Added cache for router
hostnames. - Fixes #1428.
Posted by ak...@apache.org.
IGNITE-4545 Added cache for router hostnames. - Fixes #1428.
Signed-off-by: Andrey Novikov <an...@gridgain.com>
(cherry picked from commit 27ba69b)
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/71176473
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/71176473
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/71176473
Branch: refs/heads/ignite-4436-2
Commit: 71176473f9fd0aa2088ba4e611ba4b7fc45e76b8
Parents: c3eae9f
Author: Andrey Novikov <an...@gridgain.com>
Authored: Mon Jan 16 11:22:34 2017 +0700
Committer: Andrey Novikov <an...@gridgain.com>
Committed: Tue Jan 17 12:43:16 2017 +0700
----------------------------------------------------------------------
.../GridClientConnectionManagerAdapter.java | 7 ++-
.../impl/connection/GridClientTopology.java | 53 ++++++++++++++++----
2 files changed, 49 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/71176473/modules/core/src/main/java/org/apache/ignite/internal/client/impl/connection/GridClientConnectionManagerAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/impl/connection/GridClientConnectionManagerAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/client/impl/connection/GridClientConnectionManagerAdapter.java
index 6ea7c22..0928c90 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/client/impl/connection/GridClientConnectionManagerAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/client/impl/connection/GridClientConnectionManagerAdapter.java
@@ -85,6 +85,9 @@ public abstract class GridClientConnectionManagerAdapter implements GridClientCo
/** Class logger. */
private final Logger log;
+ /** All local enabled MACs. */
+ private final Collection<String> macs;
+
/** NIO server. */
private GridNioServer srv;
@@ -166,6 +169,8 @@ public abstract class GridClientConnectionManagerAdapter implements GridClientCo
if (marshId == null && cfg.getMarshaller() == null)
throw new GridClientException("Failed to start client (marshaller is not configured).");
+ macs = U.allLocalMACs();
+
if (cfg.getProtocol() == GridClientProtocol.TCP) {
try {
IgniteLogger gridLog = new JavaLogger(false);
@@ -315,7 +320,7 @@ public abstract class GridClientConnectionManagerAdapter implements GridClientCo
}
boolean sameHost = node.attributes().isEmpty() ||
- F.containsAny(U.allLocalMACs(), node.attribute(ATTR_MACS).toString().split(", "));
+ F.containsAny(macs, node.attribute(ATTR_MACS).toString().split(", "));
Collection<InetSocketAddress> srvs = new LinkedHashSet<>();
http://git-wip-us.apache.org/repos/asf/ignite/blob/71176473/modules/core/src/main/java/org/apache/ignite/internal/client/impl/connection/GridClientTopology.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/impl/connection/GridClientTopology.java b/modules/core/src/main/java/org/apache/ignite/internal/client/impl/connection/GridClientTopology.java
index effd5b3..97aa586 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/client/impl/connection/GridClientTopology.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/client/impl/connection/GridClientTopology.java
@@ -21,7 +21,6 @@ import java.net.InetSocketAddress;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map;
import java.util.Set;
@@ -61,12 +60,18 @@ public class GridClientTopology {
/** Cached last error prevented topology from update. */
private GridClientException lastError;
+ /** Router addresses from configuration. */
+ private final String routers;
+
/**
* Set of router addresses to infer direct connectivity
* when client is working in router connection mode.
* {@code null} when client is working in direct connection node.
*/
- private final Set<String> routerAddrs;
+ private final Set<InetSocketAddress> routerAddrs;
+
+ /** List of all known local MACs */
+ private final Collection<String> macsCache;
/** Protocol. */
private final GridClientProtocol prot;
@@ -96,8 +101,38 @@ public class GridClientTopology {
metricsCache = cfg.isEnableMetricsCache();
attrCache = cfg.isEnableAttributesCache();
prot = cfg.getProtocol();
- routerAddrs = (!cfg.getRouters().isEmpty() && cfg.getServers().isEmpty()) ?
- new HashSet<>(cfg.getRouters()) : null;
+
+ if (!cfg.getRouters().isEmpty() && cfg.getServers().isEmpty()) {
+ routers = cfg.getRouters().toString();
+
+ routerAddrs = U.newHashSet(cfg.getRouters().size());
+
+ for (String router : cfg.getRouters()) {
+ int portIdx = router.lastIndexOf(":");
+
+ if (portIdx > 0) {
+ String hostName = router.substring(0, portIdx);
+
+ try {
+ int port = Integer.parseInt(router.substring(portIdx + 1));
+
+ InetSocketAddress inetSockAddr = new InetSocketAddress(hostName, port);
+
+ routerAddrs.add(inetSockAddr);
+ }
+ catch (Exception ignore) {
+ // No-op.
+ }
+ }
+ }
+ }
+ else {
+ routers = null;
+
+ routerAddrs = Collections.emptySet();
+ }
+
+ macsCache = U.allLocalMACs();
}
/**
@@ -279,7 +314,7 @@ public class GridClientTopology {
try {
if (lastError != null)
throw new GridClientDisconnectedException(
- "Topology is failed [protocol=" + prot + ", routers=" + routerAddrs + ']', lastError);
+ "Topology is failed [protocol=" + prot + ", routers=" + routers + ']', lastError);
else
return nodes.get(id);
}
@@ -376,19 +411,17 @@ public class GridClientTopology {
(metricsCache && attrCache) || (node.attributes().isEmpty() && node.metrics() == null);
// Try to bypass object copying.
- if (noAttrsAndMetrics && routerAddrs == null && node.connectable())
+ if (noAttrsAndMetrics && routerAddrs.isEmpty() && node.connectable())
return node;
// Return a new node instance based on the original one.
GridClientNodeImpl.Builder nodeBuilder = GridClientNodeImpl.builder(node, !attrCache, !metricsCache);
for (InetSocketAddress addr : node.availableAddresses(prot, true)) {
- boolean router = routerAddrs == null ||
- routerAddrs.contains(addr.getHostName() + ":" + addr.getPort()) ||
- routerAddrs.contains(addr.getAddress().getHostAddress() + ":" + addr.getPort());
+ boolean router = routerAddrs.isEmpty() || routerAddrs.contains(addr);
boolean reachable = noAttrsAndMetrics || !addr.getAddress().isLoopbackAddress() ||
- F.containsAny(U.allLocalMACs(), node.attribute(ATTR_MACS).toString().split(", "));
+ F.containsAny(macsCache, node.<String>attribute(ATTR_MACS).split(", "));
if (router && reachable) {
nodeBuilder.connectable(true);
[03/31] ignite git commit: IGNITE-4424 REPLICATED cache isn't synced
across nodes
Posted by ak...@apache.org.
IGNITE-4424 REPLICATED cache isn't synced across nodes
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/1665a615
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/1665a615
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/1665a615
Branch: refs/heads/ignite-4436-2
Commit: 1665a615030201a7c9a51fd479868c3533b103b5
Parents: 6c38eb2
Author: Anton Vinogradov <av...@apache.org>
Authored: Fri Dec 30 13:41:34 2016 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Mon Jan 16 11:59:33 2017 +0300
----------------------------------------------------------------------
.../GridNearAtomicAbstractUpdateFuture.java | 34 ++-
.../GridNearAtomicSingleUpdateFuture.java | 44 ++--
.../dht/atomic/GridNearAtomicUpdateFuture.java | 57 ++---
.../AtomicPutAllChangingTopologyTest.java | 212 +++++++++++++++++++
.../IgniteCacheFailoverTestSuite.java | 3 +
5 files changed, 284 insertions(+), 66 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/1665a615/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 2fbabaa..c92e0f5 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
@@ -212,14 +212,18 @@ public abstract class GridNearAtomicAbstractUpdateFuture extends GridFutureAdapt
// Cannot remap.
remapCnt = 1;
- map(topVer);
+ GridCacheVersion futVer = addAtomicFuture(topVer);
+
+ if (futVer != null)
+ map(topVer, futVer);
}
}
/**
* @param topVer Topology version.
+ * @param futVer Future version
*/
- protected abstract void map(AffinityTopologyVersion topVer);
+ protected abstract void map(AffinityTopologyVersion topVer, GridCacheVersion futVer);
/**
* Maps future on ready topology.
@@ -302,7 +306,7 @@ public abstract class GridNearAtomicAbstractUpdateFuture extends GridFutureAdapt
* @param req Request.
* @param e Error.
*/
- protected void onSendError(GridNearAtomicAbstractUpdateRequest req, IgniteCheckedException e) {
+ protected final void onSendError(GridNearAtomicAbstractUpdateRequest req, IgniteCheckedException e) {
synchronized (mux) {
GridNearAtomicUpdateResponse res = new GridNearAtomicUpdateResponse(cctx.cacheId(),
req.nodeId(),
@@ -314,4 +318,28 @@ public abstract class GridNearAtomicAbstractUpdateFuture extends GridFutureAdapt
onResult(req.nodeId(), res, true);
}
}
+
+ /**
+ * Adds future prevents topology change before operation complete.
+ * Should be invoked before topology lock released.
+ *
+ * @param topVer Topology version.
+ * @return Future version in case future added.
+ */
+ protected final GridCacheVersion addAtomicFuture(AffinityTopologyVersion topVer) {
+ GridCacheVersion futVer = cctx.versions().next(topVer);
+
+ synchronized (mux) {
+ assert this.futVer == null : this;
+ assert this.topVer == AffinityTopologyVersion.ZERO : this;
+
+ this.topVer = topVer;
+ this.futVer = futVer;
+ }
+
+ if (storeFuture() && !cctx.mvcc().addAtomicFuture(futVer, this))
+ return null;
+
+ return futVer;
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1665a615/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 bd231cf..7376aff 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
@@ -348,14 +348,7 @@ public class GridNearAtomicSingleUpdateFuture extends GridNearAtomicAbstractUpda
@Override public void apply(final IgniteInternalFuture<AffinityTopologyVersion> fut) {
cctx.kernalContext().closure().runLocalSafe(new Runnable() {
@Override public void run() {
- try {
- AffinityTopologyVersion topVer = fut.get();
-
- map(topVer);
- }
- catch (IgniteCheckedException e) {
- onDone(e);
- }
+ mapOnTopology();
}
});
}
@@ -388,7 +381,9 @@ public class GridNearAtomicSingleUpdateFuture extends GridNearAtomicAbstractUpda
@Override protected void mapOnTopology() {
cache.topology().readLock();
- AffinityTopologyVersion topVer = null;
+ AffinityTopologyVersion topVer;
+
+ GridCacheVersion futVer;
try {
if (cache.topology().stopping()) {
@@ -410,6 +405,8 @@ public class GridNearAtomicSingleUpdateFuture extends GridNearAtomicAbstractUpda
}
topVer = fut.topologyVersion();
+
+ futVer = addAtomicFuture(topVer);
}
else {
if (waitTopFut) {
@@ -435,11 +432,12 @@ public class GridNearAtomicSingleUpdateFuture extends GridNearAtomicAbstractUpda
cache.topology().readUnlock();
}
- map(topVer);
+ if (futVer != null)
+ map(topVer, futVer);
}
/** {@inheritDoc} */
- protected void map(AffinityTopologyVersion topVer) {
+ @Override protected void map(AffinityTopologyVersion topVer, GridCacheVersion futVer) {
Collection<ClusterNode> topNodes = CU.affinityNodes(cctx, topVer);
if (F.isEmpty(topNodes)) {
@@ -449,11 +447,6 @@ public class GridNearAtomicSingleUpdateFuture extends GridNearAtomicAbstractUpda
return;
}
- Exception err = null;
- GridNearAtomicAbstractUpdateRequest singleReq0 = null;
-
- GridCacheVersion futVer = cctx.versions().next(topVer);
-
GridCacheVersion updVer;
// Assign version on near node in CLOCK ordering mode even if fastMap is false.
@@ -470,16 +463,17 @@ public class GridNearAtomicSingleUpdateFuture extends GridNearAtomicAbstractUpda
else
updVer = null;
+ Exception err = null;
+ GridNearAtomicAbstractUpdateRequest singleReq0 = null;
+
try {
singleReq0 = mapSingleUpdate(topVer, futVer, updVer);
synchronized (mux) {
- assert this.futVer == null : this;
- assert this.topVer == AffinityTopologyVersion.ZERO : this;
+ assert this.futVer == futVer || (this.isDone() && this.error() != null);
+ assert this.topVer == topVer;
- this.topVer = topVer;
this.updVer = updVer;
- this.futVer = futVer;
resCnt = 0;
@@ -496,14 +490,6 @@ public class GridNearAtomicSingleUpdateFuture extends GridNearAtomicAbstractUpda
return;
}
- if (storeFuture()) {
- if (!cctx.mvcc().addAtomicFuture(futVer, this)) {
- assert isDone() : this;
-
- return;
- }
- }
-
// Optimize mapping for single key.
mapSingle(singleReq0.nodeId(), singleReq0);
}
@@ -511,7 +497,7 @@ public class GridNearAtomicSingleUpdateFuture extends GridNearAtomicAbstractUpda
/**
* @return Future version.
*/
- GridCacheVersion onFutureDone() {
+ private GridCacheVersion onFutureDone() {
GridCacheVersion ver0;
GridFutureAdapter<Void> fut0;
http://git-wip-us.apache.org/repos/asf/ignite/blob/1665a615/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 cd64117..950e5bd 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
@@ -456,14 +456,7 @@ public class GridNearAtomicUpdateFuture extends GridNearAtomicAbstractUpdateFutu
@Override public void apply(final IgniteInternalFuture<AffinityTopologyVersion> fut) {
cctx.kernalContext().closure().runLocalSafe(new Runnable() {
@Override public void run() {
- try {
- AffinityTopologyVersion topVer = fut.get();
-
- map(topVer, remapKeys);
- }
- catch (IgniteCheckedException e) {
- onDone(e);
- }
+ mapOnTopology();
}
});
}
@@ -497,7 +490,9 @@ public class GridNearAtomicUpdateFuture extends GridNearAtomicAbstractUpdateFutu
@Override protected void mapOnTopology() {
cache.topology().readLock();
- AffinityTopologyVersion topVer = null;
+ AffinityTopologyVersion topVer;
+
+ GridCacheVersion futVer;
try {
if (cache.topology().stopping()) {
@@ -519,6 +514,8 @@ public class GridNearAtomicUpdateFuture extends GridNearAtomicAbstractUpdateFutu
}
topVer = fut.topologyVersion();
+
+ futVer = addAtomicFuture(topVer);
}
else {
if (waitTopFut) {
@@ -544,7 +541,8 @@ public class GridNearAtomicUpdateFuture extends GridNearAtomicAbstractUpdateFutu
cache.topology().readUnlock();
}
- map(topVer, null);
+ if (futVer != null)
+ map(topVer, futVer, remapKeys);
}
/**
@@ -602,15 +600,18 @@ public class GridNearAtomicUpdateFuture extends GridNearAtomicAbstractUpdateFutu
}
/** {@inheritDoc} */
- protected void map(AffinityTopologyVersion topVer) {
- map(topVer, null);
+ @Override protected void map(AffinityTopologyVersion topVer, GridCacheVersion futVer) {
+ map(topVer, futVer, null);
}
/**
* @param topVer Topology version.
+ * @param futVer Future ID.
* @param remapKeys Keys to remap.
*/
- void map(AffinityTopologyVersion topVer, @Nullable Collection<KeyCacheObject> remapKeys) {
+ void map(AffinityTopologyVersion topVer,
+ GridCacheVersion futVer,
+ @Nullable Collection<KeyCacheObject> remapKeys) {
Collection<ClusterNode> topNodes = CU.affinityNodes(cctx, topVer);
if (F.isEmpty(topNodes)) {
@@ -620,14 +621,6 @@ public class GridNearAtomicUpdateFuture extends GridNearAtomicAbstractUpdateFutu
return;
}
- Exception err = null;
- GridNearAtomicFullUpdateRequest singleReq0 = null;
- Map<UUID, GridNearAtomicFullUpdateRequest> mappings0 = null;
-
- int size = keys.size();
-
- GridCacheVersion futVer = cctx.versions().next(topVer);
-
GridCacheVersion updVer;
// Assign version on near node in CLOCK ordering mode even if fastMap is false.
@@ -644,6 +637,12 @@ public class GridNearAtomicUpdateFuture extends GridNearAtomicAbstractUpdateFutu
else
updVer = null;
+ Exception err = null;
+ GridNearAtomicFullUpdateRequest singleReq0 = null;
+ Map<UUID, GridNearAtomicFullUpdateRequest> mappings0 = null;
+
+ int size = keys.size();
+
try {
if (size == 1 && !fastMap) {
assert remapKeys == null || remapKeys.size() == 1;
@@ -676,12 +675,10 @@ public class GridNearAtomicUpdateFuture extends GridNearAtomicAbstractUpdateFutu
}
synchronized (mux) {
- assert this.futVer == null : this;
- assert this.topVer == AffinityTopologyVersion.ZERO : this;
+ assert this.futVer == futVer || (this.isDone() && this.error() != null);
+ assert this.topVer == topVer;
- this.topVer = topVer;
this.updVer = updVer;
- this.futVer = futVer;
resCnt = 0;
@@ -701,14 +698,6 @@ public class GridNearAtomicUpdateFuture extends GridNearAtomicAbstractUpdateFutu
return;
}
- if (storeFuture()) {
- if (!cctx.mvcc().addAtomicFuture(futVer, this)) {
- assert isDone() : this;
-
- return;
- }
- }
-
// Optimize mapping for single key.
if (singleReq0 != null)
mapSingle(singleReq0.nodeId(), singleReq0);
@@ -725,7 +714,7 @@ public class GridNearAtomicUpdateFuture extends GridNearAtomicAbstractUpdateFutu
/**
* @return Future version.
*/
- GridCacheVersion onFutureDone() {
+ private GridCacheVersion onFutureDone() {
GridCacheVersion ver0;
GridFutureAdapter<Void> fut0;
http://git-wip-us.apache.org/repos/asf/ignite/blob/1665a615/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/AtomicPutAllChangingTopologyTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/AtomicPutAllChangingTopologyTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/AtomicPutAllChangingTopologyTest.java
new file mode 100644
index 0000000..878cb17
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/AtomicPutAllChangingTopologyTest.java
@@ -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.
+ */
+
+package org.apache.ignite.internal.processors.cache.distributed.dht.atomic;
+
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Callable;
+import java.util.concurrent.CountDownLatch;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.cache.affinity.fair.FairAffinityFunction;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.util.typedef.internal.U;
+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;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
+import static org.apache.ignite.cache.CacheMode.REPLICATED;
+import static org.apache.ignite.cache.CachePeekMode.BACKUP;
+import static org.apache.ignite.cache.CachePeekMode.PRIMARY;
+import static org.apache.ignite.cache.CacheRebalanceMode.SYNC;
+import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
+
+/** */
+public class AtomicPutAllChangingTopologyTest extends GridCommonAbstractTest {
+ /** */
+ private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+ /** */
+ private static final int NODES_CNT = 3;
+
+ /** */
+ public static final String CACHE_NAME = "test-cache";
+
+ /** */
+ private static final int CACHE_SIZE = 20_000;
+
+ /** */
+ private static volatile CountDownLatch FILLED_LATCH;
+
+ /**
+ * @return Cache configuration.
+ */
+ private CacheConfiguration<Integer, Integer> cacheConfig() {
+ return new CacheConfiguration<Integer, Integer>()
+ .setAtomicityMode(ATOMIC)
+ .setCacheMode(REPLICATED)
+ .setAffinity(new FairAffinityFunction(false, 1))
+ .setWriteSynchronizationMode(FULL_SYNC)
+ .setRebalanceMode(SYNC)
+ .setName(CACHE_NAME);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER);
+
+ return cfg;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPutAllOnChangingTopology() throws Exception {
+ List<IgniteInternalFuture> futs = new LinkedList<>();
+
+ for (int i = 1; i < NODES_CNT; i++)
+ futs.add(startNodeAsync(i));
+
+ futs.add(startSeedNodeAsync());
+
+ boolean failed = false;
+
+ for (IgniteInternalFuture fut : futs) {
+ try {
+ fut.get();
+ }
+ catch (Throwable th) {
+ log.error("Check failed.", th);
+
+ failed = true;
+ }
+ }
+
+ if (failed)
+ throw new RuntimeException("Test Failed.");
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTest() throws Exception {
+ FILLED_LATCH = new CountDownLatch(1);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ super.afterTest();
+
+ stopAllGrids();
+ }
+
+ /**
+ * @return Future.
+ * @throws IgniteCheckedException If failed.
+ */
+ private IgniteInternalFuture startSeedNodeAsync() throws IgniteCheckedException {
+ return GridTestUtils.runAsync(new Callable<Object>() {
+ @Override public Boolean call() throws Exception {
+ Ignite node = startGrid(0);
+
+ log.info("Creating cache.");
+
+ IgniteCache<Integer, Integer> cache = node.getOrCreateCache(cacheConfig());
+
+ log.info("Created cache.");
+
+ Map<Integer, Integer> data = new HashMap<>(CACHE_SIZE);
+
+ for (int i = 0; i < CACHE_SIZE; i++)
+ data.put(i, i);
+
+ log.info("Filling.");
+
+ cache.putAll(data);
+
+ log.info("Filled.");
+
+ FILLED_LATCH.countDown();
+
+ checkCacheState(node, cache);
+
+ return true;
+ }
+ });
+ }
+
+ /**
+ * @param nodeId Node index.
+ * @return Future.
+ * @throws IgniteCheckedException If failed.
+ */
+ private IgniteInternalFuture startNodeAsync(final int nodeId) throws IgniteCheckedException {
+ return GridTestUtils.runAsync(new Callable<Object>() {
+ @Override public Boolean call() throws Exception {
+ Ignite node = startGrid(nodeId);
+
+ log.info("Getting cache.");
+
+ IgniteCache<Integer, Integer> cache = node.getOrCreateCache(cacheConfig());
+
+ log.info("Got cache.");
+
+ FILLED_LATCH.await();
+
+ log.info("Got Filled.");
+
+ cache.put(1, nodeId);
+
+ checkCacheState(node, cache);
+
+ return true;
+ }
+ });
+ }
+
+ /**
+ * @param node Node.
+ * @param cache Cache.
+ * @throws Exception If failed.
+ */
+ private void checkCacheState(Ignite node, IgniteCache<Integer, Integer> cache) throws Exception {
+ int locSize = cache.localSize(PRIMARY, BACKUP);
+ int locSize2 = -1;
+
+ if (locSize != CACHE_SIZE) {
+ U.sleep(5000);
+
+ // Rechecking.
+ locSize2 = cache.localSize(PRIMARY, BACKUP);
+ }
+
+ assertEquals("Wrong cache size on node [node=" + node.configuration().getGridName() +
+ ", expected= " + CACHE_SIZE +
+ ", actual=" + locSize +
+ ", actual2=" + locSize2 + "]",
+ locSize, CACHE_SIZE);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/1665a615/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite.java
index c9e507d..5bc6729 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite.java
@@ -33,6 +33,7 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheDhtR
import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheTxNodeFailureSelfTest;
import org.apache.ignite.internal.processors.cache.distributed.dht.GridNearCacheTxNodeFailureSelfTest;
import org.apache.ignite.internal.processors.cache.distributed.dht.IgniteAtomicLongChangingTopologySelfTest;
+import org.apache.ignite.internal.processors.cache.distributed.dht.atomic.AtomicPutAllChangingTopologyTest;
import org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridCacheAtomicClientInvalidPartitionHandlingSelfTest;
import org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridCacheAtomicClientRemoveFailureTest;
import org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridCacheAtomicInvalidPartitionHandlingSelfTest;
@@ -95,6 +96,8 @@ public class IgniteCacheFailoverTestSuite extends TestSuite {
suite.addTestSuite(GridCacheTxNodeFailureSelfTest.class);
suite.addTestSuite(GridNearCacheTxNodeFailureSelfTest.class);
+ suite.addTestSuite(AtomicPutAllChangingTopologyTest.class);
+
return suite;
}
}
[05/31] ignite git commit: IGNITE-4513 Improve debug logging.
Posted by ak...@apache.org.
IGNITE-4513 Improve debug logging.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/496fb173
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/496fb173
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/496fb173
Branch: refs/heads/ignite-4436-2
Commit: 496fb173d55a8ea0702fcb70a4e807f61d8fc53e
Parents: 1665a61
Author: nikolay_tikhonov <nt...@gridgain.com>
Authored: Mon Jan 16 13:19:51 2017 +0300
Committer: nikolay_tikhonov <nt...@gridgain.com>
Committed: Mon Jan 16 13:19:51 2017 +0300
----------------------------------------------------------------------
.../processors/cache/GridCacheUtils.java | 3 +
.../continuous/CacheContinuousQueryHandler.java | 81 +++++++++++++++++---
modules/core/src/test/config/log4j-test.xml | 6 ++
3 files changed, 79 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/496fb173/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
index d32f4c1..8ee77e3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
@@ -123,6 +123,9 @@ public class GridCacheUtils {
public static final String MARSH_CACHE_NAME = "ignite-marshaller-sys-cache";
/** */
+ public static final String CONTINUOUS_QRY_LOG_CATEGORY = "org.apache.ignite.continuous.query";
+
+ /** */
public static final String CACHE_MSG_LOG_CATEGORY = "org.apache.ignite.cache.msg";
/** */
http://git-wip-us.apache.org/repos/asf/ignite/blob/496fb173/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
index 10784fc..83edab4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
@@ -352,7 +352,7 @@ public class CacheContinuousQueryHandler<K, V> implements GridContinuousHandler
assert !skipPrimaryCheck || loc;
- log = ctx.log(CacheContinuousQueryHandler.class);
+ log = ctx.log(CU.CONTINUOUS_QRY_LOG_CATEGORY);
CacheContinuousQueryListener<K, V> lsnr = new CacheContinuousQueryListener<K, V>() {
@Override public void onExecution() {
@@ -384,7 +384,10 @@ public class CacheContinuousQueryHandler<K, V> implements GridContinuousHandler
final boolean recordIgniteEvt,
GridDhtAtomicAbstractUpdateFuture fut) {
if (ignoreExpired && evt.getEventType() == EventType.EXPIRED)
- return ;
+ return;
+
+ if (log.isDebugEnabled())
+ log.debug("Entry updated on affinity node [evt=" + evt + ", primary=" + primary + ']');
final GridCacheContext<K, V> cctx = cacheContext(ctx);
@@ -407,6 +410,10 @@ public class CacheContinuousQueryHandler<K, V> implements GridContinuousHandler
else {
final boolean notify = filter(evt, primary);
+ if (log.isDebugEnabled())
+ log.debug("Filter invoked for event [evt=" + evt + ", primary=" + primary
+ + ", notify=" + notify + ']');
+
if (primary || skipPrimaryCheck) {
if (fut == null)
onEntryUpdate(evt, notify, loc, recordIgniteEvt);
@@ -474,7 +481,8 @@ public class CacheContinuousQueryHandler<K, V> implements GridContinuousHandler
backupQueue0.clear();
}
catch (IgniteCheckedException e) {
- U.error(ctx.log(getClass()), "Failed to send backup event notification to node: " + nodeId, e);
+ U.error(ctx.log(CU.CONTINUOUS_QRY_LOG_CATEGORY),
+ "Failed to send backup event notification to node: " + nodeId, e);
}
}
@@ -653,7 +661,7 @@ public class CacheContinuousQueryHandler<K, V> implements GridContinuousHandler
final GridCacheContext cctx = cacheContext(ctx);
if (cctx == null) {
- IgniteLogger log = ctx.log(CacheContinuousQueryHandler.class);
+ IgniteLogger log = ctx.log(CU.CONTINUOUS_QRY_LOG_CATEGORY);
if (log.isDebugEnabled())
log.debug("Failed to notify callback, cache is not found: " + cacheId);
@@ -689,7 +697,7 @@ public class CacheContinuousQueryHandler<K, V> implements GridContinuousHandler
if (ignoreClsNotFound)
assert internal;
else
- U.error(ctx.log(getClass()), "Failed to unmarshal entry.", ex);
+ U.error(ctx.log(CU.CONTINUOUS_QRY_LOG_CATEGORY), "Failed to unmarshal entry.", ex);
}
}
@@ -799,8 +807,12 @@ public class CacheContinuousQueryHandler<K, V> implements GridContinuousHandler
CacheContinuousQueryEntry e = handleEntry(entry);
- if (e != null)
+ if (e != null) {
+ if (log.isDebugEnabled())
+ log.debug("Send the following event to listener: " + e);
+
ctx.continuous().addNotification(nodeId, routineId, entry, topic, sync, true);
+ }
}
}
catch (ClusterTopologyCheckedException ex) {
@@ -809,7 +821,7 @@ public class CacheContinuousQueryHandler<K, V> implements GridContinuousHandler
"[node=" + nodeId + ", err=" + ex + ']');
}
catch (IgniteCheckedException ex) {
- U.error(ctx.log(getClass()), "Failed to send event notification to node: " + nodeId, ex);
+ U.error(ctx.log(CU.CONTINUOUS_QRY_LOG_CATEGORY), "Failed to send event notification to node: " + nodeId, ex);
}
if (recordIgniteEvt && notify) {
@@ -875,7 +887,7 @@ public class CacheContinuousQueryHandler<K, V> implements GridContinuousHandler
partCntr = initUpdCntrs.get(partId);
}
- rec = new PartitionRecovery(ctx.log(getClass()), initTopVer0, partCntr);
+ rec = new PartitionRecovery(ctx.log(CU.CONTINUOUS_QRY_LOG_CATEGORY), initTopVer0, partCntr);
PartitionRecovery oldRec = rcvs.putIfAbsent(partId, rec);
@@ -984,12 +996,27 @@ public class CacheContinuousQueryHandler<K, V> implements GridContinuousHandler
List<CacheEntryEvent<? extends K, ? extends V>> entries;
synchronized (pendingEvts) {
+ if (log.isDebugEnabled()) {
+ log.debug("Handling event [lastFiredEvt=" + lastFiredEvt +
+ ", curTop=" + curTop +
+ ", entUpdCnt=" + entry.updateCounter() +
+ ", partId=" + entry.partition() +
+ ", pendingEvts=" + pendingEvts + ']');
+ }
+
// Received first event.
if (curTop == AffinityTopologyVersion.NONE) {
lastFiredEvt = entry.updateCounter();
curTop = entry.topologyVersion();
+ if (log.isDebugEnabled()) {
+ log.debug("First event [lastFiredEvt=" + lastFiredEvt +
+ ", curTop=" + curTop +
+ ", entUpdCnt=" + entry.updateCounter() +
+ ", partId=" + entry.partition() + ']');
+ }
+
return !entry.isFiltered() ?
F.<CacheEntryEvent<? extends K, ? extends V>>
asList(new CacheContinuousQueryEvent<K, V>(cache, cctx, entry)) :
@@ -1014,6 +1041,13 @@ public class CacheContinuousQueryHandler<K, V> implements GridContinuousHandler
if (!entry.isFiltered())
entries.add(new CacheContinuousQueryEvent<K, V>(cache, cctx, entry));
+ if (log.isDebugEnabled())
+ log.debug("Partition was lost [lastFiredEvt=" + lastFiredEvt +
+ ", curTop=" + curTop +
+ ", entUpdCnt=" + entry.updateCounter() +
+ ", partId=" + entry.partition() +
+ ", pendingEvts=" + pendingEvts + ']');
+
return entries;
}
@@ -1039,8 +1073,16 @@ public class CacheContinuousQueryHandler<K, V> implements GridContinuousHandler
return Collections.emptyList();
}
- if (pendingEvts.isEmpty())
+ if (pendingEvts.isEmpty()) {
+ if (log.isDebugEnabled()) {
+ log.debug("Nothing sent to listener [lastFiredEvt=" + lastFiredEvt +
+ ", curTop=" + curTop +
+ ", entUpdCnt=" + entry.updateCounter() +
+ ", partId=" + entry.partition() + ']');
+ }
+
return Collections.emptyList();
+ }
Iterator<Map.Entry<Long, CacheContinuousQueryEntry>> iter = pendingEvts.entrySet().iterator();
@@ -1057,6 +1099,14 @@ public class CacheContinuousQueryHandler<K, V> implements GridContinuousHandler
iter.remove();
}
+
+ if (log.isDebugEnabled()) {
+ log.debug("Pending events reached max of buffer size [lastFiredEvt=" + lastFiredEvt +
+ ", curTop=" + curTop +
+ ", entUpdCnt=" + entry.updateCounter() +
+ ", partId=" + entry.partition() +
+ ", pendingEvts=" + pendingEvts + ']');
+ }
}
else {
// Elements are consistently.
@@ -1077,6 +1127,15 @@ public class CacheContinuousQueryHandler<K, V> implements GridContinuousHandler
}
}
+ if (log.isDebugEnabled()) {
+ log.debug("Will send to listener the following events [entries=" + entries +
+ ", lastFiredEvt=" + lastFiredEvt +
+ ", curTop=" + curTop +
+ ", entUpdCnt=" + entry.updateCounter() +
+ ", partId=" + entry.partition() +
+ ", pendingEvts=" + pendingEvts + ']');
+ }
+
return entries;
}
}
@@ -1254,14 +1313,14 @@ public class CacheContinuousQueryHandler<K, V> implements GridContinuousHandler
cctx.io().send(node, msg, GridIoPolicy.SYSTEM_POOL);
}
catch (ClusterTopologyCheckedException e) {
- IgniteLogger log = ctx.log(getClass());
+ IgniteLogger log = ctx.log(CU.CONTINUOUS_QRY_LOG_CATEGORY);
if (log.isDebugEnabled())
log.debug("Failed to send acknowledge message, node left " +
"[msg=" + msg + ", node=" + node + ']');
}
catch (IgniteCheckedException e) {
- IgniteLogger log = ctx.log(getClass());
+ IgniteLogger log = ctx.log(CU.CONTINUOUS_QRY_LOG_CATEGORY);
U.error(log, "Failed to send acknowledge message " +
"[msg=" + msg + ", node=" + node + ']', e);
http://git-wip-us.apache.org/repos/asf/ignite/blob/496fb173/modules/core/src/test/config/log4j-test.xml
----------------------------------------------------------------------
diff --git a/modules/core/src/test/config/log4j-test.xml b/modules/core/src/test/config/log4j-test.xml
index 276de8c..638b260 100644
--- a/modules/core/src/test/config/log4j-test.xml
+++ b/modules/core/src/test/config/log4j-test.xml
@@ -102,6 +102,12 @@
</category>
-->
+ <!--
+ <category name="org.apache.ignite.continuous.query">
+ <level value="DEBUG"/>
+ </category>
+ -->
+
<!-- Disable all open source debugging. -->
<category name="org">
<level value="INFO"/>
[26/31] ignite git commit: IGNITE-4678 Web Console: Implemented demo
load as service.
Posted by ak...@apache.org.
IGNITE-4678 Web Console: Implemented demo load as service.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/a600cafd
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/a600cafd
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/a600cafd
Branch: refs/heads/ignite-4436-2
Commit: a600cafd1eec7581e8edde5a10b7d171997551f7
Parents: 3bf880c
Author: Andrey Novikov <an...@gridgain.com>
Authored: Fri Feb 10 15:55:05 2017 +0700
Committer: Andrey Novikov <an...@gridgain.com>
Committed: Fri Feb 10 15:55:05 2017 +0700
----------------------------------------------------------------------
modules/web-console/backend/app/agent.js | 34 ++
modules/web-console/backend/app/browser.js | 26 +
modules/web-console/frontend/package.json | 2 +-
.../ignite/console/demo/AgentClusterDemo.java | 475 +------------------
.../ignite/console/demo/AgentDemoUtils.java | 79 +++
.../demo/service/DemoCachesLoadService.java | 456 ++++++++++++++++++
.../service/DemoRandomCacheLoadService.java | 120 +++++
.../service/DemoServiceClusterSingleton.java | 41 ++
.../demo/service/DemoServiceKeyAffinity.java | 41 ++
.../service/DemoServiceMultipleInstances.java | 41 ++
.../demo/service/DemoServiceNodeSingleton.java | 41 ++
11 files changed, 897 insertions(+), 459 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/a600cafd/modules/web-console/backend/app/agent.js
----------------------------------------------------------------------
diff --git a/modules/web-console/backend/app/agent.js b/modules/web-console/backend/app/agent.js
index 8170280..4cae8ee 100644
--- a/modules/web-console/backend/app/agent.js
+++ b/modules/web-console/backend/app/agent.js
@@ -581,6 +581,40 @@ module.exports.factory = function(_, fs, path, JSZip, socketio, settings, mongo,
return this.executeRest(cmd);
}
+
+ /**
+ * Collect service information.
+ * @param {Boolean} demo Is need run command on demo node.
+ * @param {String} nid Node ID.
+ * @returns {Promise}
+ */
+ services(demo, nid) {
+ const cmd = new Command(demo, 'exe')
+ .addParam('name', 'org.apache.ignite.internal.visor.compute.VisorGatewayTask')
+ .addParam('p1', nid)
+ .addParam('p2', 'org.apache.ignite.internal.visor.service.VisorServiceTask')
+ .addParam('p3', 'java.lang.Void');
+
+ return this.executeRest(cmd);
+ }
+
+ /**
+ * Cancel service with specified name.
+ * @param {Boolean} demo Is need run command on demo node.
+ * @param {String} nid Node ID.
+ * @param {String} name Name of service to cancel.
+ * @returns {Promise}
+ */
+ serviceCancel(demo, nid, name) {
+ const cmd = new Command(demo, 'exe')
+ .addParam('name', 'org.apache.ignite.internal.visor.compute.VisorGatewayTask')
+ .addParam('p1', nid)
+ .addParam('p2', 'org.apache.ignite.internal.visor.service.VisorCancelServiceTask')
+ .addParam('p3', 'java.lang.String')
+ .addParam('p4', name);
+
+ return this.executeRest(cmd);
+ }
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/a600cafd/modules/web-console/backend/app/browser.js
----------------------------------------------------------------------
diff --git a/modules/web-console/backend/app/browser.js b/modules/web-console/backend/app/browser.js
index 499d84d..2b1285e 100644
--- a/modules/web-console/backend/app/browser.js
+++ b/modules/web-console/backend/app/browser.js
@@ -455,6 +455,32 @@ module.exports.factory = (_, socketio, agentMgr, configure) => {
.catch((err) => cb(_errorToJson(err)));
});
+ // Collect service information from grid.
+ socket.on('service:collect', (nid, cb) => {
+ agentMgr.findAgent(accountId())
+ .then((agent) => agent.services(demo, nid))
+ .then((data) => {
+ if (data.finished)
+ return cb(null, data.result);
+
+ cb(_errorToJson(data.error));
+ })
+ .catch((err) => cb(_errorToJson(err)));
+ });
+
+ // Collect service information from grid.
+ socket.on('service:cancel', (nid, name, cb) => {
+ agentMgr.findAgent(accountId())
+ .then((agent) => agent.serviceCancel(demo, nid, name))
+ .then((data) => {
+ if (data.finished)
+ return cb(null, data.result);
+
+ cb(_errorToJson(data.error));
+ })
+ .catch((err) => cb(_errorToJson(err)));
+ });
+
const count = agentMgr.addAgentListener(user._id, socket);
socket.emit('agent:count', {count});
http://git-wip-us.apache.org/repos/asf/ignite/blob/a600cafd/modules/web-console/frontend/package.json
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/package.json b/modules/web-console/frontend/package.json
index ff52ba4..651f496 100644
--- a/modules/web-console/frontend/package.json
+++ b/modules/web-console/frontend/package.json
@@ -46,7 +46,7 @@
"angular-touch": "~1.5.9",
"angular-translate": "~2.13.1",
"angular-tree-control": "~0.2.26",
- "angular-ui-grid": "~3.2.9",
+ "angular-ui-grid": "~4.0.0",
"angular-ui-router": "~0.3.1",
"bootstrap-sass": "~3.3.6",
"brace": "~0.8.0",
http://git-wip-us.apache.org/repos/asf/ignite/blob/a600cafd/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/demo/AgentClusterDemo.java
----------------------------------------------------------------------
diff --git a/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/demo/AgentClusterDemo.java b/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/demo/AgentClusterDemo.java
index 489e762..252692e 100644
--- a/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/demo/AgentClusterDemo.java
+++ b/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/demo/AgentClusterDemo.java
@@ -17,37 +17,24 @@
package org.apache.ignite.console.demo;
-import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
-import java.util.HashSet;
-import java.util.LinkedHashMap;
-import java.util.Random;
-import java.util.Set;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.ScheduledThreadPoolExecutor;
-import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
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.IgniteServices;
import org.apache.ignite.Ignition;
-import org.apache.ignite.cache.CacheAtomicityMode;
-import org.apache.ignite.cache.QueryEntity;
-import org.apache.ignite.cache.QueryIndex;
-import org.apache.ignite.cache.QueryIndexType;
-import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
-import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.console.agent.AgentConfiguration;
-import org.apache.ignite.console.demo.model.Car;
-import org.apache.ignite.console.demo.model.Country;
-import org.apache.ignite.console.demo.model.Department;
-import org.apache.ignite.console.demo.model.Employee;
-import org.apache.ignite.console.demo.model.Parking;
+import org.apache.ignite.console.demo.service.DemoCachesLoadService;
+import org.apache.ignite.console.demo.service.DemoRandomCacheLoadService;
+import org.apache.ignite.console.demo.service.DemoServiceMultipleInstances;
+import org.apache.ignite.console.demo.service.DemoServiceClusterSingleton;
+import org.apache.ignite.console.demo.service.DemoServiceKeyAffinity;
+import org.apache.ignite.console.demo.service.DemoServiceNodeSingleton;
import org.apache.ignite.internal.IgniteEx;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.logger.log4j.Log4JLogger;
@@ -55,7 +42,6 @@ import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
import org.apache.ignite.spi.swapspace.file.FileSwapSpaceSpi;
-import org.apache.ignite.transactions.Transaction;
import org.apache.log4j.Logger;
import static org.apache.ignite.IgniteSystemProperties.IGNITE_ATOMIC_CACHE_DELETE_HISTORY_SIZE;
@@ -66,8 +52,6 @@ import static org.apache.ignite.IgniteSystemProperties.IGNITE_NO_ASCII;
import static org.apache.ignite.events.EventType.EVTS_DISCOVERY;
import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_REST_JETTY_ADDRS;
import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_REST_JETTY_PORT;
-import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
-import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ;
/**
* Demo for cluster features like SQL and Monitoring.
@@ -84,247 +68,6 @@ public class AgentClusterDemo {
/** */
private static final int NODE_CNT = 3;
- /** */
- private static final String COUNTRY_CACHE_NAME = "CountryCache";
-
- /** */
- private static final String DEPARTMENT_CACHE_NAME = "DepartmentCache";
-
- /** */
- private static final String EMPLOYEE_CACHE_NAME = "EmployeeCache";
-
- /** */
- private static final String PARKING_CACHE_NAME = "ParkingCache";
-
- /** */
- private static final String CAR_CACHE_NAME = "CarCache";
-
- /** */
- private static final Set<String> DEMO_CACHES = new HashSet<>(Arrays.asList(COUNTRY_CACHE_NAME,
- DEPARTMENT_CACHE_NAME, EMPLOYEE_CACHE_NAME, PARKING_CACHE_NAME, CAR_CACHE_NAME));
-
- /** */
- private static final Random rnd = new Random();
-
- /** Countries count. */
- private static final int CNTR_CNT = 10;
-
- /** Departments count */
- private static final int DEP_CNT = 100;
-
- /** Employees count. */
- private static final int EMPL_CNT = 1000;
-
- /** Countries count. */
- private static final int CAR_CNT = 100;
-
- /** Departments count */
- private static final int PARK_CNT = 10;
-
- /** Counter for threads in pool. */
- private static final AtomicInteger THREAD_CNT = new AtomicInteger(0);
-
- /**
- * Create base cache configuration.
- *
- * @param name cache name.
- * @return Cache configuration with basic properties set.
- */
- private static <K, V> CacheConfiguration<K, V> cacheConfiguration(String name) {
- CacheConfiguration<K, V> ccfg = new CacheConfiguration<>(name);
-
- ccfg.setAffinity(new RendezvousAffinityFunction(false, 32));
- ccfg.setQueryDetailMetricsSize(10);
- ccfg.setStartSize(100);
- ccfg.setStatisticsEnabled(true);
-
- return ccfg;
- }
-
- /**
- * Configure cacheCountry.
- */
- private static <K, V> CacheConfiguration<K, V> cacheCountry() {
- CacheConfiguration<K, V> ccfg = cacheConfiguration(COUNTRY_CACHE_NAME);
-
- // Configure cacheCountry types.
- Collection<QueryEntity> qryEntities = new ArrayList<>();
-
- // COUNTRY.
- QueryEntity type = new QueryEntity();
-
- qryEntities.add(type);
-
- type.setKeyType(Integer.class.getName());
- type.setValueType(Country.class.getName());
-
- // Query fields for COUNTRY.
- LinkedHashMap<String, String> qryFlds = new LinkedHashMap<>();
-
- qryFlds.put("id", "java.lang.Integer");
- qryFlds.put("name", "java.lang.String");
- qryFlds.put("population", "java.lang.Integer");
-
- type.setFields(qryFlds);
-
- ccfg.setQueryEntities(qryEntities);
-
- return ccfg;
- }
-
- /**
- * Configure cacheEmployee.
- */
- private static <K, V> CacheConfiguration<K, V> cacheDepartment() {
- CacheConfiguration<K, V> ccfg = cacheConfiguration(DEPARTMENT_CACHE_NAME);
-
- // Configure cacheDepartment types.
- Collection<QueryEntity> qryEntities = new ArrayList<>();
-
- // DEPARTMENT.
- QueryEntity type = new QueryEntity();
-
- qryEntities.add(type);
-
- type.setKeyType(Integer.class.getName());
- type.setValueType(Department.class.getName());
-
- // Query fields for DEPARTMENT.
- LinkedHashMap<String, String> qryFlds = new LinkedHashMap<>();
-
- qryFlds.put("id", "java.lang.Integer");
- qryFlds.put("countryId", "java.lang.Integer");
- qryFlds.put("name", "java.lang.String");
-
- type.setFields(qryFlds);
-
- ccfg.setQueryEntities(qryEntities);
-
- return ccfg;
- }
-
- /**
- * Configure cacheEmployee.
- */
- private static <K, V> CacheConfiguration<K, V> cacheEmployee() {
- CacheConfiguration<K, V> ccfg = cacheConfiguration(EMPLOYEE_CACHE_NAME);
-
- ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
- ccfg.setBackups(1);
-
- // Configure cacheEmployee types.
- Collection<QueryEntity> qryEntities = new ArrayList<>();
-
- // EMPLOYEE.
- QueryEntity type = new QueryEntity();
-
- qryEntities.add(type);
-
- type.setKeyType(Integer.class.getName());
- type.setValueType(Employee.class.getName());
-
- // Query fields for EMPLOYEE.
- LinkedHashMap<String, String> qryFlds = new LinkedHashMap<>();
-
- qryFlds.put("id", "java.lang.Integer");
- qryFlds.put("departmentId", "java.lang.Integer");
- qryFlds.put("managerId", "java.lang.Integer");
- qryFlds.put("firstName", "java.lang.String");
- qryFlds.put("lastName", "java.lang.String");
- qryFlds.put("email", "java.lang.String");
- qryFlds.put("phoneNumber", "java.lang.String");
- qryFlds.put("hireDate", "java.sql.Date");
- qryFlds.put("job", "java.lang.String");
- qryFlds.put("salary", "java.lang.Double");
-
- type.setFields(qryFlds);
-
- // Indexes for EMPLOYEE.
- Collection<QueryIndex> indexes = new ArrayList<>();
-
- QueryIndex idx = new QueryIndex();
-
- idx.setName("EMP_NAMES");
- idx.setIndexType(QueryIndexType.SORTED);
- LinkedHashMap<String, Boolean> indFlds = new LinkedHashMap<>();
-
- indFlds.put("firstName", Boolean.FALSE);
- indFlds.put("lastName", Boolean.FALSE);
-
- idx.setFields(indFlds);
-
- indexes.add(idx);
- indexes.add(new QueryIndex("salary", QueryIndexType.SORTED, false, "EMP_SALARY"));
-
- type.setIndexes(indexes);
-
- ccfg.setQueryEntities(qryEntities);
-
- return ccfg;
- }
-
- /**
- * Configure cacheEmployee.
- */
- private static <K, V> CacheConfiguration<K, V> cacheParking() {
- CacheConfiguration<K, V> ccfg = cacheConfiguration(PARKING_CACHE_NAME);
-
- // Configure cacheParking types.
- Collection<QueryEntity> qryEntities = new ArrayList<>();
-
- // PARKING.
- QueryEntity type = new QueryEntity();
-
- qryEntities.add(type);
-
- type.setKeyType(Integer.class.getName());
- type.setValueType(Parking.class.getName());
-
- // Query fields for PARKING.
- LinkedHashMap<String, String> qryFlds = new LinkedHashMap<>();
-
- qryFlds.put("id", "java.lang.Integer");
- qryFlds.put("name", "java.lang.String");
- qryFlds.put("capacity", "java.lang.Integer");
-
- type.setFields(qryFlds);
-
- ccfg.setQueryEntities(qryEntities);
-
- return ccfg;
- }
-
- /**
- * Configure cacheEmployee.
- */
- private static <K, V> CacheConfiguration<K, V> cacheCar() {
- CacheConfiguration<K, V> ccfg = cacheConfiguration(CAR_CACHE_NAME);
-
- // Configure cacheCar types.
- Collection<QueryEntity> qryEntities = new ArrayList<>();
-
- // CAR.
- QueryEntity type = new QueryEntity();
-
- qryEntities.add(type);
-
- type.setKeyType(Integer.class.getName());
- type.setValueType(Car.class.getName());
-
- // Query fields for CAR.
- LinkedHashMap<String, String> qryFlds = new LinkedHashMap<>();
-
- qryFlds.put("id", "java.lang.Integer");
- qryFlds.put("parkingId", "java.lang.Integer");
- qryFlds.put("name", "java.lang.String");
-
- type.setFields(qryFlds);
-
- ccfg.setQueryEntities(qryEntities);
-
- return ccfg;
- }
-
/**
* Configure node.
* @param gridIdx Grid name index.
@@ -363,212 +106,20 @@ public class AgentClusterDemo {
if (client)
cfg.setClientMode(true);
- cfg.setCacheConfiguration(cacheCountry(), cacheDepartment(), cacheEmployee(), cacheParking(), cacheCar());
-
cfg.setSwapSpaceSpi(new FileSwapSpaceSpi());
return cfg;
}
/**
- * @param val Value to round.
- * @param places Numbers after point.
- * @return Rounded value;
- */
- private static double round(double val, int places) {
- if (places < 0)
- throw new IllegalArgumentException();
-
- long factor = (long)Math.pow(10, places);
-
- val *= factor;
-
- long tmp = Math.round(val);
-
- return (double)tmp / factor;
- }
-
- /**
- * @param ignite Ignite.
- * @param range Time range in milliseconds.
- */
- private static void populateCacheEmployee(Ignite ignite, long range) {
- if (log.isDebugEnabled())
- log.debug("DEMO: Start employees population with data...");
-
- IgniteCache<Integer, Country> cacheCountry = ignite.cache(COUNTRY_CACHE_NAME);
-
- for (int i = 0, n = 1; i < CNTR_CNT; i++, n++)
- cacheCountry.put(i, new Country(i, "Country #" + n, n * 10000000));
-
- IgniteCache<Integer, Department> cacheDepartment = ignite.cache(DEPARTMENT_CACHE_NAME);
-
- IgniteCache<Integer, Employee> cacheEmployee = ignite.cache(EMPLOYEE_CACHE_NAME);
-
- for (int i = 0, n = 1; i < DEP_CNT; i++, n++) {
- cacheDepartment.put(i, new Department(n, rnd.nextInt(CNTR_CNT), "Department #" + n));
-
- double r = rnd.nextDouble();
-
- cacheEmployee.put(i, new Employee(i, rnd.nextInt(DEP_CNT), null, "First name manager #" + n,
- "Last name manager #" + n, "Email manager #" + n, "Phone number manager #" + n,
- new java.sql.Date((long)(r * range)), "Job manager #" + n, 1000 + round(r * 4000, 2)));
- }
-
- for (int i = 0, n = 1; i < EMPL_CNT; i++, n++) {
- Integer depId = rnd.nextInt(DEP_CNT);
-
- double r = rnd.nextDouble();
-
- cacheEmployee.put(i, new Employee(i, depId, depId, "First name employee #" + n,
- "Last name employee #" + n, "Email employee #" + n, "Phone number employee #" + n,
- new java.sql.Date((long)(r * range)), "Job employee #" + n, 500 + round(r * 2000, 2)));
- }
-
- if (log.isDebugEnabled())
- log.debug("DEMO: Finished employees population.");
- }
-
- /**
- * @param ignite Ignite.
- */
- private static void populateCacheCar(Ignite ignite) {
- if (log.isDebugEnabled())
- log.debug("DEMO: Start cars population...");
-
- IgniteCache<Integer, Parking> cacheParking = ignite.cache(PARKING_CACHE_NAME);
-
- for (int i = 0, n = 1; i < PARK_CNT; i++, n++)
- cacheParking.put(i, new Parking(i, "Parking #" + n, n * 10));
-
- IgniteCache<Integer, Car> cacheCar = ignite.cache(CAR_CACHE_NAME);
-
- for (int i = 0, n = 1; i < CAR_CNT; i++, n++)
- cacheCar.put(i, new Car(i, rnd.nextInt(PARK_CNT), "Car #" + n));
-
- if (log.isDebugEnabled())
- log.debug("DEMO: Finished cars population.");
- }
-
- /**
- * Creates a thread pool that can schedule commands to run after a given delay, or to execute periodically.
- *
- * @param corePoolSize Number of threads to keep in the pool, even if they are idle.
- * @param threadName Part of thread name that would be used by thread factory.
- * @return Newly created scheduled thread pool.
- */
- private static ScheduledExecutorService newScheduledThreadPool(int corePoolSize, final String threadName) {
- ScheduledExecutorService srvc = Executors.newScheduledThreadPool(corePoolSize, new ThreadFactory() {
- @Override public Thread newThread(Runnable r) {
- Thread thread = new Thread(r, String.format("%s-%d", threadName, THREAD_CNT.getAndIncrement()));
-
- thread.setDaemon(true);
-
- return thread;
- }
- });
-
- ScheduledThreadPoolExecutor executor = (ScheduledThreadPoolExecutor)srvc;
-
- // Setting up shutdown policy.
- executor.setExecuteExistingDelayedTasksAfterShutdownPolicy(false);
- executor.setContinueExistingPeriodicTasksAfterShutdownPolicy(false);
-
- return srvc;
- }
-
- /**
* Starts read and write from cache in background.
*
* @param ignite Ignite.
* @param cnt - maximum count read/write key
*/
private static void startLoad(final Ignite ignite, final int cnt) {
- final long diff = new java.util.Date().getTime();
-
- populateCacheEmployee(ignite, diff);
- populateCacheCar(ignite);
-
- ScheduledExecutorService cachePool = newScheduledThreadPool(2, "demo-sql-load-cache-tasks");
-
- cachePool.scheduleWithFixedDelay(new Runnable() {
- @Override public void run() {
- try {
- for (String cacheName : ignite.cacheNames()) {
- if (!DEMO_CACHES.contains(cacheName)) {
- IgniteCache<Integer, String> otherCache = ignite.cache(cacheName);
-
- if (otherCache != null) {
- for (int i = 0, n = 1; i < cnt; i++, n++) {
- Integer key = rnd.nextInt(1000);
-
- String val = otherCache.get(key);
-
- if (val == null)
- otherCache.put(key, "other-" + key);
- else if (rnd.nextInt(100) < 30)
- otherCache.remove(key);
- }
- }
- }
- }
-
- IgniteCache<Integer, Employee> cacheEmployee = ignite.cache(EMPLOYEE_CACHE_NAME);
-
- if (cacheEmployee != null)
- try(Transaction tx = ignite.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) {
- for (int i = 0, n = 1; i < cnt; i++, n++) {
- Integer id = rnd.nextInt(EMPL_CNT);
-
- Integer depId = rnd.nextInt(DEP_CNT);
-
- double r = rnd.nextDouble();
-
- cacheEmployee.put(id, new Employee(id, depId, depId, "First name employee #" + n,
- "Last name employee #" + n, "Email employee #" + n, "Phone number employee #" + n,
- new java.sql.Date((long)(r * diff)), "Job employee #" + n, 500 + round(r * 2000, 2)));
-
- if (rnd.nextBoolean())
- cacheEmployee.remove(rnd.nextInt(EMPL_CNT));
-
- cacheEmployee.get(rnd.nextInt(EMPL_CNT));
- }
-
- if (rnd.nextInt(100) > 20)
- tx.commit();
- }
- }
- catch (Throwable e) {
- if (!e.getMessage().contains("cache is stopped"))
- ignite.log().error("Cache write task execution error", e);
- }
- }
- }, 10, 3, TimeUnit.SECONDS);
-
- cachePool.scheduleWithFixedDelay(new Runnable() {
- @Override public void run() {
- try {
- IgniteCache<Integer, Car> cache = ignite.cache(CAR_CACHE_NAME);
-
- if (cache != null)
- for (int i = 0; i < cnt; i++) {
- Integer carId = rnd.nextInt(CAR_CNT);
-
- cache.put(carId, new Car(carId, rnd.nextInt(PARK_CNT), "Car #" + (i + 1)));
-
- if (rnd.nextBoolean())
- cache.remove(rnd.nextInt(CAR_CNT));
- }
- }
- catch (IllegalStateException ignored) {
- // No-op.
- }
- catch (Throwable e) {
- if (!e.getMessage().contains("cache is stopped"))
- ignite.log().error("Cache write task execution error", e);
- }
- }
- }, 10, 3, TimeUnit.SECONDS);
+ ignite.services().deployClusterSingleton("Demo caches load service", new DemoCachesLoadService(cnt));
+ ignite.services().deployNodeSingleton("RandomCache load service", new DemoRandomCacheLoadService(cnt));
}
/**
@@ -609,6 +160,14 @@ public class AgentClusterDemo {
}
}, 10, 10, TimeUnit.SECONDS);
+ IgniteServices services = ignite.services();
+
+ services.deployMultiple("Demo service: Multiple instances", new DemoServiceMultipleInstances(), 7, 3);
+ services.deployNodeSingleton("Demo service: Node singleton", new DemoServiceNodeSingleton());
+ services.deployClusterSingleton("Demo service: Cluster singleton", new DemoServiceClusterSingleton());
+ services.deployKeyAffinitySingleton("Demo service: Key affinity singleton",
+ new DemoServiceKeyAffinity(), DemoCachesLoadService.CAR_CACHE_NAME, "id");
+
if (log.isDebugEnabled())
log.debug("DEMO: Started embedded nodes with indexed enabled caches...");
http://git-wip-us.apache.org/repos/asf/ignite/blob/a600cafd/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/demo/AgentDemoUtils.java
----------------------------------------------------------------------
diff --git a/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/demo/AgentDemoUtils.java b/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/demo/AgentDemoUtils.java
new file mode 100644
index 0000000..fb34de7
--- /dev/null
+++ b/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/demo/AgentDemoUtils.java
@@ -0,0 +1,79 @@
+/*
+ * 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.console.demo;
+
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledThreadPoolExecutor;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * Utilites for Agent demo mode.
+ */
+public class AgentDemoUtils {
+ /** Counter for threads in pool. */
+ private static final AtomicInteger THREAD_CNT = new AtomicInteger(0);
+
+ /**
+ * Creates a thread pool that can schedule commands to run after a given delay, or to execute periodically.
+ *
+ * @param corePoolSize Number of threads to keep in the pool, even if they are idle.
+ * @param threadName Part of thread name that would be used by thread factory.
+ * @return Newly created scheduled thread pool.
+ */
+ public static ScheduledExecutorService newScheduledThreadPool(int corePoolSize, final String threadName) {
+ ScheduledExecutorService srvc = Executors.newScheduledThreadPool(corePoolSize, new ThreadFactory() {
+ @Override public Thread newThread(Runnable r) {
+ Thread thread = new Thread(r, String.format("%s-%d", threadName, THREAD_CNT.getAndIncrement()));
+
+ thread.setDaemon(true);
+
+ return thread;
+ }
+ });
+
+ ScheduledThreadPoolExecutor executor = (ScheduledThreadPoolExecutor)srvc;
+
+ // Setting up shutdown policy.
+ executor.setExecuteExistingDelayedTasksAfterShutdownPolicy(false);
+ executor.setContinueExistingPeriodicTasksAfterShutdownPolicy(false);
+
+ return srvc;
+ }
+
+ /**
+ * Round value.
+ *
+ * @param val Value to round.
+ * @param places Numbers after point.
+ * @return Rounded value;
+ */
+ public static double round(double val, int places) {
+ if (places < 0)
+ throw new IllegalArgumentException();
+
+ long factor = (long)Math.pow(10, places);
+
+ val *= factor;
+
+ long tmp = Math.round(val);
+
+ return (double)tmp / factor;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a600cafd/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/demo/service/DemoCachesLoadService.java
----------------------------------------------------------------------
diff --git a/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/demo/service/DemoCachesLoadService.java b/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/demo/service/DemoCachesLoadService.java
new file mode 100644
index 0000000..9117646
--- /dev/null
+++ b/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/demo/service/DemoCachesLoadService.java
@@ -0,0 +1,456 @@
+/*
+ * 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.console.demo.service;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.Random;
+import java.util.Set;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.QueryEntity;
+import org.apache.ignite.cache.QueryIndex;
+import org.apache.ignite.cache.QueryIndexType;
+import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.console.demo.AgentDemoUtils;
+import org.apache.ignite.console.demo.model.Car;
+import org.apache.ignite.console.demo.model.Country;
+import org.apache.ignite.console.demo.model.Department;
+import org.apache.ignite.console.demo.model.Employee;
+import org.apache.ignite.console.demo.model.Parking;
+import org.apache.ignite.resources.IgniteInstanceResource;
+import org.apache.ignite.services.Service;
+import org.apache.ignite.services.ServiceContext;
+import org.apache.ignite.transactions.Transaction;
+
+import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
+import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ;
+
+/**
+ * Demo service. Create and populate caches. Run demo load on caches.
+ */
+public class DemoCachesLoadService implements Service {
+ /** Ignite instance. */
+ @IgniteInstanceResource
+ private Ignite ignite;
+
+ /** Thread pool to execute cache load operations. */
+ private ScheduledExecutorService cachePool;
+
+ /** */
+ private static final String COUNTRY_CACHE_NAME = "CountryCache";
+
+ /** */
+ private static final String DEPARTMENT_CACHE_NAME = "DepartmentCache";
+
+ /** */
+ private static final String EMPLOYEE_CACHE_NAME = "EmployeeCache";
+
+ /** */
+ private static final String PARKING_CACHE_NAME = "ParkingCache";
+
+ /** */
+ public static final String CAR_CACHE_NAME = "CarCache";
+
+ /** */
+ static final Set<String> DEMO_CACHES = new HashSet<>(Arrays.asList(COUNTRY_CACHE_NAME,
+ DEPARTMENT_CACHE_NAME, EMPLOYEE_CACHE_NAME, PARKING_CACHE_NAME, CAR_CACHE_NAME));
+
+ /** Countries count. */
+ private static final int CNTR_CNT = 10;
+
+ /** Departments count */
+ private static final int DEP_CNT = 100;
+
+ /** Employees count. */
+ private static final int EMPL_CNT = 1000;
+
+ /** Countries count. */
+ private static final int CAR_CNT = 100;
+
+ /** Departments count */
+ private static final int PARK_CNT = 10;
+
+ /** */
+ private static final Random rnd = new Random();
+
+ /** Maximum count read/write key. */
+ private final int cnt;
+
+ /** Time range in milliseconds. */
+ private final long range;
+
+ /**
+ * @param cnt Maximum count read/write key.
+ */
+ public DemoCachesLoadService(int cnt) {
+ this.cnt = cnt;
+
+ range = new java.util.Date().getTime();
+ }
+
+ /** {@inheritDoc} */
+ @Override public void cancel(ServiceContext ctx) {
+ if (cachePool != null)
+ cachePool.shutdown();
+ }
+
+ /** {@inheritDoc} */
+ @Override public void init(ServiceContext ctx) throws Exception {
+ ignite.createCache(cacheCountry());
+ ignite.createCache(cacheDepartment());
+ ignite.createCache(cacheEmployee());
+ ignite.createCache(cacheCar());
+ ignite.createCache(cacheParking());
+
+ populateCacheEmployee();
+ populateCacheCar();
+
+ cachePool = AgentDemoUtils.newScheduledThreadPool(2, "demo-sql-load-cache-tasks");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void execute(ServiceContext ctx) throws Exception {
+ cachePool.scheduleWithFixedDelay(new Runnable() {
+ @Override public void run() {
+ try {
+ IgniteCache<Integer, Employee> cacheEmployee = ignite.cache(EMPLOYEE_CACHE_NAME);
+
+ if (cacheEmployee != null)
+ try(Transaction tx = ignite.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) {
+ for (int i = 0, n = 1; i < cnt; i++, n++) {
+ Integer id = rnd.nextInt(EMPL_CNT);
+
+ Integer depId = rnd.nextInt(DEP_CNT);
+
+ double r = rnd.nextDouble();
+
+ cacheEmployee.put(id, new Employee(id, depId, depId, "First name employee #" + n,
+ "Last name employee #" + n, "Email employee #" + n, "Phone number employee #" + n,
+ new java.sql.Date((long)(r * range)), "Job employee #" + n,
+ 500 + AgentDemoUtils.round(r * 2000, 2)));
+
+ if (rnd.nextBoolean())
+ cacheEmployee.remove(rnd.nextInt(EMPL_CNT));
+
+ cacheEmployee.get(rnd.nextInt(EMPL_CNT));
+ }
+
+ if (rnd.nextInt(100) > 20)
+ tx.commit();
+ }
+ }
+ catch (Throwable e) {
+ if (!e.getMessage().contains("cache is stopped"))
+ ignite.log().error("Cache write task execution error", e);
+ }
+ }
+ }, 10, 3, TimeUnit.SECONDS);
+
+ cachePool.scheduleWithFixedDelay(new Runnable() {
+ @Override public void run() {
+ try {
+ IgniteCache<Integer, Car> cache = ignite.cache(CAR_CACHE_NAME);
+
+ if (cache != null)
+ for (int i = 0; i < cnt; i++) {
+ Integer carId = rnd.nextInt(CAR_CNT);
+
+ cache.put(carId, new Car(carId, rnd.nextInt(PARK_CNT), "Car #" + (i + 1)));
+
+ if (rnd.nextBoolean())
+ cache.remove(rnd.nextInt(CAR_CNT));
+ }
+ }
+ catch (IllegalStateException ignored) {
+ // No-op.
+ }
+ catch (Throwable e) {
+ if (!e.getMessage().contains("cache is stopped"))
+ ignite.log().error("Cache write task execution error", e);
+ }
+ }
+ }, 10, 3, TimeUnit.SECONDS);
+ }
+
+
+ /**
+ * Create base cache configuration.
+ *
+ * @param name cache name.
+ * @return Cache configuration with basic properties set.
+ */
+ private static <K, V> CacheConfiguration<K, V> cacheConfiguration(String name) {
+ CacheConfiguration<K, V> ccfg = new CacheConfiguration<>(name);
+
+ ccfg.setAffinity(new RendezvousAffinityFunction(false, 32));
+ ccfg.setQueryDetailMetricsSize(10);
+ ccfg.setStartSize(100);
+ ccfg.setStatisticsEnabled(true);
+
+ return ccfg;
+ }
+
+ /**
+ * Configure cacheCountry.
+ */
+ private static <K, V> CacheConfiguration<K, V> cacheCountry() {
+ CacheConfiguration<K, V> ccfg = cacheConfiguration(COUNTRY_CACHE_NAME);
+
+ // Configure cacheCountry types.
+ Collection<QueryEntity> qryEntities = new ArrayList<>();
+
+ // COUNTRY.
+ QueryEntity type = new QueryEntity();
+
+ qryEntities.add(type);
+
+ type.setKeyType(Integer.class.getName());
+ type.setValueType(Country.class.getName());
+
+ // Query fields for COUNTRY.
+ LinkedHashMap<String, String> qryFlds = new LinkedHashMap<>();
+
+ qryFlds.put("id", "java.lang.Integer");
+ qryFlds.put("name", "java.lang.String");
+ qryFlds.put("population", "java.lang.Integer");
+
+ type.setFields(qryFlds);
+
+ ccfg.setQueryEntities(qryEntities);
+
+ return ccfg;
+ }
+
+ /**
+ * Configure cacheEmployee.
+ */
+ private static <K, V> CacheConfiguration<K, V> cacheDepartment() {
+ CacheConfiguration<K, V> ccfg = cacheConfiguration(DEPARTMENT_CACHE_NAME);
+
+ // Configure cacheDepartment types.
+ Collection<QueryEntity> qryEntities = new ArrayList<>();
+
+ // DEPARTMENT.
+ QueryEntity type = new QueryEntity();
+
+ qryEntities.add(type);
+
+ type.setKeyType(Integer.class.getName());
+ type.setValueType(Department.class.getName());
+
+ // Query fields for DEPARTMENT.
+ LinkedHashMap<String, String> qryFlds = new LinkedHashMap<>();
+
+ qryFlds.put("id", "java.lang.Integer");
+ qryFlds.put("countryId", "java.lang.Integer");
+ qryFlds.put("name", "java.lang.String");
+
+ type.setFields(qryFlds);
+
+ ccfg.setQueryEntities(qryEntities);
+
+ return ccfg;
+ }
+
+ /**
+ * Configure cacheEmployee.
+ */
+ private static <K, V> CacheConfiguration<K, V> cacheEmployee() {
+ CacheConfiguration<K, V> ccfg = cacheConfiguration(EMPLOYEE_CACHE_NAME);
+
+ ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
+ ccfg.setBackups(1);
+
+ // Configure cacheEmployee types.
+ Collection<QueryEntity> qryEntities = new ArrayList<>();
+
+ // EMPLOYEE.
+ QueryEntity type = new QueryEntity();
+
+ qryEntities.add(type);
+
+ type.setKeyType(Integer.class.getName());
+ type.setValueType(Employee.class.getName());
+
+ // Query fields for EMPLOYEE.
+ LinkedHashMap<String, String> qryFlds = new LinkedHashMap<>();
+
+ qryFlds.put("id", "java.lang.Integer");
+ qryFlds.put("departmentId", "java.lang.Integer");
+ qryFlds.put("managerId", "java.lang.Integer");
+ qryFlds.put("firstName", "java.lang.String");
+ qryFlds.put("lastName", "java.lang.String");
+ qryFlds.put("email", "java.lang.String");
+ qryFlds.put("phoneNumber", "java.lang.String");
+ qryFlds.put("hireDate", "java.sql.Date");
+ qryFlds.put("job", "java.lang.String");
+ qryFlds.put("salary", "java.lang.Double");
+
+ type.setFields(qryFlds);
+
+ // Indexes for EMPLOYEE.
+ Collection<QueryIndex> indexes = new ArrayList<>();
+
+ QueryIndex idx = new QueryIndex();
+
+ idx.setName("EMP_NAMES");
+ idx.setIndexType(QueryIndexType.SORTED);
+ LinkedHashMap<String, Boolean> indFlds = new LinkedHashMap<>();
+
+ indFlds.put("firstName", Boolean.FALSE);
+ indFlds.put("lastName", Boolean.FALSE);
+
+ idx.setFields(indFlds);
+
+ indexes.add(idx);
+ indexes.add(new QueryIndex("salary", QueryIndexType.SORTED, false, "EMP_SALARY"));
+
+ type.setIndexes(indexes);
+
+ ccfg.setQueryEntities(qryEntities);
+
+ return ccfg;
+ }
+
+ /**
+ * Configure cacheEmployee.
+ */
+ private static <K, V> CacheConfiguration<K, V> cacheParking() {
+ CacheConfiguration<K, V> ccfg = cacheConfiguration(PARKING_CACHE_NAME);
+
+ // Configure cacheParking types.
+ Collection<QueryEntity> qryEntities = new ArrayList<>();
+
+ // PARKING.
+ QueryEntity type = new QueryEntity();
+
+ qryEntities.add(type);
+
+ type.setKeyType(Integer.class.getName());
+ type.setValueType(Parking.class.getName());
+
+ // Query fields for PARKING.
+ LinkedHashMap<String, String> qryFlds = new LinkedHashMap<>();
+
+ qryFlds.put("id", "java.lang.Integer");
+ qryFlds.put("name", "java.lang.String");
+ qryFlds.put("capacity", "java.lang.Integer");
+
+ type.setFields(qryFlds);
+
+ ccfg.setQueryEntities(qryEntities);
+
+ return ccfg;
+ }
+
+ /**
+ * Configure cacheEmployee.
+ */
+ private static <K, V> CacheConfiguration<K, V> cacheCar() {
+ CacheConfiguration<K, V> ccfg = cacheConfiguration(CAR_CACHE_NAME);
+
+ // Configure cacheCar types.
+ Collection<QueryEntity> qryEntities = new ArrayList<>();
+
+ // CAR.
+ QueryEntity type = new QueryEntity();
+
+ qryEntities.add(type);
+
+ type.setKeyType(Integer.class.getName());
+ type.setValueType(Car.class.getName());
+
+ // Query fields for CAR.
+ LinkedHashMap<String, String> qryFlds = new LinkedHashMap<>();
+
+ qryFlds.put("id", "java.lang.Integer");
+ qryFlds.put("parkingId", "java.lang.Integer");
+ qryFlds.put("name", "java.lang.String");
+
+ type.setFields(qryFlds);
+
+ ccfg.setQueryEntities(qryEntities);
+
+ return ccfg;
+ }
+
+ /** */
+ private void populateCacheEmployee() {
+ if (ignite.log().isDebugEnabled())
+ ignite.log().debug("DEMO: Start employees population with data...");
+
+ IgniteCache<Integer, Country> cacheCountry = ignite.cache(COUNTRY_CACHE_NAME);
+
+ for (int i = 0, n = 1; i < CNTR_CNT; i++, n++)
+ cacheCountry.put(i, new Country(i, "Country #" + n, n * 10000000));
+
+ IgniteCache<Integer, Department> cacheDepartment = ignite.cache(DEPARTMENT_CACHE_NAME);
+
+ IgniteCache<Integer, Employee> cacheEmployee = ignite.cache(EMPLOYEE_CACHE_NAME);
+
+ for (int i = 0, n = 1; i < DEP_CNT; i++, n++) {
+ cacheDepartment.put(i, new Department(n, rnd.nextInt(CNTR_CNT), "Department #" + n));
+
+ double r = rnd.nextDouble();
+
+ cacheEmployee.put(i, new Employee(i, rnd.nextInt(DEP_CNT), null, "First name manager #" + n,
+ "Last name manager #" + n, "Email manager #" + n, "Phone number manager #" + n,
+ new java.sql.Date((long)(r * range)), "Job manager #" + n, 1000 + AgentDemoUtils.round(r * 4000, 2)));
+ }
+
+ for (int i = 0, n = 1; i < EMPL_CNT; i++, n++) {
+ Integer depId = rnd.nextInt(DEP_CNT);
+
+ double r = rnd.nextDouble();
+
+ cacheEmployee.put(i, new Employee(i, depId, depId, "First name employee #" + n,
+ "Last name employee #" + n, "Email employee #" + n, "Phone number employee #" + n,
+ new java.sql.Date((long)(r * range)), "Job employee #" + n, 500 + AgentDemoUtils.round(r * 2000, 2)));
+ }
+
+ if (ignite.log().isDebugEnabled())
+ ignite.log().debug("DEMO: Finished employees population.");
+ }
+
+ /** */
+ private void populateCacheCar() {
+ if (ignite.log().isDebugEnabled())
+ ignite.log().debug("DEMO: Start cars population...");
+
+ IgniteCache<Integer, Parking> cacheParking = ignite.cache(PARKING_CACHE_NAME);
+
+ for (int i = 0, n = 1; i < PARK_CNT; i++, n++)
+ cacheParking.put(i, new Parking(i, "Parking #" + n, n * 10));
+
+ IgniteCache<Integer, Car> cacheCar = ignite.cache(CAR_CACHE_NAME);
+
+ for (int i = 0, n = 1; i < CAR_CNT; i++, n++)
+ cacheCar.put(i, new Car(i, rnd.nextInt(PARK_CNT), "Car #" + n));
+
+ if (ignite.log().isDebugEnabled())
+ ignite.log().debug("DEMO: Finished cars population.");
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a600cafd/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/demo/service/DemoRandomCacheLoadService.java
----------------------------------------------------------------------
diff --git a/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/demo/service/DemoRandomCacheLoadService.java b/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/demo/service/DemoRandomCacheLoadService.java
new file mode 100644
index 0000000..57b26a2
--- /dev/null
+++ b/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/demo/service/DemoRandomCacheLoadService.java
@@ -0,0 +1,120 @@
+/*
+ * 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.console.demo.service;
+
+import java.util.Random;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.console.demo.AgentDemoUtils;
+import org.apache.ignite.resources.IgniteInstanceResource;
+import org.apache.ignite.services.Service;
+import org.apache.ignite.services.ServiceContext;
+
+/**
+ * Demo service. Create cache and populate it by random int pairs.
+ */
+public class DemoRandomCacheLoadService implements Service {
+ /** Ignite instance. */
+ @IgniteInstanceResource
+ private Ignite ignite;
+
+ /** Thread pool to execute cache load operations. */
+ private ScheduledExecutorService cachePool;
+
+ /** */
+ public static final String RANDOM_CACHE_NAME = "RandomCache";
+
+ /** Employees count. */
+ private static final int RND_CNT = 1024;
+
+ /** */
+ private static final Random rnd = new Random();
+
+ /** Maximum count read/write key. */
+ private final int cnt;
+
+ /**
+ * @param cnt Maximum count read/write key.
+ */
+ public DemoRandomCacheLoadService(int cnt) {
+ this.cnt = cnt;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void cancel(ServiceContext ctx) {
+ if (cachePool != null)
+ cachePool.shutdown();
+ }
+
+ /** {@inheritDoc} */
+ @Override public void init(ServiceContext ctx) throws Exception {
+ ignite.getOrCreateCache(cacheRandom());
+
+ cachePool = AgentDemoUtils.newScheduledThreadPool(2, "demo-sql-random-load-cache-tasks");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void execute(ServiceContext ctx) throws Exception {
+ cachePool.scheduleWithFixedDelay(new Runnable() {
+ @Override public void run() {
+ try {
+ for (String cacheName : ignite.cacheNames()) {
+ if (!DemoCachesLoadService.DEMO_CACHES.contains(cacheName)) {
+ IgniteCache<Integer, Integer> cache = ignite.cache(cacheName);
+
+ if (cache != null) {
+ for (int i = 0, n = 1; i < cnt; i++, n++) {
+ Integer key = rnd.nextInt(RND_CNT);
+ Integer val = rnd.nextInt(RND_CNT);
+
+ cache.put(key, val);
+
+ if (rnd.nextInt(100) < 30)
+ cache.remove(key);
+ }
+ }
+ }
+ }
+ }
+ catch (Throwable e) {
+ if (!e.getMessage().contains("cache is stopped"))
+ ignite.log().error("Cache write task execution error", e);
+ }
+ }
+ }, 10, 3, TimeUnit.SECONDS);
+ }
+
+ /**
+ * Configure cacheCountry.
+ */
+ private static <K, V> CacheConfiguration<K, V> cacheRandom() {
+ CacheConfiguration<K, V> ccfg = new CacheConfiguration<>(RANDOM_CACHE_NAME);
+
+ ccfg.setAffinity(new RendezvousAffinityFunction(false, 32));
+ ccfg.setQueryDetailMetricsSize(10);
+ ccfg.setStartSize(100);
+ ccfg.setStatisticsEnabled(true);
+ ccfg.setIndexedTypes(Integer.class, Integer.class);
+
+ return ccfg;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a600cafd/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/demo/service/DemoServiceClusterSingleton.java
----------------------------------------------------------------------
diff --git a/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/demo/service/DemoServiceClusterSingleton.java b/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/demo/service/DemoServiceClusterSingleton.java
new file mode 100644
index 0000000..8c0623a
--- /dev/null
+++ b/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/demo/service/DemoServiceClusterSingleton.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.console.demo.service;
+
+import org.apache.ignite.services.Service;
+import org.apache.ignite.services.ServiceContext;
+
+/**
+ * Demo service to provide on one node in cluster.
+ */
+public class DemoServiceClusterSingleton implements Service {
+ /** {@inheritDoc} */
+ @Override public void cancel(ServiceContext ctx) {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override public void init(ServiceContext ctx) throws Exception {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override public void execute(ServiceContext ctx) throws Exception {
+ // No-op.
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a600cafd/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/demo/service/DemoServiceKeyAffinity.java
----------------------------------------------------------------------
diff --git a/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/demo/service/DemoServiceKeyAffinity.java b/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/demo/service/DemoServiceKeyAffinity.java
new file mode 100644
index 0000000..081ae27
--- /dev/null
+++ b/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/demo/service/DemoServiceKeyAffinity.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.console.demo.service;
+
+import org.apache.ignite.services.Service;
+import org.apache.ignite.services.ServiceContext;
+
+/**
+ * Demo service to provide for cache.
+ */
+public class DemoServiceKeyAffinity implements Service {
+ /** {@inheritDoc} */
+ @Override public void cancel(ServiceContext ctx) {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override public void init(ServiceContext ctx) throws Exception {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override public void execute(ServiceContext ctx) throws Exception {
+ // No-op.
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a600cafd/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/demo/service/DemoServiceMultipleInstances.java
----------------------------------------------------------------------
diff --git a/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/demo/service/DemoServiceMultipleInstances.java b/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/demo/service/DemoServiceMultipleInstances.java
new file mode 100644
index 0000000..0d10753
--- /dev/null
+++ b/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/demo/service/DemoServiceMultipleInstances.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.console.demo.service;
+
+import org.apache.ignite.services.Service;
+import org.apache.ignite.services.ServiceContext;
+
+/**
+ * Demo service to provide on all nodes.
+ */
+public class DemoServiceMultipleInstances implements Service {
+ /** {@inheritDoc} */
+ @Override public void cancel(ServiceContext ctx) {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override public void init(ServiceContext ctx) throws Exception {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override public void execute(ServiceContext ctx) throws Exception {
+ // No-op.
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a600cafd/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/demo/service/DemoServiceNodeSingleton.java
----------------------------------------------------------------------
diff --git a/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/demo/service/DemoServiceNodeSingleton.java b/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/demo/service/DemoServiceNodeSingleton.java
new file mode 100644
index 0000000..4d491da
--- /dev/null
+++ b/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/demo/service/DemoServiceNodeSingleton.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.console.demo.service;
+
+import org.apache.ignite.services.Service;
+import org.apache.ignite.services.ServiceContext;
+
+/**
+ * Demo service to provide on all nodes by one.
+ */
+public class DemoServiceNodeSingleton implements Service {
+ /** {@inheritDoc} */
+ @Override public void cancel(ServiceContext ctx) {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override public void init(ServiceContext ctx) throws Exception {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override public void execute(ServiceContext ctx) throws Exception {
+ // No-op.
+ }
+}