You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2018/11/16 13:38:59 UTC
[01/13] ignite git commit: IGNITE-8735 Metastorage creates its own
index partition - Fixes #5383.
Repository: ignite
Updated Branches:
refs/heads/ignite-10043 9a6d642f8 -> bc1ac15c3
IGNITE-8735 Metastorage creates its own index partition - Fixes #5383.
Signed-off-by: Ivan Rakov <ir...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/a74d9c4f
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/a74d9c4f
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/a74d9c4f
Branch: refs/heads/ignite-10043
Commit: a74d9c4f66f407bfde56173a727b2545cc3bfb99
Parents: 3c54f38
Author: Alexey Stelmak <sp...@gmail.com>
Authored: Thu Nov 15 15:28:22 2018 +0300
Committer: Ivan Rakov <ir...@apache.org>
Committed: Thu Nov 15 15:28:22 2018 +0300
----------------------------------------------------------------------
.../internal/pagemem/PageIdAllocator.java | 3 +
.../persistence/metastorage/MetaStorage.java | 7 ++
.../metastorage/MetastorageTree.java | 9 +++
.../metastorage/IgniteMetaStorageBasicTest.java | 78 ++++++++++++++++++++
4 files changed, 97 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/a74d9c4f/modules/core/src/main/java/org/apache/ignite/internal/pagemem/PageIdAllocator.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/PageIdAllocator.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/PageIdAllocator.java
index c6aeabe..b3e4b07 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/PageIdAllocator.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/PageIdAllocator.java
@@ -35,6 +35,9 @@ public interface PageIdAllocator {
/** Special partition reserved for index space. */
public static final int INDEX_PARTITION = 0xFFFF;
+ /** Special partition reserved for metastore space. */
+ public static final int METASTORE_PARTITION = 0x0;
+
/**
* Allocates a page from the space for the given partition ID and the given flags.
*
http://git-wip-us.apache.org/repos/asf/ignite/blob/a74d9c4f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/metastorage/MetaStorage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/metastorage/MetaStorage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/metastorage/MetaStorage.java
index 4a243aa..91fbec0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/metastorage/MetaStorage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/metastorage/MetaStorage.java
@@ -28,6 +28,7 @@ import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.internal.pagemem.FullPageId;
+import org.apache.ignite.internal.pagemem.PageIdAllocator;
import org.apache.ignite.internal.pagemem.PageIdUtils;
import org.apache.ignite.internal.pagemem.PageMemory;
import org.apache.ignite.internal.pagemem.wal.IgniteWriteAheadLogManager;
@@ -62,6 +63,7 @@ import org.apache.ignite.marshaller.Marshaller;
import org.apache.ignite.marshaller.jdk.JdkMarshaller;
import org.jetbrains.annotations.NotNull;
+import static org.apache.ignite.internal.pagemem.PageIdAllocator.FLAG_DATA;
import static org.apache.ignite.internal.pagemem.PageIdUtils.itemId;
import static org.apache.ignite.internal.pagemem.PageIdUtils.pageId;
@@ -507,6 +509,11 @@ public class MetaStorage implements DbCheckpointListener, ReadOnlyMetastorage, R
return SimpleDataPageIO.VERSIONS;
}
+ /** {@inheritDoc} */
+ @Override protected long allocatePageNoReuse() throws IgniteCheckedException {
+ return pageMem.allocatePage(grpId, PageIdAllocator.METASTORE_PARTITION, FLAG_DATA);
+ }
+
/**
* Read row from data pages.
*/
http://git-wip-us.apache.org/repos/asf/ignite/blob/a74d9c4f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/metastorage/MetastorageTree.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/metastorage/MetastorageTree.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/metastorage/MetastorageTree.java
index 00db5cd..27de684 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/metastorage/MetastorageTree.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/metastorage/MetastorageTree.java
@@ -19,6 +19,7 @@ package org.apache.ignite.internal.processors.cache.persistence.metastorage;
import java.util.concurrent.atomic.AtomicLong;
import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.internal.pagemem.PageIdAllocator;
import org.apache.ignite.internal.pagemem.PageMemory;
import org.apache.ignite.internal.pagemem.PageUtils;
import org.apache.ignite.internal.pagemem.wal.IgniteWriteAheadLogManager;
@@ -31,6 +32,9 @@ import org.apache.ignite.internal.processors.cache.persistence.tree.reuse.ReuseL
import org.apache.ignite.internal.processors.failure.FailureProcessor;
import org.jetbrains.annotations.Nullable;
+import static org.apache.ignite.internal.pagemem.PageIdAllocator.FLAG_DATA;
+import static org.apache.ignite.internal.pagemem.PageIdAllocator.FLAG_IDX;
+
/**
*
*/
@@ -94,6 +98,11 @@ public class MetastorageTree extends BPlusTree<MetastorageSearchRow, Metastorage
return rowStore;
}
+ /** {@inheritDoc} */
+ @Override protected long allocatePageNoReuse() throws IgniteCheckedException {
+ return pageMem.allocatePage(grpId, PageIdAllocator.METASTORE_PARTITION, FLAG_DATA);
+ }
+
/**
*
*/
http://git-wip-us.apache.org/repos/asf/ignite/blob/a74d9c4f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/metastorage/IgniteMetaStorageBasicTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/metastorage/IgniteMetaStorageBasicTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/metastorage/IgniteMetaStorageBasicTest.java
index e5a53fa..b6dfc12 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/metastorage/IgniteMetaStorageBasicTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/metastorage/IgniteMetaStorageBasicTest.java
@@ -17,6 +17,9 @@
package org.apache.ignite.internal.processors.cache.persistence.metastorage;
import java.io.Serializable;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Random;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.configuration.DataRegionConfiguration;
@@ -79,6 +82,81 @@ public class IgniteMetaStorageBasicTest extends GridCommonAbstractTest {
}
/**
+ *
+ */
+ public void testMetaStorageMassivePutFixed() throws Exception {
+ IgniteEx ig = startGrid(0);
+
+ ig.cluster().active(true);
+
+ IgniteCacheDatabaseSharedManager db = ig.context().cache().context().database();
+
+ MetaStorage metaStorage = db.metaStorage();
+
+ assertNotNull(metaStorage);
+
+ Random rnd = new Random();
+
+ db.checkpointReadLock();
+
+ int size;
+ try {
+ for (int i = 0; i < 10_000; i++) {
+ size = rnd.nextBoolean() ? 3500 : 2 * 3500;
+ String key = "TEST_KEY_" + (i % 1000);
+
+ byte[] arr = new byte[size];
+ rnd.nextBytes(arr);
+
+ metaStorage.remove(key);
+
+ metaStorage.putData(key, arr/*b.toString().getBytes()*/);
+ }
+ }
+ finally {
+ db.checkpointReadUnlock();
+ }
+ }
+
+ /**
+ *
+ */
+ public void testMetaStorageMassivePutRandom() throws Exception {
+ IgniteEx ig = startGrid(0);
+
+ ig.cluster().active(true);
+
+ IgniteCacheDatabaseSharedManager db = ig.context().cache().context().database();
+
+ MetaStorage metaStorage = db.metaStorage();
+
+ assertNotNull(metaStorage);
+
+ Random rnd = new Random();
+
+ db.checkpointReadLock();
+
+ int size;
+ try {
+ for (int i = 0; i < 50_000; i++) {
+ size = 100 + rnd.nextInt(9000);
+
+ String key = "TEST_KEY_" + (i % 2_000);
+
+ byte[] arr = new byte[size];
+ rnd.nextBytes(arr);
+
+ metaStorage.remove(key);
+
+ metaStorage.putData(key, arr/*b.toString().getBytes()*/);
+ }
+ }
+ finally {
+ db.checkpointReadUnlock();
+ }
+ }
+
+ /**
* Verifies that MetaStorage after massive amounts of keys stored and updated keys restores its state successfully
* after restart.
*
[04/13] ignite git commit: IGNITE-10009: ODBC fix for escaped table
names
Posted by sb...@apache.org.
IGNITE-10009: ODBC fix for escaped table names
This closes #5080
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/665aa950
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/665aa950
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/665aa950
Branch: refs/heads/ignite-10043
Commit: 665aa9508687e0c37fa81ad0832b60d0e2b7e7b3
Parents: 59db291
Author: Igor Sapego <is...@apache.org>
Authored: Thu Nov 15 17:08:00 2018 +0300
Committer: Igor Sapego <is...@apache.org>
Committed: Thu Nov 15 17:08:00 2018 +0300
----------------------------------------------------------------------
.../odbc/odbc/OdbcRequestHandler.java | 12 ++----
.../processors/odbc/odbc/OdbcUtils.java | 22 ++++++++++
.../cpp/odbc-test/src/meta_queries_test.cpp | 43 ++++++++++++++++++++
3 files changed, 68 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/665aa950/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcRequestHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcRequestHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcRequestHandler.java
index 723ce5c..10cfd6d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcRequestHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcRequestHandler.java
@@ -868,15 +868,12 @@ public class OdbcRequestHandler implements ClientListenerRequestHandler {
if (str == null)
return false;
- String pattern = ptrn.toUpperCase().replace("%", ".*").replace("_", ".");
+ String pattern = OdbcUtils.preprocessPattern(ptrn);
String[] types = pattern.split(",");
for (String type0 : types) {
- String type = type0.trim();
-
- if (type.length() >= 2 && type.matches("['\"].*['\"]"))
- type = type.substring(1, type.length() - 1);
+ String type = OdbcUtils.removeQuotationMarksIfNeeded(type0.trim());
if (str.toUpperCase().matches(type))
return true;
@@ -899,10 +896,7 @@ public class OdbcRequestHandler implements ClientListenerRequestHandler {
if (str == null)
return false;
- String pattern = ptrn.toUpperCase().replace("%", ".*").replace("_", ".");
-
- if (pattern.length() >= 2 && pattern.matches("['\"].*['\"]"))
- pattern = pattern.substring(1, pattern.length() - 1);
+ String pattern = OdbcUtils.preprocessPattern(ptrn);
return str.toUpperCase().matches(pattern);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/665aa950/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcUtils.java
index 966d7bb..d294ac2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcUtils.java
@@ -25,6 +25,7 @@ import org.apache.ignite.internal.processors.cache.QueryCursorImpl;
import org.apache.ignite.internal.processors.cache.query.IgniteQueryErrorCode;
import org.apache.ignite.internal.processors.odbc.SqlListenerDataTypes;
import org.apache.ignite.internal.processors.query.IgniteSQLException;
+import org.apache.ignite.internal.util.typedef.F;
/**
* Various ODBC utility methods.
@@ -57,6 +58,27 @@ public class OdbcUtils {
}
/**
+ * Pre-process table or column pattern.
+ *
+ * @param ptrn Pattern to pre-process.
+ * @return Processed pattern.
+ */
+ public static String preprocessPattern(String ptrn) {
+ if (F.isEmpty(ptrn))
+ return ptrn;
+
+ String ptrn0 = ' ' + removeQuotationMarksIfNeeded(ptrn.toUpperCase());
+
+ ptrn0 = ptrn0.replaceAll("([^\\\\])%", "$1.*");
+
+ ptrn0 = ptrn0.replaceAll("([^\\\\])_", "$1.");
+
+ ptrn0 = ptrn0.replaceAll("\\\\(.)", "$1");
+
+ return ptrn0.substring(1);
+ }
+
+ /**
* Private constructor.
*/
private OdbcUtils() {
http://git-wip-us.apache.org/repos/asf/ignite/blob/665aa950/modules/platforms/cpp/odbc-test/src/meta_queries_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/meta_queries_test.cpp b/modules/platforms/cpp/odbc-test/src/meta_queries_test.cpp
index d3b4a26..1edda7c 100644
--- a/modules/platforms/cpp/odbc-test/src/meta_queries_test.cpp
+++ b/modules/platforms/cpp/odbc-test/src/meta_queries_test.cpp
@@ -418,4 +418,47 @@ BOOST_AUTO_TEST_CASE(TestDdlColumnsMeta)
BOOST_REQUIRE_EQUAL(ret, SQL_NO_DATA);
}
+BOOST_AUTO_TEST_CASE(TestDdlColumnsMetaEscaped)
+{
+ Connect("DRIVER={Apache Ignite};ADDRESS=127.0.0.1:11110;SCHEMA=PUBLIC");
+
+ SQLCHAR createTable[] = "create table ESG_FOCUS(id int primary key, TEST_COLUMN varchar)";
+ SQLRETURN ret = SQLExecDirect(stmt, createTable, SQL_NTS);
+
+ if (!SQL_SUCCEEDED(ret))
+ BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt));
+
+ SQLCHAR empty[] = "";
+ SQLCHAR table[] = "ESG\\_FOCUS";
+
+ ret = SQLColumns(stmt, empty, SQL_NTS, empty, SQL_NTS, table, SQL_NTS, empty, SQL_NTS);
+
+ if (!SQL_SUCCEEDED(ret))
+ BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt));
+
+ ret = SQLFetch(stmt);
+
+ if (!SQL_SUCCEEDED(ret))
+ BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt));
+
+ CheckStringColumn(stmt, 1, "");
+ CheckStringColumn(stmt, 2, "\"PUBLIC\"");
+ CheckStringColumn(stmt, 3, "ESG_FOCUS");
+ CheckStringColumn(stmt, 4, "ID");
+
+ ret = SQLFetch(stmt);
+
+ if (!SQL_SUCCEEDED(ret))
+ BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_STMT, stmt));
+
+ CheckStringColumn(stmt, 1, "");
+ CheckStringColumn(stmt, 2, "\"PUBLIC\"");
+ CheckStringColumn(stmt, 3, "ESG_FOCUS");
+ CheckStringColumn(stmt, 4, "TEST_COLUMN");
+
+ ret = SQLFetch(stmt);
+
+ BOOST_REQUIRE_EQUAL(ret, SQL_NO_DATA);
+}
+
BOOST_AUTO_TEST_SUITE_END()
[12/13] ignite git commit: merge
Posted by sb...@apache.org.
merge
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/fb8fd071
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/fb8fd071
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/fb8fd071
Branch: refs/heads/ignite-10043
Commit: fb8fd071b1d69f2cb054d3798320380eb3401362
Parents: 9a6d642 64b19a9
Author: sboikov <sb...@apache.org>
Authored: Fri Nov 16 16:37:04 2018 +0300
Committer: sboikov <sb...@apache.org>
Committed: Fri Nov 16 16:37:04 2018 +0300
----------------------------------------------------------------------
.../internal/pagemem/PageIdAllocator.java | 3 +
.../processors/cache/CacheGroupContext.java | 1 -
.../cache/GridCacheConcurrentMapImpl.java | 1 -
.../processors/cache/GridCacheContext.java | 34 +-
.../cache/GridCacheEvictionManager.java | 1 -
.../cache/distributed/dht/GridDhtGetFuture.java | 40 +-
.../distributed/dht/GridDhtGetSingleFuture.java | 41 +-
.../dht/GridDhtTopologyFutureAdapter.java | 233 ++++---
.../dht/GridPartitionedGetFuture.java | 2 +-
.../dht/GridPartitionedSingleGetFuture.java | 9 +-
.../dht/preloader/GridDhtPartitionDemander.java | 1 -
.../GridDhtPartitionsExchangeFuture.java | 4 +-
.../dht/topology/GridDhtLocalPartition.java | 1 -
.../distributed/near/GridNearGetFuture.java | 2 +-
.../persistence/metastorage/MetaStorage.java | 7 +
.../metastorage/MetastorageTree.java | 8 +
.../wal/reader/IgniteWalIteratorFactory.java | 3 +-
.../reader/StandaloneWalRecordsIterator.java | 6 +-
.../wal/reader/StrictBoundsCheckException.java | 35 +
.../odbc/odbc/OdbcRequestHandler.java | 12 +-
.../processors/odbc/odbc/OdbcUtils.java | 22 +
.../cache/ClientCacheNodePartitionsRequest.java | 3 +-
.../processors/query/GridQueryIndexing.java | 23 +-
.../processors/query/GridQueryProcessor.java | 275 ++++----
.../processors/query/QueryKeyValueIterable.java | 53 ++
.../processors/query/QueryKeyValueIterator.java | 68 ++
.../visor/node/VisorNodeDataCollectorJob.java | 3 +-
...IgniteClientCacheInitializationFailTest.java | 19 +-
...CacheResultIsNotNullOnPartitionLossTest.java | 23 +-
.../IgniteCachePartitionLossPolicySelfTest.java | 650 +++++++------------
.../metastorage/IgniteMetaStorageBasicTest.java | 77 +++
.../processors/query/h2/IgniteH2Indexing.java | 285 ++------
...CacheAbstractQueryDetailMetricsSelfTest.java | 15 +-
.../CacheAbstractQueryMetricsSelfTest.java | 13 -
...niteCacheLockPartitionOnAffinityRunTest.java | 2 +
...ndexingCachePartitionLossPolicySelfTest.java | 2 +-
.../h2/GridIndexingSpiAbstractSelfTest.java | 639 +-----------------
...H2ResultSetIteratorNullifyOnEndSelfTest.java | 186 ------
.../cpp/odbc-test/src/meta_queries_test.cpp | 43 ++
.../cpp/odbc-test/src/sql_get_info_test.cpp | 2 +-
.../cpp/odbc/src/config/connection_info.cpp | 2 +-
.../thin-client-test/src/cache_client_test.cpp | 27 +
42 files changed, 1055 insertions(+), 1821 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/fb8fd071/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
----------------------------------------------------------------------
[03/13] ignite git commit: IGNITE-9897: ODBC fix for PDO when used
with unixODBC
Posted by sb...@apache.org.
IGNITE-9897: ODBC fix for PDO when used with unixODBC
This closes #5248
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/59db2913
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/59db2913
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/59db2913
Branch: refs/heads/ignite-10043
Commit: 59db29138406b6986200910ef8de44666f993fcd
Parents: 43ebe7a
Author: Igor Sapego <is...@apache.org>
Authored: Thu Nov 15 16:59:54 2018 +0300
Committer: Igor Sapego <is...@apache.org>
Committed: Thu Nov 15 16:59:54 2018 +0300
----------------------------------------------------------------------
modules/platforms/cpp/odbc-test/src/sql_get_info_test.cpp | 2 +-
modules/platforms/cpp/odbc/src/config/connection_info.cpp | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/59db2913/modules/platforms/cpp/odbc-test/src/sql_get_info_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/sql_get_info_test.cpp b/modules/platforms/cpp/odbc-test/src/sql_get_info_test.cpp
index d8ed087..96e6164 100644
--- a/modules/platforms/cpp/odbc-test/src/sql_get_info_test.cpp
+++ b/modules/platforms/cpp/odbc-test/src/sql_get_info_test.cpp
@@ -165,7 +165,7 @@ BOOST_AUTO_TEST_CASE(TestValues)
CheckIntInfo(SQL_POS_OPERATIONS, 0);
CheckIntInfo(SQL_SQL92_DATETIME_FUNCTIONS, SQL_SDF_CURRENT_DATE | SQL_SDF_CURRENT_TIMESTAMP);
CheckIntInfo(SQL_SQL92_VALUE_EXPRESSIONS, SQL_SVE_CASE | SQL_SVE_CAST | SQL_SVE_COALESCE | SQL_SVE_NULLIF);
- CheckIntInfo(SQL_STATIC_CURSOR_ATTRIBUTES1, SQL_CA1_NEXT);
+ CheckIntInfo(SQL_STATIC_CURSOR_ATTRIBUTES1, SQL_CA1_NEXT | SQL_CA1_ABSOLUTE);
CheckIntInfo(SQL_STATIC_CURSOR_ATTRIBUTES2, 0);
CheckIntInfo(SQL_PARAM_ARRAY_ROW_COUNTS, SQL_PARC_BATCH);
CheckIntInfo(SQL_PARAM_ARRAY_SELECTS, SQL_PAS_NO_SELECT);
http://git-wip-us.apache.org/repos/asf/ignite/blob/59db2913/modules/platforms/cpp/odbc/src/config/connection_info.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/config/connection_info.cpp b/modules/platforms/cpp/odbc/src/config/connection_info.cpp
index 5885381..fde8ca5 100644
--- a/modules/platforms/cpp/odbc/src/config/connection_info.cpp
+++ b/modules/platforms/cpp/odbc/src/config/connection_info.cpp
@@ -1103,7 +1103,7 @@ namespace ignite
// Bitmask that describes the attributes of a static cursor that are supported by the driver. This
// bitmask contains the first subset of attributes; for the second subset, see
// SQL_STATIC_CURSOR_ATTRIBUTES2.
- intParams[SQL_STATIC_CURSOR_ATTRIBUTES1] = SQL_CA1_NEXT;
+ intParams[SQL_STATIC_CURSOR_ATTRIBUTES1] = SQL_CA1_NEXT | SQL_CA1_ABSOLUTE;
#endif // SQL_STATIC_CURSOR_ATTRIBUTES1
#ifdef SQL_STATIC_CURSOR_ATTRIBUTES2
[11/13] ignite git commit: IGNITE-10273: Thin clents now getting the
last affinity mapping in all cases.
Posted by sb...@apache.org.
IGNITE-10273: Thin clents now getting the last affinity mapping in all
cases.
This closes #5399
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/64b19a99
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/64b19a99
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/64b19a99
Branch: refs/heads/ignite-10043
Commit: 64b19a99abdc4e253d0aeb53ba860c8a2f30c51d
Parents: eed26bc
Author: Igor Sapego <is...@apache.org>
Authored: Fri Nov 16 15:40:24 2018 +0300
Committer: Igor Sapego <is...@apache.org>
Committed: Fri Nov 16 15:40:24 2018 +0300
----------------------------------------------------------------------
.../cache/ClientCacheNodePartitionsRequest.java | 3 +--
.../thin-client-test/src/cache_client_test.cpp | 27 ++++++++++++++++++++
2 files changed, 28 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/64b19a99/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheNodePartitionsRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheNodePartitionsRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheNodePartitionsRequest.java
index b9bf80e..377d26f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheNodePartitionsRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheNodePartitionsRequest.java
@@ -50,8 +50,7 @@ public class ClientCacheNodePartitionsRequest extends ClientCacheRequest {
IgniteCache cache = cache(ctx);
GridDiscoveryManager discovery = ctx.kernalContext().discovery();
- Collection<ClusterNode> nodes = discovery.cacheNodes(cache.getName(),
- new AffinityTopologyVersion(discovery.topologyVersion()));
+ Collection<ClusterNode> nodes = discovery.discoCache().cacheNodes(cache.getName());
Affinity aff = ctx.kernalContext().affinity().affinityProxy(cache.getName());
http://git-wip-us.apache.org/repos/asf/ignite/blob/64b19a99/modules/platforms/cpp/thin-client-test/src/cache_client_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/thin-client-test/src/cache_client_test.cpp b/modules/platforms/cpp/thin-client-test/src/cache_client_test.cpp
index 24ff48f..4031d46 100644
--- a/modules/platforms/cpp/thin-client-test/src/cache_client_test.cpp
+++ b/modules/platforms/cpp/thin-client-test/src/cache_client_test.cpp
@@ -814,6 +814,33 @@ BOOST_AUTO_TEST_CASE(CacheClientDefaultDynamicCache)
}
}
+BOOST_AUTO_TEST_CASE(CacheClientDefaultDynamicCacheThreeNodes)
+{
+ StartNode("node1");
+ StartNode("node2");
+
+ IgniteClientConfiguration cfg;
+ cfg.SetEndPoints("127.0.0.1:11110..11120");
+
+ IgniteClient client = IgniteClient::Start(cfg);
+
+ cache::CacheClient<std::string, int64_t> cache =
+ client.CreateCache<std::string, int64_t>("defaultdynamic3");
+
+ cache.RefreshAffinityMapping();
+
+ for (int64_t i = 1; i < 1000; ++i)
+ cache.Put(ignite::common::LexicalCast<std::string>(i * 39916801), i * 5039);
+
+ for (int64_t i = 1; i < 1000; ++i)
+ {
+ int64_t val;
+ LocalPeek(cache, ignite::common::LexicalCast<std::string>(i * 39916801), val);
+
+ BOOST_CHECK_EQUAL(val, i * 5039);
+ }
+}
+
BOOST_AUTO_TEST_CASE(CacheClientGetAllContainers)
{
IgniteClientConfiguration cfg;
[07/13] ignite git commit: IGNITE-10246 Added license header.
Posted by sb...@apache.org.
IGNITE-10246 Added license header.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/a8020741
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/a8020741
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/a8020741
Branch: refs/heads/ignite-10043
Commit: a8020741c276618331900078d86e90c63bf2dcf4
Parents: 3ad2034
Author: Ivan Rakov <ir...@apache.org>
Authored: Thu Nov 15 20:14:33 2018 +0300
Committer: Ivan Rakov <ir...@apache.org>
Committed: Thu Nov 15 20:14:33 2018 +0300
----------------------------------------------------------------------
.../wal/reader/StrictBoundsCheckException.java | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/a8020741/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StrictBoundsCheckException.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StrictBoundsCheckException.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StrictBoundsCheckException.java
index 4a52e08..89d54eb 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StrictBoundsCheckException.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StrictBoundsCheckException.java
@@ -1,3 +1,20 @@
+/*
+ * 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.persistence.wal.reader;
import org.apache.ignite.IgniteCheckedException;
[06/13] ignite git commit: IGNITE-10237 Fixed inspections
Posted by sb...@apache.org.
IGNITE-10237 Fixed inspections
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/3ad2034c
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/3ad2034c
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/3ad2034c
Branch: refs/heads/ignite-10043
Commit: 3ad2034c0473e02fb8c7142cb9b2f7b74ecccded
Parents: e476098
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Thu Nov 15 20:05:52 2018 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Thu Nov 15 20:05:52 2018 +0300
----------------------------------------------------------------------
.../apache/ignite/internal/processors/cache/CacheGroupContext.java | 1 -
.../internal/processors/cache/GridCacheConcurrentMapImpl.java | 1 -
.../ignite/internal/processors/cache/GridCacheEvictionManager.java | 1 -
.../cache/distributed/dht/preloader/GridDhtPartitionDemander.java | 1 -
.../cache/distributed/dht/topology/GridDhtLocalPartition.java | 1 -
5 files changed, 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3ad2034c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupContext.java
index 7f0b4ed..95fc08f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupContext.java
@@ -64,7 +64,6 @@ import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteBiInClosure;
import org.apache.ignite.lang.IgniteFuture;
import org.apache.ignite.lang.IgnitePredicate;
-import org.apache.ignite.lang.IgniteUuid;
import org.apache.ignite.mxbean.CacheGroupMetricsMXBean;
import org.jetbrains.annotations.Nullable;
http://git-wip-us.apache.org/repos/asf/ignite/blob/3ad2034c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentMapImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentMapImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentMapImpl.java
index 005fdfb..a463500 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentMapImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentMapImpl.java
@@ -26,7 +26,6 @@ import java.util.Set;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.lang.IgnitePredicate;
-import org.apache.ignite.lang.IgniteUuid;
import org.jetbrains.annotations.Nullable;
import static org.apache.ignite.events.EventType.EVT_CACHE_ENTRY_CREATED;
http://git-wip-us.apache.org/repos/asf/ignite/blob/3ad2034c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java
index b3b8810..a1bf0ff 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java
@@ -30,7 +30,6 @@ import org.apache.ignite.internal.processors.cache.version.GridCacheVersionManag
import org.apache.ignite.internal.util.GridBusyLock;
import org.apache.ignite.internal.util.typedef.X;
import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.lang.IgniteUuid;
import org.apache.ignite.mxbean.IgniteMBeanAware;
import org.jetbrains.annotations.Nullable;
http://git-wip-us.apache.org/repos/asf/ignite/blob/3ad2034c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
index 7ea943d..a75fae7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
@@ -70,7 +70,6 @@ import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteInClosure;
import org.apache.ignite.lang.IgnitePredicate;
-import org.apache.ignite.lang.IgniteUuid;
import org.apache.ignite.spi.IgniteSpiException;
import org.jetbrains.annotations.Nullable;
http://git-wip-us.apache.org/repos/asf/ignite/blob/3ad2034c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/topology/GridDhtLocalPartition.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/topology/GridDhtLocalPartition.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/topology/GridDhtLocalPartition.java
index c1f3713..8ee7a9d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/topology/GridDhtLocalPartition.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/topology/GridDhtLocalPartition.java
@@ -59,7 +59,6 @@ import org.apache.ignite.internal.util.tostring.GridToStringExclude;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteInClosure;
-import org.apache.ignite.lang.IgniteUuid;
import org.apache.ignite.util.deque.FastSizeDeque;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
[09/13] ignite git commit: IGNITE-10237 Fixed inspections
Posted by sb...@apache.org.
IGNITE-10237 Fixed inspections
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/a9c5aedf
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/a9c5aedf
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/a9c5aedf
Branch: refs/heads/ignite-10043
Commit: a9c5aedfa13e16a04a9567ce18ecb730cf6691f3
Parents: c4ec543
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Fri Nov 16 11:18:31 2018 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Fri Nov 16 11:18:31 2018 +0300
----------------------------------------------------------------------
.../internal/processors/cache/GridCacheContext.java | 15 ---------------
.../persistence/metastorage/MetastorageTree.java | 1 -
.../metastorage/IgniteMetaStorageBasicTest.java | 3 +--
3 files changed, 1 insertion(+), 18 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/a9c5aedf/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 53c0bf0..30cf969 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
@@ -1254,21 +1254,6 @@ public class GridCacheContext<K, V> implements Externalizable {
*
* @param e Element.
* @param p Predicates.
- * @return {@code True} if predicates passed.
- * @throws IgniteCheckedException If failed.
- */
- public <K1, V1> boolean isAll(
- GridCacheEntryEx e,
- @Nullable IgnitePredicate<Cache.Entry<K1, V1>>[] p
- ) throws IgniteCheckedException {
- return F.isEmpty(p) || isAll(e.<K1, V1>wrapLazyValue(keepBinary()), p);
- }
-
- /**
- * Same as {@link GridFunc#isAll(Object, IgnitePredicate[])}, but safely unwraps exceptions.
- *
- * @param e Element.
- * @param p Predicates.
* @param <E> Element type.
* @return {@code True} if predicates passed.
* @throws IgniteCheckedException If failed.
http://git-wip-us.apache.org/repos/asf/ignite/blob/a9c5aedf/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/metastorage/MetastorageTree.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/metastorage/MetastorageTree.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/metastorage/MetastorageTree.java
index 27de684..420c51d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/metastorage/MetastorageTree.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/metastorage/MetastorageTree.java
@@ -33,7 +33,6 @@ import org.apache.ignite.internal.processors.failure.FailureProcessor;
import org.jetbrains.annotations.Nullable;
import static org.apache.ignite.internal.pagemem.PageIdAllocator.FLAG_DATA;
-import static org.apache.ignite.internal.pagemem.PageIdAllocator.FLAG_IDX;
/**
*
http://git-wip-us.apache.org/repos/asf/ignite/blob/a9c5aedf/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/metastorage/IgniteMetaStorageBasicTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/metastorage/IgniteMetaStorageBasicTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/metastorage/IgniteMetaStorageBasicTest.java
index b6dfc12..538b332 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/metastorage/IgniteMetaStorageBasicTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/metastorage/IgniteMetaStorageBasicTest.java
@@ -14,11 +14,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package org.apache.ignite.internal.processors.cache.persistence.metastorage;
import java.io.Serializable;
-import java.util.HashSet;
-import java.util.List;
import java.util.Random;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCheckedException;
[13/13] ignite git commit: merge
Posted by sb...@apache.org.
merge
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/bc1ac15c
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/bc1ac15c
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/bc1ac15c
Branch: refs/heads/ignite-10043
Commit: bc1ac15c36fb459f221c9b723ad82a6e43a5bfca
Parents: fb8fd07
Author: sboikov <sb...@apache.org>
Authored: Fri Nov 16 16:38:07 2018 +0300
Committer: sboikov <sb...@apache.org>
Committed: Fri Nov 16 16:38:07 2018 +0300
----------------------------------------------------------------------
.../distributed/IgniteCachePartitionLossPolicySelfTest.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/bc1ac15c/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCachePartitionLossPolicySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCachePartitionLossPolicySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCachePartitionLossPolicySelfTest.java
index f02563d..322a79f 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCachePartitionLossPolicySelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCachePartitionLossPolicySelfTest.java
@@ -553,12 +553,12 @@ public class IgniteCachePartitionLossPolicySelfTest extends GridCommonAbstractTe
for (Map<Integer, Semaphore> map : lostMap) {
for (Map.Entry<Integer, Semaphore> entry : map.entrySet())
- assertTrue("Failed to wait for partition LOST event for partition:" + entry.getKey(), entry.getValue().tryAcquire(1));
+ assertTrue("Failed to wait for partition LOST event for partition: " + entry.getKey(), entry.getValue().tryAcquire(1));
}
for (Map<Integer, Semaphore> map : lostMap) {
for (Map.Entry<Integer, Semaphore> entry : map.entrySet())
- assertFalse("Partition LOST event raised twice for partition:" + entry.getKey(), entry.getValue().tryAcquire(1));
+ assertFalse("Partition LOST event raised twice for partition: " + entry.getKey(), entry.getValue().tryAcquire(1));
}
return parts;
[05/13] ignite git commit: IGNITE-10207 Fixed missed loss policy
checks - Fixes #5360.
Posted by sb...@apache.org.
IGNITE-10207 Fixed missed loss policy checks - Fixes #5360.
Signed-off-by: Dmitriy Govorukhin <dm...@gmail.com>
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/e4760980
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/e4760980
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/e4760980
Branch: refs/heads/ignite-10043
Commit: e4760980ab6077ee398965f551fdf8302820ae0e
Parents: 665aa95
Author: Dmitriy Govorukhin <dm...@gmail.com>
Authored: Thu Nov 15 19:15:13 2018 +0300
Committer: Dmitriy Govorukhin <dm...@gmail.com>
Committed: Thu Nov 15 19:15:13 2018 +0300
----------------------------------------------------------------------
.../processors/cache/GridCacheContext.java | 19 +-
.../cache/distributed/dht/GridDhtGetFuture.java | 40 +-
.../distributed/dht/GridDhtGetSingleFuture.java | 41 +-
.../dht/GridDhtTopologyFutureAdapter.java | 233 ++++---
.../dht/GridPartitionedGetFuture.java | 2 +-
.../dht/GridPartitionedSingleGetFuture.java | 9 +-
.../GridDhtPartitionsExchangeFuture.java | 4 +-
.../distributed/near/GridNearGetFuture.java | 2 +-
...CacheResultIsNotNullOnPartitionLossTest.java | 23 +-
.../IgniteCachePartitionLossPolicySelfTest.java | 652 +++++++------------
...ndexingCachePartitionLossPolicySelfTest.java | 2 +-
11 files changed, 483 insertions(+), 544 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4760980/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 44d067c..53c0bf0 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
@@ -2241,9 +2241,14 @@ public class GridCacheContext<K, V> implements Externalizable {
*
* @param affNodes All affinity nodes.
* @param canRemap Flag indicating that 'get' should be done on a locked topology version.
+ * @param partitionId Partition ID.
* @return Affinity node to get key from or {@code null} if there is no suitable alive node.
*/
- @Nullable public ClusterNode selectAffinityNodeBalanced(List<ClusterNode> affNodes, boolean canRemap) {
+ @Nullable public ClusterNode selectAffinityNodeBalanced(
+ List<ClusterNode> affNodes,
+ int partitionId,
+ boolean canRemap
+ ) {
if (!readLoadBalancingEnabled) {
if (!canRemap) {
for (ClusterNode node : affNodes) {
@@ -2267,7 +2272,7 @@ public class GridCacheContext<K, V> implements Externalizable {
ClusterNode n0 = null;
for (ClusterNode node : affNodes) {
- if (canRemap || discovery().alive(node)) {
+ if ((canRemap || discovery().alive(node) && isOwner(node, partitionId))) {
if (locMacs.equals(node.attribute(ATTR_MACS)))
return node;
@@ -2282,6 +2287,16 @@ public class GridCacheContext<K, V> implements Externalizable {
}
/**
+ * Check that node is owner for partition.
+ * @param node Cluster node.
+ * @param partitionId Partition ID.
+ * @return {@code}
+ */
+ private boolean isOwner(ClusterNode node, int partitionId) {
+ return topology().partitionState(node.id(), partitionId) == OWNING;
+ }
+
+ /**
* Prepare affinity field for builder (if possible).
*
* @param buider Builder.
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4760980/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 024e262..96d1769 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
@@ -37,6 +37,7 @@ import org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedExceptio
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.dht.GridDhtTopologyFutureAdapter.LostPolicyValidator;
import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtInvalidPartitionException;
import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtLocalPartition;
import org.apache.ignite.internal.processors.cache.mvcc.MvccSnapshot;
@@ -55,6 +56,11 @@ import org.apache.ignite.lang.IgniteUuid;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import static java.util.Collections.singleton;
+import static org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTopologyFutureAdapter.OperationType.READ;
+import static org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState.LOST;
+import static org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState.OWNING;
+
/**
*
*/
@@ -185,6 +191,7 @@ public final class GridDhtGetFuture<K, V> extends GridCompoundIdentityFuture<Col
* Initializes future.
*/
void init() {
+ // TODO get rid of force keys request https://issues.apache.org/jira/browse/IGNITE-10251
GridDhtFuture<Object> fut = cctx.group().preloader().request(cctx, keys.keySet(), topVer);
if (fut != null) {
@@ -209,14 +216,14 @@ public final class GridDhtGetFuture<K, V> extends GridCompoundIdentityFuture<Col
return;
}
- map0(keys);
+ map0(keys, true);
markInitialized();
}
});
}
else {
- map0(keys);
+ map0(keys, false);
markInitialized();
}
@@ -257,7 +264,7 @@ public final class GridDhtGetFuture<K, V> extends GridCompoundIdentityFuture<Col
/**
* @param keys Keys to map.
*/
- private void map0(Map<KeyCacheObject, Boolean> keys) {
+ private void map0(Map<KeyCacheObject, Boolean> keys, boolean forceKeys) {
Map<KeyCacheObject, Boolean> mappedKeys = null;
// Assign keys to primary nodes.
@@ -265,7 +272,7 @@ public final class GridDhtGetFuture<K, V> extends GridCompoundIdentityFuture<Col
int part = cctx.affinity().partition(key.getKey());
if (retries == null || !retries.contains(part)) {
- if (!map(key.getKey())) {
+ if (!map(key.getKey(), forceKeys)) {
if (retries == null)
retries = new HashSet<>();
@@ -309,7 +316,7 @@ public final class GridDhtGetFuture<K, V> extends GridCompoundIdentityFuture<Col
* @param key Key.
* @return {@code True} if mapped.
*/
- private boolean map(KeyCacheObject key) {
+ private boolean map(KeyCacheObject key, boolean forceKeys) {
try {
int keyPart = cctx.affinity().partition(key);
@@ -320,14 +327,31 @@ public final class GridDhtGetFuture<K, V> extends GridCompoundIdentityFuture<Col
if (part == null)
return false;
+ if (!forceKeys && part.state() == LOST && !recovery) {
+ Throwable error = LostPolicyValidator.validate(cctx, key, READ, singleton(part.id()));
+
+ if (error != null) {
+ onDone(null, error);
+
+ return false;
+ }
+ }
+
if (parts == null || !F.contains(parts, part.id())) {
// By reserving, we make sure that partition won't be unloaded while processed.
if (part.reserve()) {
- parts = parts == null ? new int[1] : Arrays.copyOf(parts, parts.length + 1);
+ if (forceKeys || (part.state() == OWNING || part.state() == LOST)) {
+ parts = parts == null ? new int[1] : Arrays.copyOf(parts, parts.length + 1);
- parts[parts.length - 1] = part.id();
+ parts[parts.length - 1] = part.id();
- return true;
+ return true;
+ }
+ else {
+ part.release();
+
+ return false;
+ }
}
else
return false;
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4760980/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 88f6848..e0fe8be 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,6 +35,7 @@ import org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedExceptio
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.dht.GridDhtTopologyFutureAdapter.LostPolicyValidator;
import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtInvalidPartitionException;
import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtLocalPartition;
import org.apache.ignite.internal.processors.cache.mvcc.MvccSnapshot;
@@ -47,6 +48,11 @@ import org.apache.ignite.lang.IgniteUuid;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import static java.util.Collections.singleton;
+import static org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTopologyFutureAdapter.OperationType.READ;
+import static org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState.LOST;
+import static org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState.OWNING;
+
/**
*
*/
@@ -207,6 +213,7 @@ public final class GridDhtGetSingleFuture<K, V> extends GridFutureAdapter<GridCa
*
*/
private void map() {
+ // TODO get rid of force keys request https://issues.apache.org/jira/browse/IGNITE-10251
if (cctx.group().preloader().needForceKeys()) {
GridDhtFuture<Object> fut = cctx.group().preloader().request(
cctx,
@@ -240,7 +247,7 @@ public final class GridDhtGetSingleFuture<K, V> extends GridFutureAdapter<GridCa
onDone(e);
}
else
- map0();
+ map0(true);
}
}
);
@@ -249,19 +256,20 @@ public final class GridDhtGetSingleFuture<K, V> extends GridFutureAdapter<GridCa
}
}
- map0();
+ map0(false);
}
/**
*
*/
- private void map0() {
+ private void map0(boolean forceKeys) {
assert retry == null : retry;
- if (!map(key)) {
+ if (!map(key, forceKeys)) {
retry = cctx.affinity().partition(key);
- onDone((GridCacheEntryInfo)null);
+ if (!isDone())
+ onDone((GridCacheEntryInfo)null);
return;
}
@@ -278,7 +286,7 @@ public final class GridDhtGetSingleFuture<K, V> extends GridFutureAdapter<GridCa
* @param key Key.
* @return {@code True} if mapped.
*/
- private boolean map(KeyCacheObject key) {
+ private boolean map(KeyCacheObject key, boolean forceKeys) {
try {
int keyPart = cctx.affinity().partition(key);
@@ -291,11 +299,28 @@ public final class GridDhtGetSingleFuture<K, V> extends GridFutureAdapter<GridCa
assert this.part == -1;
+ if (!forceKeys && part.state() == LOST && !recovery) {
+ Throwable error = LostPolicyValidator.validate(cctx, key, READ, singleton(part.id()));
+
+ if (error != null) {
+ onDone(null, error);
+
+ return false;
+ }
+ }
+
// By reserving, we make sure that partition won't be unloaded while processed.
if (part.reserve()) {
- this.part = part.id();
+ if (forceKeys || (part.state() == OWNING || part.state() == LOST)) {
+ this.part = part.id();
+
+ return true;
+ }
+ else {
+ part.release();
- return true;
+ return false;
+ }
}
else
return false;
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4760980/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTopologyFutureAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTopologyFutureAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTopologyFutureAdapter.java
index 9214308..8a6a5ee 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTopologyFutureAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTopologyFutureAdapter.java
@@ -29,12 +29,13 @@ import org.apache.ignite.internal.processors.cache.CacheGroupContext;
import org.apache.ignite.internal.processors.cache.CacheInvalidStateException;
import org.apache.ignite.internal.processors.cache.GridCacheContext;
import org.apache.ignite.internal.util.future.GridFutureAdapter;
+import org.apache.ignite.internal.util.typedef.F;
import org.jetbrains.annotations.Nullable;
import static org.apache.ignite.cache.PartitionLossPolicy.READ_ONLY_ALL;
import static org.apache.ignite.cache.PartitionLossPolicy.READ_ONLY_SAFE;
-import static org.apache.ignite.cache.PartitionLossPolicy.READ_WRITE_ALL;
import static org.apache.ignite.cache.PartitionLossPolicy.READ_WRITE_SAFE;
+import static org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTopologyFutureAdapter.OperationType.WRITE;
/**
*
@@ -42,7 +43,7 @@ import static org.apache.ignite.cache.PartitionLossPolicy.READ_WRITE_SAFE;
public abstract class GridDhtTopologyFutureAdapter extends GridFutureAdapter<AffinityTopologyVersion>
implements GridDhtTopologyFuture {
/** Cache groups validation results. */
- protected volatile Map<Integer, CacheValidation> grpValidRes;
+ protected volatile Map<Integer, CacheGroupValidation> grpValidRes = Collections.emptyMap();
/** Whether or not cluster is active. */
protected volatile boolean clusterIsActive = true;
@@ -52,7 +53,7 @@ public abstract class GridDhtTopologyFutureAdapter extends GridFutureAdapter<Aff
* @param topNodes Topology nodes.
* @return Validation result.
*/
- protected final CacheValidation validateCacheGroup(CacheGroupContext grp, Collection<ClusterNode> topNodes) {
+ protected final CacheGroupValidation validateCacheGroup(CacheGroupContext grp, Collection<ClusterNode> topNodes) {
Collection<Integer> lostParts = grp.isLocal() ?
Collections.<Integer>emptyList() : grp.topology().lostPartitions();
@@ -65,11 +66,11 @@ public abstract class GridDhtTopologyFutureAdapter extends GridFutureAdapter<Aff
valid = validator.validate(topNodes);
}
- return new CacheValidation(valid, lostParts);
+ return new CacheGroupValidation(valid, lostParts);
}
/** {@inheritDoc} */
- @Nullable @Override public final Throwable validateCache(
+ @Override public final @Nullable Throwable validateCache(
GridCacheContext cctx,
boolean recovery,
boolean read,
@@ -87,115 +88,181 @@ public abstract class GridDhtTopologyFutureAdapter extends GridFutureAdapter<Aff
return new CacheInvalidStateException(
"Failed to perform cache operation (cluster is not activated): " + cctx.name());
+ OperationType opType = read ? OperationType.READ : WRITE;
+
CacheGroupContext grp = cctx.group();
- PartitionLossPolicy partLossPlc = grp.config().getPartitionLossPolicy();
+ PartitionLossPolicy lossPlc = grp.config().getPartitionLossPolicy();
+
+ if (cctx.shared().readOnlyMode() && opType == WRITE)
+ return new IgniteCheckedException("Failed to perform cache operation (cluster is in read only mode)");
if (grp.needsRecovery() && !recovery) {
- if (!read && (partLossPlc == READ_ONLY_SAFE || partLossPlc == READ_ONLY_ALL))
- return new IgniteCheckedException("Failed to write to cache (cache is moved to a read-only state): " +
- cctx.name());
+ if (opType == WRITE && (lossPlc == READ_ONLY_SAFE || lossPlc == READ_ONLY_ALL))
+ return new IgniteCheckedException(
+ "Failed to write to cache (cache is moved to a read-only state): " + cctx.name());
}
- if (cctx.shared().readOnlyMode() && !read)
- return new IgniteCheckedException("Failed to perform cache operation (cluster is in read only mode)" );
+ CacheGroupValidation validation = grpValidRes.get(grp.groupId());
- if (grp.needsRecovery() || grp.topologyValidator() != null) {
- CacheValidation validation = grpValidRes.get(grp.groupId());
+ if (validation == null)
+ return null;
- if (validation == null)
- return null;
+ if (opType == WRITE && !validation.isValid()) {
+ return new IgniteCheckedException("Failed to perform cache operation " +
+ "(cache topology is not valid): " + cctx.name());
+ }
- if (!validation.valid && !read)
- return new IgniteCheckedException("Failed to perform cache operation " +
- "(cache topology is not valid): " + cctx.name());
+ if (recovery)
+ return null;
- if (recovery || !grp.needsRecovery())
- return null;
+ if (validation.hasLostPartitions()) {
+ if (key != null)
+ return LostPolicyValidator.validate(cctx, key, opType, validation.lostPartitions());
- if (key != null) {
- int p = cctx.affinity().partition(key);
+ if (keys != null)
+ return LostPolicyValidator.validate(cctx, keys, opType, validation.lostPartitions());
+ }
- CacheInvalidStateException ex = validatePartitionOperation(cctx.name(), read, key, p,
- validation.lostParts, partLossPlc);
+ return null;
+ }
- if (ex != null)
- return ex;
- }
+ /**
+ * Cache group validation result.
+ */
+ protected static class CacheGroupValidation {
+ /** Topology validation result. */
+ private final boolean valid;
- if (keys != null) {
- for (Object k : keys) {
- int p = cctx.affinity().partition(k);
+ /** Lost partitions on this topology version. */
+ private final Collection<Integer> lostParts;
- CacheInvalidStateException ex = validatePartitionOperation(cctx.name(), read, k, p,
- validation.lostParts, partLossPlc);
+ /**
+ * @param valid Valid flag.
+ * @param lostParts Lost partitions.
+ */
+ private CacheGroupValidation(boolean valid, Collection<Integer> lostParts) {
+ this.valid = valid;
+ this.lostParts = lostParts;
+ }
- if (ex != null)
- return ex;
- }
- }
+ /**
+ * @return True if valid, False if invalide.
+ */
+ public boolean isValid() {
+ return valid;
}
- return null;
+ /**
+ * @return True if lost partition is present, False if not.
+ */
+ public boolean hasLostPartitions() {
+ return !F.isEmpty(lostParts);
+ }
+
+ /**
+ * @return Lost patition ID collection.
+ */
+ public Collection<Integer> lostPartitions() {
+ return lostParts;
+ }
}
/**
- * @param cacheName Cache name.
- * @param read Read flag.
- * @param key Key to check.
- * @param part Partition this key belongs to.
- * @param lostParts Collection of lost partitions.
- * @param plc Partition loss policy.
- * @return Invalid state exception if this operation is disallowed.
+ *
*/
- private CacheInvalidStateException validatePartitionOperation(
- String cacheName,
- boolean read,
- Object key,
- int part,
- Collection<Integer> lostParts,
- PartitionLossPolicy plc
- ) {
- if (lostParts.contains(part)) {
- if (!read) {
- assert plc == READ_WRITE_ALL || plc == READ_WRITE_SAFE;
+ public enum OperationType {
+ /**
+ * Read operation.
+ */
+ READ,
+ /**
+ * Write operation.
+ */
+ WRITE
+ }
+
+ /**
+ * Lost policy validator.
+ */
+ public static class LostPolicyValidator {
+ /**
+ *
+ */
+ public static Throwable validate(
+ GridCacheContext cctx,
+ Object key,
+ OperationType opType,
+ Collection<Integer> lostParts
+ ) {
+ CacheGroupContext grp = cctx.group();
+
+ PartitionLossPolicy lostPlc = grp.config().getPartitionLossPolicy();
+
+ int partition = cctx.affinity().partition(key);
+
+ return validate(cctx, key, partition, opType, lostPlc, lostParts);
+ }
+
+ /**
+ *
+ */
+ public static Throwable validate(
+ GridCacheContext cctx,
+ Collection<?> keys,
+ OperationType opType,
+ Collection<Integer> lostParts
+ ) {
+ CacheGroupContext grp = cctx.group();
- if (plc == READ_WRITE_SAFE) {
+ PartitionLossPolicy lostPlc = grp.config().getPartitionLossPolicy();
+
+ for (Object key : keys) {
+ int partition = cctx.affinity().partition(key);
+
+ Throwable res = validate(cctx, key, partition, opType, lostPlc, lostParts);
+
+ if (res != null)
+ return res;
+ }
+
+ return null;
+ }
+
+ /**
+ *
+ */
+ private static Throwable validate(
+ GridCacheContext cctx,
+ Object key,
+ int partition,
+ OperationType opType,
+ PartitionLossPolicy lostPlc,
+ Collection<Integer> lostParts
+ ) {
+ if (opType == WRITE) {
+ if (lostPlc == READ_ONLY_SAFE || lostPlc == READ_ONLY_ALL) {
+ return new IgniteCheckedException(
+ "Failed to write to cache (cache is moved to a read-only state): " + cctx.name()
+ );
+ }
+
+ if (lostParts.contains(partition) && lostPlc == READ_WRITE_SAFE) {
return new CacheInvalidStateException("Failed to execute cache operation " +
"(all partition owners have left the grid, partition data has been lost) [" +
- "cacheName=" + cacheName + ", part=" + part + ", key=" + key + ']');
+ "cacheName=" + cctx.name() + ", part=" + partition + ", key=" + key + ']');
}
}
- else {
- // Read.
- if (plc == READ_ONLY_SAFE || plc == READ_WRITE_SAFE)
+
+ if (opType == OperationType.READ) {
+ if (lostParts.contains(partition) && (lostPlc == READ_ONLY_SAFE || lostPlc == READ_WRITE_SAFE))
return new CacheInvalidStateException("Failed to execute cache operation " +
"(all partition owners have left the grid, partition data has been lost) [" +
- "cacheName=" + cacheName + ", part=" + part + ", key=" + key + ']');
+ "cacheName=" + cctx.name() + ", part=" + partition + ", key=" + key + ']'
+ );
}
- }
-
- return null;
- }
-
- /**
- * Cache validation result.
- */
- protected static class CacheValidation {
- /** Topology validation result. */
- private boolean valid;
- /** Lost partitions on this topology version. */
- private Collection<Integer> lostParts;
-
- /**
- * @param valid Valid flag.
- * @param lostParts Lost partitions.
- */
- private CacheValidation(boolean valid, Collection<Integer> lostParts) {
- this.valid = valid;
- this.lostParts = lostParts;
+ return null;
}
}
-
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4760980/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 8725e05..2fcd677 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
@@ -483,7 +483,7 @@ public class GridPartitionedGetFuture<K, V> extends CacheDistributedGetFutureAda
}
}
- ClusterNode node = cctx.selectAffinityNodeBalanced(affNodes, canRemap);
+ ClusterNode node = cctx.selectAffinityNodeBalanced(affNodes, part, canRemap);
if (node == null) {
onDone(serverNotFoundError(part, topVer));
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4760980/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 ad716e6..4d0e129 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
@@ -367,7 +367,7 @@ public class GridPartitionedSingleGetFuture extends GridCacheFutureAdapter<Objec
}
}
- ClusterNode affNode = cctx.selectAffinityNodeBalanced(affNodes, canRemap);
+ ClusterNode affNode = cctx.selectAffinityNodeBalanced(affNodes, part, canRemap);
if (affNode == null) {
onDone(serverNotFoundError(part, topVer));
@@ -775,6 +775,13 @@ public class GridPartitionedSingleGetFuture extends GridCacheFutureAdapter<Objec
private void remap(final AffinityTopologyVersion topVer) {
cctx.closures().runLocalSafe(new Runnable() {
@Override public void run() {
+ GridDhtTopologyFuture lastFut = cctx.shared().exchange().lastFinishedFuture();
+
+ Throwable error = lastFut.validateCache(cctx, recovery, true, key, null);
+
+ if (error != null)
+ onDone(error);
+
map(topVer);
}
});
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4760980/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
index 3702a51..c8471c7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
@@ -2077,10 +2077,10 @@ public class GridDhtPartitionsExchangeFuture extends GridDhtTopologyFutureAdapte
}
}
- if (serverNodeDiscoveryEvent())
+ if (serverNodeDiscoveryEvent() || localJoinExchange())
detectLostPartitions(res);
- Map<Integer, CacheValidation> m = U.newHashMap(cctx.cache().cacheGroups().size());
+ Map<Integer, CacheGroupValidation> m = U.newHashMap(cctx.cache().cacheGroups().size());
for (CacheGroupContext grp : cctx.cache().cacheGroups())
m.put(grp.groupId(), validateCacheGroup(grp, events().lastEvent().topologyNodes()));
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4760980/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 0350e1a..54c3cae 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
@@ -494,7 +494,7 @@ public final class GridNearGetFuture<K, V> extends CacheDistributedGetFutureAdap
}
}
- ClusterNode affNode = cctx.selectAffinityNodeBalanced(affNodes, canRemap);
+ ClusterNode affNode = cctx.selectAffinityNodeBalanced(affNodes, part, canRemap);
if (affNode == null) {
onDone(serverNotFoundError(part, topVer));
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4760980/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheResultIsNotNullOnPartitionLossTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheResultIsNotNullOnPartitionLossTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheResultIsNotNullOnPartitionLossTest.java
index ceafc9e..0958f83 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheResultIsNotNullOnPartitionLossTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheResultIsNotNullOnPartitionLossTest.java
@@ -17,15 +17,21 @@
package org.apache.ignite.internal.processors.cache.distributed;
+import java.util.Collections;
+import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteClientDisconnectedException;
import org.apache.ignite.IgniteDataStreamer;
import org.apache.ignite.cache.CacheMode;
import org.apache.ignite.cache.CacheWriteSynchronizationMode;
import org.apache.ignite.cache.PartitionLossPolicy;
+import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.events.EventType;
@@ -48,13 +54,13 @@ public class CacheResultIsNotNullOnPartitionLossTest extends GridCommonAbstractT
private static final TcpDiscoveryVmIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
/** Number of servers to be started. */
- private static final int SERVERS = 10;
+ private static final int SERVERS = 5;
/** Index of node that is goning to be the only client node. */
private static final int CLIENT_IDX = SERVERS;
/** Number of cache entries to insert into the test cache. */
- private static final int CACHE_ENTRIES_CNT = 10_000;
+ private static final int CACHE_ENTRIES_CNT = 60;
/** True if {@link #getConfiguration(String)} is expected to configure client node on next invocations. */
private boolean isClient;
@@ -75,6 +81,7 @@ public class CacheResultIsNotNullOnPartitionLossTest extends GridCommonAbstractT
.setCacheMode(CacheMode.PARTITIONED)
.setBackups(0)
.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC)
+ .setAffinity(new RendezvousAffinityFunction(false, 50))
.setPartitionLossPolicy(PartitionLossPolicy.READ_WRITE_SAFE)
);
@@ -90,7 +97,12 @@ public class CacheResultIsNotNullOnPartitionLossTest extends GridCommonAbstractT
cleanPersistenceDir();
- startGrids(SERVERS);
+ List<Integer> list = IntStream.range(0, SERVERS).boxed().collect(Collectors.toList());
+
+ Collections.shuffle(list);
+
+ for (Integer i : list)
+ startGrid(i);
isClient = true;
@@ -178,9 +190,9 @@ public class CacheResultIsNotNullOnPartitionLossTest extends GridCommonAbstractT
readerThreadStarted.await(1, TimeUnit.SECONDS);
for (int i = 0; i < SERVERS - 1; i++) {
- Thread.sleep(50L);
-
grid(i).close();
+
+ Thread.sleep(400L);
}
}
finally {
@@ -204,6 +216,7 @@ public class CacheResultIsNotNullOnPartitionLossTest extends GridCommonAbstractT
private boolean expectedThrowableClass(Throwable throwable) {
return X.hasCause(
throwable,
+ IgniteClientDisconnectedException.class,
CacheInvalidStateException.class,
ClusterTopologyCheckedException.class,
IllegalStateException.class,
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4760980/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCachePartitionLossPolicySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCachePartitionLossPolicySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCachePartitionLossPolicySelfTest.java
index caf0829..f02563d 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCachePartitionLossPolicySelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCachePartitionLossPolicySelfTest.java
@@ -18,14 +18,11 @@
package org.apache.ignite.internal.processors.cache.distributed;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Semaphore;
@@ -39,8 +36,6 @@ import org.apache.ignite.cache.affinity.Affinity;
import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
import org.apache.ignite.cache.query.ScanQuery;
import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.configuration.DataRegionConfiguration;
-import org.apache.ignite.configuration.DataStorageConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.events.CacheRebalancingEvent;
import org.apache.ignite.events.Event;
@@ -48,7 +43,7 @@ import org.apache.ignite.events.EventType;
import org.apache.ignite.internal.IgniteEx;
import org.apache.ignite.internal.TestDelayingCommunicationSpi;
import org.apache.ignite.internal.managers.communication.GridIoMessage;
-import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
+import org.apache.ignite.internal.processors.cache.CacheGroupContext;
import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsAbstractMessage;
import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsFullMessage;
import org.apache.ignite.internal.util.typedef.F;
@@ -58,18 +53,19 @@ import org.apache.ignite.plugin.extensions.communication.Message;
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 java.util.Arrays.asList;
import static org.apache.ignite.cache.CacheMode.PARTITIONED;
import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
+import static org.apache.ignite.internal.processors.cache.GridCacheUtils.cacheId;
/**
*
*/
public class IgniteCachePartitionLossPolicySelfTest extends GridCommonAbstractTest {
/** */
- private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
+ private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
/** */
private boolean client;
@@ -78,43 +74,36 @@ public class IgniteCachePartitionLossPolicySelfTest extends GridCommonAbstractTe
private PartitionLossPolicy partLossPlc;
/** */
- protected static final String CACHE_NAME = "partitioned";
+ private int backups;
/** */
- private int backups = 0;
+ private final AtomicBoolean delayPartExchange = new AtomicBoolean();
/** */
- private final AtomicBoolean delayPartExchange = new AtomicBoolean(false);
-
- /** */
- private final TopologyChanger killSingleNode = new TopologyChanger(false, Collections.singletonList(3), Arrays.asList(0, 1, 2, 4), 0);
-
- /** */
- private boolean isPersistenceEnabled;
+ private final TopologyChanger killSingleNode = new TopologyChanger(
+ false, asList(3), asList(0, 1, 2, 4), 0
+ );
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(gridName);
- ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder);
+ cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(IP_FINDER));
cfg.setCommunicationSpi(new TestDelayingCommunicationSpi() {
+ /** {@inheritDoc} */
@Override protected boolean delayMessage(Message msg, GridIoMessage ioMsg) {
- return delayPartExchange.get() && (msg instanceof GridDhtPartitionsFullMessage || msg instanceof GridDhtPartitionsAbstractMessage);
+ return delayPartExchange.get() &&
+ (msg instanceof GridDhtPartitionsFullMessage || msg instanceof GridDhtPartitionsAbstractMessage);
}
- @Override protected int delayMillis() {
- return 250;
- }
});
cfg.setClientMode(client);
- cfg.setCacheConfiguration(cacheConfiguration());
+ cfg.setConsistentId(gridName);
- cfg.setDataStorageConfiguration(new DataStorageConfiguration().setDefaultDataRegionConfiguration(
- new DataRegionConfiguration().setPersistenceEnabled(isPersistenceEnabled)
- ));
+ cfg.setCacheConfiguration(cacheConfiguration());
return cfg;
}
@@ -123,7 +112,7 @@ public class IgniteCachePartitionLossPolicySelfTest extends GridCommonAbstractTe
* @return Cache configuration.
*/
protected CacheConfiguration<Integer, Integer> cacheConfiguration() {
- CacheConfiguration<Integer, Integer> cacheCfg = new CacheConfiguration<>(CACHE_NAME);
+ CacheConfiguration<Integer, Integer> cacheCfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME);
cacheCfg.setCacheMode(PARTITIONED);
cacheCfg.setBackups(backups);
@@ -135,44 +124,27 @@ public class IgniteCachePartitionLossPolicySelfTest extends GridCommonAbstractTe
}
/** {@inheritDoc} */
- @Override protected void beforeTest() throws Exception {
- super.beforeTest();
-
- delayPartExchange.set(false);
-
- partLossPlc = PartitionLossPolicy.IGNORE;
-
- backups = 0;
-
- isPersistenceEnabled = false;
+ @Override protected void afterTest() throws Exception {
+ stopAllGrids();
}
/** {@inheritDoc} */
- @Override protected void afterTest() throws Exception {
- stopAllGrids();
+ @Override protected void beforeTest() throws Exception {
+ super.beforeTest();
cleanPersistenceDir();
- super.afterTest();
- }
-
- /**
- * @throws Exception if failed.
- */
- public void testReadOnlySafe() throws Exception {
- partLossPlc = PartitionLossPolicy.READ_ONLY_SAFE;
+ delayPartExchange.set(false);
- checkLostPartition(false, true, killSingleNode);
+ backups = 0;
}
/**
* @throws Exception if failed.
*/
- public void testReadOnlySafeWithPersistence() throws Exception {
+ public void testReadOnlySafe() throws Exception {
partLossPlc = PartitionLossPolicy.READ_ONLY_SAFE;
- isPersistenceEnabled = true;
-
checkLostPartition(false, true, killSingleNode);
}
@@ -188,19 +160,6 @@ public class IgniteCachePartitionLossPolicySelfTest extends GridCommonAbstractTe
/**
* @throws Exception if failed.
*/
- public void testReadOnlyAllWithPersistence() throws Exception {
- fail("https://issues.apache.org/jira/browse/IGNITE-10041");
-
- partLossPlc = PartitionLossPolicy.READ_ONLY_ALL;
-
- isPersistenceEnabled = true;
-
- checkLostPartition(false, false, killSingleNode);
- }
-
- /**
- * @throws Exception if failed.
- */
public void testReadWriteSafe() throws Exception {
partLossPlc = PartitionLossPolicy.READ_WRITE_SAFE;
@@ -210,17 +169,6 @@ public class IgniteCachePartitionLossPolicySelfTest extends GridCommonAbstractTe
/**
* @throws Exception if failed.
*/
- public void testReadWriteSafeWithPersistence() throws Exception {
- partLossPlc = PartitionLossPolicy.READ_WRITE_SAFE;
-
- isPersistenceEnabled = true;
-
- checkLostPartition(true, true, killSingleNode);
- }
-
- /**
- * @throws Exception if failed.
- */
public void testReadWriteAll() throws Exception {
partLossPlc = PartitionLossPolicy.READ_WRITE_ALL;
@@ -230,34 +178,10 @@ public class IgniteCachePartitionLossPolicySelfTest extends GridCommonAbstractTe
/**
* @throws Exception if failed.
*/
- public void testReadWriteAllWithPersistence() throws Exception {
- fail("https://issues.apache.org/jira/browse/IGNITE-10041");
-
- partLossPlc = PartitionLossPolicy.READ_WRITE_ALL;
-
- isPersistenceEnabled = true;
-
- checkLostPartition(true, false, killSingleNode);
- }
-
- /**
- * @throws Exception if failed.
- */
public void testReadWriteSafeAfterKillTwoNodes() throws Exception {
partLossPlc = PartitionLossPolicy.READ_WRITE_SAFE;
- checkLostPartition(true, true, new TopologyChanger(false, Arrays.asList(3, 2), Arrays.asList(0, 1, 4), 0));
- }
-
- /**
- * @throws Exception if failed.
- */
- public void testReadWriteSafeAfterKillTwoNodesWithPersistence() throws Exception {
- partLossPlc = PartitionLossPolicy.READ_WRITE_SAFE;
-
- isPersistenceEnabled = true;
-
- checkLostPartition(true, true, new TopologyChanger(false, Arrays.asList(3, 2), Arrays.asList(0, 1, 4), 0));
+ checkLostPartition(true, true, new TopologyChanger(false, asList(3, 2), asList(0, 1, 4), 0));
}
/**
@@ -266,18 +190,7 @@ public class IgniteCachePartitionLossPolicySelfTest extends GridCommonAbstractTe
public void testReadWriteSafeAfterKillTwoNodesWithDelay() throws Exception {
partLossPlc = PartitionLossPolicy.READ_WRITE_SAFE;
- checkLostPartition(true, true, new TopologyChanger(false, Arrays.asList(3, 2), Arrays.asList(0, 1, 4), 20));
- }
-
- /**
- * @throws Exception if failed.
- */
- public void testReadWriteSafeAfterKillTwoNodesWithDelayWithPersistence() throws Exception {
- partLossPlc = PartitionLossPolicy.READ_WRITE_SAFE;
-
- isPersistenceEnabled = true;
-
- checkLostPartition(true, true, new TopologyChanger(false, Arrays.asList(3, 2), Arrays.asList(0, 1, 4), 20));
+ checkLostPartition(true, true, new TopologyChanger(false, asList(3, 2), asList(0, 1, 4), 20));
}
/**
@@ -288,22 +201,7 @@ public class IgniteCachePartitionLossPolicySelfTest extends GridCommonAbstractTe
backups = 1;
- checkLostPartition(true, true, new TopologyChanger(true, Arrays.asList(3, 2, 1), Arrays.asList(0, 4), 0));
- }
-
- /**
- * @throws Exception if failed.
- */
- public void testReadWriteSafeWithBackupsAfterKillThreeNodesWithPersistence() throws Exception {
- fail("https://issues.apache.org/jira/browse/IGNITE-10043");
-
- partLossPlc = PartitionLossPolicy.READ_WRITE_SAFE;
-
- backups = 1;
-
- isPersistenceEnabled = true;
-
- checkLostPartition(true, true, new TopologyChanger(true, Arrays.asList(3, 2, 1), Arrays.asList(0, 4), 0));
+ checkLostPartition(true, true, new TopologyChanger(true, asList(3, 2, 1), asList(0, 4), 0));
}
/**
@@ -312,18 +210,7 @@ public class IgniteCachePartitionLossPolicySelfTest extends GridCommonAbstractTe
public void testReadWriteSafeAfterKillCrd() throws Exception {
partLossPlc = PartitionLossPolicy.READ_WRITE_SAFE;
- checkLostPartition(true, true, new TopologyChanger(true, Arrays.asList(3, 0), Arrays.asList(1, 2, 4), 0));
- }
-
- /**
- * @throws Exception if failed.
- */
- public void testReadWriteSafeAfterKillCrdWithPersistence() throws Exception {
- partLossPlc = PartitionLossPolicy.READ_WRITE_SAFE;
-
- isPersistenceEnabled = true;
-
- checkLostPartition(true, true, new TopologyChanger(true, Arrays.asList(3, 0), Arrays.asList(1, 2, 4), 0));
+ checkLostPartition(true, true, new TopologyChanger(true, asList(3, 0), asList(1, 2, 4), 0));
}
/**
@@ -334,20 +221,7 @@ public class IgniteCachePartitionLossPolicySelfTest extends GridCommonAbstractTe
backups = 1;
- checkLostPartition(true, true, new TopologyChanger(true, Arrays.asList(3, 2), Arrays.asList(0, 1, 4), 0));
- }
-
- /**
- * @throws Exception if failed.
- */
- public void testReadWriteSafeWithBackupsWithPersistence() throws Exception {
- partLossPlc = PartitionLossPolicy.READ_WRITE_SAFE;
-
- backups = 1;
-
- isPersistenceEnabled = true;
-
- checkLostPartition(true, true, new TopologyChanger(true, Arrays.asList(3, 2), Arrays.asList(0, 1, 4), 0));
+ checkLostPartition(true, true, new TopologyChanger(true, asList(3, 2), asList(0, 1, 4), 0));
}
/**
@@ -358,95 +232,26 @@ public class IgniteCachePartitionLossPolicySelfTest extends GridCommonAbstractTe
backups = 1;
- checkLostPartition(true, true, new TopologyChanger(true, Arrays.asList(3, 0), Arrays.asList(1, 2, 4), 0));
- }
-
- /**
- * @throws Exception if failed.
- */
- public void testReadWriteSafeWithBackupsAfterKillCrdWithPersistence() throws Exception {
- partLossPlc = PartitionLossPolicy.READ_WRITE_SAFE;
-
- backups = 1;
-
- isPersistenceEnabled = true;
-
- checkLostPartition(true, true, new TopologyChanger(true, Arrays.asList(3, 0), Arrays.asList(1, 2, 4), 0));
- }
-
- /**
- * @throws Exception if failed.
- */
- public void testIgnore() throws Exception {
- fail("https://issues.apache.org/jira/browse/IGNITE-5078");
-
- partLossPlc = PartitionLossPolicy.IGNORE;
-
- checkIgnore(killSingleNode);
+ checkLostPartition(true, true, new TopologyChanger(true, asList(3, 0), asList(1, 2, 4), 0));
}
/**
+ * @param topChanger topology changer.
* @throws Exception if failed.
*/
- public void testIgnoreWithPersistence() throws Exception {
+ public void testIgnore(TopologyChanger topChanger) throws Exception {
fail("https://issues.apache.org/jira/browse/IGNITE-5078");
- fail("https://issues.apache.org/jira/browse/IGNITE-10041");
-
- partLossPlc = PartitionLossPolicy.IGNORE;
-
- isPersistenceEnabled = true;
-
- checkIgnore(killSingleNode);
- }
-
- /**
- * @throws Exception if failed.
- */
- public void testIgnoreKillThreeNodes() throws Exception {
- partLossPlc = PartitionLossPolicy.IGNORE;
-
- // TODO aliveNodes should include node 4, but it fails due to https://issues.apache.org/jira/browse/IGNITE-5078.
- // TODO need to add 4 to the aliveNodes after IGNITE-5078 is fixed.
- // TopologyChanger onlyCrdIsAlive = new TopologyChanger(false, Arrays.asList(1, 2, 3), Arrays.asList(0, 4), 0);
- TopologyChanger onlyCrdIsAlive = new TopologyChanger(false, Arrays.asList(1, 2, 3), Collections.singletonList(0), 0);
-
- checkIgnore(onlyCrdIsAlive);
- }
-
- /**
- * @throws Exception if failed.
- */
- public void testIgnoreKillThreeNodesWithPersistence() throws Exception {
- fail("https://issues.apache.org/jira/browse/IGNITE-10041");
-
- partLossPlc = PartitionLossPolicy.IGNORE;
-
- isPersistenceEnabled = true;
-
- // TODO aliveNodes should include node 4, but it fails due to https://issues.apache.org/jira/browse/IGNITE-5078.
- // TODO need to add 4 to the aliveNodes after IGNITE-5078 is fixed.
- // TopologyChanger onlyCrdIsAlive = new TopologyChanger(false, Arrays.asList(1, 2, 3), Arrays.asList(0, 4), 0);
- TopologyChanger onlyCrdIsAlive = new TopologyChanger(false, Arrays.asList(1, 2, 3), Collections.singletonList(0), 0);
-
- checkIgnore(onlyCrdIsAlive);
- }
-
- /**
- * @param topChanger topology changer.
- * @throws Exception if failed.
- */
- private void checkIgnore(TopologyChanger topChanger) throws Exception {
topChanger.changeTopology();
for (Ignite ig : G.allGrids()) {
- IgniteCache<Integer, Integer> cache = ig.cache(CACHE_NAME);
+ IgniteCache<Integer, Integer> cache = ig.cache(DEFAULT_CACHE_NAME);
Collection<Integer> lost = cache.lostPartitions();
assertTrue("[grid=" + ig.name() + ", lost=" + lost.toString() + ']', lost.isEmpty());
- int parts = ig.affinity(CACHE_NAME).partitions();
+ int parts = ig.affinity(DEFAULT_CACHE_NAME).partitions();
for (int i = 0; i < parts; i++) {
cache.get(i);
@@ -465,127 +270,109 @@ public class IgniteCachePartitionLossPolicySelfTest extends GridCommonAbstractTe
private void checkLostPartition(boolean canWrite, boolean safe, TopologyChanger topChanger) throws Exception {
assert partLossPlc != null;
- List<Integer> lostParts = topChanger.changeTopology();
-
- // Wait for all grids (servers and client) have same topology version
- // to make sure that all nodes received map with lost partition.
- boolean success = GridTestUtils.waitForCondition(() -> {
- AffinityTopologyVersion last = null;
- for (Ignite ig : G.allGrids()) {
- AffinityTopologyVersion ver = ((IgniteEx)ig).context().cache().context().exchange().readyAffinityVersion();
-
- if (last != null && !last.equals(ver))
- return false;
-
- last = ver;
- }
-
- return true;
- }, 10000);
-
- assertTrue("Failed to wait for new topology", success);
+ int part = topChanger.changeTopology().get(0);
for (Ignite ig : G.allGrids()) {
info("Checking node: " + ig.cluster().localNode().id());
- IgniteCache<Integer, Integer> cache = ig.cache(CACHE_NAME);
+ IgniteCache<Integer, Integer> cache = ig.cache(DEFAULT_CACHE_NAME);
- verifyLostPartitions(ig, lostParts);
-
- verifyCacheOps(canWrite, safe, ig);
-
- validateQuery(safe, ig);
+ verifyCacheOps(canWrite, safe, part, ig);
- // TODO withPartitionRecover doesn't work with BLT - https://issues.apache.org/jira/browse/IGNITE-10041.
- if (!isPersistenceEnabled) {
- // Check we can read and write to lost partition in recovery mode.
- IgniteCache<Integer, Integer> recoverCache = cache.withPartitionRecover();
+ // Check we can read and write to lost partition in recovery mode.
+ IgniteCache<Integer, Integer> recoverCache = cache.withPartitionRecover();
- for (int lostPart : recoverCache.lostPartitions()) {
- recoverCache.get(lostPart);
- recoverCache.put(lostPart, lostPart);
- }
-
- // Check that writing in recover mode does not clear partition state.
- verifyLostPartitions(ig, lostParts);
+ for (int lostPart : recoverCache.lostPartitions()) {
+ recoverCache.get(lostPart);
+ recoverCache.put(lostPart, lostPart);
+ }
- verifyCacheOps(canWrite, safe, ig);
+ // Check that writing in recover mode does not clear partition state.
+ verifyCacheOps(canWrite, safe, part, ig);
- validateQuery(safe, ig);
- }
+ // Validate queries.
+ validateQuery(safe, ig);
}
- // Bring all nodes back.
- for (int i : topChanger.killNodes) {
- IgniteEx grd = startGrid(i);
+ checkNewNode(true, canWrite, safe, part);
+ checkNewNode(false, canWrite, safe, part);
- info("Newly started node: " + grd.cluster().localNode().id());
+ // Check that partition state does not change after we start a new node.
+ IgniteEx grd = startGrid(3);
- // Check that partition state does not change after we start each node.
- // TODO With persistence enabled LOST partitions become OWNING after a node joins back - https://issues.apache.org/jira/browse/IGNITE-10044.
- if (!isPersistenceEnabled) {
- for (Ignite ig : G.allGrids()) {
- verifyCacheOps(canWrite, safe, ig);
+ info("Newly started node: " + grd.cluster().localNode().id());
- // TODO Query effectively waits for rebalance due to https://issues.apache.org/jira/browse/IGNITE-10057
- // TODO and after resetLostPartition there is another OWNING copy in the cluster due to https://issues.apache.org/jira/browse/IGNITE-10058.
- // TODO Uncomment after https://issues.apache.org/jira/browse/IGNITE-10058 is fixed.
-// validateQuery(safe, ig);
- }
- }
- }
+ for (Ignite ig : G.allGrids())
+ verifyCacheOps(canWrite, safe, part, ig);
- ignite(4).resetLostPartitions(Collections.singletonList(CACHE_NAME));
+ ignite(4).resetLostPartitions(Collections.singletonList(DEFAULT_CACHE_NAME));
awaitPartitionMapExchange(true, true, null);
for (Ignite ig : G.allGrids()) {
- IgniteCache<Integer, Integer> cache = ig.cache(CACHE_NAME);
+ IgniteCache<Integer, Integer> cache = ig.cache(DEFAULT_CACHE_NAME);
assertTrue(cache.lostPartitions().isEmpty());
- int parts = ig.affinity(CACHE_NAME).partitions();
+ int parts = ig.affinity(DEFAULT_CACHE_NAME).partitions();
for (int i = 0; i < parts; i++) {
cache.get(i);
cache.put(i, i);
}
-
- for (int i = 0; i < parts; i++) {
- checkQueryPasses(ig, false, i);
-
- if (shouldExecuteLocalQuery(ig, i))
- checkQueryPasses(ig, true, i);
-
- }
-
- checkQueryPasses(ig, false);
}
}
/**
- * @param node Node.
- * @param lostParts Lost partition IDs.
+ * @param client Client flag.
+ * @param canWrite Can write flag.
+ * @param safe Safe flag.
+ * @param part List of lost partitions.
+ * @throws Exception If failed to start a new node.
*/
- private void verifyLostPartitions(Ignite node, List<Integer> lostParts) {
- IgniteCache<Integer, Integer> cache = node.cache(CACHE_NAME);
+ private void checkNewNode(
+ boolean client,
+ boolean canWrite,
+ boolean safe,
+ int part
+ ) throws Exception {
+ this.client = client;
+
+ try {
+ IgniteEx cl = startGrid("newNode");
+
+ CacheGroupContext grpCtx = cl.context().cache().cacheGroup(cacheId(DEFAULT_CACHE_NAME));
+
+ assertTrue(grpCtx.needsRecovery());
- Set<Integer> actualSortedLostParts = new TreeSet<>(cache.lostPartitions());
- Set<Integer> expSortedLostParts = new TreeSet<>(lostParts);
+ verifyCacheOps(canWrite, safe, part, cl);
- assertEqualsCollections(expSortedLostParts, actualSortedLostParts);
+ validateQuery(safe, cl);
+ }
+ finally {
+ stopGrid("newNode", false);
+
+ this.client = false;
+ }
}
/**
+ *
* @param canWrite {@code True} if writes are allowed.
* @param safe {@code True} if lost partition should trigger exception.
+ * @param part Lost partition ID.
* @param ig Ignite instance.
*/
- private void verifyCacheOps(boolean canWrite, boolean safe, Ignite ig) {
- IgniteCache<Integer, Integer> cache = ig.cache(CACHE_NAME);
+ private void verifyCacheOps(boolean canWrite, boolean safe, int part, Ignite ig) {
+ IgniteCache<Integer, Integer> cache = ig.cache(DEFAULT_CACHE_NAME);
- int parts = ig.affinity(CACHE_NAME).partitions();
+ Collection<Integer> lost = cache.lostPartitions();
+
+ assertTrue("Failed to find expected lost partition [exp=" + part + ", lost=" + lost + ']',
+ lost.contains(part));
+
+ int parts = ig.affinity(DEFAULT_CACHE_NAME).partitions();
// Check read.
for (int i = 0; i < parts; i++) {
@@ -632,8 +419,8 @@ public class IgniteCachePartitionLossPolicySelfTest extends GridCommonAbstractTe
* @param nodes List of nodes to find partition.
* @return List of partitions that aren't primary or backup for specified nodes.
*/
- private List<Integer> noPrimaryOrBackupPartition(List<Integer> nodes) {
- Affinity<Object> aff = ignite(4).affinity(CACHE_NAME);
+ protected List<Integer> noPrimaryOrBackupPartition(List<Integer> nodes) {
+ Affinity<Object> aff = ignite(4).affinity(DEFAULT_CACHE_NAME);
List<Integer> parts = new ArrayList<>();
@@ -657,6 +444,127 @@ public class IgniteCachePartitionLossPolicySelfTest extends GridCommonAbstractTe
return parts;
}
+ /** */
+ private class TopologyChanger {
+ /** Flag to delay partition exchange */
+ private boolean delayExchange;
+
+ /** List of nodes to kill */
+ private List<Integer> killNodes;
+
+ /** List of nodes to be alive */
+ private List<Integer> aliveNodes;
+
+ /** Delay between node stops */
+ private long stopDelay;
+
+ /**
+ * @param delayExchange Flag for delay partition exchange.
+ * @param killNodes List of nodes to kill.
+ * @param aliveNodes List of nodes to be alive.
+ * @param stopDelay Delay between stopping nodes.
+ */
+ public TopologyChanger(
+ boolean delayExchange,
+ List<Integer> killNodes,
+ List<Integer> aliveNodes,
+ long stopDelay
+ ) {
+ this.delayExchange = delayExchange;
+ this.killNodes = killNodes;
+ this.aliveNodes = aliveNodes;
+ this.stopDelay = stopDelay;
+ }
+
+ /**
+ * @return Lost partition ID.
+ * @throws Exception If failed.
+ */
+ protected List<Integer> changeTopology() throws Exception {
+ startGrids(4);
+
+ Affinity<Object> aff = ignite(0).affinity(DEFAULT_CACHE_NAME);
+
+ for (int i = 0; i < aff.partitions(); i++)
+ ignite(0).cache(DEFAULT_CACHE_NAME).put(i, i);
+
+ client = true;
+
+ startGrid(4);
+
+ client = false;
+
+ for (int i = 0; i < 5; i++)
+ info(">>> Node [idx=" + i + ", nodeId=" + ignite(i).cluster().localNode().id() + ']');
+
+ awaitPartitionMapExchange();
+
+ final List<Integer> parts = noPrimaryOrBackupPartition(aliveNodes);
+
+ if (parts.isEmpty())
+ throw new IllegalStateException("No partition on nodes: " + killNodes);
+
+ final List<Map<Integer, Semaphore>> lostMap = new ArrayList<>();
+
+ for (int i : aliveNodes) {
+ HashMap<Integer, Semaphore> semaphoreMap = new HashMap<>();
+
+ for (Integer part : parts)
+ semaphoreMap.put(part, new Semaphore(0));
+
+ lostMap.add(semaphoreMap);
+
+ grid(i).events().localListen(new P1<Event>() {
+ @Override public boolean apply(Event evt) {
+ assert evt.type() == EventType.EVT_CACHE_REBALANCE_PART_DATA_LOST;
+
+ CacheRebalancingEvent cacheEvt = (CacheRebalancingEvent)evt;
+
+ if (F.eq(DEFAULT_CACHE_NAME, cacheEvt.cacheName())) {
+ if (semaphoreMap.containsKey(cacheEvt.partition()))
+ semaphoreMap.get(cacheEvt.partition()).release();
+ }
+
+ return true;
+ }
+ }, EventType.EVT_CACHE_REBALANCE_PART_DATA_LOST);
+ }
+
+ if (delayExchange)
+ delayPartExchange.set(true);
+
+ ExecutorService executor = Executors.newFixedThreadPool(killNodes.size());
+
+ for (Integer node : killNodes) {
+ executor.submit(new Runnable() {
+ @Override public void run() {
+ grid(node).close();
+ }
+ });
+
+ Thread.sleep(stopDelay);
+ }
+
+ executor.shutdown();
+
+ delayPartExchange.set(false);
+
+ Thread.sleep(5_000L);
+
+ for (Map<Integer, Semaphore> map : lostMap) {
+ for (Map.Entry<Integer, Semaphore> entry : map.entrySet())
+ assertTrue("Failed to wait for partition LOST event for partition:" + entry.getKey(), entry.getValue().tryAcquire(1));
+ }
+
+ for (Map<Integer, Semaphore> map : lostMap) {
+ for (Map.Entry<Integer, Semaphore> entry : map.entrySet())
+ assertFalse("Partition LOST event raised twice for partition:" + entry.getKey(), entry.getValue().tryAcquire(1));
+ }
+
+ return parts;
+ }
+ }
+
/**
* Validate query execution on a node.
*
@@ -665,7 +573,7 @@ public class IgniteCachePartitionLossPolicySelfTest extends GridCommonAbstractTe
*/
private void validateQuery(boolean safe, Ignite node) {
// Get node lost and remaining partitions.
- IgniteCache<?, ?> cache = node.cache(CACHE_NAME);
+ IgniteCache<?, ?> cache = node.cache(DEFAULT_CACHE_NAME);
Collection<Integer> lostParts = cache.lostPartitions();
@@ -673,7 +581,7 @@ public class IgniteCachePartitionLossPolicySelfTest extends GridCommonAbstractTe
Integer remainingPart = null;
- for (int i = 0; i < node.affinity(CACHE_NAME).partitions(); i++) {
+ for (int i = 0; i < node.affinity(DEFAULT_CACHE_NAME).partitions(); i++) {
if (lostParts.contains(i))
continue;
@@ -730,7 +638,7 @@ public class IgniteCachePartitionLossPolicySelfTest extends GridCommonAbstractTe
int numOfPrimaryParts = 0;
- for (int nodePrimaryPart : node.affinity(CACHE_NAME).primaryPartitions(node.cluster().localNode())) {
+ for (int nodePrimaryPart : node.affinity(DEFAULT_CACHE_NAME).primaryPartitions(node.cluster().localNode())) {
for (int part : parts) {
if (part == nodePrimaryPart)
numOfPrimaryParts++;
@@ -754,7 +662,7 @@ public class IgniteCachePartitionLossPolicySelfTest extends GridCommonAbstractTe
if (loc)
return;
- IgniteCache cache = node.cache(CACHE_NAME);
+ IgniteCache cache = node.cache(DEFAULT_CACHE_NAME);
ScanQuery qry = new ScanQuery();
@@ -777,124 +685,4 @@ public class IgniteCachePartitionLossPolicySelfTest extends GridCommonAbstractTe
// TODO Need to add an actual check after https://issues.apache.org/jira/browse/IGNITE-9902 is fixed.
// No-op.
}
-
- /** */
- private class TopologyChanger {
- /** Flag to delay partition exchange */
- private boolean delayExchange;
-
- /** List of nodes to kill */
- private List<Integer> killNodes;
-
- /** List of nodes to be alive */
- private List<Integer> aliveNodes;
-
- /** Delay between node stops */
- private long stopDelay;
-
- /**
- * @param delayExchange Flag for delay partition exchange.
- * @param killNodes List of nodes to kill.
- * @param aliveNodes List of nodes to be alive.
- * @param stopDelay Delay between stopping nodes.
- */
- private TopologyChanger(boolean delayExchange, List<Integer> killNodes, List<Integer> aliveNodes,
- long stopDelay) {
- this.delayExchange = delayExchange;
- this.killNodes = killNodes;
- this.aliveNodes = aliveNodes;
- this.stopDelay = stopDelay;
- }
-
- /**
- * @return Lost partition ID.
- * @throws Exception If failed.
- */
- private List<Integer> changeTopology() throws Exception {
- startGrids(4);
-
- if (isPersistenceEnabled)
- grid(0).cluster().active(true);
-
- Affinity<Object> aff = ignite(0).affinity(CACHE_NAME);
-
- for (int i = 0; i < aff.partitions(); i++)
- ignite(0).cache(CACHE_NAME).put(i, i);
-
- client = true;
-
- startGrid(4);
-
- client = false;
-
- for (int i = 0; i < 5; i++)
- info(">>> Node [idx=" + i + ", nodeId=" + ignite(i).cluster().localNode().id() + ']');
-
- awaitPartitionMapExchange();
-
- final List<Integer> parts = noPrimaryOrBackupPartition(aliveNodes);
-
- if (parts.isEmpty())
- throw new IllegalStateException("No partition on nodes: " + killNodes);
-
- final List<Map<Integer, Semaphore>> lostMap = new ArrayList<>();
-
- for (int i : aliveNodes) {
- HashMap<Integer, Semaphore> semaphoreMap = new HashMap<>();
-
- for (Integer part : parts)
- semaphoreMap.put(part, new Semaphore(0));
-
- lostMap.add(semaphoreMap);
-
- grid(i).events().localListen(new P1<Event>() {
- @Override public boolean apply(Event evt) {
- assert evt.type() == EventType.EVT_CACHE_REBALANCE_PART_DATA_LOST;
-
- CacheRebalancingEvent cacheEvt = (CacheRebalancingEvent)evt;
-
- if (F.eq(CACHE_NAME, cacheEvt.cacheName())) {
- if (semaphoreMap.containsKey(cacheEvt.partition()))
- semaphoreMap.get(cacheEvt.partition()).release();
- }
-
- return true;
- }
- }, EventType.EVT_CACHE_REBALANCE_PART_DATA_LOST);
- }
-
- if (delayExchange)
- delayPartExchange.set(true);
-
- ExecutorService executor = Executors.newFixedThreadPool(killNodes.size());
-
- for (Integer node : killNodes) {
- executor.submit(new Runnable() {
- @Override public void run() {
- grid(node).close();
- }
- });
-
- Thread.sleep(stopDelay);
- }
-
- executor.shutdown();
-
- delayPartExchange.set(false);
-
- Thread.sleep(5_000L);
-
- for (Map<Integer, Semaphore> map : lostMap) {
- for (Map.Entry<Integer, Semaphore> entry : map.entrySet())
- assertTrue("Failed to wait for partition LOST event for partition:" + entry.getKey(), entry.getValue().tryAcquire(1));
- }
-
- for (Map<Integer, Semaphore> map : lostMap) {
- for (Map.Entry<Integer, Semaphore> entry : map.entrySet())
- assertFalse("Partition LOST event raised twice for partition:" + entry.getKey(), entry.getValue().tryAcquire(1));
- }
-
- return parts;
- }
- }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4760980/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IndexingCachePartitionLossPolicySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IndexingCachePartitionLossPolicySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IndexingCachePartitionLossPolicySelfTest.java
index a31a1c6..7007499 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IndexingCachePartitionLossPolicySelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IndexingCachePartitionLossPolicySelfTest.java
@@ -69,7 +69,7 @@ public class IndexingCachePartitionLossPolicySelfTest extends IgniteCachePartiti
* @param loc Local flag.
*/
private static void executeQuery(Ignite node, boolean loc, int... parts) {
- IgniteCache cache = node.cache(CACHE_NAME);
+ IgniteCache cache = node.cache(DEFAULT_CACHE_NAME);
SqlFieldsQuery qry = new SqlFieldsQuery("SELECT * FROM Integer");
[02/13] ignite git commit: IGNITE-10246 StandaloneWALRecordIterator
must throw checkBounds exception - Fixes #5398.
Posted by sb...@apache.org.
IGNITE-10246 StandaloneWALRecordIterator must throw checkBounds exception - Fixes #5398.
Signed-off-by: Ivan Rakov <ir...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/43ebe7a5
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/43ebe7a5
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/43ebe7a5
Branch: refs/heads/ignite-10043
Commit: 43ebe7a5b3a4a19a1ef842b6d80417a4fc3580a0
Parents: a74d9c4
Author: Alexey Stelmak <sp...@gmail.com>
Authored: Thu Nov 15 16:33:07 2018 +0300
Committer: Ivan Rakov <ir...@apache.org>
Committed: Thu Nov 15 16:33:07 2018 +0300
----------------------------------------------------------------------
.../wal/reader/IgniteWalIteratorFactory.java | 3 ++-
.../wal/reader/StandaloneWalRecordsIterator.java | 6 +++---
.../wal/reader/StrictBoundsCheckException.java | 18 ++++++++++++++++++
3 files changed, 23 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/43ebe7a5/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/IgniteWalIteratorFactory.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/IgniteWalIteratorFactory.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/IgniteWalIteratorFactory.java
index f4ebec5..697dded 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/IgniteWalIteratorFactory.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/IgniteWalIteratorFactory.java
@@ -564,7 +564,8 @@ public class IgniteWalIteratorFactory {
.marshallerMappingFileStoreDir(marshallerMappingFileStoreDir)
.from(lowBound)
.to(highBound)
- .filter(filter);
+ .filter(filter)
+ .strictBoundsCheck(strictBoundsCheck);
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/43ebe7a5/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneWalRecordsIterator.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneWalRecordsIterator.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneWalRecordsIterator.java
index e6191dd..21275d8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneWalRecordsIterator.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneWalRecordsIterator.java
@@ -177,7 +177,7 @@ class StandaloneWalRecordsIterator extends AbstractWalRecordsIterator {
}
if (idx == walFiles.size())
- throw new IgniteCheckedException("Wal segments not in bounds. loBoundIndex=" + lowBound.index() +
+ throw new StrictBoundsCheckException("Wal segments not in bounds. loBoundIndex=" + lowBound.index() +
", indexes=" + printIndexes(walFiles));
long curWalSegmIdx = walFiles.get(idx).idx();
@@ -188,11 +188,11 @@ class StandaloneWalRecordsIterator extends AbstractWalRecordsIterator {
assert desc != null;
if (curWalSegmIdx != desc.idx())
- throw new IgniteCheckedException("Wal segment " + curWalSegmIdx + " not found in files " + printIndexes(walFiles));
+ throw new StrictBoundsCheckException("Wal segment " + curWalSegmIdx + " not found in files " + printIndexes(walFiles));
}
if (highBound.index() < Long.MAX_VALUE && curWalSegmIdx <= highBound.index())
- throw new IgniteCheckedException("Wal segments not in bounds. hiBoundIndex=" + highBound.index() +
+ throw new StrictBoundsCheckException("Wal segments not in bounds. hiBoundIndex=" + highBound.index() +
", indexes=" + printIndexes(walFiles));
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/43ebe7a5/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StrictBoundsCheckException.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StrictBoundsCheckException.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StrictBoundsCheckException.java
new file mode 100644
index 0000000..4a52e08
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StrictBoundsCheckException.java
@@ -0,0 +1,18 @@
+package org.apache.ignite.internal.processors.cache.persistence.wal.reader;
+
+import org.apache.ignite.IgniteCheckedException;
+
+/**
+ * This exception is used in checking boundaries (StandaloneWalRecordsIterator).
+ */
+public class StrictBoundsCheckException extends IgniteCheckedException {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /**
+ * @param mesg Message.
+ */
+ public StrictBoundsCheckException(String mesg) {
+ super(mesg);
+ }
+}
\ No newline at end of file
[08/13] ignite git commit: IGNITE-10253: SQL: Merged SqlQuery
execution logic with SqlFieldsQuery. Now the first one is simply an
additional converter on top of the second. This closes #5395.
Posted by sb...@apache.org.
IGNITE-10253: SQL: Merged SqlQuery execution logic with SqlFieldsQuery. Now the first one is simply an additional converter on top of the second. This closes #5395.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/c4ec543a
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/c4ec543a
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/c4ec543a
Branch: refs/heads/ignite-10043
Commit: c4ec543a8b0da9c5d9a2e25739ac31fd68d13a5d
Parents: a802074
Author: devozerov <pp...@gmail.com>
Authored: Thu Nov 15 22:40:22 2018 +0300
Committer: devozerov <pp...@gmail.com>
Committed: Thu Nov 15 22:40:22 2018 +0300
----------------------------------------------------------------------
.../processors/query/GridQueryIndexing.java | 23 +-
.../processors/query/GridQueryProcessor.java | 275 ++++----
.../processors/query/QueryKeyValueIterable.java | 53 ++
.../processors/query/QueryKeyValueIterator.java | 68 ++
...IgniteClientCacheInitializationFailTest.java | 19 +-
.../processors/query/h2/IgniteH2Indexing.java | 285 ++-------
...CacheAbstractQueryDetailMetricsSelfTest.java | 15 +-
.../CacheAbstractQueryMetricsSelfTest.java | 13 -
...niteCacheLockPartitionOnAffinityRunTest.java | 2 +
.../h2/GridIndexingSpiAbstractSelfTest.java | 639 +------------------
...H2ResultSetIteratorNullifyOnEndSelfTest.java | 186 ------
11 files changed, 337 insertions(+), 1241 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4ec543a/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 60b0221..3eb732c 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,11 +21,9 @@ import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Collection;
import java.util.List;
-import javax.cache.Cache;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteDataStreamer;
import org.apache.ignite.cache.query.FieldsQueryCursor;
-import org.apache.ignite.cache.query.QueryCursor;
import org.apache.ignite.cache.query.SqlFieldsQuery;
import org.apache.ignite.cache.query.SqlQuery;
import org.apache.ignite.internal.GridKernalContext;
@@ -70,16 +68,13 @@ public interface GridQueryIndexing {
public void onClientDisconnect() throws IgniteCheckedException;
/**
- * Parses SQL query into two step query and executes it.
+ * Generate SqlFieldsQuery from SqlQuery.
*
- * @param schemaName Schema name.
* @param cacheName Cache name.
* @param qry Query.
- * @param keepBinary Keep binary flag.
- * @throws IgniteCheckedException If failed.
+ * @return Fields query.
*/
- public <K, V> QueryCursor<Cache.Entry<K, V>> queryDistributedSql(String schemaName, String cacheName, SqlQuery qry,
- boolean keepBinary) throws IgniteCheckedException;
+ public SqlFieldsQuery generateFieldsQuery(String cacheName, SqlQuery qry);
/**
* Detect whether SQL query should be executed in distributed or local manner and execute it.
@@ -121,18 +116,6 @@ public interface GridQueryIndexing {
SqlClientContext cliCtx) throws IgniteCheckedException;
/**
- * Executes regular query.
- *
- * @param schemaName Schema name.
- * @param cacheName Cache name.
- * @param qry Query.
- * @param filter Cache name and key filter.
- * @param keepBinary Keep binary flag. @return Cursor.
- */
- public <K, V> QueryCursor<Cache.Entry<K,V>> queryLocalSql(String schemaName, String cacheName, SqlQuery qry,
- IndexingQueryFilter filter, boolean keepBinary) throws IgniteCheckedException;
-
- /**
* Queries individual fields (generally used by JDBC drivers).
*
* @param schemaName Schema name.
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4ec543a/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 957d3ae..30c28b1 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
@@ -66,6 +66,7 @@ import org.apache.ignite.internal.processors.cache.DynamicCacheDescriptor;
import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
import org.apache.ignite.internal.processors.cache.GridCacheContext;
import org.apache.ignite.internal.processors.cache.KeyCacheObject;
+import org.apache.ignite.internal.processors.cache.QueryCursorImpl;
import org.apache.ignite.internal.processors.cache.mvcc.MvccSnapshot;
import org.apache.ignite.internal.processors.cache.persistence.CacheDataRow;
import org.apache.ignite.internal.processors.cache.query.CacheQueryFuture;
@@ -2078,7 +2079,13 @@ public class GridQueryProcessor extends GridProcessorAdapter {
*/
public List<FieldsQueryCursor<List<?>>> querySqlFields(final SqlFieldsQuery qry, final boolean keepBinary,
final boolean failOnMultipleStmts) {
- return querySqlFields(null, qry, null, keepBinary, failOnMultipleStmts);
+ return querySqlFields(
+ null,
+ qry,
+ null,
+ keepBinary,
+ failOnMultipleStmts
+ );
}
/**
@@ -2089,7 +2096,13 @@ public class GridQueryProcessor extends GridProcessorAdapter {
* @return Cursor.
*/
public FieldsQueryCursor<List<?>> querySqlFields(final SqlFieldsQuery qry, final boolean keepBinary) {
- return querySqlFields(null, qry, null, keepBinary, true).get(0);
+ return querySqlFields(
+ null,
+ qry,
+ null,
+ keepBinary,
+ true
+ ).get(0);
}
/**
@@ -2103,40 +2116,92 @@ public class GridQueryProcessor extends GridProcessorAdapter {
* more then one SQL statement.
* @return Cursor.
*/
- public List<FieldsQueryCursor<List<?>>> querySqlFields(@Nullable final GridCacheContext<?, ?> cctx,
- final SqlFieldsQuery qry, final SqlClientContext cliCtx, final boolean keepBinary,
- final boolean failOnMultipleStmts) {
- checkxEnabled();
-
- validateSqlFieldsQuery(qry, ctx, cctx);
+ public List<FieldsQueryCursor<List<?>>> querySqlFields(
+ @Nullable final GridCacheContext<?, ?> cctx,
+ final SqlFieldsQuery qry,
+ final SqlClientContext cliCtx,
+ final boolean keepBinary,
+ final boolean failOnMultipleStmts
+ ) {
+ return querySqlFields(
+ cctx,
+ qry,
+ cliCtx,
+ keepBinary,
+ failOnMultipleStmts,
+ GridCacheQueryType.SQL_FIELDS
+ );
+ }
- if (!busyLock.enterBusy())
- throw new IllegalStateException("Failed to execute query (grid is stopping).");
+ /**
+ * Query SQL fields.
+ *
+ * @param cctx Cache context.
+ * @param qry Query.
+ * @param cliCtx Client context.
+ * @param keepBinary Keep binary flag.
+ * @param failOnMultipleStmts If {@code true} the method must throws exception when query contains
+ * more then one SQL statement.
+ * @param qryType Real query type.
+ * @return Cursor.
+ */
+ public List<FieldsQueryCursor<List<?>>> querySqlFields(
+ @Nullable final GridCacheContext<?, ?> cctx,
+ final SqlFieldsQuery qry,
+ final SqlClientContext cliCtx,
+ final boolean keepBinary,
+ final boolean failOnMultipleStmts,
+ GridCacheQueryType qryType
+ ) {
+ // Validate.
+ checkxEnabled();
- GridCacheContext oldCctx = curCache.get();
+ if (qry.isDistributedJoins() && qry.getPartitions() != null)
+ throw new CacheException("Using both partitions and distributed JOINs is not supported for the same query");
- curCache.set(cctx);
+ if (qry.isLocal() && ctx.clientNode() && (cctx == null || cctx.config().getCacheMode() != CacheMode.LOCAL))
+ throw new CacheException("Execution of local SqlFieldsQuery on client node disallowed.");
- final String schemaName = qry.getSchema() != null ? qry.getSchema()
- : (cctx != null ? idx.schema(cctx.name()) : QueryUtils.DFLT_SCHEMA);
+ return executeQuerySafe(cctx, () -> {
+ final String schemaName = qry.getSchema() != null ? qry.getSchema()
+ : (cctx != null ? idx.schema(cctx.name()) : QueryUtils.DFLT_SCHEMA);
- try {
IgniteOutClosureX<List<FieldsQueryCursor<List<?>>>> clo =
new IgniteOutClosureX<List<FieldsQueryCursor<List<?>>>>() {
- @Override public List<FieldsQueryCursor<List<?>>> applyx() throws IgniteCheckedException {
- GridQueryCancel cancel = new GridQueryCancel();
+ @Override public List<FieldsQueryCursor<List<?>>> applyx() {
+ GridQueryCancel cancel = new GridQueryCancel();
- List<FieldsQueryCursor<List<?>>> res =
- idx.querySqlFields(schemaName, qry, cliCtx, keepBinary, failOnMultipleStmts, null, cancel);
+ List<FieldsQueryCursor<List<?>>> res =
+ idx.querySqlFields(schemaName, qry, cliCtx, keepBinary, failOnMultipleStmts, null, cancel);
- if (cctx != null)
- sendQueryExecutedEvent(qry.getSql(), qry.getArgs(), cctx);
+ if (cctx != null)
+ sendQueryExecutedEvent(qry.getSql(), qry.getArgs(), cctx);
- return res;
- }
- };
+ return res;
+ }
+ };
+
+ return executeQuery(qryType, qry.getSql(), cctx, clo, true);
+ });
+ }
+
+ /**
+ * Execute query setting busy lock, preserving current cache context and properly handling checked exceptions.
+ *
+ * @param cctx Cache context.
+ * @param supplier Code to be executed.
+ * @return Result.
+ */
+ private <T> T executeQuerySafe(@Nullable final GridCacheContext<?, ?> cctx, SupplierX<T> supplier) {
+ GridCacheContext oldCctx = curCache.get();
+
+ curCache.set(cctx);
+
+ if (!busyLock.enterBusy())
+ throw new IllegalStateException("Failed to execute query (grid is stopping).");
- return executeQuery(GridCacheQueryType.SQL_FIELDS, qry.getSql(), cctx, clo, true);
+ try {
+ return supplier.get();
}
catch (IgniteCheckedException e) {
throw new CacheException(e);
@@ -2149,34 +2214,6 @@ public class GridQueryProcessor extends GridProcessorAdapter {
}
/**
- * Validate SQL fields query.
- *
- * @param qry Query.
- * @param ctx Kernal context.
- * @param cctx Cache context.
- */
- private static void validateSqlFieldsQuery(SqlFieldsQuery qry, GridKernalContext ctx,
- @Nullable GridCacheContext<?, ?> cctx) {
- if (qry.isDistributedJoins() && qry.getPartitions() != null)
- throw new CacheException("Using both partitions and distributed JOINs is not supported for the same query");
-
- if (qry.isLocal() && ctx.clientNode() && (cctx == null || cctx.config().getCacheMode() != CacheMode.LOCAL))
- throw new CacheException("Execution of local SqlFieldsQuery on client node disallowed.");
- }
-
- /**
- * Validate SQL query.
- *
- * @param qry Query.
- * @param ctx Kernal context.
- * @param cctx Cache context.
- */
- private static void validateSqlQuery(SqlQuery qry, GridKernalContext ctx, GridCacheContext<?, ?> cctx) {
- if (qry.isLocal() && ctx.clientNode() && cctx.config().getCacheMode() != CacheMode.LOCAL)
- throw new CacheException("Execution of local SqlQuery on client node disallowed.");
- }
-
- /**
* @param cacheName Cache name.
* @param schemaName Schema name.
* @param streamer Data streamer.
@@ -2242,99 +2279,38 @@ public class GridQueryProcessor extends GridProcessorAdapter {
* @param keepBinary Keep binary flag.
* @return Cursor.
*/
- public <K, V> QueryCursor<Cache.Entry<K,V>> querySql(final GridCacheContext<?,?> cctx, final SqlQuery qry,
- boolean keepBinary) {
- validateSqlQuery(qry, ctx, cctx);
+ public <K, V> QueryCursor<Cache.Entry<K,V>> querySql(
+ final GridCacheContext<?,?> cctx,
+ final SqlQuery qry,
+ boolean keepBinary
+ ) {
+ // Generate.
+ String type = qry.getType();
- if (qry.isReplicatedOnly() && qry.getPartitions() != null)
- throw new CacheException("Partitions are not supported in replicated only mode.");
+ String typeName = typeName(cctx.name(), type);
- if (qry.isDistributedJoins() && qry.getPartitions() != null)
- throw new CacheException(
- "Using both partitions and distributed JOINs is not supported for the same query");
-
- if ((qry.isReplicatedOnly() && cctx.isReplicatedAffinityNode()) || cctx.isLocal() || qry.isLocal())
- return queryLocalSql(cctx, qry, keepBinary);
-
- return queryDistributedSql(cctx, qry, keepBinary);
- }
+ qry.setType(typeName);
- /**
- * @param cctx Cache context.
- * @param qry Query.
- * @param keepBinary Keep binary flag.
- * @return Cursor.
- */
- private <K,V> QueryCursor<Cache.Entry<K,V>> queryDistributedSql(final GridCacheContext<?,?> cctx,
- final SqlQuery qry, final boolean keepBinary) {
- checkxEnabled();
+ SqlFieldsQuery fieldsQry = idx.generateFieldsQuery(cctx.name(), qry);
- if (!busyLock.enterBusy())
- throw new IllegalStateException("Failed to execute query (grid is stopping).");
+ // Execute.
+ FieldsQueryCursor<List<?>> res = querySqlFields(
+ cctx,
+ fieldsQry,
+ null,
+ keepBinary,
+ true,
+ GridCacheQueryType.SQL
+ ).get(0);
- try {
- final String schemaName = idx.schema(cctx.name());
+ // Convert.
+ QueryKeyValueIterable<K, V>converted = new QueryKeyValueIterable<>(res);
- return executeQuery(GridCacheQueryType.SQL, qry.getSql(), cctx,
- new IgniteOutClosureX<QueryCursor<Cache.Entry<K, V>>>() {
- @Override public QueryCursor<Cache.Entry<K, V>> applyx() throws IgniteCheckedException {
- return idx.queryDistributedSql(schemaName, cctx.name(), qry, keepBinary);
- }
- }, true);
- }
- catch (IgniteCheckedException e) {
- throw new IgniteException(e);
- }
- finally {
- busyLock.leaveBusy();
- }
- }
-
- /**
- * @param cctx Cache context.
- * @param qry Query.
- * @param keepBinary Keep binary flag.
- * @return Cursor.
- */
- private <K, V> QueryCursor<Cache.Entry<K, V>> queryLocalSql(final GridCacheContext<?, ?> cctx, final SqlQuery qry,
- final boolean keepBinary) {
- if (!busyLock.enterBusy())
- throw new IllegalStateException("Failed to execute query (grid is stopping).");
-
- final String schemaName = idx.schema(cctx.name());
-
- try {
- return executeQuery(GridCacheQueryType.SQL, qry.getSql(), cctx,
- new IgniteOutClosureX<QueryCursor<Cache.Entry<K, V>>>() {
- @Override public QueryCursor<Cache.Entry<K, V>> applyx() throws IgniteCheckedException {
- String type = qry.getType();
-
- String typeName = typeName(cctx.name(), type);
-
- qry.setType(typeName);
-
- sendQueryExecutedEvent(
- qry.getSql(),
- qry.getArgs(),
- cctx);
-
- if (cctx.config().getQueryParallelism() > 1) {
- qry.setDistributedJoins(true);
-
- return idx.queryDistributedSql(schemaName, cctx.name(), qry, keepBinary);
- }
- else
- return idx.queryLocalSql(schemaName, cctx.name(), qry, idx.backupFilter(requestTopVer.get(),
- qry.getPartitions()), keepBinary);
- }
- }, true);
- }
- catch (IgniteCheckedException e) {
- throw new CacheException(e);
- }
- finally {
- busyLock.leaveBusy();
- }
+ return new QueryCursorImpl<Cache.Entry<K, V>>(converted) {
+ @Override public void close() {
+ converted.cursor().close();
+ }
+ };
}
/**
@@ -2667,13 +2643,12 @@ public class GridQueryProcessor extends GridProcessorAdapter {
* @param cacheName Cache name.
* @param typeName Type name.
* @return Type descriptor.
- * @throws IgniteCheckedException If failed.
*/
- private String typeName(@Nullable String cacheName, String typeName) throws IgniteCheckedException {
+ private String typeName(@Nullable String cacheName, String typeName) throws IgniteException {
QueryTypeDescriptorImpl type = typesByName.get(new QueryTypeNameKey(cacheName, typeName));
if (type == null)
- throw new IgniteCheckedException("Failed to find SQL table for type: " + typeName);
+ throw new IgniteException("Failed to find SQL table for type: " + typeName);
return type.name();
}
@@ -3144,4 +3119,18 @@ public class GridQueryProcessor extends GridProcessorAdapter {
return S.toString(TableCacheFilter.class, this);
}
}
+
+ /**
+ * Function which can throw exception.
+ */
+ @FunctionalInterface
+ private interface SupplierX<T> {
+ /**
+ * Get value.
+ *
+ * @return Value.
+ * @throws IgniteCheckedException If failed.
+ */
+ T get() throws IgniteCheckedException;
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4ec543a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryKeyValueIterable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryKeyValueIterable.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryKeyValueIterable.java
new file mode 100644
index 0000000..41d5145
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryKeyValueIterable.java
@@ -0,0 +1,53 @@
+/*
+ * 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.query;
+
+import org.apache.ignite.cache.query.QueryCursor;
+
+import javax.cache.Cache;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * SqlQuery key-value iterable.
+ */
+public class QueryKeyValueIterable<K, V> implements Iterable<Cache.Entry<K, V>> {
+ /** Underlying fields query cursor. */
+ private final QueryCursor<List<?>> cur;
+
+ /**
+ * Constructor.
+ *
+ * @param cur Underlying fields query cursor.
+ */
+ public QueryKeyValueIterable(QueryCursor<List<?>> cur) {
+ this.cur = cur;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Iterator<Cache.Entry<K, V>> iterator() {
+ return new QueryKeyValueIterator<>(cur.iterator());
+ }
+
+ /**
+ * @return Underlying fields query cursor.
+ */
+ QueryCursor<List<?>> cursor() {
+ return cur;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4ec543a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryKeyValueIterator.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryKeyValueIterator.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryKeyValueIterator.java
new file mode 100644
index 0000000..02dde9d
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryKeyValueIterator.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.query;
+
+import org.apache.ignite.internal.processors.cache.CacheEntryImpl;
+
+import javax.cache.Cache;
+import javax.cache.CacheException;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * SqlQuery key-value iterator.
+ */
+public class QueryKeyValueIterator<K, V> implements Iterator<Cache.Entry<K, V>> {
+ /** Target iterator. */
+ private final Iterator<List<?>> iter;
+
+ /**
+ * Constructor.
+ *
+ * @param iter Target iterator.
+ */
+ public QueryKeyValueIterator(Iterator<List<?>> iter) {
+ this.iter = iter;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean hasNext() {
+ return iter.hasNext();
+ }
+
+ /** {@inheritDoc} */
+ @SuppressWarnings("unchecked")
+ @Override public Cache.Entry<K, V> next() {
+ try {
+ List<?> row = iter.next();
+
+ return new CacheEntryImpl<>((K)row.get(0), (V)row.get(1));
+ }
+ catch (CacheException e) {
+ throw e;
+ }
+ catch (Exception e) {
+ throw new CacheException(e);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public void remove() {
+ throw new UnsupportedOperationException();
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4ec543a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteClientCacheInitializationFailTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteClientCacheInitializationFailTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteClientCacheInitializationFailTest.java
index 69b1655..ba2fec6 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteClientCacheInitializationFailTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteClientCacheInitializationFailTest.java
@@ -26,7 +26,6 @@ import java.util.List;
import java.util.Random;
import java.util.Set;
import java.util.concurrent.Callable;
-import javax.cache.Cache;
import javax.cache.CacheException;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
@@ -34,7 +33,6 @@ import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteDataStreamer;
import org.apache.ignite.cache.CacheAtomicityMode;
import org.apache.ignite.cache.query.FieldsQueryCursor;
-import org.apache.ignite.cache.query.QueryCursor;
import org.apache.ignite.cache.query.SqlFieldsQuery;
import org.apache.ignite.cache.query.SqlQuery;
import org.apache.ignite.configuration.CacheConfiguration;
@@ -231,19 +229,18 @@ public class IgniteClientCacheInitializationFailTest extends GridCommonAbstractT
}
/** {@inheritDoc} */
- @Override public void start(GridKernalContext ctx, GridSpinBusyLock busyLock) throws IgniteCheckedException {
- // No-op
+ @Override public SqlFieldsQuery generateFieldsQuery(String cacheName, SqlQuery qry) {
+ return null;
}
/** {@inheritDoc} */
- @Override public void stop() throws IgniteCheckedException {
+ @Override public void start(GridKernalContext ctx, GridSpinBusyLock busyLock) throws IgniteCheckedException {
// No-op
}
/** {@inheritDoc} */
- @Override public <K, V> QueryCursor<Cache.Entry<K, V>> queryDistributedSql(String schemaName, String cacheName,
- SqlQuery qry, boolean keepBinary) throws IgniteCheckedException {
- return null;
+ @Override public void stop() throws IgniteCheckedException {
+ // No-op
}
/** {@inheritDoc} */
@@ -265,12 +262,6 @@ public class IgniteClientCacheInitializationFailTest extends GridCommonAbstractT
}
/** {@inheritDoc} */
- @Override public <K, V> QueryCursor<Cache.Entry<K, V>> queryLocalSql(String schemaName, String cacheName,
- SqlQuery qry, IndexingQueryFilter filter, boolean keepBinary) throws IgniteCheckedException {
- return null;
- }
-
- /** {@inheritDoc} */
@Override public FieldsQueryCursor<List<?>> queryLocalSqlFields(String schemaName, SqlFieldsQuery qry,
boolean keepBinary, IndexingQueryFilter filter, GridQueryCancel cancel) throws IgniteCheckedException {
return null;
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4ec543a/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 e2dba50..58e09cb 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
@@ -44,7 +44,6 @@ import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import java.util.regex.Pattern;
-import javax.cache.Cache;
import javax.cache.CacheException;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteDataStreamer;
@@ -53,7 +52,6 @@ import org.apache.ignite.IgniteLogger;
import org.apache.ignite.IgniteSystemProperties;
import org.apache.ignite.cache.query.FieldsQueryCursor;
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.cache.query.SqlQuery;
import org.apache.ignite.cache.query.annotations.QuerySqlFunction;
@@ -62,8 +60,6 @@ import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.GridTopic;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
-import org.apache.ignite.internal.processors.cache.CacheEntryImpl;
-import org.apache.ignite.internal.processors.cache.CacheObjectUtils;
import org.apache.ignite.internal.processors.cache.CacheObjectValueContext;
import org.apache.ignite.internal.processors.cache.DynamicCacheDescriptor;
import org.apache.ignite.internal.processors.cache.GridCacheContext;
@@ -209,7 +205,6 @@ import static org.apache.ignite.internal.processors.cache.mvcc.MvccUtils.checkAc
import static org.apache.ignite.internal.processors.cache.mvcc.MvccUtils.mvccEnabled;
import static org.apache.ignite.internal.processors.cache.mvcc.MvccUtils.tx;
import static org.apache.ignite.internal.processors.cache.mvcc.MvccUtils.txStart;
-import static org.apache.ignite.internal.processors.cache.query.GridCacheQueryType.SQL;
import static org.apache.ignite.internal.processors.cache.query.GridCacheQueryType.SQL_FIELDS;
import static org.apache.ignite.internal.processors.cache.query.GridCacheQueryType.TEXT;
import static org.apache.ignite.internal.processors.query.QueryUtils.KEY_FIELD_NAME;
@@ -1568,111 +1563,6 @@ public class IgniteH2Indexing implements GridQueryIndexing {
return cursor;
}
- /** {@inheritDoc} */
- @SuppressWarnings("unchecked")
- @Override public <K, V> QueryCursor<Cache.Entry<K,V>> queryLocalSql(String schemaName, String cacheName,
- final SqlQuery qry, final IndexingQueryFilter filter, final boolean keepBinary) throws IgniteCheckedException {
- String type = qry.getType();
- String sqlQry = qry.getSql();
- String alias = qry.getAlias();
- Object[] params = qry.getArgs();
-
- GridQueryCancel cancel = new GridQueryCancel();
-
- final GridCloseableIterator<IgniteBiTuple<K, V>> i = queryLocalSql(schemaName, cacheName, sqlQry, alias,
- F.asList(params), type, filter, cancel);
-
- return new QueryCursorImpl<>(new Iterable<Cache.Entry<K, V>>() {
- @SuppressWarnings("NullableProblems")
- @Override public Iterator<Cache.Entry<K, V>> iterator() {
- return new ClIter<Cache.Entry<K, V>>() {
- @Override public void close() throws Exception {
- i.close();
- }
-
- @Override public boolean hasNext() {
- return i.hasNext();
- }
-
- @Override public Cache.Entry<K, V> next() {
- IgniteBiTuple<K, V> t = i.next();
-
- K key = (K)CacheObjectUtils.unwrapBinaryIfNeeded(objectContext(), t.get1(), keepBinary, false);
- V val = (V)CacheObjectUtils.unwrapBinaryIfNeeded(objectContext(), t.get2(), keepBinary, false);
-
- return new CacheEntryImpl<>(key, val);
- }
-
- @Override public void remove() {
- throw new UnsupportedOperationException();
- }
- };
- }
- }, cancel);
- }
-
- /**
- * Executes regular query.
- *
- * @param schemaName Schema name.
- * @param cacheName Cache name.
- * @param qry Query.
- * @param alias Table alias.
- * @param params Query parameters.
- * @param type Query return type.
- * @param filter Cache name and key filter.
- * @param cancel Cancel object.
- * @return Queried rows.
- * @throws IgniteCheckedException If failed.
- */
- @SuppressWarnings("unchecked")
- <K, V> GridCloseableIterator<IgniteBiTuple<K, V>> queryLocalSql(String schemaName, String cacheName,
- final String qry, String alias, @Nullable final Collection<Object> params, String type,
- final IndexingQueryFilter filter, GridQueryCancel cancel) throws IgniteCheckedException {
- final H2TableDescriptor tbl = tableDescriptor(schemaName, cacheName, type);
-
- if (tbl == null)
- throw new IgniteSQLException("Failed to find SQL table for type: " + type,
- IgniteQueryErrorCode.TABLE_NOT_FOUND);
-
- String sql = generateQuery(qry, alias, tbl);
-
- Connection conn = connectionForThread(tbl.schemaName());
-
- H2Utils.setupConnection(conn, false, false);
-
- GridH2QueryContext qctx = new GridH2QueryContext(nodeId, nodeId, 0, LOCAL).filter(filter)
- .distributedJoinMode(OFF);
-
- PreparedStatement stmt = preparedStatementWithParams(conn, sql, params, true);
-
- MvccQueryTracker mvccTracker = mvccTracker(stmt, false);
-
- if (mvccTracker != null)
- qctx.mvccSnapshot(mvccTracker.snapshot());
-
- GridH2QueryContext.set(qctx);
-
- GridRunningQueryInfo run = new GridRunningQueryInfo(qryIdGen.incrementAndGet(), qry, SQL, schemaName,
- U.currentTimeMillis(), null, true);
-
- runs.put(run.id(), run);
-
- try {
- ResultSet rs = executeSqlQueryWithTimer(stmt, conn, sql, params, 0, cancel);
-
- return new H2KeyValueIterator(rs);
- }
- finally {
- GridH2QueryContext.clearThreadLocal();
-
- if (mvccTracker != null)
- mvccTracker.onDone();
-
- runs.remove(run.id());
- }
- }
-
/**
* Initialises MVCC filter and returns MVCC query tracker if needed.
* @param stmt Prepared statement.
@@ -1754,8 +1644,6 @@ public class IgniteH2Indexing implements GridQueryIndexing {
PreparedStatementEx stmtEx = stmt.unwrap(PreparedStatementEx.class);
if (mvccEnabled) {
- assert mvccCacheId != null;
-
stmtEx.putMeta(MVCC_CACHE_ID, mvccCacheId);
stmtEx.putMeta(MVCC_STATE, Boolean.TRUE);
}
@@ -1840,9 +1728,9 @@ public class IgniteH2Indexing implements GridQueryIndexing {
}
/** {@inheritDoc} */
- @SuppressWarnings("unchecked")
- @Override public <K, V> QueryCursor<Cache.Entry<K, V>> queryDistributedSql(String schemaName, String cacheName,
- SqlQuery qry, boolean keepBinary) {
+ @Override public SqlFieldsQuery generateFieldsQuery(String cacheName, SqlQuery qry) {
+ String schemaName = schema(cacheName);
+
String type = qry.getType();
H2TableDescriptor tblDesc = tableDescriptor(schemaName, cacheName, type);
@@ -1860,58 +1748,80 @@ public class IgniteH2Indexing implements GridQueryIndexing {
throw new IgniteException(e);
}
- SqlFieldsQuery fqry = new SqlFieldsQuery(sql);
+ SqlFieldsQuery res = new SqlFieldsQuery(sql);
- fqry.setArgs(qry.getArgs());
- fqry.setPageSize(qry.getPageSize());
- fqry.setDistributedJoins(qry.isDistributedJoins());
- fqry.setPartitions(qry.getPartitions());
- fqry.setLocal(qry.isLocal());
+ res.setArgs(qry.getArgs());
+ res.setDistributedJoins(qry.isDistributedJoins());
+ res.setLocal(qry.isLocal());
+ res.setPageSize(qry.getPageSize());
+ res.setPartitions(qry.getPartitions());
+ res.setReplicatedOnly(qry.isReplicatedOnly());
+ res.setSchema(schemaName);
+ res.setSql(sql);
if (qry.getTimeout() > 0)
- fqry.setTimeout(qry.getTimeout(), TimeUnit.MILLISECONDS);
+ res.setTimeout(qry.getTimeout(), TimeUnit.MILLISECONDS);
+
+ return res;
+ }
- final QueryCursor<List<?>> res =
- querySqlFields(schemaName, fqry, null, keepBinary, true, null, null).get(0);
+ /**
+ * 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 static String generateQuery(String qry, String tableAlias, H2TableDescriptor tbl)
+ throws IgniteCheckedException {
+ assert tbl != null;
- final Iterable<Cache.Entry<K, V>> converted = new Iterable<Cache.Entry<K, V>>() {
- @Override public Iterator<Cache.Entry<K, V>> iterator() {
- final Iterator<List<?>> iter0 = res.iterator();
+ final String qry0 = qry;
- return new Iterator<Cache.Entry<K, V>>() {
- @Override public boolean hasNext() {
- return iter0.hasNext();
- }
+ String t = tbl.fullTableName();
- @Override public Cache.Entry<K, V> next() {
- List<?> l;
+ String from = " ";
- try {
- l = iter0.next();
- }
- catch (CacheException e) {
- throw e;
- }
- catch (Exception e) {
- throw new CacheException(e);
- }
+ qry = qry.trim();
- return new CacheEntryImpl<>((K)l.get(0), (V)l.get(1));
- }
+ String upper = qry.toUpperCase();
- @Override public void remove() {
- throw new UnsupportedOperationException();
- }
- };
- }
- };
+ if (upper.startsWith("SELECT")) {
+ qry = qry.substring(6).trim();
- // No metadata for SQL queries.
- return new QueryCursorImpl<Cache.Entry<K, V>>(converted) {
- @Override public void close() {
- res.close();
+ final int star = qry.indexOf('*');
+
+ if (star == 0)
+ qry = qry.substring(1).trim();
+ else if (star > 0) {
+ if (F.eq('.', qry.charAt(star - 1))) {
+ t = qry.substring(0, star - 1);
+
+ qry = qry.substring(star + 1).trim();
+ }
+ else
+ throw new IgniteCheckedException("Invalid query (missing alias before asterisk): " + qry0);
}
- };
+ else
+ throw new IgniteCheckedException("Only queries starting with 'SELECT *' and 'SELECT alias.*' " +
+ "are supported (rewrite your query or use SqlFieldsQuery instead): " + qry0);
+
+ upper = qry.toUpperCase();
+ }
+
+ if (!upper.startsWith("FROM"))
+ 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;
}
/**
@@ -2774,64 +2684,6 @@ 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, String tableAlias, H2TableDescriptor tbl) throws IgniteCheckedException {
- assert tbl != null;
-
- final String qry0 = qry;
-
- String t = tbl.fullTableName();
-
- String from = " ";
-
- qry = qry.trim();
-
- String upper = qry.toUpperCase();
-
- if (upper.startsWith("SELECT")) {
- qry = qry.substring(6).trim();
-
- final int star = qry.indexOf('*');
-
- if (star == 0)
- qry = qry.substring(1).trim();
- else if (star > 0) {
- if (F.eq('.', qry.charAt(star - 1))) {
- t = qry.substring(0, star - 1);
-
- qry = qry.substring(star + 1).trim();
- }
- else
- throw new IgniteCheckedException("Invalid query (missing alias before asterisk): " + qry0);
- }
- else
- throw new IgniteCheckedException("Only queries starting with 'SELECT *' and 'SELECT alias.*' " +
- "are supported (rewrite your query or use SqlFieldsQuery instead): " + qry0);
-
- upper = qry.toUpperCase();
- }
-
- if (!upper.startsWith("FROM"))
- 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;
- }
-
- /**
* Registers new class description.
*
* This implementation doesn't support type reregistration.
@@ -3842,11 +3694,4 @@ public class IgniteH2Indexing implements GridQueryIndexing {
return false;
}
-
- /**
- * Closeable iterator.
- */
- private interface ClIter<X> extends AutoCloseable, Iterator<X> {
- // No-op.
- }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4ec543a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheAbstractQueryDetailMetricsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheAbstractQueryDetailMetricsSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheAbstractQueryDetailMetricsSelfTest.java
index 837de65..e1d7154 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheAbstractQueryDetailMetricsSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheAbstractQueryDetailMetricsSelfTest.java
@@ -186,7 +186,7 @@ public abstract class CacheAbstractQueryDetailMetricsSelfTest extends GridCommon
assertTrue(lastMetrics.contains("SQL_FIELDS select * from String limit 2;"));
assertTrue(lastMetrics.contains("SCAN A;"));
- assertTrue(lastMetrics.contains("SQL from String;"));
+ assertTrue(lastMetrics.contains("SELECT \"A\".\"STRING\"._KEY, \"A\".\"STRING\"._VAL from String;"));
cache = grid(0).context().cache().jcache("B");
@@ -349,19 +349,6 @@ public abstract class CacheAbstractQueryDetailMetricsSelfTest extends GridCommon
}
/**
- * Test metrics for failed Scan queries.
- *
- * @throws Exception In case of error.
- */
- public void testSqlQueryFailedMetrics() throws Exception {
- IgniteCache<Integer, String> cache = grid(0).context().cache().jcache("A");
-
- SqlQuery<Integer, String> qry = new SqlQuery<>("Long", "from Long");
-
- checkQueryFailedMetrics(cache, qry);
- }
-
- /**
* Test metrics for Sql queries.
*
* @throws Exception In case of error.
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4ec543a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheAbstractQueryMetricsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheAbstractQueryMetricsSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheAbstractQueryMetricsSelfTest.java
index eb3c8d6..e1c796b 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheAbstractQueryMetricsSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheAbstractQueryMetricsSelfTest.java
@@ -209,19 +209,6 @@ public abstract class CacheAbstractQueryMetricsSelfTest extends GridCommonAbstra
}
/**
- * Test metrics for failed Scan queries.
- *
- * @throws Exception In case of error.
- */
- public void testSqlQueryFailedMetrics() throws Exception {
- IgniteCache<Integer, String> cache = grid(0).context().cache().jcache("A");
-
- SqlQuery qry = new SqlQuery<>("Long", "from Long");
-
- checkQueryFailedMetrics(cache, qry);
- }
-
- /**
* Test metrics for Sql queries.
*
* @throws Exception In case of error.
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4ec543a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheLockPartitionOnAffinityRunTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheLockPartitionOnAffinityRunTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheLockPartitionOnAffinityRunTest.java
index 89ef607..d0cfbd9 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheLockPartitionOnAffinityRunTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheLockPartitionOnAffinityRunTest.java
@@ -291,6 +291,8 @@ public class IgniteCacheLockPartitionOnAffinityRunTest extends IgniteCacheLockPa
* @throws Exception If failed.
*/
public void testSingleCache() throws Exception {
+ fail("https://issues.apache.org/jira/browse/IGNITE-7692");
+
final PersonsCountGetter personsCntGetter = new PersonsCountGetter() {
@Override public int getPersonsCount(IgniteEx ignite, IgniteLogger log, int orgId) throws Exception {
return getPersonsCountSingleCache(ignite, log, orgId);
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4ec543a/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 6b76230..7e198f8 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
@@ -17,20 +17,7 @@
package org.apache.ignite.internal.processors.query.h2;
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteLogger;
-import org.apache.ignite.binary.BinaryObject;
-import org.apache.ignite.binary.BinaryObjectBuilder;
import org.apache.ignite.cache.QueryEntity;
import org.apache.ignite.cache.QueryIndex;
import org.apache.ignite.cache.QueryIndexType;
@@ -38,48 +25,33 @@ import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.IgniteEx;
import org.apache.ignite.internal.binary.BinaryMarshaller;
-import org.apache.ignite.internal.binary.BinaryObjectImpl;
-import org.apache.ignite.internal.processors.cache.CacheObject;
-import org.apache.ignite.internal.processors.cache.CacheObjectContext;
-import org.apache.ignite.internal.processors.cache.CacheObjectValueContext;
-import org.apache.ignite.internal.processors.cache.KeyCacheObject;
import org.apache.ignite.internal.processors.query.GridQueryFieldsResult;
-import org.apache.ignite.internal.processors.query.GridQueryIndexDescriptor;
-import org.apache.ignite.internal.processors.query.GridQueryProperty;
-import org.apache.ignite.internal.processors.query.GridQueryTypeDescriptor;
-import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.lang.IgniteBiTuple;
-import org.apache.ignite.plugin.extensions.communication.MessageReader;
-import org.apache.ignite.plugin.extensions.communication.MessageWriter;
-import org.apache.ignite.spi.IgniteSpiCloseableIterator;
-import org.apache.ignite.spi.IgniteSpiException;
import org.apache.ignite.testframework.GridStringLogger;
import org.apache.ignite.testframework.GridTestUtils;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-import org.h2.util.JdbcUtils;
-import org.jetbrains.annotations.Nullable;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
/**
* Tests for all SQL based indexing SPI implementations.
*/
public abstract class GridIndexingSpiAbstractSelfTest extends GridCommonAbstractTest {
/** */
- private static final TextIndex textIdx = new TextIndex(F.asList("txt"));
-
- /** */
private static final LinkedHashMap<String, String> fieldsAA = new LinkedHashMap<>();
/** */
private static final LinkedHashMap<String, String> fieldsAB = new LinkedHashMap<>();
/** */
- private static final LinkedHashMap<String, String> fieldsBA = new LinkedHashMap<>();
-
- /** */
private IgniteEx ignite0;
/** {@inheritDoc} */
+ @SuppressWarnings("deprecation")
@Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(gridName);
@@ -98,20 +70,8 @@ public abstract class GridIndexingSpiAbstractSelfTest extends GridCommonAbstract
fieldsAB.putAll(fieldsAA);
fieldsAB.put("txt", String.class.getName());
-
- fieldsBA.putAll(fieldsAA);
- fieldsBA.put("sex", Boolean.class.getName());
}
- /** */
- private static TypeDesc typeAA = new TypeDesc("A", "A", "A", Collections.<String, Class<?>>emptyMap(), null);
-
- /** */
- private static TypeDesc typeAB = new TypeDesc("A", "A", "B", Collections.<String, Class<?>>emptyMap(), textIdx);
-
- /** */
- private static TypeDesc typeBA = new TypeDesc("B", "B", "A", Collections.<String, Class<?>>emptyMap(), null);
-
/** {@inheritDoc} */
@Override protected void beforeTest() throws Exception {
ignite0 = startGrid(0);
@@ -144,82 +104,12 @@ public abstract class GridIndexingSpiAbstractSelfTest extends GridCommonAbstract
return cfg;
}
- /**
- *
- */
- private CacheConfiguration cacheBCfg() {
- CacheConfiguration cfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
-
- cfg.setName("B");
-
- QueryEntity eA = new QueryEntity(Integer.class.getName(), "A");
- eA.setFields(fieldsBA);
-
- cfg.setQueryEntities(Collections.singleton(eA));
-
- return cfg;
- }
-
/** {@inheritDoc} */
@Override protected void afterTest() throws Exception {
stopAllGrids();
}
/**
- * @param id Id.
- * @param name Name.
- * @param age Age.
- * @return AA.
- */
- private BinaryObjectBuilder aa(String typeName, long id, String name, int age) {
- BinaryObjectBuilder aBuilder = ignite0.binary().builder(typeName)
- .setField("id", id)
- .setField("name", name)
- .setField("age", age);
-
- return aBuilder;
- }
-
- /**
- * @param id Id.
- * @param name Name.
- * @param age Age.
- * @param txt Text.
- * @return AB.
- */
- private BinaryObjectBuilder ab(long id, String name, int age, String txt) {
- BinaryObjectBuilder aBuilder = aa("B", id, name, age);
-
- aBuilder.setField("txt", txt);
-
- return aBuilder;
- }
-
- /**
- * @param id Id.
- * @param name Name.
- * @param age Age.
- * @param sex Sex.
- * @return BA.
- */
- private BinaryObjectBuilder ba(long id, String name, int age, boolean sex) {
- BinaryObjectBuilder builder = aa("A", id, name, age);
-
- builder.setField("sex", sex);
-
- return builder;
- }
-
- /**
- * @param row Row
- * @return Value.
- * @throws IgniteSpiException If failed.
- */
- private BinaryObjectImpl value(IgniteBiTuple<Integer, BinaryObjectImpl> row) throws IgniteSpiException {
- return row.get2();
- }
-
- /**
* @return Indexing.
*/
private IgniteH2Indexing getIndexing() {
@@ -234,147 +124,11 @@ public abstract class GridIndexingSpiAbstractSelfTest extends GridCommonAbstract
}
/**
- * @param key Key.
- * @return Cache object.
- */
- private KeyCacheObject key(int key) {
- return new TestCacheObject(key);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testSpi() throws Exception {
- IgniteH2Indexing spi = getIndexing();
-
- IgniteCache<Integer, BinaryObject> cacheA = ignite0.createCache(cacheACfg());
-
- IgniteCache<Integer, BinaryObject> cacheB = ignite0.createCache(cacheBCfg());
-
- assertFalse(spi.queryLocalSql(spi.schema(typeAA.cacheName()), typeAA.cacheName(), "select * from A.A", null,
- Collections.emptySet(), typeAA.name(), null, null).hasNext());
-
- assertFalse(spi.queryLocalSql(spi.schema(typeAB.cacheName()), typeAB.cacheName(), "select * from A.B", null,
- Collections.emptySet(), typeAB.name(), null, null).hasNext());
-
- assertFalse(spi.queryLocalSql(spi.schema(typeBA.cacheName()), typeBA.cacheName(), "select * from B.A", null,
- Collections.emptySet(), typeBA.name(), null, null).hasNext());
-
- assertFalse(spi.queryLocalSql(spi.schema(typeBA.cacheName()), typeBA.cacheName(),
- "select * from B.A, A.B, A.A", null, Collections.emptySet(), typeBA.name(), null, null).hasNext());
-
- try {
- spi.queryLocalSql(spi.schema(typeBA.cacheName()), typeBA.cacheName(),
- "select aa.*, ab.*, ba.* from A.A aa, A.B ab, B.A ba",
- null, Collections.emptySet(), typeBA.name(), null, null).hasNext();
-
- fail("Enumerations of aliases in select block must be prohibited");
- }
- catch (IgniteCheckedException ignored) {
- // all fine
- }
-
- assertFalse(spi.queryLocalSql(spi.schema(typeAB.cacheName()), typeAB.cacheName(), "select ab.* from A.B ab",
- null, Collections.emptySet(), typeAB.name(), null, null).hasNext());
-
- assertFalse(spi.queryLocalSql(spi.schema(typeBA.cacheName()), typeBA.cacheName(),
- "select ba.* from B.A as ba", null, Collections.emptySet(), typeBA.name(), null, null).hasNext());
-
- cacheA.put(1, aa("A", 1, "Vasya", 10).build());
- cacheA.put(1, ab(1, "Vasya", 20, "Some text about Vasya goes here.").build());
- cacheB.put(1, ba(2, "Petya", 25, true).build());
- cacheB.put(1, ba(2, "Kolya", 25, true).build());
- cacheA.put(2, aa("A", 2, "Valera", 19).build());
- cacheA.put(3, aa("A", 3, "Borya", 18).build());
- cacheA.put(4, ab(4, "Vitalya", 20, "Very Good guy").build());
-
- // Query data.
- Iterator<IgniteBiTuple<Integer, BinaryObjectImpl>> res = spi.queryLocalSql(spi.schema(typeAA.cacheName()),
- typeAA.cacheName(), "from a order by age", null, Collections.emptySet(), typeAA.name(), null, null);
-
- assertTrue(res.hasNext());
- assertEquals(aa("A", 3, "Borya", 18).build(), value(res.next()));
- assertTrue(res.hasNext());
- assertEquals(aa("A", 2, "Valera", 19).build(), value(res.next()));
- assertFalse(res.hasNext());
-
- res = spi.queryLocalSql(spi.schema(typeAA.cacheName()), typeAA.cacheName(),
- "select aa.* from a aa order by aa.age", null, Collections.emptySet(), typeAA.name(), null, null);
-
- assertTrue(res.hasNext());
- assertEquals(aa("A", 3, "Borya", 18).build(), value(res.next()));
- assertTrue(res.hasNext());
- assertEquals(aa("A", 2, "Valera", 19).build(), value(res.next()));
- assertFalse(res.hasNext());
-
- res = spi.queryLocalSql(spi.schema(typeAB.cacheName()), typeAB.cacheName(), "from b order by name", null,
- Collections.emptySet(), typeAB.name(), null, null);
-
- assertTrue(res.hasNext());
- assertEquals(ab(1, "Vasya", 20, "Some text about Vasya goes here.").build(), value(res.next()));
- assertTrue(res.hasNext());
- assertEquals(ab(4, "Vitalya", 20, "Very Good guy").build(), value(res.next()));
- assertFalse(res.hasNext());
-
- res = spi.queryLocalSql(spi.schema(typeAB.cacheName()), typeAB.cacheName(),
- "select bb.* from b as bb order by bb.name", null, Collections.emptySet(), typeAB.name(), null, null);
-
- assertTrue(res.hasNext());
- assertEquals(ab(1, "Vasya", 20, "Some text about Vasya goes here.").build(), value(res.next()));
- assertTrue(res.hasNext());
- assertEquals(ab(4, "Vitalya", 20, "Very Good guy").build(), value(res.next()));
- assertFalse(res.hasNext());
-
- res = spi.queryLocalSql(spi.schema(typeBA.cacheName()), typeBA.cacheName(), "from a", null,
- Collections.emptySet(), typeBA.name(), null, null);
-
- assertTrue(res.hasNext());
- assertEquals(ba(2, "Kolya", 25, true).build(), value(res.next()));
- assertFalse(res.hasNext());
-
- // Text queries
- Iterator<IgniteBiTuple<Integer, BinaryObjectImpl>> txtRes = spi.queryLocalText(spi.schema(typeAB.cacheName()),
- typeAB.cacheName(), "good", typeAB.name(), null);
-
- assertTrue(txtRes.hasNext());
- assertEquals(ab(4, "Vitalya", 20, "Very Good guy").build(), value(txtRes.next()));
- assertFalse(txtRes.hasNext());
-
- // Fields query
- GridQueryFieldsResult fieldsRes =
- spi.queryLocalSqlFields(spi.schema("A"), "select a.a.name n1, a.a.age a1, b.a.name n2, " +
- "b.a.age a2 from a.a, b.a where a.a.id = b.a.id ", Collections.emptySet(), null, false, false, 0, null);
-
- String[] aliases = {"N1", "A1", "N2", "A2"};
- Object[] vals = { "Valera", 19, "Kolya", 25};
-
- IgniteSpiCloseableIterator<List<?>> it = fieldsRes.iterator();
-
- assertTrue(it.hasNext());
-
- List<?> fields = it.next();
-
- assertEquals(4, fields.size());
-
- int i = 0;
-
- for (Object f : fields) {
- assertEquals(aliases[i], fieldsRes.metaData().get(i).fieldName());
- assertEquals(vals[i++], f);
- }
-
- assertFalse(it.hasNext());
-
- // Remove
- cacheA.remove(2);
- cacheB.remove(1);
- }
-
- /**
* Test long queries write explain warnings into log.
*
* @throws Exception If failed.
*/
+ @SuppressWarnings({"unchecked", "deprecation"})
public void testLongQueries() throws Exception {
IgniteH2Indexing spi = getIndexing();
@@ -416,381 +170,4 @@ public abstract class GridIndexingSpiAbstractSelfTest extends GridCommonAbstract
GridTestUtils.setFieldValue(spi, "log", oldLog);
}
}
-
- /**
- * Index descriptor.
- */
- private static class TextIndex implements GridQueryIndexDescriptor {
- /** */
- private final Collection<String> fields;
-
- /**
- * @param fields Fields.
- */
- private TextIndex(Collection<String> fields) {
- this.fields = Collections.unmodifiableCollection(fields);
- }
-
- /** {@inheritDoc} */
- @Override public String name() {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public Collection<String> fields() {
- return fields;
- }
-
- /** {@inheritDoc} */
- @Override public boolean descending(String field) {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override public QueryIndexType type() {
- return QueryIndexType.FULLTEXT;
- }
-
- /** {@inheritDoc} */
- @Override public int inlineSize() {
- return 0;
- }
- }
-
- /**
- * Type descriptor.
- */
- private static class TypeDesc implements GridQueryTypeDescriptor {
- /** */
- private final String name;
-
- /** */
- private final String cacheName;
-
- /** */
- private final String schemaName;
-
- /** */
- private final Map<String, Class<?>> valFields;
-
- /** */
- private final GridQueryIndexDescriptor textIdx;
-
- /**
- * @param cacheName Cache name.
- * @param schemaName Schema name.
- * @param name Type name.
- * @param valFields Fields.
- * @param textIdx Fulltext index.
- */
- private TypeDesc(String cacheName, String schemaName, String name, Map<String, Class<?>> valFields, GridQueryIndexDescriptor textIdx) {
- this.name = name;
- this.cacheName = cacheName;
- this.schemaName = schemaName;
- this.valFields = Collections.unmodifiableMap(valFields);
- this.textIdx = textIdx;
- }
-
- /** {@inheritDoc} */
- @Override public String affinityKey() {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public String name() {
- return name;
- }
-
- /** {@inheritDoc} */
- @Override public String schemaName() {
- return schemaName;
- }
-
- /** {@inheritDoc} */
- @Override public String tableName() {
- return null;
- }
-
- /**
- * @return Cache name.
- */
- String cacheName() {
- return cacheName;
- }
-
- /** {@inheritDoc} */
- @Override public Map<String, Class<?>> fields() {
- return valFields;
- }
-
- /** {@inheritDoc} */
- @Override public GridQueryProperty property(final String name) {
- return new GridQueryProperty() {
- /** */
- @Override public Object value(Object key, Object val) throws IgniteCheckedException {
- return TypeDesc.this.value(name, key, val);
- }
-
- /** */
- @Override public void setValue(Object key, Object val, Object propVal) throws IgniteCheckedException {
- throw new UnsupportedOperationException();
- }
-
- /** */
- @Override public String name() {
- return name;
- }
-
- /** */
- @Override public Class<?> type() {
- return Object.class;
- }
-
- /** */
- @Override public boolean key() {
- return false;
- }
-
- /** */
- @Override public GridQueryProperty parent() {
- return null;
- }
-
- /** */
- @Override public boolean notNull() {
- return false;
- }
-
- /** */
- @Override public Object defaultValue() {
- return null;
- }
-
- /** */
- @Override public int precision() {
- return -1;
- }
-
- /** */
- @Override public int scale() {
- return -1;
- }
- };
- }
-
- /** {@inheritDoc} */
- @SuppressWarnings("unchecked")
- @Override public <T> T value(String field, Object key, Object val) throws IgniteSpiException {
- assert !F.isEmpty(field);
-
- assert key instanceof Integer;
-
- Map<String, T> m = (Map<String, T>)val;
-
- if (m.containsKey(field))
- return m.get(field);
-
- return null;
- }
-
- /** {@inheritDoc} */
- @SuppressWarnings("unchecked")
- @Override public void setValue(String field, Object key, Object val, Object propVal) throws IgniteCheckedException {
- assert !F.isEmpty(field);
-
- assert key instanceof Integer;
-
- Map<String, Object> m = (Map<String, Object>)val;
-
- m.put(field, propVal);
- }
-
- /** */
- @Override public Map<String, GridQueryIndexDescriptor> indexes() {
- return Collections.emptyMap();
- }
-
- /** */
- @Override public GridQueryIndexDescriptor textIndex() {
- return textIdx;
- }
-
- /** */
- @Override public Class<?> valueClass() {
- return Object.class;
- }
-
- /** */
- @Override public Class<?> keyClass() {
- return Integer.class;
- }
-
- /** */
- @Override public String keyTypeName() {
- return null;
- }
-
- /** */
- @Override public String valueTypeName() {
- return null;
- }
-
- /** */
- @Override public boolean valueTextIndex() {
- return textIdx == null;
- }
-
- /** */
- @Override public int typeId() {
- return 0;
- }
-
- /** {@inheritDoc} */
- @Override public String keyFieldName() {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public String valueFieldName() {
- return null;
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public String keyFieldAlias() {
- return null;
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public String valueFieldAlias() {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public void validateKeyAndValue(Object key, Object value) throws IgniteCheckedException {
- // No-op.
- }
-
- /** {@inheritDoc} */
- @Override public void setDefaults(Object key, Object val) throws IgniteCheckedException {
- // No-op.
- }
- }
-
- /**
- */
- private static class TestCacheObject implements KeyCacheObject {
- /** */
- private Object val;
-
- /** */
- private int part;
-
- /**
- * @param val Value.
- */
- private TestCacheObject(Object val) {
- this.val = val;
- }
-
- /** {@inheritDoc} */
- @Override public void onAckReceived() {
- // No-op.
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public <T> T value(CacheObjectValueContext ctx, boolean cpy) {
- return (T)val;
- }
-
- /** {@inheritDoc} */
- @Override public int partition() {
- return part;
- }
-
- /** {@inheritDoc} */
- @Override public void partition(int part) {
- this.part = part;
- }
-
- /** {@inheritDoc} */
- @Override public byte[] valueBytes(CacheObjectValueContext ctx) throws IgniteCheckedException {
- return JdbcUtils.serialize(val, null);
- }
-
- /** {@inheritDoc} */
- @Override public boolean putValue(ByteBuffer buf) throws IgniteCheckedException {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override public int putValue(long addr) throws IgniteCheckedException {
- return 0;
- }
-
- /** {@inheritDoc} */
- @Override public boolean putValue(final ByteBuffer buf, final int off, final int len)
- throws IgniteCheckedException {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override public int valueBytesLength(CacheObjectContext ctx) throws IgniteCheckedException {
- return 0;
- }
-
- /** {@inheritDoc} */
- @Override public byte cacheObjectType() {
- throw new UnsupportedOperationException();
- }
-
- /** {@inheritDoc} */
- @Override public boolean isPlatformType() {
- return true;
- }
-
- /** {@inheritDoc} */
- @Override public KeyCacheObject copy(int part) {
- return this;
- }
-
- /** {@inheritDoc} */
- @Override public CacheObject prepareForCache(CacheObjectContext ctx) {
- throw new UnsupportedOperationException();
- }
-
- /** {@inheritDoc} */
- @Override public void finishUnmarshal(CacheObjectValueContext ctx, ClassLoader ldr) throws IgniteCheckedException {
- throw new UnsupportedOperationException();
- }
-
- /** {@inheritDoc} */
- @Override public void prepareMarshal(CacheObjectValueContext ctx) throws IgniteCheckedException {
- throw new UnsupportedOperationException();
- }
-
- /** {@inheritDoc} */
- @Override public boolean writeTo(ByteBuffer buf, MessageWriter writer) {
- throw new UnsupportedOperationException();
- }
-
- /** {@inheritDoc} */
- @Override public boolean readFrom(ByteBuffer buf, MessageReader reader) {
- throw new UnsupportedOperationException();
- }
-
- /** {@inheritDoc} */
- @Override public short directType() {
- throw new UnsupportedOperationException();
- }
-
- /** {@inheritDoc} */
- @Override public byte fieldsCount() {
- throw new UnsupportedOperationException();
- }
-
- /** {@inheritDoc} */
- @Override public boolean internal() {
- return false;
- }
- }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c4ec543a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/H2ResultSetIteratorNullifyOnEndSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/H2ResultSetIteratorNullifyOnEndSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/H2ResultSetIteratorNullifyOnEndSelfTest.java
index 31b0b97..66f9dd2 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/H2ResultSetIteratorNullifyOnEndSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/H2ResultSetIteratorNullifyOnEndSelfTest.java
@@ -17,22 +17,16 @@
package org.apache.ignite.internal.processors.query.h2;
-import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
-import javax.cache.Cache;
import org.apache.ignite.IgniteCache;
-import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.cache.query.QueryCursor;
import org.apache.ignite.cache.query.SqlFieldsQuery;
-import org.apache.ignite.cache.query.SqlQuery;
import org.apache.ignite.cache.query.annotations.QuerySqlField;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.internal.processors.cache.QueryCursorImpl;
import org.apache.ignite.internal.processors.query.GridQueryCacheObjectsIterator;
-import org.apache.ignite.internal.processors.query.GridQueryProcessor;
-import org.apache.ignite.internal.util.lang.GridCloseableIterator;
import org.apache.ignite.testframework.GridTestUtils;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
@@ -47,80 +41,9 @@ public class H2ResultSetIteratorNullifyOnEndSelfTest extends GridCommonAbstractT
private static final int PERSON_COUNT = 20;
/** */
- private static final String SELECT_ALL_SQL = "SELECT p.* FROM Person p ORDER BY p.salary";
-
- /** */
private static final String SELECT_MAX_SAL_SQLF = "select max(salary) from Person";
/**
- * Non local SQL check nullification after close
- */
- public void testSqlQueryClose() {
- SqlQuery<String, Person> qry = new SqlQuery<>(Person.class, SELECT_ALL_SQL);
-
- QueryCursor<Cache.Entry<String, Person>> qryCurs = cache().query(qry);
-
- qryCurs.iterator();
-
- qryCurs.close();
-
- H2ResultSetIterator h2It = extractIteratorInnerGridIteratorInnerH2ResultSetIterator(qryCurs);
-
- checkIterator(h2It);
- }
-
- /**
- * Non local SQL check nullification after complete
- */
- public void testSqlQueryComplete() {
- SqlQuery<String, Person> qry = new SqlQuery<>(Person.class, SELECT_ALL_SQL);
-
- QueryCursor<Cache.Entry<String, Person>> qryCurs = cache().query(qry);
-
- qryCurs.getAll();
-
- H2ResultSetIterator h2It = extractIteratorInnerGridIteratorInnerH2ResultSetIterator(qryCurs);
-
- checkIterator(h2It);
- }
-
- /**
- * Local SQL check nullification after close
- */
- public void testSqlQueryLocalClose() {
- SqlQuery<String, Person> qry = new SqlQuery<>(Person.class, SELECT_ALL_SQL);
-
- qry.setLocal(true);
-
- QueryCursor<Cache.Entry<String, Person>> qryCurs = cache().query(qry);
-
- qryCurs.iterator();
-
- qryCurs.close();
-
- H2ResultSetIterator h2It = extractIterableInnerH2ResultSetIterator(qryCurs);
-
- checkIterator(h2It);
- }
-
- /**
- * Local SQL check nullification after complete
- */
- public void testSqlQueryLocalComplete() {
- SqlQuery<String, Person> qry = new SqlQuery<>(Person.class, SELECT_ALL_SQL);
-
- qry.setLocal(true);
-
- QueryCursor<Cache.Entry<String, Person>> qryCurs = cache().query(qry);
-
- qryCurs.getAll();
-
- H2ResultSetIterator h2It = extractIterableInnerH2ResultSetIterator(qryCurs);
-
- checkIterator(h2It);
- }
-
- /**
* Non local SQL Fields check nullification after close
*/
public void testSqlFieldsQueryClose() {
@@ -200,45 +123,6 @@ public class H2ResultSetIteratorNullifyOnEndSelfTest extends GridCommonAbstractT
}
/**
- * Extract H2ResultSetIterator by reflection for non local SQL cases
- * @param qryCurs source cursor
- * @return target iterator or null of not extracted
- */
- private H2ResultSetIterator extractIteratorInnerGridIteratorInnerH2ResultSetIterator(
- QueryCursor<Cache.Entry<String, Person>> qryCurs) {
- if (QueryCursorImpl.class.isAssignableFrom(qryCurs.getClass())) {
- Iterator inner = GridTestUtils.getFieldValue(qryCurs, QueryCursorImpl.class, "iter");
-
- GridQueryCacheObjectsIterator it = GridTestUtils.getFieldValue(inner, inner.getClass(), "val$iter0");
-
- Iterator<List<?>> h2RsIt = GridTestUtils.getFieldValue(it, GridQueryCacheObjectsIterator.class, "iter");
-
- if (H2ResultSetIterator.class.isAssignableFrom(h2RsIt.getClass()))
- return (H2ResultSetIterator)h2RsIt;
- }
- return null;
- }
-
- /**
- * Extract H2ResultSetIterator by reflection for local SQL cases.
- *
- * @param qryCurs source cursor
- * @return target iterator or null of not extracted
- */
- private H2ResultSetIterator extractIterableInnerH2ResultSetIterator(
- QueryCursor<Cache.Entry<String, Person>> qryCurs) {
- if (QueryCursorImpl.class.isAssignableFrom(qryCurs.getClass())) {
- Iterable iterable = GridTestUtils.getFieldValue(qryCurs, QueryCursorImpl.class, "iterExec");
-
- Iterator h2RsIt = GridTestUtils.getFieldValue(iterable, iterable.getClass(), "val$i");
-
- if (H2ResultSetIterator.class.isAssignableFrom(h2RsIt.getClass()))
- return (H2ResultSetIterator)h2RsIt;
- }
- return null;
- }
-
- /**
* Extract H2ResultSetIterator by reflection for SQL Fields cases.
*
* @param qryCurs source cursor
@@ -256,67 +140,6 @@ public class H2ResultSetIteratorNullifyOnEndSelfTest extends GridCommonAbstractT
return null;
}
- /**
- * "onClose" should remove links to data.
- */
- public void testOnClose() {
- try {
- GridCloseableIterator it = indexing().queryLocalSql(
- indexing().schema(cache().getName()),
- cache().getName(),
- SELECT_ALL_SQL,
- null,
- Collections.emptySet(),
- "Person",
- null,
- null);
-
- if (H2ResultSetIterator.class.isAssignableFrom(it.getClass())) {
- H2ResultSetIterator h2it = (H2ResultSetIterator)it;
-
- h2it.onClose();
-
- assertNull(GridTestUtils.getFieldValue(h2it, H2ResultSetIterator.class, "data"));
- }
- else
- fail();
- }
- catch (IgniteCheckedException e) {
- fail(e.getMessage());
- }
- }
-
- /**
- * Complete iterate should remove links to data.
- */
- public void testOnComplete() {
- try {
- GridCloseableIterator it = indexing().queryLocalSql(
- indexing().schema(cache().getName()),
- cache().getName(),
- SELECT_ALL_SQL,
- null,
- Collections.emptySet(),
- "Person",
- null,
- null);
-
- if (H2ResultSetIterator.class.isAssignableFrom(it.getClass())) {
- H2ResultSetIterator h2it = (H2ResultSetIterator)it;
-
- while (h2it.onHasNext())
- h2it.onNext();
-
- assertNull(GridTestUtils.getFieldValue(h2it, H2ResultSetIterator.class, "data"));
- }
- else
- fail();
- }
- catch (IgniteCheckedException e) {
- fail(e.getMessage());
- }
- }
-
/** {@inheritDoc} */
@Override protected void beforeTestsStarted() throws Exception {
startGrids(NODES_COUNT);
@@ -336,15 +159,6 @@ public class H2ResultSetIteratorNullifyOnEndSelfTest extends GridCommonAbstractT
}
/**
- * @return H2 indexing instance.
- */
- private IgniteH2Indexing indexing() {
- GridQueryProcessor qryProcessor = grid(0).context().query();
-
- return GridTestUtils.getFieldValue(qryProcessor, GridQueryProcessor.class, "idx");
- }
-
- /**
* @return Cache.
*/
private IgniteCache<String, Person> cache() {
[10/13] ignite git commit: IGNITE-10293 Collect caches info only on
active cluster.
Posted by sb...@apache.org.
IGNITE-10293 Collect caches info only on active cluster.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/eed26bcf
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/eed26bcf
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/eed26bcf
Branch: refs/heads/ignite-10043
Commit: eed26bcfb26d58372459f84173c4d0969dc08c8a
Parents: a9c5aed
Author: Alexey Kuznetsov <ak...@apache.org>
Authored: Fri Nov 16 16:17:01 2018 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Fri Nov 16 16:17:01 2018 +0700
----------------------------------------------------------------------
.../ignite/internal/visor/node/VisorNodeDataCollectorJob.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/eed26bcf/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeDataCollectorJob.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeDataCollectorJob.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeDataCollectorJob.java
index 5fab8d1..9025ed0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeDataCollectorJob.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeDataCollectorJob.java
@@ -335,7 +335,8 @@ public class VisorNodeDataCollectorJob extends VisorJob<VisorNodeDataCollectorTa
if (debug)
start0 = log(ignite.log(), "Collected memory metrics", getClass(), start0);
- caches(res, arg);
+ if (ignite.cluster().active())
+ caches(res, arg);
if (debug)
start0 = log(ignite.log(), "Collected caches", getClass(), start0);